fix unset space dims
This commit is contained in:
parent
de86e12ba0
commit
1e393394c1
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#define SIM_MAX_PING 5.0
|
#define SIM_MAX_PING 5.0
|
||||||
|
|
||||||
#define SIM_PHYSICS_SUBSTEPS 8
|
#define SIM_PHYSICS_SUBSTEPS 4
|
||||||
|
|
||||||
#define SIM_TICKS_PER_SECOND 64
|
#define SIM_TICKS_PER_SECOND 64
|
||||||
#define SIM_TICK_INTERVAL_NS (NsFromSeconds(1) / SIM_TICKS_PER_SECOND)
|
#define SIM_TICK_INTERVAL_NS (NsFromSeconds(1) / SIM_TICKS_PER_SECOND)
|
||||||
|
|||||||
51
src/pp/pp.c
51
src/pp/pp.c
@ -194,7 +194,7 @@ P_Shape P_LocalShapeFromEnt(P_Ent *ent)
|
|||||||
result = P_ShapeFromDesc(
|
result = P_ShapeFromDesc(
|
||||||
.mass = 10,
|
.mass = 10,
|
||||||
.count = 1,
|
.count = 1,
|
||||||
.radius = 0.25,
|
.radius = TweakFloat("Guy radius", 0.25, 0, 1),
|
||||||
);
|
);
|
||||||
|
|
||||||
// f32 guy_width = 0.75;
|
// f32 guy_width = 0.75;
|
||||||
@ -1201,6 +1201,7 @@ P_Space P_SpaceFromEnts(Arena *arena, P_Frame *frame)
|
|||||||
P_Space space = Zi;
|
P_Space space = Zi;
|
||||||
TempArena scratch = BeginScratch(arena);
|
TempArena scratch = BeginScratch(arena);
|
||||||
P_World *world = frame->world;
|
P_World *world = frame->world;
|
||||||
|
space.dims = VEC2I32(P_WorldPitch, P_WorldPitch);
|
||||||
i64 cells_count = P_WorldPitch * P_WorldPitch;
|
i64 cells_count = P_WorldPitch * P_WorldPitch;
|
||||||
space.cells = PushStructs(arena, P_SpaceCell, cells_count);
|
space.cells = PushStructs(arena, P_SpaceCell, cells_count);
|
||||||
|
|
||||||
@ -1909,18 +1910,23 @@ void P_StepFrame(P_Frame *frame)
|
|||||||
// Score spawns
|
// Score spawns
|
||||||
for (P_Ent *ent = P_FirstEnt(frame); !P_IsEntNil(ent); ent = P_NextEnt(ent))
|
for (P_Ent *ent = P_FirstEnt(frame); !P_IsEntNil(ent); ent = P_NextEnt(ent))
|
||||||
{
|
{
|
||||||
b32 should_score = 0;
|
b32 should_avoid = 0;
|
||||||
if (ent->is_guy)
|
if (ent->is_guy)
|
||||||
{
|
{
|
||||||
should_score = 1;
|
should_avoid = 1;
|
||||||
}
|
}
|
||||||
if (should_score)
|
if (P_MatchEntKey(ent->key, player->spawn))
|
||||||
|
{
|
||||||
|
// Avoid old spawn
|
||||||
|
should_avoid = 1;
|
||||||
|
}
|
||||||
|
if (should_avoid)
|
||||||
{
|
{
|
||||||
for (SpawnNode *spawn = first_spawn; spawn; spawn = spawn->next)
|
for (SpawnNode *spawn = first_spawn; spawn; spawn = spawn->next)
|
||||||
{
|
{
|
||||||
// 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)
|
// if (score < 10)
|
||||||
{
|
{
|
||||||
spawn->score = MinF32(spawn->score, score);
|
spawn->score = MinF32(spawn->score, score);
|
||||||
}
|
}
|
||||||
@ -1932,16 +1938,12 @@ void P_StepFrame(P_Frame *frame)
|
|||||||
i64 highest_score = -Inf;
|
i64 highest_score = -Inf;
|
||||||
for (SpawnNode *spawn = first_spawn; spawn; spawn = spawn->next)
|
for (SpawnNode *spawn = first_spawn; spawn; spawn = spawn->next)
|
||||||
{
|
{
|
||||||
b32 ignore_spawn = spawns_count > 1 && P_MatchEntKey(spawn->ent->key, player->spawn);
|
f32 rand_score_spread = 10;
|
||||||
if (!ignore_spawn)
|
f32 virtual_score = spawn->score + rand_score_spread * Norm24(RandU64FromState(&world->rand));
|
||||||
|
if (virtual_score > highest_score)
|
||||||
{
|
{
|
||||||
f32 rand_score_spread = 5;
|
highest_score = virtual_score;
|
||||||
f32 virtual_score = spawn->score + rand_score_spread * Norm24(RandU64FromState(&world->rand));
|
highest_scoring_spawn = spawn->ent;
|
||||||
if (virtual_score > highest_score)
|
|
||||||
{
|
|
||||||
highest_score = virtual_score;
|
|
||||||
highest_scoring_spawn = spawn->ent;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2046,9 +2048,6 @@ void P_StepFrame(P_Frame *frame)
|
|||||||
// 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.1, 0, 50);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- Bake world
|
//- Bake world
|
||||||
|
|
||||||
@ -2056,6 +2055,7 @@ void P_StepFrame(P_Frame *frame)
|
|||||||
u64 desired_bake_hash = world->tiles_hash;
|
u64 desired_bake_hash = world->tiles_hash;
|
||||||
if (desired_bake_hash != world->baked_hash)
|
if (desired_bake_hash != world->baked_hash)
|
||||||
{
|
{
|
||||||
|
LogDebugF("Bake step");
|
||||||
ResetArena(world->bake_arena);
|
ResetArena(world->bake_arena);
|
||||||
world->walls_space = P_SpaceFromWalls(world->bake_arena, frame);
|
world->walls_space = P_SpaceFromWalls(world->bake_arena, frame);
|
||||||
world->baked_hash = desired_bake_hash;
|
world->baked_hash = desired_bake_hash;
|
||||||
@ -2063,18 +2063,13 @@ void P_StepFrame(P_Frame *frame)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- Build pre-solve ents space
|
//- Build pre-solve space from ents
|
||||||
|
|
||||||
P_Space ents_space = P_SpaceFromEnts(scratch.arena, frame);
|
|
||||||
|
|
||||||
|
P_Space pre_solve_ents_space = P_SpaceFromEnts(scratch.arena, frame);
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- Generate guy constraints
|
//- Generate guy constraints
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: Not like this
|
|
||||||
|
|
||||||
for (P_Ent *ent0 = P_FirstEnt(frame); !P_IsEntNil(ent0); ent0 = P_NextEnt(ent0))
|
for (P_Ent *ent0 = P_FirstEnt(frame); !P_IsEntNil(ent0); ent0 = P_NextEnt(ent0))
|
||||||
{
|
{
|
||||||
if (ent0->is_guy)
|
if (ent0->is_guy)
|
||||||
@ -2093,7 +2088,7 @@ void P_StepFrame(P_Frame *frame)
|
|||||||
for (i32 query_x = query_rect.p0.x; query_x < query_rect.p1.x; ++query_x)
|
for (i32 query_x = query_rect.p0.x; query_x < query_rect.p1.x; ++query_x)
|
||||||
{
|
{
|
||||||
P_SpaceCell cells[] = {
|
P_SpaceCell cells[] = {
|
||||||
P_SpaceCellFromPos(&ents_space, VEC2(query_x, query_y)),
|
P_SpaceCellFromPos(&pre_solve_ents_space, VEC2(query_x, query_y)),
|
||||||
P_SpaceCellFromPos(&world->walls_space, VEC2(query_x, query_y)),
|
P_SpaceCellFromPos(&world->walls_space, VEC2(query_x, query_y)),
|
||||||
};
|
};
|
||||||
for (i64 cell_idx = 0; cell_idx < countof(cells); ++cell_idx)
|
for (i64 cell_idx = 0; cell_idx < countof(cells); ++cell_idx)
|
||||||
@ -2558,7 +2553,6 @@ void P_StepFrame(P_Frame *frame)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- Integrate velocities
|
//- Integrate velocities
|
||||||
|
|
||||||
@ -2574,6 +2568,11 @@ void P_StepFrame(P_Frame *frame)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
//- Build post-solve space from ents
|
||||||
|
|
||||||
|
// P_Space post_solve_ents_space = P_SpaceFromEnts(scratch.arena, frame);
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- Move bullets
|
//- Move bullets
|
||||||
|
|
||||||
|
|||||||
@ -88,7 +88,7 @@ void S_TickForever(WaveLaneCtx *lane)
|
|||||||
while (!shutdown)
|
while (!shutdown)
|
||||||
{
|
{
|
||||||
shutdown = Atomic32Fetch(&S.shutdown);
|
shutdown = Atomic32Fetch(&S.shutdown);
|
||||||
P_tl.debug_draw_enabled = TweakBool("Simulation debug draw", 1);
|
P_tl.debug_draw_enabled = TweakBool("Simulation debug draw", 0);
|
||||||
ResetArena(frame_arena);
|
ResetArena(frame_arena);
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
|
|||||||
@ -524,7 +524,7 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
while (!shutdown)
|
while (!shutdown)
|
||||||
{
|
{
|
||||||
shutdown = Atomic32Fetch(&V.shutdown);
|
shutdown = Atomic32Fetch(&V.shutdown);
|
||||||
P_tl.debug_draw_enabled = TweakBool("Vis debug draw", 1);
|
P_tl.debug_draw_enabled = TweakBool("Vis debug draw", 0);
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- Begin frame
|
//- Begin frame
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user