From 0f7b6d2ffcc3a5c875b408dd493bfebe6e621112 Mon Sep 17 00:00:00 2001 From: jacob Date: Thu, 8 Jan 2026 07:03:23 -0600 Subject: [PATCH] blood tweaks --- src/pp/pp_sim/pp_sim_core.c | 19 +++++++++++++------ src/pp/pp_sim/pp_sim_core.h | 2 ++ src/pp/pp_vis/pp_vis_core.c | 12 ++++++++---- src/pp/pp_vis/pp_vis_core.h | 1 + src/pp/pp_vis/pp_vis_gpu.g | 15 +++++++++++++-- 5 files changed, 37 insertions(+), 12 deletions(-) diff --git a/src/pp/pp_sim/pp_sim_core.c b/src/pp/pp_sim/pp_sim_core.c index 02c1c207..bb7cbe76 100644 --- a/src/pp/pp_sim/pp_sim_core.c +++ b/src/pp/pp_sim/pp_sim_core.c @@ -1342,6 +1342,11 @@ void S_TickForever(WaveLaneCtx *lane) ////////////////////////////// //- Update ent controls + for (S_Ent *ent = S_FirstEnt(world); ent->valid; ent = S_NextEnt(ent)) + { + ent->fire_presses = 0; + } + for (S_CmdNode *cmd_node = input->first_cmd_node; cmd_node; cmd_node = cmd_node->next) { S_Cmd cmd = cmd_node->cmd; @@ -1353,6 +1358,7 @@ void S_TickForever(WaveLaneCtx *lane) target->move = ClampVec2Len(cmd.move, 1); target->look = cmd.look; target->fire_held = cmd.fire_held; + target->fire_presses += cmd.fire_presses; } } } @@ -1600,7 +1606,8 @@ void S_TickForever(WaveLaneCtx *lane) S_EntList bullets_to_spawn = Zi; for (S_Ent *firer = S_FirstEnt(world); firer->valid; firer = S_NextEnt(firer)) { - if (firer->fire_held) + // if (firer->fire_held) + if (firer->fire_presses) { // i64 fire_delta_ns = world->time_ns - firer->last_fire_ns; @@ -1608,10 +1615,10 @@ void S_TickForever(WaveLaneCtx *lane) // i64 tick_bullets_count = sim_dt * firer->fire_rate; - f32 fire_rate = 50; - f32 bullets_per_fire = 3; - f32 spread = Tau * 0.05; - // f32 spread = Tau * 0.01; + f32 fire_rate = 20; + f32 bullets_per_fire = 1; + // f32 spread = Tau * 0.05; + f32 spread = Tau * 0.01; f32 tweak_speed = TweakFloat("Bullet speed", 100, 1, 100); b32 can_fire = (firer->last_fire_ns + NsFromSeconds(1.0 / fire_rate)) <= world->time_ns; @@ -1883,7 +1890,7 @@ void S_TickForever(WaveLaneCtx *lane) { Vec4 color = VEC4(0.8, 0.8, 0.8, 1); Vec2 p0 = world_shape.centroid; - Vec2 p1 = S_SupportPointFromShape(world_shape, ent->look).p; + Vec2 p1 = S_EdgePointFromShape(world_shape, ent->look); S_DebugDrawLine(p0, p1, color); } } diff --git a/src/pp/pp_sim/pp_sim_core.h b/src/pp/pp_sim/pp_sim_core.h index 85d98667..dc731b1d 100644 --- a/src/pp/pp_sim/pp_sim_core.h +++ b/src/pp/pp_sim/pp_sim_core.h @@ -71,6 +71,7 @@ Struct(S_Ent) Vec2 move; Vec2 look; f32 fire_held; + f32 fire_presses; // TODO: Remove this (weapon testing) i64 last_fire_ns; @@ -260,6 +261,7 @@ Struct(S_Cmd) Vec2 move; Vec2 look; b32 fire_held; + i32 fire_presses; }; Struct(S_CmdNode) diff --git a/src/pp/pp_vis/pp_vis_core.c b/src/pp/pp_vis/pp_vis_core.c index 32053202..9a1c1a0f 100644 --- a/src/pp/pp_vis/pp_vis_core.c +++ b/src/pp/pp_vis/pp_vis_core.c @@ -2562,6 +2562,7 @@ void V_TickForever(WaveLaneCtx *lane) if (frame->held_buttons[Button_S]) move.y += 1; } f32 fire_held = frame->held_buttons[Button_M1]; + f32 fire_presses = fire_held && !last_frame->held_buttons[Button_M1]; Vec2 look = Zi; { Vec2 center = MulXformV2(player->xf, player->local_shape.centroid); @@ -2580,6 +2581,7 @@ void V_TickForever(WaveLaneCtx *lane) frame->move = move; frame->look = look; frame->fire_held = fire_held; + frame->fire_presses = fire_presses; } } @@ -2590,6 +2592,7 @@ void V_TickForever(WaveLaneCtx *lane) cmd->move = frame->move; cmd->look = frame->look; cmd->fire_held = frame->fire_held; + cmd->fire_presses = frame->fire_presses; } ////////////////////////////// @@ -2819,12 +2822,12 @@ void V_TickForever(WaveLaneCtx *lane) V_ParticleFlag flags = 0; flags |= V_ParticleFlag_PruneWhenStill; flags |= V_ParticleFlag_StainOnPrune; - if (TweakBool("Emitter stain trail", 0)) + if (TweakBool("Emitter stain trail", 1)) { flags |= V_ParticleFlag_StainTrail; } // f32 count = TweakFloat("Emitter count", 50, 0, 10000); - f32 count = TweakFloat("Emitter count", 50, 1, 1000); + f32 count = TweakFloat("Emitter count", 20, 1, 1000); f32 speed = TweakFloat("Emitter speed", 20, 0, 100); f32 falloff = TweakFloat("Emitter falloff", 50, 0, 100); f32 angle_spread = TweakFloat("Emitter angle spread", 0.1, 0, 1) * Tau; @@ -2852,9 +2855,10 @@ void V_TickForever(WaveLaneCtx *lane) // emitter.angle_spread = Tau / 32; // emitter.color_lin = LinearFromSrgb(VEC4(0.5, 0.1, 0.1, 1)); - emitter.color_lin = LinearFromSrgb(VEC4(0.5, 0.1, 0.1, 1)); + emitter.color_lin = LinearFromSrgb(VEC4(0.5, 0.1, 0.1, 0.5)); - emitter.color_spread = VEC4(0.1, 0, 0, 0); + // emitter.color_spread = VEC4(0.1, 0, 0, 0); + emitter.color_spread = VEC4(0.1, 0, 0, 0.5); // emitter.color = LinearFromSrgb(Vec4(0.5, 0.1, 0.1, 1)); diff --git a/src/pp/pp_vis/pp_vis_core.h b/src/pp/pp_vis/pp_vis_core.h index 019cca77..e0098011 100644 --- a/src/pp/pp_vis/pp_vis_core.h +++ b/src/pp/pp_vis/pp_vis_core.h @@ -268,6 +268,7 @@ Struct(V_Frame) Vec2 move; Vec2 look; f32 fire_held; + f32 fire_presses; // Sim cmds u64 sim_cmds_count; diff --git a/src/pp/pp_vis/pp_vis_gpu.g b/src/pp/pp_vis/pp_vis_gpu.g index b07275a6..559c266a 100644 --- a/src/pp/pp_vis/pp_vis_gpu.g +++ b/src/pp/pp_vis/pp_vis_gpu.g @@ -118,7 +118,8 @@ ComputeShader2D(V_BackdropCS, 8, 8) case S_TileKind_Wall: { - result = Color_Red; + // result = Color_Red; + result = Color_Black; } break; } } @@ -402,7 +403,17 @@ ComputeShader(V_SimParticlesCS, 64) cells[cell_pos] = color; if (should_stain) { - stains[cell_pos] = color; + // stains[cell_pos] = color; + + + Vec4 old_stain = stains[cell_pos]; + + Vec4 new_stain = 0; + new_stain.rgb = (old_stain.rgb * old_stain.a) + (color.rgb * (1.0 - old_stain.a)); + new_stain.a = color.a = (old_stain.a * 1) + (color.a * (1.0 - old_stain.a)); + + + stains[cell_pos] = new_stain; } } else