diff --git a/src/config.h b/src/config.h index b1ce3efb..1e7be96f 100644 --- a/src/config.h +++ b/src/config.h @@ -39,7 +39,8 @@ #define SIM_TILES_PER_UNIT_SQRT (4) #define SIM_TILES_PER_CHUNK_SQRT (16) -#define SIM_TICKS_PER_SECOND 100 +// #define SIM_TICKS_PER_SECOND 100 +#define SIM_TICKS_PER_SECOND 64 // Like USER_INTERP_RATIO, but applies to snapshots received by the local sim from the // master sim (how far back in time should the client render the server's state) #define SIM_CLIENT_INTERP_RATIO 2.0 diff --git a/src/gpu/gpu_dx12/gpu_dx12_core.c b/src/gpu/gpu_dx12/gpu_dx12_core.c index 6a0640dc..55f37e94 100644 --- a/src/gpu/gpu_dx12/gpu_dx12_core.c +++ b/src/gpu/gpu_dx12/gpu_dx12_core.c @@ -2900,8 +2900,6 @@ G_ResourceHandle G_PrepareBackbuffer(G_SwapchainHandle swapchain_handle, G_Forma hr = IDXGISwapChain1_QueryInterface(swapchain1, &IID_IDXGISwapChain3, (void **)&swapchain3); IDXGISwapChain1_Release(swapchain1); } - - } swapchain->d3d_swapchain = swapchain3; swapchain->backbuffers_format = format; diff --git a/src/pp/pp.c b/src/pp/pp.c index 8d51297a..4f6025be 100644 --- a/src/pp/pp.c +++ b/src/pp/pp.c @@ -1,5 +1,5 @@ P_Ctx P = Zi; -P_ThreadLocalCtx P_tl = Zi; +ThreadLocal P_ThreadLocalCtx P_tl = Zi; Readonly P_Ent P_NilEnt = { .xf = CompXformIdentity, @@ -22,9 +22,6 @@ void P_Bootstrap(void) P_OutputState *output = &P.sim_output_states[i]; output->arena = AcquireArena(Gibi(64)); } - - // Initialize thread state - P_tl.debug_arena = AcquireArena(Gibi(64)); } //////////////////////////////////////////////////////////// @@ -225,6 +222,15 @@ P_Shape P_LocalShapeFromEnt(P_Ent *ent) .radius = 0.3, ); + // f32 player_width = 0.6; + // f32 player_height = 0.3; + // result = P_ShapeFromDesc( + // .mass = 10, + // .count = 2, + // .points = { VEC2(-player_width / 2 + (player_height / 2), 0), VEC2(player_width / 2 - (player_height / 2), 0) }, + // .radius = player_height / 2, + // ); + // Rng2 test_rect = Zi; // test_rect.p0 = VEC2(-1, -1); // test_rect.p1 = VEC2(1, 1); diff --git a/src/pp/pp_sim/pp_sim_core.c b/src/pp/pp_sim/pp_sim_core.c index 26f40f58..57ae4665 100644 --- a/src/pp/pp_sim/pp_sim_core.c +++ b/src/pp/pp_sim/pp_sim_core.c @@ -22,6 +22,7 @@ void S_TickForever(WaveLaneCtx *lane) { Arena *perm = PermArena(); Arena *frame_arena = AcquireArena(Gibi(64)); + P_tl.debug_arena = AcquireArena(Gibi(64)); Arena *world_arena = AcquireArena(Gibi(64)); P_World *world = 0; @@ -29,6 +30,7 @@ void S_TickForever(WaveLaneCtx *lane) // TODO: Real per-client deltas b32 has_sent_initial_tick = 0; + ////////////////////////////// //- Sim loop @@ -344,8 +346,8 @@ void S_TickForever(WaveLaneCtx *lane) // TODO: Real masses f32 inv_m0 = 10; f32 inv_m1 = 10; - f32 inv_i0 = 10; - f32 inv_i1 = 10; + f32 inv_i0 = 0; + f32 inv_i1 = 0; constraint->ent0 = ent0->key; constraint->ent1 = ent1->key; @@ -775,12 +777,12 @@ void S_TickForever(WaveLaneCtx *lane) b32 apply_bias = 1; if (separation > 0.0) { - /* Speculative */ + // Speculative velocity_bias = separation / solver_dt; } else if (apply_bias) { - /* Soft constraint */ + // Soft constraint SoftSpring softness = MakeSpring(contact_spring_hz, contact_spring_damp, solver_dt); // f32 pushout_velocity = constraint->pushout_velocity; f32 pushout_velocity = 3.0; @@ -795,7 +797,7 @@ void S_TickForever(WaveLaneCtx *lane) f32 k = contact->inv_normal_mass; - /* (to be applied along n) */ + // (to be applied along n) f32 vn = DotVec2(vrel, normal); f32 j = ((k * mass_scale) * (vn - velocity_bias)) - (contact->solved_normal_impulse * impulse_scale); @@ -825,7 +827,7 @@ void S_TickForever(WaveLaneCtx *lane) f32 k = contact->inv_tangent_mass; - /* (to be applied along t) */ + // (to be applied along t) f32 vt = DotVec2(vrel, tangent); f32 j = vt * k; diff --git a/src/pp/pp_vis/pp_vis_core.c b/src/pp/pp_vis/pp_vis_core.c index 9de15255..a9dcd26c 100644 --- a/src/pp/pp_vis/pp_vis_core.c +++ b/src/pp/pp_vis/pp_vis_core.c @@ -325,6 +325,7 @@ void V_TickForever(WaveLaneCtx *lane) { Arena *perm = PermArena(); G_ArenaHandle gpu_perm = G_PermArena(); + P_tl.debug_arena = AcquireArena(Gibi(64)); const i32 world_pitch = P_WorldPitch; const f32 zoom_rate = 1.50; @@ -489,7 +490,7 @@ void V_TickForever(WaveLaneCtx *lane) while (!shutdown) { shutdown = Atomic32Fetch(&V.shutdown); - P_tl.debug_draw_enabled = 1; + P_tl.debug_draw_enabled = TweakBool("Vis debug draw", 1); ////////////////////////////// //- Begin frame @@ -584,7 +585,7 @@ void V_TickForever(WaveLaneCtx *lane) frame->window_restore = BB_ReadString(frame->arena, &br); } - // Write swapout + //- Write swapout if (swapout) { WriteSwappedState(Lit("pp_vis.swp"), STRING(BB_GetNumBytesWritten(&bw), BB_GetWrittenRaw(&bw))); @@ -3053,6 +3054,7 @@ void V_TickForever(WaveLaneCtx *lane) last_debug_draw_node = P_tl.last_debug_draw_node; } + // Push draws for (P_DebugDrawNode *n = first_debug_draw_node; n; n = n->next) { Vec4 color = Vec4FromU32(n->srgb32); @@ -3085,7 +3087,6 @@ void V_TickForever(WaveLaneCtx *lane) { P_Shape ui_shape = P_MulXformShape(frame->xf.world_to_ui, n->shape); V_DrawShape(ui_shape, color, detail, V_DrawFlag_Line); - // V_DrawShape(ui_shape, color, detail, V_DrawFlag_None); } break; } }