@galacean/engine-physics-physx 0.0.0-experimental-2.0-migrate.6 → 0.0.0-experimental-2.0-skill.0
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 +1962 -0
- package/dist/browser.js.map +1 -0
- package/dist/browser.min.js +2 -0
- package/dist/browser.min.js.map +1 -0
- package/dist/main.js +57 -190
- package/dist/main.js.map +1 -1
- package/dist/module.js +57 -190
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/PhysXDynamicCollider.d.ts +1 -38
- package/types/PhysXPhysics.d.ts +1 -28
- package/types/PhysXPhysicsScene.d.ts +0 -5
- package/types/index.d.ts +0 -1
package/dist/module.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { Vector3, Vector4, MathUtil, Quaternion, DisorderedArray, MeshColliderShapeCookingFlag, SystemInfo } from '@galacean/engine';
|
|
2
2
|
|
|
3
|
-
function _type_of(obj) {
|
|
4
|
-
"@swc/helpers - typeof";
|
|
5
|
-
|
|
6
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
3
|
function _instanceof(left, right) {
|
|
10
4
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
11
5
|
return !!right[Symbol.hasInstance](left);
|
|
@@ -45,7 +39,7 @@ function _inherits(subClass, superClass) {
|
|
|
45
39
|
*/ var PhysXColliderShape = /*#__PURE__*/ function() {
|
|
46
40
|
function PhysXColliderShape(physXPhysics) {
|
|
47
41
|
/** @internal */ this._controllers = new DisorderedArray();
|
|
48
|
-
/** @internal */ this.
|
|
42
|
+
/** @internal */ this._contractOffset = 0.02;
|
|
49
43
|
/** @internal */ this._worldScale = new Vector3(1, 1, 1);
|
|
50
44
|
/** @internal */ this._position = new Vector3();
|
|
51
45
|
/** @internal */ this._rotation = new Vector3();
|
|
@@ -53,7 +47,6 @@ function _inherits(subClass, superClass) {
|
|
|
53
47
|
this._physXRotation = new Quaternion();
|
|
54
48
|
this._shapeFlags = 2 | 1;
|
|
55
49
|
this._physXPhysics = physXPhysics;
|
|
56
|
-
this._contactOffset = physXPhysics.getDefaultContactOffset();
|
|
57
50
|
}
|
|
58
51
|
var _proto = PhysXColliderShape.prototype;
|
|
59
52
|
/**
|
|
@@ -91,7 +84,7 @@ function _inherits(subClass, superClass) {
|
|
|
91
84
|
* {@inheritDoc IColliderShape.setContactOffset }
|
|
92
85
|
* @default 0.02f * PxTolerancesScale::length
|
|
93
86
|
*/ _proto.setContactOffset = function setContactOffset(offset) {
|
|
94
|
-
this.
|
|
87
|
+
this._contractOffset = offset;
|
|
95
88
|
var controllers = this._controllers;
|
|
96
89
|
if (controllers.length) {
|
|
97
90
|
for(var i = 0, n = controllers.length; i < n; i++){
|
|
@@ -432,7 +425,7 @@ PhysXBoxColliderShape._tempHalfExtents = new Vector3();
|
|
|
432
425
|
this._pxManager && this._createPXController(this._pxManager, shape);
|
|
433
426
|
this._shape = shape;
|
|
434
427
|
shape._controllers.add(this);
|
|
435
|
-
(_this__pxController = this._pxController) == null ? void 0 : _this__pxController.setContactOffset(shape.
|
|
428
|
+
(_this__pxController = this._pxController) == null ? void 0 : _this__pxController.setContactOffset(shape._contractOffset);
|
|
436
429
|
(_this__scene = this._scene) == null ? void 0 : _this__scene._addColliderShape(shape._id);
|
|
437
430
|
};
|
|
438
431
|
/**
|
|
@@ -586,15 +579,7 @@ PhysXCollider._tempTransform = {
|
|
|
586
579
|
_inherits(PhysXDynamicCollider, PhysXCollider);
|
|
587
580
|
function PhysXDynamicCollider(physXPhysics, position, rotation) {
|
|
588
581
|
var _this;
|
|
589
|
-
_this = PhysXCollider.call(this, physXPhysics) || this
|
|
590
|
-
* Whether actor is currently kinematic.
|
|
591
|
-
* PhysX 拒绝在 kinematic actor 上启用 CCD(会打印警告并忽略),
|
|
592
|
-
* 所以 setCollisionDetectionMode 在 kinematic 状态下只缓存目标值,
|
|
593
|
-
* 等切回 dynamic 时再真正写到 PhysX。
|
|
594
|
-
*/ _this._isKinematic = false, /**
|
|
595
|
-
* Cached collision detection mode. Always reflects user's intent.
|
|
596
|
-
* 实际 PhysX CCD flag 可能跟这个不一致(kinematic 时强制 Discrete)。
|
|
597
|
-
*/ _this._collisionDetectionMode = 0;
|
|
582
|
+
_this = PhysXCollider.call(this, physXPhysics) || this;
|
|
598
583
|
var transform = _this._transform(position, rotation);
|
|
599
584
|
_this._pxActor = physXPhysics._pxPhysics.createRigidDynamic(transform);
|
|
600
585
|
return _this;
|
|
@@ -677,7 +662,7 @@ PhysXCollider._tempTransform = {
|
|
|
677
662
|
};
|
|
678
663
|
/**
|
|
679
664
|
* {@inheritDoc IDynamicCollider.setSleepThreshold }
|
|
680
|
-
* @default
|
|
665
|
+
* @default 1e-5f * PxTolerancesScale::speed * PxTolerancesScale::speed
|
|
681
666
|
*/ _proto.setSleepThreshold = function setSleepThreshold(value) {
|
|
682
667
|
this._pxActor.setSleepThreshold(value);
|
|
683
668
|
};
|
|
@@ -688,45 +673,7 @@ PhysXCollider._tempTransform = {
|
|
|
688
673
|
};
|
|
689
674
|
/**
|
|
690
675
|
* {@inheritDoc IDynamicCollider.setCollisionDetectionMode }
|
|
691
|
-
*
|
|
692
|
-
* PhysX 在 kinematic actor 上调用 setRigidBodyFlag(eENABLE_CCD, true) 会触发警告:
|
|
693
|
-
* "kinematic bodies with CCD enabled are not supported! CCD will be ignored"
|
|
694
|
-
* 虽然 PhysX 会忽略这次调用而非真的拒绝(切回 dynamic 时 flag 不会自动恢复),
|
|
695
|
-
* 但每次 setIsKinematic 切换都会让这个 warning 重复打印,污染日志,
|
|
696
|
-
* 同时让 actor 在 dynamic 状态下 CCD flag 状态不确定。
|
|
697
|
-
*
|
|
698
|
-
* 解决: 只在 dynamic 状态时立即 apply CCD flags。kinematic 时仅缓存到
|
|
699
|
-
* `_collisionDetectionMode`,等切回 dynamic 时由 setIsKinematic 重新 apply。
|
|
700
676
|
*/ _proto.setCollisionDetectionMode = function setCollisionDetectionMode(value) {
|
|
701
|
-
this._collisionDetectionMode = value;
|
|
702
|
-
if (!this._isKinematic) {
|
|
703
|
-
this._applyCollisionDetectionFlags(value);
|
|
704
|
-
}
|
|
705
|
-
};
|
|
706
|
-
/**
|
|
707
|
-
* {@inheritDoc IDynamicCollider.setUseGravity }
|
|
708
|
-
*/ _proto.setUseGravity = function setUseGravity(value) {
|
|
709
|
-
this._pxActor.setActorFlag(this._physXPhysics._physX.PxActorFlag.eDISABLE_GRAVITY, !value);
|
|
710
|
-
};
|
|
711
|
-
/**
|
|
712
|
-
* {@inheritDoc IDynamicCollider.setIsKinematic }
|
|
713
|
-
*
|
|
714
|
-
* 切换 kinematic 状态时同步处理 CCD flag:
|
|
715
|
-
* - 切到 kinematic 前先关 CCD(避免 PhysX 警告 + 让状态显式)
|
|
716
|
-
* - 切回 dynamic 后恢复用户期望的 CCD mode(来自 `_collisionDetectionMode` 缓存)
|
|
717
|
-
*/ _proto.setIsKinematic = function setIsKinematic(value) {
|
|
718
|
-
if (this._isKinematic === value) return;
|
|
719
|
-
var physX = this._physXPhysics._physX;
|
|
720
|
-
if (value) {
|
|
721
|
-
this._applyCollisionDetectionFlags(0);
|
|
722
|
-
this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eKINEMATIC, true);
|
|
723
|
-
} else {
|
|
724
|
-
this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eKINEMATIC, false);
|
|
725
|
-
this._applyCollisionDetectionFlags(this._collisionDetectionMode);
|
|
726
|
-
}
|
|
727
|
-
this._isKinematic = value;
|
|
728
|
-
};
|
|
729
|
-
_proto._applyCollisionDetectionFlags = function _applyCollisionDetectionFlags(value) {
|
|
730
677
|
var physX = this._physXPhysics._physX;
|
|
731
678
|
switch(value){
|
|
732
679
|
case 1:
|
|
@@ -752,20 +699,27 @@ PhysXCollider._tempTransform = {
|
|
|
752
699
|
}
|
|
753
700
|
};
|
|
754
701
|
/**
|
|
702
|
+
* {@inheritDoc IDynamicCollider.setUseGravity }
|
|
703
|
+
*/ _proto.setUseGravity = function setUseGravity(value) {
|
|
704
|
+
this._pxActor.setActorFlag(this._physXPhysics._physX.PxActorFlag.eDISABLE_GRAVITY, !value);
|
|
705
|
+
};
|
|
706
|
+
/**
|
|
707
|
+
* {@inheritDoc IDynamicCollider.setIsKinematic }
|
|
708
|
+
*/ _proto.setIsKinematic = function setIsKinematic(value) {
|
|
709
|
+
if (value) {
|
|
710
|
+
this._pxActor.setRigidBodyFlag(this._physXPhysics._physX.PxRigidBodyFlag.eKINEMATIC, true);
|
|
711
|
+
} else {
|
|
712
|
+
this._pxActor.setRigidBodyFlag(this._physXPhysics._physX.PxRigidBodyFlag.eKINEMATIC, false);
|
|
713
|
+
}
|
|
714
|
+
};
|
|
715
|
+
/**
|
|
755
716
|
* {@inheritDoc IDynamicCollider.setConstraints }
|
|
756
717
|
*/ _proto.setConstraints = function setConstraints(flags) {
|
|
757
718
|
this._pxActor.setRigidDynamicLockFlags(flags);
|
|
758
719
|
};
|
|
759
720
|
/**
|
|
760
721
|
* {@inheritDoc IDynamicCollider.addForce }
|
|
761
|
-
*
|
|
762
|
-
* PhysX 在 kinematic actor 上调 addForce 是 no-op(doc: "kinematic bodies don't
|
|
763
|
-
* respond to forces")。提前 return 避免无意义的 wasm boundary cross。
|
|
764
|
-
*
|
|
765
|
-
* Sleeping actor 不需要显式 wakeUp — wasm binding 调用 `addForce(force, eFORCE,
|
|
766
|
-
* autowake=true)`,PhysX 自动唤醒(已通过 `applyForce on sleeping actor` 测试验证)。
|
|
767
722
|
*/ _proto.addForce = function addForce(force) {
|
|
768
|
-
if (this._isKinematic) return;
|
|
769
723
|
this._pxActor.addForce(force);
|
|
770
724
|
};
|
|
771
725
|
/**
|
|
@@ -775,33 +729,23 @@ PhysXCollider._tempTransform = {
|
|
|
775
729
|
};
|
|
776
730
|
/**
|
|
777
731
|
* {@inheritDoc IDynamicCollider.addTorque }
|
|
778
|
-
*
|
|
779
|
-
* 同 addForce — kinematic 提前 return,sleeping 由 PhysX autowake 自动处理。
|
|
780
732
|
*/ _proto.addTorque = function addTorque(torque) {
|
|
781
|
-
if (this._isKinematic) return;
|
|
782
733
|
this._pxActor.addTorque(torque);
|
|
783
734
|
};
|
|
784
735
|
/**
|
|
785
736
|
* {@inheritDoc IDynamicCollider.move }
|
|
786
|
-
*
|
|
787
|
-
* PhysX 要求 setKinematicTarget 的 rotation 是 normalized quaternion,否则会触发
|
|
788
|
-
* 内部 assertion / 警告,并把 actor 转到错误的姿态。所以在写入 wasm 边界前统一 normalize。
|
|
789
737
|
*/ _proto.move = function move(positionOrRotation, rotation) {
|
|
790
|
-
var tempTranslation = PhysXDynamicCollider._tempTranslation;
|
|
791
|
-
var tempRotation = PhysXDynamicCollider._tempRotation;
|
|
792
738
|
if (rotation) {
|
|
793
|
-
|
|
794
|
-
this._pxActor.setKinematicTarget(positionOrRotation, tempRotation);
|
|
739
|
+
this._pxActor.setKinematicTarget(positionOrRotation, rotation);
|
|
795
740
|
return;
|
|
796
741
|
}
|
|
742
|
+
var tempTranslation = PhysXDynamicCollider._tempTranslation;
|
|
743
|
+
var tempRotation = PhysXDynamicCollider._tempRotation;
|
|
744
|
+
this.getWorldTransform(tempTranslation, tempRotation);
|
|
797
745
|
if (_instanceof(positionOrRotation, Vector3)) {
|
|
798
|
-
this.getWorldTransform(tempTranslation, tempRotation);
|
|
799
|
-
// current rotation read from PhysX is already normalized; no extra work needed
|
|
800
746
|
this._pxActor.setKinematicTarget(positionOrRotation, tempRotation);
|
|
801
747
|
} else {
|
|
802
|
-
this.
|
|
803
|
-
tempRotation.copyFrom(positionOrRotation).normalize();
|
|
804
|
-
this._pxActor.setKinematicTarget(tempTranslation, tempRotation);
|
|
748
|
+
this._pxActor.setKinematicTarget(tempTranslation, positionOrRotation);
|
|
805
749
|
}
|
|
806
750
|
};
|
|
807
751
|
/**
|
|
@@ -904,7 +848,6 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
904
848
|
this._activeTriggers = new DisorderedArray();
|
|
905
849
|
this._contactEvents = [];
|
|
906
850
|
this._contactEventCount = 0;
|
|
907
|
-
this._contactEventEnabled = true;
|
|
908
851
|
this._triggerEvents = [];
|
|
909
852
|
this._physicsEvents = {
|
|
910
853
|
contactEvents: [],
|
|
@@ -1027,17 +970,6 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
1027
970
|
this._fetchResults();
|
|
1028
971
|
};
|
|
1029
972
|
/**
|
|
1030
|
-
* {@inheritDoc IPhysicsScene.setContactEventEnabled }
|
|
1031
|
-
*/ _proto.setContactEventEnabled = function setContactEventEnabled(enabled) {
|
|
1032
|
-
if (this._contactEventEnabled === enabled) {
|
|
1033
|
-
return;
|
|
1034
|
-
}
|
|
1035
|
-
this._contactEventEnabled = enabled;
|
|
1036
|
-
if (!enabled) {
|
|
1037
|
-
this._contactEventCount = 0;
|
|
1038
|
-
}
|
|
1039
|
-
};
|
|
1040
|
-
/**
|
|
1041
973
|
* {@inheritDoc IPhysicsScene.updateEvents }
|
|
1042
974
|
*/ _proto.updateEvents = function updateEvents() {
|
|
1043
975
|
var physicsEvents = this._physicsEvents;
|
|
@@ -1285,7 +1217,6 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
1285
1217
|
};
|
|
1286
1218
|
_proto._bufferContactEvent = function _bufferContactEvent(collision, state) {
|
|
1287
1219
|
var _this__contactEvents, _index;
|
|
1288
|
-
if (!this._contactEventEnabled) return;
|
|
1289
1220
|
var index = this._contactEventCount++;
|
|
1290
1221
|
var event = (_this__contactEvents = this._contactEvents)[_index = index] || (_this__contactEvents[_index] = new ContactEvent());
|
|
1291
1222
|
event.shape0Id = collision.shape0Id;
|
|
@@ -1623,6 +1554,12 @@ function _assert_this_initialized(self) {
|
|
|
1623
1554
|
return self;
|
|
1624
1555
|
}
|
|
1625
1556
|
|
|
1557
|
+
function _type_of(obj) {
|
|
1558
|
+
"@swc/helpers - typeof";
|
|
1559
|
+
|
|
1560
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1626
1563
|
function _possible_constructor_return(self, call) {
|
|
1627
1564
|
if (call && (_type_of(call) === "object" || typeof call === "function")) return call;
|
|
1628
1565
|
|
|
@@ -1637,8 +1574,7 @@ function _possible_constructor_return(self, call) {
|
|
|
1637
1574
|
var _this;
|
|
1638
1575
|
_this = PhysXColliderShape.call(this, physXPhysics) || this, _this._pxMesh = null;
|
|
1639
1576
|
_this._isConvex = isConvex;
|
|
1640
|
-
|
|
1641
|
-
if (!cooked) {
|
|
1577
|
+
if (!_this._cookMesh(positions, indices, cookingFlags)) {
|
|
1642
1578
|
return _possible_constructor_return(_this);
|
|
1643
1579
|
}
|
|
1644
1580
|
var physX = physXPhysics._physX, physics = physXPhysics._pxPhysics;
|
|
@@ -1646,11 +1582,9 @@ function _possible_constructor_return(self, call) {
|
|
|
1646
1582
|
var shapeFlags = ShapeFlag.SCENE_QUERY_SHAPE | ShapeFlag.SIMULATION_SHAPE;
|
|
1647
1583
|
var meshFlag = isConvex ? PhysXMeshColliderShape._tightBoundsFlag : 0;
|
|
1648
1584
|
var createShapeFn = isConvex ? physX.createConvexMeshShape : physX.createTriMeshShape;
|
|
1649
|
-
_this._pxShape = createShapeFn(
|
|
1585
|
+
_this._pxShape = createShapeFn(_this._pxMesh, scaleX, scaleY, scaleZ, meshFlag, shapeFlags, material._pxMaterial, physics);
|
|
1650
1586
|
_this._id = uniqueID;
|
|
1651
1587
|
_this._pxMaterial = material._pxMaterial;
|
|
1652
|
-
_this._pxMesh = cooked.mesh;
|
|
1653
|
-
_this._pxGeometry = cooked.geometry;
|
|
1654
1588
|
_this._pxShape.setUUID(uniqueID);
|
|
1655
1589
|
_this._setLocalPose();
|
|
1656
1590
|
return _this;
|
|
@@ -1659,25 +1593,16 @@ function _possible_constructor_return(self, call) {
|
|
|
1659
1593
|
/**
|
|
1660
1594
|
* {@inheritDoc IMeshColliderShape.setMeshData }
|
|
1661
1595
|
*/ _proto.setMeshData = function setMeshData(positions, indices, isConvex, cookingFlags) {
|
|
1662
|
-
var
|
|
1663
|
-
|
|
1596
|
+
var _this__pxMesh, _this__pxGeometry;
|
|
1597
|
+
(_this__pxMesh = this._pxMesh) == null ? void 0 : _this__pxMesh.release();
|
|
1598
|
+
(_this__pxGeometry = this._pxGeometry) == null ? void 0 : _this__pxGeometry.delete();
|
|
1599
|
+
this._pxMesh = null;
|
|
1600
|
+
this._pxGeometry = null;
|
|
1601
|
+
this._isConvex = isConvex;
|
|
1602
|
+
if (!this._cookMesh(positions, indices, cookingFlags)) {
|
|
1664
1603
|
return false;
|
|
1665
1604
|
}
|
|
1666
|
-
|
|
1667
|
-
var oldGeometry = this._pxGeometry;
|
|
1668
|
-
try {
|
|
1669
|
-
this._pxShape.setGeometry(cooked.geometry);
|
|
1670
|
-
} catch (error) {
|
|
1671
|
-
var _cooked_mesh, _cooked_geometry;
|
|
1672
|
-
(_cooked_mesh = cooked.mesh) == null ? void 0 : _cooked_mesh.release();
|
|
1673
|
-
(_cooked_geometry = cooked.geometry) == null ? void 0 : _cooked_geometry.delete();
|
|
1674
|
-
throw error;
|
|
1675
|
-
}
|
|
1676
|
-
this._pxMesh = cooked.mesh;
|
|
1677
|
-
this._pxGeometry = cooked.geometry;
|
|
1678
|
-
this._isConvex = isConvex;
|
|
1679
|
-
oldMesh == null ? void 0 : oldMesh.release();
|
|
1680
|
-
oldGeometry == null ? void 0 : oldGeometry.delete();
|
|
1605
|
+
this._pxShape.setGeometry(this._pxGeometry);
|
|
1681
1606
|
return true;
|
|
1682
1607
|
};
|
|
1683
1608
|
/**
|
|
@@ -1693,7 +1618,7 @@ function _possible_constructor_return(self, call) {
|
|
|
1693
1618
|
(_this__pxMesh = this._pxMesh) == null ? void 0 : _this__pxMesh.release();
|
|
1694
1619
|
PhysXColliderShape.prototype.destroy.call(this);
|
|
1695
1620
|
};
|
|
1696
|
-
_proto._cookMesh = function _cookMesh(positions, indices,
|
|
1621
|
+
_proto._cookMesh = function _cookMesh(positions, indices, cookingFlags) {
|
|
1697
1622
|
var _this__physXPhysics = this._physXPhysics, physX = _this__physXPhysics._physX, physics = _this__physXPhysics._pxPhysics, cooking = _this__physXPhysics._pxCooking, cookingParams = _this__physXPhysics._pxCookingParams;
|
|
1698
1623
|
// Apply per-shape cooking flags
|
|
1699
1624
|
var preprocessFlags = 0;
|
|
@@ -1706,37 +1631,33 @@ function _possible_constructor_return(self, call) {
|
|
|
1706
1631
|
physX.setCookingMeshPreprocessParams(cookingParams, preprocessFlags);
|
|
1707
1632
|
cooking.setParams(cookingParams);
|
|
1708
1633
|
var verticesPtr = this._allocatePositions(positions);
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
pxMesh = cooking.createConvexMesh(verticesPtr, positions.length, physics);
|
|
1634
|
+
if (this._isConvex) {
|
|
1635
|
+
this._pxMesh = cooking.createConvexMesh(verticesPtr, positions.length, physics);
|
|
1712
1636
|
physX._free(verticesPtr);
|
|
1713
|
-
if (!
|
|
1637
|
+
if (!this._pxMesh) {
|
|
1714
1638
|
this._logConvexCookingError(physX);
|
|
1715
|
-
return
|
|
1639
|
+
return false;
|
|
1716
1640
|
}
|
|
1717
1641
|
} else {
|
|
1718
1642
|
if (!indices) {
|
|
1719
1643
|
physX._free(verticesPtr);
|
|
1720
1644
|
console.error("PhysXMeshColliderShape: Triangle mesh requires indices.");
|
|
1721
|
-
return
|
|
1645
|
+
return false;
|
|
1722
1646
|
}
|
|
1723
1647
|
var isU32 = _instanceof(indices, Uint32Array);
|
|
1724
1648
|
var indicesPtr = this._allocateIndices(indices, isU32);
|
|
1725
|
-
|
|
1649
|
+
this._pxMesh = cooking.createTriMesh(verticesPtr, positions.length, indicesPtr, indices.length / 3, !isU32, physics);
|
|
1726
1650
|
physX._free(verticesPtr);
|
|
1727
1651
|
physX._free(indicesPtr);
|
|
1728
|
-
if (!
|
|
1652
|
+
if (!this._pxMesh) {
|
|
1729
1653
|
this._logTriMeshCookingError(physX);
|
|
1730
|
-
return
|
|
1654
|
+
return false;
|
|
1731
1655
|
}
|
|
1732
1656
|
}
|
|
1733
1657
|
var _this__worldScale = this._worldScale, scaleX = _this__worldScale.x, scaleY = _this__worldScale.y, scaleZ = _this__worldScale.z;
|
|
1734
|
-
var meshFlag =
|
|
1735
|
-
|
|
1736
|
-
return
|
|
1737
|
-
mesh: pxMesh,
|
|
1738
|
-
geometry: geometry
|
|
1739
|
-
};
|
|
1658
|
+
var meshFlag = this._isConvex ? PhysXMeshColliderShape._tightBoundsFlag : 0;
|
|
1659
|
+
this._pxGeometry = this._isConvex ? physX.createConvexMeshGeometry(this._pxMesh, scaleX, scaleY, scaleZ, meshFlag) : physX.createTriMeshGeometry(this._pxMesh, scaleX, scaleY, scaleZ, meshFlag);
|
|
1660
|
+
return true;
|
|
1740
1661
|
};
|
|
1741
1662
|
_proto._logConvexCookingError = function _logConvexCookingError(physX) {
|
|
1742
1663
|
switch(physX.getLastConvexCookingResult()){
|
|
@@ -1786,15 +1707,9 @@ function _possible_constructor_return(self, call) {
|
|
|
1786
1707
|
var _this__worldScale = this._worldScale, scaleX = _this__worldScale.x, scaleY = _this__worldScale.y, scaleZ = _this__worldScale.z;
|
|
1787
1708
|
var meshFlag = this._isConvex ? PhysXMeshColliderShape._tightBoundsFlag : 0;
|
|
1788
1709
|
var newGeometry = this._isConvex ? physX.createConvexMeshGeometry(this._pxMesh, scaleX, scaleY, scaleZ, meshFlag) : physX.createTriMeshGeometry(this._pxMesh, scaleX, scaleY, scaleZ, meshFlag);
|
|
1789
|
-
|
|
1790
|
-
try {
|
|
1791
|
-
this._pxShape.setGeometry(newGeometry);
|
|
1792
|
-
} catch (error) {
|
|
1793
|
-
newGeometry == null ? void 0 : newGeometry.delete();
|
|
1794
|
-
throw error;
|
|
1795
|
-
}
|
|
1710
|
+
this._pxGeometry.delete();
|
|
1796
1711
|
this._pxGeometry = newGeometry;
|
|
1797
|
-
|
|
1712
|
+
this._pxShape.setGeometry(this._pxGeometry);
|
|
1798
1713
|
};
|
|
1799
1714
|
return PhysXMeshColliderShape;
|
|
1800
1715
|
}(PhysXColliderShape);
|
|
@@ -1853,27 +1768,14 @@ PhysXMeshColliderShape._tightBoundsFlag = 1 // eTIGHT_BOUNDS = 1 (1<<0)
|
|
|
1853
1768
|
/**
|
|
1854
1769
|
* PhysX object creation.
|
|
1855
1770
|
*/ var PhysXPhysics = /*#__PURE__*/ function() {
|
|
1856
|
-
function PhysXPhysics(
|
|
1857
|
-
if (
|
|
1858
|
-
var _this__tolerancesScaleOptions, _this__tolerancesScaleOptions1;
|
|
1771
|
+
function PhysXPhysics(runtimeMode, runtimeUrls) {
|
|
1772
|
+
if (runtimeMode === void 0) runtimeMode = PhysXRuntimeMode.Auto;
|
|
1859
1773
|
this._initializeState = 0;
|
|
1860
|
-
this._defaultContactOffset = 0.02;
|
|
1861
|
-
this._defaultSleepThreshold = 5e-3;
|
|
1862
|
-
var isOptionsObject = (typeof runtimeModeOrOptions === "undefined" ? "undefined" : _type_of(runtimeModeOrOptions)) === "object";
|
|
1863
|
-
var runtimeMode = isOptionsObject ? PhysXRuntimeMode.Auto : runtimeModeOrOptions != null ? runtimeModeOrOptions : PhysXRuntimeMode.Auto;
|
|
1864
|
-
var resolvedOptions = isOptionsObject ? runtimeModeOrOptions : options;
|
|
1865
1774
|
this._runTimeMode = runtimeMode;
|
|
1866
1775
|
var _runtimeUrls_wasmSIMDModeUrl;
|
|
1867
1776
|
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";
|
|
1868
1777
|
var _runtimeUrls_wasmModeUrl;
|
|
1869
1778
|
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";
|
|
1870
|
-
this._tolerancesScaleOptions = resolvedOptions == null ? void 0 : resolvedOptions.tolerancesScale;
|
|
1871
|
-
var _this__tolerancesScaleOptions_length;
|
|
1872
|
-
var length = (_this__tolerancesScaleOptions_length = (_this__tolerancesScaleOptions = this._tolerancesScaleOptions) == null ? void 0 : _this__tolerancesScaleOptions.length) != null ? _this__tolerancesScaleOptions_length : 1;
|
|
1873
|
-
var _this__tolerancesScaleOptions_speed;
|
|
1874
|
-
var speed = (_this__tolerancesScaleOptions_speed = (_this__tolerancesScaleOptions1 = this._tolerancesScaleOptions) == null ? void 0 : _this__tolerancesScaleOptions1.speed) != null ? _this__tolerancesScaleOptions_speed : 10;
|
|
1875
|
-
this._validateTolerancesScale(length, speed);
|
|
1876
|
-
this._updateScaledDefaults(length, speed);
|
|
1877
1779
|
}
|
|
1878
1780
|
var _proto = PhysXPhysics.prototype;
|
|
1879
1781
|
/**
|
|
@@ -1943,16 +1845,6 @@ PhysXMeshColliderShape._tightBoundsFlag = 1 // eTIGHT_BOUNDS = 1 (1<<0)
|
|
|
1943
1845
|
return scene;
|
|
1944
1846
|
};
|
|
1945
1847
|
/**
|
|
1946
|
-
* {@inheritDoc IPhysics.getDefaultContactOffset }
|
|
1947
|
-
*/ _proto.getDefaultContactOffset = function getDefaultContactOffset() {
|
|
1948
|
-
return this._defaultContactOffset;
|
|
1949
|
-
};
|
|
1950
|
-
/**
|
|
1951
|
-
* {@inheritDoc IPhysics.getDefaultSleepThreshold }
|
|
1952
|
-
*/ _proto.getDefaultSleepThreshold = function getDefaultSleepThreshold() {
|
|
1953
|
-
return this._defaultSleepThreshold;
|
|
1954
|
-
};
|
|
1955
|
-
/**
|
|
1956
1848
|
* {@inheritDoc IPhysics.createStaticCollider }
|
|
1957
1849
|
*/ _proto.createStaticCollider = function createStaticCollider(position, rotation) {
|
|
1958
1850
|
return new PhysXStaticCollider(this, position, rotation);
|
|
@@ -2029,7 +1921,6 @@ PhysXMeshColliderShape._tightBoundsFlag = 1 // eTIGHT_BOUNDS = 1 (1<<0)
|
|
|
2029
1921
|
var allocator = new physX.PxDefaultAllocator();
|
|
2030
1922
|
var pxFoundation = physX.PxCreateFoundation(version, allocator, defaultErrorCallback);
|
|
2031
1923
|
var tolerancesScale = new physX.PxTolerancesScale();
|
|
2032
|
-
this._applyTolerancesScale(tolerancesScale);
|
|
2033
1924
|
var pxPhysics = physX.PxCreatePhysics(version, pxFoundation, tolerancesScale, false, null);
|
|
2034
1925
|
physX.PxInitExtensions(pxPhysics, null);
|
|
2035
1926
|
// Initialize cooking for mesh colliders
|
|
@@ -2050,35 +1941,11 @@ PhysXMeshColliderShape._tightBoundsFlag = 1 // eTIGHT_BOUNDS = 1 (1<<0)
|
|
|
2050
1941
|
this._allocator = allocator;
|
|
2051
1942
|
this._tolerancesScale = tolerancesScale;
|
|
2052
1943
|
};
|
|
2053
|
-
_proto._applyTolerancesScale = function _applyTolerancesScale(tolerancesScale) {
|
|
2054
|
-
var _this__tolerancesScaleOptions, _this__tolerancesScaleOptions1;
|
|
2055
|
-
var _this__tolerancesScaleOptions_length;
|
|
2056
|
-
var length = (_this__tolerancesScaleOptions_length = (_this__tolerancesScaleOptions = this._tolerancesScaleOptions) == null ? void 0 : _this__tolerancesScaleOptions.length) != null ? _this__tolerancesScaleOptions_length : tolerancesScale.length;
|
|
2057
|
-
var _this__tolerancesScaleOptions_speed;
|
|
2058
|
-
var speed = (_this__tolerancesScaleOptions_speed = (_this__tolerancesScaleOptions1 = this._tolerancesScaleOptions) == null ? void 0 : _this__tolerancesScaleOptions1.speed) != null ? _this__tolerancesScaleOptions_speed : tolerancesScale.speed;
|
|
2059
|
-
this._validateTolerancesScale(length, speed);
|
|
2060
|
-
tolerancesScale.length = length;
|
|
2061
|
-
tolerancesScale.speed = speed;
|
|
2062
|
-
this._updateScaledDefaults(length, speed);
|
|
2063
|
-
};
|
|
2064
|
-
_proto._assertPositiveFinite = function _assertPositiveFinite(value, name) {
|
|
2065
|
-
if (!Number.isFinite(value) || value <= 0) {
|
|
2066
|
-
throw new Error("PhysXPhysics " + name + " must be a positive finite number.");
|
|
2067
|
-
}
|
|
2068
|
-
};
|
|
2069
|
-
_proto._validateTolerancesScale = function _validateTolerancesScale(length, speed) {
|
|
2070
|
-
this._assertPositiveFinite(length, "tolerancesScale.length");
|
|
2071
|
-
this._assertPositiveFinite(speed, "tolerancesScale.speed");
|
|
2072
|
-
};
|
|
2073
|
-
_proto._updateScaledDefaults = function _updateScaledDefaults(length, speed) {
|
|
2074
|
-
this._defaultContactOffset = 0.02 * length;
|
|
2075
|
-
this._defaultSleepThreshold = 5e-5 * speed * speed;
|
|
2076
|
-
};
|
|
2077
1944
|
return PhysXPhysics;
|
|
2078
1945
|
}();
|
|
2079
1946
|
|
|
2080
1947
|
//@ts-ignore
|
|
2081
|
-
var version = "0.0.0-experimental-2.0-
|
|
1948
|
+
var version = "0.0.0-experimental-2.0-skill.0";
|
|
2082
1949
|
console.log("Galacean Engine Physics PhysX Version: " + version);
|
|
2083
1950
|
|
|
2084
1951
|
export { PhysXPhysics, PhysXRuntimeMode, version };
|