impact particle testing
This commit is contained in:
parent
63c7e9122d
commit
6c26104f5e
16
src/pp/pp.c
16
src/pp/pp.c
@ -2854,14 +2854,14 @@ void P_StepFrame(P_Frame *frame)
|
|||||||
// insert a path from the bullet's base to its starting position before
|
// insert a path from the bullet's base to its starting position before
|
||||||
// its actual firing path
|
// its actual firing path
|
||||||
{
|
{
|
||||||
// Firer origin -> weapon base path
|
// Firer origin -> weapon chamber path
|
||||||
BulletPath *path = PushStruct(scratch.arena, BulletPath);
|
BulletPath *path = PushStruct(scratch.arena, BulletPath);
|
||||||
SllQueuePush(first_bullet_path, last_bullet_path, path);
|
SllQueuePush(first_bullet_path, last_bullet_path, path);
|
||||||
path->start = bullet->bullet_base0;
|
path->start = bullet->bullet_base0;
|
||||||
path->end = bullet->bullet_base1;
|
path->end = bullet->bullet_base1;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Weapon base -> bullet start path
|
// Weapon chamber -> bullet start path
|
||||||
BulletPath *path = PushStruct(scratch.arena, BulletPath);
|
BulletPath *path = PushStruct(scratch.arena, BulletPath);
|
||||||
SllQueuePush(first_bullet_path, last_bullet_path, path);
|
SllQueuePush(first_bullet_path, last_bullet_path, path);
|
||||||
path->start = bullet->bullet_base1;
|
path->start = bullet->bullet_base1;
|
||||||
@ -2928,7 +2928,7 @@ void P_StepFrame(P_Frame *frame)
|
|||||||
}
|
}
|
||||||
if (!P_IsEntKeyNil(victim_key))
|
if (!P_IsEntKeyNil(victim_key))
|
||||||
{
|
{
|
||||||
// No need to check future paths if this path hit
|
// No need to check subsequent paths if this path hit
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2944,11 +2944,19 @@ void P_StepFrame(P_Frame *frame)
|
|||||||
bullet->hit_entry_normal = victim_raycast.normal;
|
bullet->hit_entry_normal = victim_raycast.normal;
|
||||||
// bullet->bullet_end = bullet->hit_entry;
|
// bullet->bullet_end = bullet->hit_entry;
|
||||||
bullet->exists = 0;
|
bullet->exists = 0;
|
||||||
|
if (victim->is_guy)
|
||||||
|
{
|
||||||
|
bullet->hit_material = P_MaterialKind_Flesh;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bullet->hit_material = P_MaterialKind_Wall;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove this
|
||||||
if (!P_IsEntNil(victim))
|
if (!P_IsEntNil(victim))
|
||||||
{
|
{
|
||||||
// TODO: Remove this
|
|
||||||
victim->health -= 0.25;
|
victim->health -= 0.25;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -126,7 +126,7 @@ Struct(P_Ent)
|
|||||||
i64 last_fire_ns;
|
i64 last_fire_ns;
|
||||||
b32 has_weapon;
|
b32 has_weapon;
|
||||||
|
|
||||||
//- Bullet
|
//- Bullet / hit
|
||||||
|
|
||||||
P_EntKey bullet_firer;
|
P_EntKey bullet_firer;
|
||||||
b32 is_bullet;
|
b32 is_bullet;
|
||||||
@ -138,6 +138,7 @@ Struct(P_Ent)
|
|||||||
b32 has_hit;
|
b32 has_hit;
|
||||||
Vec2 hit_entry;
|
Vec2 hit_entry;
|
||||||
Vec2 hit_entry_normal;
|
Vec2 hit_entry_normal;
|
||||||
|
P_MaterialKind hit_material;
|
||||||
|
|
||||||
//- Player / Guy
|
//- Player / Guy
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,15 @@
|
|||||||
#define P_TilesCount (P_TilesPitch * P_TilesPitch)
|
#define P_TilesCount (P_TilesPitch * P_TilesPitch)
|
||||||
#define P_CellsCount (P_CellsPitch * P_TilesPitch)
|
#define P_CellsCount (P_CellsPitch * P_TilesPitch)
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
//~ Material types
|
||||||
|
|
||||||
|
Enum(P_MaterialKind)
|
||||||
|
{
|
||||||
|
P_MaterialKind_Wall,
|
||||||
|
P_MaterialKind_Flesh,
|
||||||
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Tile types
|
//~ Tile types
|
||||||
|
|
||||||
@ -21,7 +30,7 @@
|
|||||||
X(Carpet) \
|
X(Carpet) \
|
||||||
/* -------------------- */
|
/* -------------------- */
|
||||||
|
|
||||||
//- Tiles kinds
|
//- Tile kinds
|
||||||
Enum(P_TileKind)
|
Enum(P_TileKind)
|
||||||
{
|
{
|
||||||
#define X(name, ...) P_TileKind_##name,
|
#define X(name, ...) P_TileKind_##name,
|
||||||
|
|||||||
@ -2146,9 +2146,6 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
|
|
||||||
// TODO: Not like this
|
// TODO: Not like this
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (P_Ent *bullet = P_FirstEnt(local_frame); !P_IsEntNil(bullet); bullet = P_NextEnt(bullet))
|
for (P_Ent *bullet = P_FirstEnt(local_frame); !P_IsEntNil(bullet); bullet = P_NextEnt(bullet))
|
||||||
{
|
{
|
||||||
if (bullet->is_bullet)
|
if (bullet->is_bullet)
|
||||||
@ -2222,103 +2219,14 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
}
|
}
|
||||||
V_PushParticles(emitter);
|
V_PushParticles(emitter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// {
|
|
||||||
// PERSIST Vec2 start = {5, 5};
|
|
||||||
// PERSIST Vec2 end = {3, -20};
|
|
||||||
|
|
||||||
|
|
||||||
// b32 skip = 1;
|
|
||||||
// if (frame->held_buttons[Button_G])
|
|
||||||
// {
|
|
||||||
// end = frame->world_cursor;
|
|
||||||
// if (!prev_frame->held_buttons[Button_G])
|
|
||||||
// {
|
|
||||||
// start = end;
|
|
||||||
// }
|
|
||||||
// skip = 0;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Vec2 vel = SubVec2(end, start);
|
|
||||||
|
|
||||||
|
|
||||||
// f32 trail_len = Vec2Len(SubVec2(end, start));
|
|
||||||
// // f32 particles_count = MaxF32(trail_len * 10000, 1);
|
|
||||||
// // f32 particles_count = MaxF32(trail_len * 512, 1);
|
|
||||||
// // f32 particles_count = MaxF32(trail_len * 64, 1);
|
|
||||||
// f32 particles_count = MaxF32(trail_len * 32, 1);
|
|
||||||
|
|
||||||
|
|
||||||
// f32 angle = AngleFromVec2(PerpVec2(SubVec2(end, start)));
|
|
||||||
// // f32 angle = AngleFromVec2(NegVec2(SubVec2(end, start)));
|
|
||||||
|
|
||||||
// V_Emitter *emitter = V_PushEmitter(particles_count);
|
|
||||||
|
|
||||||
// // emitter->flags |= V_ParticleFlag_StainOnPrune;
|
|
||||||
// // emitter->flags |= V_ParticleFlag_StainTrail;
|
|
||||||
|
|
||||||
// // emitter->lifetime = 1;
|
|
||||||
// // emitter->lifetime_spread = 2;
|
|
||||||
|
|
||||||
// emitter->lifetime = 0.25;
|
|
||||||
// emitter->lifetime_spread = emitter->lifetime * 2;
|
|
||||||
|
|
||||||
// emitter->angle = angle;
|
|
||||||
// // emitter->angle_spread = Tau / 4;
|
|
||||||
// emitter->angle_spread = Tau / 4;
|
|
||||||
|
|
||||||
// emitter->start = start;
|
|
||||||
// emitter->end = end;
|
|
||||||
|
|
||||||
// // emitter->color_lin = LinearFromSrgb(VEC4(0, 1, 0, 1));
|
|
||||||
|
|
||||||
// // emitter->color_lin = LinearFromSrgb(VEC4(0.8, 0.8, 0.8, 0.25));
|
|
||||||
// emitter->color_lin = LinearFromSrgb(VEC4(0.8, 0.6, 0.2, 1));
|
|
||||||
// // emitter->color_spread = LinearFromSrgb(VEC4(0, 0, 0, 0.2));
|
|
||||||
|
|
||||||
// emitter->speed = 0;
|
|
||||||
// emitter->speed_spread = 1;
|
|
||||||
|
|
||||||
// // emitter->speed = 1;
|
|
||||||
// // emitter->speed_spread = 1;
|
|
||||||
|
|
||||||
// // emitter->velocity_falloff = 1;
|
|
||||||
// // emitter->velocity_falloff_spread = 0;
|
|
||||||
|
|
||||||
// start = end;
|
|
||||||
// end = AddVec2(end, vel);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- Push test blood particles
|
//- Push test impact particles
|
||||||
|
|
||||||
// TODO: Not like this
|
// TODO: Not like this
|
||||||
|
|
||||||
@ -2330,8 +2238,7 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
{
|
{
|
||||||
if (bullet->is_bullet && bullet->has_hit)
|
if (bullet->is_bullet && bullet->has_hit)
|
||||||
{
|
{
|
||||||
// Vec2 bullet_start = bullet->start;
|
P_MaterialKind material = bullet->hit_material;
|
||||||
// Vec2 bullet_end = bullet->end;
|
|
||||||
|
|
||||||
Vec2 hit_entry = bullet->hit_entry;
|
Vec2 hit_entry = bullet->hit_entry;
|
||||||
Vec2 hit_entry_normal = bullet->hit_entry_normal;
|
Vec2 hit_entry_normal = bullet->hit_entry_normal;
|
||||||
@ -2339,6 +2246,88 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
|
|
||||||
V_DrawLine(bullet->bullet_start, bullet->bullet_end, Color_Cyan);
|
V_DrawLine(bullet->bullet_start, bullet->bullet_end, Color_Cyan);
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
//- Wall particles
|
||||||
|
|
||||||
|
if (material != P_MaterialKind_Flesh)
|
||||||
|
{
|
||||||
|
//- Wall debris
|
||||||
|
{
|
||||||
|
V_Emitter emitter = Zi;
|
||||||
|
{
|
||||||
|
emitter.flags |= V_ParticleFlag_PruneWhenStill;
|
||||||
|
emitter.flags |= V_ParticleFlag_StainOnPrune;
|
||||||
|
|
||||||
|
emitter.count = 4;
|
||||||
|
|
||||||
|
emitter.start = hit_entry;
|
||||||
|
emitter.end = emitter.start;
|
||||||
|
|
||||||
|
emitter.color_lin = LinearFromSrgb(VEC4(0.3, 0.25, 0.0, 1));
|
||||||
|
// emitter.color_spread = VEC4(0.1, 0.1, 0.1, 0);
|
||||||
|
|
||||||
|
emitter.speed = 2;
|
||||||
|
// emitter.speed_spread = emitter.speed * 2;
|
||||||
|
emitter.speed_spread = emitter.speed * 2;
|
||||||
|
|
||||||
|
emitter.velocity_falloff = 5;
|
||||||
|
emitter.velocity_falloff_spread = emitter.velocity_falloff_spread * 1.5;
|
||||||
|
|
||||||
|
Vec2 dir = hit_entry_normal;
|
||||||
|
|
||||||
|
emitter.angle = AngleFromVec2(dir);
|
||||||
|
emitter.angle_spread = Tau * 0.5;
|
||||||
|
|
||||||
|
// emitter.lifetime = 0.25;
|
||||||
|
// emitter.lifetime = 0.05;
|
||||||
|
// emitter.lifetime = 0.04;
|
||||||
|
emitter.lifetime_spread = emitter.lifetime * 2;
|
||||||
|
}
|
||||||
|
V_PushParticles(emitter);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Wall dust
|
||||||
|
{
|
||||||
|
V_Emitter emitter = Zi;
|
||||||
|
{
|
||||||
|
// emitter.flags |= V_ParticleFlag_PruneWhenStill;
|
||||||
|
|
||||||
|
emitter.count = 32;
|
||||||
|
|
||||||
|
emitter.start = hit_entry;
|
||||||
|
emitter.end = emitter.start;
|
||||||
|
|
||||||
|
emitter.color_lin = LinearFromSrgb(VEC4(0.5, 0.5, 0.5, 0.75));
|
||||||
|
|
||||||
|
emitter.speed = 4;
|
||||||
|
// emitter.speed_spread = emitter.speed * 2;
|
||||||
|
emitter.speed_spread = emitter.speed * 2;
|
||||||
|
|
||||||
|
emitter.velocity_falloff = 12;
|
||||||
|
emitter.velocity_falloff_spread = emitter.velocity_falloff_spread * 1.5;
|
||||||
|
|
||||||
|
Vec2 dir = hit_entry_normal;
|
||||||
|
|
||||||
|
emitter.angle = AngleFromVec2(dir);
|
||||||
|
emitter.angle_spread = Tau * 0.1;
|
||||||
|
|
||||||
|
emitter.lifetime = 1;
|
||||||
|
// emitter.lifetime = 0.05;
|
||||||
|
// emitter.lifetime = 0.04;
|
||||||
|
emitter.lifetime_spread = emitter.lifetime * 2;
|
||||||
|
}
|
||||||
|
V_PushParticles(emitter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
//- Blood particles
|
||||||
|
|
||||||
|
if (material == P_MaterialKind_Flesh)
|
||||||
|
{
|
||||||
|
// Vec2 bullet_start = bullet->start;
|
||||||
|
// Vec2 bullet_end = bullet->end;
|
||||||
|
|
||||||
V_ParticleFlag flags = 0;
|
V_ParticleFlag flags = 0;
|
||||||
flags |= V_ParticleFlag_PruneWhenStill;
|
flags |= V_ParticleFlag_PruneWhenStill;
|
||||||
flags |= V_ParticleFlag_StainOnPrune;
|
flags |= V_ParticleFlag_StainOnPrune;
|
||||||
@ -2387,6 +2376,7 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
// emitter.angle_spread = Tau;
|
// emitter.angle_spread = Tau;
|
||||||
}
|
}
|
||||||
V_PushParticles(emitter);
|
V_PushParticles(emitter);
|
||||||
|
}
|
||||||
|
|
||||||
// V_DrawPoint(victim_raycast.p, Color_Green);
|
// V_DrawPoint(victim_raycast.p, Color_Green);
|
||||||
// V_DrawLine(victim_raycast.p, AddVec2(victim_raycast.p, MulVec2(victim_raycast.normal, 0.5)), Color_White);
|
// V_DrawLine(victim_raycast.p, AddVec2(victim_raycast.p, MulVec2(victim_raycast.normal, 0.5)), Color_White);
|
||||||
|
|||||||
@ -498,6 +498,7 @@ PixelShader(V_CompositePS, V_CompositePSOutput, V_CompositePSInput input)
|
|||||||
// TODO: Remove this
|
// TODO: Remove this
|
||||||
|
|
||||||
Vec4 particle_color = cells.Load(cell_pos);
|
Vec4 particle_color = cells.Load(cell_pos);
|
||||||
|
particle_color.rgb *= particle_color.a;
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- Compose world
|
//- Compose world
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user