@galacean/engine-physics-physx 0.0.0-experimental-2.0-migrate.5 → 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 +60 -191
- 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 +60 -191
- package/dist/main.js.map +1 -1
- package/dist/module.js +60 -191
- package/dist/module.js.map +1 -1
- package/package.json +6 -5
- 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/browser.js
CHANGED
|
@@ -4,12 +4,6 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.Galacean = global.Galacean || {}, global.Galacean.PhysicsPhysX = {}), global.Galacean));
|
|
5
5
|
})(this, (function (exports, engine) { 'use strict';
|
|
6
6
|
|
|
7
|
-
function _type_of(obj) {
|
|
8
|
-
"@swc/helpers - typeof";
|
|
9
|
-
|
|
10
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
7
|
function _instanceof(left, right) {
|
|
14
8
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
15
9
|
return !!right[Symbol.hasInstance](left);
|
|
@@ -49,7 +43,7 @@
|
|
|
49
43
|
*/ var PhysXColliderShape = /*#__PURE__*/ function() {
|
|
50
44
|
function PhysXColliderShape(physXPhysics) {
|
|
51
45
|
/** @internal */ this._controllers = new engine.DisorderedArray();
|
|
52
|
-
/** @internal */ this.
|
|
46
|
+
/** @internal */ this._contractOffset = 0.02;
|
|
53
47
|
/** @internal */ this._worldScale = new engine.Vector3(1, 1, 1);
|
|
54
48
|
/** @internal */ this._position = new engine.Vector3();
|
|
55
49
|
/** @internal */ this._rotation = new engine.Vector3();
|
|
@@ -57,7 +51,6 @@
|
|
|
57
51
|
this._physXRotation = new engine.Quaternion();
|
|
58
52
|
this._shapeFlags = 2 | 1;
|
|
59
53
|
this._physXPhysics = physXPhysics;
|
|
60
|
-
this._contactOffset = physXPhysics.getDefaultContactOffset();
|
|
61
54
|
}
|
|
62
55
|
var _proto = PhysXColliderShape.prototype;
|
|
63
56
|
/**
|
|
@@ -95,7 +88,7 @@
|
|
|
95
88
|
* {@inheritDoc IColliderShape.setContactOffset }
|
|
96
89
|
* @default 0.02f * PxTolerancesScale::length
|
|
97
90
|
*/ _proto.setContactOffset = function setContactOffset(offset) {
|
|
98
|
-
this.
|
|
91
|
+
this._contractOffset = offset;
|
|
99
92
|
var controllers = this._controllers;
|
|
100
93
|
if (controllers.length) {
|
|
101
94
|
for(var i = 0, n = controllers.length; i < n; i++){
|
|
@@ -436,7 +429,7 @@
|
|
|
436
429
|
this._pxManager && this._createPXController(this._pxManager, shape);
|
|
437
430
|
this._shape = shape;
|
|
438
431
|
shape._controllers.add(this);
|
|
439
|
-
(_this__pxController = this._pxController) == null ? void 0 : _this__pxController.setContactOffset(shape.
|
|
432
|
+
(_this__pxController = this._pxController) == null ? void 0 : _this__pxController.setContactOffset(shape._contractOffset);
|
|
440
433
|
(_this__scene = this._scene) == null ? void 0 : _this__scene._addColliderShape(shape._id);
|
|
441
434
|
};
|
|
442
435
|
/**
|
|
@@ -532,7 +525,9 @@
|
|
|
532
525
|
* {@inheritDoc ICollider.addShape }
|
|
533
526
|
*/ _proto.addShape = function addShape(shape) {
|
|
534
527
|
var _this__scene;
|
|
535
|
-
this._pxActor.attachShape(shape._pxShape)
|
|
528
|
+
if (!this._pxActor.attachShape(shape._pxShape)) {
|
|
529
|
+
throw new Error("PhysXCollider: failed to attach shape to the native actor.");
|
|
530
|
+
}
|
|
536
531
|
this._shapes.push(shape);
|
|
537
532
|
(_this__scene = this._scene) == null ? void 0 : _this__scene._addColliderShape(shape._id);
|
|
538
533
|
};
|
|
@@ -588,15 +583,7 @@
|
|
|
588
583
|
_inherits(PhysXDynamicCollider, PhysXCollider);
|
|
589
584
|
function PhysXDynamicCollider(physXPhysics, position, rotation) {
|
|
590
585
|
var _this;
|
|
591
|
-
_this = PhysXCollider.call(this, physXPhysics) || this
|
|
592
|
-
* Whether actor is currently kinematic.
|
|
593
|
-
* PhysX 拒绝在 kinematic actor 上启用 CCD(会打印警告并忽略),
|
|
594
|
-
* 所以 setCollisionDetectionMode 在 kinematic 状态下只缓存目标值,
|
|
595
|
-
* 等切回 dynamic 时再真正写到 PhysX。
|
|
596
|
-
*/ _this._isKinematic = false, /**
|
|
597
|
-
* Cached collision detection mode. Always reflects user's intent.
|
|
598
|
-
* 实际 PhysX CCD flag 可能跟这个不一致(kinematic 时强制 Discrete)。
|
|
599
|
-
*/ _this._collisionDetectionMode = 0;
|
|
586
|
+
_this = PhysXCollider.call(this, physXPhysics) || this;
|
|
600
587
|
var transform = _this._transform(position, rotation);
|
|
601
588
|
_this._pxActor = physXPhysics._pxPhysics.createRigidDynamic(transform);
|
|
602
589
|
return _this;
|
|
@@ -679,7 +666,7 @@
|
|
|
679
666
|
};
|
|
680
667
|
/**
|
|
681
668
|
* {@inheritDoc IDynamicCollider.setSleepThreshold }
|
|
682
|
-
* @default
|
|
669
|
+
* @default 1e-5f * PxTolerancesScale::speed * PxTolerancesScale::speed
|
|
683
670
|
*/ _proto.setSleepThreshold = function setSleepThreshold(value) {
|
|
684
671
|
this._pxActor.setSleepThreshold(value);
|
|
685
672
|
};
|
|
@@ -690,45 +677,7 @@
|
|
|
690
677
|
};
|
|
691
678
|
/**
|
|
692
679
|
* {@inheritDoc IDynamicCollider.setCollisionDetectionMode }
|
|
693
|
-
*
|
|
694
|
-
* PhysX 在 kinematic actor 上调用 setRigidBodyFlag(eENABLE_CCD, true) 会触发警告:
|
|
695
|
-
* "kinematic bodies with CCD enabled are not supported! CCD will be ignored"
|
|
696
|
-
* 虽然 PhysX 会忽略这次调用而非真的拒绝(切回 dynamic 时 flag 不会自动恢复),
|
|
697
|
-
* 但每次 setIsKinematic 切换都会让这个 warning 重复打印,污染日志,
|
|
698
|
-
* 同时让 actor 在 dynamic 状态下 CCD flag 状态不确定。
|
|
699
|
-
*
|
|
700
|
-
* 解决: 只在 dynamic 状态时立即 apply CCD flags。kinematic 时仅缓存到
|
|
701
|
-
* `_collisionDetectionMode`,等切回 dynamic 时由 setIsKinematic 重新 apply。
|
|
702
680
|
*/ _proto.setCollisionDetectionMode = function setCollisionDetectionMode(value) {
|
|
703
|
-
this._collisionDetectionMode = value;
|
|
704
|
-
if (!this._isKinematic) {
|
|
705
|
-
this._applyCollisionDetectionFlags(value);
|
|
706
|
-
}
|
|
707
|
-
};
|
|
708
|
-
/**
|
|
709
|
-
* {@inheritDoc IDynamicCollider.setUseGravity }
|
|
710
|
-
*/ _proto.setUseGravity = function setUseGravity(value) {
|
|
711
|
-
this._pxActor.setActorFlag(this._physXPhysics._physX.PxActorFlag.eDISABLE_GRAVITY, !value);
|
|
712
|
-
};
|
|
713
|
-
/**
|
|
714
|
-
* {@inheritDoc IDynamicCollider.setIsKinematic }
|
|
715
|
-
*
|
|
716
|
-
* 切换 kinematic 状态时同步处理 CCD flag:
|
|
717
|
-
* - 切到 kinematic 前先关 CCD(避免 PhysX 警告 + 让状态显式)
|
|
718
|
-
* - 切回 dynamic 后恢复用户期望的 CCD mode(来自 `_collisionDetectionMode` 缓存)
|
|
719
|
-
*/ _proto.setIsKinematic = function setIsKinematic(value) {
|
|
720
|
-
if (this._isKinematic === value) return;
|
|
721
|
-
var physX = this._physXPhysics._physX;
|
|
722
|
-
if (value) {
|
|
723
|
-
this._applyCollisionDetectionFlags(0);
|
|
724
|
-
this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eKINEMATIC, true);
|
|
725
|
-
} else {
|
|
726
|
-
this._pxActor.setRigidBodyFlag(physX.PxRigidBodyFlag.eKINEMATIC, false);
|
|
727
|
-
this._applyCollisionDetectionFlags(this._collisionDetectionMode);
|
|
728
|
-
}
|
|
729
|
-
this._isKinematic = value;
|
|
730
|
-
};
|
|
731
|
-
_proto._applyCollisionDetectionFlags = function _applyCollisionDetectionFlags(value) {
|
|
732
681
|
var physX = this._physXPhysics._physX;
|
|
733
682
|
switch(value){
|
|
734
683
|
case 1:
|
|
@@ -754,20 +703,27 @@
|
|
|
754
703
|
}
|
|
755
704
|
};
|
|
756
705
|
/**
|
|
706
|
+
* {@inheritDoc IDynamicCollider.setUseGravity }
|
|
707
|
+
*/ _proto.setUseGravity = function setUseGravity(value) {
|
|
708
|
+
this._pxActor.setActorFlag(this._physXPhysics._physX.PxActorFlag.eDISABLE_GRAVITY, !value);
|
|
709
|
+
};
|
|
710
|
+
/**
|
|
711
|
+
* {@inheritDoc IDynamicCollider.setIsKinematic }
|
|
712
|
+
*/ _proto.setIsKinematic = function setIsKinematic(value) {
|
|
713
|
+
if (value) {
|
|
714
|
+
this._pxActor.setRigidBodyFlag(this._physXPhysics._physX.PxRigidBodyFlag.eKINEMATIC, true);
|
|
715
|
+
} else {
|
|
716
|
+
this._pxActor.setRigidBodyFlag(this._physXPhysics._physX.PxRigidBodyFlag.eKINEMATIC, false);
|
|
717
|
+
}
|
|
718
|
+
};
|
|
719
|
+
/**
|
|
757
720
|
* {@inheritDoc IDynamicCollider.setConstraints }
|
|
758
721
|
*/ _proto.setConstraints = function setConstraints(flags) {
|
|
759
722
|
this._pxActor.setRigidDynamicLockFlags(flags);
|
|
760
723
|
};
|
|
761
724
|
/**
|
|
762
725
|
* {@inheritDoc IDynamicCollider.addForce }
|
|
763
|
-
*
|
|
764
|
-
* PhysX 在 kinematic actor 上调 addForce 是 no-op(doc: "kinematic bodies don't
|
|
765
|
-
* respond to forces")。提前 return 避免无意义的 wasm boundary cross。
|
|
766
|
-
*
|
|
767
|
-
* Sleeping actor 不需要显式 wakeUp — wasm binding 调用 `addForce(force, eFORCE,
|
|
768
|
-
* autowake=true)`,PhysX 自动唤醒(已通过 `applyForce on sleeping actor` 测试验证)。
|
|
769
726
|
*/ _proto.addForce = function addForce(force) {
|
|
770
|
-
if (this._isKinematic) return;
|
|
771
727
|
this._pxActor.addForce(force);
|
|
772
728
|
};
|
|
773
729
|
/**
|
|
@@ -777,33 +733,23 @@
|
|
|
777
733
|
};
|
|
778
734
|
/**
|
|
779
735
|
* {@inheritDoc IDynamicCollider.addTorque }
|
|
780
|
-
*
|
|
781
|
-
* 同 addForce — kinematic 提前 return,sleeping 由 PhysX autowake 自动处理。
|
|
782
736
|
*/ _proto.addTorque = function addTorque(torque) {
|
|
783
|
-
if (this._isKinematic) return;
|
|
784
737
|
this._pxActor.addTorque(torque);
|
|
785
738
|
};
|
|
786
739
|
/**
|
|
787
740
|
* {@inheritDoc IDynamicCollider.move }
|
|
788
|
-
*
|
|
789
|
-
* PhysX 要求 setKinematicTarget 的 rotation 是 normalized quaternion,否则会触发
|
|
790
|
-
* 内部 assertion / 警告,并把 actor 转到错误的姿态。所以在写入 wasm 边界前统一 normalize。
|
|
791
741
|
*/ _proto.move = function move(positionOrRotation, rotation) {
|
|
792
|
-
var tempTranslation = PhysXDynamicCollider._tempTranslation;
|
|
793
|
-
var tempRotation = PhysXDynamicCollider._tempRotation;
|
|
794
742
|
if (rotation) {
|
|
795
|
-
|
|
796
|
-
this._pxActor.setKinematicTarget(positionOrRotation, tempRotation);
|
|
743
|
+
this._pxActor.setKinematicTarget(positionOrRotation, rotation);
|
|
797
744
|
return;
|
|
798
745
|
}
|
|
746
|
+
var tempTranslation = PhysXDynamicCollider._tempTranslation;
|
|
747
|
+
var tempRotation = PhysXDynamicCollider._tempRotation;
|
|
748
|
+
this.getWorldTransform(tempTranslation, tempRotation);
|
|
799
749
|
if (_instanceof(positionOrRotation, engine.Vector3)) {
|
|
800
|
-
this.getWorldTransform(tempTranslation, tempRotation);
|
|
801
|
-
// current rotation read from PhysX is already normalized; no extra work needed
|
|
802
750
|
this._pxActor.setKinematicTarget(positionOrRotation, tempRotation);
|
|
803
751
|
} else {
|
|
804
|
-
this.
|
|
805
|
-
tempRotation.copyFrom(positionOrRotation).normalize();
|
|
806
|
-
this._pxActor.setKinematicTarget(tempTranslation, tempRotation);
|
|
752
|
+
this._pxActor.setKinematicTarget(tempTranslation, positionOrRotation);
|
|
807
753
|
}
|
|
808
754
|
};
|
|
809
755
|
/**
|
|
@@ -906,7 +852,6 @@
|
|
|
906
852
|
this._activeTriggers = new engine.DisorderedArray();
|
|
907
853
|
this._contactEvents = [];
|
|
908
854
|
this._contactEventCount = 0;
|
|
909
|
-
this._contactEventEnabled = true;
|
|
910
855
|
this._triggerEvents = [];
|
|
911
856
|
this._physicsEvents = {
|
|
912
857
|
contactEvents: [],
|
|
@@ -1029,17 +974,6 @@
|
|
|
1029
974
|
this._fetchResults();
|
|
1030
975
|
};
|
|
1031
976
|
/**
|
|
1032
|
-
* {@inheritDoc IPhysicsScene.setContactEventEnabled }
|
|
1033
|
-
*/ _proto.setContactEventEnabled = function setContactEventEnabled(enabled) {
|
|
1034
|
-
if (this._contactEventEnabled === enabled) {
|
|
1035
|
-
return;
|
|
1036
|
-
}
|
|
1037
|
-
this._contactEventEnabled = enabled;
|
|
1038
|
-
if (!enabled) {
|
|
1039
|
-
this._contactEventCount = 0;
|
|
1040
|
-
}
|
|
1041
|
-
};
|
|
1042
|
-
/**
|
|
1043
977
|
* {@inheritDoc IPhysicsScene.updateEvents }
|
|
1044
978
|
*/ _proto.updateEvents = function updateEvents() {
|
|
1045
979
|
var physicsEvents = this._physicsEvents;
|
|
@@ -1287,7 +1221,6 @@
|
|
|
1287
1221
|
};
|
|
1288
1222
|
_proto._bufferContactEvent = function _bufferContactEvent(collision, state) {
|
|
1289
1223
|
var _this__contactEvents, _index;
|
|
1290
|
-
if (!this._contactEventEnabled) return;
|
|
1291
1224
|
var index = this._contactEventCount++;
|
|
1292
1225
|
var event = (_this__contactEvents = this._contactEvents)[_index = index] || (_this__contactEvents[_index] = new ContactEvent());
|
|
1293
1226
|
event.shape0Id = collision.shape0Id;
|
|
@@ -1625,6 +1558,12 @@
|
|
|
1625
1558
|
return self;
|
|
1626
1559
|
}
|
|
1627
1560
|
|
|
1561
|
+
function _type_of(obj) {
|
|
1562
|
+
"@swc/helpers - typeof";
|
|
1563
|
+
|
|
1564
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1628
1567
|
function _possible_constructor_return(self, call) {
|
|
1629
1568
|
if (call && (_type_of(call) === "object" || typeof call === "function")) return call;
|
|
1630
1569
|
|
|
@@ -1639,8 +1578,7 @@
|
|
|
1639
1578
|
var _this;
|
|
1640
1579
|
_this = PhysXColliderShape.call(this, physXPhysics) || this, _this._pxMesh = null;
|
|
1641
1580
|
_this._isConvex = isConvex;
|
|
1642
|
-
|
|
1643
|
-
if (!cooked) {
|
|
1581
|
+
if (!_this._cookMesh(positions, indices, cookingFlags)) {
|
|
1644
1582
|
return _possible_constructor_return(_this);
|
|
1645
1583
|
}
|
|
1646
1584
|
var physX = physXPhysics._physX, physics = physXPhysics._pxPhysics;
|
|
@@ -1648,11 +1586,9 @@
|
|
|
1648
1586
|
var shapeFlags = ShapeFlag.SCENE_QUERY_SHAPE | ShapeFlag.SIMULATION_SHAPE;
|
|
1649
1587
|
var meshFlag = isConvex ? PhysXMeshColliderShape._tightBoundsFlag : 0;
|
|
1650
1588
|
var createShapeFn = isConvex ? physX.createConvexMeshShape : physX.createTriMeshShape;
|
|
1651
|
-
_this._pxShape = createShapeFn(
|
|
1589
|
+
_this._pxShape = createShapeFn(_this._pxMesh, scaleX, scaleY, scaleZ, meshFlag, shapeFlags, material._pxMaterial, physics);
|
|
1652
1590
|
_this._id = uniqueID;
|
|
1653
1591
|
_this._pxMaterial = material._pxMaterial;
|
|
1654
|
-
_this._pxMesh = cooked.mesh;
|
|
1655
|
-
_this._pxGeometry = cooked.geometry;
|
|
1656
1592
|
_this._pxShape.setUUID(uniqueID);
|
|
1657
1593
|
_this._setLocalPose();
|
|
1658
1594
|
return _this;
|
|
@@ -1661,25 +1597,16 @@
|
|
|
1661
1597
|
/**
|
|
1662
1598
|
* {@inheritDoc IMeshColliderShape.setMeshData }
|
|
1663
1599
|
*/ _proto.setMeshData = function setMeshData(positions, indices, isConvex, cookingFlags) {
|
|
1664
|
-
var
|
|
1665
|
-
|
|
1600
|
+
var _this__pxMesh, _this__pxGeometry;
|
|
1601
|
+
(_this__pxMesh = this._pxMesh) == null ? void 0 : _this__pxMesh.release();
|
|
1602
|
+
(_this__pxGeometry = this._pxGeometry) == null ? void 0 : _this__pxGeometry.delete();
|
|
1603
|
+
this._pxMesh = null;
|
|
1604
|
+
this._pxGeometry = null;
|
|
1605
|
+
this._isConvex = isConvex;
|
|
1606
|
+
if (!this._cookMesh(positions, indices, cookingFlags)) {
|
|
1666
1607
|
return false;
|
|
1667
1608
|
}
|
|
1668
|
-
|
|
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();
|
|
1609
|
+
this._pxShape.setGeometry(this._pxGeometry);
|
|
1683
1610
|
return true;
|
|
1684
1611
|
};
|
|
1685
1612
|
/**
|
|
@@ -1695,7 +1622,7 @@
|
|
|
1695
1622
|
(_this__pxMesh = this._pxMesh) == null ? void 0 : _this__pxMesh.release();
|
|
1696
1623
|
PhysXColliderShape.prototype.destroy.call(this);
|
|
1697
1624
|
};
|
|
1698
|
-
_proto._cookMesh = function _cookMesh(positions, indices,
|
|
1625
|
+
_proto._cookMesh = function _cookMesh(positions, indices, cookingFlags) {
|
|
1699
1626
|
var _this__physXPhysics = this._physXPhysics, physX = _this__physXPhysics._physX, physics = _this__physXPhysics._pxPhysics, cooking = _this__physXPhysics._pxCooking, cookingParams = _this__physXPhysics._pxCookingParams;
|
|
1700
1627
|
// Apply per-shape cooking flags
|
|
1701
1628
|
var preprocessFlags = 0;
|
|
@@ -1708,37 +1635,33 @@
|
|
|
1708
1635
|
physX.setCookingMeshPreprocessParams(cookingParams, preprocessFlags);
|
|
1709
1636
|
cooking.setParams(cookingParams);
|
|
1710
1637
|
var verticesPtr = this._allocatePositions(positions);
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
pxMesh = cooking.createConvexMesh(verticesPtr, positions.length, physics);
|
|
1638
|
+
if (this._isConvex) {
|
|
1639
|
+
this._pxMesh = cooking.createConvexMesh(verticesPtr, positions.length, physics);
|
|
1714
1640
|
physX._free(verticesPtr);
|
|
1715
|
-
if (!
|
|
1641
|
+
if (!this._pxMesh) {
|
|
1716
1642
|
this._logConvexCookingError(physX);
|
|
1717
|
-
return
|
|
1643
|
+
return false;
|
|
1718
1644
|
}
|
|
1719
1645
|
} else {
|
|
1720
1646
|
if (!indices) {
|
|
1721
1647
|
physX._free(verticesPtr);
|
|
1722
1648
|
console.error("PhysXMeshColliderShape: Triangle mesh requires indices.");
|
|
1723
|
-
return
|
|
1649
|
+
return false;
|
|
1724
1650
|
}
|
|
1725
1651
|
var isU32 = _instanceof(indices, Uint32Array);
|
|
1726
1652
|
var indicesPtr = this._allocateIndices(indices, isU32);
|
|
1727
|
-
|
|
1653
|
+
this._pxMesh = cooking.createTriMesh(verticesPtr, positions.length, indicesPtr, indices.length / 3, !isU32, physics);
|
|
1728
1654
|
physX._free(verticesPtr);
|
|
1729
1655
|
physX._free(indicesPtr);
|
|
1730
|
-
if (!
|
|
1656
|
+
if (!this._pxMesh) {
|
|
1731
1657
|
this._logTriMeshCookingError(physX);
|
|
1732
|
-
return
|
|
1658
|
+
return false;
|
|
1733
1659
|
}
|
|
1734
1660
|
}
|
|
1735
1661
|
var _this__worldScale = this._worldScale, scaleX = _this__worldScale.x, scaleY = _this__worldScale.y, scaleZ = _this__worldScale.z;
|
|
1736
|
-
var meshFlag =
|
|
1737
|
-
|
|
1738
|
-
return
|
|
1739
|
-
mesh: pxMesh,
|
|
1740
|
-
geometry: geometry
|
|
1741
|
-
};
|
|
1662
|
+
var meshFlag = this._isConvex ? PhysXMeshColliderShape._tightBoundsFlag : 0;
|
|
1663
|
+
this._pxGeometry = this._isConvex ? physX.createConvexMeshGeometry(this._pxMesh, scaleX, scaleY, scaleZ, meshFlag) : physX.createTriMeshGeometry(this._pxMesh, scaleX, scaleY, scaleZ, meshFlag);
|
|
1664
|
+
return true;
|
|
1742
1665
|
};
|
|
1743
1666
|
_proto._logConvexCookingError = function _logConvexCookingError(physX) {
|
|
1744
1667
|
switch(physX.getLastConvexCookingResult()){
|
|
@@ -1788,15 +1711,9 @@
|
|
|
1788
1711
|
var _this__worldScale = this._worldScale, scaleX = _this__worldScale.x, scaleY = _this__worldScale.y, scaleZ = _this__worldScale.z;
|
|
1789
1712
|
var meshFlag = this._isConvex ? PhysXMeshColliderShape._tightBoundsFlag : 0;
|
|
1790
1713
|
var newGeometry = this._isConvex ? physX.createConvexMeshGeometry(this._pxMesh, scaleX, scaleY, scaleZ, meshFlag) : physX.createTriMeshGeometry(this._pxMesh, scaleX, scaleY, scaleZ, meshFlag);
|
|
1791
|
-
|
|
1792
|
-
try {
|
|
1793
|
-
this._pxShape.setGeometry(newGeometry);
|
|
1794
|
-
} catch (error) {
|
|
1795
|
-
newGeometry == null ? void 0 : newGeometry.delete();
|
|
1796
|
-
throw error;
|
|
1797
|
-
}
|
|
1714
|
+
this._pxGeometry.delete();
|
|
1798
1715
|
this._pxGeometry = newGeometry;
|
|
1799
|
-
|
|
1716
|
+
this._pxShape.setGeometry(this._pxGeometry);
|
|
1800
1717
|
};
|
|
1801
1718
|
return PhysXMeshColliderShape;
|
|
1802
1719
|
}(PhysXColliderShape);
|
|
@@ -1855,27 +1772,14 @@
|
|
|
1855
1772
|
/**
|
|
1856
1773
|
* PhysX object creation.
|
|
1857
1774
|
*/ var PhysXPhysics = /*#__PURE__*/ function() {
|
|
1858
|
-
function PhysXPhysics(
|
|
1859
|
-
if (
|
|
1860
|
-
var _this__tolerancesScaleOptions, _this__tolerancesScaleOptions1;
|
|
1775
|
+
function PhysXPhysics(runtimeMode, runtimeUrls) {
|
|
1776
|
+
if (runtimeMode === void 0) runtimeMode = PhysXRuntimeMode.Auto;
|
|
1861
1777
|
this._initializeState = 0;
|
|
1862
|
-
this._defaultContactOffset = 0.02;
|
|
1863
|
-
this._defaultSleepThreshold = 5e-3;
|
|
1864
|
-
var isOptionsObject = (typeof runtimeModeOrOptions === "undefined" ? "undefined" : _type_of(runtimeModeOrOptions)) === "object";
|
|
1865
|
-
var runtimeMode = isOptionsObject ? PhysXRuntimeMode.Auto : runtimeModeOrOptions != null ? runtimeModeOrOptions : PhysXRuntimeMode.Auto;
|
|
1866
|
-
var resolvedOptions = isOptionsObject ? runtimeModeOrOptions : options;
|
|
1867
1778
|
this._runTimeMode = runtimeMode;
|
|
1868
1779
|
var _runtimeUrls_wasmSIMDModeUrl;
|
|
1869
1780
|
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";
|
|
1870
1781
|
var _runtimeUrls_wasmModeUrl;
|
|
1871
1782
|
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";
|
|
1872
|
-
this._tolerancesScaleOptions = resolvedOptions == null ? void 0 : resolvedOptions.tolerancesScale;
|
|
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);
|
|
1879
1783
|
}
|
|
1880
1784
|
var _proto = PhysXPhysics.prototype;
|
|
1881
1785
|
/**
|
|
@@ -1945,16 +1849,6 @@
|
|
|
1945
1849
|
return scene;
|
|
1946
1850
|
};
|
|
1947
1851
|
/**
|
|
1948
|
-
* {@inheritDoc IPhysics.getDefaultContactOffset }
|
|
1949
|
-
*/ _proto.getDefaultContactOffset = function getDefaultContactOffset() {
|
|
1950
|
-
return this._defaultContactOffset;
|
|
1951
|
-
};
|
|
1952
|
-
/**
|
|
1953
|
-
* {@inheritDoc IPhysics.getDefaultSleepThreshold }
|
|
1954
|
-
*/ _proto.getDefaultSleepThreshold = function getDefaultSleepThreshold() {
|
|
1955
|
-
return this._defaultSleepThreshold;
|
|
1956
|
-
};
|
|
1957
|
-
/**
|
|
1958
1852
|
* {@inheritDoc IPhysics.createStaticCollider }
|
|
1959
1853
|
*/ _proto.createStaticCollider = function createStaticCollider(position, rotation) {
|
|
1960
1854
|
return new PhysXStaticCollider(this, position, rotation);
|
|
@@ -2031,7 +1925,6 @@
|
|
|
2031
1925
|
var allocator = new physX.PxDefaultAllocator();
|
|
2032
1926
|
var pxFoundation = physX.PxCreateFoundation(version, allocator, defaultErrorCallback);
|
|
2033
1927
|
var tolerancesScale = new physX.PxTolerancesScale();
|
|
2034
|
-
this._applyTolerancesScale(tolerancesScale);
|
|
2035
1928
|
var pxPhysics = physX.PxCreatePhysics(version, pxFoundation, tolerancesScale, false, null);
|
|
2036
1929
|
physX.PxInitExtensions(pxPhysics, null);
|
|
2037
1930
|
// Initialize cooking for mesh colliders
|
|
@@ -2052,35 +1945,11 @@
|
|
|
2052
1945
|
this._allocator = allocator;
|
|
2053
1946
|
this._tolerancesScale = tolerancesScale;
|
|
2054
1947
|
};
|
|
2055
|
-
_proto._applyTolerancesScale = function _applyTolerancesScale(tolerancesScale) {
|
|
2056
|
-
var _this__tolerancesScaleOptions, _this__tolerancesScaleOptions1;
|
|
2057
|
-
var _this__tolerancesScaleOptions_length;
|
|
2058
|
-
var length = (_this__tolerancesScaleOptions_length = (_this__tolerancesScaleOptions = this._tolerancesScaleOptions) == null ? void 0 : _this__tolerancesScaleOptions.length) != null ? _this__tolerancesScaleOptions_length : tolerancesScale.length;
|
|
2059
|
-
var _this__tolerancesScaleOptions_speed;
|
|
2060
|
-
var speed = (_this__tolerancesScaleOptions_speed = (_this__tolerancesScaleOptions1 = this._tolerancesScaleOptions) == null ? void 0 : _this__tolerancesScaleOptions1.speed) != null ? _this__tolerancesScaleOptions_speed : tolerancesScale.speed;
|
|
2061
|
-
this._validateTolerancesScale(length, speed);
|
|
2062
|
-
tolerancesScale.length = length;
|
|
2063
|
-
tolerancesScale.speed = speed;
|
|
2064
|
-
this._updateScaledDefaults(length, speed);
|
|
2065
|
-
};
|
|
2066
|
-
_proto._assertPositiveFinite = function _assertPositiveFinite(value, name) {
|
|
2067
|
-
if (!Number.isFinite(value) || value <= 0) {
|
|
2068
|
-
throw new Error("PhysXPhysics " + name + " must be a positive finite number.");
|
|
2069
|
-
}
|
|
2070
|
-
};
|
|
2071
|
-
_proto._validateTolerancesScale = function _validateTolerancesScale(length, speed) {
|
|
2072
|
-
this._assertPositiveFinite(length, "tolerancesScale.length");
|
|
2073
|
-
this._assertPositiveFinite(speed, "tolerancesScale.speed");
|
|
2074
|
-
};
|
|
2075
|
-
_proto._updateScaledDefaults = function _updateScaledDefaults(length, speed) {
|
|
2076
|
-
this._defaultContactOffset = 0.02 * length;
|
|
2077
|
-
this._defaultSleepThreshold = 5e-5 * speed * speed;
|
|
2078
|
-
};
|
|
2079
1948
|
return PhysXPhysics;
|
|
2080
1949
|
}();
|
|
2081
1950
|
|
|
2082
1951
|
//@ts-ignore
|
|
2083
|
-
var version = "0.0.0-experimental-2.0-
|
|
1952
|
+
var version = "0.0.0-experimental-2.0-skill.0";
|
|
2084
1953
|
console.log("Galacean Engine Physics PhysX Version: " + version);
|
|
2085
1954
|
|
|
2086
1955
|
exports.PhysXPhysics = PhysXPhysics;
|