From abd223a6237c8f21260baf10cbeda21fb79ebc82 Mon Sep 17 00:00:00 2001 From: spatialfree Date: Sat, 21 Dec 2024 14:24:30 -0500 Subject: [PATCH] slash tip pos frame circle buffer --- src/Arts.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Arts.cs b/src/Arts.cs index 9a336e9..cfd9973 100644 --- a/src/Arts.cs +++ b/src/Arts.cs @@ -18,10 +18,14 @@ static class Arts public static Vec3 shake = new(0, 0, 0); // static Quat spin_ori = Quat.Identity; - public static Vec3 last_tip_pos = new(0, 0, 0); static TextStyle text_style; + // slash tip pos frame circle buffer + static int tip_index = 0; + static int tip_count = 12; + static Vec3[] tip_buffer = new Vec3[tip_count]; + public static void Init() { foreach (ModelNode node in assets_model.Nodes) @@ -239,11 +243,14 @@ static class Arts Quat blade_ori = Rig.r_hld.orientation; Vec3 blade_pos = Rig.r_hld.position; Vec3 tip_pos = blade_pos + blade_ori * V.XYZ(0, 0, -1); + tip_index = (tip_index + 1) % tip_count; + tip_buffer[tip_index] = tip_pos; + Vec3 oldest_tip = tip_buffer[(tip_index + 1) % tip_count]; mesh.SetData( new Vertex[] { new( blade_pos, V.XYZ(0,0,1)), new( tip_pos, V.XYZ(0,0,1)), - new(last_tip_pos, V.XYZ(0,0,1)) + new(oldest_tip, V.XYZ(0,0,1)) }, new uint[] { 0, 1, 2 @@ -254,9 +261,9 @@ static class Arts Matrix.Identity, Color.Hex(0xF9BF05FF).ToLinear() ); - Ray slash_ray = new Ray(tip_pos, Vec3.Direction(tip_pos, last_tip_pos)); - float ray_dist = Vec3.Distance(tip_pos, last_tip_pos); - last_tip_pos = Vec3.Lerp(last_tip_pos, tip_pos, Time.Stepf / 0.1f); + Ray slash_ray = new Ray(tip_pos, Vec3.Direction(tip_pos, oldest_tip)); + float ray_dist = Vec3.Distance(tip_pos, oldest_tip); + // last_tip_pos = Vec3.Lerp(last_tip_pos, tip_pos, Time.Stepf / 0.1f); if (true) // hit test {