|
1 | 1 | use std::collections::VecDeque; |
2 | 2 |
|
| 3 | +use godot::builtin::Callable; |
3 | 4 | use godot::engine::PhysicsServer3D; |
4 | 5 | use godot::prelude::Rid; |
5 | 6 |
|
@@ -90,72 +91,41 @@ impl Default for PhysicsAreaPool { |
90 | 91 | #[allow(dead_code)] |
91 | 92 | impl PhysicsAreaPool { |
92 | 93 | pub fn acquire_area(&mut self) -> Rid { |
93 | | - let (rid, reused) = self |
| 94 | + let (rid, _reused) = self |
94 | 95 | .areas |
95 | 96 | .acquire(|| PhysicsServer3D::singleton().area_create()); |
96 | | - let (created, in_use, pooled) = self.areas.stats(); |
97 | | - tracing::debug!( |
98 | | - "[PhysicsAreaPool] ACQUIRE area: rid={:?}, reused={}, stats=(created={}, in_use={}, pooled={})", |
99 | | - rid, reused, created, in_use, pooled |
100 | | - ); |
101 | 97 | rid |
102 | 98 | } |
103 | 99 |
|
104 | 100 | pub fn release_area(&mut self, rid: Rid) { |
105 | 101 | let mut server = PhysicsServer3D::singleton(); |
| 102 | + // Clear monitor callback to prevent stale events |
| 103 | + server.area_set_monitor_callback(rid, Callable::invalid()); |
106 | 104 | server.area_clear_shapes(rid); |
107 | 105 | server.area_set_space(rid, Rid::Invalid); |
108 | 106 | self.areas.release(rid); |
109 | | - let (created, in_use, pooled) = self.areas.stats(); |
110 | | - tracing::debug!( |
111 | | - "[PhysicsAreaPool] RELEASE area: rid={:?}, stats=(created={}, in_use={}, pooled={})", |
112 | | - rid, |
113 | | - created, |
114 | | - in_use, |
115 | | - pooled |
116 | | - ); |
117 | 107 | } |
118 | 108 |
|
119 | 109 | pub fn acquire_box_shape(&mut self) -> Rid { |
120 | | - let (rid, reused) = self |
| 110 | + let (rid, _reused) = self |
121 | 111 | .shapes_box |
122 | 112 | .acquire(|| PhysicsServer3D::singleton().box_shape_create()); |
123 | | - let (created, in_use, pooled) = self.shapes_box.stats(); |
124 | | - tracing::debug!( |
125 | | - "[PhysicsAreaPool] ACQUIRE box_shape: rid={:?}, reused={}, stats=(created={}, in_use={}, pooled={})", |
126 | | - rid, reused, created, in_use, pooled |
127 | | - ); |
128 | 113 | rid |
129 | 114 | } |
130 | 115 |
|
131 | 116 | pub fn acquire_sphere_shape(&mut self) -> Rid { |
132 | | - let (rid, reused) = self |
| 117 | + let (rid, _reused) = self |
133 | 118 | .shapes_sphere |
134 | 119 | .acquire(|| PhysicsServer3D::singleton().sphere_shape_create()); |
135 | | - let (created, in_use, pooled) = self.shapes_sphere.stats(); |
136 | | - tracing::debug!( |
137 | | - "[PhysicsAreaPool] ACQUIRE sphere_shape: rid={:?}, reused={}, stats=(created={}, in_use={}, pooled={})", |
138 | | - rid, reused, created, in_use, pooled |
139 | | - ); |
140 | 120 | rid |
141 | 121 | } |
142 | 122 |
|
143 | 123 | pub fn release_box_shape(&mut self, rid: Rid) { |
144 | 124 | self.shapes_box.release(rid); |
145 | | - let (created, in_use, pooled) = self.shapes_box.stats(); |
146 | | - tracing::debug!( |
147 | | - "[PhysicsAreaPool] RELEASE box_shape: rid={:?}, stats=(created={}, in_use={}, pooled={})", |
148 | | - rid, created, in_use, pooled |
149 | | - ); |
150 | 125 | } |
151 | 126 |
|
152 | 127 | pub fn release_sphere_shape(&mut self, rid: Rid) { |
153 | 128 | self.shapes_sphere.release(rid); |
154 | | - let (created, in_use, pooled) = self.shapes_sphere.stats(); |
155 | | - tracing::debug!( |
156 | | - "[PhysicsAreaPool] RELEASE sphere_shape: rid={:?}, stats=(created={}, in_use={}, pooled={})", |
157 | | - rid, created, in_use, pooled |
158 | | - ); |
159 | 129 | } |
160 | 130 |
|
161 | 131 | pub fn cleanup(&mut self) { |
|
0 commit comments