Skip to main content

box2d_rust/types/
mod.rs

1// Port of the creation/definition types from box2d-cpp-reference/include/box2d/types.h
2// and the b2Default* constructors from src/types.c.
3//
4// Split to satisfy the 800-line file limit:
5// - world.rs — WorldDef, Capacity, RayResult, mixing-callback aliases
6// - body.rs  — BodyType, MotionLocks, BodyDef
7// - shape.rs — Filter, QueryFilter, SurfaceMaterial, ShapeDef, ChainDef
8//
9// Porting decisions applied throughout:
10// - C `void* userData` becomes `u64` (Box2D only stores and returns it, never
11//   dereferences it; this matches the dynamic tree's user_data and stays safe).
12// - Optional mixing callbacks become `Option<fn(...)>`.
13// - The multithreading task-system fields (b2EnqueueTaskCallback,
14//   b2FinishTaskCallback, userTaskContext) are deferred to the scheduler phase;
15//   the port runs single-threaded, which preserves determinism. `worker_count`
16//   is kept.
17// - `internalValue` (the B2_SECRET_COOKIE validity cookie) is kept as
18//   `internal_value` for fidelity with the world-creation validation.
19//
20// The event, profile, counters, joint-def, hex-color, and debug-draw types from
21// types.h are ported in their respective later phases, not here.
22//
23// SPDX-FileCopyrightText: 2023 Erin Catto
24// SPDX-License-Identifier: MIT
25
26mod body;
27mod joint;
28mod shape;
29mod world;
30
31pub use body::{default_body_def, BodyDef, BodyType, MotionLocks, BODY_TYPE_COUNT};
32pub use joint::{
33    default_distance_joint_def, default_filter_joint_def, default_motor_joint_def,
34    default_prismatic_joint_def, default_revolute_joint_def, default_weld_joint_def,
35    default_wheel_joint_def, DistanceJointDef, FilterJointDef, JointDef, MotorJointDef,
36    PrismaticJointDef, RevoluteJointDef, WeldJointDef, WheelJointDef,
37};
38pub use shape::{
39    default_chain_def, default_filter, default_query_filter, default_shape_def,
40    default_surface_material, ChainDef, Filter, QueryFilter, ShapeDef, SurfaceMaterial,
41};
42pub use world::{
43    default_explosion_def, default_world_def, Capacity, Counters, ExplosionDef, FrictionCallback,
44    RayResult, RestitutionCallback, WorldDef,
45};
46
47// types.h: B2_DEFAULT_CATEGORY_BITS / B2_DEFAULT_MASK_BITS. These are the same
48// constants used by the dynamic tree; re-exported here from their canonical home.
49pub use crate::dynamic_tree::{DEFAULT_CATEGORY_BITS, DEFAULT_MASK_BITS};