box3d-rust 0.2.1

Pure Rust port of the Box3D 3D physics engine
Documentation
//! Recording op table generated from recording_ops.inl.
//! Opcode constants; the framed write helpers live in write_ops/.
//!
//! SPDX-FileCopyrightText: 2026 Erin Catto
//! SPDX-License-Identifier: MIT

/// Opcode constants from recording_ops.inl.
#[repr(u8)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum RecOp {
    DestroyWorld = 0x01,
    Step = 0x80,
    WorldEnableSleeping = 0x02,
    WorldEnableContinuous = 0x03,
    WorldSetRestitutionThreshold = 0x04,
    WorldSetHitEventThreshold = 0x05,
    WorldSetGravity = 0x06,
    WorldExplode = 0x07,
    WorldSetContactTuning = 0x08,
    WorldSetContactRecycleDistance = 0x09,
    WorldSetMaximumLinearSpeed = 0x0A,
    WorldEnableWarmStarting = 0x0B,
    WorldRebuildStaticTree = 0x0C,
    WorldEnableSpeculative = 0x0D,
    CreateBody = 0x10,
    DestroyBody = 0x11,
    BodySetTransform = 0x20,
    BodySetLinearVelocity = 0x21,
    BodySetType = 0x22,
    BodySetName = 0x23,
    BodySetAngularVelocity = 0x24,
    BodySetTargetTransform = 0x25,
    BodyApplyForce = 0x26,
    BodyApplyForceToCenter = 0x27,
    BodyApplyTorque = 0x28,
    BodyApplyLinearImpulse = 0x29,
    BodyApplyLinearImpulseToCenter = 0x2A,
    BodyApplyAngularImpulse = 0x2B,
    BodySetMassData = 0x2C,
    BodyApplyMassFromShapes = 0x2D,
    BodySetLinearDamping = 0x2E,
    BodySetAngularDamping = 0x2F,
    BodySetGravityScale = 0x30,
    BodySetAwake = 0x31,
    BodyEnableSleep = 0x32,
    BodySetSleepThreshold = 0x33,
    BodyDisable = 0x34,
    BodyEnable = 0x35,
    BodySetMotionLocks = 0x36,
    BodySetBullet = 0x37,
    BodyEnableContactRecycling = 0x38,
    BodyEnableHitEvents = 0x39,
    CreateSphereShape = 0x40,
    CreateCapsuleShape = 0x41,
    CreateHullShape = 0x42,
    CreateMeshShape = 0x43,
    CreateHeightFieldShape = 0x44,
    CreateCompoundShape = 0x45,
    DestroyShape = 0x46,
    ShapeSetDensity = 0x50,
    ShapeSetFriction = 0x51,
    ShapeSetRestitution = 0x52,
    ShapeSetSurfaceMaterial = 0x53,
    ShapeSetFilter = 0x54,
    ShapeEnableSensorEvents = 0x55,
    ShapeEnableContactEvents = 0x56,
    ShapeEnablePreSolveEvents = 0x57,
    ShapeEnableHitEvents = 0x58,
    ShapeSetSphere = 0x59,
    ShapeSetCapsule = 0x5A,
    ShapeApplyWind = 0x5B,
    ShapeSetName = 0x5C,
    CreateParallelJoint = 0x90,
    CreateDistanceJoint = 0x91,
    CreateFilterJoint = 0x92,
    CreateMotorJoint = 0x93,
    CreatePrismaticJoint = 0x94,
    CreateRevoluteJoint = 0x95,
    CreateSphericalJoint = 0x96,
    CreateWeldJoint = 0x97,
    CreateWheelJoint = 0x98,
    DestroyJoint = 0x99,
    JointSetLocalFrameA = 0x9A,
    JointSetLocalFrameB = 0x9B,
    JointSetCollideConnected = 0x9C,
    JointWakeBodies = 0x9D,
    JointSetConstraintTuning = 0x9E,
    JointSetForceThreshold = 0x9F,
    JointSetTorqueThreshold = 0xA0,
    ParallelJointSetSpringHertz = 0xA1,
    ParallelJointSetSpringDampingRatio = 0xA2,
    ParallelJointSetMaxTorque = 0xA3,
    DistanceJointSetLength = 0xA4,
    DistanceJointEnableSpring = 0xA5,
    DistanceJointSetSpringForceRange = 0xA6,
    DistanceJointSetSpringHertz = 0xA7,
    DistanceJointSetSpringDampingRatio = 0xA8,
    DistanceJointEnableLimit = 0xA9,
    DistanceJointSetLengthRange = 0xAA,
    DistanceJointEnableMotor = 0xAB,
    DistanceJointSetMotorSpeed = 0xAC,
    DistanceJointSetMaxMotorForce = 0xAD,
    MotorJointSetLinearVelocity = 0xAE,
    MotorJointSetAngularVelocity = 0xAF,
    MotorJointSetMaxVelocityForce = 0xB0,
    MotorJointSetMaxVelocityTorque = 0xB1,
    MotorJointSetLinearHertz = 0xB2,
    MotorJointSetLinearDampingRatio = 0xB3,
    MotorJointSetAngularHertz = 0xB4,
    MotorJointSetAngularDampingRatio = 0xB5,
    MotorJointSetMaxSpringForce = 0xB6,
    MotorJointSetMaxSpringTorque = 0xB7,
    PrismaticJointEnableSpring = 0xB8,
    PrismaticJointSetSpringHertz = 0xB9,
    PrismaticJointSetSpringDampingRatio = 0xBA,
    PrismaticJointSetTargetTranslation = 0xBB,
    PrismaticJointEnableLimit = 0xBC,
    PrismaticJointSetLimits = 0xBD,
    PrismaticJointEnableMotor = 0xBE,
    PrismaticJointSetMotorSpeed = 0xBF,
    PrismaticJointSetMaxMotorForce = 0xC0,
    RevoluteJointEnableSpring = 0xC1,
    RevoluteJointSetSpringHertz = 0xC2,
    RevoluteJointSetSpringDampingRatio = 0xC3,
    RevoluteJointSetTargetAngle = 0xC4,
    RevoluteJointEnableLimit = 0xC5,
    RevoluteJointSetLimits = 0xC6,
    RevoluteJointEnableMotor = 0xC7,
    RevoluteJointSetMotorSpeed = 0xC8,
    RevoluteJointSetMaxMotorTorque = 0xC9,
    SphericalJointEnableConeLimit = 0xCA,
    SphericalJointSetConeLimit = 0xCB,
    SphericalJointEnableTwistLimit = 0xCC,
    SphericalJointSetTwistLimits = 0xCD,
    SphericalJointEnableSpring = 0xCE,
    SphericalJointSetSpringHertz = 0xCF,
    SphericalJointSetSpringDampingRatio = 0xD0,
    SphericalJointSetTargetRotation = 0xD1,
    SphericalJointEnableMotor = 0xD2,
    SphericalJointSetMotorVelocity = 0xD3,
    SphericalJointSetMaxMotorTorque = 0xD4,
    WeldJointSetLinearHertz = 0xD5,
    WeldJointSetLinearDampingRatio = 0xD6,
    WeldJointSetAngularHertz = 0xD7,
    WeldJointSetAngularDampingRatio = 0xD8,
    WheelJointEnableSuspension = 0xD9,
    WheelJointSetSuspensionHertz = 0xDA,
    WheelJointSetSuspensionDampingRatio = 0xDB,
    WheelJointEnableSuspensionLimit = 0xDC,
    WheelJointSetSuspensionLimits = 0xDD,
    WheelJointEnableSpinMotor = 0xDE,
    WheelJointSetSpinMotorSpeed = 0xDF,
    WheelJointSetMaxSpinTorque = 0xE0,
    WheelJointEnableSteering = 0xE1,
    WheelJointSetSteeringHertz = 0xE2,
    WheelJointSetSteeringDampingRatio = 0xE3,
    WheelJointSetMaxSteeringTorque = 0xE4,
    WheelJointEnableSteeringLimit = 0xE5,
    WheelJointSetSteeringLimits = 0xE6,
    WheelJointSetTargetSteeringAngle = 0xE7,
    QueryOverlapAABB = 0xE8,
    QueryOverlapShape = 0xE9,
    QueryCastRay = 0xEA,
    QueryCastShape = 0xEB,
    QueryCastRayClosest = 0xEC,
    QueryCastMover = 0xED,
    QueryCollideMover = 0xEE,
    QueryTag = 0xEF,
    StateHash = 0xF1,
    RecordingBounds = 0xF2,
}

impl RecOp {
    pub fn from_u8(v: u8) -> Option<Self> {
        match v {
            0x01 => Some(Self::DestroyWorld),
            0x80 => Some(Self::Step),
            0x02 => Some(Self::WorldEnableSleeping),
            0x03 => Some(Self::WorldEnableContinuous),
            0x04 => Some(Self::WorldSetRestitutionThreshold),
            0x05 => Some(Self::WorldSetHitEventThreshold),
            0x06 => Some(Self::WorldSetGravity),
            0x07 => Some(Self::WorldExplode),
            0x08 => Some(Self::WorldSetContactTuning),
            0x09 => Some(Self::WorldSetContactRecycleDistance),
            0x0A => Some(Self::WorldSetMaximumLinearSpeed),
            0x0B => Some(Self::WorldEnableWarmStarting),
            0x0C => Some(Self::WorldRebuildStaticTree),
            0x0D => Some(Self::WorldEnableSpeculative),
            0x10 => Some(Self::CreateBody),
            0x11 => Some(Self::DestroyBody),
            0x20 => Some(Self::BodySetTransform),
            0x21 => Some(Self::BodySetLinearVelocity),
            0x22 => Some(Self::BodySetType),
            0x23 => Some(Self::BodySetName),
            0x24 => Some(Self::BodySetAngularVelocity),
            0x25 => Some(Self::BodySetTargetTransform),
            0x26 => Some(Self::BodyApplyForce),
            0x27 => Some(Self::BodyApplyForceToCenter),
            0x28 => Some(Self::BodyApplyTorque),
            0x29 => Some(Self::BodyApplyLinearImpulse),
            0x2A => Some(Self::BodyApplyLinearImpulseToCenter),
            0x2B => Some(Self::BodyApplyAngularImpulse),
            0x2C => Some(Self::BodySetMassData),
            0x2D => Some(Self::BodyApplyMassFromShapes),
            0x2E => Some(Self::BodySetLinearDamping),
            0x2F => Some(Self::BodySetAngularDamping),
            0x30 => Some(Self::BodySetGravityScale),
            0x31 => Some(Self::BodySetAwake),
            0x32 => Some(Self::BodyEnableSleep),
            0x33 => Some(Self::BodySetSleepThreshold),
            0x34 => Some(Self::BodyDisable),
            0x35 => Some(Self::BodyEnable),
            0x36 => Some(Self::BodySetMotionLocks),
            0x37 => Some(Self::BodySetBullet),
            0x38 => Some(Self::BodyEnableContactRecycling),
            0x39 => Some(Self::BodyEnableHitEvents),
            0x40 => Some(Self::CreateSphereShape),
            0x41 => Some(Self::CreateCapsuleShape),
            0x42 => Some(Self::CreateHullShape),
            0x43 => Some(Self::CreateMeshShape),
            0x44 => Some(Self::CreateHeightFieldShape),
            0x45 => Some(Self::CreateCompoundShape),
            0x46 => Some(Self::DestroyShape),
            0x50 => Some(Self::ShapeSetDensity),
            0x51 => Some(Self::ShapeSetFriction),
            0x52 => Some(Self::ShapeSetRestitution),
            0x53 => Some(Self::ShapeSetSurfaceMaterial),
            0x54 => Some(Self::ShapeSetFilter),
            0x55 => Some(Self::ShapeEnableSensorEvents),
            0x56 => Some(Self::ShapeEnableContactEvents),
            0x57 => Some(Self::ShapeEnablePreSolveEvents),
            0x58 => Some(Self::ShapeEnableHitEvents),
            0x59 => Some(Self::ShapeSetSphere),
            0x5A => Some(Self::ShapeSetCapsule),
            0x5B => Some(Self::ShapeApplyWind),
            0x5C => Some(Self::ShapeSetName),
            0x90 => Some(Self::CreateParallelJoint),
            0x91 => Some(Self::CreateDistanceJoint),
            0x92 => Some(Self::CreateFilterJoint),
            0x93 => Some(Self::CreateMotorJoint),
            0x94 => Some(Self::CreatePrismaticJoint),
            0x95 => Some(Self::CreateRevoluteJoint),
            0x96 => Some(Self::CreateSphericalJoint),
            0x97 => Some(Self::CreateWeldJoint),
            0x98 => Some(Self::CreateWheelJoint),
            0x99 => Some(Self::DestroyJoint),
            0x9A => Some(Self::JointSetLocalFrameA),
            0x9B => Some(Self::JointSetLocalFrameB),
            0x9C => Some(Self::JointSetCollideConnected),
            0x9D => Some(Self::JointWakeBodies),
            0x9E => Some(Self::JointSetConstraintTuning),
            0x9F => Some(Self::JointSetForceThreshold),
            0xA0 => Some(Self::JointSetTorqueThreshold),
            0xA1 => Some(Self::ParallelJointSetSpringHertz),
            0xA2 => Some(Self::ParallelJointSetSpringDampingRatio),
            0xA3 => Some(Self::ParallelJointSetMaxTorque),
            0xA4 => Some(Self::DistanceJointSetLength),
            0xA5 => Some(Self::DistanceJointEnableSpring),
            0xA6 => Some(Self::DistanceJointSetSpringForceRange),
            0xA7 => Some(Self::DistanceJointSetSpringHertz),
            0xA8 => Some(Self::DistanceJointSetSpringDampingRatio),
            0xA9 => Some(Self::DistanceJointEnableLimit),
            0xAA => Some(Self::DistanceJointSetLengthRange),
            0xAB => Some(Self::DistanceJointEnableMotor),
            0xAC => Some(Self::DistanceJointSetMotorSpeed),
            0xAD => Some(Self::DistanceJointSetMaxMotorForce),
            0xAE => Some(Self::MotorJointSetLinearVelocity),
            0xAF => Some(Self::MotorJointSetAngularVelocity),
            0xB0 => Some(Self::MotorJointSetMaxVelocityForce),
            0xB1 => Some(Self::MotorJointSetMaxVelocityTorque),
            0xB2 => Some(Self::MotorJointSetLinearHertz),
            0xB3 => Some(Self::MotorJointSetLinearDampingRatio),
            0xB4 => Some(Self::MotorJointSetAngularHertz),
            0xB5 => Some(Self::MotorJointSetAngularDampingRatio),
            0xB6 => Some(Self::MotorJointSetMaxSpringForce),
            0xB7 => Some(Self::MotorJointSetMaxSpringTorque),
            0xB8 => Some(Self::PrismaticJointEnableSpring),
            0xB9 => Some(Self::PrismaticJointSetSpringHertz),
            0xBA => Some(Self::PrismaticJointSetSpringDampingRatio),
            0xBB => Some(Self::PrismaticJointSetTargetTranslation),
            0xBC => Some(Self::PrismaticJointEnableLimit),
            0xBD => Some(Self::PrismaticJointSetLimits),
            0xBE => Some(Self::PrismaticJointEnableMotor),
            0xBF => Some(Self::PrismaticJointSetMotorSpeed),
            0xC0 => Some(Self::PrismaticJointSetMaxMotorForce),
            0xC1 => Some(Self::RevoluteJointEnableSpring),
            0xC2 => Some(Self::RevoluteJointSetSpringHertz),
            0xC3 => Some(Self::RevoluteJointSetSpringDampingRatio),
            0xC4 => Some(Self::RevoluteJointSetTargetAngle),
            0xC5 => Some(Self::RevoluteJointEnableLimit),
            0xC6 => Some(Self::RevoluteJointSetLimits),
            0xC7 => Some(Self::RevoluteJointEnableMotor),
            0xC8 => Some(Self::RevoluteJointSetMotorSpeed),
            0xC9 => Some(Self::RevoluteJointSetMaxMotorTorque),
            0xCA => Some(Self::SphericalJointEnableConeLimit),
            0xCB => Some(Self::SphericalJointSetConeLimit),
            0xCC => Some(Self::SphericalJointEnableTwistLimit),
            0xCD => Some(Self::SphericalJointSetTwistLimits),
            0xCE => Some(Self::SphericalJointEnableSpring),
            0xCF => Some(Self::SphericalJointSetSpringHertz),
            0xD0 => Some(Self::SphericalJointSetSpringDampingRatio),
            0xD1 => Some(Self::SphericalJointSetTargetRotation),
            0xD2 => Some(Self::SphericalJointEnableMotor),
            0xD3 => Some(Self::SphericalJointSetMotorVelocity),
            0xD4 => Some(Self::SphericalJointSetMaxMotorTorque),
            0xD5 => Some(Self::WeldJointSetLinearHertz),
            0xD6 => Some(Self::WeldJointSetLinearDampingRatio),
            0xD7 => Some(Self::WeldJointSetAngularHertz),
            0xD8 => Some(Self::WeldJointSetAngularDampingRatio),
            0xD9 => Some(Self::WheelJointEnableSuspension),
            0xDA => Some(Self::WheelJointSetSuspensionHertz),
            0xDB => Some(Self::WheelJointSetSuspensionDampingRatio),
            0xDC => Some(Self::WheelJointEnableSuspensionLimit),
            0xDD => Some(Self::WheelJointSetSuspensionLimits),
            0xDE => Some(Self::WheelJointEnableSpinMotor),
            0xDF => Some(Self::WheelJointSetSpinMotorSpeed),
            0xE0 => Some(Self::WheelJointSetMaxSpinTorque),
            0xE1 => Some(Self::WheelJointEnableSteering),
            0xE2 => Some(Self::WheelJointSetSteeringHertz),
            0xE3 => Some(Self::WheelJointSetSteeringDampingRatio),
            0xE4 => Some(Self::WheelJointSetMaxSteeringTorque),
            0xE5 => Some(Self::WheelJointEnableSteeringLimit),
            0xE6 => Some(Self::WheelJointSetSteeringLimits),
            0xE7 => Some(Self::WheelJointSetTargetSteeringAngle),
            0xE8 => Some(Self::QueryOverlapAABB),
            0xE9 => Some(Self::QueryOverlapShape),
            0xEA => Some(Self::QueryCastRay),
            0xEB => Some(Self::QueryCastShape),
            0xEC => Some(Self::QueryCastRayClosest),
            0xED => Some(Self::QueryCastMover),
            0xEE => Some(Self::QueryCollideMover),
            0xEF => Some(Self::QueryTag),
            0xF1 => Some(Self::StateHash),
            0xF2 => Some(Self::RecordingBounds),
            _ => None,
        }
    }
}