-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change debug render systems to use bevy gizmos instead of bevy_polyline.
- Loading branch information
Showing
10 changed files
with
69 additions
and
269 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,24 @@ | ||
use bevy::{ | ||
math::Vec3, | ||
prelude::{Entity, GlobalTransform, Query, Res, ResMut}, | ||
}; | ||
use bevy::prelude::{Entity, Gizmos, GlobalTransform, Query, Res}; | ||
use bevy_rapier3d::prelude::Collider; | ||
|
||
use crate::resources::{DebugRenderColliderData, DebugRenderConfig}; | ||
use crate::resources::DebugRenderConfig; | ||
|
||
pub fn debug_render_collider_system( | ||
debug_render_config: Res<DebugRenderConfig>, | ||
query_colliders: Query<(Entity, &Collider, &GlobalTransform)>, | ||
mut render_data: ResMut<DebugRenderColliderData>, | ||
mut gizmos: Gizmos, | ||
) { | ||
if !debug_render_config.colliders { | ||
return; | ||
} | ||
|
||
for (entity, collider, global_transform) in query_colliders.iter() { | ||
let line_index = entity.index() as usize % render_data.collider.len(); | ||
let line_data = &mut render_data.collider[line_index]; | ||
|
||
// The collider shape has already been scaled | ||
let mut transform = global_transform.compute_transform(); | ||
transform.scale = Vec3::ONE; | ||
|
||
if let Some(cuboid) = collider.as_cuboid() { | ||
let (vertices, indices) = cuboid.raw.to_outline(); | ||
|
||
for idx in indices { | ||
line_data | ||
.vertices | ||
.push(transform.transform_point(vertices[idx[0] as usize].into())); | ||
line_data | ||
.vertices | ||
.push(transform.transform_point(vertices[idx[1] as usize].into())); | ||
line_data | ||
.vertices | ||
.push(Vec3::new(f32::NAN, f32::NAN, f32::NAN)); | ||
} | ||
let transform = global_transform | ||
.compute_transform() | ||
.with_scale(cuboid.half_extents() * 2.0); | ||
let color = debug_render_config.color_for_entity(entity); | ||
gizmos.cuboid(transform, color); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.