slash tip pos frame circle buffer

This commit is contained in:
ethan merchant 2024-12-21 14:24:30 -05:00
parent 52c617713c
commit abd223a623

View file

@ -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
{