@galacean/engine-physics-physx 0.0.0-experimental-2.0-game.19 → 0.0.0-experimental-2.0-migrate.2
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 +72 -46
- 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 +72 -46
- package/dist/main.js.map +1 -1
- package/dist/module.js +72 -46
- package/dist/module.js.map +1 -1
- package/libs/physx.release.simd.wasm +0 -0
- package/libs/physx.release.wasm +0 -0
- package/package.json +4 -4
- package/types/PhysXDynamicCollider.d.ts +5 -1
- package/types/PhysXPhysics.d.ts +1 -0
- package/types/index.d.ts +1 -0
package/dist/browser.js
CHANGED
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
*/ var PhysXColliderShape = /*#__PURE__*/ function() {
|
|
50
50
|
function PhysXColliderShape(physXPhysics) {
|
|
51
51
|
/** @internal */ this._controllers = new engine.DisorderedArray();
|
|
52
|
-
/** @internal */ this.
|
|
52
|
+
/** @internal */ this._contactOffset = 0.02;
|
|
53
53
|
/** @internal */ this._worldScale = new engine.Vector3(1, 1, 1);
|
|
54
54
|
/** @internal */ this._position = new engine.Vector3();
|
|
55
55
|
/** @internal */ this._rotation = new engine.Vector3();
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
this._physXRotation = new engine.Quaternion();
|
|
58
58
|
this._shapeFlags = 2 | 1;
|
|
59
59
|
this._physXPhysics = physXPhysics;
|
|
60
|
-
this.
|
|
60
|
+
this._contactOffset = physXPhysics.getDefaultContactOffset();
|
|
61
61
|
}
|
|
62
62
|
var _proto = PhysXColliderShape.prototype;
|
|
63
63
|
/**
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
* {@inheritDoc IColliderShape.setContactOffset }
|
|
96
96
|
* @default 0.02f * PxTolerancesScale::length
|
|
97
97
|
*/ _proto.setContactOffset = function setContactOffset(offset) {
|
|
98
|
-
this.
|
|
98
|
+
this._contactOffset = offset;
|
|
99
99
|
var controllers = this._controllers;
|
|
100
100
|
if (controllers.length) {
|
|
101
101
|
for(var i = 0, n = controllers.length; i < n; i++){
|
|
@@ -436,7 +436,7 @@
|
|
|
436
436
|
this._pxManager && this._createPXController(this._pxManager, shape);
|
|
437
437
|
this._shape = shape;
|
|
438
438
|
shape._controllers.add(this);
|
|
439
|
-
(_this__pxController = this._pxController) == null ? void 0 : _this__pxController.setContactOffset(shape.
|
|
439
|
+
(_this__pxController = this._pxController) == null ? void 0 : _this__pxController.setContactOffset(shape._contactOffset);
|
|
440
440
|
(_this__scene = this._scene) == null ? void 0 : _this__scene._addColliderShape(shape._id);
|
|
441
441
|
};
|
|
442
442
|
/**
|
|
@@ -679,7 +679,7 @@
|
|
|
679
679
|
};
|
|
680
680
|
/**
|
|
681
681
|
* {@inheritDoc IDynamicCollider.setSleepThreshold }
|
|
682
|
-
* @default
|
|
682
|
+
* @default 5e-5f * PxTolerancesScale::speed * PxTolerancesScale::speed
|
|
683
683
|
*/ _proto.setSleepThreshold = function setSleepThreshold(value) {
|
|
684
684
|
this._pxActor.setSleepThreshold(value);
|
|
685
685
|
};
|
|
@@ -768,11 +768,12 @@
|
|
|
768
768
|
* autowake=true)`,PhysX 自动唤醒(已通过 `applyForce on sleeping actor` 测试验证)。
|
|
769
769
|
*/ _proto.addForce = function addForce(force) {
|
|
770
770
|
if (this._isKinematic) return;
|
|
771
|
-
this._pxActor.addForce(
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
771
|
+
this._pxActor.addForce(force);
|
|
772
|
+
};
|
|
773
|
+
/**
|
|
774
|
+
* {@inheritDoc IDynamicCollider.addForceAtPosition }
|
|
775
|
+
*/ _proto.addForceAtPosition = function addForceAtPosition(force, position) {
|
|
776
|
+
this._pxActor.addForceAtPos(force, position);
|
|
776
777
|
};
|
|
777
778
|
/**
|
|
778
779
|
* {@inheritDoc IDynamicCollider.addTorque }
|
|
@@ -780,11 +781,7 @@
|
|
|
780
781
|
* 同 addForce — kinematic 提前 return,sleeping 由 PhysX autowake 自动处理。
|
|
781
782
|
*/ _proto.addTorque = function addTorque(torque) {
|
|
782
783
|
if (this._isKinematic) return;
|
|
783
|
-
this._pxActor.addTorque(
|
|
784
|
-
x: torque.x,
|
|
785
|
-
y: torque.y,
|
|
786
|
-
z: torque.z
|
|
787
|
-
});
|
|
784
|
+
this._pxActor.addTorque(torque);
|
|
788
785
|
};
|
|
789
786
|
/**
|
|
790
787
|
* {@inheritDoc IDynamicCollider.move }
|
|
@@ -1642,7 +1639,8 @@
|
|
|
1642
1639
|
var _this;
|
|
1643
1640
|
_this = PhysXColliderShape.call(this, physXPhysics) || this, _this._pxMesh = null;
|
|
1644
1641
|
_this._isConvex = isConvex;
|
|
1645
|
-
|
|
1642
|
+
var cooked = _this._cookMesh(positions, indices, isConvex, cookingFlags);
|
|
1643
|
+
if (!cooked) {
|
|
1646
1644
|
return _possible_constructor_return(_this);
|
|
1647
1645
|
}
|
|
1648
1646
|
var physX = physXPhysics._physX, physics = physXPhysics._pxPhysics;
|
|
@@ -1650,9 +1648,11 @@
|
|
|
1650
1648
|
var shapeFlags = ShapeFlag.SCENE_QUERY_SHAPE | ShapeFlag.SIMULATION_SHAPE;
|
|
1651
1649
|
var meshFlag = isConvex ? PhysXMeshColliderShape._tightBoundsFlag : 0;
|
|
1652
1650
|
var createShapeFn = isConvex ? physX.createConvexMeshShape : physX.createTriMeshShape;
|
|
1653
|
-
_this._pxShape = createShapeFn(
|
|
1651
|
+
_this._pxShape = createShapeFn(cooked.mesh, scaleX, scaleY, scaleZ, meshFlag, shapeFlags, material._pxMaterial, physics);
|
|
1654
1652
|
_this._id = uniqueID;
|
|
1655
1653
|
_this._pxMaterial = material._pxMaterial;
|
|
1654
|
+
_this._pxMesh = cooked.mesh;
|
|
1655
|
+
_this._pxGeometry = cooked.geometry;
|
|
1656
1656
|
_this._pxShape.setUUID(uniqueID);
|
|
1657
1657
|
_this._setLocalPose();
|
|
1658
1658
|
return _this;
|
|
@@ -1661,16 +1661,25 @@
|
|
|
1661
1661
|
/**
|
|
1662
1662
|
* {@inheritDoc IMeshColliderShape.setMeshData }
|
|
1663
1663
|
*/ _proto.setMeshData = function setMeshData(positions, indices, isConvex, cookingFlags) {
|
|
1664
|
-
var
|
|
1665
|
-
(
|
|
1666
|
-
(_this__pxGeometry = this._pxGeometry) == null ? void 0 : _this__pxGeometry.delete();
|
|
1667
|
-
this._pxMesh = null;
|
|
1668
|
-
this._pxGeometry = null;
|
|
1669
|
-
this._isConvex = isConvex;
|
|
1670
|
-
if (!this._cookMesh(positions, indices, cookingFlags)) {
|
|
1664
|
+
var cooked = this._cookMesh(positions, indices, isConvex, cookingFlags);
|
|
1665
|
+
if (!cooked) {
|
|
1671
1666
|
return false;
|
|
1672
1667
|
}
|
|
1673
|
-
this.
|
|
1668
|
+
var oldMesh = this._pxMesh;
|
|
1669
|
+
var oldGeometry = this._pxGeometry;
|
|
1670
|
+
try {
|
|
1671
|
+
this._pxShape.setGeometry(cooked.geometry);
|
|
1672
|
+
} catch (error) {
|
|
1673
|
+
var _cooked_mesh, _cooked_geometry;
|
|
1674
|
+
(_cooked_mesh = cooked.mesh) == null ? void 0 : _cooked_mesh.release();
|
|
1675
|
+
(_cooked_geometry = cooked.geometry) == null ? void 0 : _cooked_geometry.delete();
|
|
1676
|
+
throw error;
|
|
1677
|
+
}
|
|
1678
|
+
this._pxMesh = cooked.mesh;
|
|
1679
|
+
this._pxGeometry = cooked.geometry;
|
|
1680
|
+
this._isConvex = isConvex;
|
|
1681
|
+
oldMesh == null ? void 0 : oldMesh.release();
|
|
1682
|
+
oldGeometry == null ? void 0 : oldGeometry.delete();
|
|
1674
1683
|
return true;
|
|
1675
1684
|
};
|
|
1676
1685
|
/**
|
|
@@ -1686,7 +1695,7 @@
|
|
|
1686
1695
|
(_this__pxMesh = this._pxMesh) == null ? void 0 : _this__pxMesh.release();
|
|
1687
1696
|
PhysXColliderShape.prototype.destroy.call(this);
|
|
1688
1697
|
};
|
|
1689
|
-
_proto._cookMesh = function _cookMesh(positions, indices, cookingFlags) {
|
|
1698
|
+
_proto._cookMesh = function _cookMesh(positions, indices, isConvex, cookingFlags) {
|
|
1690
1699
|
var _this__physXPhysics = this._physXPhysics, physX = _this__physXPhysics._physX, physics = _this__physXPhysics._pxPhysics, cooking = _this__physXPhysics._pxCooking, cookingParams = _this__physXPhysics._pxCookingParams;
|
|
1691
1700
|
// Apply per-shape cooking flags
|
|
1692
1701
|
var preprocessFlags = 0;
|
|
@@ -1699,33 +1708,37 @@
|
|
|
1699
1708
|
physX.setCookingMeshPreprocessParams(cookingParams, preprocessFlags);
|
|
1700
1709
|
cooking.setParams(cookingParams);
|
|
1701
1710
|
var verticesPtr = this._allocatePositions(positions);
|
|
1702
|
-
|
|
1703
|
-
|
|
1711
|
+
var pxMesh = null;
|
|
1712
|
+
if (isConvex) {
|
|
1713
|
+
pxMesh = cooking.createConvexMesh(verticesPtr, positions.length, physics);
|
|
1704
1714
|
physX._free(verticesPtr);
|
|
1705
|
-
if (!
|
|
1715
|
+
if (!pxMesh) {
|
|
1706
1716
|
this._logConvexCookingError(physX);
|
|
1707
|
-
return
|
|
1717
|
+
return null;
|
|
1708
1718
|
}
|
|
1709
1719
|
} else {
|
|
1710
1720
|
if (!indices) {
|
|
1711
1721
|
physX._free(verticesPtr);
|
|
1712
1722
|
console.error("PhysXMeshColliderShape: Triangle mesh requires indices.");
|
|
1713
|
-
return
|
|
1723
|
+
return null;
|
|
1714
1724
|
}
|
|
1715
1725
|
var isU32 = _instanceof(indices, Uint32Array);
|
|
1716
1726
|
var indicesPtr = this._allocateIndices(indices, isU32);
|
|
1717
|
-
|
|
1727
|
+
pxMesh = cooking.createTriMesh(verticesPtr, positions.length, indicesPtr, indices.length / 3, !isU32, physics);
|
|
1718
1728
|
physX._free(verticesPtr);
|
|
1719
1729
|
physX._free(indicesPtr);
|
|
1720
|
-
if (!
|
|
1730
|
+
if (!pxMesh) {
|
|
1721
1731
|
this._logTriMeshCookingError(physX);
|
|
1722
|
-
return
|
|
1732
|
+
return null;
|
|
1723
1733
|
}
|
|
1724
1734
|
}
|
|
1725
1735
|
var _this__worldScale = this._worldScale, scaleX = _this__worldScale.x, scaleY = _this__worldScale.y, scaleZ = _this__worldScale.z;
|
|
1726
|
-
var meshFlag =
|
|
1727
|
-
|
|
1728
|
-
return
|
|
1736
|
+
var meshFlag = isConvex ? PhysXMeshColliderShape._tightBoundsFlag : 0;
|
|
1737
|
+
var geometry = isConvex ? physX.createConvexMeshGeometry(pxMesh, scaleX, scaleY, scaleZ, meshFlag) : physX.createTriMeshGeometry(pxMesh, scaleX, scaleY, scaleZ, meshFlag);
|
|
1738
|
+
return {
|
|
1739
|
+
mesh: pxMesh,
|
|
1740
|
+
geometry: geometry
|
|
1741
|
+
};
|
|
1729
1742
|
};
|
|
1730
1743
|
_proto._logConvexCookingError = function _logConvexCookingError(physX) {
|
|
1731
1744
|
switch(physX.getLastConvexCookingResult()){
|
|
@@ -1775,9 +1788,15 @@
|
|
|
1775
1788
|
var _this__worldScale = this._worldScale, scaleX = _this__worldScale.x, scaleY = _this__worldScale.y, scaleZ = _this__worldScale.z;
|
|
1776
1789
|
var meshFlag = this._isConvex ? PhysXMeshColliderShape._tightBoundsFlag : 0;
|
|
1777
1790
|
var newGeometry = this._isConvex ? physX.createConvexMeshGeometry(this._pxMesh, scaleX, scaleY, scaleZ, meshFlag) : physX.createTriMeshGeometry(this._pxMesh, scaleX, scaleY, scaleZ, meshFlag);
|
|
1778
|
-
this._pxGeometry
|
|
1791
|
+
var oldGeometry = this._pxGeometry;
|
|
1792
|
+
try {
|
|
1793
|
+
this._pxShape.setGeometry(newGeometry);
|
|
1794
|
+
} catch (error) {
|
|
1795
|
+
newGeometry == null ? void 0 : newGeometry.delete();
|
|
1796
|
+
throw error;
|
|
1797
|
+
}
|
|
1779
1798
|
this._pxGeometry = newGeometry;
|
|
1780
|
-
|
|
1799
|
+
oldGeometry == null ? void 0 : oldGeometry.delete();
|
|
1781
1800
|
};
|
|
1782
1801
|
return PhysXMeshColliderShape;
|
|
1783
1802
|
}(PhysXColliderShape);
|
|
@@ -1847,12 +1866,16 @@
|
|
|
1847
1866
|
var resolvedOptions = isOptionsObject ? runtimeModeOrOptions : options;
|
|
1848
1867
|
this._runTimeMode = runtimeMode;
|
|
1849
1868
|
var _runtimeUrls_wasmSIMDModeUrl;
|
|
1850
|
-
this._wasmSIMDModeUrl = (_runtimeUrls_wasmSIMDModeUrl = runtimeUrls == null ? void 0 : runtimeUrls.wasmSIMDModeUrl) != null ? _runtimeUrls_wasmSIMDModeUrl : "https://mdn.alipayobjects.com/rms/
|
|
1869
|
+
this._wasmSIMDModeUrl = (_runtimeUrls_wasmSIMDModeUrl = runtimeUrls == null ? void 0 : runtimeUrls.wasmSIMDModeUrl) != null ? _runtimeUrls_wasmSIMDModeUrl : "https://mdn.alipayobjects.com/rms/uri/file/as/apwallet/1781696156399/suyi/physx.release.simd.js";
|
|
1851
1870
|
var _runtimeUrls_wasmModeUrl;
|
|
1852
|
-
this._wasmModeUrl = (_runtimeUrls_wasmModeUrl = runtimeUrls == null ? void 0 : runtimeUrls.wasmModeUrl) != null ? _runtimeUrls_wasmModeUrl : "https://mdn.alipayobjects.com/rms/
|
|
1871
|
+
this._wasmModeUrl = (_runtimeUrls_wasmModeUrl = runtimeUrls == null ? void 0 : runtimeUrls.wasmModeUrl) != null ? _runtimeUrls_wasmModeUrl : "https://mdn.alipayobjects.com/rms/uri/file/as/apwallet/1781696156399/suyi/physx.release.js";
|
|
1853
1872
|
this._tolerancesScaleOptions = resolvedOptions == null ? void 0 : resolvedOptions.tolerancesScale;
|
|
1854
|
-
var _this__tolerancesScaleOptions_length
|
|
1855
|
-
|
|
1873
|
+
var _this__tolerancesScaleOptions_length;
|
|
1874
|
+
var length = (_this__tolerancesScaleOptions_length = (_this__tolerancesScaleOptions = this._tolerancesScaleOptions) == null ? void 0 : _this__tolerancesScaleOptions.length) != null ? _this__tolerancesScaleOptions_length : 1;
|
|
1875
|
+
var _this__tolerancesScaleOptions_speed;
|
|
1876
|
+
var speed = (_this__tolerancesScaleOptions_speed = (_this__tolerancesScaleOptions1 = this._tolerancesScaleOptions) == null ? void 0 : _this__tolerancesScaleOptions1.speed) != null ? _this__tolerancesScaleOptions_speed : 10;
|
|
1877
|
+
this._validateTolerancesScale(length, speed);
|
|
1878
|
+
this._updateScaledDefaults(length, speed);
|
|
1856
1879
|
}
|
|
1857
1880
|
var _proto = PhysXPhysics.prototype;
|
|
1858
1881
|
/**
|
|
@@ -2035,8 +2058,7 @@
|
|
|
2035
2058
|
var length = (_this__tolerancesScaleOptions_length = (_this__tolerancesScaleOptions = this._tolerancesScaleOptions) == null ? void 0 : _this__tolerancesScaleOptions.length) != null ? _this__tolerancesScaleOptions_length : tolerancesScale.length;
|
|
2036
2059
|
var _this__tolerancesScaleOptions_speed;
|
|
2037
2060
|
var speed = (_this__tolerancesScaleOptions_speed = (_this__tolerancesScaleOptions1 = this._tolerancesScaleOptions) == null ? void 0 : _this__tolerancesScaleOptions1.speed) != null ? _this__tolerancesScaleOptions_speed : tolerancesScale.speed;
|
|
2038
|
-
this.
|
|
2039
|
-
this._assertPositiveFinite(speed, "tolerancesScale.speed");
|
|
2061
|
+
this._validateTolerancesScale(length, speed);
|
|
2040
2062
|
tolerancesScale.length = length;
|
|
2041
2063
|
tolerancesScale.speed = speed;
|
|
2042
2064
|
this._updateScaledDefaults(length, speed);
|
|
@@ -2046,6 +2068,10 @@
|
|
|
2046
2068
|
throw new Error("PhysXPhysics " + name + " must be a positive finite number.");
|
|
2047
2069
|
}
|
|
2048
2070
|
};
|
|
2071
|
+
_proto._validateTolerancesScale = function _validateTolerancesScale(length, speed) {
|
|
2072
|
+
this._assertPositiveFinite(length, "tolerancesScale.length");
|
|
2073
|
+
this._assertPositiveFinite(speed, "tolerancesScale.speed");
|
|
2074
|
+
};
|
|
2049
2075
|
_proto._updateScaledDefaults = function _updateScaledDefaults(length, speed) {
|
|
2050
2076
|
this._defaultContactOffset = 0.02 * length;
|
|
2051
2077
|
this._defaultSleepThreshold = 5e-5 * speed * speed;
|
|
@@ -2054,7 +2080,7 @@
|
|
|
2054
2080
|
}();
|
|
2055
2081
|
|
|
2056
2082
|
//@ts-ignore
|
|
2057
|
-
var version = "0.0.0-experimental-2.0-
|
|
2083
|
+
var version = "0.0.0-experimental-2.0-migrate.2";
|
|
2058
2084
|
console.log("Galacean Engine Physics PhysX Version: " + version);
|
|
2059
2085
|
|
|
2060
2086
|
exports.PhysXPhysics = PhysXPhysics;
|