@@ -26,7 +26,7 @@ fn main() {
26
26
// Add the plugin
27
27
. add_plugin ( GpuPickingPlugin )
28
28
. add_systems ( Startup , setup)
29
- . add_systems ( Update , ( mouse_picking, save_buffer_to_file , move_cube) )
29
+ . add_systems ( Update , ( mouse_picking, move_cube) )
30
30
. run ( ) ;
31
31
}
32
32
@@ -88,7 +88,7 @@ fn setup(
88
88
GpuPickingMesh ,
89
89
) ) ;
90
90
91
- // opaque cube
91
+ // This cube will move from left to right. It shows that picking works correctly when things are moving.
92
92
commands. spawn ( (
93
93
PbrBundle {
94
94
mesh : meshes. add ( Mesh :: from ( shape:: Cube { size : 1.0 } ) ) ,
@@ -172,38 +172,6 @@ fn mouse_picking(
172
172
}
173
173
}
174
174
175
- // TODO remove before merging, this is just for testing purposes
176
- fn save_buffer_to_file (
177
- keyboard_input : Res < Input < KeyCode > > ,
178
- gpu_picking_cameras : Query < ( & GpuPickingCamera , & Camera ) > ,
179
- ) {
180
- if keyboard_input. just_pressed ( KeyCode :: P ) {
181
- for ( i, ( gpu_picking_camera, camera) ) in gpu_picking_cameras. iter ( ) . enumerate ( ) {
182
- let mut data = vec ! [ ] ;
183
- data. push ( "P3" . to_string ( ) ) ;
184
- let size = camera. logical_viewport_size ( ) . unwrap ( ) ;
185
- data. push ( format ! ( "{} {}" , size. x, size. y) ) ;
186
- data. push ( "255" . to_string ( ) ) ;
187
-
188
- for y in 0 ..=size. y as u32 {
189
- for x in 0 ..=size. x as u32 {
190
- let entity = gpu_picking_camera. get_entity ( UVec2 :: new ( x, y) ) ;
191
- if entity. is_some ( ) {
192
- data. push ( "255 0 0" . to_string ( ) ) ;
193
- } else {
194
- data. push ( "0 0 0" . to_string ( ) ) ;
195
- }
196
- }
197
- }
198
-
199
- std:: fs:: write ( format ! ( "entity_out_{i}.ppm" ) , data. join ( "\n " ) )
200
- . expect ( "Unable to write file" ) ;
201
-
202
- println ! ( "buffer saved to entity_out_{i}.ppm" ) ;
203
- }
204
- }
205
- }
206
-
207
175
// You can also use a custom material with it, you just need to make sure it correctly outputs the entity id
208
176
// See assets/shaders/gpu_picking_material.wgsl for more information
209
177
#[ derive( AsBindGroup , TypeUuid , TypePath , Debug , Clone ) ]
@@ -222,6 +190,8 @@ impl Material for GpuPickingMaterial {
222
190
#[ derive( Component ) ]
223
191
struct MoveCube ;
224
192
193
+ // Moves a mesh from left to right
194
+ // Used to show that picking works even if things are moving
225
195
fn move_cube (
226
196
mut q : Query < & mut Transform , With < MoveCube > > ,
227
197
time : Res < Time > ,
0 commit comments