From cc41442923d7e66b3c5b46f1e0f5057cfbc237db Mon Sep 17 00:00:00 2001 From: Peter Slattery Date: Mon, 7 Sep 2020 11:12:58 -0700 Subject: [PATCH] added assembly_center field to assembly files and used it to place assemblies at construction time --- src/app/editor/panels/foldhaus_panel_animation_timeline.h | 3 ++- src/app/engine/assembly_parser.cpp | 3 +++ src/app/engine/foldhaus_assembly.cpp | 7 ++++--- src/app/engine/foldhaus_assembly.h | 1 + src/todo.txt | 2 -- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/app/editor/panels/foldhaus_panel_animation_timeline.h b/src/app/editor/panels/foldhaus_panel_animation_timeline.h index 0cf63ab..877cadc 100644 --- a/src/app/editor/panels/foldhaus_panel_animation_timeline.h +++ b/src/app/editor/panels/foldhaus_panel_animation_timeline.h @@ -12,6 +12,8 @@ global v4 TimeSliderColor = v4{.36f, .52f, .78f, 1.f}; struct animation_timeline_state { frame_range VisibleRange; + gs_list_handle SelectedAnimationBlockHandle; + u32 SelectedAnimationLayer; }; inline u32 @@ -510,7 +512,6 @@ DrawAnimationTimeline (animation_system* AnimationSystem, animation_timeline_sta if (MouseDownAndNotHandled && ListHandleIsValid(DragBlockHandle)) { MouseDownAndNotHandled = false; - // TODO(Peter): Why are we passing state around? SelectAndBeginDragAnimationBlock(DragBlockHandle, AdjustedViewRange, TimelineBounds, State); } diff --git a/src/app/engine/assembly_parser.cpp b/src/app/engine/assembly_parser.cpp index 8e229e0..ea2b36c 100644 --- a/src/app/engine/assembly_parser.cpp +++ b/src/app/engine/assembly_parser.cpp @@ -9,6 +9,7 @@ enum assembly_field { AssemblyField_AssemblyName, AssemblyField_AssemblyScale, + AssemblyField_AssemblyCenter, AssemblyField_LedStripCount, AssemblyField_LedStrip, @@ -31,6 +32,7 @@ enum assembly_field global char* AssemblyFieldIdentifiers[] = { "assembly_name", // AssemblyField_AssemblyName "assembly_scale", // AssemblyField_AssemblyScale + "assembly_center", // AssemblyField_AssemblyCenter "led_strip_count", // AssemblyField_LedStripCount "led_strip", // AssemblyField_LedStrip @@ -384,6 +386,7 @@ ParseAssemblyFile(assembly* Assembly, gs_const_string FileName, gs_string FileTe Assembly->Name = ReadStringField(AssemblyField_AssemblyName, &Tokenizer, &Assembly->Arena); Assembly->Scale = ReadFloatField(AssemblyField_AssemblyScale, &Tokenizer); + Assembly->Center = ReadV3Field(AssemblyField_AssemblyCenter, &Tokenizer); Assembly->StripCount = ReadIntField(AssemblyField_LedStripCount, &Tokenizer); Assembly->Strips = PushArray(&Assembly->Arena, v2_strip, Assembly->StripCount); diff --git a/src/app/engine/foldhaus_assembly.cpp b/src/app/engine/foldhaus_assembly.cpp index c01d44f..aa651b3 100644 --- a/src/app/engine/foldhaus_assembly.cpp +++ b/src/app/engine/foldhaus_assembly.cpp @@ -77,11 +77,13 @@ LedBufferSetLed(led_buffer* Buffer, u32 Led, v4 Position) } internal void -ConstructAssemblyFromDefinition (assembly* Assembly, gs_const_string AssemblyName, v4 RootPosition, led_system* LedSystem) +ConstructAssemblyFromDefinition (assembly* Assembly, gs_const_string AssemblyName, led_system* LedSystem) { Assembly->LedBufferIndex = LedSystemTakeFreeBuffer(LedSystem, Assembly->LedCountTotal); led_buffer* LedBuffer = LedSystemGetBuffer(LedSystem, Assembly->LedBufferIndex); + v4 RootPosition = ToV4Vec(Assembly->Center); + // Add Leds u32 LedsAdded = 0; for (u32 StripIdx = 0; StripIdx < Assembly->StripCount; StripIdx++) @@ -127,8 +129,7 @@ LoadAssembly (assembly_array* Assemblies, led_system* LedSystem, gs_memory_arena NewAssembly->Arena = CreateMemoryArena(Context.ThreadContext.Allocator); if (ParseAssemblyFile(NewAssembly, FileName, AssemblyFileText, Scratch)) { - v4 Offset = v4{0,0,0,0}; //TempAssemblyOffsets[Assemblies->Count % TempAssemblyOffsetsCount]; - ConstructAssemblyFromDefinition(NewAssembly, FileName, Offset, LedSystem); + ConstructAssemblyFromDefinition(NewAssembly, FileName, LedSystem); AllocatorFree(Context.ThreadContext.Allocator, AssemblyFile.Memory, AssemblyFile.Size); } else diff --git a/src/app/engine/foldhaus_assembly.h b/src/app/engine/foldhaus_assembly.h index 6005b4a..4a6cc85 100644 --- a/src/app/engine/foldhaus_assembly.h +++ b/src/app/engine/foldhaus_assembly.h @@ -75,6 +75,7 @@ struct assembly gs_string FilePath; r32 Scale; + v3 Center; s32 LedCountTotal; u32 LedBufferIndex; diff --git a/src/todo.txt b/src/todo.txt index be2a476..6da1111 100644 --- a/src/todo.txt +++ b/src/todo.txt @@ -24,10 +24,8 @@ STREAM #1: 3D Overhaul - leds always face camera - Sculptures - - store scale in the assembly definition file - cache led vertex buffers - custom sculpture update functions (for motion) - - placing sculptures - editing sculpture files (change universe output) - motion