convert indentation to 2 spaces

This commit is contained in:
jacob 2025-12-18 18:42:53 -06:00
parent c1b768282f
commit 3377e3f94c
133 changed files with 30495 additions and 31007 deletions

View File

@ -497,9 +497,11 @@ ASE_DecodedImage ASE_DecodeImage(Arena *arena, String encoded)
if (ase_header.color_depth != 32)
{
String msg = StringF(scratch.arena,
String msg = StringF(
scratch.arena,
"Only 32 bit rgba color mode is supported (got %F)",
FmtUint(ase_header.color_depth));
FmtUint(ase_header.color_depth)
);
ASE_PushError(arena, &result.errors, msg);
goto abort;
}
@ -574,9 +576,11 @@ ASE_DecodedImage ASE_DecodeImage(Arena *arena, String encoded)
layer->blend_mode = BB_ReadUBits(&br, 16);
if (layer->blend_mode != 0)
{
ASE_PushError(arena,
ASE_PushError(
arena,
&result.errors,
Lit("Layer has unsupported blend mode (only 'Normal' mode is supported). Tip: Try using 'merge down' to create a normal layer as a workaround"));
Lit("Layer has unsupported blend mode (only 'Normal' mode is supported). Tip: Try using 'merge down' to create a normal layer as a workaround")
);
goto abort;
}

View File

@ -783,7 +783,8 @@ String FormatString(Arena *arena, String fmt, FmtArgArray args)
}
}
#if IsRtcEnabled
if (IsRtcEnabled)
{
if (!no_more_valid_args)
{
FmtArg last_arg = Zi;
@ -794,7 +795,7 @@ String FormatString(Arena *arena, String fmt, FmtArgArray args)
Assert(last_arg.kind == FmtArgKind_End);
}
}
#endif
}
return result;
}

View File

@ -47,8 +47,10 @@ Utf8DecodeResult DecodeUtf8(String str)
{
u8 c1 = str.text[1];
u8 c2 = str.text[2];
if (lengths[c1 >> 3] == 0 &&
lengths[c2 >> 3] == 0)
if (
lengths[c1 >> 3] == 0 &&
lengths[c2 >> 3] == 0
)
{
codepoint = (c2 & 0x3F) << 0;
codepoint |= (c1 & 0x3F) << 6;
@ -65,9 +67,11 @@ Utf8DecodeResult DecodeUtf8(String str)
u8 c1 = str.text[1];
u8 c2 = str.text[2];
u8 c3 = str.text[3];
if (lengths[c1 >> 3] == 0 &&
if (
lengths[c1 >> 3] == 0 &&
lengths[c2 >> 3] == 0 &&
lengths[c3 >> 3] == 0)
lengths[c3 >> 3] == 0
)
{
codepoint = (c3 & 0x3F) << 0;
codepoint |= (c2 & 0x3F) << 6;

View File

@ -34,12 +34,14 @@ typedef void WaveLaneEntryFunc(WaveLaneCtx *lane);
//~ Wave sync ops
void WaveSyncEx(WaveLaneCtx *lane, u64 spin_count);
void WaveSyncBroadcastEx_(WaveLaneCtx *lane, u32 broadcast_lane_idx, void *broadcast_ptr, u64 broadcast_size, u64 spin_count);
#define WaveSync(lane) \
WaveSyncEx((lane), (lane)->default_spin_count)
void WaveSyncBroadcastEx_(WaveLaneCtx *lane, u32 broadcast_lane_idx, void *broadcast_ptr, u64 broadcast_size, u64 spin_count);
#define WaveSyncBroadcastEx(lane, broadcast_lane_idx, broadcast_ptr, spin_count) \
WaveSyncBroadcastEx_((lane), (broadcast_lane_idx), (broadcast_ptr), sizeof(*(broadcast_ptr)), (spin_count))
#define WaveSyncBroadcast(lane, broadcast_lane_idx, broadcast_ptr) \
WaveSyncBroadcastEx_((lane), (broadcast_lane_idx), (broadcast_ptr), sizeof(*(broadcast_ptr)), (lane)->default_spin_count)

View File

@ -533,7 +533,6 @@ int CALLBACK wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev_instance,
//~ Crt stub
#if !IsCrtlibEnabled
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-variable-declarations"
#pragma clang diagnostic ignored "-Wmissing-prototypes"
@ -550,5 +549,4 @@ void __stdcall wWinMainCRTStartup(void)
}
#pragma clang diagnostic pop
#endif /* !IsCrtlibEnabled */

View File

@ -186,14 +186,16 @@ CLD_GjkData CLD_GjkDataFromShapes(CLD_Shape *shape0, CLD_Shape *shape1, Xform xf
CLD_DBGSTEP;
m = CLD_MenkowskiPointFromDir(shape0, shape1, xf0, xf1, dir);
/* Check that new point is far enough away from existing points */
if (Vec2LenSq(SubVec2(m.p, s.a.p)) < min_unique_pt_dist_sq ||
Vec2LenSq(SubVec2(m.p, s.b.p)) < min_unique_pt_dist_sq ||
(
if (
Vec2LenSq(SubVec2(m.p, s.a.p)) < min_unique_pt_dist_sq ||
Vec2LenSq(SubVec2(m.p, s.b.p)) < min_unique_pt_dist_sq || (
(num_removed >= 1) && (
(Vec2LenSq(SubVec2(m.p, removed_a)) < min_unique_pt_dist_sq) ||
(num_removed >= 2 && Vec2LenSq(SubVec2(m.p, removed_b)) < min_unique_pt_dist_sq))
(num_removed >= 2 && Vec2LenSq(SubVec2(m.p, removed_b)) < min_unique_pt_dist_sq)
)
) ||
AbsF32(WedgeVec2(SubVec2(s.b.p, s.a.p), SubVec2(m.p, s.a.p))) < min_unique_pt_dist_sq)
AbsF32(WedgeVec2(SubVec2(s.b.p, s.a.p), SubVec2(m.p, s.a.p))) < min_unique_pt_dist_sq
)
{
overlapping = 0;
break;

View File

@ -611,58 +611,80 @@ void *G_HostPointerFromResource(G_ResourceHandle resource);
u32 G_PushRef(G_ArenaHandle arena, G_ResourceHandle resource, G_RefDesc desc);
#define G_PushStructuredBufferRef(arena, resource, type, ...)(G_StructuredBufferRef) { \
.v = G_PushRef((arena), (resource), \
(G_RefDesc) { .kind = G_RefKind_StructuredBuffer, .element_size = sizeof(type), __VA_ARGS__ }) \
.v = G_PushRef( \
(arena), (resource), \
(G_RefDesc) { .kind = G_RefKind_StructuredBuffer, .element_size = sizeof(type), __VA_ARGS__ } \
) \
}
#define G_PushRWStructuredBufferRef(arena, resource, type, ...)(G_RWStructuredBufferRef) { \
.v = G_PushRef((arena), (resource), \
(G_RefDesc) { .kind = G_RefKind_RWStructuredBuffer, .element_size = sizeof(type), __VA_ARGS__ }) \
.v = G_PushRef( \
(arena), (resource), \
(G_RefDesc) { .kind = G_RefKind_RWStructuredBuffer, .element_size = sizeof(type), __VA_ARGS__ } \
) \
}
#define G_PushByteAddressBufferRef(arena, resource, ...)(G_ByteAddressBufferRef) { \
.v = G_PushRef((arena), (resource), \
(G_RefDesc) { .kind = G_RefKind_ByteAddressBuffer, __VA_ARGS__ }) \
.v = G_PushRef( \
(arena), (resource), \
(G_RefDesc) { .kind = G_RefKind_ByteAddressBuffer, __VA_ARGS__ } \
) \
}
#define G_PushRWByteAddressBufferRef(arena, resource, ...)(G_RWByteAddressBufferRef) { \
.v = G_PushRef((arena), (resource), \
(G_RefDesc) { .kind = G_RefKind_RWByteAddressBuffer, __VA_ARGS__ }) \
.v = G_PushRef( \
(arena), (resource), \
(G_RefDesc) { .kind = G_RefKind_RWByteAddressBuffer, __VA_ARGS__ } \
) \
}
#define G_PushTexture1DRef(arena, resource, ...)(G_Texture1DRef) { \
.v = G_PushRef((arena), (resource), \
(G_RefDesc) { .kind = G_RefKind_Texture1D, __VA_ARGS__ }) \
.v = G_PushRef( \
(arena), (resource), \
(G_RefDesc) { .kind = G_RefKind_Texture1D, __VA_ARGS__ } \
) \
}
#define G_PushRWTexture1DRef(arena, resource, ...)(G_RWTexture1DRef) { \
.v = G_PushRef((arena), (resource), \
(G_RefDesc) { .kind = G_RefKind_RWTexture1D, __VA_ARGS__ }) \
.v = G_PushRef( \
(arena), (resource), \
(G_RefDesc) { .kind = G_RefKind_RWTexture1D, __VA_ARGS__ } \
) \
}
#define G_PushTexture2DRef(arena, resource, ...)(G_Texture2DRef) { \
.v = G_PushRef((arena), (resource), \
(G_RefDesc) { .kind = G_RefKind_Texture2D, __VA_ARGS__ }) \
.v = G_PushRef( \
(arena), (resource), \
(G_RefDesc) { .kind = G_RefKind_Texture2D, __VA_ARGS__ } \
) \
}
#define G_PushRWTexture2DRef(arena, resource, ...)(G_RWTexture2DRef) { \
.v = G_PushRef((arena), (resource), \
(G_RefDesc) { .kind = G_RefKind_RWTexture2D, __VA_ARGS__ }) \
.v = G_PushRef( \
(arena), (resource), \
(G_RefDesc) { .kind = G_RefKind_RWTexture2D, __VA_ARGS__ } \
) \
}
#define G_PushTexture3DRef(arena, resource, ...)(G_Texture3DRef) { \
.v = G_PushRef((arena), (resource), \
(G_RefDesc) { .kind = G_RefKind_Texture3D, __VA_ARGS__ }) \
.v = G_PushRef( \
(arena), (resource), \
(G_RefDesc) { .kind = G_RefKind_Texture3D, __VA_ARGS__ } \
) \
}
#define G_PushRWTexture3DRef(arena, resource, ...)(G_RWTexture3DRef) { \
.v = G_PushRef((arena), (resource), \
(G_RefDesc) { .kind = G_RefKind_RWTexture3D, __VA_ARGS__ }) \
.v = G_PushRef( \
(arena), (resource), \
(G_RefDesc) { .kind = G_RefKind_RWTexture3D, __VA_ARGS__ } \
) \
}
#define G_PushSamplerStateRef(arena, resource, ...)(G_SamplerStateRef) { \
.v = G_PushRef((arena), (resource), \
(G_RefDesc) { .kind = G_RefKind_SamplerState, __VA_ARGS__ }) \
.v = G_PushRef( \
(arena), (resource), \
(G_RefDesc) { .kind = G_RefKind_SamplerState, __VA_ARGS__ } \
) \
}
////////////////////////////////////////////////////////////

View File

@ -18,7 +18,7 @@ void G_Bootstrap(void)
/* Enable debug layer */
u32 dxgi_factory_flags = 0;
#if GPU_DEBUG
if (GPU_DEBUG)
{
ID3D12Debug *debug_controller0 = 0;
{
@ -28,7 +28,7 @@ void G_Bootstrap(void)
Panic(Lit("Failed to create ID3D12Debug0"));
}
ID3D12Debug_EnableDebugLayer(debug_controller0);
#if GPU_DEBUG_VALIDATION
if (GPU_DEBUG_VALIDATION)
{
ID3D12Debug1 *debug_controller1 = 0;
{
@ -41,12 +41,10 @@ void G_Bootstrap(void)
}
ID3D12Debug_Release(debug_controller1);
}
#endif
}
ID3D12Debug_Release(debug_controller0);
dxgi_factory_flags |= DXGI_CREATE_FACTORY_DEBUG;
}
#endif
/* Create factory */
{
@ -119,8 +117,8 @@ void G_Bootstrap(void)
}
/* Enable debug layer breaks */
if (GPU_DEBUG)
{
#if GPU_DEBUG
/* Enable D3D12 Debug break */
{
ID3D12InfoQueue *info = 0;
@ -145,7 +143,6 @@ void G_Bootstrap(void)
IDXGIInfoQueue_SetBreakOnSeverity(dxgi_info, DXGI_DEBUG_ALL, DXGI_INFO_QUEUE_MESSAGE_SEVERITY_ERROR, 1);
IDXGIInfoQueue_Release(dxgi_info);
}
#endif
}
}

View File

@ -16,9 +16,10 @@
#define G_D12_TearingIsAllowed 1
#define G_D12_FrameLatency 1
#define G_D12_SwapchainBufferCount 3
#define G_D12_SwapchainFlags (((G_D12_TearingIsAllowed != 0) * DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING) \
| ((G_D12_FrameLatency != 0) * DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT))
#define G_D12_SwapchainFlags (0 \
| ((G_D12_TearingIsAllowed != 0) * DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING) \
| ((G_D12_FrameLatency != 0) * DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT) \
)
#define G_D12_MaxCbvSrvUavDescriptors (1024 * 128)
#define G_D12_MaxSamplerDescriptors (1024 * 1)

View File

@ -637,12 +637,10 @@ String interpret_string(Arena *arena, String src, String *error)
} break;
/* TODO: Unicode escape support */
#if 0
case 'u':
{
/* TODO */
} break;
#endif
// case 'u':
// {
// /* TODO */
// } break;
}
}
else

View File

@ -69,10 +69,12 @@ String StringFromMetaErrors(Arena *arena, M_ErrorList errors)
if (token_file.len > 0)
{
i64 token_pos = -1;
if (token->s.len > 0
if (
token->s.len > 0
&& token_file_data.len > 0
&& token->s.text > token_file_data.text
&& token->s.text < (token_file_data.text + token_file_data.len))
&& token->s.text < (token_file_data.text + token_file_data.len)
)
{
token_pos = token->s.text - token_file_data.text;
}

View File

@ -441,9 +441,11 @@ void P_WriteFile(P_File file, String data)
if (data.len >= 0x7FFF)
{
TempArena scratch = BeginScratchNoConflict();
Panic(StringF(scratch.arena,
Panic(StringF(
scratch.arena,
"Tried to write too many bytes to disk (%F)",
FmtUint(data.len)));
FmtUint(data.len)
));
EndScratch(scratch);
}
@ -598,15 +600,13 @@ P_Address P_AddressFromIpPortCstr(char *ip_cstr, char *port_cstr)
else if (ai_result->ai_family == AF_INET6)
{
/* TODO: Enable ipv6 */
#if 0
struct sockaddr_in6 *sockaddr = (struct sockaddr_in6 *)ai_result->ai_addr;
result.valid = 1;
result.family = P_AddressFamily_Ipv6;
result.portnb = sockaddr->sin6_port;
StaticAssert(sizeof(sockaddr->sin6_addr) == 16);
CopyBytes(result.ipnb, (void *)&sockaddr->sin6_addr, 16);
break;
#endif
// struct sockaddr_in6 *sockaddr = (struct sockaddr_in6 *)ai_result->ai_addr;
// result.valid = 1;
// result.family = P_AddressFamily_Ipv6;
// result.portnb = sockaddr->sin6_port;
// StaticAssert(sizeof(sockaddr->sin6_addr) == 16);
// CopyBytes(result.ipnb, (void *)&sockaddr->sin6_addr, 16);
// break;
}
ai_result = ai_result->ai_next;
}
@ -850,13 +850,14 @@ P_SockReadResult P_ReadSock(Arena *arena, P_Sock *sock)
}
else
{
#if IsRtcEnabled
if (IsRtcEnabled)
{
i32 err = WSAGetLastError();
if (err != WSAEWOULDBLOCK && err != WSAETIMEDOUT && err != WSAECONNRESET)
{
Assert(0);
}
#endif
}
}
return result;
@ -871,13 +872,14 @@ void P_WriteSock(P_Sock *sock, P_Address address, String data)
{
AddGstat(SockBytesSent, size);
}
#if IsRtcEnabled
if (IsRtcEnabled)
{
if (size != (i32)data.len)
{
i32 err = WSAGetLastError();
Assert(0);
}
#endif
}
}
////////////////////////////////////////////////////////////

View File

@ -162,16 +162,17 @@ void PB_WSP_EndUpdate(PB_WSP_Buff *wspbuf, MIX_PcmF32 src)
else
{
/* Submit silence if not enough samples */
flags = AUDCLNT_BUFFERFLAGS_SILENT;
flags |= AUDCLNT_BUFFERFLAGS_SILENT;
/* This shouldn't occur, mixer should be generating samples equivilent
* to value returned from `PB_WSP_BeginUpdate`. */
Assert(0);
}
#if !AUDIO_ENABLED
flags = AUDCLNT_BUFFERFLAGS_SILENT;
#endif
if (!AUDIO_ENABLED)
{
flags |= AUDCLNT_BUFFERFLAGS_SILENT;
}
/* Submit output buffer to WASAPI */
IAudioRenderClient_ReleaseBuffer(g->playback, frames_in_source, flags);

View File

@ -289,7 +289,6 @@ void V_EndCommandsWidget(V_CommandsWidget *widget)
UI_SetNext(Flags, UI_BoxFlag_DrawText | UI_BoxFlag_Interactable);
UI_PushCP(UI_BuildRowEx(hotkey_key));
{
}
UI_PopCP(UI_TopCP());
}
@ -839,22 +838,22 @@ void V_TickForever(WaveLaneCtx *lane)
if (frame->is_editing)
{
Struct(DfsNode) { DfsNode *next; b32 visited; V_Space *space; UI_Checkpoint cp; };
DfsNode *first_dfs = PushStruct(frame->arena, DfsNode);
first_dfs->space = V.root_space;
Struct(SpaceDfsNode) { SpaceDfsNode *next; b32 visited; V_Space *space; UI_Checkpoint cp; };
SpaceDfsNode *first_space_dfs = PushStruct(frame->arena, SpaceDfsNode);
first_space_dfs->space = V.root_space;
while (first_dfs)
while (first_space_dfs)
{
DfsNode *dfs = first_dfs;
V_Space *space = dfs->space;
if (!dfs->visited)
SpaceDfsNode *space_dfs = first_space_dfs;
V_Space *space = space_dfs->space;
if (!space_dfs->visited)
{
dfs->visited = 1;
space_dfs->visited = 1;
for (V_Space *child = space->last; child; child = child->prev)
{
DfsNode *n = PushStruct(frame->arena, DfsNode);
SpaceDfsNode *n = PushStruct(frame->arena, SpaceDfsNode);
n->space = child;
SllStackPush(first_dfs, n);
SllStackPush(first_space_dfs, n);
}
UI_Key space_key = UI_TransKey();
@ -866,7 +865,7 @@ void V_TickForever(WaveLaneCtx *lane)
{
UI_BuildColumnEx(space_key);
}
dfs->cp = UI_PushCP(space_key);
space_dfs->cp = UI_PushCP(space_key);
for (V_Panel *panel = space->first_panel; panel; panel = panel->next_in_space)
{
@ -932,8 +931,8 @@ void V_TickForever(WaveLaneCtx *lane)
}
else
{
UI_PopCP(dfs->cp);
SllStackPop(first_dfs);
UI_PopCP(space_dfs->cp);
SllStackPop(first_space_dfs);
}
}
}

View File

@ -138,14 +138,6 @@ void PP_DrawDebugXform(Xform xf, u32 color_x, u32 color_y)
#if 0
D_DrawArrowRay(g->render_sig, pos, x_ray, thickness, arrowhead_len, color_x);
D_DrawArrowRay(g->render_sig, pos, y_ray, thickness, arrowhead_len, color_y);
#else
LAX x_ray;
LAX y_ray;
LAX thickness;
LAX arrowhead_len;
LAX pos;
LAX color_x;
LAX color_y;
#endif
//u32 color_quad = Rgba32F(0, 1, 1, 0.3);
@ -172,17 +164,7 @@ void PP_DrawDebugMovement(PP_Ent *ent)
if (Vec2Len(vel_ray) > 0.00001)
{
/* FIXME: Enable this */
#if 0
D_DrawArrowRay(g->render_sig, pos, vel_ray, thickness, arrow_len, color_vel);
#else
LAX thickness;
LAX arrow_len;
LAX color_vel;
LAX xf;
LAX velocity;
LAX pos;
LAX vel_ray;
#endif
}
}
@ -963,113 +945,6 @@ void PP_UpdateUser(void)
mat->xf = XformFromRect(RectFromVec2(pos, size));
}
#if 0
//- Acquire / release tile cache entries
/* Acquire entries from new sim chunks */
for (u64 ent_index = 0; ent_index < g->ss_blended->num_ents_reserved; ++ent_index)
{
PP_Ent *chunk_ent = &g->ss_blended->ents[ent_index];
if (PP_IsValidAndActive(chunk_ent) && PP_HasProp(chunk_ent, PP_Prop_TileChunk))
{
struct user_tile_cache_entry *entry = user_tile_cache_entry_from_chunk_pos(chunk_ent->tile_chunk_pos);
if (!entry->valid)
{
entry = user_tile_cache_entry_acquire(chunk_ent->tile_chunk_pos);
}
}
}
/* Release entries with invalid sim chunks */
for (u64 entry_index = 0; entry_index < g->tile_cache.num_reserved_entries; ++entry_index)
{
struct tile_cache_entry *entry = &g->tile_cache.entries[entry_index];
if (entry->valid)
{
PP_Ent *chunk_ent = sim_ent_from_chunk_pos(entry->pos);
if (!chunk_ent->valid)
{
user_tile_cache_entry_release(entry);
}
}
}
//- Draw dirty tile cache entries
for (u64 entry_index = 0; entry_index < g->tile_cache.num_reserved_entries; ++entry_index)
{
struct tile_cache_entry *entry = &g->tile_cache.entries[entry_index];
if (entry->valid)
{
Vec2I32 chunk_pos = entry->pos;
PP_Ent *chunk_ent = sim_ent_from_chunk_pos(chunk_pos);
if (entry->applied_dirty_gen != chunk_ent->dirty_gen)
{
entry->applied_dirty_gen = chunk_ent->dirty_gen;
/* TODO: Autotiling */
String data = sim_ent_get_chunk_tile_data(chunk_ent);
u64 tile_count = data.len;
if (tile_count == SIM_TILES_PER_CHUNK_SQRT * SIM_TILES_PER_CHUNK_SQRT)
{
for (u64 y_in_chunk = 0; y_in_chunk < SIM_TILES_PER_CHUNK_SQRT; ++y_in_chunk)
{
for (u64 x_in_chunk = 0; x_in_chunk < SIM_TILES_PER_CHUNK_SQRT; ++x_in_chunk)
{
}
}
}
else
{
/* TODO: Clear gpu buffer if it exists */
}
}
}
}
#if 0
for (u64 entry_index = 0; entry_index < g->tile_cache.num_reserved_entries; ++entry_index)
{
struct tile_cache_entry *entry = &g->tile_cache.entries[entry_index];
if (entry->valid)
{
Vec2I32 chunk_pos = entry->pos;
PP_Ent *chunk_ent = sim_ent_from_chunk_pos(chunk_pos);
if (entry->applied_dirty_gen != chunk_ent->dirty_gen)
{
entry->applied_dirty_gen = chunk_ent->dirty_gen;
/* Retreive surrounding chunk info since we're auto-tiling
* [TL] [T] [TR]
* [L ] X [R ]
* [BL] [B] [BR]
*/
Vec2I32 chunk_pos_tl = VEC2I32(chunk_pos.x - 1, chunk_pos.y - 1);
Vec2I32 chunk_pos_t = VEC2I32(chunk_pos.x, chunk_pos.y - 1);
Vec2I32 chunk_pos_tr = VEC2I32(chunk_pos.x + 1, chunk_pos.y - 1);
Vec2I32 chunk_pos_l = VEC2I32(chunk_pos.x - 1, chunk_pos.y);
Vec2I32 chunk_pos_r = VEC2I32(chunk_pos.x + 1, chunk_pos.y);
Vec2I32 chunk_pos_bl = VEC2I32(chunk_pos.x - 1, chunk_pos.y + 1);
Vec2I32 chunk_pos_b = VEC2I32(chunk_pos.x, chunk_pos.y + 1);
Vec2I32 chunk_pos_br = VEC2I32(chunk_pos.x + 1, chunk_pos.y + 1);
PP_Ent *chunk_ent_tl = sim_ent_from_chunk_pos(chunk_pos_tl);
PP_Ent *chunk_ent_t = sim_ent_from_chunk_pos(chunk_pos_t);
PP_Ent *chunk_ent_tr = sim_ent_from_chunk_pos(chunk_pos_tr);
PP_Ent *chunk_ent_l = sim_ent_from_chunk_pos(chunk_pos_l);
PP_Ent *chunk_ent_r = sim_ent_from_chunk_pos(chunk_pos_r);
PP_Ent *chunk_ent_bl = sim_ent_from_chunk_pos(chunk_pos_bl);
PP_Ent *chunk_ent_b = sim_ent_from_chunk_pos(chunk_pos_b);
PP_Ent *chunk_ent_br = sim_ent_from_chunk_pos(chunk_pos_br);
String data = sim_ent_get_chunk_tile_data(chunk_ent);
}
}
}
#endif
#endif
//- Sort drawable entities
PP_Ent **sorted = PushDry(scratch.arena, PP_Ent *);
u64 sorted_count = 0;

View File

@ -236,13 +236,12 @@ void PP_SetEntKey(PP_Ent *ent, PP_EntKey key)
/* Insert new key into lookup */
if (!PP_IsNilEntKey(key))
{
#if IsRtcEnabled
if (IsRtcEnabled)
{
PP_Ent *existing = PP_EntFromKey(ss, key);
/* Collision should be extremely unlikely under normal circumstances, there's probably a logic error somewhere. */
Assert(!existing->valid);
}
#endif
PP_EntBin *bin = PP_EntBinFromKey(ss, key);
u32 ent_index = PP_IndexFromEnt(ss, ent);
@ -742,8 +741,6 @@ void PP_SyncEnt(PP_Ent *local, PP_Ent *remote)
PP_EnableProp(local, PP_Prop_SyncDst);
}
#if 1
////////////////////////////////////////////////////////////
//~ Encode
@ -795,74 +792,3 @@ void PP_DecodeEnt(BB_Reader *br, PP_Ent *e)
e->ss = old_ss;
}
#else
////////////////////////////////////////////////////////////
//~ Encode
void PP_EncodeEnt(BB_Writer *bw, PP_Ent *e0, PP_Ent *e1)
{
PP_Snapshot *ss = e1->ss;
/* FIXME: Things like xforms need to be retreived manually rather than memcopied.
* This will also be true for things like ent keys once uids are implemented. */
/* TODO: Granular delta encoding */
u64 pos = 0;
e1->ss = e0->ss;
while (pos < sizeof(*e1))
{
u64 chunk_size = MinU64(pos + 8, sizeof(*e1)) - pos;
u8 *chunk0 = (u8 *)e0 + pos;
u8 *chunk1 = (u8 *)e1 + pos;
if (EqBytes(chunk0, chunk1, chunk_size))
{
BB_WriteBit(bw, 0);
}
else
{
BB_WriteBit(bw, 1);
u64 bits = 0;
CopyBytes(&bits, chunk1, chunk_size);
BB_WriteUBits(bw, bits, 64);
}
pos += 8;
}
e1->ss = ss;
}
////////////////////////////////////////////////////////////
//~ Decode
void PP_DecodeEnt(BB_Reader *br, PP_Ent *e)
{
PP_Ent decoded = *e;
{
u64 pos = 0;
while (pos < sizeof(decoded))
{
u8 *chunk = (u8 *)&decoded + pos;
if (BB_ReadBit(br))
{
u64 chunk_size = MinU64(pos + 8, sizeof(decoded)) - pos;
u64 bits = BB_ReadUBits(br, 64);
CopyBytes(chunk, &bits, chunk_size);
}
pos += 8;
}
}
decoded.ss = e->ss;
PP_EntKey old_id = e->key;
PP_EntKey new_id = decoded.key;
CopyStruct(e, &decoded);
e->key = old_id;
if (!PP_EqEntKey(old_id, new_id))
{
PP_SetEntKey(e, new_id);
}
}
#endif

View File

@ -397,9 +397,11 @@ void PP_PrepareContacts(PP_PhysStepCtx *ctx, u64 phys_iteration)
PP_Ent *e0 = PP_EntFromKey(ss, dbg->e0);
PP_Ent *e1 = PP_EntFromKey(ss, dbg->e1);
if (!(PP_ShouldSimulate(e0) && PP_ShouldSimulate(e1)) ||
if (
!(PP_ShouldSimulate(e0) && PP_ShouldSimulate(e1)) ||
!(PP_HasProp(e0, PP_Prop_Solid) || PP_HasProp(e0, PP_Prop_Sensor)) ||
!(PP_HasProp(e1, PP_Prop_Solid) || PP_HasProp(e1, PP_Prop_Sensor)))
!(PP_HasProp(e1, PP_Prop_Solid) || PP_HasProp(e1, PP_Prop_Sensor))
)
{
/* Mark dbg ent for removal */
PP_DisableProp(dbg_ent, PP_Prop_Active);
@ -1066,7 +1068,6 @@ void PP_WarmStartWeldJoints(PP_PhysStepCtx *ctx)
}
#endif
#if 1
PP_Ent *e1 = PP_EntFromKey(ss, joint->e1);
if (PP_ShouldSimulate(e1))
{
@ -1075,9 +1076,6 @@ void PP_WarmStartWeldJoints(PP_PhysStepCtx *ctx)
PP_SetLinearVelocity(e1, AddVec2(e1->linear_velocity, MulVec2(joint->linear_impulse1, inv_m)));
PP_SetAngularVelocity(e1, e1->angular_velocity + joint->angular_impulse1 * inv_i);
}
#else
LAX joint;
#endif
}
}
@ -1331,8 +1329,6 @@ void PP_StepPhys(PP_PhysStepCtx *ctx, f32 timestep)
const u32 max_iterations = 16;
f32 earliest_toi = MaxF32(PP_DetermineEarliestToi(ctx, step_dt, tolerance, max_iterations), min_toi);
step_dt = remaining_dt * earliest_toi;
#else
LAX PP_DetermineEarliestToi;
#endif
}
remaining_dt -= step_dt;

View File

@ -41,7 +41,8 @@ Struct(PP_ContactPoint)
* rather than points fully in local space because contact manifolds
* shouldn't really be affected by rotation accross substeps
* (imagine re-building the manifold of a rotated shape, it would still be
* on the same side of the shape that it originally occured on) */
* on the same side of the shape that it originally occured on)
*/
Vec2 vcp0;
Vec2 vcp1;

View File

@ -768,20 +768,6 @@ void PP_SyncSnapshotEnts(PP_Snapshot *local_ss, PP_Snapshot *remote_ss, PP_EntKe
PP_ReleaseAllWithProp(local_ss, PP_Prop_Release);
}
#if 1
////////////////////////////////////////////////////////////
//~ Snapshot encode
@ -947,296 +933,3 @@ void PP_DecodeSnapshot(BB_Reader *br, PP_Snapshot *ss)
BB_ReadDebugMarker(br, Lit("SNAPSHOT END"));
}
#else
////////////////////////////////////////////////////////////
//~ Snapshot encode
void PP_EncodeSnapshot(BB_Writer *bw, PP_Client *receiver, PP_Snapshot *ss0, PP_Snapshot *ss1)
{
__prof;
BB_WriteIV(bw, ss1->sim_dt_ns);
BB_WriteIV(bw, ss1->sim_time_ns);
BB_WriteUV(bw, ss1->continuity_gen);
BB_WriteUV(bw, ss1->phys_iteration);
BB_WriteUid(bw, receiver->player_id.uid);
/* Ents */
if (ss1->num_ents_allocated == ss0->num_ents_allocated)
{
BB_WriteBit(bw, 0);
}
else
{
BB_WriteBit(bw, 1);
BB_WriteUV(bw, ss1->num_ents_allocated);
}
if (ss1->num_ents_reserved == ss0->num_ents_reserved)
{
BB_WriteBit(bw, 0);
}
else
{
BB_WriteBit(bw, 1);
BB_WriteUV(bw, ss1->num_ents_reserved);
}
BB_AlignWriter(bw);
for (u64 i = 0; i < ss1->num_ents_reserved; ++i)
{
PP_Ent *e0 = PP_NilEnt();
if (i < ss0->num_ents_reserved)
{
e0 = &ss0->ents[i];
}
if (e0->valid != e1->valid)
{
BB_WriteBit(1);
BB_WriteBit(e1->valid);
if (e1->valid)
{
BB_WriteUid(bw, e1->key.uid);
}
}
else
{
BB_WriteBit(0);
}
if (e1->valid)
{
PP_Ent *e1 = &ss1->ents[i];
PP_EncodeEnt(bw, e0, e1);
}
}
}
////////////////////////////////////////////////////////////
//~ Snapshot decode
struct sim_ent_decode_node
{
String tmp_encoded;
};
struct sim_ent_decode_queue
{
struct sim_ent_decode_node *first;
struct sim_ent_decode_node *last;
};
void PP_DecodeSnapshot(BB_Reader *br, PP_Snapshot *ss)
{
__prof;
TempArena scratch = BeginScratchNoConflict();
ss->sim_dt_ns = BB_ReadIV(br);
ss->sim_time_ns = BB_ReadIV(br);
ss->continuity_gen = BB_ReadUV(br);
ss->phys_iteration = BB_ReadUV(br);
ss->local_player = (PP_EntKey){ .uid = BB_ReadUid(br) };
#if 1
if (BB_ReadBit(br))
{
ss->num_ents_allocated = BB_ReadUV(br);
}
if (BB_ReadBit(br))
{
u64 old_num_ents_reserved = ss->num_ents_reserved;
ss->num_ents_reserved = BB_ReadUV(br);
i64 reserve_diff = (i64)ss->num_ents_reserved - (i64)old_num_ents_reserved;
if (reserve_diff > 0)
{
PushStructsNoZero(ss->ents_arena, PP_Ent, reserve_diff);
for (u64 i = old_num_ents_reserved; i < ss->num_ents_reserved; ++i)
{
PP_Ent *e = &ss->ents[i];
*e = *PP_NilEnt();
e->ss = ss;
}
}
}
/* Build decode queue */
struct sim_ent_decode_queue queue;
b32 should_read_ent = BB_ReadBit(br);
while (should_read_ent)
{
/* TODO: Delta decode index based on last read index */
u32 index = BB_ReadUV(br);
b32 allocation_changed = BB_ReadBit(br);
b32 released = 0;
u32 alloc_parent_index = ZI;
PP_EntKey alloc_ent_id = ZI;
if (allocation_changed)
{
released = BB_ReadBit(br);
if (released)
{
PP_Ent *e = sim_ent_from_index(ss, e);
Assert(e->valid); /* An entity that we don't have allocated should never have been marked for release */
if (e->valid)
{
PP_EnableProp(e, PP_Prop_Release);
}
}
else
{
alloc_parent_index = BB_ReadUV();
alloc_ent_id = sim_ent_id_from_uid(BB_ReadUid(br));
}
}
if (!released)
{
u64 num_ent_bits = BB_ReadUV(br);
BB_Reader ent_br = br_from_seek_bits(br, num_ent_bits);
if (BB_NumBitsRemaining(&ent_br) > 0)
{
struct sim_ent_decode_node *n = PushStruct(scratch.arena, struct sim_ent_decode_node);
n->is_new = allocation_changed && !released;
n->index = index;
n->alloc_parent_ndex = alloc_parent_index;
n->alloc_ent_id = alloc_ent_id;
n->br = ent_br;
if (queue.last)
{
queue.last->next = n;
}
else
{
queue.first = n;
}
queue.last = n;
}
}
should_read_ent = BB_ReadBit(br);
}
/* Acquire new ents from decode queue */
for (struct sim_ent_decode_node *n = queue.first; n; n = n->next)
{
if (n->is_new)
{
u32 index = n->index;
PP_Ent *parent = sim_ent_from_index(ss, n->alloc_parent_index);
Assert(!sim_ent_from_index(ss, index)->valid && !PP_EntFromKey(ss, alloc_ent_id)->valid); /* An entity that we have allocated already should never be marked for allocation */
Assert(parent->valid); /* Parent for new entity allocation should always be valid */
if (parent->valid && index < ss->num_ents_reserved)
{
PP_Ent *ent = &ss->ents[index];
ent->valid = 1;
PP_SetEntKey(ent, n->alloc_ent_id);
Link(parent, ent);
}
else
{
/* Received an invalid entity allocation */
Assert(0);
}
}
}
/* Decode ent data from decode queue */
for (struct sim_ent_decode_node *n = queue.first; n; n = n->next)
{
BB_Reader ent_br = n->br;
u32 index = n->index;
PP_Ent *e = sim_ent_from_index(ss, index);
if (e->valid)
{
PP_DecodeEnt(&ent_br, e);
}
else
{
/* Received delta for unallocated ent */
Assert(0);
}
}
#else
/* Ents */
if (BB_ReadBit(br))
{
ss->num_ents_allocated = BB_ReadUV(br);
}
if (BB_ReadBit(br))
{
u64 old_num_ents_reserved = ss->num_ents_reserved;
ss->num_ents_reserved = BB_ReadUV(br);
i64 reserve_diff = (i64)ss->num_ents_reserved - (i64)old_num_ents_reserved;
if (reserve_diff > 0)
{
PushStructsNoZero(ss->ents_arena, PP_Ent, reserve_diff);
for (u64 i = old_num_ents_reserved; i < ss->num_ents_reserved; ++i)
{
PP_Ent *e = &ss->ents[i];
*e = *PP_NilEnt();
e->ss = ss;
}
}
}
for (u64 i = 0; i < ss->num_ents_reserved; ++i)
{
b32 allocation_changed = BB_ReadBit(br);
if (allocation_changed)
{
if (BB_ReadBit(br))
{
struct sim_ent_decode_node *n = PushStruct(scratch.arena, struct sim_ent_decode_node)
}
else
{
PP_EnableProp(e, PP_Prop_Release);
}
}
}
for (u64 i = 0; i < ss->num_ents_reserved; ++i)
{
PP_Ent *e = &ss->ents[i];
e->ss = ss;
b32 valid_changed = BB_ReadBit(br);
b32 allocated = 1;
if (valid_changed)
{
allocated = BB_ReadBit(br);
}
if (!allocated)
{
/* Why is an already released ent being marked as released? */
Assert(e->valid);
if (e->valid)
{
PP_EnableProp(e, PP_Prop_Release);
}
}
else
{
PP_DecodeEnt(br, e);
}
}
PP_ReleaseAllWithProp(ss, PP_Prop_Release);
#endif
EndScratch(scratch);
}
#endif

View File

@ -1312,42 +1312,6 @@ void PP_StepSim(PP_SimStepCtx *ctx)
SPR_Slice slice = SPR_SliceFromKey(sheet, ent->sprite_collider_slice_key, ent->animation_frame);
ent->local_collider = CLD_ShapeFromQuad(MulXformQuad(cxf, QuadFromRect(slice.rect)));
}
/* Test collider */
#if 0
if (PP_HasProp(ent, PP_Prop_Test))
{
//if ((1)) {
#if 0
ent->local_collider.points[0] = VEC2(0, 0);
ent->local_collider.count = 1;
ent->local_collider.radius = 0.5;
#elif 0
ent->local_collider.points[0] = Vec2WithLen(VEC2(0.08f, 0.17f), 0.15f);
ent->local_collider.points[1] = Vec2WithLen(VEC2(-0.07f, -0.2f), 0.15f);
ent->local_collider.count = 2;
ent->local_collider.radius = 0.075f;
#elif 1
#if 0
/* "Bad" winding order */
ent->local_collider.points[0] = VEC2(-0.15, 0.15);
ent->local_collider.points[1] = VEC2(0.15, 0.15);
ent->local_collider.points[2] = VEC2(0, -0.15);
#else
ent->local_collider.points[0] = VEC2(0, -0.15);
ent->local_collider.points[1] = VEC2(0.15, 0.15);
ent->local_collider.points[2] = VEC2(-0.15, 0.15);
#endif
ent->local_collider.count = 3;
ent->local_collider.radius = 0.25;
//ent->local_collider.radius = AbsF32(SinF32(ctx->tick.time) / 3);
#else
//ent->local_collider.radius = 0.5;
ent->local_collider.radius = 0.25;
//ent->local_collider.radius = 0.;
#endif
}
#endif
}
//- Update attachments

View File

@ -8,8 +8,7 @@ void PT_RunForever(WaveLaneCtx *lane)
for (u64 cev_idx = 0; cev_idx < window_frame.controller_events.count; ++cev_idx)
{
ControllerEvent *cev = &window_frame.controller_events.events[cev_idx];
if (cev->kind == ControllerEventKind_Quit ||
(cev->kind == ControllerEventKind_ButtonDown && cev->button == Button_Escape))
if (cev->kind == ControllerEventKind_Quit || (cev->kind == ControllerEventKind_ButtonDown && cev->button == Button_Escape))
{
SignalExit(0);
}

View File

@ -61,8 +61,7 @@ TAR_Archive TAR_ArchiveFromString(Arena *arena, String data, String prefix)
if (!is_dir && header.file_type != TAR_FileKind_File)
{
/* Unsupported type */
Assert(header.file_type == TAR_FileKind_PaxHeaderX ||
header.file_type == TAR_FileKind_PaxHeaderG);
Assert(header.file_type == TAR_FileKind_PaxHeaderX || header.file_type == TAR_FileKind_PaxHeaderG);
continue;
}

View File

@ -487,10 +487,12 @@ WND_Frame WND_BeginFrame(G_Format backbuffer_format, WND_BackbufferSizeMode back
{
result.minimized = 1;
}
if (screen_rect.left == monitor_rect.left &&
if (
screen_rect.left == monitor_rect.left &&
screen_rect.top == monitor_rect.top &&
screen_rect.right == monitor_rect.right &&
screen_rect.bottom == monitor_rect.bottom)
screen_rect.bottom == monitor_rect.bottom
)
{
result.fullscreen = 1;
}