@flighthq/physics2d 0.5.1-next.815.cc08b93 → 0.5.1-next.903.f434bc2
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/README.md +2 -2
- package/dist/colliderTransform.d.ts +19 -1
- package/dist/colliderTransform.d.ts.map +1 -1
- package/dist/colliderTransform.js +74 -15
- package/dist/colliderTransform.js.map +1 -1
- package/dist/contract.d.ts +4 -0
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +4 -0
- package/dist/contract.js.map +1 -1
- package/dist/debugGeometry.d.ts +2 -1
- package/dist/debugGeometry.d.ts.map +1 -1
- package/dist/debugGeometry.js +11 -3
- package/dist/debugGeometry.js.map +1 -1
- package/dist/jointFactories.d.ts +10 -1
- package/dist/jointFactories.d.ts.map +1 -1
- package/dist/jointFactories.js +153 -130
- package/dist/jointFactories.js.map +1 -1
- package/dist/jointReactions.d.ts +2 -1
- package/dist/jointReactions.d.ts.map +1 -1
- package/dist/jointReactions.js +10 -3
- package/dist/jointReactions.js.map +1 -1
- package/dist/world.d.ts +4 -1
- package/dist/world.d.ts.map +1 -1
- package/dist/world.js +77 -68
- package/dist/world.js.map +1 -1
- package/dist/worldQueries.d.ts +4 -1
- package/dist/worldQueries.d.ts.map +1 -1
- package/dist/worldQueries.js +38 -24
- package/dist/worldQueries.js.map +1 -1
- package/package.json +8 -8
- package/src/debugGeometry.test.ts +20 -20
- package/src/enablePhysics2DGuards.test.ts +23 -24
- package/src/jointReactions.test.ts +20 -20
- package/src/jointRegistry.test.ts +20 -20
- package/src/joints.test.ts +20 -20
- package/src/step.test.ts +6 -2
- package/src/stepValidation.test.ts +6 -2
- package/src/world.test.ts +6 -2
package/dist/jointFactories.js
CHANGED
|
@@ -1,155 +1,178 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
2
|
import { Physics2DDistanceJointKind, Physics2DGearJointKind, Physics2DMouseJointKind, Physics2DPrismaticJointKind, Physics2DPulleyJointKind, Physics2DRevoluteJointKind, Physics2DRopeJointKind, Physics2DWeldJointKind, Physics2DWheelJointKind, } from './joints';
|
|
3
3
|
// Joint factories mirror Flight's other descriptor factories: they allocate plain data, accept one
|
|
4
4
|
// readonly options object, and make only authoring choices. Registration and world mutation remain
|
|
5
5
|
// explicit operations. The common helper is also the boundary that keeps solver-owned cache out of
|
|
6
6
|
// every public options type.
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
rAY: 0,
|
|
25
|
-
rBX: 0,
|
|
26
|
-
rBY: 0,
|
|
27
|
-
});
|
|
7
|
+
function initJointBase(out, options) {
|
|
8
|
+
out.bodyA = options.bodyA;
|
|
9
|
+
out.bodyB = options.bodyB;
|
|
10
|
+
out.localAnchorAX = options.localAnchorAX ?? 0;
|
|
11
|
+
out.localAnchorAY = options.localAnchorAY ?? 0;
|
|
12
|
+
out.localAnchorBX = options.localAnchorBX ?? 0;
|
|
13
|
+
out.localAnchorBY = options.localAnchorBY ?? 0;
|
|
14
|
+
out.collideConnected = options.collideConnected ?? false;
|
|
15
|
+
out.breakForce = options.breakForce ?? Number.POSITIVE_INFINITY;
|
|
16
|
+
out.breakTorque = options.breakTorque ?? Number.POSITIVE_INFINITY;
|
|
17
|
+
out.impulse0 = 0;
|
|
18
|
+
out.impulse1 = 0;
|
|
19
|
+
out.impulse2 = 0;
|
|
20
|
+
out.rAX = 0;
|
|
21
|
+
out.rAY = 0;
|
|
22
|
+
out.rBX = 0;
|
|
23
|
+
out.rBY = 0;
|
|
28
24
|
}
|
|
29
25
|
export function createPhysics2DDistanceJoint(options) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
length: options.length,
|
|
34
|
-
frequencyHz: options.frequencyHz ?? 0,
|
|
35
|
-
dampingRatio: options.dampingRatio ?? 0,
|
|
36
|
-
});
|
|
26
|
+
const out = allocateEntity();
|
|
27
|
+
initializePhysics2DDistanceJoint(out, options);
|
|
28
|
+
return finishEntity(out);
|
|
37
29
|
}
|
|
38
30
|
export function createPhysics2DGearJoint(options) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
coordinateA: options.coordinateA,
|
|
43
|
-
coordinateB: options.coordinateB,
|
|
44
|
-
axisAX: options.axisAX ?? 1,
|
|
45
|
-
axisAY: options.axisAY ?? 0,
|
|
46
|
-
axisBX: options.axisBX ?? 1,
|
|
47
|
-
axisBY: options.axisBY ?? 0,
|
|
48
|
-
ratio: options.ratio ?? 1,
|
|
49
|
-
constant: options.constant,
|
|
50
|
-
});
|
|
31
|
+
const out = allocateEntity();
|
|
32
|
+
initializePhysics2DGearJoint(out, options);
|
|
33
|
+
return finishEntity(out);
|
|
51
34
|
}
|
|
52
35
|
export function createPhysics2DMouseJoint(options) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
bodyB: options.body,
|
|
57
|
-
localAnchorAX: 0,
|
|
58
|
-
localAnchorAY: 0,
|
|
59
|
-
localAnchorBX: options.localAnchorX ?? 0,
|
|
60
|
-
localAnchorBY: options.localAnchorY ?? 0,
|
|
61
|
-
collideConnected: false,
|
|
62
|
-
breakForce: options.breakForce ?? Number.POSITIVE_INFINITY,
|
|
63
|
-
breakTorque: options.breakTorque ?? Number.POSITIVE_INFINITY,
|
|
64
|
-
impulse0: 0,
|
|
65
|
-
impulse1: 0,
|
|
66
|
-
impulse2: 0,
|
|
67
|
-
rAX: 0,
|
|
68
|
-
rAY: 0,
|
|
69
|
-
rBX: 0,
|
|
70
|
-
rBY: 0,
|
|
71
|
-
targetX: options.targetX,
|
|
72
|
-
targetY: options.targetY,
|
|
73
|
-
maxForce: options.maxForce,
|
|
74
|
-
frequencyHz: options.frequencyHz ?? 5,
|
|
75
|
-
dampingRatio: options.dampingRatio ?? 0.7,
|
|
76
|
-
});
|
|
36
|
+
const out = allocateEntity();
|
|
37
|
+
initializePhysics2DMouseJoint(out, options);
|
|
38
|
+
return finishEntity(out);
|
|
77
39
|
}
|
|
78
40
|
export function createPhysics2DPrismaticJoint(options) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
localAxisAX: options.localAxisAX ?? 1,
|
|
83
|
-
localAxisAY: options.localAxisAY ?? 0,
|
|
84
|
-
referenceAngle: options.referenceAngle ?? 0,
|
|
85
|
-
enableMotor: options.enableMotor ?? false,
|
|
86
|
-
motorSpeed: options.motorSpeed ?? 0,
|
|
87
|
-
maxMotorForce: options.maxMotorForce ?? 0,
|
|
88
|
-
motorImpulse: 0,
|
|
89
|
-
enableLimit: options.enableLimit ?? false,
|
|
90
|
-
lowerTranslation: options.lowerTranslation ?? 0,
|
|
91
|
-
upperTranslation: options.upperTranslation ?? 0,
|
|
92
|
-
enableLimitSpring: options.enableLimitSpring ?? false,
|
|
93
|
-
limitFrequencyHz: options.limitFrequencyHz ?? 0,
|
|
94
|
-
limitDampingRatio: options.limitDampingRatio ?? 0,
|
|
95
|
-
});
|
|
41
|
+
const out = allocateEntity();
|
|
42
|
+
initializePhysics2DPrismaticJoint(out, options);
|
|
43
|
+
return finishEntity(out);
|
|
96
44
|
}
|
|
97
45
|
export function createPhysics2DPulleyJoint(options) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
groundAnchorAX: options.groundAnchorAX,
|
|
102
|
-
groundAnchorAY: options.groundAnchorAY,
|
|
103
|
-
groundAnchorBX: options.groundAnchorBX,
|
|
104
|
-
groundAnchorBY: options.groundAnchorBY,
|
|
105
|
-
ratio: options.ratio ?? 1,
|
|
106
|
-
constant: options.constant,
|
|
107
|
-
});
|
|
46
|
+
const out = allocateEntity();
|
|
47
|
+
initializePhysics2DPulleyJoint(out, options);
|
|
48
|
+
return finishEntity(out);
|
|
108
49
|
}
|
|
109
50
|
export function createPhysics2DRevoluteJoint(options) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
enableMotor: options.enableMotor ?? false,
|
|
114
|
-
motorSpeed: options.motorSpeed ?? 0,
|
|
115
|
-
maxMotorTorque: options.maxMotorTorque ?? 0,
|
|
116
|
-
motorImpulse: 0,
|
|
117
|
-
enableLimit: options.enableLimit ?? false,
|
|
118
|
-
lowerAngle: options.lowerAngle ?? 0,
|
|
119
|
-
upperAngle: options.upperAngle ?? 0,
|
|
120
|
-
referenceAngle: options.referenceAngle ?? 0,
|
|
121
|
-
enableLimitSpring: options.enableLimitSpring ?? false,
|
|
122
|
-
limitFrequencyHz: options.limitFrequencyHz ?? 0,
|
|
123
|
-
limitDampingRatio: options.limitDampingRatio ?? 0,
|
|
124
|
-
});
|
|
51
|
+
const out = allocateEntity();
|
|
52
|
+
initializePhysics2DRevoluteJoint(out, options);
|
|
53
|
+
return finishEntity(out);
|
|
125
54
|
}
|
|
126
55
|
export function createPhysics2DRopeJoint(options) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
maxLength: options.maxLength,
|
|
131
|
-
});
|
|
56
|
+
const out = allocateEntity();
|
|
57
|
+
initializePhysics2DRopeJoint(out, options);
|
|
58
|
+
return finishEntity(out);
|
|
132
59
|
}
|
|
133
60
|
export function createPhysics2DWeldJoint(options) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
referenceAngle: options.referenceAngle ?? 0,
|
|
138
|
-
});
|
|
61
|
+
const out = allocateEntity();
|
|
62
|
+
initializePhysics2DWeldJoint(out, options);
|
|
63
|
+
return finishEntity(out);
|
|
139
64
|
}
|
|
140
65
|
export function createPhysics2DWheelJoint(options) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
66
|
+
const out = allocateEntity();
|
|
67
|
+
initializePhysics2DWheelJoint(out, options);
|
|
68
|
+
return finishEntity(out);
|
|
69
|
+
}
|
|
70
|
+
export function initializePhysics2DDistanceJoint(out, options) {
|
|
71
|
+
out.kind = Physics2DDistanceJointKind;
|
|
72
|
+
initJointBase(out, options);
|
|
73
|
+
out.length = options.length;
|
|
74
|
+
out.frequencyHz = options.frequencyHz ?? 0;
|
|
75
|
+
out.dampingRatio = options.dampingRatio ?? 0;
|
|
76
|
+
}
|
|
77
|
+
export function initializePhysics2DGearJoint(out, options) {
|
|
78
|
+
out.kind = Physics2DGearJointKind;
|
|
79
|
+
initJointBase(out, options);
|
|
80
|
+
out.coordinateA = options.coordinateA;
|
|
81
|
+
out.coordinateB = options.coordinateB;
|
|
82
|
+
out.axisAX = options.axisAX ?? 1;
|
|
83
|
+
out.axisAY = options.axisAY ?? 0;
|
|
84
|
+
out.axisBX = options.axisBX ?? 1;
|
|
85
|
+
out.axisBY = options.axisBY ?? 0;
|
|
86
|
+
out.ratio = options.ratio ?? 1;
|
|
87
|
+
out.constant = options.constant;
|
|
88
|
+
}
|
|
89
|
+
export function initializePhysics2DMouseJoint(out, options) {
|
|
90
|
+
out.kind = Physics2DMouseJointKind;
|
|
91
|
+
out.bodyA = options.body;
|
|
92
|
+
out.bodyB = options.body;
|
|
93
|
+
out.localAnchorAX = 0;
|
|
94
|
+
out.localAnchorAY = 0;
|
|
95
|
+
out.localAnchorBX = options.localAnchorX ?? 0;
|
|
96
|
+
out.localAnchorBY = options.localAnchorY ?? 0;
|
|
97
|
+
out.collideConnected = false;
|
|
98
|
+
out.breakForce = options.breakForce ?? Number.POSITIVE_INFINITY;
|
|
99
|
+
out.breakTorque = options.breakTorque ?? Number.POSITIVE_INFINITY;
|
|
100
|
+
out.impulse0 = 0;
|
|
101
|
+
out.impulse1 = 0;
|
|
102
|
+
out.impulse2 = 0;
|
|
103
|
+
out.rAX = 0;
|
|
104
|
+
out.rAY = 0;
|
|
105
|
+
out.rBX = 0;
|
|
106
|
+
out.rBY = 0;
|
|
107
|
+
out.targetX = options.targetX;
|
|
108
|
+
out.targetY = options.targetY;
|
|
109
|
+
out.maxForce = options.maxForce;
|
|
110
|
+
out.frequencyHz = options.frequencyHz ?? 5;
|
|
111
|
+
out.dampingRatio = options.dampingRatio ?? 0.7;
|
|
112
|
+
}
|
|
113
|
+
export function initializePhysics2DPrismaticJoint(out, options) {
|
|
114
|
+
out.kind = Physics2DPrismaticJointKind;
|
|
115
|
+
initJointBase(out, options);
|
|
116
|
+
out.localAxisAX = options.localAxisAX ?? 1;
|
|
117
|
+
out.localAxisAY = options.localAxisAY ?? 0;
|
|
118
|
+
out.referenceAngle = options.referenceAngle ?? 0;
|
|
119
|
+
out.enableMotor = options.enableMotor ?? false;
|
|
120
|
+
out.motorSpeed = options.motorSpeed ?? 0;
|
|
121
|
+
out.maxMotorForce = options.maxMotorForce ?? 0;
|
|
122
|
+
out.motorImpulse = 0;
|
|
123
|
+
out.enableLimit = options.enableLimit ?? false;
|
|
124
|
+
out.lowerTranslation = options.lowerTranslation ?? 0;
|
|
125
|
+
out.upperTranslation = options.upperTranslation ?? 0;
|
|
126
|
+
out.enableLimitSpring = options.enableLimitSpring ?? false;
|
|
127
|
+
out.limitFrequencyHz = options.limitFrequencyHz ?? 0;
|
|
128
|
+
out.limitDampingRatio = options.limitDampingRatio ?? 0;
|
|
129
|
+
}
|
|
130
|
+
export function initializePhysics2DPulleyJoint(out, options) {
|
|
131
|
+
out.kind = Physics2DPulleyJointKind;
|
|
132
|
+
initJointBase(out, options);
|
|
133
|
+
out.groundAnchorAX = options.groundAnchorAX;
|
|
134
|
+
out.groundAnchorAY = options.groundAnchorAY;
|
|
135
|
+
out.groundAnchorBX = options.groundAnchorBX;
|
|
136
|
+
out.groundAnchorBY = options.groundAnchorBY;
|
|
137
|
+
out.ratio = options.ratio ?? 1;
|
|
138
|
+
out.constant = options.constant;
|
|
139
|
+
}
|
|
140
|
+
export function initializePhysics2DRevoluteJoint(out, options) {
|
|
141
|
+
out.kind = Physics2DRevoluteJointKind;
|
|
142
|
+
initJointBase(out, options);
|
|
143
|
+
out.enableMotor = options.enableMotor ?? false;
|
|
144
|
+
out.motorSpeed = options.motorSpeed ?? 0;
|
|
145
|
+
out.maxMotorTorque = options.maxMotorTorque ?? 0;
|
|
146
|
+
out.motorImpulse = 0;
|
|
147
|
+
out.enableLimit = options.enableLimit ?? false;
|
|
148
|
+
out.lowerAngle = options.lowerAngle ?? 0;
|
|
149
|
+
out.upperAngle = options.upperAngle ?? 0;
|
|
150
|
+
out.referenceAngle = options.referenceAngle ?? 0;
|
|
151
|
+
out.enableLimitSpring = options.enableLimitSpring ?? false;
|
|
152
|
+
out.limitFrequencyHz = options.limitFrequencyHz ?? 0;
|
|
153
|
+
out.limitDampingRatio = options.limitDampingRatio ?? 0;
|
|
154
|
+
}
|
|
155
|
+
export function initializePhysics2DRopeJoint(out, options) {
|
|
156
|
+
out.kind = Physics2DRopeJointKind;
|
|
157
|
+
initJointBase(out, options);
|
|
158
|
+
out.maxLength = options.maxLength;
|
|
159
|
+
}
|
|
160
|
+
export function initializePhysics2DWeldJoint(out, options) {
|
|
161
|
+
out.kind = Physics2DWeldJointKind;
|
|
162
|
+
initJointBase(out, options);
|
|
163
|
+
out.referenceAngle = options.referenceAngle ?? 0;
|
|
164
|
+
}
|
|
165
|
+
export function initializePhysics2DWheelJoint(out, options) {
|
|
166
|
+
out.kind = Physics2DWheelJointKind;
|
|
167
|
+
initJointBase(out, options);
|
|
168
|
+
out.localAxisAX = options.localAxisAX ?? 0;
|
|
169
|
+
out.localAxisAY = options.localAxisAY ?? 1;
|
|
170
|
+
out.restTranslation = options.restTranslation ?? 0;
|
|
171
|
+
out.frequencyHz = options.frequencyHz ?? 0;
|
|
172
|
+
out.dampingRatio = options.dampingRatio ?? 0;
|
|
173
|
+
out.enableMotor = options.enableMotor ?? false;
|
|
174
|
+
out.motorSpeed = options.motorSpeed ?? 0;
|
|
175
|
+
out.maxMotorTorque = options.maxMotorTorque ?? 0;
|
|
176
|
+
out.motorImpulse = 0;
|
|
154
177
|
}
|
|
155
178
|
//# sourceMappingURL=jointFactories.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jointFactories.js","sourceRoot":"","sources":["../src/jointFactories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"jointFactories.js","sourceRoot":"","sources":["../src/jointFactories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAyBzE,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,EACtB,uBAAuB,EACvB,2BAA2B,EAC3B,wBAAwB,EACxB,0BAA0B,EAC1B,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,UAAU,CAAC;AAElB,mGAAmG;AACnG,mGAAmG;AACnG,mGAAmG;AACnG,6BAA6B;AAC7B,SAAS,aAAa,CAAC,GAAmB,EAAE,OAAwC;IAClF,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC1B,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC1B,GAAG,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,CAAC,CAAC;IAC/C,GAAG,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,CAAC,CAAC;IAC/C,GAAG,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,CAAC,CAAC;IAC/C,GAAG,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,CAAC,CAAC;IAC/C,GAAG,CAAC,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,IAAI,KAAK,CAAC;IACzD,GAAG,CAAC,UAAU,GAAG,OA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CAAC,CAAC;IAC5B,GAAG,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,CAAC,CAAC;IAC3C,GAAG,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,CAAC,CAAC;IAC3C,GAAG,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,CAAC,CAAC;IACnD,GAAG,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,CAAC,CAAC;IAC3C,GAAG,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,CAAC,CAAC;IAC7C,GAAG,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,KAAK,CAAC;IAC/C,GAAG,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,CAAC,CAAC;IACzC,GAAG,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,CAAC,CAAC;IACjD,GAAG,CAAC,YAAY,GAAG,CAAC,CAAC;AACvB,CAAC"}
|
package/dist/jointReactions.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Physics2DJoint, Physics2DJointReaction, Physics2DWorld } from '@flighthq/types/contract';
|
|
1
|
+
import type { EntityConstruction, Physics2DJoint, Physics2DJointReaction, Physics2DWorld } from '@flighthq/types/contract';
|
|
2
2
|
export declare function createPhysics2DJointReaction(): Physics2DJointReaction;
|
|
3
|
+
export declare function initializePhysics2DJointReaction(out: EntityConstruction<Physics2DJointReaction>): void;
|
|
3
4
|
export declare function writePhysics2DJointReaction(world: Readonly<Physics2DWorld>, joint: Readonly<Physics2DJoint>, dt: number, out: Physics2DJointReaction): boolean;
|
|
4
5
|
//# sourceMappingURL=jointReactions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jointReactions.d.ts","sourceRoot":"","sources":["../src/jointReactions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"jointReactions.d.ts","sourceRoot":"","sources":["../src/jointReactions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,kBAAkB,EAClB,cAAc,EACd,sBAAsB,EACtB,cAAc,EACf,MAAM,0BAA0B,CAAC;AAElC,wBAAgB,4BAA4B,IAAI,sBAAsB,CAIrE;AAGD,wBAAgB,gCAAgC,CAAC,GAAG,EAAE,kBAAkB,CAAC,sBAAsB,CAAC,GAAG,IAAI,CAItG;AAiBD,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,QAAQ,CAAC,cAAc,CAAC,EAC/B,KAAK,EAAE,QAAQ,CAAC,cAAc,CAAC,EAC/B,EAAE,EAAE,MAAM,EACV,GAAG,EAAE,sBAAsB,GAC1B,OAAO,CAQT"}
|
package/dist/jointReactions.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
// An all-zero reaction, for a caller that wants somewhere to write.
|
|
1
|
+
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
3
2
|
export function createPhysics2DJointReaction() {
|
|
4
|
-
|
|
3
|
+
const out = allocateEntity();
|
|
4
|
+
initializePhysics2DJointReaction(out);
|
|
5
|
+
return finishEntity(out);
|
|
6
|
+
}
|
|
7
|
+
// An all-zero reaction, for a caller that wants somewhere to write.
|
|
8
|
+
export function initializePhysics2DJointReaction(out) {
|
|
9
|
+
out.forceX = 0;
|
|
10
|
+
out.forceY = 0;
|
|
11
|
+
out.torque = 0;
|
|
5
12
|
}
|
|
6
13
|
// Writes the force and couple `joint` applied to body B on the step that just ran, in world space.
|
|
7
14
|
//
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jointReactions.js","sourceRoot":"","sources":["../src/jointReactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"jointReactions.js","sourceRoot":"","sources":["../src/jointReactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE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|
|
1
|
-
import type { CollisionBuiltInShape2D, NonEntityCreateResult, Physics2DCollisionFilter, Physics2DCollider, Physics2DMaterial, Physics2DSolverConfig, Physics2DWorld, RigidBody2D, SpatialIndexBackend2D } from '@flighthq/types/contract';
|
|
1
|
+
import type { CollisionBuiltInShape2D, EntityConstruction, NonEntityCreateResult, Physics2DCollisionFilter, Physics2DCollider, Physics2DMaterial, Physics2DSolverConfig, Physics2DWorld, RigidBody2D, SpatialIndexBackend2D } from '@flighthq/types/contract';
|
|
2
2
|
export declare function addPhysics2DBody(world: Physics2DWorld, body: RigidBody2D): RigidBody2D;
|
|
3
3
|
export declare function addPhysics2DCollider(world: Physics2DWorld, body: RigidBody2D, collider: Physics2DCollider): Physics2DCollider;
|
|
4
4
|
export declare function applyPhysics2DForce(body: RigidBody2D, forceX: number, forceY: number): boolean;
|
|
@@ -12,6 +12,9 @@ export declare function createPhysics2DWorld(gravityX?: number, gravityY?: numbe
|
|
|
12
12
|
export declare function createRigidBody2D(type: RigidBody2D['type'], x: number, y: number, angle?: number): RigidBody2D;
|
|
13
13
|
export declare function findPhysics2DBody(world: Readonly<Physics2DWorld>, index: number): RigidBody2D | null;
|
|
14
14
|
export declare function hydratePhysics2DWorld(world: Physics2DWorld): boolean;
|
|
15
|
+
export declare function initializePhysics2DCollider(out: EntityConstruction<Physics2DCollider>, filter: Physics2DCollisionFilter, local: CollisionBuiltInShape2D, material: Physics2DMaterial, sensor: boolean, world: Physics2DCollider['world']): void;
|
|
16
|
+
export declare function initializePhysics2DWorld(out: EntityConstruction<Physics2DWorld>, config: NonEntityCreateResult<Physics2DSolverConfig, 'options'>, gravityX: number, gravityY: number, index: SpatialIndexBackend2D): void;
|
|
17
|
+
export declare function initializeRigidBody2D(out: EntityConstruction<RigidBody2D>, angle: number, type: RigidBody2D['type'], x: number, y: number): void;
|
|
15
18
|
export declare function invalidatePhysics2DCollider(world: Physics2DWorld, body: RigidBody2D, collider: Physics2DCollider): boolean;
|
|
16
19
|
export declare function isPhysics2DPairOrdered(a: Readonly<RigidBody2D>, b: Readonly<RigidBody2D>): boolean;
|
|
17
20
|
export declare function removePhysics2DBody(world: Physics2DWorld, body: Readonly<RigidBody2D>): boolean;
|
package/dist/world.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"world.d.ts","sourceRoot":"","sources":["../src/world.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,uBAAuB,EACvB,qBAAqB,EACrB,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,EACd,WAAW,EACX,qBAAqB,EACtB,MAAM,0BAA0B,CAAC;AAkBlC,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,GAAG,WAAW,CAsBtF;AAMD,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,cAAc,EACrB,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,iBAAiB,GAC1B,iBAAiB,CAuBnB;AAID,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAO9F;AAID,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,WAAW,EACjB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb,OAAO,CAgBT;AAID,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAO1G;AAID,wBAAgB,kCAAkC,CAChD,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb,OAAO,CAiBT;AAGD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,WAAW,EAAE,MAA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K,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,OAAO,CAmBjH;AAgED,eAAO,MAAM,qBAAqB,IAAI,CAAC"}
|
package/dist/world.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
2
|
import { createUniformGridSpatialBackend2D } from '@flighthq/spatial/contract';
|
|
3
3
|
import { synchronizePhysics2DBroadphase } from './broadphase';
|
|
4
4
|
import { createPhysics2DColliderWorldShape } from './colliderTransform';
|
|
@@ -140,13 +140,9 @@ export function applyPhysics2DTorque(body, torque) {
|
|
|
140
140
|
// independent invalidation units rather than aliases whose mass and broadphase caches can disagree.
|
|
141
141
|
export function createPhysics2DCollider(local, material, sensor = false, filter) {
|
|
142
142
|
const ownedLocal = clonePhysics2DLocalShape(local);
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
material: { ...material },
|
|
147
|
-
filter: filter === undefined ? { categoryBits: 1, maskBits: 0xffffffff, groupIndex: 0 } : { ...filter },
|
|
148
|
-
sensor,
|
|
149
|
-
});
|
|
143
|
+
const out = allocateEntity();
|
|
144
|
+
initializePhysics2DCollider(out, filter === undefined ? { categoryBits: 1, maskBits: 0xffffffff, groupIndex: 0 } : { ...filter }, ownedLocal, { ...material }, sensor, createPhysics2DColliderWorldShape(ownedLocal));
|
|
145
|
+
return finishEntity(out);
|
|
150
146
|
}
|
|
151
147
|
function clonePhysics2DLocalShape(local) {
|
|
152
148
|
switch (local.kind) {
|
|
@@ -199,71 +195,17 @@ export function createPhysics2DSolverConfig() {
|
|
|
199
195
|
// without this package knowing which it got — `SpatialIndexBackend2D` is already that seam, so physics
|
|
200
196
|
// adds no second one over it.
|
|
201
197
|
export function createPhysics2DWorld(gravityX = 0, gravityY = -9.81, index) {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
bodyByIndex: new Map(),
|
|
206
|
-
contacts: [],
|
|
207
|
-
joints: [],
|
|
208
|
-
jointSolvers: new Map(),
|
|
209
|
-
jointCollisionSuppressions: new Map(),
|
|
210
|
-
events: { began: [], ended: [] },
|
|
211
|
-
jointEvents: { broke: [] },
|
|
212
|
-
contactHooks: { preSolve: null, postSolve: null },
|
|
213
|
-
index: index ?? createUniformGridSpatialBackend2D(1),
|
|
214
|
-
config: createPhysics2DSolverConfig(),
|
|
215
|
-
islandParents: new Map(),
|
|
216
|
-
islandSleepTimers: new Map(),
|
|
217
|
-
solveIslandByRoot: new Map(),
|
|
218
|
-
solveIslandRoots: [],
|
|
219
|
-
solveIslandBodyStarts: [],
|
|
220
|
-
solveIslandBodyCounts: [],
|
|
221
|
-
solveIslandContactStarts: [],
|
|
222
|
-
solveIslandContactCounts: [],
|
|
223
|
-
solveIslandJointStarts: [],
|
|
224
|
-
solveIslandJointCounts: [],
|
|
225
|
-
solveIslandBodyIndices: [],
|
|
226
|
-
solveIslandContactIndices: [],
|
|
227
|
-
solveIslandJointIndices: [],
|
|
228
|
-
solveIslandCursors: [],
|
|
229
|
-
gravityX,
|
|
230
|
-
gravityY,
|
|
231
|
-
previousTimestep: 0,
|
|
232
|
-
nextBodyIndex: 0,
|
|
233
|
-
});
|
|
198
|
+
const out = allocateEntity();
|
|
199
|
+
initializePhysics2DWorld(out, createPhysics2DSolverConfig(), gravityX, gravityY, index ?? createUniformGridSpatialBackend2D(1));
|
|
200
|
+
return finishEntity(out);
|
|
234
201
|
}
|
|
235
202
|
// Creates a rigid body at rest. Mass properties stay zero until the body is added to a world, which
|
|
236
203
|
// derives them from the colliders — a body's mass is never assigned, only derived, so it cannot
|
|
237
204
|
// disagree with its shape.
|
|
238
205
|
export function createRigidBody2D(type, x, y, angle = 0) {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
x,
|
|
243
|
-
y,
|
|
244
|
-
angle,
|
|
245
|
-
velocityX: 0,
|
|
246
|
-
velocityY: 0,
|
|
247
|
-
angularVelocity: 0,
|
|
248
|
-
forceX: 0,
|
|
249
|
-
forceY: 0,
|
|
250
|
-
torque: 0,
|
|
251
|
-
mass: 0,
|
|
252
|
-
inverseMass: 0,
|
|
253
|
-
inertia: 0,
|
|
254
|
-
inverseInertia: 0,
|
|
255
|
-
centerX: 0,
|
|
256
|
-
centerY: 0,
|
|
257
|
-
linearDamping: 0,
|
|
258
|
-
angularDamping: 0,
|
|
259
|
-
gravityScale: 1,
|
|
260
|
-
fixedRotation: false,
|
|
261
|
-
bullet: false,
|
|
262
|
-
sleeping: false,
|
|
263
|
-
sleepEnabled: true,
|
|
264
|
-
sleepTimer: 0,
|
|
265
|
-
colliders: [],
|
|
266
|
-
});
|
|
206
|
+
const out = allocateEntity();
|
|
207
|
+
initializeRigidBody2D(out, angle, type, x, y);
|
|
208
|
+
return finishEntity(out);
|
|
267
209
|
}
|
|
268
210
|
// The body carrying `index`, or null when the world no longer holds it. Contacts store body indices
|
|
269
211
|
// rather than references so a contact can outlive one step without pinning a removed body alive; this is
|
|
@@ -305,6 +247,73 @@ export function hydratePhysics2DWorld(world) {
|
|
|
305
247
|
world.version = Physics2DWorldVersion;
|
|
306
248
|
return true;
|
|
307
249
|
}
|
|
250
|
+
export function initializePhysics2DCollider(out, filter, local, material, sensor, world) {
|
|
251
|
+
out.filter = filter;
|
|
252
|
+
out.local = local;
|
|
253
|
+
out.material = material;
|
|
254
|
+
out.sensor = sensor;
|
|
255
|
+
out.world = world;
|
|
256
|
+
}
|
|
257
|
+
export function initializePhysics2DWorld(out, config, gravityX, gravityY, index) {
|
|
258
|
+
out.bodies = [];
|
|
259
|
+
out.bodyByIndex = new Map();
|
|
260
|
+
out.config = config;
|
|
261
|
+
out.contactHooks = { preSolve: null, postSolve: null };
|
|
262
|
+
out.contacts = [];
|
|
263
|
+
out.events = { began: [], ended: [] };
|
|
264
|
+
out.gravityX = gravityX;
|
|
265
|
+
out.gravityY = gravityY;
|
|
266
|
+
out.index = index;
|
|
267
|
+
out.islandParents = new Map();
|
|
268
|
+
out.islandSleepTimers = new Map();
|
|
269
|
+
out.jointCollisionSuppressions = new Map();
|
|
270
|
+
out.jointEvents = { broke: [] };
|
|
271
|
+
out.jointSolvers = new Map();
|
|
272
|
+
out.joints = [];
|
|
273
|
+
out.nextBodyIndex = 0;
|
|
274
|
+
out.previousTimestep = 0;
|
|
275
|
+
out.solveIslandBodyCounts = [];
|
|
276
|
+
out.solveIslandBodyIndices = [];
|
|
277
|
+
out.solveIslandBodyStarts = [];
|
|
278
|
+
out.solveIslandByRoot = new Map();
|
|
279
|
+
out.solveIslandContactCounts = [];
|
|
280
|
+
out.solveIslandContactIndices = [];
|
|
281
|
+
out.solveIslandContactStarts = [];
|
|
282
|
+
out.solveIslandCursors = [];
|
|
283
|
+
out.solveIslandJointCounts = [];
|
|
284
|
+
out.solveIslandJointIndices = [];
|
|
285
|
+
out.solveIslandJointStarts = [];
|
|
286
|
+
out.solveIslandRoots = [];
|
|
287
|
+
out.version = Physics2DWorldVersion;
|
|
288
|
+
}
|
|
289
|
+
export function initializeRigidBody2D(out, angle, type, x, y) {
|
|
290
|
+
out.angle = angle;
|
|
291
|
+
out.angularDamping = 0;
|
|
292
|
+
out.angularVelocity = 0;
|
|
293
|
+
out.bullet = false;
|
|
294
|
+
out.centerX = 0;
|
|
295
|
+
out.centerY = 0;
|
|
296
|
+
out.colliders = [];
|
|
297
|
+
out.fixedRotation = false;
|
|
298
|
+
out.forceX = 0;
|
|
299
|
+
out.forceY = 0;
|
|
300
|
+
out.gravityScale = 1;
|
|
301
|
+
out.index = -1;
|
|
302
|
+
out.inertia = 0;
|
|
303
|
+
out.inverseInertia = 0;
|
|
304
|
+
out.inverseMass = 0;
|
|
305
|
+
out.linearDamping = 0;
|
|
306
|
+
out.mass = 0;
|
|
307
|
+
out.sleepEnabled = true;
|
|
308
|
+
out.sleepTimer = 0;
|
|
309
|
+
out.sleeping = false;
|
|
310
|
+
out.torque = 0;
|
|
311
|
+
out.type = type;
|
|
312
|
+
out.velocityX = 0;
|
|
313
|
+
out.velocityY = 0;
|
|
314
|
+
out.x = x;
|
|
315
|
+
out.y = y;
|
|
316
|
+
}
|
|
308
317
|
// Rebuilds everything derived from a collider after its authored shape, material, filter, or sensor
|
|
309
318
|
// state changes. The caller owns those plain-data fields; this explicit invalidation point keeps mutation
|
|
310
319
|
// cheap while making the necessary cache boundary impossible to mistake for an ordinary assignment.
|