@galacean/engine-physics-physx 2.0.0-alpha.5 → 2.0.0-alpha.50

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.
@@ -1,12 +1,23 @@
1
1
  import { ICharacterController } from "@galacean/engine-design";
2
2
  import { Vector3 } from "@galacean/engine";
3
3
  import { PhysXPhysics } from "./PhysXPhysics";
4
+ import { PhysXPhysicsScene } from "./PhysXPhysicsScene";
4
5
  import { PhysXColliderShape } from "./shape/PhysXColliderShape";
5
6
  /**
6
7
  * Base class for character controllers.
7
8
  */
8
9
  export declare class PhysXCharacterController implements ICharacterController {
9
10
  private static _tempVec;
11
+ /** @internal */
12
+ _scene: PhysXPhysicsScene | null;
13
+ /** @internal */
14
+ _id: number;
15
+ /** @internal */
16
+ _pxController: any;
17
+ /** @internal */
18
+ _pxManager: PhysXPhysicsScene | null;
19
+ /** @internal */
20
+ _shape: PhysXColliderShape | null;
10
21
  private _shapeScaledPosition;
11
22
  private _worldPosition;
12
23
  private _physXPhysics;
@@ -55,5 +66,17 @@ export declare class PhysXCharacterController implements ICharacterController {
55
66
  * {@inheritDoc ICharacterController.destroy }
56
67
  */
57
68
  destroy(): void;
69
+ /**
70
+ * @internal
71
+ */
72
+ _createPXController(pxManager: PhysXPhysicsScene, shape: PhysXColliderShape): void;
73
+ /**
74
+ * @internal
75
+ */
76
+ _destroyPXController(): void;
77
+ /**
78
+ * @internal
79
+ */
80
+ _updateShapePosition(shapePosition: Vector3, worldScale: Vector3): void;
58
81
  private _updateNativePosition;
59
82
  }
@@ -2,11 +2,18 @@ import { ICollider } from "@galacean/engine-design";
2
2
  import { Quaternion, Vector3 } from "@galacean/engine";
3
3
  import { PhysXPhysics } from "./PhysXPhysics";
4
4
  import { PhysXColliderShape } from "./shape/PhysXColliderShape";
5
+ import { PhysXPhysicsScene } from "./PhysXPhysicsScene";
5
6
  /**
6
7
  * Abstract class of physical collider.
7
8
  */
8
9
  export declare abstract class PhysXCollider implements ICollider {
9
10
  private static _tempTransform;
11
+ /** @internal */
12
+ _scene: PhysXPhysicsScene | null;
13
+ /** @internal */
14
+ _pxActor: any;
15
+ /** @internal */
16
+ _shapes: PhysXColliderShape[];
10
17
  protected _physXPhysics: PhysXPhysics;
11
18
  constructor(physXPhysics: PhysXPhysics);
12
19
  /**
@@ -33,4 +40,11 @@ export declare abstract class PhysXCollider implements ICollider {
33
40
  * {@inheritDoc ICollider.destroy }
34
41
  */
35
42
  destroy(): void;
43
+ /**
44
+ * @internal
45
+ */
46
+ _transform(pos: Vector3, rot: Quaternion): {
47
+ translation: Vector3;
48
+ rotation: Quaternion;
49
+ };
36
50
  }
@@ -87,18 +87,14 @@ export declare class PhysXDynamicCollider extends PhysXCollider implements IDyna
87
87
  * {@inheritDoc IDynamicCollider.setSolverIterations }
88
88
  */
89
89
  setSolverIterations(value: number): void;
90
- /**
91
- * {@inheritDoc IDynamicCollider.setCollisionDetectionMode }
92
- */
93
- setCollisionDetectionMode(value: number): void;
94
90
  /**
95
91
  * {@inheritDoc IDynamicCollider.setUseGravity }
96
92
  */
97
93
  setUseGravity(value: boolean): void;
98
94
  /**
99
- * {@inheritDoc IDynamicCollider.setIsKinematic }
95
+ * {@inheritDoc IDynamicCollider.setMotionState }
100
96
  */
101
- setIsKinematic(value: boolean): void;
97
+ setMotionState(isKinematic: boolean, collisionDetectionMode: number): void;
102
98
  /**
103
99
  * {@inheritDoc IDynamicCollider.setConstraints }
104
100
  */
@@ -107,6 +103,10 @@ export declare class PhysXDynamicCollider extends PhysXCollider implements IDyna
107
103
  * {@inheritDoc IDynamicCollider.addForce }
108
104
  */
109
105
  addForce(force: Vector3): void;
106
+ /**
107
+ * {@inheritDoc IDynamicCollider.addForceAtPosition }
108
+ */
109
+ addForceAtPosition(force: Vector3, position: Vector3): void;
110
110
  /**
111
111
  * {@inheritDoc IDynamicCollider.addTorque }
112
112
  */
@@ -1,5 +1,5 @@
1
1
  import { Quaternion, Vector3 } from "@galacean/engine";
2
- import { IBoxColliderShape, ICapsuleColliderShape, ICharacterController, ICollision, IDynamicCollider, IFixedJoint, IHingeJoint, IMeshColliderShape, IPhysics, IPhysicsManager, IPhysicsMaterial, IPhysicsScene, IPlaneColliderShape, ISphereColliderShape, ISpringJoint, IStaticCollider } from "@galacean/engine-design";
2
+ import { IBoxColliderShape, ICapsuleColliderShape, ICharacterController, IDynamicCollider, IFixedJoint, IHingeJoint, IMeshColliderShape, IPhysics, IPhysicsManager, IPhysicsMaterial, IPhysicsScene, IPlaneColliderShape, ISphereColliderShape, ISpringJoint, IStaticCollider } from "@galacean/engine-design";
3
3
  import { PhysXCollider } from "./PhysXCollider";
4
4
  import { PhysXPhysicsManager } from "./PhysXPhysicsManager";
5
5
  import { PhysXPhysicsMaterial } from "./PhysXPhysicsMaterial";
@@ -8,6 +8,16 @@ import { PhysXRuntimeMode } from "./enum/PhysXRuntimeMode";
8
8
  * PhysX object creation.
9
9
  */
10
10
  export declare class PhysXPhysics implements IPhysics {
11
+ /** @internal PhysX wasm object */
12
+ _physX: any;
13
+ /** @internal PhysX Foundation SDK singleton class */
14
+ _pxFoundation: any;
15
+ /** @internal PhysX physics object */
16
+ _pxPhysics: any;
17
+ /** @internal PhysX cooking object for mesh colliders */
18
+ _pxCooking: any;
19
+ /** @internal PhysX cooking params */
20
+ _pxCookingParams: any;
11
21
  private _runTimeMode;
12
22
  private _initializeState;
13
23
  private _initializePromise;
@@ -39,7 +49,7 @@ export declare class PhysXPhysics implements IPhysics {
39
49
  /**
40
50
  * {@inheritDoc IPhysics.createPhysicsScene }
41
51
  */
42
- createPhysicsScene(physicsManager: PhysXPhysicsManager, onContactBegin?: (collision: ICollision) => void, onContactEnd?: (collision: ICollision) => void, onContactStay?: (collision: ICollision) => void, onTriggerBegin?: (obj1: number, obj2: number) => void, onTriggerEnd?: (obj1: number, obj2: number) => void, onTriggerStay?: (obj1: number, obj2: number) => void): IPhysicsScene;
52
+ createPhysicsScene(physicsManager: PhysXPhysicsManager): IPhysicsScene;
43
53
  /**
44
54
  * {@inheritDoc IPhysics.createStaticCollider }
45
55
  */
@@ -1,3 +1,6 @@
1
1
  import { IPhysicsManager } from "@galacean/engine-design";
2
+ import { TriggerEvent } from "./PhysXPhysicsScene";
2
3
  export declare class PhysXPhysicsManager implements IPhysicsManager {
4
+ /** @internal */
5
+ _eventMap: Record<number, Record<number, TriggerEvent | undefined>>;
3
6
  }
@@ -4,6 +4,8 @@ import { PhysXPhysics } from "./PhysXPhysics";
4
4
  * Physics material describes how to handle colliding objects (friction, bounciness).
5
5
  */
6
6
  export declare class PhysXPhysicsMaterial implements IPhysicsMaterial {
7
+ /** @internal */
8
+ _pxMaterial: any;
7
9
  protected _physXPhysics: PhysXPhysics;
8
10
  constructor(physXPhysics: PhysXPhysics, staticFriction: number, dynamicFriction: number, bounciness: number, frictionCombine: CombineMode, bounceCombine: CombineMode);
9
11
  /**
@@ -1,5 +1,5 @@
1
- import { Ray, Vector3, Quaternion } from "@galacean/engine";
2
- import { ICollision, IPhysicsScene } from "@galacean/engine-design";
1
+ import { Vector3, Quaternion } from "@galacean/engine";
2
+ import { IPhysicsScene, IPhysicsEvents, ITriggerEvent } from "@galacean/engine-design";
3
3
  import { PhysXCharacterController } from "./PhysXCharacterController";
4
4
  import { PhysXCollider } from "./PhysXCollider";
5
5
  import { PhysXPhysics } from "./PhysXPhysics";
@@ -8,6 +8,8 @@ import { PhysXPhysicsManager } from "./PhysXPhysicsManager";
8
8
  * A manager is a collection of colliders and constraints which can interact.
9
9
  */
10
10
  export declare class PhysXPhysicsScene implements IPhysicsScene {
11
+ /** @internal */
12
+ _pxControllerManager: any;
11
13
  private static _tempPosition;
12
14
  private static _tempQuaternion;
13
15
  private static _tempNormal;
@@ -19,18 +21,20 @@ export declare class PhysXPhysicsScene implements IPhysicsScene {
19
21
  private _physXPhysics;
20
22
  private _physXManager;
21
23
  private _pxRaycastHit;
24
+ private _pxSweepHit;
22
25
  private _pxFilterData;
26
+ private _pxRaycastSweepFilterData;
23
27
  private _pxScene;
24
28
  private _physXSimulationCallbackInstance;
25
- private readonly _onContactEnter?;
26
- private readonly _onContactExit?;
27
- private readonly _onContactStay?;
28
- private readonly _onTriggerEnter?;
29
- private readonly _onTriggerExit?;
30
- private readonly _onTriggerStay?;
31
- private _currentEvents;
32
- private _eventPool;
33
- constructor(physXPhysics: PhysXPhysics, physicsManager: PhysXPhysicsManager, onContactEnter?: (collision: ICollision) => void, onContactExit?: (collision: ICollision) => void, onContactStay?: (collision: ICollision) => void, onTriggerEnter?: (obj1: number, obj2: number) => void, onTriggerExit?: (obj1: number, obj2: number) => void, onTriggerStay?: (obj1: number, obj2: number) => void);
29
+ private _pxQueryCallback;
30
+ private _currentOnQuery;
31
+ private _activeTriggers;
32
+ private _contactEvents;
33
+ private _contactEventCount;
34
+ private _triggerEvents;
35
+ private _physicsEvents;
36
+ private _triggerEventPool;
37
+ constructor(physXPhysics: PhysXPhysics, physicsManager: PhysXPhysicsManager);
34
38
  /**
35
39
  * {@inheritDoc IPhysicsScene.setGravity }
36
40
  */
@@ -55,10 +59,18 @@ export declare class PhysXPhysicsScene implements IPhysicsScene {
55
59
  * {@inheritDoc IPhysicsScene.update }
56
60
  */
57
61
  update(elapsedTime: number): void;
62
+ /**
63
+ * {@inheritDoc IPhysicsScene.setContactEventEnabled }
64
+ */
65
+ setContactEventEnabled(enabled: boolean): void;
66
+ /**
67
+ * {@inheritDoc IPhysicsScene.updateEvents }
68
+ */
69
+ updateEvents(): IPhysicsEvents;
58
70
  /**
59
71
  * {@inheritDoc IPhysicsScene.raycast }
60
72
  */
61
- raycast(ray: Ray, distance: number, onRaycast: (obj: number) => boolean, hit?: (shapeUniqueID: number, distance: number, position: Vector3, normal: Vector3) => void): boolean;
73
+ raycast(origin: Vector3, direction: Vector3, distance: number, onRaycast: (obj: number) => boolean, hit?: (shapeUniqueID: number, distance: number, position: Vector3, normal: Vector3) => void): boolean;
62
74
  /**
63
75
  * {@inheritDoc IPhysicsScene.boxCast }
64
76
  */
@@ -83,32 +95,40 @@ export declare class PhysXPhysicsScene implements IPhysicsScene {
83
95
  * {@inheritDoc IPhysicsScene.overlapCapsuleAll }
84
96
  */
85
97
  overlapCapsuleAll(center: Vector3, radius: number, height: number, orientation: Quaternion, onOverlap: (obj: number) => boolean): number[];
98
+ /**
99
+ * {@inheritDoc IPhysicsScene.gc }
100
+ */
101
+ gc(): void;
86
102
  /**
87
103
  * {@inheritDoc IPhysicsScene.destroy }
88
104
  */
89
105
  destroy(): void;
106
+ /**
107
+ * @internal
108
+ */
109
+ _getControllerManager(): any;
110
+ /**
111
+ * @internal
112
+ */
113
+ _addColliderShape(id: number): void;
114
+ /**
115
+ * @internal
116
+ */
117
+ _removeColliderShape(id: number): void;
90
118
  private _sweepSingle;
91
119
  private _overlapMultiple;
92
120
  private _simulate;
93
121
  private _fetchResults;
94
122
  private _getTrigger;
95
- private _fireEvent;
96
- }
97
- /**
98
- * Physics state
99
- */
100
- declare enum TriggerEventState {
101
- Enter = 0,
102
- Stay = 1,
103
- Exit = 2
123
+ private _bufferContactEvent;
104
124
  }
105
125
  /**
106
126
  * Trigger event to store interactive object ids and state.
107
127
  */
108
- export declare class TriggerEvent {
109
- state: TriggerEventState;
128
+ export declare class TriggerEvent implements ITriggerEvent {
129
+ state: number;
130
+ dispatchState: number;
110
131
  index1: number;
111
132
  index2: number;
112
133
  constructor(index1: number, index2: number);
113
134
  }
114
- export {};
@@ -8,6 +8,8 @@ import { PhysXColliderShape } from "./PhysXColliderShape";
8
8
  */
9
9
  export declare class PhysXBoxColliderShape extends PhysXColliderShape implements IBoxColliderShape {
10
10
  private static _tempHalfExtents;
11
+ /** @internal */
12
+ _halfSize: Vector3;
11
13
  constructor(physXPhysics: PhysXPhysics, uniqueID: number, size: Vector3, material: PhysXPhysicsMaterial);
12
14
  /**
13
15
  * {@inheritDoc IBoxColliderShape.setSize }
@@ -7,6 +7,12 @@ import { PhysXColliderShape } from "./PhysXColliderShape";
7
7
  * Capsule collider shape in PhysX.
8
8
  */
9
9
  export declare class PhysXCapsuleColliderShape extends PhysXColliderShape implements ICapsuleColliderShape {
10
+ /** @internal */
11
+ _radius: number;
12
+ /** @internal */
13
+ _halfHeight: number;
14
+ /** @internal */
15
+ _upAxis: ColliderShapeUpAxis;
10
16
  constructor(physXPhysics: PhysXPhysics, uniqueID: number, radius: number, height: number, material: PhysXPhysicsMaterial);
11
17
  /**
12
18
  * {@inheritDoc ICapsuleColliderShape.setRadius }
@@ -1,5 +1,6 @@
1
- import { Quaternion, Vector3, Vector4 } from "@galacean/engine";
1
+ import { Quaternion, Vector3, DisorderedArray, Vector4 } from "@galacean/engine";
2
2
  import { IColliderShape } from "@galacean/engine-design";
3
+ import { PhysXCharacterController } from "../PhysXCharacterController";
3
4
  import { PhysXPhysics } from "../PhysXPhysics";
4
5
  import { PhysXPhysicsMaterial } from "../PhysXPhysicsMaterial";
5
6
  /**
@@ -20,12 +21,29 @@ export declare abstract class PhysXColliderShape implements IColliderShape {
20
21
  static readonly halfSqrt: number;
21
22
  static transform: {
22
23
  translation: Vector3;
23
- rotation: any;
24
+ rotation: Quaternion | null;
24
25
  };
25
26
  protected static _tempVector4: Vector4;
27
+ /** @internal */
28
+ _controllers: DisorderedArray<PhysXCharacterController>;
29
+ /** @internal */
30
+ _contractOffset: number;
31
+ /** @internal */
32
+ _worldScale: Vector3;
33
+ /** @internal */
34
+ _position: Vector3;
35
+ /** @internal */
36
+ _pxMaterial: any;
37
+ /** @internal */
38
+ _pxShape: any;
39
+ /** @internal */
40
+ /** @internal */
41
+ _id: number;
42
+ /** @internal */
43
+ _rotation: Vector3;
26
44
  protected _physXPhysics: PhysXPhysics;
27
45
  protected _pxGeometry: any;
28
- protected _axis: Quaternion;
46
+ protected _axis: Quaternion | null;
29
47
  protected _physXRotation: Quaternion;
30
48
  private _shapeFlags;
31
49
  constructor(physXPhysics: PhysXPhysics);
@@ -62,6 +80,10 @@ export declare abstract class PhysXColliderShape implements IColliderShape {
62
80
  * {@inheritDoc IColliderShape.destroy }
63
81
  */
64
82
  destroy(): void;
83
+ /**
84
+ * @internal
85
+ */
86
+ _setShapeFlags(flags: ShapeFlag): void;
65
87
  protected _setLocalPose(): void;
66
88
  protected _initialize(material: PhysXPhysicsMaterial, id: number): void;
67
89
  private _modifyFlag;