Add waveland snapping (#95)
Reviewed-on: #95 Co-authored-by: Álex Román Núñez <eirexe@eirteam.moe>
This commit was merged in pull request #95.
This commit is contained in:
+15
-5
@@ -1,15 +1,15 @@
|
||||
use bevy::{color::palettes::css::RED, prelude::*};
|
||||
|
||||
use crate::{
|
||||
match_loading::MatchConfig, math::{int::FGi32, vec3::FGVec3}, stage::{
|
||||
line::{StageCollision, StageLedgeSide},
|
||||
manifest::{StageManifest, StageManifestRegistry},
|
||||
game_settings::GameSettings, match_loading::MatchConfig, math::{int::FGi32, vec3::FGVec3}, stage::{
|
||||
line::{StageCollision, StageLedgeSide, StagePolyLineSegmentType}, manifest::{StageManifest, StageManifestRegistry},
|
||||
},
|
||||
};
|
||||
|
||||
pub fn debug_draw_scene(mut gizmos: Gizmos, stage_collision: Res<StageCollision>) {
|
||||
pub fn debug_draw_scene(mut gizmos: Gizmos, stage_collision: Res<StageCollision>, game_settings: Res<GameSettings>) {
|
||||
for poly in stage_collision.stage_polys.iter() {
|
||||
for segment in &poly.segments {
|
||||
for (segment, next_segment) in poly.segments.iter().zip(poly.segments.iter().cycle().skip(1)) {
|
||||
let wavedash_normal = ((next_segment.normal.to_vec2() + segment.normal.to_vec2()) * 0.5).normalize();
|
||||
let from = segment.segment.point1().to_vec2();
|
||||
let to = segment.segment.point2().to_vec2();
|
||||
let from_3d = Vec3::new(from.x, from.y, 0.0);
|
||||
@@ -18,6 +18,16 @@ pub fn debug_draw_scene(mut gizmos: Gizmos, stage_collision: Res<StageCollision>
|
||||
gizmos.line(from_3d, end_3d, RED);
|
||||
let midpoint = (from_3d + end_3d) * 0.5;
|
||||
gizmos.arrow(midpoint, midpoint + normal_3d, RED);
|
||||
if matches!(segment.segment_type, StagePolyLineSegmentType::Floor) {
|
||||
let radius = game_settings.fighter_common.waveland_snap_distance.to_num::<f32>();
|
||||
let a = segment.segment.point1().to_vec2();
|
||||
let a = Vec3::new(a.x, a.y, 0.0);
|
||||
let b = segment.segment.point2().to_vec2();
|
||||
let b = Vec3::new(b.x, b.y, 0.0);
|
||||
let offset = Vec3::new(wavedash_normal.x, wavedash_normal.y, 0.0) * radius;
|
||||
gizmos.line(a + offset, b + offset, bevy::color::palettes::css::HOT_PINK);
|
||||
gizmos.line(a - offset, b - offset, bevy::color::palettes::css::HOT_PINK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user