Add waveland snapping
CI / production-build (pull_request) Successful in 11m11s
CI / build-and-test (pull_request) Failing after 1m38s

This commit is contained in:
2026-10-13 22:49:56 +02:00
parent 472a0b6a19
commit 5be69cab52
5 changed files with 44 additions and 17 deletions
+15 -5
View File
@@ -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);
}
}
}