Skip to main content

box3d_rust/recording/
ops.rs

1//! Recording op table generated from recording_ops.inl.
2//! Opcode constants; the framed write helpers live in write_ops/.
3//!
4//! SPDX-FileCopyrightText: 2026 Erin Catto
5//! SPDX-License-Identifier: MIT
6
7/// Opcode constants from recording_ops.inl.
8#[repr(u8)]
9#[derive(Debug, Clone, Copy, PartialEq, Eq)]
10pub enum RecOp {
11    DestroyWorld = 0x01,
12    Step = 0x80,
13    WorldEnableSleeping = 0x02,
14    WorldEnableContinuous = 0x03,
15    WorldSetRestitutionThreshold = 0x04,
16    WorldSetHitEventThreshold = 0x05,
17    WorldSetGravity = 0x06,
18    WorldExplode = 0x07,
19    WorldSetContactTuning = 0x08,
20    WorldSetContactRecycleDistance = 0x09,
21    WorldSetMaximumLinearSpeed = 0x0A,
22    WorldEnableWarmStarting = 0x0B,
23    WorldRebuildStaticTree = 0x0C,
24    WorldEnableSpeculative = 0x0D,
25    CreateBody = 0x10,
26    DestroyBody = 0x11,
27    BodySetTransform = 0x20,
28    BodySetLinearVelocity = 0x21,
29    BodySetType = 0x22,
30    BodySetName = 0x23,
31    BodySetAngularVelocity = 0x24,
32    BodySetTargetTransform = 0x25,
33    BodyApplyForce = 0x26,
34    BodyApplyForceToCenter = 0x27,
35    BodyApplyTorque = 0x28,
36    BodyApplyLinearImpulse = 0x29,
37    BodyApplyLinearImpulseToCenter = 0x2A,
38    BodyApplyAngularImpulse = 0x2B,
39    BodySetMassData = 0x2C,
40    BodyApplyMassFromShapes = 0x2D,
41    BodySetLinearDamping = 0x2E,
42    BodySetAngularDamping = 0x2F,
43    BodySetGravityScale = 0x30,
44    BodySetAwake = 0x31,
45    BodyEnableSleep = 0x32,
46    BodySetSleepThreshold = 0x33,
47    BodyDisable = 0x34,
48    BodyEnable = 0x35,
49    BodySetMotionLocks = 0x36,
50    BodySetBullet = 0x37,
51    BodyEnableContactRecycling = 0x38,
52    BodyEnableHitEvents = 0x39,
53    CreateSphereShape = 0x40,
54    CreateCapsuleShape = 0x41,
55    CreateHullShape = 0x42,
56    CreateMeshShape = 0x43,
57    CreateHeightFieldShape = 0x44,
58    CreateCompoundShape = 0x45,
59    DestroyShape = 0x46,
60    ShapeSetDensity = 0x50,
61    ShapeSetFriction = 0x51,
62    ShapeSetRestitution = 0x52,
63    ShapeSetSurfaceMaterial = 0x53,
64    ShapeSetFilter = 0x54,
65    ShapeEnableSensorEvents = 0x55,
66    ShapeEnableContactEvents = 0x56,
67    ShapeEnablePreSolveEvents = 0x57,
68    ShapeEnableHitEvents = 0x58,
69    ShapeSetSphere = 0x59,
70    ShapeSetCapsule = 0x5A,
71    ShapeApplyWind = 0x5B,
72    ShapeSetName = 0x5C,
73    CreateParallelJoint = 0x90,
74    CreateDistanceJoint = 0x91,
75    CreateFilterJoint = 0x92,
76    CreateMotorJoint = 0x93,
77    CreatePrismaticJoint = 0x94,
78    CreateRevoluteJoint = 0x95,
79    CreateSphericalJoint = 0x96,
80    CreateWeldJoint = 0x97,
81    CreateWheelJoint = 0x98,
82    DestroyJoint = 0x99,
83    JointSetLocalFrameA = 0x9A,
84    JointSetLocalFrameB = 0x9B,
85    JointSetCollideConnected = 0x9C,
86    JointWakeBodies = 0x9D,
87    JointSetConstraintTuning = 0x9E,
88    JointSetForceThreshold = 0x9F,
89    JointSetTorqueThreshold = 0xA0,
90    ParallelJointSetSpringHertz = 0xA1,
91    ParallelJointSetSpringDampingRatio = 0xA2,
92    ParallelJointSetMaxTorque = 0xA3,
93    DistanceJointSetLength = 0xA4,
94    DistanceJointEnableSpring = 0xA5,
95    DistanceJointSetSpringForceRange = 0xA6,
96    DistanceJointSetSpringHertz = 0xA7,
97    DistanceJointSetSpringDampingRatio = 0xA8,
98    DistanceJointEnableLimit = 0xA9,
99    DistanceJointSetLengthRange = 0xAA,
100    DistanceJointEnableMotor = 0xAB,
101    DistanceJointSetMotorSpeed = 0xAC,
102    DistanceJointSetMaxMotorForce = 0xAD,
103    MotorJointSetLinearVelocity = 0xAE,
104    MotorJointSetAngularVelocity = 0xAF,
105    MotorJointSetMaxVelocityForce = 0xB0,
106    MotorJointSetMaxVelocityTorque = 0xB1,
107    MotorJointSetLinearHertz = 0xB2,
108    MotorJointSetLinearDampingRatio = 0xB3,
109    MotorJointSetAngularHertz = 0xB4,
110    MotorJointSetAngularDampingRatio = 0xB5,
111    MotorJointSetMaxSpringForce = 0xB6,
112    MotorJointSetMaxSpringTorque = 0xB7,
113    PrismaticJointEnableSpring = 0xB8,
114    PrismaticJointSetSpringHertz = 0xB9,
115    PrismaticJointSetSpringDampingRatio = 0xBA,
116    PrismaticJointSetTargetTranslation = 0xBB,
117    PrismaticJointEnableLimit = 0xBC,
118    PrismaticJointSetLimits = 0xBD,
119    PrismaticJointEnableMotor = 0xBE,
120    PrismaticJointSetMotorSpeed = 0xBF,
121    PrismaticJointSetMaxMotorForce = 0xC0,
122    RevoluteJointEnableSpring = 0xC1,
123    RevoluteJointSetSpringHertz = 0xC2,
124    RevoluteJointSetSpringDampingRatio = 0xC3,
125    RevoluteJointSetTargetAngle = 0xC4,
126    RevoluteJointEnableLimit = 0xC5,
127    RevoluteJointSetLimits = 0xC6,
128    RevoluteJointEnableMotor = 0xC7,
129    RevoluteJointSetMotorSpeed = 0xC8,
130    RevoluteJointSetMaxMotorTorque = 0xC9,
131    SphericalJointEnableConeLimit = 0xCA,
132    SphericalJointSetConeLimit = 0xCB,
133    SphericalJointEnableTwistLimit = 0xCC,
134    SphericalJointSetTwistLimits = 0xCD,
135    SphericalJointEnableSpring = 0xCE,
136    SphericalJointSetSpringHertz = 0xCF,
137    SphericalJointSetSpringDampingRatio = 0xD0,
138    SphericalJointSetTargetRotation = 0xD1,
139    SphericalJointEnableMotor = 0xD2,
140    SphericalJointSetMotorVelocity = 0xD3,
141    SphericalJointSetMaxMotorTorque = 0xD4,
142    WeldJointSetLinearHertz = 0xD5,
143    WeldJointSetLinearDampingRatio = 0xD6,
144    WeldJointSetAngularHertz = 0xD7,
145    WeldJointSetAngularDampingRatio = 0xD8,
146    WheelJointEnableSuspension = 0xD9,
147    WheelJointSetSuspensionHertz = 0xDA,
148    WheelJointSetSuspensionDampingRatio = 0xDB,
149    WheelJointEnableSuspensionLimit = 0xDC,
150    WheelJointSetSuspensionLimits = 0xDD,
151    WheelJointEnableSpinMotor = 0xDE,
152    WheelJointSetSpinMotorSpeed = 0xDF,
153    WheelJointSetMaxSpinTorque = 0xE0,
154    WheelJointEnableSteering = 0xE1,
155    WheelJointSetSteeringHertz = 0xE2,
156    WheelJointSetSteeringDampingRatio = 0xE3,
157    WheelJointSetMaxSteeringTorque = 0xE4,
158    WheelJointEnableSteeringLimit = 0xE5,
159    WheelJointSetSteeringLimits = 0xE6,
160    WheelJointSetTargetSteeringAngle = 0xE7,
161    QueryOverlapAABB = 0xE8,
162    QueryOverlapShape = 0xE9,
163    QueryCastRay = 0xEA,
164    QueryCastShape = 0xEB,
165    QueryCastRayClosest = 0xEC,
166    QueryCastMover = 0xED,
167    QueryCollideMover = 0xEE,
168    QueryTag = 0xEF,
169    StateHash = 0xF1,
170    RecordingBounds = 0xF2,
171}
172
173impl RecOp {
174    pub fn from_u8(v: u8) -> Option<Self> {
175        match v {
176            0x01 => Some(Self::DestroyWorld),
177            0x80 => Some(Self::Step),
178            0x02 => Some(Self::WorldEnableSleeping),
179            0x03 => Some(Self::WorldEnableContinuous),
180            0x04 => Some(Self::WorldSetRestitutionThreshold),
181            0x05 => Some(Self::WorldSetHitEventThreshold),
182            0x06 => Some(Self::WorldSetGravity),
183            0x07 => Some(Self::WorldExplode),
184            0x08 => Some(Self::WorldSetContactTuning),
185            0x09 => Some(Self::WorldSetContactRecycleDistance),
186            0x0A => Some(Self::WorldSetMaximumLinearSpeed),
187            0x0B => Some(Self::WorldEnableWarmStarting),
188            0x0C => Some(Self::WorldRebuildStaticTree),
189            0x0D => Some(Self::WorldEnableSpeculative),
190            0x10 => Some(Self::CreateBody),
191            0x11 => Some(Self::DestroyBody),
192            0x20 => Some(Self::BodySetTransform),
193            0x21 => Some(Self::BodySetLinearVelocity),
194            0x22 => Some(Self::BodySetType),
195            0x23 => Some(Self::BodySetName),
196            0x24 => Some(Self::BodySetAngularVelocity),
197            0x25 => Some(Self::BodySetTargetTransform),
198            0x26 => Some(Self::BodyApplyForce),
199            0x27 => Some(Self::BodyApplyForceToCenter),
200            0x28 => Some(Self::BodyApplyTorque),
201            0x29 => Some(Self::BodyApplyLinearImpulse),
202            0x2A => Some(Self::BodyApplyLinearImpulseToCenter),
203            0x2B => Some(Self::BodyApplyAngularImpulse),
204            0x2C => Some(Self::BodySetMassData),
205            0x2D => Some(Self::BodyApplyMassFromShapes),
206            0x2E => Some(Self::BodySetLinearDamping),
207            0x2F => Some(Self::BodySetAngularDamping),
208            0x30 => Some(Self::BodySetGravityScale),
209            0x31 => Some(Self::BodySetAwake),
210            0x32 => Some(Self::BodyEnableSleep),
211            0x33 => Some(Self::BodySetSleepThreshold),
212            0x34 => Some(Self::BodyDisable),
213            0x35 => Some(Self::BodyEnable),
214            0x36 => Some(Self::BodySetMotionLocks),
215            0x37 => Some(Self::BodySetBullet),
216            0x38 => Some(Self::BodyEnableContactRecycling),
217            0x39 => Some(Self::BodyEnableHitEvents),
218            0x40 => Some(Self::CreateSphereShape),
219            0x41 => Some(Self::CreateCapsuleShape),
220            0x42 => Some(Self::CreateHullShape),
221            0x43 => Some(Self::CreateMeshShape),
222            0x44 => Some(Self::CreateHeightFieldShape),
223            0x45 => Some(Self::CreateCompoundShape),
224            0x46 => Some(Self::DestroyShape),
225            0x50 => Some(Self::ShapeSetDensity),
226            0x51 => Some(Self::ShapeSetFriction),
227            0x52 => Some(Self::ShapeSetRestitution),
228            0x53 => Some(Self::ShapeSetSurfaceMaterial),
229            0x54 => Some(Self::ShapeSetFilter),
230            0x55 => Some(Self::ShapeEnableSensorEvents),
231            0x56 => Some(Self::ShapeEnableContactEvents),
232            0x57 => Some(Self::ShapeEnablePreSolveEvents),
233            0x58 => Some(Self::ShapeEnableHitEvents),
234            0x59 => Some(Self::ShapeSetSphere),
235            0x5A => Some(Self::ShapeSetCapsule),
236            0x5B => Some(Self::ShapeApplyWind),
237            0x5C => Some(Self::ShapeSetName),
238            0x90 => Some(Self::CreateParallelJoint),
239            0x91 => Some(Self::CreateDistanceJoint),
240            0x92 => Some(Self::CreateFilterJoint),
241            0x93 => Some(Self::CreateMotorJoint),
242            0x94 => Some(Self::CreatePrismaticJoint),
243            0x95 => Some(Self::CreateRevoluteJoint),
244            0x96 => Some(Self::CreateSphericalJoint),
245            0x97 => Some(Self::CreateWeldJoint),
246            0x98 => Some(Self::CreateWheelJoint),
247            0x99 => Some(Self::DestroyJoint),
248            0x9A => Some(Self::JointSetLocalFrameA),
249            0x9B => Some(Self::JointSetLocalFrameB),
250            0x9C => Some(Self::JointSetCollideConnected),
251            0x9D => Some(Self::JointWakeBodies),
252            0x9E => Some(Self::JointSetConstraintTuning),
253            0x9F => Some(Self::JointSetForceThreshold),
254            0xA0 => Some(Self::JointSetTorqueThreshold),
255            0xA1 => Some(Self::ParallelJointSetSpringHertz),
256            0xA2 => Some(Self::ParallelJointSetSpringDampingRatio),
257            0xA3 => Some(Self::ParallelJointSetMaxTorque),
258            0xA4 => Some(Self::DistanceJointSetLength),
259            0xA5 => Some(Self::DistanceJointEnableSpring),
260            0xA6 => Some(Self::DistanceJointSetSpringForceRange),
261            0xA7 => Some(Self::DistanceJointSetSpringHertz),
262            0xA8 => Some(Self::DistanceJointSetSpringDampingRatio),
263            0xA9 => Some(Self::DistanceJointEnableLimit),
264            0xAA => Some(Self::DistanceJointSetLengthRange),
265            0xAB => Some(Self::DistanceJointEnableMotor),
266            0xAC => Some(Self::DistanceJointSetMotorSpeed),
267            0xAD => Some(Self::DistanceJointSetMaxMotorForce),
268            0xAE => Some(Self::MotorJointSetLinearVelocity),
269            0xAF => Some(Self::MotorJointSetAngularVelocity),
270            0xB0 => Some(Self::MotorJointSetMaxVelocityForce),
271            0xB1 => Some(Self::MotorJointSetMaxVelocityTorque),
272            0xB2 => Some(Self::MotorJointSetLinearHertz),
273            0xB3 => Some(Self::MotorJointSetLinearDampingRatio),
274            0xB4 => Some(Self::MotorJointSetAngularHertz),
275            0xB5 => Some(Self::MotorJointSetAngularDampingRatio),
276            0xB6 => Some(Self::MotorJointSetMaxSpringForce),
277            0xB7 => Some(Self::MotorJointSetMaxSpringTorque),
278            0xB8 => Some(Self::PrismaticJointEnableSpring),
279            0xB9 => Some(Self::PrismaticJointSetSpringHertz),
280            0xBA => Some(Self::PrismaticJointSetSpringDampingRatio),
281            0xBB => Some(Self::PrismaticJointSetTargetTranslation),
282            0xBC => Some(Self::PrismaticJointEnableLimit),
283            0xBD => Some(Self::PrismaticJointSetLimits),
284            0xBE => Some(Self::PrismaticJointEnableMotor),
285            0xBF => Some(Self::PrismaticJointSetMotorSpeed),
286            0xC0 => Some(Self::PrismaticJointSetMaxMotorForce),
287            0xC1 => Some(Self::RevoluteJointEnableSpring),
288            0xC2 => Some(Self::RevoluteJointSetSpringHertz),
289            0xC3 => Some(Self::RevoluteJointSetSpringDampingRatio),
290            0xC4 => Some(Self::RevoluteJointSetTargetAngle),
291            0xC5 => Some(Self::RevoluteJointEnableLimit),
292            0xC6 => Some(Self::RevoluteJointSetLimits),
293            0xC7 => Some(Self::RevoluteJointEnableMotor),
294            0xC8 => Some(Self::RevoluteJointSetMotorSpeed),
295            0xC9 => Some(Self::RevoluteJointSetMaxMotorTorque),
296            0xCA => Some(Self::SphericalJointEnableConeLimit),
297            0xCB => Some(Self::SphericalJointSetConeLimit),
298            0xCC => Some(Self::SphericalJointEnableTwistLimit),
299            0xCD => Some(Self::SphericalJointSetTwistLimits),
300            0xCE => Some(Self::SphericalJointEnableSpring),
301            0xCF => Some(Self::SphericalJointSetSpringHertz),
302            0xD0 => Some(Self::SphericalJointSetSpringDampingRatio),
303            0xD1 => Some(Self::SphericalJointSetTargetRotation),
304            0xD2 => Some(Self::SphericalJointEnableMotor),
305            0xD3 => Some(Self::SphericalJointSetMotorVelocity),
306            0xD4 => Some(Self::SphericalJointSetMaxMotorTorque),
307            0xD5 => Some(Self::WeldJointSetLinearHertz),
308            0xD6 => Some(Self::WeldJointSetLinearDampingRatio),
309            0xD7 => Some(Self::WeldJointSetAngularHertz),
310            0xD8 => Some(Self::WeldJointSetAngularDampingRatio),
311            0xD9 => Some(Self::WheelJointEnableSuspension),
312            0xDA => Some(Self::WheelJointSetSuspensionHertz),
313            0xDB => Some(Self::WheelJointSetSuspensionDampingRatio),
314            0xDC => Some(Self::WheelJointEnableSuspensionLimit),
315            0xDD => Some(Self::WheelJointSetSuspensionLimits),
316            0xDE => Some(Self::WheelJointEnableSpinMotor),
317            0xDF => Some(Self::WheelJointSetSpinMotorSpeed),
318            0xE0 => Some(Self::WheelJointSetMaxSpinTorque),
319            0xE1 => Some(Self::WheelJointEnableSteering),
320            0xE2 => Some(Self::WheelJointSetSteeringHertz),
321            0xE3 => Some(Self::WheelJointSetSteeringDampingRatio),
322            0xE4 => Some(Self::WheelJointSetMaxSteeringTorque),
323            0xE5 => Some(Self::WheelJointEnableSteeringLimit),
324            0xE6 => Some(Self::WheelJointSetSteeringLimits),
325            0xE7 => Some(Self::WheelJointSetTargetSteeringAngle),
326            0xE8 => Some(Self::QueryOverlapAABB),
327            0xE9 => Some(Self::QueryOverlapShape),
328            0xEA => Some(Self::QueryCastRay),
329            0xEB => Some(Self::QueryCastShape),
330            0xEC => Some(Self::QueryCastRayClosest),
331            0xED => Some(Self::QueryCastMover),
332            0xEE => Some(Self::QueryCollideMover),
333            0xEF => Some(Self::QueryTag),
334            0xF1 => Some(Self::StateHash),
335            0xF2 => Some(Self::RecordingBounds),
336            _ => None,
337        }
338    }
339}