@@ -45,6 +45,61 @@ impl PhysicsWorld {
4545 . build ( ) ;
4646 collider_set. insert ( ground_collider) ;
4747
48+ // Create boundary walls around the perimeter to contain bouncing balls
49+ // Ground is 10000x10000 units, so boundaries are at ±5000
50+ // Walls are 2000 units tall (20 meters) to contain high bounces
51+ let wall_height = 2000.0 ;
52+ let wall_thickness = 100.0 ; // 1 meter thick walls
53+ let ground_half_size = 5000.0 ;
54+
55+ // East wall (positive X) - inner edge at x = ground_half_size
56+ let east_wall = ColliderBuilder :: cuboid ( wall_thickness, wall_height, ground_half_size)
57+ . translation ( vector ! [
58+ ground_half_size + wall_thickness / 2.0 ,
59+ wall_height,
60+ 0.0
61+ ] )
62+ . friction ( 0.0 )
63+ . restitution ( 1.0 ) // Perfect elasticity
64+ . build ( ) ;
65+ collider_set. insert ( east_wall) ;
66+
67+ // West wall (negative X) - inner edge at x = -ground_half_size
68+ let west_wall = ColliderBuilder :: cuboid ( wall_thickness, wall_height, ground_half_size)
69+ . translation ( vector ! [
70+ -ground_half_size - wall_thickness / 2.0 ,
71+ wall_height,
72+ 0.0
73+ ] )
74+ . friction ( 0.0 )
75+ . restitution ( 1.0 ) // Perfect elasticity
76+ . build ( ) ;
77+ collider_set. insert ( west_wall) ;
78+
79+ // North wall (positive Z) - inner edge at z = ground_half_size
80+ let north_wall = ColliderBuilder :: cuboid ( ground_half_size, wall_height, wall_thickness)
81+ . translation ( vector ! [
82+ 0.0 ,
83+ wall_height,
84+ ground_half_size + wall_thickness / 2.0
85+ ] )
86+ . friction ( 0.0 )
87+ . restitution ( 1.0 ) // Perfect elasticity
88+ . build ( ) ;
89+ collider_set. insert ( north_wall) ;
90+
91+ // South wall (negative Z) - inner edge at z = -ground_half_size
92+ let south_wall = ColliderBuilder :: cuboid ( ground_half_size, wall_height, wall_thickness)
93+ . translation ( vector ! [
94+ 0.0 ,
95+ wall_height,
96+ -ground_half_size - wall_thickness / 2.0
97+ ] )
98+ . friction ( 0.0 )
99+ . restitution ( 1.0 ) // Perfect elasticity
100+ . build ( ) ;
101+ collider_set. insert ( south_wall) ;
102+
48103 Self {
49104 rigid_body_set,
50105 collider_set,
0 commit comments