@galacean/engine-physics-physx 2.0.0-alpha.5 → 2.0.0-alpha.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +218 -122
- package/dist/browser.js.map +1 -1
- package/dist/browser.min.js +1 -1
- package/dist/browser.min.js.map +1 -1
- package/dist/main.js +218 -122
- package/dist/main.js.map +1 -1
- package/dist/module.js +218 -122
- package/dist/module.js.map +1 -1
- package/libs/physx.release.js +1 -1
- package/libs/physx.release.simd.js +1 -1
- package/libs/physx.release.simd.wasm +0 -0
- package/libs/physx.release.wasm +0 -0
- package/package.json +6 -5
- package/types/PhysXCharacterController.d.ts +23 -0
- package/types/PhysXCollider.d.ts +14 -0
- package/types/PhysXDynamicCollider.d.ts +6 -6
- package/types/PhysXPhysics.d.ts +12 -2
- package/types/PhysXPhysicsManager.d.ts +3 -0
- package/types/PhysXPhysicsMaterial.d.ts +2 -0
- package/types/PhysXPhysicsScene.d.ts +44 -24
- package/types/shape/PhysXBoxColliderShape.d.ts +2 -0
- package/types/shape/PhysXCapsuleColliderShape.d.ts +6 -0
- package/types/shape/PhysXColliderShape.d.ts +25 -3
package/dist/browser.js
CHANGED
|
@@ -297,7 +297,8 @@
|
|
|
297
297
|
/**
|
|
298
298
|
* {@inheritDoc ICapsuleColliderShape.setUpAxis }
|
|
299
299
|
*/ _proto.setUpAxis = function setUpAxis(upAxis) {
|
|
300
|
-
var _this = this, rotation = _this._rotation,
|
|
300
|
+
var _this = this, rotation = _this._rotation, physXRotation = _this._physXRotation;
|
|
301
|
+
var axis = this._axis;
|
|
301
302
|
this._upAxis = upAxis;
|
|
302
303
|
switch(this._upAxis){
|
|
303
304
|
case 0:
|
|
@@ -525,7 +526,9 @@
|
|
|
525
526
|
* {@inheritDoc ICollider.addShape }
|
|
526
527
|
*/ _proto.addShape = function addShape(shape) {
|
|
527
528
|
var _this__scene;
|
|
528
|
-
this._pxActor.attachShape(shape._pxShape)
|
|
529
|
+
if (!this._pxActor.attachShape(shape._pxShape)) {
|
|
530
|
+
throw new Error("PhysXCollider: failed to attach shape to the native actor.");
|
|
531
|
+
}
|
|
529
532
|
this._shapes.push(shape);
|
|
530
533
|
(_this__scene = this._scene) == null ? void 0 : _this__scene._addColliderShape(shape._id);
|
|
531
534
|
};
|
|
@@ -674,44 +677,27 @@
|
|
|
674
677
|
this._pxActor.setSolverIterationCounts(value, 1);
|
|
675
678
|
};
|
|
676
679
|
/**
|
|
677
|
-
* {@inheritDoc IDynamicCollider.setCollisionDetectionMode }
|
|
678
|
-
*/ _proto.setCollisionDetectionMode = function setCollisionDetectionMode(value) {
|
|
679
|
-
var physX = this._physXPhysics._physX;
|
|
680
|
-
switch(value){
|
|
681
|
-
case 1:
|
|
682
|
-
this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eENABLE_CCD, true);
|
|
683
|
-
this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eENABLE_CCD_FRICTION, false);
|
|
684
|
-
this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eENABLE_SPECULATIVE_CCD, false);
|
|
685
|
-
break;
|
|
686
|
-
case 2:
|
|
687
|
-
this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eENABLE_CCD, true);
|
|
688
|
-
this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eENABLE_CCD_FRICTION, true);
|
|
689
|
-
this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eENABLE_SPECULATIVE_CCD, false);
|
|
690
|
-
break;
|
|
691
|
-
case 3:
|
|
692
|
-
this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eENABLE_CCD, false);
|
|
693
|
-
this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eENABLE_CCD_FRICTION, false);
|
|
694
|
-
this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eENABLE_SPECULATIVE_CCD, true);
|
|
695
|
-
break;
|
|
696
|
-
case 0:
|
|
697
|
-
this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eENABLE_CCD, false);
|
|
698
|
-
this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eENABLE_CCD_FRICTION, false);
|
|
699
|
-
this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eENABLE_SPECULATIVE_CCD, false);
|
|
700
|
-
break;
|
|
701
|
-
}
|
|
702
|
-
};
|
|
703
|
-
/**
|
|
704
680
|
* {@inheritDoc IDynamicCollider.setUseGravity }
|
|
705
681
|
*/ _proto.setUseGravity = function setUseGravity(value) {
|
|
706
682
|
this._pxActor.setActorFlag(this._physXPhysics._physX.PxActorFlag.eDISABLE_GRAVITY, !value);
|
|
707
683
|
};
|
|
708
684
|
/**
|
|
709
|
-
* {@inheritDoc IDynamicCollider.
|
|
710
|
-
*/ _proto.
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
685
|
+
* {@inheritDoc IDynamicCollider.setMotionState }
|
|
686
|
+
*/ _proto.setMotionState = function setMotionState(isKinematic, collisionDetectionMode) {
|
|
687
|
+
var PxRigidBodyFlag = this._physXPhysics._physX.PxRigidBodyFlag;
|
|
688
|
+
// PhysX 4.1 does not support sweep-based CCD on kinematic bodies
|
|
689
|
+
var useSpeculativeCCD = collisionDetectionMode === 3 || isKinematic && collisionDetectionMode !== 0;
|
|
690
|
+
this._pxActor.setRigidBodyFlag(PxRigidBodyFlag.eENABLE_CCD, false);
|
|
691
|
+
this._pxActor.setRigidBodyFlag(PxRigidBodyFlag.eENABLE_CCD_FRICTION, false);
|
|
692
|
+
this._pxActor.setRigidBodyFlag(PxRigidBodyFlag.eENABLE_SPECULATIVE_CCD, false);
|
|
693
|
+
this._pxActor.setRigidBodyFlag(PxRigidBodyFlag.eKINEMATIC, isKinematic);
|
|
694
|
+
if (useSpeculativeCCD) {
|
|
695
|
+
this._pxActor.setRigidBodyFlag(PxRigidBodyFlag.eENABLE_SPECULATIVE_CCD, true);
|
|
696
|
+
} else if (collisionDetectionMode !== 0) {
|
|
697
|
+
this._pxActor.setRigidBodyFlag(PxRigidBodyFlag.eENABLE_CCD, true);
|
|
698
|
+
if (collisionDetectionMode === 2) {
|
|
699
|
+
this._pxActor.setRigidBodyFlag(PxRigidBodyFlag.eENABLE_CCD_FRICTION, true);
|
|
700
|
+
}
|
|
715
701
|
}
|
|
716
702
|
};
|
|
717
703
|
/**
|
|
@@ -722,20 +708,17 @@
|
|
|
722
708
|
/**
|
|
723
709
|
* {@inheritDoc IDynamicCollider.addForce }
|
|
724
710
|
*/ _proto.addForce = function addForce(force) {
|
|
725
|
-
this._pxActor.addForce(
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
711
|
+
this._pxActor.addForce(force);
|
|
712
|
+
};
|
|
713
|
+
/**
|
|
714
|
+
* {@inheritDoc IDynamicCollider.addForceAtPosition }
|
|
715
|
+
*/ _proto.addForceAtPosition = function addForceAtPosition(force, position) {
|
|
716
|
+
this._pxActor.addForceAtPos(force, position);
|
|
730
717
|
};
|
|
731
718
|
/**
|
|
732
719
|
* {@inheritDoc IDynamicCollider.addTorque }
|
|
733
720
|
*/ _proto.addTorque = function addTorque(torque) {
|
|
734
|
-
this._pxActor.addTorque(
|
|
735
|
-
x: torque.x,
|
|
736
|
-
y: torque.y,
|
|
737
|
-
z: torque.z
|
|
738
|
-
});
|
|
721
|
+
this._pxActor.addTorque(torque);
|
|
739
722
|
};
|
|
740
723
|
/**
|
|
741
724
|
* {@inheritDoc IDynamicCollider.move }
|
|
@@ -821,44 +804,68 @@
|
|
|
821
804
|
return PhysXPhysicsMaterial;
|
|
822
805
|
}();
|
|
823
806
|
|
|
807
|
+
function _defineProperties(target, props) {
|
|
808
|
+
for (var i = 0; i < props.length; i++) {
|
|
809
|
+
var descriptor = props[i];
|
|
810
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
811
|
+
descriptor.configurable = true;
|
|
812
|
+
|
|
813
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
814
|
+
|
|
815
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
819
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
820
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
821
|
+
|
|
822
|
+
return Constructor;
|
|
823
|
+
}
|
|
824
|
+
|
|
824
825
|
/**
|
|
825
826
|
* A manager is a collection of colliders and constraints which can interact.
|
|
826
827
|
*/ var PhysXPhysicsScene = /*#__PURE__*/ function() {
|
|
827
|
-
function PhysXPhysicsScene(physXPhysics, physicsManager
|
|
828
|
+
function PhysXPhysicsScene(physXPhysics, physicsManager) {
|
|
828
829
|
var _this = this;
|
|
829
830
|
/** @internal */ this._pxControllerManager = null;
|
|
830
831
|
// Cached geometry objects for reuse
|
|
831
832
|
this._boxGeometry = null;
|
|
832
833
|
this._sphereGeometry = null;
|
|
833
834
|
this._capsuleGeometry = null;
|
|
834
|
-
this.
|
|
835
|
-
this.
|
|
835
|
+
this._currentOnQuery = null;
|
|
836
|
+
this._activeTriggers = new engine.DisorderedArray();
|
|
837
|
+
this._contactEvents = [];
|
|
838
|
+
this._contactEventCount = 0;
|
|
839
|
+
this._triggerEvents = [];
|
|
840
|
+
this._physicsEvents = {
|
|
841
|
+
contactEvents: [],
|
|
842
|
+
contactEventCount: 0,
|
|
843
|
+
triggerEvents: []
|
|
844
|
+
};
|
|
845
|
+
this._triggerEventPool = [];
|
|
836
846
|
this._physXPhysics = physXPhysics;
|
|
837
847
|
this._physXManager = physicsManager;
|
|
838
848
|
var physX = physXPhysics._physX;
|
|
839
849
|
this._pxRaycastHit = new physX.PxRaycastHit();
|
|
850
|
+
this._pxSweepHit = new physX.PxSweepHit();
|
|
840
851
|
this._pxFilterData = new physX.PxQueryFilterData();
|
|
841
852
|
this._pxFilterData.flags = new physX.PxQueryFlags(1 | 2 | 4);
|
|
842
|
-
this.
|
|
843
|
-
this.
|
|
844
|
-
this._onContactStay = onContactStay;
|
|
845
|
-
this._onTriggerEnter = onTriggerEnter;
|
|
846
|
-
this._onTriggerExit = onTriggerExit;
|
|
847
|
-
this._onTriggerStay = onTriggerStay;
|
|
853
|
+
this._pxRaycastSweepFilterData = new physX.PxQueryFilterData();
|
|
854
|
+
this._pxRaycastSweepFilterData.flags = new physX.PxQueryFlags(1 | 2 | 4 | 8);
|
|
848
855
|
var triggerCallback = {
|
|
849
856
|
onContactBegin: function(collision) {
|
|
850
|
-
_this.
|
|
857
|
+
_this._bufferContactEvent(collision, 0);
|
|
851
858
|
},
|
|
852
859
|
onContactEnd: function(collision) {
|
|
853
|
-
_this.
|
|
860
|
+
_this._bufferContactEvent(collision, 2);
|
|
854
861
|
},
|
|
855
862
|
onContactPersist: function(collision) {
|
|
856
|
-
_this.
|
|
863
|
+
_this._bufferContactEvent(collision, 1);
|
|
857
864
|
},
|
|
858
865
|
onTriggerBegin: function(index1, index2) {
|
|
859
866
|
var event = index1 < index2 ? _this._getTrigger(index1, index2) : _this._getTrigger(index2, index1);
|
|
860
867
|
event.state = 0;
|
|
861
|
-
_this.
|
|
868
|
+
_this._activeTriggers.add(event);
|
|
862
869
|
},
|
|
863
870
|
onTriggerEnd: function(index1, index2) {
|
|
864
871
|
var event;
|
|
@@ -879,6 +886,16 @@
|
|
|
879
886
|
var sceneDesc = physX.getDefaultSceneDesc(pxPhysics.getTolerancesScale(), 0, this._physXSimulationCallbackInstance);
|
|
880
887
|
this._pxScene = pxPhysics.createScene(sceneDesc);
|
|
881
888
|
sceneDesc.delete();
|
|
889
|
+
this._pxQueryCallback = physX.PxQueryFilterCallback.implement({
|
|
890
|
+
preFilter: function(_filterData, index, _actor) {
|
|
891
|
+
return _this._currentOnQuery(index) ? 2 : 0;
|
|
892
|
+
},
|
|
893
|
+
// distance <= 0 means initial overlap — drop the hit so subsequent hits can be considered.
|
|
894
|
+
// Only invoked when the query's filter data includes POST_FILTER (raycast/sweep, not overlap).
|
|
895
|
+
postFilter: function(_filterData, distance) {
|
|
896
|
+
return distance <= 0 ? 0 : 2;
|
|
897
|
+
}
|
|
898
|
+
});
|
|
882
899
|
}
|
|
883
900
|
var _proto = PhysXPhysicsScene.prototype;
|
|
884
901
|
/**
|
|
@@ -936,27 +953,53 @@
|
|
|
936
953
|
/**
|
|
937
954
|
* {@inheritDoc IPhysicsScene.update }
|
|
938
955
|
*/ _proto.update = function update(elapsedTime) {
|
|
956
|
+
this._contactEventCount = 0;
|
|
939
957
|
this._simulate(elapsedTime);
|
|
940
958
|
this._fetchResults();
|
|
941
|
-
|
|
959
|
+
};
|
|
960
|
+
/**
|
|
961
|
+
* {@inheritDoc IPhysicsScene.setContactEventEnabled }
|
|
962
|
+
*/ _proto.setContactEventEnabled = function setContactEventEnabled(enabled) {
|
|
963
|
+
this._physXPhysics._physX.setContactEventEnabled(this._physXSimulationCallbackInstance, enabled);
|
|
964
|
+
if (!enabled) {
|
|
965
|
+
this._contactEventCount = 0;
|
|
966
|
+
}
|
|
967
|
+
};
|
|
968
|
+
/**
|
|
969
|
+
* {@inheritDoc IPhysicsScene.updateEvents }
|
|
970
|
+
*/ _proto.updateEvents = function updateEvents() {
|
|
971
|
+
var physicsEvents = this._physicsEvents;
|
|
972
|
+
// Collect trigger events: snapshot state for dispatch, then advance
|
|
973
|
+
var _this = this, triggerEventPool = _this._triggerEventPool, activeTriggers = _this._activeTriggers, triggerEvents = _this._triggerEvents;
|
|
974
|
+
triggerEvents.length = 0;
|
|
975
|
+
activeTriggers.forEach(function(event, i) {
|
|
976
|
+
event.dispatchState = event.state;
|
|
977
|
+
triggerEvents.push(event);
|
|
978
|
+
if (event.state === 0) {
|
|
979
|
+
event.state = 1;
|
|
980
|
+
} else if (event.state === 2) {
|
|
981
|
+
activeTriggers.deleteByIndex(i);
|
|
982
|
+
triggerEventPool.push(event);
|
|
983
|
+
}
|
|
984
|
+
});
|
|
985
|
+
physicsEvents.contactEvents = this._contactEvents;
|
|
986
|
+
physicsEvents.contactEventCount = this._contactEventCount;
|
|
987
|
+
physicsEvents.triggerEvents = triggerEvents;
|
|
988
|
+
return physicsEvents;
|
|
942
989
|
};
|
|
943
990
|
/**
|
|
944
991
|
* {@inheritDoc IPhysicsScene.raycast }
|
|
945
|
-
*/ _proto.raycast = function raycast(
|
|
992
|
+
*/ _proto.raycast = function raycast(origin, direction, distance, onRaycast, hit) {
|
|
946
993
|
var _this = this, pxHitResult = _this._pxRaycastHit;
|
|
947
994
|
distance = Math.min(distance, 3.4e38); // float32 max value limit in physX raycast.
|
|
948
|
-
var
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
};
|
|
957
|
-
var pxRaycastCallback = this._physXPhysics._physX.PxQueryFilterCallback.implement(raycastCallback);
|
|
958
|
-
var result = this._pxScene.raycastSingle(ray.origin, ray.direction, distance, pxHitResult, this._pxFilterData, pxRaycastCallback);
|
|
959
|
-
pxRaycastCallback.delete();
|
|
995
|
+
var prevOnQuery = this._currentOnQuery;
|
|
996
|
+
this._currentOnQuery = onRaycast;
|
|
997
|
+
var result;
|
|
998
|
+
try {
|
|
999
|
+
result = this._pxScene.raycastSingle(origin, direction, distance, pxHitResult, this._pxRaycastSweepFilterData, this._pxQueryCallback);
|
|
1000
|
+
} finally{
|
|
1001
|
+
this._currentOnQuery = prevOnQuery;
|
|
1002
|
+
}
|
|
960
1003
|
if (result && hit != undefined) {
|
|
961
1004
|
var position = PhysXPhysicsScene._tempPosition, normal = PhysXPhysicsScene._tempNormal;
|
|
962
1005
|
var pxPosition = pxHitResult.position, pxNormal = pxHitResult.normal;
|
|
@@ -1053,6 +1096,11 @@
|
|
|
1053
1096
|
return this._overlapMultiple(this._capsuleGeometry, pose, onOverlap);
|
|
1054
1097
|
};
|
|
1055
1098
|
/**
|
|
1099
|
+
* {@inheritDoc IPhysicsScene.gc }
|
|
1100
|
+
*/ _proto.gc = function gc() {
|
|
1101
|
+
this._contactEvents.length = this._contactEventCount;
|
|
1102
|
+
};
|
|
1103
|
+
/**
|
|
1056
1104
|
* {@inheritDoc IPhysicsScene.destroy }
|
|
1057
1105
|
*/ _proto.destroy = function destroy() {
|
|
1058
1106
|
var _this__boxGeometry, _this__sphereGeometry, _this__capsuleGeometry, // Need to release the controller manager before release the scene.
|
|
@@ -1062,8 +1110,12 @@
|
|
|
1062
1110
|
(_this__capsuleGeometry = this._capsuleGeometry) == null ? void 0 : _this__capsuleGeometry.delete();
|
|
1063
1111
|
this._physXSimulationCallbackInstance.delete();
|
|
1064
1112
|
this._pxRaycastHit.delete();
|
|
1113
|
+
this._pxSweepHit.delete();
|
|
1065
1114
|
this._pxFilterData.flags.delete();
|
|
1066
1115
|
this._pxFilterData.delete();
|
|
1116
|
+
this._pxRaycastSweepFilterData.flags.delete();
|
|
1117
|
+
this._pxRaycastSweepFilterData.delete();
|
|
1118
|
+
this._pxQueryCallback.delete();
|
|
1067
1119
|
(_this__pxControllerManager = this._pxControllerManager) == null ? void 0 : _this__pxControllerManager.release();
|
|
1068
1120
|
this._pxScene.release();
|
|
1069
1121
|
};
|
|
@@ -1084,15 +1136,15 @@
|
|
|
1084
1136
|
/**
|
|
1085
1137
|
* @internal
|
|
1086
1138
|
*/ _proto._removeColliderShape = function _removeColliderShape(id) {
|
|
1087
|
-
var _this = this,
|
|
1139
|
+
var _this = this, triggerEventPool = _this._triggerEventPool, activeTriggers = _this._activeTriggers;
|
|
1088
1140
|
var _this__physXManager = this._physXManager, eventMap = _this__physXManager._eventMap;
|
|
1089
|
-
|
|
1141
|
+
activeTriggers.forEach(function(event, i) {
|
|
1090
1142
|
if (event.index1 == id) {
|
|
1091
|
-
|
|
1092
|
-
|
|
1143
|
+
activeTriggers.deleteByIndex(i);
|
|
1144
|
+
triggerEventPool.push(event);
|
|
1093
1145
|
} else if (event.index2 == id) {
|
|
1094
|
-
|
|
1095
|
-
|
|
1146
|
+
activeTriggers.deleteByIndex(i);
|
|
1147
|
+
triggerEventPool.push(event);
|
|
1096
1148
|
// If the shape is big index, should clear from the small index shape subMap
|
|
1097
1149
|
eventMap[event.index1][id] = undefined;
|
|
1098
1150
|
}
|
|
@@ -1100,19 +1152,16 @@
|
|
|
1100
1152
|
delete eventMap[id];
|
|
1101
1153
|
};
|
|
1102
1154
|
_proto._sweepSingle = function _sweepSingle(geometry, pose, direction, distance, onSweep, outHitResult) {
|
|
1155
|
+
var _this = this, pxSweepHit = _this._pxSweepHit;
|
|
1103
1156
|
distance = Math.min(distance, 3.4e38); // float32 max value limit in physx sweep
|
|
1104
|
-
var
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
};
|
|
1113
|
-
var pxSweepCallback = this._physXPhysics._physX.PxQueryFilterCallback.implement(sweepCallback);
|
|
1114
|
-
var pxSweepHit = new this._physXPhysics._physX.PxSweepHit();
|
|
1115
|
-
var result = this._pxScene.sweepSingle(geometry, pose, direction, distance, pxSweepHit, this._pxFilterData, pxSweepCallback);
|
|
1157
|
+
var prevOnQuery = this._currentOnQuery;
|
|
1158
|
+
this._currentOnQuery = onSweep;
|
|
1159
|
+
var result;
|
|
1160
|
+
try {
|
|
1161
|
+
result = this._pxScene.sweepSingle(geometry, pose, direction, distance, pxSweepHit, this._pxRaycastSweepFilterData, this._pxQueryCallback);
|
|
1162
|
+
} finally{
|
|
1163
|
+
this._currentOnQuery = prevOnQuery;
|
|
1164
|
+
}
|
|
1116
1165
|
if (result && outHitResult != undefined) {
|
|
1117
1166
|
var position = PhysXPhysicsScene._tempPosition, normal = PhysXPhysicsScene._tempNormal;
|
|
1118
1167
|
var pxPosition = pxSweepHit.position, pxNormal = pxSweepHit.normal;
|
|
@@ -1120,19 +1169,18 @@
|
|
|
1120
1169
|
normal.set(pxNormal.x, pxNormal.y, pxNormal.z);
|
|
1121
1170
|
outHitResult(pxSweepHit.getShape().getUUID(), pxSweepHit.distance, position, normal);
|
|
1122
1171
|
}
|
|
1123
|
-
pxSweepCallback.delete();
|
|
1124
|
-
pxSweepHit.delete();
|
|
1125
1172
|
return result;
|
|
1126
1173
|
};
|
|
1127
1174
|
_proto._overlapMultiple = function _overlapMultiple(geometry, pose, onOverlap) {
|
|
1128
|
-
var
|
|
1129
|
-
|
|
1130
|
-
return onOverlap(index) ? 2 : 0;
|
|
1131
|
-
}
|
|
1132
|
-
};
|
|
1133
|
-
var pxOverlapCallback = this._physXPhysics._physX.PxQueryFilterCallback.implement(overlapCallback);
|
|
1175
|
+
var prevOnQuery = this._currentOnQuery;
|
|
1176
|
+
this._currentOnQuery = onOverlap;
|
|
1134
1177
|
var maxHits = 256;
|
|
1135
|
-
var hits
|
|
1178
|
+
var hits;
|
|
1179
|
+
try {
|
|
1180
|
+
hits = this._pxScene.overlapMultiple(geometry, pose, maxHits, this._pxFilterData, this._pxQueryCallback);
|
|
1181
|
+
} finally{
|
|
1182
|
+
this._currentOnQuery = prevOnQuery;
|
|
1183
|
+
}
|
|
1136
1184
|
var result = PhysXPhysicsScene._tempShapeIDs;
|
|
1137
1185
|
result.length = 0;
|
|
1138
1186
|
if (hits) {
|
|
@@ -1141,7 +1189,6 @@
|
|
|
1141
1189
|
result.push(hits.get(i).getShape().getUUID());
|
|
1142
1190
|
}
|
|
1143
1191
|
}
|
|
1144
|
-
pxOverlapCallback.delete();
|
|
1145
1192
|
hits == null ? void 0 : hits.delete();
|
|
1146
1193
|
return result;
|
|
1147
1194
|
};
|
|
@@ -1154,8 +1201,8 @@
|
|
|
1154
1201
|
};
|
|
1155
1202
|
_proto._getTrigger = function _getTrigger(index1, index2) {
|
|
1156
1203
|
var event;
|
|
1157
|
-
if (this.
|
|
1158
|
-
event = this.
|
|
1204
|
+
if (this._triggerEventPool.length) {
|
|
1205
|
+
event = this._triggerEventPool.pop();
|
|
1159
1206
|
event.index1 = index1;
|
|
1160
1207
|
event.index2 = index2;
|
|
1161
1208
|
} else {
|
|
@@ -1164,21 +1211,27 @@
|
|
|
1164
1211
|
this._physXManager._eventMap[index1][index2] = event;
|
|
1165
1212
|
return event;
|
|
1166
1213
|
};
|
|
1167
|
-
_proto.
|
|
1168
|
-
var
|
|
1169
|
-
var
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1214
|
+
_proto._bufferContactEvent = function _bufferContactEvent(collision, state) {
|
|
1215
|
+
var _this__contactEvents, _index;
|
|
1216
|
+
var index = this._contactEventCount++;
|
|
1217
|
+
var event = (_this__contactEvents = this._contactEvents)[_index = index] || (_this__contactEvents[_index] = new ContactEvent());
|
|
1218
|
+
event.shape0Id = collision.shape0Id;
|
|
1219
|
+
event.shape1Id = collision.shape1Id;
|
|
1220
|
+
event.state = state;
|
|
1221
|
+
// Copy contact points from PhysX (the native data is only valid during fetchResults)
|
|
1222
|
+
var nativeContacts = collision.getContacts();
|
|
1223
|
+
var count = nativeContacts.size();
|
|
1224
|
+
var bufferedContacts = event._bufferedContacts;
|
|
1225
|
+
bufferedContacts.contactCount = count;
|
|
1226
|
+
for(var i = 0; i < count; i++){
|
|
1227
|
+
var _bufferedContacts_contacts, _i;
|
|
1228
|
+
var src = nativeContacts.get(i);
|
|
1229
|
+
var dst = (_bufferedContacts_contacts = bufferedContacts.contacts)[_i = i] || (_bufferedContacts_contacts[_i] = new BufferedContactPoint());
|
|
1230
|
+
dst.position.copyFrom(src.position);
|
|
1231
|
+
dst.normal.copyFrom(src.normal);
|
|
1232
|
+
dst.impulse.copyFrom(src.impulse);
|
|
1233
|
+
dst.separation = src.separation;
|
|
1234
|
+
}
|
|
1182
1235
|
};
|
|
1183
1236
|
return PhysXPhysicsScene;
|
|
1184
1237
|
}();
|
|
@@ -1196,6 +1249,49 @@
|
|
|
1196
1249
|
this.index1 = index1;
|
|
1197
1250
|
this.index2 = index2;
|
|
1198
1251
|
};
|
|
1252
|
+
/**
|
|
1253
|
+
* Buffered contact point data, copied from PhysX during fetchResults.
|
|
1254
|
+
*/ var BufferedContactPoint = function BufferedContactPoint() {
|
|
1255
|
+
this.position = new engine.Vector3();
|
|
1256
|
+
this.normal = new engine.Vector3();
|
|
1257
|
+
this.impulse = new engine.Vector3();
|
|
1258
|
+
this.separation = 0;
|
|
1259
|
+
};
|
|
1260
|
+
/**
|
|
1261
|
+
* Contact event buffered from PhysX fetchResults callback.
|
|
1262
|
+
* Implements ICollision so it can be passed directly to the core layer.
|
|
1263
|
+
*/ var BufferedContacts = /*#__PURE__*/ function() {
|
|
1264
|
+
function BufferedContacts() {
|
|
1265
|
+
this.contactCount = 0;
|
|
1266
|
+
this.contacts = [];
|
|
1267
|
+
}
|
|
1268
|
+
var _proto = BufferedContacts.prototype;
|
|
1269
|
+
_proto.size = function size() {
|
|
1270
|
+
return this.contactCount;
|
|
1271
|
+
};
|
|
1272
|
+
_proto.get = function get(index) {
|
|
1273
|
+
return this.contacts[index];
|
|
1274
|
+
};
|
|
1275
|
+
return BufferedContacts;
|
|
1276
|
+
}();
|
|
1277
|
+
var ContactEvent = /*#__PURE__*/ function() {
|
|
1278
|
+
function ContactEvent() {
|
|
1279
|
+
/** @internal */ this._bufferedContacts = new BufferedContacts();
|
|
1280
|
+
}
|
|
1281
|
+
var _proto = ContactEvent.prototype;
|
|
1282
|
+
_proto.getContacts = function getContacts() {
|
|
1283
|
+
return this._bufferedContacts;
|
|
1284
|
+
};
|
|
1285
|
+
_create_class(ContactEvent, [
|
|
1286
|
+
{
|
|
1287
|
+
key: "contactCount",
|
|
1288
|
+
get: function get() {
|
|
1289
|
+
return this._bufferedContacts.contactCount;
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
]);
|
|
1293
|
+
return ContactEvent;
|
|
1294
|
+
}();
|
|
1199
1295
|
|
|
1200
1296
|
/**
|
|
1201
1297
|
* A static collider component that will not move.
|
|
@@ -1673,9 +1769,9 @@
|
|
|
1673
1769
|
this._initializeState = 0;
|
|
1674
1770
|
this._runTimeMode = runtimeMode;
|
|
1675
1771
|
var _runtimeUrls_wasmSIMDModeUrl;
|
|
1676
|
-
this._wasmSIMDModeUrl = (_runtimeUrls_wasmSIMDModeUrl = runtimeUrls == null ? void 0 : runtimeUrls.wasmSIMDModeUrl) != null ? _runtimeUrls_wasmSIMDModeUrl : "https://mdn.alipayobjects.com/rms/
|
|
1772
|
+
this._wasmSIMDModeUrl = (_runtimeUrls_wasmSIMDModeUrl = runtimeUrls == null ? void 0 : runtimeUrls.wasmSIMDModeUrl) != null ? _runtimeUrls_wasmSIMDModeUrl : "https://mdn.alipayobjects.com/rms/uri/file/as/apwallet/1787063975729/suyi/physx.release.simd.js";
|
|
1677
1773
|
var _runtimeUrls_wasmModeUrl;
|
|
1678
|
-
this._wasmModeUrl = (_runtimeUrls_wasmModeUrl = runtimeUrls == null ? void 0 : runtimeUrls.wasmModeUrl) != null ? _runtimeUrls_wasmModeUrl : "https://mdn.alipayobjects.com/rms/
|
|
1774
|
+
this._wasmModeUrl = (_runtimeUrls_wasmModeUrl = runtimeUrls == null ? void 0 : runtimeUrls.wasmModeUrl) != null ? _runtimeUrls_wasmModeUrl : "https://mdn.alipayobjects.com/rms/uri/file/as/apwallet/1787063975729/suyi/physx.release.js";
|
|
1679
1775
|
}
|
|
1680
1776
|
var _proto = PhysXPhysics.prototype;
|
|
1681
1777
|
/**
|
|
@@ -1740,8 +1836,8 @@
|
|
|
1740
1836
|
};
|
|
1741
1837
|
/**
|
|
1742
1838
|
* {@inheritDoc IPhysics.createPhysicsScene }
|
|
1743
|
-
*/ _proto.createPhysicsScene = function createPhysicsScene(physicsManager
|
|
1744
|
-
var scene = new PhysXPhysicsScene(this, physicsManager
|
|
1839
|
+
*/ _proto.createPhysicsScene = function createPhysicsScene(physicsManager) {
|
|
1840
|
+
var scene = new PhysXPhysicsScene(this, physicsManager);
|
|
1745
1841
|
return scene;
|
|
1746
1842
|
};
|
|
1747
1843
|
/**
|
|
@@ -1845,7 +1941,7 @@
|
|
|
1845
1941
|
}();
|
|
1846
1942
|
|
|
1847
1943
|
//@ts-ignore
|
|
1848
|
-
var version = "2.0.0-alpha.
|
|
1944
|
+
var version = "2.0.0-alpha.51";
|
|
1849
1945
|
console.log("Galacean Engine Physics PhysX Version: " + version);
|
|
1850
1946
|
|
|
1851
1947
|
exports.PhysXPhysics = PhysXPhysics;
|