A bit more cleanup around sacn and assemblies.
This commit is contained in:
parent
9c432a3807
commit
23c9dabfbb
|
@ -182,7 +182,7 @@ INITIALIZE_APPLICATION(InitializeApplication)
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
string SculpturePath = MakeStringLiteral("data/blumen_lumen_v2.fold");
|
string SculpturePath = MakeStringLiteral("data/blumen_lumen_v2.fold");
|
||||||
LoadAssembly(State, Context, SculpturePath);
|
LoadAssembly(&State->Assemblies, &State->LedSystem, &State->Transient, Context, SculpturePath, State->GlobalLog);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
State->PixelsToWorldScale = .01f;
|
State->PixelsToWorldScale = .01f;
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
//
|
//
|
||||||
#ifndef FOLDHAUS_ASSEMBLY_CPP
|
#ifndef FOLDHAUS_ASSEMBLY_CPP
|
||||||
|
|
||||||
// Led System
|
|
||||||
|
|
||||||
internal led_system
|
internal led_system
|
||||||
LedSystemInitialize(platform_memory_handler PlatformMemory, u32 BuffersMax)
|
LedSystemInitialize(platform_memory_handler PlatformMemory, u32 BuffersMax)
|
||||||
{
|
{
|
||||||
|
@ -78,8 +76,6 @@ LedBufferSetLed(led_buffer* Buffer, u32 Led, v4 Position)
|
||||||
Buffer->Positions[Led] = Position;
|
Buffer->Positions[Led] = Position;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assembly
|
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
ConstructAssemblyFromDefinition (assembly* Assembly, string AssemblyName, v4 RootPosition, led_system* LedSystem)
|
ConstructAssemblyFromDefinition (assembly* Assembly, string AssemblyName, v4 RootPosition, led_system* LedSystem)
|
||||||
{
|
{
|
||||||
|
@ -114,37 +110,36 @@ ConstructAssemblyFromDefinition (assembly* Assembly, string AssemblyName, v4 Roo
|
||||||
static v4 TempAssemblyOffsets[] = { v4{0, 0, 0, 0}, v4{250, 0, 75, 0}, v4{-250, 0, 75, 0} };
|
static v4 TempAssemblyOffsets[] = { v4{0, 0, 0, 0}, v4{250, 0, 75, 0}, v4{-250, 0, 75, 0} };
|
||||||
s32 TempAssemblyOffsetsCount = 3;
|
s32 TempAssemblyOffsetsCount = 3;
|
||||||
|
|
||||||
// TODO(Peter): Don't reference State, pull back to the Led buffer and Assembly Array
|
|
||||||
internal void
|
internal void
|
||||||
LoadAssembly (app_state* State, context Context, string Path)
|
LoadAssembly (assembly_array* Assemblies, led_system* LedSystem, memory_arena* Scratch, context Context, string Path, event_log* GlobalLog)
|
||||||
{
|
{
|
||||||
platform_memory_result AssemblyFile = ReadEntireFile(Context, Path);
|
platform_memory_result AssemblyFile = ReadEntireFile(Context, Path);
|
||||||
if (AssemblyFile.Error == PlatformMemory_NoError && AssemblyFile.Size > 0)
|
if (AssemblyFile.Error == PlatformMemory_NoError && AssemblyFile.Size > 0)
|
||||||
{
|
{
|
||||||
string AssemblyFileText = MakeString((char*)AssemblyFile.Base);
|
string AssemblyFileText = MakeString((char*)AssemblyFile.Base);
|
||||||
|
|
||||||
Assert(State->Assemblies.Count < State->Assemblies.CountMax);
|
Assert(Assemblies->Count < Assemblies->CountMax);
|
||||||
assembly* NewAssembly = &State->Assemblies.Values[State->Assemblies.Count++];
|
assembly* NewAssembly = &Assemblies->Values[Assemblies->Count++];
|
||||||
|
|
||||||
s32 IndexOfLastSlash = FastLastIndexOfCharInCharArray(Path.Memory, Path.Length, '\\');
|
s32 IndexOfLastSlash = FastLastIndexOfCharInCharArray(Path.Memory, Path.Length, '\\');
|
||||||
string FileName = Substring(Path, IndexOfLastSlash + 1);
|
string FileName = Substring(Path, IndexOfLastSlash + 1);
|
||||||
|
|
||||||
NewAssembly->Arena.PlatformMemory = Context.PlatformMemory;
|
NewAssembly->Arena.PlatformMemory = Context.PlatformMemory;
|
||||||
if (ParseAssemblyFile(NewAssembly, AssemblyFileText, &State->Transient))
|
if (ParseAssemblyFile(NewAssembly, AssemblyFileText, Scratch))
|
||||||
{
|
{
|
||||||
v4 Offset = TempAssemblyOffsets[State->Assemblies.Count % TempAssemblyOffsetsCount];
|
v4 Offset = TempAssemblyOffsets[Assemblies->Count % TempAssemblyOffsetsCount];
|
||||||
ConstructAssemblyFromDefinition(NewAssembly, FileName, Offset, &State->LedSystem);
|
ConstructAssemblyFromDefinition(NewAssembly, FileName, Offset, LedSystem);
|
||||||
PlatformFree(Context.PlatformMemory, AssemblyFile.Base, AssemblyFile.Size);
|
PlatformFree(Context.PlatformMemory, AssemblyFile.Base, AssemblyFile.Size);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FreeMemoryArena(&NewAssembly->Arena);
|
FreeMemoryArena(&NewAssembly->Arena);
|
||||||
State->Assemblies.Count -= 1;
|
Assemblies->Count -= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogError(State->GlobalLog, "Unable to load assembly file");
|
LogError(GlobalLog, "Unable to load assembly file");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -477,6 +477,5 @@ DrawAllPanels(panel_layout PanelLayout, render_command_buffer* RenderBuffer, mou
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define FOLDHAUS_INTERFACE_CPP
|
#define FOLDHAUS_INTERFACE_CPP
|
||||||
#endif // FOLDHAUS_INTERFACE_CPP
|
#endif // FOLDHAUS_INTERFACE_CPP
|
|
@ -71,7 +71,7 @@ HierarchyView_Render(panel Panel, rect PanelBounds, render_command_buffer* Rende
|
||||||
b32 Success = GetFilePath(Context, &FilePath, "Foldhaus Files\0*.fold\0\0");
|
b32 Success = GetFilePath(Context, &FilePath, "Foldhaus Files\0*.fold\0\0");
|
||||||
if (Success)
|
if (Success)
|
||||||
{
|
{
|
||||||
LoadAssembly(State, Context, FilePath);
|
LoadAssembly(&State->Assemblies, &State->LedSystem, &State->Transient, Context, FilePath, State->GlobalLog);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue