bounding-box skin
This commit is contained in:
parent
1e393394c1
commit
19b7601c5f
36
src/pp/pp.c
36
src/pp/pp.c
@ -173,14 +173,15 @@ P_Shape P_MulXformShape(Xform xf, P_Shape shape)
|
|||||||
|
|
||||||
Rng2 P_BoundingBoxFromShape(P_Shape shape)
|
Rng2 P_BoundingBoxFromShape(P_Shape shape)
|
||||||
{
|
{
|
||||||
|
f32 skin = 0.01;
|
||||||
Vec2 left = P_SupportPointFromShape(shape, VEC2(-1, 0)).p;
|
Vec2 left = P_SupportPointFromShape(shape, VEC2(-1, 0)).p;
|
||||||
Vec2 top = P_SupportPointFromShape(shape, VEC2(0, -1)).p;
|
Vec2 top = P_SupportPointFromShape(shape, VEC2(0, -1)).p;
|
||||||
Vec2 right = P_SupportPointFromShape(shape, VEC2(1, 0)).p;
|
Vec2 right = P_SupportPointFromShape(shape, VEC2(1, 0)).p;
|
||||||
Vec2 bottom = P_SupportPointFromShape(shape, VEC2(0, 1)).p;
|
Vec2 bottom = P_SupportPointFromShape(shape, VEC2(0, 1)).p;
|
||||||
|
|
||||||
Rng2 result = Zi;
|
Rng2 result = Zi;
|
||||||
result.p0 = VEC2(left.x, top.y);
|
result.p0 = VEC2(left.x - skin, top.y - skin);
|
||||||
result.p1 = VEC2(right.x, bottom.y);
|
result.p1 = VEC2(right.x + skin, bottom.y + skin);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1926,13 +1927,10 @@ void P_StepFrame(P_Frame *frame)
|
|||||||
{
|
{
|
||||||
// TODO: Something better than linear distance for scoring
|
// TODO: Something better than linear distance for scoring
|
||||||
f32 score = Vec2Len(SubVec2(ent->xf.t, spawn->ent->xf.t));
|
f32 score = Vec2Len(SubVec2(ent->xf.t, spawn->ent->xf.t));
|
||||||
// if (score < 10)
|
|
||||||
{
|
|
||||||
spawn->score = MinF32(spawn->score, score);
|
spawn->score = MinF32(spawn->score, score);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Find highest scoring spawn
|
// Find highest scoring spawn
|
||||||
i64 highest_score = -Inf;
|
i64 highest_score = -Inf;
|
||||||
@ -2041,12 +2039,13 @@ void P_StepFrame(P_Frame *frame)
|
|||||||
f32 solver_dt = sim_dt / solver_steps_count;
|
f32 solver_dt = sim_dt / solver_steps_count;
|
||||||
|
|
||||||
// Solid params
|
// Solid params
|
||||||
|
// SoftSpring solid_spring = MakeSpring(TweakFloat("Contact spring hz", 25, 5, 200), TweakFloat("Contact spring damp", 10, 5, 100), solver_dt);
|
||||||
SoftSpring solid_spring = MakeSpring(TweakFloat("Contact spring hz", 100, 5, 200), TweakFloat("Contact spring damp", 10, 5, 100), solver_dt);
|
SoftSpring solid_spring = MakeSpring(TweakFloat("Contact spring hz", 100, 5, 200), TweakFloat("Contact spring damp", 10, 5, 100), solver_dt);
|
||||||
f32 solid_pushout_velocity = TweakFloat("Contact spring pushout", 3, 0, 50);
|
f32 solid_pushout_velocity = TweakFloat("Contact spring pushout", 3, 0, 50);
|
||||||
|
|
||||||
// Gentle params
|
// Gentle params
|
||||||
// f32 gentle_pushout_factor = TweakFloat("Gentle pushout factor", 10, 0, 50);
|
// f32 gentle_pushout_factor = TweakFloat("Gentle pushout factor", 10, 0, 50);
|
||||||
f32 gentle_pushout_factor = TweakFloat("Gentle pushout factor", 0.1, 0, 50);
|
f32 gentle_pushout_factor = TweakFloat("Gentle pushout factor", 0.5, 0, 50);
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- Bake world
|
//- Bake world
|
||||||
@ -2613,18 +2612,10 @@ void P_StepFrame(P_Frame *frame)
|
|||||||
f32 tweak_speed = TweakFloat("Bullet speed", 100, 1, 100);
|
f32 tweak_speed = TweakFloat("Bullet speed", 100, 1, 100);
|
||||||
|
|
||||||
b32 can_fire = (firer->last_fire_ns + NsFromSeconds(1.0 / fire_rate)) <= frame->time_ns;
|
b32 can_fire = (firer->last_fire_ns + NsFromSeconds(1.0 / fire_rate)) <= frame->time_ns;
|
||||||
if (can_fire)
|
|
||||||
{
|
|
||||||
i64 tick_bullets_count = bullets_per_fire;
|
|
||||||
if (tick_bullets_count > 0)
|
|
||||||
{
|
|
||||||
P_Shape firer_world_shape = P_WorldShapeFromEnt(firer);
|
|
||||||
|
|
||||||
// Vec2 fire_pos = P_EdgePointFromShape(firer_world_shape, firer->control.look);
|
|
||||||
// Vec2 fire_dir = firer->control.look;
|
|
||||||
|
|
||||||
Vec2 fire_pos = Zi;
|
Vec2 fire_pos = Zi;
|
||||||
Vec2 fire_dir = Zi;
|
Vec2 fire_dir = Zi;
|
||||||
|
if (can_fire)
|
||||||
{
|
{
|
||||||
Vec2 look = firer->control.look;
|
Vec2 look = firer->control.look;
|
||||||
P_Anim anim = P_AnimFromEnt(firer, frame->time_ns);
|
P_Anim anim = P_AnimFromEnt(firer, frame->time_ns);
|
||||||
@ -2671,9 +2662,20 @@ void P_StepFrame(P_Frame *frame)
|
|||||||
SPR_Ray fire_ray = wep.rays[SPR_RayKind_Ap];
|
SPR_Ray fire_ray = wep.rays[SPR_RayKind_Ap];
|
||||||
fire_pos = MulAffineVec2(wep_pix_to_world_af, fire_ray.pos);
|
fire_pos = MulAffineVec2(wep_pix_to_world_af, fire_ray.pos);
|
||||||
fire_dir = NormRot(MulAffineBasisVec2(wep_pix_to_world_af, fire_ray.dir));
|
fire_dir = NormRot(MulAffineBasisVec2(wep_pix_to_world_af, fire_ray.dir));
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: Prevent obstructed weapons from firing through walls
|
// FIXME: Prevent obstructed weapons from firing through walls
|
||||||
|
}
|
||||||
|
|
||||||
|
if (can_fire)
|
||||||
|
{
|
||||||
|
i64 tick_bullets_count = bullets_per_fire;
|
||||||
|
if (tick_bullets_count > 0)
|
||||||
|
{
|
||||||
|
P_Shape firer_world_shape = P_WorldShapeFromEnt(firer);
|
||||||
|
|
||||||
|
// Vec2 fire_pos = P_EdgePointFromShape(firer_world_shape, firer->control.look);
|
||||||
|
// Vec2 fire_dir = firer->control.look;
|
||||||
|
|
||||||
for (i64 bullet_idx = 0; bullet_idx < tick_bullets_count; ++bullet_idx)
|
for (i64 bullet_idx = 0; bullet_idx < tick_bullets_count; ++bullet_idx)
|
||||||
{
|
{
|
||||||
P_Ent *bullet = P_PushTempEnt(scratch.arena, &bullets_to_spawn);
|
P_Ent *bullet = P_PushTempEnt(scratch.arena, &bullets_to_spawn);
|
||||||
@ -2719,6 +2721,8 @@ void P_StepFrame(P_Frame *frame)
|
|||||||
Vec2 ray_end = bullet->bullet_end;
|
Vec2 ray_end = bullet->bullet_end;
|
||||||
Vec2 ray_dir = SubVec2(ray_end, ray_start);
|
Vec2 ray_dir = SubVec2(ray_end, ray_start);
|
||||||
|
|
||||||
|
P_DebugDrawLine(bullet->bullet_start, bullet->bullet_end, Color_Red);
|
||||||
|
|
||||||
// TODO: Real raycast query
|
// TODO: Real raycast query
|
||||||
P_Ent *victim = &P_NilEnt;
|
P_Ent *victim = &P_NilEnt;
|
||||||
P_RaycastResult victim_raycast = Zi;
|
P_RaycastResult victim_raycast = Zi;
|
||||||
|
|||||||
@ -4730,6 +4730,8 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- Initialization pass
|
//- Initialization pass
|
||||||
|
|
||||||
|
b32 disable_vis_draw = TweakBool("Disable vis draw", 0);
|
||||||
|
|
||||||
{
|
{
|
||||||
// Prepare shade
|
// Prepare shade
|
||||||
G_Compute(frame->cl, V_PrepareShadeCS, V_ThreadGroupSizeFromTexSize(frame->shade_dims));
|
G_Compute(frame->cl, V_PrepareShadeCS, V_ThreadGroupSizeFromTexSize(frame->shade_dims));
|
||||||
@ -4743,10 +4745,17 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
G_Compute(frame->cl, V_ClearParticlesCS, V_ThreadGroupSizeFromBufferSize(V_ParticlesCap));
|
G_Compute(frame->cl, V_ClearParticlesCS, V_ThreadGroupSizeFromBufferSize(V_ParticlesCap));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Discard screen RT
|
// Prepare screen RT
|
||||||
|
if (disable_vis_draw)
|
||||||
|
{
|
||||||
|
G_ClearRenderTarget(frame->cl, screen_target, VEC4(0, 0, 0, 0));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
G_DiscardRenderTarget(frame->cl, screen_target);
|
G_DiscardRenderTarget(frame->cl, screen_target);
|
||||||
|
}
|
||||||
|
|
||||||
// Clear albedo RT
|
// Prepare albedo RT
|
||||||
G_ClearRenderTarget(frame->cl, albedo_target, VEC4(0, 0, 0, 0));
|
G_ClearRenderTarget(frame->cl, albedo_target, VEC4(0, 0, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4804,6 +4813,7 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- Composite pass
|
//- Composite pass
|
||||||
|
|
||||||
|
if (!disable_vis_draw)
|
||||||
{
|
{
|
||||||
G_Rasterize(
|
G_Rasterize(
|
||||||
frame->cl,
|
frame->cl,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user