Jolt Patch

This commit is contained in:
2026-07-09 17:25:48 -07:00
parent cb19c9b5b4
commit 9d83c318b6
18 changed files with 2542 additions and 157 deletions

View File

@ -158,7 +158,9 @@ extern class Body {
public function IsSensor():Bool;
public function SetIsSensor(sensor:Bool):Void;
public function GetPosition():RVec3;
public function GetPositionInto(out:RVec3):Void;
public function GetRotation():Quat;
public function GetRotationInto(out:Quat):Void;
public function GetWorldTransform():Mat44;
public function GetCenterOfMassPosition():RVec3;
public function GetCenterOfMassTransform():Mat44;
@ -291,6 +293,7 @@ extern class MassProperties {
@:native('Jolt.BodyCreationSettings')
extern class BodyCreationSettings {
public function new(shape:Shape, position:RVec3, rotation:Quat, motionType:Int, objectLayer:Int):Void;
public var mObjectLayer:Int;
public var mFriction:Float;
public var mRestitution:Float;
public var mLinearDamping:Float;
@ -409,9 +412,70 @@ extern class ObjectLayerPairFilter {
public function new():Void;
}
@:native('Jolt.RayCastSettings')
extern class RayCastSettings {
public function new():Void;
}
@:native('Jolt.BroadPhaseLayerFilter')
extern class BroadPhaseLayerFilter {
public function new():Void;
}
@:native('Jolt.ObjectLayerFilter')
extern class ObjectLayerFilter {
public function new():Void;
}
@:native('Jolt.DefaultObjectLayerFilter')
extern class DefaultObjectLayerFilter extends ObjectLayerFilter {
public function new(objectLayerPairFilter:ObjectLayerPairFilter, objectLayer:Int):Void;
}
@:native('Jolt.BodyFilter')
extern class BodyFilter {
public function new():Void;
}
@:native('Jolt.ShapeFilter')
extern class ShapeFilter {
public function new():Void;
}
@:native('Jolt.CastRayCollector')
extern class CastRayCollector {
public function new():Void;
public function Reset():Void;
public function SetContext(context:Dynamic):Void;
public function GetContext():Dynamic;
public function UpdateEarlyOutFraction(fraction:Float):Void;
public function ResetEarlyOutFraction(fraction:Float = 1.0):Void;
public function ForceEarlyOut():Void;
public function ShouldEarlyOut():Bool;
public function GetEarlyOutFraction():Float;
public function GetPositiveEarlyOutFraction():Float;
}
@:native('Jolt.CastRayClosestHitCollisionCollector')
extern class CastRayClosestHitCollisionCollector extends CastRayCollector {
public function new():Void;
public function HadHit():Bool;
public var mHit:RayCastResult;
}
@:native('Jolt.BroadPhaseQuery')
extern class BroadPhaseQuery {
public function CastRay(ray:RRayCast, result:RayCastResult,
broadPhaseFilter:BroadPhaseLayerFilter,
objectLayerFilter:ObjectLayerFilter):Void;
}
@:native('Jolt.NarrowPhaseQuery')
extern class NarrowPhaseQuery {
public function CastRay(ray:RRayCast, result:RayCastResult):Bool;
public function CastRay(ray:RRayCast, settings:RayCastSettings,
collector:CastRayCollector, broadPhaseFilter:BroadPhaseLayerFilter,
objectLayerFilter:ObjectLayerFilter, bodyFilter:BodyFilter,
shapeFilter:ShapeFilter):Void;
}
@:native('Jolt.ContactListenerJS')
@ -440,6 +504,7 @@ extern class PhysicsSystem {
public function SetContactListener(listener:ContactListener):Void;
public function SetBodyActivationListener(listener:BodyActivationListener):Void;
public function GetNarrowPhaseQuery():NarrowPhaseQuery;
public function GetBroadPhaseQuery():BroadPhaseQuery;
public function AddConstraint(constraint:Constraint):Void;
public function RemoveConstraint(constraint:Constraint):Void;
}

View File

@ -156,7 +156,9 @@ interface Body {
int GetMotionType();
void SetMotionType(int inMotionType);
[Value] RVec3 GetPosition();
void GetPositionInto([Ref] RVec3 outPosition);
[Value] Quat GetRotation();
void GetRotationInto([Ref] Quat outRotation);
[Value] Mat44 GetWorldTransform();
[Value] RVec3 GetCenterOfMassPosition();
[Value] Mat44 GetCenterOfMassTransform();
@ -198,6 +200,7 @@ interface MassProperties {
// BodyCreationSettings
interface BodyCreationSettings {
void BodyCreationSettings([Const] Shape inShape, [Const, Ref] RVec3 inPosition, [Const, Ref] Quat inRotation, int inMotionType, short inObjectLayer);
attribute short mObjectLayer;
attribute float mFriction;
attribute float mRestitution;
attribute float mLinearDamping;
@ -273,9 +276,39 @@ interface RayCastResult {
attribute float mFraction;
};
// RayCastSettings
interface RayCastSettings {
void RayCastSettings();
};
// BroadPhaseLayerFilter
interface BroadPhaseLayerFilter {
void BroadPhaseLayerFilter();
};
// ObjectLayerFilter
interface ObjectLayerFilter {
void ObjectLayerFilter();
};
// BodyFilter
interface BodyFilter {
void BodyFilter();
};
// ShapeFilter
interface ShapeFilter {
void ShapeFilter();
};
// BroadPhaseQuery
interface BroadPhaseQuery {
void CastRay([Const, Ref] RRayCast inRay, [Ref] RayCastResult ioHit, [Const, Ref] BroadPhaseLayerFilter inBroadPhaseLayerFilter, [Const, Ref] ObjectLayerFilter inObjectLayerFilter);
};
// NarrowPhaseQuery
interface NarrowPhaseQuery {
boolean CastRay([Const, Ref] RRayCast inRay, [Ref] RayCastResult ioHit);
boolean CastRay([Const, Ref] RRayCast inRay, [Ref] RayCastResult ioHit, [Const, Ref] RayCastSettings inRayCastSettings, [Const, Ref] BroadPhaseLayerFilter inBroadPhaseLayerFilter, [Const, Ref] ObjectLayerFilter inObjectLayerFilter, [Const, Ref] BodyFilter inBodyFilter, [Const, Ref] ShapeFilter inShapeFilter);
};
// PhysicsSystem
@ -292,6 +325,7 @@ interface PhysicsSystem {
void SetGravity([Const, Ref] Vec3 inGravity);
[Value] Vec3 GetGravity();
[Const, Ref] NarrowPhaseQuery GetNarrowPhaseQuery();
[Const, Ref] BroadPhaseQuery GetBroadPhaseQuery();
void AddConstraint(Constraint inConstraint);
void RemoveConstraint(Constraint inConstraint);
};

View File

@ -214,7 +214,7 @@ class Module {
if( v.ret.t != TVoid )
e = { expr : EReturn(e), pos : p };
else if( isConstr )
e = macro this = $e;
e = macro this = untyped $e;
return e;
}

View File

@ -849,6 +849,16 @@ HL_PRIM void HL_NAME(BodyCreationSettings_set_mIsSensor)(_ref(BodyCreationSettin
}
DEFINE_PRIM(_VOID, BodyCreationSettings_set_mIsSensor, _IDL _BOOL);
HL_PRIM int HL_NAME(BodyCreationSettings_get_mObjectLayer)(_ref(BodyCreationSettings)* _this) {
return (int)_unref(_this)->mObjectLayer;
}
DEFINE_PRIM(_I32, BodyCreationSettings_get_mObjectLayer, _IDL);
HL_PRIM void HL_NAME(BodyCreationSettings_set_mObjectLayer)(_ref(BodyCreationSettings)* _this, int value) {
_unref(_this)->mObjectLayer = (ObjectLayer)value;
}
DEFINE_PRIM(_VOID, BodyCreationSettings_set_mObjectLayer, _IDL _I32);
// ============= BodyInterface =============
HL_PRIM _ref(Body)* HL_NAME(BodyInterface_CreateBody1)(_ref(BodyInterface)* _this, _ref(BodyCreationSettings)* settings) {
@ -1110,12 +1120,22 @@ HL_PRIM _ref(RVec3)* HL_NAME(Body_GetPosition0)(_ref(Body)* _this) {
}
DEFINE_PRIM(_IDL, Body_GetPosition0, _IDL);
HL_PRIM void HL_NAME(Body_GetPositionInto1)(_ref(Body)* _this, _ref(RVec3)* out) {
*_unref(out) = _unref(_this)->GetPosition();
}
DEFINE_PRIM(_VOID, Body_GetPositionInto1, _IDL _IDL);
HL_PRIM _ref(Quat)* HL_NAME(Body_GetRotation0)(_ref(Body)* _this) {
Quat rot = _unref(_this)->GetRotation();
return alloc_ref(new Quat(rot), Quat);
}
DEFINE_PRIM(_IDL, Body_GetRotation0, _IDL);
HL_PRIM void HL_NAME(Body_GetRotationInto1)(_ref(Body)* _this, _ref(Quat)* out) {
*_unref(out) = _unref(_this)->GetRotation();
}
DEFINE_PRIM(_VOID, Body_GetRotationInto1, _IDL _IDL);
HL_PRIM _ref(RVec3)* HL_NAME(Body_GetCenterOfMassPosition0)(_ref(Body)* _this) {
RVec3 pos = _unref(_this)->GetCenterOfMassPosition();
return alloc_ref(new RVec3(pos), RVec3);
@ -2385,6 +2405,66 @@ HL_PRIM void HL_NAME(SixDOFConstraintSettings_SetLimitedAxis3)(_ref(SixDOFConstr
}
DEFINE_PRIM(_VOID, SixDOFConstraintSettings_SetLimitedAxis3, _IDL _I32 _F32 _F32);
// ============= RayCastSettings =============
HL_PRIM _ref(RayCastSettings)* HL_NAME(RayCastSettings_new0)() {
return alloc_ref(new RayCastSettings(), RayCastSettings);
}
DEFINE_PRIM(_IDL, RayCastSettings_new0, _NO_ARG);
HL_PRIM void HL_NAME(RayCastSettings_delete)(_ref(RayCastSettings)* _this) {
free_ref(_this);
}
DEFINE_PRIM(_VOID, RayCastSettings_delete, _IDL);
// ============= BroadPhaseLayerFilter =============
HL_PRIM _ref(BroadPhaseLayerFilter)* HL_NAME(BroadPhaseLayerFilter_new0)() {
return alloc_ref(new BroadPhaseLayerFilter(), BroadPhaseLayerFilter);
}
DEFINE_PRIM(_IDL, BroadPhaseLayerFilter_new0, _NO_ARG);
HL_PRIM void HL_NAME(BroadPhaseLayerFilter_delete)(_ref(BroadPhaseLayerFilter)* _this) {
free_ref(_this);
}
DEFINE_PRIM(_VOID, BroadPhaseLayerFilter_delete, _IDL);
// ============= ObjectLayerFilter =============
HL_PRIM _ref(ObjectLayerFilter)* HL_NAME(ObjectLayerFilter_new0)() {
return alloc_ref(new ObjectLayerFilter(), ObjectLayerFilter);
}
DEFINE_PRIM(_IDL, ObjectLayerFilter_new0, _NO_ARG);
HL_PRIM void HL_NAME(ObjectLayerFilter_delete)(_ref(ObjectLayerFilter)* _this) {
free_ref(_this);
}
DEFINE_PRIM(_VOID, ObjectLayerFilter_delete, _IDL);
// ============= BodyFilter =============
HL_PRIM _ref(BodyFilter)* HL_NAME(BodyFilter_new0)() {
return alloc_ref(new BodyFilter(), BodyFilter);
}
DEFINE_PRIM(_IDL, BodyFilter_new0, _NO_ARG);
HL_PRIM void HL_NAME(BodyFilter_delete)(_ref(BodyFilter)* _this) {
free_ref(_this);
}
DEFINE_PRIM(_VOID, BodyFilter_delete, _IDL);
// ============= ShapeFilter =============
HL_PRIM _ref(ShapeFilter)* HL_NAME(ShapeFilter_new0)() {
return alloc_ref(new ShapeFilter(), ShapeFilter);
}
DEFINE_PRIM(_IDL, ShapeFilter_new0, _NO_ARG);
HL_PRIM void HL_NAME(ShapeFilter_delete)(_ref(ShapeFilter)* _this) {
free_ref(_this);
}
DEFINE_PRIM(_VOID, ShapeFilter_delete, _IDL);
// ============= NarrowPhaseQuery =============
HL_PRIM void HL_NAME(NarrowPhaseQuery_delete)(_ref(NarrowPhaseQuery)* _this) {
@ -2392,15 +2472,10 @@ HL_PRIM void HL_NAME(NarrowPhaseQuery_delete)(_ref(NarrowPhaseQuery)* _this) {
}
DEFINE_PRIM(_VOID, NarrowPhaseQuery_delete, _IDL);
HL_PRIM bool HL_NAME(NarrowPhaseQuery_CastRay2)(_ref(NarrowPhaseQuery)* _this, _ref(RRayCast)* ray, _ref(RayCastResult)* result) {
RayCastResult hit;
bool didHit = _unref(_this)->CastRay(*_unref(ray), hit);
if (didHit) {
*_unref(result) = hit;
}
return didHit;
HL_PRIM bool HL_NAME(NarrowPhaseQuery_CastRay7)(_ref(NarrowPhaseQuery)* _this, _ref(RRayCast)* ray, _ref(RayCastResult)* result, _ref(RayCastSettings)* settings, _ref(BroadPhaseLayerFilter)* broadPhaseFilter, _ref(ObjectLayerFilter)* objectLayerFilter, _ref(BodyFilter)* bodyFilter, _ref(ShapeFilter)* shapeFilter) {
return _unref(_this)->CastRay(*_unref(ray), *_unref(result), *_unref(broadPhaseFilter), *_unref(objectLayerFilter), *_unref(bodyFilter));
}
DEFINE_PRIM(_BOOL, NarrowPhaseQuery_CastRay2, _IDL _IDL _IDL);
DEFINE_PRIM(_BOOL, NarrowPhaseQuery_CastRay7, _IDL _IDL _IDL _IDL _IDL _IDL _IDL _IDL);
// ============= PhysicsSystem::GetNarrowPhaseQuery =============
@ -2409,4 +2484,23 @@ HL_PRIM _ref(NarrowPhaseQuery)* HL_NAME(PhysicsSystem_GetNarrowPhaseQuery0)(_ref
}
DEFINE_PRIM(_IDL, PhysicsSystem_GetNarrowPhaseQuery0, _IDL);
// ============= BroadPhaseQuery =============
HL_PRIM void HL_NAME(BroadPhaseQuery_delete)(_ref(BroadPhaseQuery)* _this) {
// BroadPhaseQuery is owned by PhysicsSystem, do not delete
}
DEFINE_PRIM(_VOID, BroadPhaseQuery_delete, _IDL);
HL_PRIM void HL_NAME(BroadPhaseQuery_CastRay4)(_ref(BroadPhaseQuery)* _this, _ref(RRayCast)* ray, _ref(RayCastResult)* result, _ref(BroadPhaseLayerFilter)* broadPhaseFilter, _ref(ObjectLayerFilter)* objectLayerFilter) {
// BroadPhaseQuery::CastRay API mismatch - RayCastBodyCollector required, not RayCastResult. Not used from Haxe.
}
DEFINE_PRIM(_VOID, BroadPhaseQuery_CastRay4, _IDL _IDL _IDL _IDL _IDL);
// ============= PhysicsSystem::GetBroadPhaseQuery =============
HL_PRIM _ref(BroadPhaseQuery)* HL_NAME(PhysicsSystem_GetBroadPhaseQuery0)(_ref(PhysicsSystem)* _this) {
return const_cast<BroadPhaseQuery*>(&_unref(_this)->GetBroadPhaseQuery());
}
DEFINE_PRIM(_IDL, PhysicsSystem_GetBroadPhaseQuery0, _IDL);
} // extern "C"

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -10,7 +10,20 @@ project.cppStd = 'c++17';
if (platform === Platform.Windows || platform === Platform.Linux) {
project.addDefine('JPH_USE_SSE4_1');
project.addDefine('JPH_USE_SSE4_2');
if (process.env.JOLT_USE_AVX2) {
project.addDefine('JPH_USE_AVX2');
}
}
if (platform === Platform.Windows) {
project.addCppFlag('/O2');
project.addCppFlag('/Ot');
if (process.env.JOLT_USE_AVX2) {
project.addCppFlag('/arch:AVX2');
}
project.addCppFlag('/Ob1');
}
project.addDefine('JPH_NO_DEBUG');
project.addDefine('NDEBUG');
resolve(project);