@cyclonium/physics-2d 0.0.104 → 1.0.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/lib/body-collider-link.js +1 -1
- package/lib/character-controller-2d.js +17 -18
- package/lib/collider-2d.d.ts +4 -29
- package/lib/collider-2d.js +15 -15
- package/lib/colliders/box-collider-2d.js +3 -3
- package/lib/colliders/capsule-collider-2d.js +3 -3
- package/lib/colliders/circle-collider-2d.js +2 -2
- package/lib/colliders/polygon-collider-2d.js +1 -2
- package/lib/collision-matrix.d.ts +2 -2
- package/lib/collision-matrix.js +12 -10
- package/lib/gizmo-headless.js +18 -6
- package/lib/physics-2d-debugger-headless.d.ts +0 -1
- package/lib/physics-2d-debugger-headless.js +2 -2
- package/lib/physics-2d-debugger.js +10 -10
- package/lib/physics-2d-settings.d.ts +3 -2
- package/lib/physics-2d-settings.js +22 -15
- package/lib/physics-component-2d-base.js +8 -4
- package/lib/physics-world-2d-scene-component.d.ts +5 -2
- package/lib/physics-world-2d-scene-component.js +43 -14
- package/lib/physics-world-2d.d.ts +2 -1
- package/lib/physics-world-2d.js +39 -18
- package/lib/px2-impl.js +3 -5
- package/lib/rigid-body-2d.d.ts +8 -1
- package/lib/rigid-body-2d.js +52 -10
- package/lib/scene-query-probe-2d.d.ts +4 -4
- package/lib/scene-query-probe-2d.js +18 -17
- package/lib/scene-query-probes/box-scene-query-probe-2d.d.ts +1 -1
- package/lib/scene-query-probes/box-scene-query-probe-2d.js +4 -4
- package/lib/scene-query-probes/capsule-scene-query-probe-2d.d.ts +2 -2
- package/lib/scene-query-probes/capsule-scene-query-probe-2d.js +5 -5
- package/lib/scene-query-probes/circle-scene-query-probe-2d.d.ts +1 -1
- package/lib/scene-query-probes/circle-scene-query-probe-2d.js +3 -3
- package/lib/scene-query.d.ts +1 -2
- package/lib/scene-query.js +4 -6
- package/lib/wasm-binary-helper.d.ts +1 -1
- package/lib/wasm-binary-helper.js +1 -2
- package/package.json +3 -3
|
@@ -22,7 +22,7 @@ export class BodyColliderLink {
|
|
|
22
22
|
this._colliders.length = 0;
|
|
23
23
|
}
|
|
24
24
|
linkCollider(collider) {
|
|
25
|
-
if (this._colliders.
|
|
25
|
+
if (this._colliders.includes(collider)) {
|
|
26
26
|
throw new Error(`Collider ${collider.name} already joined to body ${this._rigidBody?.name}.`);
|
|
27
27
|
}
|
|
28
28
|
this._colliders.push(collider);
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { editable, idem, idemBy,
|
|
7
|
+
import { editable, idem, idemBy, stored } from '@cyclonium/core/legacy-decorator';
|
|
8
8
|
import { Vec2 } from '@cyclonium/core/math/vec2';
|
|
9
9
|
import { fromPx2ImplVec2, toPx2ImplVec2 } from './exchange.js';
|
|
10
10
|
import { px2Impl } from './px2-impl.js';
|
|
@@ -134,7 +134,7 @@ let KinematicCharacterController2D = class KinematicCharacterController2D extend
|
|
|
134
134
|
return;
|
|
135
135
|
}
|
|
136
136
|
const collider = Collider2D.ofOrNull(this);
|
|
137
|
-
if (!collider
|
|
137
|
+
if (!collider?.impl_internal) {
|
|
138
138
|
return;
|
|
139
139
|
}
|
|
140
140
|
const world = this.world;
|
|
@@ -145,7 +145,7 @@ let KinematicCharacterController2D = class KinematicCharacterController2D extend
|
|
|
145
145
|
const movement = fromPx2ImplVec2(impl.computedMovement());
|
|
146
146
|
Vec2.assign(this._lastMovement, movement);
|
|
147
147
|
const rigidBody = collider.attachedRigidBody;
|
|
148
|
-
if (!rigidBody
|
|
148
|
+
if (!rigidBody?.impl) {
|
|
149
149
|
const newPosition = fromPx2ImplVec2(collider.impl_internal.translation()).add(movement);
|
|
150
150
|
Transform2DComponent.of(collider).position = newPosition;
|
|
151
151
|
collider.impl_internal.setTranslation(toPx2ImplVec2(newPosition));
|
|
@@ -156,8 +156,7 @@ let KinematicCharacterController2D = class KinematicCharacterController2D extend
|
|
|
156
156
|
else {
|
|
157
157
|
const currentPosition = fromPx2ImplVec2(rigidBody.impl.nextTranslation());
|
|
158
158
|
const newPosition = fromPx2ImplVec2(currentPosition).add(movement);
|
|
159
|
-
|
|
160
|
-
rigidBody.impl.setNextKinematicTranslation(toPx2ImplVec2(newPosition));
|
|
159
|
+
rigidBody.setNextKinematicPosition(newPosition);
|
|
161
160
|
}
|
|
162
161
|
this._emitCharacterCollisionEvents(impl, world);
|
|
163
162
|
}
|
|
@@ -295,7 +294,7 @@ __decorate([
|
|
|
295
294
|
], KinematicCharacterController2D.prototype, "skinWidth", null);
|
|
296
295
|
__decorate([
|
|
297
296
|
editable,
|
|
298
|
-
idemBy(Vec2.strictEquals)
|
|
297
|
+
idemBy((left, right) => Vec2.strictEquals(left, right))
|
|
299
298
|
], KinematicCharacterController2D.prototype, "up", null);
|
|
300
299
|
__decorate([
|
|
301
300
|
editable,
|
|
@@ -338,40 +337,40 @@ __decorate([
|
|
|
338
337
|
idem
|
|
339
338
|
], KinematicCharacterController2D.prototype, "applyImpulsesToDynamicBodies", null);
|
|
340
339
|
__decorate([
|
|
341
|
-
|
|
340
|
+
stored
|
|
342
341
|
], KinematicCharacterController2D.prototype, "_skinWidth", void 0);
|
|
343
342
|
__decorate([
|
|
344
|
-
|
|
343
|
+
stored
|
|
345
344
|
], KinematicCharacterController2D.prototype, "_up", void 0);
|
|
346
345
|
__decorate([
|
|
347
|
-
|
|
346
|
+
stored
|
|
348
347
|
], KinematicCharacterController2D.prototype, "_slideEnabled", void 0);
|
|
349
348
|
__decorate([
|
|
350
|
-
|
|
349
|
+
stored
|
|
351
350
|
], KinematicCharacterController2D.prototype, "_minSlopeSlideAngle", void 0);
|
|
352
351
|
__decorate([
|
|
353
|
-
|
|
352
|
+
stored
|
|
354
353
|
], KinematicCharacterController2D.prototype, "_maxSlopeClimbAngle", void 0);
|
|
355
354
|
__decorate([
|
|
356
|
-
|
|
355
|
+
stored
|
|
357
356
|
], KinematicCharacterController2D.prototype, "_autoStepEnabled", void 0);
|
|
358
357
|
__decorate([
|
|
359
|
-
|
|
358
|
+
stored
|
|
360
359
|
], KinematicCharacterController2D.prototype, "_autoStepMaxHeight", void 0);
|
|
361
360
|
__decorate([
|
|
362
|
-
|
|
361
|
+
stored
|
|
363
362
|
], KinematicCharacterController2D.prototype, "_autoStepMinWidth", void 0);
|
|
364
363
|
__decorate([
|
|
365
|
-
|
|
364
|
+
stored
|
|
366
365
|
], KinematicCharacterController2D.prototype, "_autoStepIncludeDynamicBodies", void 0);
|
|
367
366
|
__decorate([
|
|
368
|
-
|
|
367
|
+
stored
|
|
369
368
|
], KinematicCharacterController2D.prototype, "_snapToGroundEnabled", void 0);
|
|
370
369
|
__decorate([
|
|
371
|
-
|
|
370
|
+
stored
|
|
372
371
|
], KinematicCharacterController2D.prototype, "_snapToGroundDistance", void 0);
|
|
373
372
|
__decorate([
|
|
374
|
-
|
|
373
|
+
stored
|
|
375
374
|
], KinematicCharacterController2D.prototype, "_applyImpulsesToDynamicBodies", void 0);
|
|
376
375
|
KinematicCharacterController2D = __decorate([
|
|
377
376
|
cycloBuiltinClass('KinematicCharacterController2D')
|
package/lib/collider-2d.d.ts
CHANGED
|
@@ -6,44 +6,20 @@ import { ColliderShapeCastHit, ColliderShapeIntersection, RayColliderIntersectio
|
|
|
6
6
|
import type { Ray2D } from '@cyclonium/core/math/ray';
|
|
7
7
|
import { Bounds2D } from '@cyclonium/core/math/bounds-2d';
|
|
8
8
|
export declare abstract class Collider2D extends PhysicsComponent2DBase {
|
|
9
|
+
onContactBegin: import("@cyclonium/event").ManagedEventEmitter<[Collider2D, Collider2D, Contact2DInfo]>;
|
|
10
|
+
onContactStay: import("@cyclonium/event").ManagedEventEmitter<[Collider2D, Collider2D, Contact2DInfo]>;
|
|
11
|
+
onContactEnd: import("@cyclonium/event").ManagedEventEmitter<[Collider2D, Collider2D, Contact2DInfo]>;
|
|
9
12
|
get attachedRigidBody(): import("./rigid-body-2d.js").RigidBody2D | null;
|
|
10
13
|
get isSensor(): boolean;
|
|
11
14
|
set isSensor(value: boolean);
|
|
12
15
|
get center(): Vec2;
|
|
13
16
|
set center(value: Vec2);
|
|
14
17
|
get bounds(): Bounds2D;
|
|
15
|
-
/**
|
|
16
|
-
* Test only.
|
|
17
|
-
* @internal
|
|
18
|
-
*/
|
|
19
|
-
get impl_internal(): px2Impl.Collider | undefined;
|
|
20
|
-
onContactBegin: import("@cyclonium/event").ManagedEventEmitter<[Collider2D, Collider2D, Contact2DInfo]>;
|
|
21
|
-
onContactStay: import("@cyclonium/event").ManagedEventEmitter<[Collider2D, Collider2D, Contact2DInfo]>;
|
|
22
|
-
onContactEnd: import("@cyclonium/event").ManagedEventEmitter<[Collider2D, Collider2D, Contact2DInfo]>;
|
|
23
18
|
intersect(opts: ShapeIntersectionQueryOptions): ColliderShapeIntersection | undefined;
|
|
24
19
|
cast(opts: ShapeCastQueryOptions): ColliderShapeCastHit | undefined;
|
|
25
20
|
castRay(ray: Ray2D, maxDistance: number, solid?: boolean): RayColliderIntersection | undefined;
|
|
26
|
-
/**
|
|
27
|
-
* @internal
|
|
28
|
-
*/
|
|
29
|
-
_enableCollisionEventsSinceBody(value: boolean): void;
|
|
30
|
-
/**
|
|
31
|
-
* @internal
|
|
32
|
-
*/
|
|
33
|
-
_responseToBodyActiveCollisionTypes(value: number): void;
|
|
34
|
-
/**
|
|
35
|
-
* @internal
|
|
36
|
-
*/
|
|
37
|
-
_responseToBodyCollisionGroups(value: number): void;
|
|
38
|
-
/**
|
|
39
|
-
* @internal
|
|
40
|
-
*/
|
|
41
|
-
_responseToBodySolverGroups(value: number): void;
|
|
42
|
-
/**
|
|
43
|
-
* @internal
|
|
44
|
-
*/
|
|
45
|
-
_responseToAttachedRigidBodyChanged(): void;
|
|
46
21
|
protected get _implCollider(): px2Impl.Collider | undefined;
|
|
22
|
+
protected get sceneGraphScale(): Vec2;
|
|
47
23
|
protected recreateCollider(): void;
|
|
48
24
|
protected onAttachToWorld(): void;
|
|
49
25
|
protected onDetachFromWorld(): void;
|
|
@@ -52,7 +28,6 @@ export declare abstract class Collider2D extends PhysicsComponent2DBase {
|
|
|
52
28
|
protected onSyncTransforms(forceTransform: boolean, forceScale: boolean): void;
|
|
53
29
|
protected abstract getShape(): px2Impl.Shape | undefined;
|
|
54
30
|
protected abstract computeShapeBounds(out: Bounds2D): void;
|
|
55
|
-
protected get sceneGraphScale(): Vec2;
|
|
56
31
|
protected updateSceneGraphScale(): void;
|
|
57
32
|
private _isSensor;
|
|
58
33
|
private _center;
|
package/lib/collider-2d.js
CHANGED
|
@@ -5,7 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { Transform2DComponent, TransformChangeFlagsObserver, TransformFlag } from '@cyclonium/core/2d';
|
|
8
|
-
import { editable, requiresComponent,
|
|
8
|
+
import { editable, requiresComponent, stored } from '@cyclonium/core/legacy-decorator';
|
|
9
9
|
import { cycloBuiltinClass } from '@cyclonium/core/internal';
|
|
10
10
|
import { Vec2 } from '@cyclonium/core/math/vec2';
|
|
11
11
|
import {} from './contact.js';
|
|
@@ -19,6 +19,15 @@ import { getZRotation } from './utils/3-to-2.js';
|
|
|
19
19
|
import { ColliderShapeCastHit, ColliderShapeIntersection, RayColliderIntersection } from './scene-query.js';
|
|
20
20
|
import { Bounds2D } from '@cyclonium/core/math/bounds-2d';
|
|
21
21
|
let Collider2D = class Collider2D extends PhysicsComponent2DBase {
|
|
22
|
+
onContactBegin = createCollisionEventEmitter((hasAnyListener) => {
|
|
23
|
+
this._updateListenerFlag(ContactEventListenerFlagIndex.begin, hasAnyListener);
|
|
24
|
+
});
|
|
25
|
+
onContactStay = createCollisionEventEmitter((hasAnyListener) => {
|
|
26
|
+
this._updateListenerFlag(ContactEventListenerFlagIndex.stay, hasAnyListener);
|
|
27
|
+
});
|
|
28
|
+
onContactEnd = createCollisionEventEmitter((hasAnyListener) => {
|
|
29
|
+
this._updateListenerFlag(ContactEventListenerFlagIndex.end, hasAnyListener);
|
|
30
|
+
});
|
|
22
31
|
get attachedRigidBody() {
|
|
23
32
|
return this._handle?.attachedRigidBody ?? null;
|
|
24
33
|
}
|
|
@@ -48,15 +57,6 @@ let Collider2D = class Collider2D extends PhysicsComponent2DBase {
|
|
|
48
57
|
get impl_internal() {
|
|
49
58
|
return this._implCollider;
|
|
50
59
|
}
|
|
51
|
-
onContactBegin = createCollisionEventEmitter((hasAnyListener) => {
|
|
52
|
-
this._updateListenerFlag(ContactEventListenerFlagIndex.begin, hasAnyListener);
|
|
53
|
-
});
|
|
54
|
-
onContactStay = createCollisionEventEmitter((hasAnyListener) => {
|
|
55
|
-
this._updateListenerFlag(ContactEventListenerFlagIndex.stay, hasAnyListener);
|
|
56
|
-
});
|
|
57
|
-
onContactEnd = createCollisionEventEmitter((hasAnyListener) => {
|
|
58
|
-
this._updateListenerFlag(ContactEventListenerFlagIndex.end, hasAnyListener);
|
|
59
|
-
});
|
|
60
60
|
intersect(opts) {
|
|
61
61
|
const world = this.world;
|
|
62
62
|
if (!world) {
|
|
@@ -167,6 +167,9 @@ let Collider2D = class Collider2D extends PhysicsComponent2DBase {
|
|
|
167
167
|
get _implCollider() {
|
|
168
168
|
return this._handle?.impl ?? undefined;
|
|
169
169
|
}
|
|
170
|
+
get sceneGraphScale() {
|
|
171
|
+
return this._transform.scale;
|
|
172
|
+
}
|
|
170
173
|
recreateCollider() {
|
|
171
174
|
this._destroyCollider();
|
|
172
175
|
const handle = this._handle;
|
|
@@ -219,9 +222,6 @@ let Collider2D = class Collider2D extends PhysicsComponent2DBase {
|
|
|
219
222
|
this._updateTransform();
|
|
220
223
|
}
|
|
221
224
|
}
|
|
222
|
-
get sceneGraphScale() {
|
|
223
|
-
return this._transform.scale;
|
|
224
|
-
}
|
|
225
225
|
updateSceneGraphScale() {
|
|
226
226
|
const implCollider = this._implCollider;
|
|
227
227
|
if (!implCollider) {
|
|
@@ -340,10 +340,10 @@ __decorate([
|
|
|
340
340
|
editable
|
|
341
341
|
], Collider2D.prototype, "center", null);
|
|
342
342
|
__decorate([
|
|
343
|
-
|
|
343
|
+
stored
|
|
344
344
|
], Collider2D.prototype, "_isSensor", void 0);
|
|
345
345
|
__decorate([
|
|
346
|
-
|
|
346
|
+
stored
|
|
347
347
|
], Collider2D.prototype, "_center", void 0);
|
|
348
348
|
__decorate([
|
|
349
349
|
requiresComponent(Transform2DComponent)
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { editable, executeInEditMode, idem,
|
|
7
|
+
import { editable, executeInEditMode, idem, stored } from '@cyclonium/core/legacy-decorator';
|
|
8
8
|
import { Collider2D } from '../collider-2d.js';
|
|
9
9
|
import { px2Impl } from '../px2-impl.js';
|
|
10
10
|
import { EDITOR_NOT_IN_PREVIEW } from 'cc/env';
|
|
@@ -71,10 +71,10 @@ __decorate([
|
|
|
71
71
|
idem
|
|
72
72
|
], BoxCollider2D.prototype, "height", null);
|
|
73
73
|
__decorate([
|
|
74
|
-
|
|
74
|
+
stored
|
|
75
75
|
], BoxCollider2D.prototype, "_halfWidth", void 0);
|
|
76
76
|
__decorate([
|
|
77
|
-
|
|
77
|
+
stored
|
|
78
78
|
], BoxCollider2D.prototype, "_halfHeight", void 0);
|
|
79
79
|
BoxCollider2D = __decorate([
|
|
80
80
|
cycloBuiltinClass('BoxCollider2D'),
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { editable, executeInEditMode, idem,
|
|
7
|
+
import { editable, executeInEditMode, idem, stored } from '@cyclonium/core/legacy-decorator';
|
|
8
8
|
import { Collider2D } from '../collider-2d.js';
|
|
9
9
|
import { px2Impl } from '../px2-impl.js';
|
|
10
10
|
import { EDITOR_NOT_IN_PREVIEW } from 'cc/env';
|
|
@@ -65,10 +65,10 @@ __decorate([
|
|
|
65
65
|
idem
|
|
66
66
|
], CapsuleCollider2D.prototype, "halfHeight", null);
|
|
67
67
|
__decorate([
|
|
68
|
-
|
|
68
|
+
stored
|
|
69
69
|
], CapsuleCollider2D.prototype, "_radius", void 0);
|
|
70
70
|
__decorate([
|
|
71
|
-
|
|
71
|
+
stored
|
|
72
72
|
], CapsuleCollider2D.prototype, "_halfHeight", void 0);
|
|
73
73
|
CapsuleCollider2D = __decorate([
|
|
74
74
|
cycloBuiltinClass('CapsuleCollider2D'),
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { editable, executeInEditMode, idem,
|
|
7
|
+
import { editable, executeInEditMode, idem, stored } from '@cyclonium/core/legacy-decorator';
|
|
8
8
|
import { Collider2D } from '../collider-2d.js';
|
|
9
9
|
import { px2Impl } from '../px2-impl.js';
|
|
10
10
|
import { EDITOR_NOT_IN_PREVIEW } from 'cc/env';
|
|
@@ -49,7 +49,7 @@ __decorate([
|
|
|
49
49
|
idem
|
|
50
50
|
], CircleCollider2D.prototype, "radius", null);
|
|
51
51
|
__decorate([
|
|
52
|
-
|
|
52
|
+
stored
|
|
53
53
|
], CircleCollider2D.prototype, "_radius", void 0);
|
|
54
54
|
CircleCollider2D = __decorate([
|
|
55
55
|
cycloBuiltinClass('CircleCollider2D'),
|
|
@@ -28,8 +28,7 @@ let PolygonCollider2D = class PolygonCollider2D extends Collider2D {
|
|
|
28
28
|
const scale = this.sceneGraphScale;
|
|
29
29
|
out.setMinMax(Vec2.POSITIVE_INFINITY, Vec2.NEGATIVE_INFINITY);
|
|
30
30
|
const p = new Vec2();
|
|
31
|
-
for (
|
|
32
|
-
const point = this._points[i];
|
|
31
|
+
for (const point of this._points) {
|
|
33
32
|
out.extend(p.copyFrom(point).mulSelf(scale));
|
|
34
33
|
}
|
|
35
34
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export declare class CollisionMatrix {
|
|
2
2
|
static readonly EXTENT = 16;
|
|
3
|
-
private get values();
|
|
4
|
-
private set values(value);
|
|
5
3
|
clone(): CollisionMatrix;
|
|
6
4
|
get(i: number, j: number): boolean;
|
|
7
5
|
set(i: number, j: number, value: boolean): void;
|
|
8
6
|
getCollisionsBitsOf(i: number): number;
|
|
9
7
|
private _values;
|
|
8
|
+
private get values();
|
|
9
|
+
private set values(value);
|
|
10
10
|
private _locate;
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=collision-matrix.d.ts.map
|
package/lib/collision-matrix.js
CHANGED
|
@@ -5,19 +5,13 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
var CollisionMatrix_1;
|
|
8
|
-
import { editable,
|
|
8
|
+
import { editable, stored } from '@cyclonium/core/legacy-decorator';
|
|
9
9
|
import { cycloBuiltinClass } from '@cyclonium/core/internal';
|
|
10
10
|
import { dumpRaw } from '@cyclonium/core/utils';
|
|
11
11
|
const EXTENT = 16;
|
|
12
12
|
let CollisionMatrix = class CollisionMatrix {
|
|
13
13
|
static { CollisionMatrix_1 = this; }
|
|
14
14
|
static EXTENT = EXTENT;
|
|
15
|
-
get values() {
|
|
16
|
-
return this._values;
|
|
17
|
-
}
|
|
18
|
-
set values(values) {
|
|
19
|
-
this._values = [...values];
|
|
20
|
-
}
|
|
21
15
|
clone() {
|
|
22
16
|
const clone = new CollisionMatrix_1();
|
|
23
17
|
clone._values = this._values.slice();
|
|
@@ -45,6 +39,13 @@ let CollisionMatrix = class CollisionMatrix {
|
|
|
45
39
|
return bits;
|
|
46
40
|
}
|
|
47
41
|
_values = new Array(EXTENT * (EXTENT + 1) / 2).fill(false);
|
|
42
|
+
get values() {
|
|
43
|
+
return this._values;
|
|
44
|
+
}
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- The private accessor name is part of the serialized editor dump schema.
|
|
46
|
+
set values(values) {
|
|
47
|
+
this._values = [...values];
|
|
48
|
+
}
|
|
48
49
|
_locate(i, j) {
|
|
49
50
|
if (i < 0 || i >= EXTENT || j < 0 || j >= EXTENT) {
|
|
50
51
|
throw new Error(`Index out of range.`);
|
|
@@ -56,13 +57,14 @@ let CollisionMatrix = class CollisionMatrix {
|
|
|
56
57
|
return rowStart + j;
|
|
57
58
|
}
|
|
58
59
|
};
|
|
60
|
+
__decorate([
|
|
61
|
+
stored
|
|
62
|
+
], CollisionMatrix.prototype, "_values", void 0);
|
|
59
63
|
__decorate([
|
|
60
64
|
editable,
|
|
61
65
|
dumpRaw
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- The private accessor name is part of the serialized editor dump schema.
|
|
62
67
|
], CollisionMatrix.prototype, "values", null);
|
|
63
|
-
__decorate([
|
|
64
|
-
serializable
|
|
65
|
-
], CollisionMatrix.prototype, "_values", void 0);
|
|
66
68
|
CollisionMatrix = CollisionMatrix_1 = __decorate([
|
|
67
69
|
cycloBuiltinClass('CollisionMatrix')
|
|
68
70
|
], CollisionMatrix);
|
package/lib/gizmo-headless.js
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
export function drawBoxCollider2DGizmo() {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export function
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export function drawBoxCollider2DGizmo() {
|
|
2
|
+
// Gizmos are intentionally disabled in headless builds.
|
|
3
|
+
}
|
|
4
|
+
export function drawCircleCollider2DGizmo() {
|
|
5
|
+
// Gizmos are intentionally disabled in headless builds.
|
|
6
|
+
}
|
|
7
|
+
export function drawCapsuleCollider2DGizmo() {
|
|
8
|
+
// Gizmos are intentionally disabled in headless builds.
|
|
9
|
+
}
|
|
10
|
+
export function drawBoxSceneQueryProbe2DGizmo() {
|
|
11
|
+
// Gizmos are intentionally disabled in headless builds.
|
|
12
|
+
}
|
|
13
|
+
export function drawCircleSceneQueryProbe2DGizmo() {
|
|
14
|
+
// Gizmos are intentionally disabled in headless builds.
|
|
15
|
+
}
|
|
16
|
+
export function drawCapsuleSceneQueryProbe2DGizmo() {
|
|
17
|
+
// Gizmos are intentionally disabled in headless builds.
|
|
18
|
+
}
|
|
7
19
|
//# sourceMappingURL=gizmo-headless.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export class Physics2DDebugger {
|
|
2
|
-
constructor() {
|
|
3
|
-
}
|
|
4
2
|
destroy() {
|
|
3
|
+
// No render resources exist in headless builds.
|
|
5
4
|
}
|
|
6
5
|
render() {
|
|
6
|
+
// Debug rendering is intentionally disabled in headless builds.
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=physics-2d-debugger-headless.js.map
|
|
@@ -16,16 +16,6 @@ class Physics2DDebugRenderer extends Renderer {
|
|
|
16
16
|
this._material = material;
|
|
17
17
|
this._loadMaterial();
|
|
18
18
|
}
|
|
19
|
-
onEnable() {
|
|
20
|
-
if (this._renderRecord) {
|
|
21
|
-
this._renderRecord.model.enabled = true;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
onDisable() {
|
|
25
|
-
if (this._renderRecord) {
|
|
26
|
-
this._renderRecord.model.enabled = false;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
19
|
render(world) {
|
|
30
20
|
const { vertices, colors } = world.debugRender();
|
|
31
21
|
const vertexCount = vertices.length / 2;
|
|
@@ -42,6 +32,16 @@ class Physics2DDebugRenderer extends Renderer {
|
|
|
42
32
|
renderRecord.colorVertexBuffer.update(colors, colors.byteLength);
|
|
43
33
|
}
|
|
44
34
|
}
|
|
35
|
+
onEnable() {
|
|
36
|
+
if (this._renderRecord) {
|
|
37
|
+
this._renderRecord.model.enabled = true;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
onDisable() {
|
|
41
|
+
if (this._renderRecord) {
|
|
42
|
+
this._renderRecord.model.enabled = false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
45
|
_material;
|
|
46
46
|
_materialLoaded = false;
|
|
47
47
|
_renderRecord;
|
|
@@ -2,12 +2,13 @@ import { Asset } from 'cc';
|
|
|
2
2
|
import { CollisionMatrix } from './collision-matrix.js';
|
|
3
3
|
export declare class Physics2DSettings extends Asset {
|
|
4
4
|
fps: number;
|
|
5
|
+
maxSubsteps: number;
|
|
5
6
|
get tags(): Record<string, number>;
|
|
6
|
-
private get tags_editor();
|
|
7
|
-
private set tags_editor(value);
|
|
8
7
|
get collisionMatrix(): CollisionMatrix;
|
|
9
8
|
findTagIndex(tag: string): number;
|
|
10
9
|
private _tags;
|
|
11
10
|
private _collisionMatrix;
|
|
11
|
+
private get tags_editor();
|
|
12
|
+
private set tags_editor(value);
|
|
12
13
|
}
|
|
13
14
|
//# sourceMappingURL=physics-2d-settings.d.ts.map
|
|
@@ -4,22 +4,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { Asset } from 'cc';
|
|
8
|
-
import { editable,
|
|
7
|
+
import { Asset, CCInteger } from 'cc';
|
|
8
|
+
import { editable, stored } from '@cyclonium/core/legacy-decorator';
|
|
9
9
|
import { cycloBuiltinClass } from '@cyclonium/core/internal';
|
|
10
10
|
import { CollisionMatrix } from './collision-matrix.js';
|
|
11
11
|
import { dumpRaw } from '@cyclonium/core/utils';
|
|
12
12
|
let Physics2DSettings = class Physics2DSettings extends Asset {
|
|
13
13
|
fps = 60;
|
|
14
|
+
maxSubsteps = 4;
|
|
14
15
|
get tags() {
|
|
15
16
|
return this._tags;
|
|
16
17
|
}
|
|
17
|
-
get tags_editor() {
|
|
18
|
-
return this._tags;
|
|
19
|
-
}
|
|
20
|
-
set tags_editor(value) {
|
|
21
|
-
this._tags = { ...value };
|
|
22
|
-
}
|
|
23
18
|
get collisionMatrix() {
|
|
24
19
|
return this._collisionMatrix;
|
|
25
20
|
}
|
|
@@ -28,24 +23,36 @@ let Physics2DSettings = class Physics2DSettings extends Asset {
|
|
|
28
23
|
}
|
|
29
24
|
_tags = {};
|
|
30
25
|
_collisionMatrix = new CollisionMatrix();
|
|
26
|
+
get tags_editor() {
|
|
27
|
+
return this._tags;
|
|
28
|
+
}
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Cocos editor inspectors consume this serialized compatibility property by name.
|
|
30
|
+
set tags_editor(value) {
|
|
31
|
+
this._tags = { ...value };
|
|
32
|
+
}
|
|
31
33
|
};
|
|
32
34
|
__decorate([
|
|
33
|
-
|
|
34
|
-
editable
|
|
35
|
+
stored,
|
|
36
|
+
editable({ min: 1 })
|
|
35
37
|
], Physics2DSettings.prototype, "fps", void 0);
|
|
36
38
|
__decorate([
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
], Physics2DSettings.prototype, "
|
|
39
|
+
stored,
|
|
40
|
+
editable({ type: CCInteger, min: 1, step: 1 })
|
|
41
|
+
], Physics2DSettings.prototype, "maxSubsteps", void 0);
|
|
40
42
|
__decorate([
|
|
41
43
|
editable
|
|
42
44
|
], Physics2DSettings.prototype, "collisionMatrix", null);
|
|
43
45
|
__decorate([
|
|
44
|
-
|
|
46
|
+
stored
|
|
45
47
|
], Physics2DSettings.prototype, "_tags", void 0);
|
|
46
48
|
__decorate([
|
|
47
|
-
|
|
49
|
+
stored
|
|
48
50
|
], Physics2DSettings.prototype, "_collisionMatrix", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
editable,
|
|
53
|
+
dumpRaw
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Cocos editor inspectors consume this serialized compatibility property by name.
|
|
55
|
+
], Physics2DSettings.prototype, "tags_editor", null);
|
|
49
56
|
Physics2DSettings = __decorate([
|
|
50
57
|
cycloBuiltinClass('Physics2DSettings')
|
|
51
58
|
], Physics2DSettings);
|
|
@@ -20,8 +20,12 @@ let PhysicsComponent2DBase = class PhysicsComponent2DBase extends CycloComponent
|
|
|
20
20
|
get world() {
|
|
21
21
|
return this._physicsWorld;
|
|
22
22
|
}
|
|
23
|
-
onSyncTransforms(_forceTransform, _forceScale) {
|
|
24
|
-
|
|
23
|
+
onSyncTransforms(_forceTransform, _forceScale) {
|
|
24
|
+
// Optional synchronization hook for physics components.
|
|
25
|
+
}
|
|
26
|
+
onAfterPhysicsStep() {
|
|
27
|
+
// Optional post-step hook for physics components.
|
|
28
|
+
}
|
|
25
29
|
onAwake() {
|
|
26
30
|
if (!this._attached) {
|
|
27
31
|
this._tryAttach();
|
|
@@ -47,14 +51,14 @@ let PhysicsComponent2DBase = class PhysicsComponent2DBase extends CycloComponent
|
|
|
47
51
|
_physicsWorld = null;
|
|
48
52
|
_firstEnabled = true;
|
|
49
53
|
_attached = false;
|
|
50
|
-
_handleAncestorChange() {
|
|
54
|
+
_handleAncestorChange = () => {
|
|
51
55
|
if (this.node) {
|
|
52
56
|
this._tryAttach();
|
|
53
57
|
}
|
|
54
58
|
else {
|
|
55
59
|
this._tryDetach();
|
|
56
60
|
}
|
|
57
|
-
}
|
|
61
|
+
};
|
|
58
62
|
_tryAttach() {
|
|
59
63
|
const node = this.node;
|
|
60
64
|
const physicsWorld = getPhysicsWorld(node.scene);
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import { CycloComponent } from '@cyclonium/core/framework';
|
|
2
|
-
import { PhysicsWorld2D } from './physics-world-2d.js';
|
|
3
2
|
import { Physics2DSettings } from './physics-2d-settings.js';
|
|
3
|
+
import { PhysicsWorld2D } from './physics-world-2d.js';
|
|
4
4
|
export declare class PhysicsWorld2DSceneComponent extends CycloComponent {
|
|
5
5
|
get debug(): boolean;
|
|
6
6
|
set debug(v: boolean);
|
|
7
7
|
get settings(): Physics2DSettings | null;
|
|
8
8
|
set settings(value: Physics2DSettings | null);
|
|
9
|
+
get physicsWorld(): PhysicsWorld2D | null;
|
|
9
10
|
protected onAwake(): void;
|
|
10
11
|
protected onDestroy(): void;
|
|
11
12
|
protected onUpdate(deltaTime: number): void;
|
|
12
|
-
get physicsWorld(): PhysicsWorld2D | null;
|
|
13
13
|
private _physicsWorld;
|
|
14
14
|
private _physicsDebugger;
|
|
15
15
|
private _lastUpdateFrame;
|
|
16
|
+
private _maxSubsteps;
|
|
17
|
+
private _timeAccumulator;
|
|
18
|
+
private _overloading;
|
|
16
19
|
private _debug;
|
|
17
20
|
private _settings;
|
|
18
21
|
private _updateFrame;
|