@series-inc/rundot-syncplay 6.0.0-rc.34 → 6.0.0-rc.35
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/MIGRATING-RC34-TO-RC35.md +334 -0
- package/core/native/physics/constraint_rows.cpp +4 -0
- package/core/native/physics/geometry_store.cpp +22 -0
- package/core/native/physics/geometry_store.hpp +9 -0
- package/core/native/physics/physics.cpp +2139 -211
- package/core/native/physics/physics.hpp +137 -15
- package/core/native/physics/world.cpp +890 -67
- package/core/native/physics/world.hpp +113 -11
- package/core/native/physics/world_abi.cpp +198 -4
- package/core/native/physics/world_abi.hpp +32 -2
- package/core/scripts/build-wasm-physics.mjs +5 -1
- package/core/src/physics/physics-profile-wasm-module.generated.mjs +6 -6
- package/core/src/physics/physics-wasm-module.generated.mjs +6 -6
- package/core/src/physics/voxel-cooking.mjs +11 -8
- package/core/src/physics/world.mjs +188 -8
- package/core/src/physics2d/physics2d-wasm-module.generated.mjs +1 -1
- package/core/world.d.ts +50 -0
- package/dist/physics/3d.d.ts +90 -3
- package/dist/physics/3d.js +2898 -219
- package/dist/physics/installed-runtime3d.d.ts +5 -1
- package/dist/physics/installed-runtime3d.js +2 -1
- package/dist/physics/portal-render3d.d.ts +205 -3
- package/dist/physics/portal-render3d.js +556 -33
- package/dist/physics/vehicle-state3d.js +101 -19
- package/package.json +5 -4
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
# Migrating from Syncplay 6.0.0-rc.34 to rc.35
|
|
2
|
+
|
|
3
|
+
This release completes the portal items of the Wreck Yard request list: A1
|
|
4
|
+
bubbles, A2 shadow clones, A7 (kinematic hosts, wheel rays, and joints
|
|
5
|
+
through portals), and the optional A6 stencil-recursive renderer. Each
|
|
6
|
+
section names what changes for a game and what does not.
|
|
7
|
+
|
|
8
|
+
## Behavior changes
|
|
9
|
+
|
|
10
|
+
### Bodies that straddle an opening touch the far side (A1, A2)
|
|
11
|
+
|
|
12
|
+
Before rc.35, a body half through a portal touched only what was on its own
|
|
13
|
+
side. Its far half could not rest on a floor or push a body in front of the
|
|
14
|
+
linked end.
|
|
15
|
+
|
|
16
|
+
From rc.35:
|
|
17
|
+
|
|
18
|
+
- Static boxes in front of the linked end hold up the part of a straddling
|
|
19
|
+
body that is through the opening. A box half through a wall portal rests on
|
|
20
|
+
the floor in front of the linked end.
|
|
21
|
+
- A straddling dynamic body has a shadow clone at the linked end. A body that
|
|
22
|
+
pushes the clone moves the original by the turned impulse in the same step.
|
|
23
|
+
A stack across a floor-to-ceiling pair is stable, also with a heavy body on
|
|
24
|
+
the clone: the solver treats the clone and the original as one rigid body.
|
|
25
|
+
A straddling kinematic
|
|
26
|
+
body has a kinematic clone, so a door or pusher in an opening pushes bodies
|
|
27
|
+
at the linked end. Only a body whose shape fits the opening has a clone; a
|
|
28
|
+
larger body touches nothing through the opening.
|
|
29
|
+
- A body with a clone crosses onto the clone pose exactly. The crossing has no
|
|
30
|
+
0.05 m nudge.
|
|
31
|
+
|
|
32
|
+
What to check: a game that pushed bodies through an opening against nothing
|
|
33
|
+
now meets the geometry in front of the linked end.
|
|
34
|
+
|
|
35
|
+
The copies (bubbles and clones) are hidden. They are not in queries,
|
|
36
|
+
contacts, fluid interactions, motion or transform reads, `info().bodyCount`,
|
|
37
|
+
or body capacity, and they have no public handle. They exist only while a
|
|
38
|
+
body straddles an open end. They are part of checkpoints, so rollback and late
|
|
39
|
+
join stay bit-identical. Up to 64 copies and joint ghosts can exist at one
|
|
40
|
+
time in a world. When that reserve is full, a new joint ghost takes the place
|
|
41
|
+
of a copy, and the copy comes back at a later step if there is room.
|
|
42
|
+
Fluids act on the original only. While any body uses CCD, clones touch
|
|
43
|
+
nothing, as before rc.35, and vehicle support rows stay on the chassis.
|
|
44
|
+
After a world has run CCD, clones push and stop moving bodies but do not
|
|
45
|
+
separate overlap at once. A clone keeps the original's motion locks
|
|
46
|
+
on the axes that the pair rotation maps onto axes, and all of them when every
|
|
47
|
+
linear or every angular axis is locked. Through a pair turned by an angle
|
|
48
|
+
that is not a quarter turn, a partly locked body's clone loses the other
|
|
49
|
+
locks, so a hit along a locked axis moves the clone and the original does not
|
|
50
|
+
take the full response. A step that fails (for example because an output
|
|
51
|
+
capacity is too small) changes no body, but the hidden copies it made for
|
|
52
|
+
that step stay, so later body ids differ from a world that never failed;
|
|
53
|
+
every peer makes the same ones. Restore a checkpoint after a failed step if a
|
|
54
|
+
later edit must match a world that did not fail. An end on a kinematic host
|
|
55
|
+
follows the host at the start of each step, so after a `setBodyTransform` on
|
|
56
|
+
the host, queries and `portalPairs` show the old end pose until the next
|
|
57
|
+
step. A pose change by `setBodyTransform`, `setTransform`, `edit.atomicTeleport`
|
|
58
|
+
or `edit.replaceBody` is motion when the body moves no more than its shape
|
|
59
|
+
radius plus 0.5 m: it can cross a portal, as velocity-driven motion does. A
|
|
60
|
+
longer jump is a teleport and never counts as a crossing (a respawn behind a
|
|
61
|
+
portal wall stays there); the body's side of each end is taken at the start
|
|
62
|
+
of the next step, so its motion in that step can cross. An end on a kinematic host that a host jump moves
|
|
63
|
+
by up to 1 m sweeps the bodies in its way; a longer end jump does not. Copies are one level deep. When a body is longer than the gap between two
|
|
64
|
+
chained portals, its copy at the first exit can enter the second opening. The
|
|
65
|
+
copy passes the second end's host there, as a real body does, but nothing
|
|
66
|
+
copies it again, so it touches nothing beyond the second exit. When the body
|
|
67
|
+
then crosses the first portal, geometry close beyond the second exit can push
|
|
68
|
+
it back through the first portal (rc.34 behaves the same, with larger jumps).
|
|
69
|
+
Keep such chained ends farther apart than the longest body that crosses them. A clone touches the moving bodies that, at the start of a step, are
|
|
70
|
+
partly in front of its end and within the end's tracking radius plus the
|
|
71
|
+
distance they move in the step at their current speed. A body that comes
|
|
72
|
+
from behind the end's plane, or that a force or a hit speeds up from beyond
|
|
73
|
+
that reach inside one step, meets the clone one step late, as a fast body
|
|
74
|
+
without CCD can pass a thin body. A clone has the whole body shape, also the part
|
|
75
|
+
still behind its exit plane (the part not yet through the entry). A moving
|
|
76
|
+
body beside the exit opening that touches that hidden part pushes the
|
|
77
|
+
original. Host walls hide that part for a hosted end. A body on an ordinary joint (not a joint
|
|
78
|
+
through the portal) teleports when its center crosses, and the joint then
|
|
79
|
+
pulls it back across the gap between the ends (rc.34 behaves the same).
|
|
80
|
+
Create such a joint through the portal (`portal: { pair, end }`), or keep
|
|
81
|
+
jointed bodies away from openings. `portalable` controls only where a
|
|
82
|
+
portal end can be placed, not which bodies cross.
|
|
83
|
+
|
|
84
|
+
### Contacts on cylinders, cones and tapered shapes are exact
|
|
85
|
+
|
|
86
|
+
A contact that involves a cylinder, a tapered cylinder, a cone or a tapered
|
|
87
|
+
capsule now gets the exact contact normal and depth, and its contact points
|
|
88
|
+
lie on the real contact patch. Before rc.35 the contact was too deep on the
|
|
89
|
+
round sides, and the contact point was often an arbitrary rim point:
|
|
90
|
+
|
|
91
|
+
- A body with a joint (and every portal clone) lost its whole velocity
|
|
92
|
+
response when such a contact pushed it.
|
|
93
|
+
- A ball on the flat top of a cylinder, or on the base of an upside-down cone,
|
|
94
|
+
rolled off by itself, and a cylinder standing on a box never came to rest.
|
|
95
|
+
- A centered push turned a cylinder and moved it faster than the pusher.
|
|
96
|
+
|
|
97
|
+
Flat faces of these shapes now give up to four contact points, like a box
|
|
98
|
+
face. Worlds with these contacts give different results from rc.34. A
|
|
99
|
+
sphere on a hull also gets the exact contact normal now, so a ball that slid
|
|
100
|
+
on a hull face in rc.34 can rest. Contacts between boxes, spheres and
|
|
101
|
+
capsules only do not change. Overlap and shape cast hits against cylinders,
|
|
102
|
+
cones, tapered shapes and hulls can report different hit points and normals
|
|
103
|
+
(now the exact ones); their distances and the bodies they report do not
|
|
104
|
+
change. Raycasts and closest points do not change.
|
|
105
|
+
|
|
106
|
+
### Portal ends on kinematic hosts move with the host (A7)
|
|
107
|
+
|
|
108
|
+
Before rc.35, a portal end stayed where it was created when its host moved.
|
|
109
|
+
|
|
110
|
+
From rc.35, an end on a kinematic host follows the host pose. A body that
|
|
111
|
+
crosses keeps its velocity relative to the moving portal: a body at rest that
|
|
112
|
+
the portal sweeps over leaves the linked end at the portal speed.
|
|
113
|
+
`movePortalEnd` sets a new pose relative to the host. Ends on static hosts do
|
|
114
|
+
not change.
|
|
115
|
+
|
|
116
|
+
### Vehicle wheels see through portals (A7)
|
|
117
|
+
|
|
118
|
+
A deterministic vehicle wheel whose anchor is behind an open end, while the
|
|
119
|
+
chassis center is in front of it, casts from the linked end. A car keeps all
|
|
120
|
+
wheels down as it drives through a doorway portal. Wheel telemetry reports the
|
|
121
|
+
contact point and normal on the chassis side, and the support body that the
|
|
122
|
+
ray found. Support rows found through a portal carry
|
|
123
|
+
`portal: { pair, end }` (`PhysicsSupportPortal3D`). `world.applySupport` uses
|
|
124
|
+
it, so `apply: false` followed by `world.applySupport(result.records)` gives
|
|
125
|
+
the same result as automatic application.
|
|
126
|
+
|
|
127
|
+
### Portal view plans keep at most 64 views (P3)
|
|
128
|
+
|
|
129
|
+
Before rc.35, `planPortalViews3D` and `renderPortalViews3D` kept every view
|
|
130
|
+
up to `maxDepth`. From rc.35, they keep at most `maxViews` views, and the
|
|
131
|
+
default is 64. A scene with more than 64 views now gets at most 64. Pass a
|
|
132
|
+
larger `maxViews` to keep more. A scene with 64 views or fewer and the screen
|
|
133
|
+
clip off plans the same views as rc.34. The cull hook is now called level
|
|
134
|
+
by level (breadth first), and it is not called for ends below a level that
|
|
135
|
+
the budget filled. A hook that counts calls or depends on call order must
|
|
136
|
+
not assume the rc.34 depth-first order. See the addition below.
|
|
137
|
+
|
|
138
|
+
### Reusing a body key in one edit
|
|
139
|
+
|
|
140
|
+
An edit that removes a keyed body can create a body with the same key: the
|
|
141
|
+
removal frees the key for the rest of the edit. Before rc.35 this threw
|
|
142
|
+
"Duplicate body key". Two bodies created with one key in one edit still
|
|
143
|
+
throw.
|
|
144
|
+
|
|
145
|
+
### Order of `portalPath`
|
|
146
|
+
|
|
147
|
+
`portalPath` lists the pair ids in the order the query crosses them. Before
|
|
148
|
+
rc.35, a path through two or more portals listed the last pair first.
|
|
149
|
+
|
|
150
|
+
### Queries that start inside a portal opening (opt-in)
|
|
151
|
+
|
|
152
|
+
The default does not change: a query starts in real space from its own
|
|
153
|
+
origin, as in rc.34. A ray that starts inside the host wall hits the wall at
|
|
154
|
+
distance 0, and a ray that starts past the wall sees the floor behind it.
|
|
155
|
+
|
|
156
|
+
From rc.35, a query can ask for the linked start with
|
|
157
|
+
`insideOpening: 'linked'` (on a `raycast`, a `raycastBatch` ray, a
|
|
158
|
+
`shapeCast`, or an `overlap`). Each open end has an opening region: the
|
|
159
|
+
opening rectangle pushed back behind the end's plane to a depth
|
|
160
|
+
D = max(width, height) * 1.5 + 2 metres. When such a query's origin is inside
|
|
161
|
+
that region, it runs from the linked end:
|
|
162
|
+
|
|
163
|
+
- The origin, the direction, and the shape orientation turn through the pair.
|
|
164
|
+
The host of the entry end is not reported.
|
|
165
|
+
- Hits report the real body, world point, and normal on the far side, with
|
|
166
|
+
distances from the original origin.
|
|
167
|
+
- The inside start is one hop: `portalHops: 1` and `portalPath` with the pair
|
|
168
|
+
id. The query continues with the remaining `maxPortalDepth`.
|
|
169
|
+
- With `maxPortalDepth: 0`, the query ignores portals and runs in real space
|
|
170
|
+
from its own origin.
|
|
171
|
+
- An overlap drops the linked end's host and the bodies that reach only the
|
|
172
|
+
part of the shape behind the linked plane. If the shape also reaches in
|
|
173
|
+
front of the entry plane, the overlap keeps the bodies in front of that
|
|
174
|
+
plane.
|
|
175
|
+
- Only the origin is tested. A point on the plane or in front of it is not
|
|
176
|
+
inside. Closed and removed pairs have no opening region.
|
|
177
|
+
|
|
178
|
+
Vehicle wheel rays keep their own rule (see "Vehicle wheels see through
|
|
179
|
+
portals"), and the character controller does not set `insideOpening`, so it
|
|
180
|
+
collides as in rc.34. Use the linked start for probes of a body that is
|
|
181
|
+
passing through an opening, not for sensors in the room behind the wall: such
|
|
182
|
+
a query cannot see geometry behind a wall portal inside the rectangle within
|
|
183
|
+
depth D.
|
|
184
|
+
|
|
185
|
+
### Raycasts cross more than one portal
|
|
186
|
+
|
|
187
|
+
Before rc.35, a raycast crossed at most one portal, also when
|
|
188
|
+
`maxPortalDepth` was 2 or more. A ray that had to cross two portals to reach
|
|
189
|
+
a body returned no hit for that body.
|
|
190
|
+
|
|
191
|
+
From rc.35, `raycast` and `raycastBatch` cross up to `maxPortalDepth` portals
|
|
192
|
+
(default 2), as shape casts already did. Each crossing keeps the 2 mm exit
|
|
193
|
+
offset, so each crossing makes the distance 2 mm shorter than the true path.
|
|
194
|
+
|
|
195
|
+
What to check: a game that casts rays near pairs that face each other, or
|
|
196
|
+
near chained pairs, can now get hits with `portalHops: 2`. Set
|
|
197
|
+
`maxPortalDepth: 1` on a ray to keep the old limit.
|
|
198
|
+
|
|
199
|
+
## Additions
|
|
200
|
+
|
|
201
|
+
### Joints through portals (A7)
|
|
202
|
+
|
|
203
|
+
Joints take `portal: { pair, end }` (`PhysicsJointPortal3D`). bodyA is in front
|
|
204
|
+
of `end`, and bodyB is in front of the linked end. bodyB must exist before the
|
|
205
|
+
edit that creates the joint.
|
|
206
|
+
|
|
207
|
+
```ts
|
|
208
|
+
world.edit((edit) => edit.createJoint({
|
|
209
|
+
type: 'distance',
|
|
210
|
+
bodyA: hook,
|
|
211
|
+
bodyB: ball,
|
|
212
|
+
restLength: meters(3),
|
|
213
|
+
portal: { pair, end: 'A' },
|
|
214
|
+
}));
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
A portal joint cannot use a CCD bodyB. Joint reactions and break events name
|
|
218
|
+
the real bodyB, with the force and torque on it. The joint acts on bodyB as
|
|
219
|
+
seen through the pair. When either body crosses the
|
|
220
|
+
pair, the joint switches between acting through the pair and acting directly.
|
|
221
|
+
`readJoint` reports the real bodyB. Removing the pair, the joint, or either
|
|
222
|
+
body removes the joint in that edit,
|
|
223
|
+
also while it acts directly.
|
|
224
|
+
|
|
225
|
+
### Stencil-recursive portal rendering (A6)
|
|
226
|
+
|
|
227
|
+
`renderPortalViews3D({ cameraWorldMatrix, projection, pairs, maxDepth, hooks })`
|
|
228
|
+
draws the portal views of one frame with nested stencil regions, depth first.
|
|
229
|
+
`createThreePortalStencilHooks3D({ renderer, scene, camera, portalSurface })`
|
|
230
|
+
gives the hooks for a three.js or react-three-fiber `WebGLRenderer` created
|
|
231
|
+
with `stencil: true`. Both are render only and do not change the simulation.
|
|
232
|
+
|
|
233
|
+
Before each inner view, a surface draw resets the marked region to the far
|
|
234
|
+
depth. That draw has `fill: 'background'` and `colorWrite: true`: it writes
|
|
235
|
+
the background color of the view about to draw, not the surface color. So
|
|
236
|
+
where a nearer portal overlaps a farther one on screen, and the nearer room
|
|
237
|
+
draws nothing at a pixel, the pixel shows the nearer room's background. A
|
|
238
|
+
custom renderer writes its background color in that draw. The three.js hooks
|
|
239
|
+
draw each `MeshBasicMaterial` of the portal surface object as a flat color
|
|
240
|
+
for that draw: the `Color` scene background, or the clear color when the scene
|
|
241
|
+
has no background. A surface with no `MeshBasicMaterial` writes no color
|
|
242
|
+
there.
|
|
243
|
+
|
|
244
|
+
### Portal view budget and screen clip (P3)
|
|
245
|
+
|
|
246
|
+
`planPortalViews3D` and `renderPortalViews3D` take `maxViews` (default 64).
|
|
247
|
+
The planner selects views breadth first, so its work stays within the budget.
|
|
248
|
+
It keeps whole depths first, and it returns the kept views in the same
|
|
249
|
+
depth-first draw order. Both functions return a `PortalViewPlan3D`: the views,
|
|
250
|
+
with a non-enumerable `truncated` flag that is true when the budget left out a
|
|
251
|
+
view.
|
|
252
|
+
|
|
253
|
+
`screenClip: true` with the eye `projection` gives each view a nested scissor
|
|
254
|
+
rect in normalized device coordinates (`screenRect`). It culls child ends that
|
|
255
|
+
are off screen or outside their parent's opening, and it passes
|
|
256
|
+
`parentScreenRect` and `screenRect` to the cull hook. `renderPortalViews3D`
|
|
257
|
+
then puts a `scissor` on each draw, and `createThreePortalStencilHooks3D`
|
|
258
|
+
applies it through `setScissor`. The clip is off by default. New types:
|
|
259
|
+
`PortalScreenRect3D` and `PortalViewPlan3D`.
|
|
260
|
+
|
|
261
|
+
### Teleport counters (rc.34 review P2-a)
|
|
262
|
+
|
|
263
|
+
Each body has an unsigned 32-bit teleport counter. It increases by 1 for each
|
|
264
|
+
pose jump: a portal crossing, an ejection when a pair closes, moves, or goes
|
|
265
|
+
away, `edit.atomicTeleport` on an existing body, and a `setBodyTransform` or
|
|
266
|
+
`setTransform` call that changes the pose. Read the counters with a fifth
|
|
267
|
+
`Uint32Array` output on `world.writeBodyMotionInto`,
|
|
268
|
+
`world.writeCheckpointBodyMotionInto`, and
|
|
269
|
+
`PhysicsCheckpointView3D.writeBodyMotionInto`. Each
|
|
270
|
+
`latest().motionBatch.bodies` entry also carries `teleports`. A renderer that
|
|
271
|
+
keeps the counters of the previous frame snaps a body whose counter changed
|
|
272
|
+
(compare with `!==`; the counter wraps). This finds a crossing in any step of
|
|
273
|
+
a frame, also after a rollback replay.
|
|
274
|
+
|
|
275
|
+
```ts
|
|
276
|
+
const teleports = new Uint32Array(bodyCapacity);
|
|
277
|
+
const { count } = world.writeBodyMotionInto(poses, velocities, ids, status, teleports);
|
|
278
|
+
for (let row = 0; row < count; row += 1) {
|
|
279
|
+
if (previous.get(ids[row]!) !== teleports[row]) snap(ids[row]!);
|
|
280
|
+
}
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
The four-argument calls return and write the same values as before.
|
|
284
|
+
|
|
285
|
+
### Straddler list (rc.34 review P2-b)
|
|
286
|
+
|
|
287
|
+
`world.latest().portalStraddlers` lists the bodies that straddle each open end
|
|
288
|
+
after the last step, as frozen `PortalStraddler3D` entries `{ bodyId, pairId,
|
|
289
|
+
end }`. Draw a second copy of each body at the linked end through
|
|
290
|
+
`portalTransformMatrix3D(pair, end)`, clipped by `portalExitClipPlane3D(pair,
|
|
291
|
+
end)`. The list is part of the checkpoint and not of the digest.
|
|
292
|
+
|
|
293
|
+
### Query index cost under churn and drift (rc.34 P1)
|
|
294
|
+
|
|
295
|
+
`world.queryStats()` reports three more fields: `visitedNodes`,
|
|
296
|
+
`preparedBodies`, and `treeBuilds` (see "Query cost" in the physics guide).
|
|
297
|
+
They are additive cost diagnostics; `testedBodies` does not change.
|
|
298
|
+
|
|
299
|
+
The query index now changes only the affected leaves when bodies are added,
|
|
300
|
+
removed, or edited, and it prepares only edited bodies again. A step or a
|
|
301
|
+
transform change prepares nothing. When bodies drift apart, the index builds
|
|
302
|
+
its tree again, without preparing bodies again, once the tree quality passes
|
|
303
|
+
2 times its value at the last build. Query results do not change; they stay
|
|
304
|
+
bit-identical to the linear scan.
|
|
305
|
+
|
|
306
|
+
No action is needed.
|
|
307
|
+
|
|
308
|
+
## Checkpoints
|
|
309
|
+
|
|
310
|
+
Portal trailer version 2 stays the same. Checkpoints from rc.34 restore. Their
|
|
311
|
+
proxy list is empty, and the first step creates the proxies that the bodies
|
|
312
|
+
need. They restore with every teleport counter at 0 and an empty straddler
|
|
313
|
+
list.
|
|
314
|
+
|
|
315
|
+
A world in which a body jumped now carries the teleport counters in its
|
|
316
|
+
checkpoint and in `world.digest()`, `digestCheckpoint`, and the strong digest.
|
|
317
|
+
Only a world with no portal pair and no pose jump keeps the checkpoint bytes
|
|
318
|
+
and digest that rc.34 gives, and only when every orientation it was given
|
|
319
|
+
normalizes the same way (see the next paragraph). A pose jump also happens
|
|
320
|
+
without portals: a
|
|
321
|
+
`setBodyTransform` or `setTransform` call that changes a pose (a respawn, for
|
|
322
|
+
example) and `edit.atomicTeleport` count it. A world with a portal pair
|
|
323
|
+
writes its proxy list (also when empty) and the new portal state. In both
|
|
324
|
+
cases the bytes and digest differ from rc.34. A checkpoint also records the straddler list of the last step;
|
|
325
|
+
the list is not part of the digest.
|
|
326
|
+
|
|
327
|
+
Orientations are now normalized with an exact square root
|
|
328
|
+
(`Math.sqrt`), not `Math.hypot`, whose last bit can differ between
|
|
329
|
+
JavaScript engines. An orientation that is not exactly unit length (for
|
|
330
|
+
example one built with `Math.sin` and `Math.cos`) can be stored 1 ULP
|
|
331
|
+
different from rc.34. That body's checkpoint bytes, digest, and later motion
|
|
332
|
+
then differ from rc.34, also in a world with no portal. Identity and other
|
|
333
|
+
exactly unit orientations do not change. Replays and golden digests recorded
|
|
334
|
+
with rc.34 can stop matching for this reason alone.
|
|
@@ -708,6 +708,7 @@ std::int32_t SixDofSubstepParticipant::invoke(SubstepConstraintPhase phase,
|
|
|
708
708
|
const SubstepConstraintContext& context, void* owner) {
|
|
709
709
|
if (owner == nullptr) return 3;
|
|
710
710
|
auto& state = *static_cast<SixDofSubstepParticipant*>(owner);
|
|
711
|
+
if (phase == SubstepConstraintPhase::BeforeSubstepForces) return 0;
|
|
711
712
|
if (context.bodies.size() != context.mobility.size()) return 3;
|
|
712
713
|
if (!std::isfinite(context.options.dtTicks) || context.options.dtTicks <= 0.0) return 3;
|
|
713
714
|
if (phase != SubstepConstraintPhase::BeginFixedSubstep
|
|
@@ -781,6 +782,9 @@ std::int32_t SixDofSubstepParticipant::invoke(SubstepConstraintPhase phase,
|
|
|
781
782
|
if (state.phase_ != Phase::Ready) return 3;
|
|
782
783
|
for (std::size_t index = 0; index < state.constraints_.size(); ++index) {
|
|
783
784
|
const auto range = state.ranges_[index];
|
|
785
|
+
// A joint on a portal ghost acts on its original at once.
|
|
786
|
+
const ProxyBodySync proxySync{context.proxies, context.bodies.data(),
|
|
787
|
+
state.constraints_[index].bodyA, state.constraints_[index].bodyB};
|
|
784
788
|
for (std::uint32_t offset = range[0]; offset < range[0] + range[1]; ++offset) {
|
|
785
789
|
auto& row = state.rows_[offset];
|
|
786
790
|
const double applied = solveConstraintRow(row, context.bodies, context.mobility);
|
|
@@ -291,9 +291,31 @@ GeometryRecord::GeometryRecord(ConstructionKey, std::shared_ptr<AllocationLedger
|
|
|
291
291
|
id(recordId), descriptor(shape), fingerprint(hash),
|
|
292
292
|
strongLeaf_(digestGeometryRecord(shape, values)) {
|
|
293
293
|
buildBounds();
|
|
294
|
+
buildPointBounds();
|
|
294
295
|
buildTriangleIndex();
|
|
295
296
|
}
|
|
296
297
|
|
|
298
|
+
void GeometryRecord::buildPointBounds() {
|
|
299
|
+
if (descriptor.kind == ShapeKind::Compound || descriptor.count == 0) return;
|
|
300
|
+
const std::uint32_t skip = descriptor.kind == ShapeKind::Heightfield ? 1 : 0;
|
|
301
|
+
if (descriptor.count <= skip) return;
|
|
302
|
+
const std::uint64_t pointCount = descriptor.count - skip;
|
|
303
|
+
if ((static_cast<std::uint64_t>(skip) + pointCount) * 3 > values_.size()) return;
|
|
304
|
+
const std::uint32_t first = skip * 3;
|
|
305
|
+
pointMinimum_ = {values_[first], values_[first + 1], values_[first + 2]};
|
|
306
|
+
pointMaximum_ = pointMinimum_;
|
|
307
|
+
for (std::uint64_t point = 1; point < pointCount; point += 1) {
|
|
308
|
+
const std::uint64_t offset = first + point * 3;
|
|
309
|
+
pointMinimum_[0] = std::min(pointMinimum_[0], values_[offset]);
|
|
310
|
+
pointMinimum_[1] = std::min(pointMinimum_[1], values_[offset + 1]);
|
|
311
|
+
pointMinimum_[2] = std::min(pointMinimum_[2], values_[offset + 2]);
|
|
312
|
+
pointMaximum_[0] = std::max(pointMaximum_[0], values_[offset]);
|
|
313
|
+
pointMaximum_[1] = std::max(pointMaximum_[1], values_[offset + 1]);
|
|
314
|
+
pointMaximum_[2] = std::max(pointMaximum_[2], values_[offset + 2]);
|
|
315
|
+
}
|
|
316
|
+
hasPointBounds_ = true;
|
|
317
|
+
}
|
|
318
|
+
|
|
297
319
|
void GeometryRecord::buildBounds() {
|
|
298
320
|
if (values_.empty() || descriptor.count == 0) return;
|
|
299
321
|
if (descriptor.kind == ShapeKind::Compound && descriptor.format == 4) {
|
|
@@ -47,7 +47,11 @@ class GeometryRecord : public std::enable_shared_from_this<GeometryRecord> {
|
|
|
47
47
|
bool hasBounds_ = false;
|
|
48
48
|
std::array<double, 3> minimum_{};
|
|
49
49
|
std::array<double, 3> maximum_{};
|
|
50
|
+
bool hasPointBounds_ = false;
|
|
51
|
+
std::array<double, 3> pointMinimum_{};
|
|
52
|
+
std::array<double, 3> pointMaximum_{};
|
|
50
53
|
void buildBounds();
|
|
54
|
+
void buildPointBounds();
|
|
51
55
|
void buildTriangleIndex();
|
|
52
56
|
std::uint32_t buildTriangleNode(std::uint32_t offset, std::uint32_t first, std::uint32_t count);
|
|
53
57
|
public:
|
|
@@ -68,6 +72,11 @@ class GeometryRecord : public std::enable_shared_from_this<GeometryRecord> {
|
|
|
68
72
|
bool hasBounds() const noexcept { return hasBounds_; }
|
|
69
73
|
const std::array<double, 3>& minimum() const noexcept { return minimum_; }
|
|
70
74
|
const std::array<double, 3>& maximum() const noexcept { return maximum_; }
|
|
75
|
+
// Bounds of the point list for a mesh, heightfield, or hull record. They equal the
|
|
76
|
+
// per-call scan of the whole record, in the same order, so the result is bit-identical.
|
|
77
|
+
bool hasPointBounds() const noexcept { return hasPointBounds_; }
|
|
78
|
+
const std::array<double, 3>& pointMinimum() const noexcept { return pointMinimum_; }
|
|
79
|
+
const std::array<double, 3>& pointMaximum() const noexcept { return pointMaximum_; }
|
|
71
80
|
};
|
|
72
81
|
using GeometryRecordOwner = std::shared_ptr<const GeometryRecord>;
|
|
73
82
|
struct GeometryBinding {
|