diff --git a/src/foldhaus_assembly.cpp b/src/foldhaus_assembly.cpp index 38db7fc..5acf4da 100644 --- a/src/foldhaus_assembly.cpp +++ b/src/foldhaus_assembly.cpp @@ -61,6 +61,9 @@ ConstructAssemblyFromDefinition (assembly_definition Definition, return Assembly; } +// NOTE(Peter): These are here so that if we load 2+ sculptures, they don't all +// end up on top of one another. Purely aesthetic. Can remove once we implement +// scene editing tools static v4 TempAssemblyOffsets[] = { v4{0, 0, 0, 0}, v4{250, 0, 75, 0}, v4{-250, 0, 75, 0} }; s32 TempAssemblyOffsetsCount = 3; @@ -68,34 +71,32 @@ internal void LoadAssembly (app_state* State, context Context, char* Path) { platform_memory_result TestAssemblyFile = Context.PlatformReadEntireFile(Path); - if (TestAssemblyFile.Error != PlatformMemory_NoError) + if (TestAssemblyFile.Error == PlatformMemory_NoError) { - return; + assembly_definition AssemblyDefinition = ParseAssemblyFile(TestAssemblyFile.Base, TestAssemblyFile.Size, &State->Transient); + + string PathString = MakeStringLiteral(Path); + s32 IndexOfLastSlash = FastLastIndexOfCharInCharArray(PathString.Memory, PathString.Length, '\\'); + string FileName = Substring(PathString, IndexOfLastSlash + 1); + + memory_arena AssemblyArena = {}; + AssemblyArena.Alloc = (gs_memory_alloc*)Context.PlatformAlloc; + AssemblyArena.Realloc = (gs_memory_realloc*)Context.PlatformRealloc; + + v4 Offset = TempAssemblyOffsets[State->ActiveAssemblyIndecies.Used % TempAssemblyOffsetsCount]; + r32 Scale = 100; + assembly NewAssembly = ConstructAssemblyFromDefinition(AssemblyDefinition, FileName, Offset, Scale, AssemblyArena); + gs_list_handle NewAssemblyHandle = State->AssemblyList.PushElementOnList(NewAssembly); + + State->ActiveAssemblyIndecies.PushElementOnList(NewAssemblyHandle); + State->TotalLEDsCount += NewAssembly.LEDCount; + + Context.PlatformFree(TestAssemblyFile.Base, TestAssemblyFile.Size); + } + else + { + // TODO(Peter): :ErrorLogging } - - assembly_definition AssemblyDefinition = ParseAssemblyFile(TestAssemblyFile.Base, TestAssemblyFile.Size, &State->Transient); - - Context.PlatformFree(TestAssemblyFile.Base, TestAssemblyFile.Size); - - string PathString = MakeStringLiteral(Path); - s32 IndexOfLastSlash = FastLastIndexOfCharInCharArray(PathString.Memory, PathString.Length, '\\'); - string FileName = Substring(PathString, IndexOfLastSlash + 1); - - r32 Scale = 100; - memory_arena AssemblyArena = {}; - AssemblyArena.Alloc = (gs_memory_alloc*)Context.PlatformAlloc; - AssemblyArena.Realloc = (gs_memory_realloc*)Context.PlatformRealloc; - - v4 Offset = TempAssemblyOffsets[State->ActiveAssemblyIndecies.Used % TempAssemblyOffsetsCount]; - assembly NewAssembly = ConstructAssemblyFromDefinition(AssemblyDefinition, - FileName, - Offset, - Scale, - AssemblyArena); - gs_list_handle NewAssemblyHandle = State->AssemblyList.PushElementOnList(NewAssembly); - State->ActiveAssemblyIndecies.PushElementOnList(NewAssemblyHandle); - - State->TotalLEDsCount += NewAssembly.LEDCount; } internal void diff --git a/todo.txt b/todo.txt index 21157d7..e9387e4 100644 --- a/todo.txt +++ b/todo.txt @@ -24,6 +24,15 @@ x Hot Code Reloading x File Loading x Gracefully handle File Not found +- Internal Log File + - NOTE: This should not be a part of the debug system + - Save output log to a file continuously + - Have a window where we can view the log within the app + - Create a bar that displays the most recent error message + - :ErrorLogging + +- Make sure it works without building in Debug Mode + - Buckets & Lists - Allow them to use memory arenas - Zero is initialization @@ -40,6 +49,7 @@ x File Loading - icon system - Sculptures + - store scale in the assembly definition file - cache led vertex buffers - custom sculpture update functions (for motion) - placing sculptures