added assembly_center field to assembly files and used it to place assemblies at construction time

This commit is contained in:
Peter Slattery 2020-09-07 11:12:58 -07:00
parent 44486acca4
commit cc41442923
5 changed files with 10 additions and 6 deletions

View File

@ -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);
}

View File

@ -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);

View File

@ -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

View File

@ -75,6 +75,7 @@ struct assembly
gs_string FilePath;
r32 Scale;
v3 Center;
s32 LedCountTotal;
u32 LedBufferIndex;

View File

@ -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