ambidextrous / dual slash
This commit is contained in:
parent
7c5c09c3b3
commit
75c80316a5
1 changed files with 87 additions and 59 deletions
52
src/Arts.cs
52
src/Arts.cs
|
@ -69,12 +69,17 @@ static class Arts
|
|||
mat_both.Chain = mat_backface;
|
||||
|
||||
mat_slash.FaceCull = Cull.None;
|
||||
|
||||
tip_index = new int[] { 0, 0 };
|
||||
tip_buffer = new Vec3[][] { new Vec3[tip_count], new Vec3[tip_count] };
|
||||
slashing = new DeltaBool[] { new(false), new(false) };
|
||||
}
|
||||
|
||||
// slash tip pos frame circle buffer [!] move out of render class
|
||||
static int tip_index = 0;
|
||||
static int tip_count = 24; // [!] this needs to be scaled with headset framerate
|
||||
static Vec3[] tip_buffer = new Vec3[tip_count];
|
||||
static int[] tip_index;
|
||||
static Vec3[][] tip_buffer;
|
||||
static DeltaBool[] slashing;
|
||||
|
||||
// [!] hacky offset stepper for noise
|
||||
public static int offset = 0;
|
||||
|
@ -241,14 +246,36 @@ static class Arts
|
|||
// );
|
||||
|
||||
// blade
|
||||
Mesh mesh = new();
|
||||
Quat blade_ori = Rig.r_hld.orientation;
|
||||
Vec3 blade_pos = Rig.r_hld.position;
|
||||
for (int i = 0; i < (int)Handed.Max; i++)
|
||||
{
|
||||
Quat blade_ori = Rig.pose_hld[i].orientation;
|
||||
Vec3 blade_pos = Rig.pose_hld[i].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];
|
||||
Vec3 mid_tip = tip_buffer[(tip_index + (tip_count / 3) * 2) % tip_count];
|
||||
if (!Rig.holding[i]) // [!] generic placeholder check
|
||||
{
|
||||
// reset tip buffer
|
||||
for (int j = 0; j < tip_count; j++)
|
||||
{
|
||||
tip_buffer[i][j] = tip_pos;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
tip_index[i] = (tip_index[i] + 1) % tip_count;
|
||||
tip_buffer[i][tip_index[i]] = tip_pos;
|
||||
Vec3 oldest_tip = tip_buffer[i][(tip_index[i] + 1) % tip_count];
|
||||
Vec3 mid_tip = tip_buffer[i][(tip_index[i] + (tip_count / 3) * 2) % tip_count];
|
||||
|
||||
slashing[i].Step(Vec3.Distance(tip_pos, oldest_tip) > 0.2f);
|
||||
if (slashing[i].delta == -1)
|
||||
{
|
||||
Rig.holding[i] = false;
|
||||
|
||||
// [!] janky placeholder reset
|
||||
Rig.upper_sheathes[0] = true;
|
||||
Rig.upper_sheathes[1] = true;
|
||||
}
|
||||
|
||||
Mesh mesh = new();
|
||||
mesh.SetData(
|
||||
new Vertex[] {
|
||||
new( blade_pos, V.XYZ(0,0,1)),
|
||||
|
@ -270,16 +297,16 @@ static class Arts
|
|||
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
|
||||
// hit test
|
||||
{
|
||||
Matrix enemy_m4 = enemy_test.pose.ToMatrix();
|
||||
Ray local_ray = enemy_m4.Inverse.Transform(slash_ray);
|
||||
bool hit = false;
|
||||
float min_dist = ray_dist;
|
||||
Vec3 min_hit_pos = Vec3.Zero;
|
||||
for (int i = 0; i < enemy_test.cols.Count; i++)
|
||||
for (int j = 0; j < enemy_test.cols.Count; j++)
|
||||
{
|
||||
Sphere col = enemy_test.cols[i];
|
||||
Sphere col = enemy_test.cols[j];
|
||||
Vec3 hit_pos = Vec3.Zero;
|
||||
if (col.Intersect(local_ray, out hit_pos))
|
||||
{
|
||||
|
@ -307,6 +334,7 @@ static class Arts
|
|||
VFX.Play(min_hit_pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// revolver
|
||||
Quat rvolv_ori = Rig.l_aim.orientation;
|
||||
|
|
Loading…
Add table
Reference in a new issue