@galacean/engine-physics-physx 2.0.0-alpha.2 → 2.0.0-alpha.6
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 +139 -186
- 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 +139 -186
- package/dist/main.js.map +1 -1
- package/dist/module.js +141 -187
- package/dist/module.js.map +1 -1
- package/libs/physx.release.js +2 -21
- package/libs/physx.release.simd.js +2 -0
- package/libs/physx.release.simd.wasm +0 -0
- package/libs/physx.release.wasm +0 -0
- package/package.json +4 -4
- package/types/PhysXPhysics.d.ts +6 -16
- package/types/enum/PhysXRuntimeMode.d.ts +3 -3
- package/types/index.d.ts +0 -1
- package/types/shape/PhysXMeshColliderShape.d.ts +7 -19
- package/libs/physx.release.downgrade.js +0 -60
- package/types/enum/MeshPreprocessingFlag.d.ts +0 -28
package/dist/browser.js
CHANGED
|
@@ -10,12 +10,6 @@
|
|
|
10
10
|
} else return left instanceof right;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
function _type_of(obj) {
|
|
14
|
-
"@swc/helpers - typeof";
|
|
15
|
-
|
|
16
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
13
|
function _set_prototype_of(o, p) {
|
|
20
14
|
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
21
15
|
o.__proto__ = p;
|
|
@@ -1220,9 +1214,9 @@
|
|
|
1220
1214
|
/**
|
|
1221
1215
|
* PhysX runtime mode.
|
|
1222
1216
|
*/ var PhysXRuntimeMode = /*#__PURE__*/ function(PhysXRuntimeMode) {
|
|
1223
|
-
/** Use
|
|
1217
|
+
/** Use WebAssembly SIMD mode first, then WebAssembly as fallback. */ PhysXRuntimeMode[PhysXRuntimeMode["Auto"] = 0] = "Auto";
|
|
1224
1218
|
/** WebAssembly mode. */ PhysXRuntimeMode[PhysXRuntimeMode["WebAssembly"] = 1] = "WebAssembly";
|
|
1225
|
-
/**
|
|
1219
|
+
/** WebAssembly SIMD mode. */ PhysXRuntimeMode[PhysXRuntimeMode["WebAssemblySIMD"] = 2] = "WebAssemblySIMD";
|
|
1226
1220
|
return PhysXRuntimeMode;
|
|
1227
1221
|
}({});
|
|
1228
1222
|
|
|
@@ -1454,62 +1448,62 @@
|
|
|
1454
1448
|
return PhysXSpringJoint;
|
|
1455
1449
|
}(PhysXJoint);
|
|
1456
1450
|
|
|
1457
|
-
|
|
1458
|
-
|
|
1451
|
+
function _assert_this_initialized(self) {
|
|
1452
|
+
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
1453
|
+
|
|
1454
|
+
return self;
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
function _type_of(obj) {
|
|
1458
|
+
"@swc/helpers - typeof";
|
|
1459
|
+
|
|
1460
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
function _possible_constructor_return(self, call) {
|
|
1464
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) return call;
|
|
1465
|
+
|
|
1466
|
+
return _assert_this_initialized(self);
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1459
1469
|
/**
|
|
1460
1470
|
* Mesh collider shape in PhysX.
|
|
1461
1471
|
*/ var PhysXMeshColliderShape = /*#__PURE__*/ function(PhysXColliderShape) {
|
|
1462
1472
|
_inherits(PhysXMeshColliderShape, PhysXColliderShape);
|
|
1463
|
-
function PhysXMeshColliderShape(physXPhysics, uniqueID,
|
|
1473
|
+
function PhysXMeshColliderShape(physXPhysics, uniqueID, positions, indices, isConvex, material, cookingFlags) {
|
|
1464
1474
|
var _this;
|
|
1465
|
-
_this = PhysXColliderShape.call(this, physXPhysics) || this, _this._pxMesh = null
|
|
1475
|
+
_this = PhysXColliderShape.call(this, physXPhysics) || this, _this._pxMesh = null;
|
|
1466
1476
|
_this._isConvex = isConvex;
|
|
1467
|
-
_this.
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1477
|
+
if (!_this._cookMesh(positions, indices, cookingFlags)) {
|
|
1478
|
+
return _possible_constructor_return(_this);
|
|
1479
|
+
}
|
|
1480
|
+
var physX = physXPhysics._physX, physics = physXPhysics._pxPhysics;
|
|
1481
|
+
var _this__worldScale = _this._worldScale, scaleX = _this__worldScale.x, scaleY = _this__worldScale.y, scaleZ = _this__worldScale.z;
|
|
1482
|
+
var shapeFlags = ShapeFlag.SCENE_QUERY_SHAPE | ShapeFlag.SIMULATION_SHAPE;
|
|
1483
|
+
var meshFlag = isConvex ? PhysXMeshColliderShape._tightBoundsFlag : 0;
|
|
1484
|
+
var createShapeFn = isConvex ? physX.createConvexMeshShape : physX.createTriMeshShape;
|
|
1485
|
+
_this._pxShape = createShapeFn(_this._pxMesh, scaleX, scaleY, scaleZ, meshFlag, shapeFlags, material._pxMaterial, physics);
|
|
1486
|
+
_this._id = uniqueID;
|
|
1487
|
+
_this._pxMaterial = material._pxMaterial;
|
|
1488
|
+
_this._pxShape.setUUID(uniqueID);
|
|
1471
1489
|
_this._setLocalPose();
|
|
1472
1490
|
return _this;
|
|
1473
1491
|
}
|
|
1474
1492
|
var _proto = PhysXMeshColliderShape.prototype;
|
|
1475
1493
|
/**
|
|
1476
1494
|
* {@inheritDoc IMeshColliderShape.setMeshData }
|
|
1477
|
-
*/ _proto.setMeshData = function setMeshData(
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
// Update data and create new mesh (may throw on failure)
|
|
1495
|
+
*/ _proto.setMeshData = function setMeshData(positions, indices, isConvex, cookingFlags) {
|
|
1496
|
+
var _this__pxMesh, _this__pxGeometry;
|
|
1497
|
+
(_this__pxMesh = this._pxMesh) == null ? void 0 : _this__pxMesh.release();
|
|
1498
|
+
(_this__pxGeometry = this._pxGeometry) == null ? void 0 : _this__pxGeometry.delete();
|
|
1482
1499
|
this._pxMesh = null;
|
|
1483
1500
|
this._pxGeometry = null;
|
|
1484
1501
|
this._isConvex = isConvex;
|
|
1485
|
-
this.
|
|
1486
|
-
|
|
1487
|
-
this._indices = indices;
|
|
1488
|
-
this._createMesh();
|
|
1489
|
-
this._pxShape.setGeometry(this._pxGeometry);
|
|
1490
|
-
// Release old resources only after successful creation
|
|
1491
|
-
if (oldMesh) {
|
|
1492
|
-
oldMesh.release();
|
|
1493
|
-
}
|
|
1494
|
-
if (oldGeometry) {
|
|
1495
|
-
oldGeometry.delete();
|
|
1496
|
-
}
|
|
1497
|
-
};
|
|
1498
|
-
/**
|
|
1499
|
-
* {@inheritDoc IMeshColliderShape.setDoubleSided }
|
|
1500
|
-
*/ _proto.setDoubleSided = function setDoubleSided(value) {
|
|
1501
|
-
this._doubleSided = value;
|
|
1502
|
-
if (!this._isConvex && this._pxMesh) {
|
|
1503
|
-
this._updateGeometry();
|
|
1504
|
-
}
|
|
1505
|
-
};
|
|
1506
|
-
/**
|
|
1507
|
-
* {@inheritDoc IMeshColliderShape.setTightBounds }
|
|
1508
|
-
*/ _proto.setTightBounds = function setTightBounds(value) {
|
|
1509
|
-
this._tightBounds = value;
|
|
1510
|
-
if (this._isConvex && this._pxMesh) {
|
|
1511
|
-
this._updateGeometry();
|
|
1502
|
+
if (!this._cookMesh(positions, indices, cookingFlags)) {
|
|
1503
|
+
return false;
|
|
1512
1504
|
}
|
|
1505
|
+
this._pxShape.setGeometry(this._pxGeometry);
|
|
1506
|
+
return true;
|
|
1513
1507
|
};
|
|
1514
1508
|
/**
|
|
1515
1509
|
* {@inheritDoc IColliderShape.setWorldScale }
|
|
@@ -1520,103 +1514,107 @@
|
|
|
1520
1514
|
/**
|
|
1521
1515
|
* {@inheritDoc IColliderShape.destroy }
|
|
1522
1516
|
*/ _proto.destroy = function destroy() {
|
|
1523
|
-
|
|
1517
|
+
var _this__pxMesh;
|
|
1518
|
+
(_this__pxMesh = this._pxMesh) == null ? void 0 : _this__pxMesh.release();
|
|
1524
1519
|
PhysXColliderShape.prototype.destroy.call(this);
|
|
1525
1520
|
};
|
|
1526
|
-
_proto.
|
|
1527
|
-
var
|
|
1528
|
-
|
|
1529
|
-
var
|
|
1530
|
-
|
|
1531
|
-
|
|
1521
|
+
_proto._cookMesh = function _cookMesh(positions, indices, cookingFlags) {
|
|
1522
|
+
var _this__physXPhysics = this._physXPhysics, physX = _this__physXPhysics._physX, physics = _this__physXPhysics._pxPhysics, cooking = _this__physXPhysics._pxCooking, cookingParams = _this__physXPhysics._pxCookingParams;
|
|
1523
|
+
// Apply per-shape cooking flags
|
|
1524
|
+
var preprocessFlags = 0;
|
|
1525
|
+
if (cookingFlags & engine.MeshColliderShapeCookingFlag.VertexWelding) {
|
|
1526
|
+
preprocessFlags |= 1; // eWELD_VERTICES
|
|
1527
|
+
}
|
|
1528
|
+
if (!(cookingFlags & engine.MeshColliderShapeCookingFlag.Cleaning)) {
|
|
1529
|
+
preprocessFlags |= 2; // eDISABLE_CLEAN_MESH
|
|
1530
|
+
}
|
|
1531
|
+
physX.setCookingMeshPreprocessParams(cookingParams, preprocessFlags);
|
|
1532
|
+
cooking.setParams(cookingParams);
|
|
1533
|
+
var verticesPtr = this._allocatePositions(positions);
|
|
1532
1534
|
if (this._isConvex) {
|
|
1533
|
-
this.
|
|
1535
|
+
this._pxMesh = cooking.createConvexMesh(verticesPtr, positions.length, physics);
|
|
1536
|
+
physX._free(verticesPtr);
|
|
1537
|
+
if (!this._pxMesh) {
|
|
1538
|
+
this._logConvexCookingError(physX);
|
|
1539
|
+
return false;
|
|
1540
|
+
}
|
|
1534
1541
|
} else {
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
this._pxShape.setUUID(uniqueID);
|
|
1540
|
-
};
|
|
1541
|
-
_proto._createMesh = function _createMesh() {
|
|
1542
|
-
var physX = this._physXPhysics._physX;
|
|
1543
|
-
var physics = this._physXPhysics._pxPhysics;
|
|
1544
|
-
var cooking = this._physXPhysics._pxCooking;
|
|
1545
|
-
var verticesPtr = this._allocateVertices();
|
|
1546
|
-
var indicesPtr = 0;
|
|
1547
|
-
try {
|
|
1548
|
-
if (this._isConvex) {
|
|
1549
|
-
this._pxMesh = cooking.createConvexMesh(verticesPtr, this._vertexCount, physics);
|
|
1550
|
-
if (!this._pxMesh) {
|
|
1551
|
-
throw new Error("Failed to create convex mesh. Check if vertex count <= 255 and geometry is valid.");
|
|
1552
|
-
}
|
|
1553
|
-
this._pxGeometry = physX.createConvexMeshGeometry(this._pxMesh, this._worldScale.x, this._worldScale.y, this._worldScale.z, this._tightBounds ? TIGHT_BOUNDS_FLAG : 0);
|
|
1554
|
-
} else {
|
|
1555
|
-
if (!this._indices) {
|
|
1556
|
-
throw new Error("Triangle mesh requires indices");
|
|
1557
|
-
}
|
|
1558
|
-
var _this__allocateIndices = this._allocateIndices(), ptr = _this__allocateIndices.ptr, isU16 = _this__allocateIndices.isU16, triangleCount = _this__allocateIndices.triangleCount;
|
|
1559
|
-
indicesPtr = ptr;
|
|
1560
|
-
this._pxMesh = cooking.createTriMesh(verticesPtr, this._vertexCount, indicesPtr, triangleCount, isU16, physics);
|
|
1561
|
-
if (!this._pxMesh) {
|
|
1562
|
-
throw new Error("Failed to create triangle mesh. Check if geometry is valid.");
|
|
1563
|
-
}
|
|
1564
|
-
this._pxGeometry = physX.createTriMeshGeometry(this._pxMesh, this._worldScale.x, this._worldScale.y, this._worldScale.z, this._doubleSided ? DOUBLE_SIDED_FLAG : 0);
|
|
1542
|
+
if (!indices) {
|
|
1543
|
+
physX._free(verticesPtr);
|
|
1544
|
+
console.error("PhysXMeshColliderShape: Triangle mesh requires indices.");
|
|
1545
|
+
return false;
|
|
1565
1546
|
}
|
|
1566
|
-
|
|
1547
|
+
var isU32 = _instanceof(indices, Uint32Array);
|
|
1548
|
+
var indicesPtr = this._allocateIndices(indices, isU32);
|
|
1549
|
+
this._pxMesh = cooking.createTriMesh(verticesPtr, positions.length, indicesPtr, indices.length / 3, !isU32, physics);
|
|
1567
1550
|
physX._free(verticesPtr);
|
|
1568
|
-
|
|
1569
|
-
|
|
1551
|
+
physX._free(indicesPtr);
|
|
1552
|
+
if (!this._pxMesh) {
|
|
1553
|
+
this._logTriMeshCookingError(physX);
|
|
1554
|
+
return false;
|
|
1570
1555
|
}
|
|
1571
|
-
// Release JS memory after copying to WASM
|
|
1572
|
-
this._vertices = null;
|
|
1573
|
-
this._indices = null;
|
|
1574
1556
|
}
|
|
1557
|
+
var _this__worldScale = this._worldScale, scaleX = _this__worldScale.x, scaleY = _this__worldScale.y, scaleZ = _this__worldScale.z;
|
|
1558
|
+
var meshFlag = this._isConvex ? PhysXMeshColliderShape._tightBoundsFlag : 0;
|
|
1559
|
+
this._pxGeometry = this._isConvex ? physX.createConvexMeshGeometry(this._pxMesh, scaleX, scaleY, scaleZ, meshFlag) : physX.createTriMeshGeometry(this._pxMesh, scaleX, scaleY, scaleZ, meshFlag);
|
|
1560
|
+
return true;
|
|
1575
1561
|
};
|
|
1576
|
-
_proto.
|
|
1562
|
+
_proto._logConvexCookingError = function _logConvexCookingError(physX) {
|
|
1563
|
+
switch(physX.getLastConvexCookingResult()){
|
|
1564
|
+
case 1:
|
|
1565
|
+
console.error("PhysXMeshColliderShape: Failed to create convex mesh. Could not find 4 vertices that do not form a zero-area triangle.");
|
|
1566
|
+
break;
|
|
1567
|
+
case 2:
|
|
1568
|
+
console.error("PhysXMeshColliderShape: Failed to create convex mesh within the maximum polygons limit (256). Consider simplifying the mesh.");
|
|
1569
|
+
break;
|
|
1570
|
+
default:
|
|
1571
|
+
console.error("PhysXMeshColliderShape: Failed to create convex mesh. The input geometry may be invalid.");
|
|
1572
|
+
break;
|
|
1573
|
+
}
|
|
1574
|
+
};
|
|
1575
|
+
_proto._logTriMeshCookingError = function _logTriMeshCookingError(physX) {
|
|
1576
|
+
switch(physX.getLastTriMeshCookingResult()){
|
|
1577
|
+
case 1:
|
|
1578
|
+
console.error("PhysXMeshColliderShape: Failed to create triangle mesh. One of the triangles is too large. Consider tessellating large triangles.");
|
|
1579
|
+
break;
|
|
1580
|
+
default:
|
|
1581
|
+
console.error("PhysXMeshColliderShape: Failed to create triangle mesh. The input geometry may be invalid.");
|
|
1582
|
+
break;
|
|
1583
|
+
}
|
|
1584
|
+
};
|
|
1585
|
+
_proto._allocatePositions = function _allocatePositions(positions) {
|
|
1577
1586
|
var physX = this._physXPhysics._physX;
|
|
1578
|
-
var
|
|
1579
|
-
var
|
|
1580
|
-
view
|
|
1587
|
+
var length = positions.length;
|
|
1588
|
+
var ptr = physX._malloc(length * 3 * 4);
|
|
1589
|
+
var view = new Float32Array(physX.HEAPF32.buffer, ptr, length * 3);
|
|
1590
|
+
for(var i = 0, offset = 0; i < length; i++, offset += 3){
|
|
1591
|
+
positions[i].copyToArray(view, offset);
|
|
1592
|
+
}
|
|
1581
1593
|
return ptr;
|
|
1582
1594
|
};
|
|
1583
|
-
_proto._allocateIndices = function _allocateIndices() {
|
|
1595
|
+
_proto._allocateIndices = function _allocateIndices(indices, isU32) {
|
|
1584
1596
|
var physX = this._physXPhysics._physX;
|
|
1585
|
-
|
|
1586
|
-
var
|
|
1587
|
-
var
|
|
1588
|
-
var
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
new Uint16Array(physX.HEAPU16.buffer, ptr, indices.length).set(indices);
|
|
1592
|
-
} else {
|
|
1593
|
-
new Uint32Array(physX.HEAPU32.buffer, ptr, indices.length).set(indices);
|
|
1594
|
-
}
|
|
1595
|
-
return {
|
|
1596
|
-
ptr: ptr,
|
|
1597
|
-
isU16: isU16,
|
|
1598
|
-
triangleCount: triangleCount
|
|
1599
|
-
};
|
|
1597
|
+
// Uint8Array and Uint16Array both write as Uint16 (PhysX minimum index size)
|
|
1598
|
+
var TypedArrayCtor = isU32 ? Uint32Array : Uint16Array;
|
|
1599
|
+
var heap = isU32 ? physX.HEAPU32 : physX.HEAPU16;
|
|
1600
|
+
var ptr = physX._malloc(indices.length * TypedArrayCtor.BYTES_PER_ELEMENT);
|
|
1601
|
+
new TypedArrayCtor(heap.buffer, ptr, indices.length).set(indices);
|
|
1602
|
+
return ptr;
|
|
1600
1603
|
};
|
|
1601
1604
|
_proto._updateGeometry = function _updateGeometry() {
|
|
1605
|
+
if (!this._pxMesh) return;
|
|
1602
1606
|
var physX = this._physXPhysics._physX;
|
|
1603
|
-
var
|
|
1607
|
+
var _this__worldScale = this._worldScale, scaleX = _this__worldScale.x, scaleY = _this__worldScale.y, scaleZ = _this__worldScale.z;
|
|
1608
|
+
var meshFlag = this._isConvex ? PhysXMeshColliderShape._tightBoundsFlag : 0;
|
|
1609
|
+
var newGeometry = this._isConvex ? physX.createConvexMeshGeometry(this._pxMesh, scaleX, scaleY, scaleZ, meshFlag) : physX.createTriMeshGeometry(this._pxMesh, scaleX, scaleY, scaleZ, meshFlag);
|
|
1604
1610
|
this._pxGeometry.delete();
|
|
1605
1611
|
this._pxGeometry = newGeometry;
|
|
1606
1612
|
this._pxShape.setGeometry(this._pxGeometry);
|
|
1607
1613
|
};
|
|
1608
|
-
_proto._releaseMesh = function _releaseMesh() {
|
|
1609
|
-
if (this._pxMesh) {
|
|
1610
|
-
this._pxMesh.release();
|
|
1611
|
-
this._pxMesh = null;
|
|
1612
|
-
}
|
|
1613
|
-
if (this._pxGeometry) {
|
|
1614
|
-
this._pxGeometry.delete();
|
|
1615
|
-
this._pxGeometry = null;
|
|
1616
|
-
}
|
|
1617
|
-
};
|
|
1618
1614
|
return PhysXMeshColliderShape;
|
|
1619
1615
|
}(PhysXColliderShape);
|
|
1616
|
+
PhysXMeshColliderShape._tightBoundsFlag = 1 // eTIGHT_BOUNDS = 1 (1<<0)
|
|
1617
|
+
;
|
|
1620
1618
|
|
|
1621
1619
|
/**
|
|
1622
1620
|
* Plane collider shape in PhysX.
|
|
@@ -1674,10 +1672,10 @@
|
|
|
1674
1672
|
if (runtimeMode === void 0) runtimeMode = PhysXRuntimeMode.Auto;
|
|
1675
1673
|
this._initializeState = 0;
|
|
1676
1674
|
this._runTimeMode = runtimeMode;
|
|
1675
|
+
var _runtimeUrls_wasmSIMDModeUrl;
|
|
1676
|
+
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";
|
|
1677
1677
|
var _runtimeUrls_wasmModeUrl;
|
|
1678
|
-
this._wasmModeUrl = (_runtimeUrls_wasmModeUrl = runtimeUrls == null ? void 0 : runtimeUrls.wasmModeUrl) != null ? _runtimeUrls_wasmModeUrl : "https://mdn.alipayobjects.com/rms/afts/file/A*
|
|
1679
|
-
var _runtimeUrls_javaScriptModeUrl;
|
|
1680
|
-
this._downgradeModeUrl = (_runtimeUrls_javaScriptModeUrl = runtimeUrls == null ? void 0 : runtimeUrls.javaScriptModeUrl) != null ? _runtimeUrls_javaScriptModeUrl : "https://mdn.alipayobjects.com/rms/afts/file/A*PLtBTLf8Sm0AAAAAgFAAAAgAehQnAQ/physx.release.downgrade.js";
|
|
1678
|
+
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";
|
|
1681
1679
|
}
|
|
1682
1680
|
var _proto = PhysXPhysics.prototype;
|
|
1683
1681
|
/**
|
|
@@ -1691,6 +1689,7 @@
|
|
|
1691
1689
|
} else if (this._initializeState === 1) {
|
|
1692
1690
|
return this._initializePromise;
|
|
1693
1691
|
}
|
|
1692
|
+
this._initializeState = 1;
|
|
1694
1693
|
var runtimeMode = this._runTimeMode;
|
|
1695
1694
|
var scriptPromise = new Promise(function(resolve, reject) {
|
|
1696
1695
|
var script = document.createElement("script");
|
|
@@ -1699,30 +1698,18 @@
|
|
|
1699
1698
|
script.onload = resolve;
|
|
1700
1699
|
script.onerror = reject;
|
|
1701
1700
|
if (runtimeMode == PhysXRuntimeMode.Auto) {
|
|
1702
|
-
|
|
1703
|
-
try {
|
|
1704
|
-
if ((typeof WebAssembly === "undefined" ? "undefined" : _type_of(WebAssembly)) === "object" && typeof WebAssembly.instantiate === "function") {
|
|
1705
|
-
var wasmModule = new WebAssembly.Module(Uint8Array.of(0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00));
|
|
1706
|
-
if (_instanceof(wasmModule, WebAssembly.Module)) return _instanceof(new WebAssembly.Instance(wasmModule), WebAssembly.Instance);
|
|
1707
|
-
}
|
|
1708
|
-
} catch (e) {}
|
|
1709
|
-
return false;
|
|
1710
|
-
}();
|
|
1711
|
-
if (supported) {
|
|
1712
|
-
runtimeMode = PhysXRuntimeMode.WebAssembly;
|
|
1713
|
-
} else {
|
|
1714
|
-
runtimeMode = PhysXRuntimeMode.JavaScript;
|
|
1715
|
-
}
|
|
1701
|
+
runtimeMode = engine.SystemInfo._detectSIMDSupported() ? PhysXRuntimeMode.WebAssemblySIMD : PhysXRuntimeMode.WebAssembly;
|
|
1716
1702
|
}
|
|
1717
|
-
if (runtimeMode == PhysXRuntimeMode.
|
|
1718
|
-
script.src = _this.
|
|
1719
|
-
} else
|
|
1703
|
+
if (runtimeMode == PhysXRuntimeMode.WebAssemblySIMD) {
|
|
1704
|
+
script.src = _this._wasmSIMDModeUrl;
|
|
1705
|
+
} else {
|
|
1720
1706
|
script.src = _this._wasmModeUrl;
|
|
1721
1707
|
}
|
|
1722
1708
|
});
|
|
1723
1709
|
var initializePromise = new Promise(function(resolve, reject) {
|
|
1724
1710
|
scriptPromise.then(function() {
|
|
1725
1711
|
return window.PHYSX().then(function(PHYSX) {
|
|
1712
|
+
_this._runTimeMode = runtimeMode;
|
|
1726
1713
|
_this._init(PHYSX);
|
|
1727
1714
|
_this._initializeState = 2;
|
|
1728
1715
|
_this._initializePromise = null;
|
|
@@ -1747,18 +1734,6 @@
|
|
|
1747
1734
|
this._tolerancesScale.delete();
|
|
1748
1735
|
};
|
|
1749
1736
|
/**
|
|
1750
|
-
* Set cooking parameters for mesh colliders.
|
|
1751
|
-
* @param params - Cooking parameters
|
|
1752
|
-
*/ _proto.setCookingParams = function setCookingParams(params) {
|
|
1753
|
-
var cp = this._pxCookingParams;
|
|
1754
|
-
if (params.meshWeldTolerance !== undefined) {
|
|
1755
|
-
cp.meshWeldTolerance = params.meshWeldTolerance;
|
|
1756
|
-
}
|
|
1757
|
-
if (params.meshPreprocessParams !== undefined) {
|
|
1758
|
-
this._physX.setCookingMeshPreprocessParams(cp, params.meshPreprocessParams);
|
|
1759
|
-
}
|
|
1760
|
-
};
|
|
1761
|
-
/**
|
|
1762
1737
|
* {@inheritDoc IPhysics.createPhysicsManager }
|
|
1763
1738
|
*/ _proto.createPhysicsManager = function createPhysicsManager() {
|
|
1764
1739
|
return new PhysXPhysicsManager();
|
|
@@ -1811,8 +1786,9 @@
|
|
|
1811
1786
|
};
|
|
1812
1787
|
/**
|
|
1813
1788
|
* {@inheritDoc IPhysics.createMeshColliderShape }
|
|
1814
|
-
*/ _proto.createMeshColliderShape = function createMeshColliderShape(uniqueID,
|
|
1815
|
-
|
|
1789
|
+
*/ _proto.createMeshColliderShape = function createMeshColliderShape(uniqueID, positions, indices, isConvex, material, cookingFlags) {
|
|
1790
|
+
var shape = new PhysXMeshColliderShape(this, uniqueID, positions, indices, isConvex, material, cookingFlags);
|
|
1791
|
+
return shape._pxShape ? shape : null;
|
|
1816
1792
|
};
|
|
1817
1793
|
/**
|
|
1818
1794
|
* {@inheritDoc IPhysics.createFixedJoint }
|
|
@@ -1849,9 +1825,12 @@
|
|
|
1849
1825
|
physX.PxInitExtensions(pxPhysics, null);
|
|
1850
1826
|
// Initialize cooking for mesh colliders
|
|
1851
1827
|
var cookingParams = new physX.PxCookingParams(tolerancesScale);
|
|
1852
|
-
|
|
1853
|
-
physX.setCookingMeshPreprocessParams(cookingParams, 1); // WeldVertices = 1
|
|
1828
|
+
physX.setCookingMeshPreprocessParams(cookingParams, 1); // eWELD_VERTICES
|
|
1854
1829
|
cookingParams.meshWeldTolerance = 0.001;
|
|
1830
|
+
// BVH34 midphase requires SSE2; SIMD WASM provides SSE2 via WASM SIMD
|
|
1831
|
+
if (this._runTimeMode === PhysXRuntimeMode.WebAssemblySIMD) {
|
|
1832
|
+
physX.setCookingMidphaseType(cookingParams, 1); // eBVH34
|
|
1833
|
+
}
|
|
1855
1834
|
var pxCooking = physX.PxCreateCooking(version, pxFoundation, cookingParams);
|
|
1856
1835
|
this._physX = physX;
|
|
1857
1836
|
this._pxFoundation = pxFoundation;
|
|
@@ -1865,36 +1844,10 @@
|
|
|
1865
1844
|
return PhysXPhysics;
|
|
1866
1845
|
}();
|
|
1867
1846
|
|
|
1868
|
-
/**
|
|
1869
|
-
* Mesh preprocessing flags for cooking options.
|
|
1870
|
-
* @remarks These flags control how the mesh is preprocessed during cooking.
|
|
1871
|
-
*/ var MeshPreprocessingFlag = /*#__PURE__*/ function(MeshPreprocessingFlag) {
|
|
1872
|
-
/**
|
|
1873
|
-
* When set, mesh welding is performed.
|
|
1874
|
-
* Vertices within the meshWeldTolerance distance will be merged.
|
|
1875
|
-
* Clean mesh must be enabled for this to work.
|
|
1876
|
-
*/ MeshPreprocessingFlag[MeshPreprocessingFlag["WeldVertices"] = 1] = "WeldVertices";
|
|
1877
|
-
/**
|
|
1878
|
-
* When set, mesh cleaning is disabled.
|
|
1879
|
-
* This makes cooking faster but requires the input mesh to be valid.
|
|
1880
|
-
* When clean mesh is disabled, vertex welding is also disabled.
|
|
1881
|
-
*/ MeshPreprocessingFlag[MeshPreprocessingFlag["DisableCleanMesh"] = 2] = "DisableCleanMesh";
|
|
1882
|
-
/**
|
|
1883
|
-
* When set, active edges computation is disabled.
|
|
1884
|
-
* This makes cooking faster but may slow down contact generation.
|
|
1885
|
-
*/ MeshPreprocessingFlag[MeshPreprocessingFlag["DisableActiveEdgesPrecompute"] = 4] = "DisableActiveEdgesPrecompute";
|
|
1886
|
-
/**
|
|
1887
|
-
* When set, 32-bit indices will always be used regardless of triangle count.
|
|
1888
|
-
* By default, 16-bit indices are used for meshes with <= 65535 triangles.
|
|
1889
|
-
*/ MeshPreprocessingFlag[MeshPreprocessingFlag["Force32BitIndices"] = 8] = "Force32BitIndices";
|
|
1890
|
-
return MeshPreprocessingFlag;
|
|
1891
|
-
}({});
|
|
1892
|
-
|
|
1893
1847
|
//@ts-ignore
|
|
1894
|
-
var version = "2.0.0-alpha.
|
|
1848
|
+
var version = "2.0.0-alpha.6";
|
|
1895
1849
|
console.log("Galacean Engine Physics PhysX Version: " + version);
|
|
1896
1850
|
|
|
1897
|
-
exports.MeshPreprocessingFlag = MeshPreprocessingFlag;
|
|
1898
1851
|
exports.PhysXPhysics = PhysXPhysics;
|
|
1899
1852
|
exports.PhysXRuntimeMode = PhysXRuntimeMode;
|
|
1900
1853
|
exports.version = version;
|