11import {
2+ JoltRVec3_JoltVec3 ,
3+ JoltVec3_JoltRVec3 ,
24 JoltVec3_ThreeVector3 ,
35 MirabufFloatArr_JoltFloat3 ,
46 MirabufFloatArr_JoltVec3 ,
7+ MirabufVector3_JoltRVec3 ,
58 MirabufVector3_JoltVec3 ,
69 ThreeMatrix4_JoltMat44 ,
10+ ThreeVector3_JoltRVec3 ,
711 ThreeVector3_JoltVec3 ,
812 _JoltQuat ,
913} from "../../util/TypeConversions"
@@ -234,7 +238,7 @@ class PhysicsSystem extends WorldSystem {
234238 const shape = new JOLT . BoxShape ( size , 0.1 )
235239 JOLT . destroy ( size )
236240
237- const pos = position ? ThreeVector3_JoltVec3 ( position ) : new JOLT . Vec3 ( 0.0 , 0.0 , 0.0 )
241+ const pos = position ? ThreeVector3_JoltRVec3 ( position ) : new JOLT . RVec3 ( 0.0 , 0.0 , 0.0 )
238242 const rot = _JoltQuat ( rotation )
239243 const creationSettings = new JOLT . BodyCreationSettings (
240244 shape ,
@@ -269,7 +273,7 @@ class PhysicsSystem extends WorldSystem {
269273 position : THREE . Vector3 | undefined ,
270274 rotation : THREE . Euler | THREE . Quaternion | undefined
271275 ) {
272- const pos = position ? ThreeVector3_JoltVec3 ( position ) : new JOLT . Vec3 ( 0.0 , 0.0 , 0.0 )
276+ const pos = position ? ThreeVector3_JoltRVec3 ( position ) : new JOLT . RVec3 ( 0.0 , 0.0 , 0.0 )
273277 const rot = _JoltQuat ( rotation )
274278 const creationSettings = new JOLT . BodyCreationSettings (
275279 shape ,
@@ -464,14 +468,14 @@ class PhysicsSystem extends WorldSystem {
464468 const hingeConstraintSettings = new JOLT . HingeConstraintSettings ( )
465469
466470 const jointOrigin = jointDefinition . origin
467- ? MirabufVector3_JoltVec3 ( jointDefinition . origin as mirabuf . Vector3 )
468- : new JOLT . Vec3 ( 0 , 0 , 0 )
471+ ? MirabufVector3_JoltRVec3 ( jointDefinition . origin as mirabuf . Vector3 )
472+ : new JOLT . RVec3 ( 0 , 0 , 0 )
469473 // TODO: Offset transformation for robot builder.
470474 const jointOriginOffset = jointInstance . offset
471- ? MirabufVector3_JoltVec3 ( jointInstance . offset as mirabuf . Vector3 )
472- : new JOLT . Vec3 ( 0 , 0 , 0 )
475+ ? MirabufVector3_JoltRVec3 ( jointInstance . offset as mirabuf . Vector3 )
476+ : new JOLT . RVec3 ( 0 , 0 , 0 )
473477
474- const anchorPoint = jointOrigin . Add ( jointOriginOffset )
478+ const anchorPoint = jointOrigin . AddRVec3 ( jointOriginOffset )
475479 hingeConstraintSettings . mPoint1 = hingeConstraintSettings . mPoint2 = anchorPoint
476480
477481 const rotationalFreedom = jointDefinition . rotational ! . rotationalFreedom !
@@ -532,14 +536,14 @@ class PhysicsSystem extends WorldSystem {
532536 const sliderConstraintSettings = new JOLT . SliderConstraintSettings ( )
533537
534538 const jointOrigin = jointDefinition . origin
535- ? MirabufVector3_JoltVec3 ( jointDefinition . origin as mirabuf . Vector3 )
536- : new JOLT . Vec3 ( 0 , 0 , 0 )
539+ ? MirabufVector3_JoltRVec3 ( jointDefinition . origin as mirabuf . Vector3 )
540+ : new JOLT . RVec3 ( 0 , 0 , 0 )
537541 // TODO: Offset transformation for robot builder.
538542 const jointOriginOffset = jointInstance . offset
539- ? MirabufVector3_JoltVec3 ( jointInstance . offset as mirabuf . Vector3 )
540- : new JOLT . Vec3 ( 0 , 0 , 0 )
543+ ? MirabufVector3_JoltRVec3 ( jointInstance . offset as mirabuf . Vector3 )
544+ : new JOLT . RVec3 ( 0 , 0 , 0 )
541545
542- const anchorPoint = jointOrigin . Add ( jointOriginOffset )
546+ const anchorPoint = jointOrigin . AddRVec3 ( jointOriginOffset )
543547 sliderConstraintSettings . mPoint1 = sliderConstraintSettings . mPoint2 = anchorPoint
544548
545549 const prismaticFreedom = jointDefinition . prismatic ! . prismaticFreedom !
@@ -594,27 +598,27 @@ class PhysicsSystem extends WorldSystem {
594598 const fixedSettings = new JOLT . FixedConstraintSettings ( )
595599
596600 const jointOrigin = jointDefinition . origin
597- ? MirabufVector3_JoltVec3 ( jointDefinition . origin as mirabuf . Vector3 )
598- : new JOLT . Vec3 ( 0 , 0 , 0 )
601+ ? MirabufVector3_JoltRVec3 ( jointDefinition . origin as mirabuf . Vector3 )
602+ : new JOLT . RVec3 ( 0 , 0 , 0 )
599603 const jointOriginOffset = jointInstance . offset
600- ? MirabufVector3_JoltVec3 ( jointInstance . offset as mirabuf . Vector3 )
601- : new JOLT . Vec3 ( 0 , 0 , 0 )
604+ ? MirabufVector3_JoltRVec3 ( jointInstance . offset as mirabuf . Vector3 )
605+ : new JOLT . RVec3 ( 0 , 0 , 0 )
602606
603- const anchorPoint = jointOrigin . Add ( jointOriginOffset )
607+ const anchorPoint = jointOrigin . AddRVec3 ( jointOriginOffset )
604608 fixedSettings . mPoint1 = fixedSettings . mPoint2 = anchorPoint
605609
606610 const rotationalFreedom = jointDefinition . rotational ! . rotationalFreedom !
607611
608612 // No scaling, these are unit vectors
609613 const miraAxis = rotationalFreedom . axis ! as mirabuf . Vector3
610614 const miraAxisX : number = ( versionNum < 5 ? - miraAxis . x : miraAxis . x ) ?? 0
611- const axis : Jolt . Vec3 = new JOLT . Vec3 ( miraAxisX , miraAxis . y ?? 0 , miraAxis . z ?? 0 )
615+ const axis : Jolt . RVec3 = new JOLT . RVec3 ( miraAxisX , miraAxis . y ?? 0 , miraAxis . z ?? 0 )
612616
613617 const bounds = bodyWheel . GetShape ( ) . GetLocalBounds ( )
614618 const radius = ( bounds . mMax . GetY ( ) - bounds . mMin . GetY ( ) ) / 2.0
615619
616620 const wheelSettings = new JOLT . WheelSettingsWV ( )
617- wheelSettings . mPosition = anchorPoint . Add ( axis . Mul ( 0.1 ) )
621+ wheelSettings . mPosition = JoltRVec3_JoltVec3 ( anchorPoint . AddRVec3 ( axis . Mul ( 0.1 ) ) )
618622 wheelSettings . mMaxSteerAngle = 0.0
619623 wheelSettings . mMaxHandBrakeTorque = 0.0
620624 wheelSettings . mRadius = radius * 1.05
@@ -733,7 +737,7 @@ class PhysicsSystem extends WorldSystem {
733737 const c = constraints [ i ]
734738 const hingeSettings = new JOLT . HingeConstraintSettings ( )
735739 hingeSettings . mMaxFrictionTorque = c . friction
736- hingeSettings . mPoint1 = hingeSettings . mPoint2 = anchorPoint
740+ hingeSettings . mPoint1 = hingeSettings . mPoint2 = JoltVec3_JoltRVec3 ( anchorPoint )
737741 hingeSettings . mHingeAxis1 = hingeSettings . mHingeAxis2 = c . axis . Normalized ( )
738742 hingeSettings . mNormalAxis1 = hingeSettings . mNormalAxis2 = getPerpendicular ( hingeSettings . mHingeAxis1 )
739743 if ( c . upper && c . lower ) {
@@ -1029,7 +1033,7 @@ class PhysicsSystem extends WorldSystem {
10291033
10301034 const bodySettings = new JOLT . BodyCreationSettings (
10311035 shape ,
1032- new JOLT . Vec3 ( 0.0 , 0.0 , 0.0 ) ,
1036+ new JOLT . RVec3 ( 0.0 , 0.0 , 0.0 ) ,
10331037 new JOLT . Quat ( 0 , 0 , 0 , 1 ) ,
10341038 rn . isDynamic ? JOLT . EMotionType_Dynamic : JOLT . EMotionType_Static ,
10351039 rnLayer
@@ -1162,7 +1166,7 @@ class PhysicsSystem extends WorldSystem {
11621166 * @returns Either the hit results of the closest object in the ray's path, or undefined if nothing was hit.
11631167 */
11641168 public RayCast ( from : Jolt . Vec3 , dir : Jolt . Vec3 , ...ignoreBodies : Jolt . BodyID [ ] ) : RayCastHit | undefined {
1165- const ray = new JOLT . RayCast ( from , dir )
1169+ const ray = new JOLT . RRayCast ( JoltVec3_JoltRVec3 ( from ) , dir )
11661170
11671171 const raySettings = new JOLT . RayCastSettings ( )
11681172 raySettings . mTreatConvexAsSolid = false
@@ -1181,7 +1185,7 @@ class PhysicsSystem extends WorldSystem {
11811185 if ( ! collector . HadHit ( ) ) return undefined
11821186
11831187 const hitPoint = ray . GetPointOnRay ( collector . mHit . mFraction )
1184- return { data : collector . mHit , point : hitPoint , ray : ray }
1188+ return { data : collector . mHit , point : JoltRVec3_JoltVec3 ( hitPoint ) , ray : ray }
11851189 }
11861190
11871191 /**
@@ -1287,7 +1291,7 @@ class PhysicsSystem extends WorldSystem {
12871291 const rot = new JOLT . Quat ( 0 , 0 , 0 , 1 )
12881292 const creationSettings = new JOLT . BodyCreationSettings (
12891293 shape ,
1290- position ,
1294+ JoltVec3_JoltRVec3 ( position ) ,
12911295 rot ,
12921296 JOLT . EMotionType_Dynamic ,
12931297 LAYER_GHOST
@@ -1326,8 +1330,7 @@ class PhysicsSystem extends WorldSystem {
13261330 this . _bodies . push ( ghostBodyId )
13271331
13281332 const constraintSettings = new JOLT . PointConstraintSettings ( )
1329- constraintSettings . set_mPoint1 ( anchorPoint )
1330- constraintSettings . set_mPoint2 ( anchorPoint )
1333+ constraintSettings . mPoint1 = constraintSettings . mPoint2 = JoltVec3_JoltRVec3 ( anchorPoint )
13311334 const constraint = constraintSettings . Create ( ghostBody , body )
13321335 this . _joltPhysSystem . AddConstraint ( constraint )
13331336 this . _constraints . push ( constraint )
@@ -1610,7 +1613,7 @@ function tryGetPerpendicular(vec: Jolt.Vec3, toCheck: Jolt.Vec3): Jolt.Vec3 | un
16101613export type RayCastHit = {
16111614 data : Jolt . RayCastResult
16121615 point : Jolt . Vec3
1613- ray : Jolt . RayCast
1616+ ray : Jolt . RRayCast
16141617}
16151618
16161619/**
0 commit comments