@galacean/engine-physics-physx 2.0.0-alpha.31 → 2.0.0-alpha.33

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/main.js CHANGED
@@ -849,6 +849,7 @@ function _create_class(Constructor, protoProps, staticProps) {
849
849
  this._boxGeometry = null;
850
850
  this._sphereGeometry = null;
851
851
  this._capsuleGeometry = null;
852
+ this._currentOnQuery = null;
852
853
  this._activeTriggers = new engine.DisorderedArray();
853
854
  this._contactEvents = [];
854
855
  this._contactEventCount = 0;
@@ -863,8 +864,11 @@ function _create_class(Constructor, protoProps, staticProps) {
863
864
  this._physXManager = physicsManager;
864
865
  var physX = physXPhysics._physX;
865
866
  this._pxRaycastHit = new physX.PxRaycastHit();
867
+ this._pxSweepHit = new physX.PxSweepHit();
866
868
  this._pxFilterData = new physX.PxQueryFilterData();
867
869
  this._pxFilterData.flags = new physX.PxQueryFlags(1 | 2 | 4);
870
+ this._pxRaycastSweepFilterData = new physX.PxQueryFilterData();
871
+ this._pxRaycastSweepFilterData.flags = new physX.PxQueryFlags(1 | 2 | 4 | 8);
868
872
  var triggerCallback = {
869
873
  onContactBegin: function(collision) {
870
874
  _this._bufferContactEvent(collision, 0);
@@ -899,6 +903,16 @@ function _create_class(Constructor, protoProps, staticProps) {
899
903
  var sceneDesc = physX.getDefaultSceneDesc(pxPhysics.getTolerancesScale(), 0, this._physXSimulationCallbackInstance);
900
904
  this._pxScene = pxPhysics.createScene(sceneDesc);
901
905
  sceneDesc.delete();
906
+ this._pxQueryCallback = physX.PxQueryFilterCallback.implement({
907
+ preFilter: function(_filterData, index, _actor) {
908
+ return _this._currentOnQuery(index) ? 2 : 0;
909
+ },
910
+ // distance <= 0 means initial overlap — drop the hit so subsequent hits can be considered.
911
+ // Only invoked when the query's filter data includes POST_FILTER (raycast/sweep, not overlap).
912
+ postFilter: function(_filterData, distance) {
913
+ return distance <= 0 ? 0 : 2;
914
+ }
915
+ });
902
916
  }
903
917
  var _proto = PhysXPhysicsScene.prototype;
904
918
  /**
@@ -987,18 +1001,14 @@ function _create_class(Constructor, protoProps, staticProps) {
987
1001
  */ _proto.raycast = function raycast(ray, distance, onRaycast, hit) {
988
1002
  var _this = this, pxHitResult = _this._pxRaycastHit;
989
1003
  distance = Math.min(distance, 3.4e38); // float32 max value limit in physX raycast.
990
- var raycastCallback = {
991
- preFilter: function(filterData, index, actor) {
992
- if (onRaycast(index)) {
993
- return 2; // eBLOCK
994
- } else {
995
- return 0; // eNONE
996
- }
997
- }
998
- };
999
- var pxRaycastCallback = this._physXPhysics._physX.PxQueryFilterCallback.implement(raycastCallback);
1000
- var result = this._pxScene.raycastSingle(ray.origin, ray.direction, distance, pxHitResult, this._pxFilterData, pxRaycastCallback);
1001
- pxRaycastCallback.delete();
1004
+ var prevOnQuery = this._currentOnQuery;
1005
+ this._currentOnQuery = onRaycast;
1006
+ var result;
1007
+ try {
1008
+ result = this._pxScene.raycastSingle(ray.origin, ray.direction, distance, pxHitResult, this._pxRaycastSweepFilterData, this._pxQueryCallback);
1009
+ } finally{
1010
+ this._currentOnQuery = prevOnQuery;
1011
+ }
1002
1012
  if (result && hit != undefined) {
1003
1013
  var position = PhysXPhysicsScene._tempPosition, normal = PhysXPhysicsScene._tempNormal;
1004
1014
  var pxPosition = pxHitResult.position, pxNormal = pxHitResult.normal;
@@ -1109,8 +1119,12 @@ function _create_class(Constructor, protoProps, staticProps) {
1109
1119
  (_this__capsuleGeometry = this._capsuleGeometry) == null ? void 0 : _this__capsuleGeometry.delete();
1110
1120
  this._physXSimulationCallbackInstance.delete();
1111
1121
  this._pxRaycastHit.delete();
1122
+ this._pxSweepHit.delete();
1112
1123
  this._pxFilterData.flags.delete();
1113
1124
  this._pxFilterData.delete();
1125
+ this._pxRaycastSweepFilterData.flags.delete();
1126
+ this._pxRaycastSweepFilterData.delete();
1127
+ this._pxQueryCallback.delete();
1114
1128
  (_this__pxControllerManager = this._pxControllerManager) == null ? void 0 : _this__pxControllerManager.release();
1115
1129
  this._pxScene.release();
1116
1130
  };
@@ -1147,19 +1161,16 @@ function _create_class(Constructor, protoProps, staticProps) {
1147
1161
  delete eventMap[id];
1148
1162
  };
1149
1163
  _proto._sweepSingle = function _sweepSingle(geometry, pose, direction, distance, onSweep, outHitResult) {
1164
+ var _this = this, pxSweepHit = _this._pxSweepHit;
1150
1165
  distance = Math.min(distance, 3.4e38); // float32 max value limit in physx sweep
1151
- var sweepCallback = {
1152
- preFilter: function(filterData, index, actor) {
1153
- if (onSweep(index)) {
1154
- return 2; // eBLOCK
1155
- } else {
1156
- return 0; // eNONE
1157
- }
1158
- }
1159
- };
1160
- var pxSweepCallback = this._physXPhysics._physX.PxQueryFilterCallback.implement(sweepCallback);
1161
- var pxSweepHit = new this._physXPhysics._physX.PxSweepHit();
1162
- var result = this._pxScene.sweepSingle(geometry, pose, direction, distance, pxSweepHit, this._pxFilterData, pxSweepCallback);
1166
+ var prevOnQuery = this._currentOnQuery;
1167
+ this._currentOnQuery = onSweep;
1168
+ var result;
1169
+ try {
1170
+ result = this._pxScene.sweepSingle(geometry, pose, direction, distance, pxSweepHit, this._pxRaycastSweepFilterData, this._pxQueryCallback);
1171
+ } finally{
1172
+ this._currentOnQuery = prevOnQuery;
1173
+ }
1163
1174
  if (result && outHitResult != undefined) {
1164
1175
  var position = PhysXPhysicsScene._tempPosition, normal = PhysXPhysicsScene._tempNormal;
1165
1176
  var pxPosition = pxSweepHit.position, pxNormal = pxSweepHit.normal;
@@ -1167,19 +1178,18 @@ function _create_class(Constructor, protoProps, staticProps) {
1167
1178
  normal.set(pxNormal.x, pxNormal.y, pxNormal.z);
1168
1179
  outHitResult(pxSweepHit.getShape().getUUID(), pxSweepHit.distance, position, normal);
1169
1180
  }
1170
- pxSweepCallback.delete();
1171
- pxSweepHit.delete();
1172
1181
  return result;
1173
1182
  };
1174
1183
  _proto._overlapMultiple = function _overlapMultiple(geometry, pose, onOverlap) {
1175
- var overlapCallback = {
1176
- preFilter: function(filterData, index, actor) {
1177
- return onOverlap(index) ? 2 : 0;
1178
- }
1179
- };
1180
- var pxOverlapCallback = this._physXPhysics._physX.PxQueryFilterCallback.implement(overlapCallback);
1184
+ var prevOnQuery = this._currentOnQuery;
1185
+ this._currentOnQuery = onOverlap;
1181
1186
  var maxHits = 256;
1182
- var hits = this._pxScene.overlapMultiple(geometry, pose, maxHits, this._pxFilterData, pxOverlapCallback);
1187
+ var hits;
1188
+ try {
1189
+ hits = this._pxScene.overlapMultiple(geometry, pose, maxHits, this._pxFilterData, this._pxQueryCallback);
1190
+ } finally{
1191
+ this._currentOnQuery = prevOnQuery;
1192
+ }
1183
1193
  var result = PhysXPhysicsScene._tempShapeIDs;
1184
1194
  result.length = 0;
1185
1195
  if (hits) {
@@ -1188,7 +1198,6 @@ function _create_class(Constructor, protoProps, staticProps) {
1188
1198
  result.push(hits.get(i).getShape().getUUID());
1189
1199
  }
1190
1200
  }
1191
- pxOverlapCallback.delete();
1192
1201
  hits == null ? void 0 : hits.delete();
1193
1202
  return result;
1194
1203
  };
@@ -1769,9 +1778,9 @@ PhysXMeshColliderShape._tightBoundsFlag = 1 // eTIGHT_BOUNDS = 1 (1<<0)
1769
1778
  this._initializeState = 0;
1770
1779
  this._runTimeMode = runtimeMode;
1771
1780
  var _runtimeUrls_wasmSIMDModeUrl;
1772
- this._wasmSIMDModeUrl = (_runtimeUrls_wasmSIMDModeUrl = runtimeUrls == null ? void 0 : runtimeUrls.wasmSIMDModeUrl) != null ? _runtimeUrls_wasmSIMDModeUrl : "https://mdn.alipayobjects.com/rms/afts/file/A*FHYHS4_ZL5UAAAAAQ4AAAAgAehQnAQ/physx.release.simd.js";
1781
+ this._wasmSIMDModeUrl = (_runtimeUrls_wasmSIMDModeUrl = runtimeUrls == null ? void 0 : runtimeUrls.wasmSIMDModeUrl) != null ? _runtimeUrls_wasmSIMDModeUrl : "https://mdn.alipayobjects.com/rms/afts/file/A*iHrYQKBrgTAAAAAAQ4AAAAgAehQnAQ/physx.release.simd.js";
1773
1782
  var _runtimeUrls_wasmModeUrl;
1774
- this._wasmModeUrl = (_runtimeUrls_wasmModeUrl = runtimeUrls == null ? void 0 : runtimeUrls.wasmModeUrl) != null ? _runtimeUrls_wasmModeUrl : "https://mdn.alipayobjects.com/rms/afts/file/A*2fv0RLMK1d0AAAAAQ4AAAAgAehQnAQ/physx.release.js";
1783
+ this._wasmModeUrl = (_runtimeUrls_wasmModeUrl = runtimeUrls == null ? void 0 : runtimeUrls.wasmModeUrl) != null ? _runtimeUrls_wasmModeUrl : "https://mdn.alipayobjects.com/rms/afts/file/A*DFuvR6Mv5C0AAAAAQ4AAAAgAehQnAQ/physx.release.js";
1775
1784
  }
1776
1785
  var _proto = PhysXPhysics.prototype;
1777
1786
  /**
@@ -1941,7 +1950,7 @@ PhysXMeshColliderShape._tightBoundsFlag = 1 // eTIGHT_BOUNDS = 1 (1<<0)
1941
1950
  }();
1942
1951
 
1943
1952
  //@ts-ignore
1944
- var version = "2.0.0-alpha.31";
1953
+ var version = "2.0.0-alpha.33";
1945
1954
  console.log("Galacean Engine Physics PhysX Version: " + version);
1946
1955
 
1947
1956
  exports.PhysXPhysics = PhysXPhysics;