Skip to content

Commit 1c810d1

Browse files
committed
[update] world id generation to use u64.
1 parent a2f43d4 commit 1c810d1

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

crates/lambda-rs/src/physics/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::{
77
error::Error,
88
fmt,
99
sync::atomic::{
10-
AtomicU32,
10+
AtomicU64,
1111
Ordering,
1212
},
1313
};
@@ -28,11 +28,11 @@ const DEFAULT_GRAVITY_Y: f32 = -9.81;
2828
const DEFAULT_TIMESTEP_SECONDS: f32 = 1.0 / 60.0;
2929
const DEFAULT_SUBSTEPS: u32 = 1;
3030

31-
static NEXT_WORLD_ID: AtomicU32 = AtomicU32::new(1);
31+
static NEXT_WORLD_ID: AtomicU64 = AtomicU64::new(1);
3232

3333
/// A 2D physics simulation world.
3434
pub struct PhysicsWorld2D {
35-
world_id: u32,
35+
world_id: u64,
3636
gravity: [f32; 2],
3737
timestep_seconds: f32,
3838
substeps: u32,
@@ -238,7 +238,7 @@ fn validate_gravity(gravity: [f32; 2]) -> Result<(), PhysicsWorld2DError> {
238238
}
239239

240240
/// Allocates a non-zero unique world identifier.
241-
fn allocate_world_id() -> u32 {
241+
fn allocate_world_id() -> u64 {
242242
loop {
243243
let id = NEXT_WORLD_ID.fetch_add(1, Ordering::Relaxed);
244244
if id != 0 {

crates/lambda-rs/src/physics/rigid_body_2d.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub enum RigidBodyType {
3838
/// the provided world and that the referenced body exists.
3939
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4040
pub struct RigidBody2D {
41-
world_id: u32,
41+
world_id: u64,
4242
slot_index: u32,
4343
slot_generation: u32,
4444
}

docs/specs/physics/rigid-bodies-2d.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ pub enum RigidBodyType {
168168
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
169169
pub struct RigidBody2D {
170170
// World identifier used for cross-world validation (implementation detail).
171-
world_id: u32,
171+
world_id: u64,
172172
// Body slot index (implementation detail).
173173
slot_index: u32,
174174
// Slot generation used for stale-handle detection (implementation detail).

0 commit comments

Comments
 (0)