@galacean/engine-physics-physx 1.4.15 → 1.4.16

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
@@ -123,12 +123,15 @@ function _inherits(subClass, superClass) {
123
123
  * {@inheritDoc IColliderShape.destroy }
124
124
  */ _proto.destroy = function destroy() {
125
125
  this._pxShape.release();
126
+ this._pxGeometry.delete();
126
127
  };
127
128
  /**
128
129
  * @internal
129
130
  */ _proto._setShapeFlags = function _setShapeFlags(flags) {
130
131
  this._shapeFlags = flags;
131
- this._pxShape.setFlags(new this._physXPhysics._physX.PxShapeFlags(this._shapeFlags));
132
+ var shapeFlags = new this._physXPhysics._physX.PxShapeFlags(this._shapeFlags);
133
+ this._pxShape.setFlags(shapeFlags);
134
+ shapeFlags.delete();
132
135
  };
133
136
  _proto._setLocalPose = function _setLocalPose() {
134
137
  var transform = PhysXColliderShape.transform;
@@ -139,7 +142,9 @@ function _inherits(subClass, superClass) {
139
142
  _proto._initialize = function _initialize(material, id) {
140
143
  this._id = id;
141
144
  this._pxMaterial = material._pxMaterial;
142
- this._pxShape = this._physXPhysics._pxPhysics.createShape(this._pxGeometry, material._pxMaterial, true, new this._physXPhysics._physX.PxShapeFlags(this._shapeFlags));
145
+ var shapeFlags = new this._physXPhysics._physX.PxShapeFlags(this._shapeFlags);
146
+ this._pxShape = this._physXPhysics._pxPhysics.createShape(this._pxGeometry, material._pxMaterial, true, shapeFlags);
147
+ shapeFlags.delete();
143
148
  this._pxShape.setUUID(id);
144
149
  };
145
150
  _proto._modifyFlag = function _modifyFlag(flag, value) {
@@ -429,6 +434,7 @@ PhysXBoxColliderShape._tempHalfExtents = new engine.Vector3();
429
434
  desc.setMaterial(shape._pxMaterial);
430
435
  this._pxController = pxManager._getControllerManager().createController(desc);
431
436
  this._pxController.setUUID(shape._id);
437
+ desc.delete();
432
438
  };
433
439
  /**
434
440
  * @internal
@@ -805,18 +811,19 @@ var PhysXPhysicsManager = function PhysXPhysicsManager() {
805
811
  }
806
812
  };
807
813
  var pxPhysics = physXPhysics._pxPhysics;
808
- var physXSimulationCallbackInstance = physX.PxSimulationEventCallback.implement(triggerCallback);
809
- var sceneDesc = physX.getDefaultSceneDesc(pxPhysics.getTolerancesScale(), 0, physXSimulationCallbackInstance);
814
+ this._physXSimulationCallbackInstance = physX.PxSimulationEventCallback.implement(triggerCallback);
815
+ var sceneDesc = physX.getDefaultSceneDesc(pxPhysics.getTolerancesScale(), 0, this._physXSimulationCallbackInstance);
810
816
  this._pxScene = pxPhysics.createScene(sceneDesc);
817
+ sceneDesc.delete();
811
818
  }
812
819
  var _proto = PhysXPhysicsScene.prototype;
813
820
  /**
814
- * {@inheritDoc IPhysicsManager.setGravity }
821
+ * {@inheritDoc IPhysicsScene.setGravity }
815
822
  */ _proto.setGravity = function setGravity(value) {
816
823
  this._pxScene.setGravity(value);
817
824
  };
818
825
  /**
819
- * {@inheritDoc IPhysicsManager.addCollider }
826
+ * {@inheritDoc IPhysicsScene.addCollider }
820
827
  */ _proto.addCollider = function addCollider(collider) {
821
828
  collider._scene = this;
822
829
  this._pxScene.addActor(collider._pxActor, null);
@@ -826,7 +833,7 @@ var PhysXPhysicsManager = function PhysXPhysicsManager() {
826
833
  }
827
834
  };
828
835
  /**
829
- * {@inheritDoc IPhysicsManager.removeCollider }
836
+ * {@inheritDoc IPhysicsScene.removeCollider }
830
837
  */ _proto.removeCollider = function removeCollider(collider) {
831
838
  collider._scene = null;
832
839
  this._pxScene.removeActor(collider._pxActor, true);
@@ -836,7 +843,7 @@ var PhysXPhysicsManager = function PhysXPhysicsManager() {
836
843
  }
837
844
  };
838
845
  /**
839
- * {@inheritDoc IPhysicsManager.addCharacterController }
846
+ * {@inheritDoc IPhysicsScene.addCharacterController }
840
847
  */ _proto.addCharacterController = function addCharacterController(characterController) {
841
848
  characterController._scene = this;
842
849
  // Physx have no API to remove/readd cct into scene.
@@ -854,7 +861,7 @@ var PhysXPhysicsManager = function PhysXPhysicsManager() {
854
861
  characterController._pxManager = this;
855
862
  };
856
863
  /**
857
- * {@inheritDoc IPhysicsManager.removeCharacterController }
864
+ * {@inheritDoc IPhysicsScene.removeCharacterController }
858
865
  */ _proto.removeCharacterController = function removeCharacterController(characterController) {
859
866
  characterController._scene = null;
860
867
  characterController._pxManager = null;
@@ -863,14 +870,14 @@ var PhysXPhysicsManager = function PhysXPhysicsManager() {
863
870
  shape && this._removeColliderShape(shape._id);
864
871
  };
865
872
  /**
866
- * {@inheritDoc IPhysicsManager.update }
873
+ * {@inheritDoc IPhysicsScene.update }
867
874
  */ _proto.update = function update(elapsedTime) {
868
875
  this._simulate(elapsedTime);
869
876
  this._fetchResults();
870
877
  this._fireEvent();
871
878
  };
872
879
  /**
873
- * {@inheritDoc IPhysicsManager.raycast }
880
+ * {@inheritDoc IPhysicsScene.raycast }
874
881
  */ _proto.raycast = function raycast(ray, distance, onRaycast, hit) {
875
882
  var _this = this, pxHitResult = _this._pxRaycastHit;
876
883
  distance = Math.min(distance, 3.4e38); // float32 max value limit in physx raycast.
@@ -884,7 +891,9 @@ var PhysXPhysicsManager = function PhysXPhysicsManager() {
884
891
  },
885
892
  postFilter: function(filterData, hit) {}
886
893
  };
887
- var result = this._pxScene.raycastSingle(ray.origin, ray.direction, distance, pxHitResult, this._pxFilterData, this._physXPhysics._physX.PxQueryFilterCallback.implement(raycastCallback));
894
+ var pxRaycastCallback = this._physXPhysics._physX.PxQueryFilterCallback.implement(raycastCallback);
895
+ var result = this._pxScene.raycastSingle(ray.origin, ray.direction, distance, pxHitResult, this._pxFilterData, pxRaycastCallback);
896
+ pxRaycastCallback.delete();
888
897
  if (result && hit != undefined) {
889
898
  var position = PhysXPhysicsScene._tempPosition, normal = PhysXPhysicsScene._tempNormal;
890
899
  var pxPosition = pxHitResult.position, pxNormal = pxHitResult.normal;
@@ -895,6 +904,17 @@ var PhysXPhysicsManager = function PhysXPhysicsManager() {
895
904
  return result;
896
905
  };
897
906
  /**
907
+ * {@inheritDoc IPhysicsScene.destroy }
908
+ */ _proto.destroy = function destroy() {
909
+ var _this__pxControllerManager;
910
+ this._pxScene.release();
911
+ this._physXSimulationCallbackInstance.delete();
912
+ this._pxRaycastHit.delete();
913
+ this._pxFilterData.flags.delete();
914
+ this._pxFilterData.delete();
915
+ (_this__pxControllerManager = this._pxControllerManager) == null ? void 0 : _this__pxControllerManager.release();
916
+ };
917
+ /**
898
918
  * @internal
899
919
  */ _proto._getControllerManager = function _getControllerManager() {
900
920
  var pxControllerManager = this._pxControllerManager;
@@ -906,7 +926,7 @@ var PhysXPhysicsManager = function PhysXPhysicsManager() {
906
926
  /**
907
927
  * @internal
908
928
  */ _proto._addColliderShape = function _addColliderShape(id) {
909
- this._physXManager._eventMap[id] = {};
929
+ this._physXManager._eventMap[id] = Object.create(null);
910
930
  };
911
931
  /**
912
932
  * @internal
@@ -1064,7 +1084,6 @@ PhysXPhysicsScene._tempNormal = new engine.Vector3();
1064
1084
  */ _proto.destroy = function destroy() {
1065
1085
  if (!this._pxJoint) return;
1066
1086
  this._pxJoint.release();
1067
- this._pxJoint = null;
1068
1087
  this._collider = null;
1069
1088
  };
1070
1089
  /**
@@ -1317,9 +1336,9 @@ PhysXHingeJoint._xAxis = new engine.Vector3(1, 0, 0);
1317
1336
  }
1318
1337
  }
1319
1338
  if (runtimeMode == PhysXRuntimeMode.JavaScript) {
1320
- script.src = "https://mdn.alipayobjects.com/rms/afts/file/A*PXxaQrGL0XsAAAAAAAAAAAAAARQnAQ/physx.release.downgrade.js";
1339
+ script.src = "https://mdn.alipayobjects.com/rms/afts/file/A*V4pqRqM65UMAAAAAAAAAAAAAARQnAQ/physx.release.downgrade.js";
1321
1340
  } else if (runtimeMode == PhysXRuntimeMode.WebAssembly) {
1322
- script.src = "https://mdn.alipayobjects.com/rms/afts/file/A*0Qq8Rob3_5oAAAAAAAAAAAAAARQnAQ/physx.release.js";
1341
+ script.src = "https://mdn.alipayobjects.com/rms/afts/file/A*jlLNQqp6mBsAAAAAAAAAAAAAARQnAQ/physx.release.js";
1323
1342
  }
1324
1343
  });
1325
1344
  var initializePromise = new Promise(function(resolve, reject) {
@@ -1342,9 +1361,9 @@ PhysXHingeJoint._xAxis = new engine.Vector3(1, 0, 0);
1342
1361
  this._physX.PxCloseExtensions();
1343
1362
  this._pxPhysics.release();
1344
1363
  this._pxFoundation.release();
1345
- this._physX = null;
1346
- this._pxFoundation = null;
1347
- this._pxPhysics = null;
1364
+ this._defaultErrorCallback.delete();
1365
+ this._allocator.delete();
1366
+ this._tolerancesScale.delete();
1348
1367
  };
1349
1368
  /**
1350
1369
  * {@inheritDoc IPhysics.createPhysicsManager }
@@ -1417,17 +1436,21 @@ PhysXHingeJoint._xAxis = new engine.Vector3(1, 0, 0);
1417
1436
  var defaultErrorCallback = new physX.PxDefaultErrorCallback();
1418
1437
  var allocator = new physX.PxDefaultAllocator();
1419
1438
  var pxFoundation = physX.PxCreateFoundation(version, allocator, defaultErrorCallback);
1420
- var pxPhysics = physX.PxCreatePhysics(version, pxFoundation, new physX.PxTolerancesScale(), false, null);
1439
+ var tolerancesScale = new physX.PxTolerancesScale();
1440
+ var pxPhysics = physX.PxCreatePhysics(version, pxFoundation, tolerancesScale, false, null);
1421
1441
  physX.PxInitExtensions(pxPhysics, null);
1422
1442
  this._physX = physX;
1423
1443
  this._pxFoundation = pxFoundation;
1424
1444
  this._pxPhysics = pxPhysics;
1445
+ this._defaultErrorCallback = defaultErrorCallback;
1446
+ this._allocator = allocator;
1447
+ this._tolerancesScale = tolerancesScale;
1425
1448
  };
1426
1449
  return PhysXPhysics;
1427
1450
  }();
1428
1451
 
1429
1452
  //@ts-ignore
1430
- var version = "1.4.15";
1453
+ var version = "1.4.16";
1431
1454
  console.log("Galacean Engine Physics PhysX Version: " + version);
1432
1455
 
1433
1456
  exports.PhysXPhysics = PhysXPhysics;