@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/browser.js +44 -21
- 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 +44 -21
- package/dist/main.js.map +1 -1
- package/dist/module.js +44 -21
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/PhysXPhysics.d.ts +3 -0
- package/types/PhysXPhysicsScene.d.ts +12 -7
package/dist/module.js
CHANGED
|
@@ -119,12 +119,15 @@ function _inherits(subClass, superClass) {
|
|
|
119
119
|
* {@inheritDoc IColliderShape.destroy }
|
|
120
120
|
*/ _proto.destroy = function destroy() {
|
|
121
121
|
this._pxShape.release();
|
|
122
|
+
this._pxGeometry.delete();
|
|
122
123
|
};
|
|
123
124
|
/**
|
|
124
125
|
* @internal
|
|
125
126
|
*/ _proto._setShapeFlags = function _setShapeFlags(flags) {
|
|
126
127
|
this._shapeFlags = flags;
|
|
127
|
-
|
|
128
|
+
var shapeFlags = new this._physXPhysics._physX.PxShapeFlags(this._shapeFlags);
|
|
129
|
+
this._pxShape.setFlags(shapeFlags);
|
|
130
|
+
shapeFlags.delete();
|
|
128
131
|
};
|
|
129
132
|
_proto._setLocalPose = function _setLocalPose() {
|
|
130
133
|
var transform = PhysXColliderShape.transform;
|
|
@@ -135,7 +138,9 @@ function _inherits(subClass, superClass) {
|
|
|
135
138
|
_proto._initialize = function _initialize(material, id) {
|
|
136
139
|
this._id = id;
|
|
137
140
|
this._pxMaterial = material._pxMaterial;
|
|
138
|
-
|
|
141
|
+
var shapeFlags = new this._physXPhysics._physX.PxShapeFlags(this._shapeFlags);
|
|
142
|
+
this._pxShape = this._physXPhysics._pxPhysics.createShape(this._pxGeometry, material._pxMaterial, true, shapeFlags);
|
|
143
|
+
shapeFlags.delete();
|
|
139
144
|
this._pxShape.setUUID(id);
|
|
140
145
|
};
|
|
141
146
|
_proto._modifyFlag = function _modifyFlag(flag, value) {
|
|
@@ -425,6 +430,7 @@ PhysXBoxColliderShape._tempHalfExtents = new Vector3();
|
|
|
425
430
|
desc.setMaterial(shape._pxMaterial);
|
|
426
431
|
this._pxController = pxManager._getControllerManager().createController(desc);
|
|
427
432
|
this._pxController.setUUID(shape._id);
|
|
433
|
+
desc.delete();
|
|
428
434
|
};
|
|
429
435
|
/**
|
|
430
436
|
* @internal
|
|
@@ -801,18 +807,19 @@ var PhysXPhysicsManager = function PhysXPhysicsManager() {
|
|
|
801
807
|
}
|
|
802
808
|
};
|
|
803
809
|
var pxPhysics = physXPhysics._pxPhysics;
|
|
804
|
-
|
|
805
|
-
var sceneDesc = physX.getDefaultSceneDesc(pxPhysics.getTolerancesScale(), 0,
|
|
810
|
+
this._physXSimulationCallbackInstance = physX.PxSimulationEventCallback.implement(triggerCallback);
|
|
811
|
+
var sceneDesc = physX.getDefaultSceneDesc(pxPhysics.getTolerancesScale(), 0, this._physXSimulationCallbackInstance);
|
|
806
812
|
this._pxScene = pxPhysics.createScene(sceneDesc);
|
|
813
|
+
sceneDesc.delete();
|
|
807
814
|
}
|
|
808
815
|
var _proto = PhysXPhysicsScene.prototype;
|
|
809
816
|
/**
|
|
810
|
-
* {@inheritDoc
|
|
817
|
+
* {@inheritDoc IPhysicsScene.setGravity }
|
|
811
818
|
*/ _proto.setGravity = function setGravity(value) {
|
|
812
819
|
this._pxScene.setGravity(value);
|
|
813
820
|
};
|
|
814
821
|
/**
|
|
815
|
-
* {@inheritDoc
|
|
822
|
+
* {@inheritDoc IPhysicsScene.addCollider }
|
|
816
823
|
*/ _proto.addCollider = function addCollider(collider) {
|
|
817
824
|
collider._scene = this;
|
|
818
825
|
this._pxScene.addActor(collider._pxActor, null);
|
|
@@ -822,7 +829,7 @@ var PhysXPhysicsManager = function PhysXPhysicsManager() {
|
|
|
822
829
|
}
|
|
823
830
|
};
|
|
824
831
|
/**
|
|
825
|
-
* {@inheritDoc
|
|
832
|
+
* {@inheritDoc IPhysicsScene.removeCollider }
|
|
826
833
|
*/ _proto.removeCollider = function removeCollider(collider) {
|
|
827
834
|
collider._scene = null;
|
|
828
835
|
this._pxScene.removeActor(collider._pxActor, true);
|
|
@@ -832,7 +839,7 @@ var PhysXPhysicsManager = function PhysXPhysicsManager() {
|
|
|
832
839
|
}
|
|
833
840
|
};
|
|
834
841
|
/**
|
|
835
|
-
* {@inheritDoc
|
|
842
|
+
* {@inheritDoc IPhysicsScene.addCharacterController }
|
|
836
843
|
*/ _proto.addCharacterController = function addCharacterController(characterController) {
|
|
837
844
|
characterController._scene = this;
|
|
838
845
|
// Physx have no API to remove/readd cct into scene.
|
|
@@ -850,7 +857,7 @@ var PhysXPhysicsManager = function PhysXPhysicsManager() {
|
|
|
850
857
|
characterController._pxManager = this;
|
|
851
858
|
};
|
|
852
859
|
/**
|
|
853
|
-
* {@inheritDoc
|
|
860
|
+
* {@inheritDoc IPhysicsScene.removeCharacterController }
|
|
854
861
|
*/ _proto.removeCharacterController = function removeCharacterController(characterController) {
|
|
855
862
|
characterController._scene = null;
|
|
856
863
|
characterController._pxManager = null;
|
|
@@ -859,14 +866,14 @@ var PhysXPhysicsManager = function PhysXPhysicsManager() {
|
|
|
859
866
|
shape && this._removeColliderShape(shape._id);
|
|
860
867
|
};
|
|
861
868
|
/**
|
|
862
|
-
* {@inheritDoc
|
|
869
|
+
* {@inheritDoc IPhysicsScene.update }
|
|
863
870
|
*/ _proto.update = function update(elapsedTime) {
|
|
864
871
|
this._simulate(elapsedTime);
|
|
865
872
|
this._fetchResults();
|
|
866
873
|
this._fireEvent();
|
|
867
874
|
};
|
|
868
875
|
/**
|
|
869
|
-
* {@inheritDoc
|
|
876
|
+
* {@inheritDoc IPhysicsScene.raycast }
|
|
870
877
|
*/ _proto.raycast = function raycast(ray, distance, onRaycast, hit) {
|
|
871
878
|
var _this = this, pxHitResult = _this._pxRaycastHit;
|
|
872
879
|
distance = Math.min(distance, 3.4e38); // float32 max value limit in physx raycast.
|
|
@@ -880,7 +887,9 @@ var PhysXPhysicsManager = function PhysXPhysicsManager() {
|
|
|
880
887
|
},
|
|
881
888
|
postFilter: function(filterData, hit) {}
|
|
882
889
|
};
|
|
883
|
-
var
|
|
890
|
+
var pxRaycastCallback = this._physXPhysics._physX.PxQueryFilterCallback.implement(raycastCallback);
|
|
891
|
+
var result = this._pxScene.raycastSingle(ray.origin, ray.direction, distance, pxHitResult, this._pxFilterData, pxRaycastCallback);
|
|
892
|
+
pxRaycastCallback.delete();
|
|
884
893
|
if (result && hit != undefined) {
|
|
885
894
|
var position = PhysXPhysicsScene._tempPosition, normal = PhysXPhysicsScene._tempNormal;
|
|
886
895
|
var pxPosition = pxHitResult.position, pxNormal = pxHitResult.normal;
|
|
@@ -891,6 +900,17 @@ var PhysXPhysicsManager = function PhysXPhysicsManager() {
|
|
|
891
900
|
return result;
|
|
892
901
|
};
|
|
893
902
|
/**
|
|
903
|
+
* {@inheritDoc IPhysicsScene.destroy }
|
|
904
|
+
*/ _proto.destroy = function destroy() {
|
|
905
|
+
var _this__pxControllerManager;
|
|
906
|
+
this._pxScene.release();
|
|
907
|
+
this._physXSimulationCallbackInstance.delete();
|
|
908
|
+
this._pxRaycastHit.delete();
|
|
909
|
+
this._pxFilterData.flags.delete();
|
|
910
|
+
this._pxFilterData.delete();
|
|
911
|
+
(_this__pxControllerManager = this._pxControllerManager) == null ? void 0 : _this__pxControllerManager.release();
|
|
912
|
+
};
|
|
913
|
+
/**
|
|
894
914
|
* @internal
|
|
895
915
|
*/ _proto._getControllerManager = function _getControllerManager() {
|
|
896
916
|
var pxControllerManager = this._pxControllerManager;
|
|
@@ -902,7 +922,7 @@ var PhysXPhysicsManager = function PhysXPhysicsManager() {
|
|
|
902
922
|
/**
|
|
903
923
|
* @internal
|
|
904
924
|
*/ _proto._addColliderShape = function _addColliderShape(id) {
|
|
905
|
-
this._physXManager._eventMap[id] =
|
|
925
|
+
this._physXManager._eventMap[id] = Object.create(null);
|
|
906
926
|
};
|
|
907
927
|
/**
|
|
908
928
|
* @internal
|
|
@@ -1060,7 +1080,6 @@ PhysXPhysicsScene._tempNormal = new Vector3();
|
|
|
1060
1080
|
*/ _proto.destroy = function destroy() {
|
|
1061
1081
|
if (!this._pxJoint) return;
|
|
1062
1082
|
this._pxJoint.release();
|
|
1063
|
-
this._pxJoint = null;
|
|
1064
1083
|
this._collider = null;
|
|
1065
1084
|
};
|
|
1066
1085
|
/**
|
|
@@ -1313,9 +1332,9 @@ PhysXHingeJoint._xAxis = new Vector3(1, 0, 0);
|
|
|
1313
1332
|
}
|
|
1314
1333
|
}
|
|
1315
1334
|
if (runtimeMode == PhysXRuntimeMode.JavaScript) {
|
|
1316
|
-
script.src = "https://mdn.alipayobjects.com/rms/afts/file/A*
|
|
1335
|
+
script.src = "https://mdn.alipayobjects.com/rms/afts/file/A*V4pqRqM65UMAAAAAAAAAAAAAARQnAQ/physx.release.downgrade.js";
|
|
1317
1336
|
} else if (runtimeMode == PhysXRuntimeMode.WebAssembly) {
|
|
1318
|
-
script.src = "https://mdn.alipayobjects.com/rms/afts/file/A*
|
|
1337
|
+
script.src = "https://mdn.alipayobjects.com/rms/afts/file/A*jlLNQqp6mBsAAAAAAAAAAAAAARQnAQ/physx.release.js";
|
|
1319
1338
|
}
|
|
1320
1339
|
});
|
|
1321
1340
|
var initializePromise = new Promise(function(resolve, reject) {
|
|
@@ -1338,9 +1357,9 @@ PhysXHingeJoint._xAxis = new Vector3(1, 0, 0);
|
|
|
1338
1357
|
this._physX.PxCloseExtensions();
|
|
1339
1358
|
this._pxPhysics.release();
|
|
1340
1359
|
this._pxFoundation.release();
|
|
1341
|
-
this.
|
|
1342
|
-
this.
|
|
1343
|
-
this.
|
|
1360
|
+
this._defaultErrorCallback.delete();
|
|
1361
|
+
this._allocator.delete();
|
|
1362
|
+
this._tolerancesScale.delete();
|
|
1344
1363
|
};
|
|
1345
1364
|
/**
|
|
1346
1365
|
* {@inheritDoc IPhysics.createPhysicsManager }
|
|
@@ -1413,17 +1432,21 @@ PhysXHingeJoint._xAxis = new Vector3(1, 0, 0);
|
|
|
1413
1432
|
var defaultErrorCallback = new physX.PxDefaultErrorCallback();
|
|
1414
1433
|
var allocator = new physX.PxDefaultAllocator();
|
|
1415
1434
|
var pxFoundation = physX.PxCreateFoundation(version, allocator, defaultErrorCallback);
|
|
1416
|
-
var
|
|
1435
|
+
var tolerancesScale = new physX.PxTolerancesScale();
|
|
1436
|
+
var pxPhysics = physX.PxCreatePhysics(version, pxFoundation, tolerancesScale, false, null);
|
|
1417
1437
|
physX.PxInitExtensions(pxPhysics, null);
|
|
1418
1438
|
this._physX = physX;
|
|
1419
1439
|
this._pxFoundation = pxFoundation;
|
|
1420
1440
|
this._pxPhysics = pxPhysics;
|
|
1441
|
+
this._defaultErrorCallback = defaultErrorCallback;
|
|
1442
|
+
this._allocator = allocator;
|
|
1443
|
+
this._tolerancesScale = tolerancesScale;
|
|
1421
1444
|
};
|
|
1422
1445
|
return PhysXPhysics;
|
|
1423
1446
|
}();
|
|
1424
1447
|
|
|
1425
1448
|
//@ts-ignore
|
|
1426
|
-
var version = "1.4.
|
|
1449
|
+
var version = "1.4.16";
|
|
1427
1450
|
console.log("Galacean Engine Physics PhysX Version: " + version);
|
|
1428
1451
|
|
|
1429
1452
|
export { PhysXPhysics, PhysXRuntimeMode, version };
|