diff options
Diffstat (limited to 'createcalls.cpp')
-rw-r--r-- | createcalls.cpp | 150 |
1 files changed, 105 insertions, 45 deletions
diff --git a/createcalls.cpp b/createcalls.cpp index c018eaa..176fc2f 100644 --- a/createcalls.cpp +++ b/createcalls.cpp @@ -74,6 +74,32 @@ Bezier_Lookup(memory *Memory, property_channel *Property, uint16 Index) return &Bezier->Point[Index]; } +static void +Bezier_Add(memory *Memory, property_channel *Property, bezier_point PointData) +{ + if (!Property->Block_Bezier_Count) { + Property->Block_Bezier_Index[0] = Memory_Block_AllocateNew(Memory, F_Bezier); + block_bezier *Bezier = (block_bezier *)Memory_Block_AddressAtIndex(Memory, F_Bezier, Property->Block_Bezier_Index[0]); + Bezier->Occupied = true; + // NOTE(fox): Effects will change this! + History_Action_Swap(Memory, F_Layers, sizeof(Property->Block_Bezier_Count), &Property->Block_Bezier_Count); + Property->Block_Bezier_Count++; + } + int k = 0; + for (;;) { + bezier_point *Point = Bezier_Lookup(Memory, Property, k); + if (!Point->Occupied) { + History_Action_Swap(Memory, F_Bezier, sizeof(*Point), Point); + *Point = PointData; + History_Action_Swap(Memory, F_Layers, sizeof(Property->Keyframe_Count), &Property->Keyframe_Count); + Property->Keyframe_Count++; + return; + } + k++; + } +} + + static property_channel Property_InitFloat(char *Name, real32 Val, real32 ScrubVal, real32 MinVal = PROPERTY_REAL_MIN, real32 MaxVal = PROPERTY_REAL_MAX) { property_channel Property = {}; Property.Name = Name; @@ -84,18 +110,20 @@ Property_InitFloat(char *Name, real32 Val, real32 ScrubVal, real32 MinVal = PROP return Property; } +// static property_info +// Property_Sort(memory *Memory, property_channel *Property) +// { +// } + static property_info Property_GetInfo(memory *Memory, property_channel *Property) { property_info PropertyInfo = {}; - int k = 0; - for (;;) { - bezier_point *Point = Bezier_Lookup(Memory, Property, k); - if (!Point->Occupied) - break; + int h = 0, c = 0, i = 0; + while (Block_Loop(Memory, Property, Property->Keyframe_Count, &h, &c, &i)) { + bezier_point *Point = Bezier_Lookup(Memory, Property, i); PropertyInfo.MinVal = (Point->Pos[0].y < PropertyInfo.MinVal) ? Point->Pos[0].y : PropertyInfo.MinVal; PropertyInfo.MaxVal = (Point->Pos[0].y > PropertyInfo.MaxVal) ? Point->Pos[0].y : PropertyInfo.MaxVal; - k++; } return PropertyInfo; } @@ -124,10 +152,11 @@ Graph_GetInfo(project_data *File, memory *Memory) static void Keyframe_Interact_Evaluate(memory *Memory, project_state *State, uint8 IsSelected, v2 Pos_Initial[3], v2 Pos_New[3]) { + /* Assert(Pos_New[0].y == Pos_Initial[0].y); - v2 Offset = V2(State->Interact_Offset[0], State->Interact_Offset[1]); if (State->Interact_Active == interact_type_keyframe_move) { - Pos_New[0] = Pos_New[0] + Offset; + Pos_New[0].x = Pos_New[0].x + Offset.x; + Pos_New[0].y = Pos_New[0].y + Offset.y; } else if (State->Interact_Active == interact_type_keyframe_scale) { Pos_New[1].x += (IsSelected - 1 == 0 || IsSelected - 1 == 1) ? Offset.x : 0; Pos_New[2].x -= (IsSelected - 1 == 0 || IsSelected - 1 == 2) ? Offset.x : 0; @@ -138,37 +167,45 @@ Keyframe_Interact_Evaluate(memory *Memory, project_state *State, uint8 IsSelecte Pos_New[2].x += XAxis.x + XAxis.y; Pos_New[2].y += YAxis.x + YAxis.y; } + */ +} + +static block_composition * +Precomp_Init(project_data *File, memory *Memory) +{ + if (File->Comp_Count + 1 > MAX_COMPS) { + Assert(0); + } + block_composition *Comp = (block_composition *)Memory_Block_AllocateAddress(Memory, F_Precomps); + History_Action_Block_Swap(Memory, F_Precomps, Comp); + + *Comp = {}; + Comp->Occupied = 1; + + Comp->Name_String_Index = Memory_Block_AllocateNew(Memory, F_Strings); + block_string *String = (block_string *)Memory_Block_AddressAtIndex(Memory, F_Strings, Comp->Name_String_Index); + sprintf(String->Char, "Comp %i", File->Comp_Count); + String->Occupied = 1; + + History_Action_Swap(Memory, F_File, sizeof(File->Comp_Count), &File->Comp_Count); + File->Comp_Count++; + return Comp; +} + +static layer_transforms +Layer_GetTransforms(block_layer *Layer) { + return { Layer->x.CurrentValue, Layer->y.CurrentValue, Layer->ax.CurrentValue, Layer->ay.CurrentValue, Layer->rotation.CurrentValue, Layer->scale.CurrentValue }; } -/* static void Layer_Interact_Evaluate(memory *Memory, project_state *State, uint16 Layer_Index_Physical, sorted_comp_info SortedCompInfo, sorted_layer *SortedLayerInfo, - int32 *Frame_Start, int32 *Frame_End, real32 *Vertical_Offset) + int32 *Frame_Start, int32 *Frame_End) { if (State->Interact_Active == interact_type_layer_move) { *Frame_Start += (int32)(State->Interact_Offset[0] + 0); *Frame_End += (int32)(State->Interact_Offset[0] + 0); - - real32 DesiredOffset = *Vertical_Offset + (int32)State->Interact_Offset[1]; - bool32 Direction = ((int32)State->Interact_Offset[1] > 0) ? 1 : -1; - int i = (Direction > 0) ? SortedCompInfo.LayerCount - 1 : 0; - bool32 Case = 1; - while (Case) { - sorted_layer SortEntry = SortedLayerInfo[i]; - uint32 Index_Physical = SortEntry.Block_Layer_Index; - block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, Index_Physical); - bool32 Test = (Direction > 0) ? - ((Layer->Vertical_Offset <= DesiredOffset) && (Layer->Vertical_Offset > *Vertical_Offset)) : - ((Layer->Vertical_Offset >= DesiredOffset) && (Layer->Vertical_Offset < *Vertical_Offset)); - if (!Layer->IsSelected && Test) { - DesiredOffset += Direction; - } - i -= Direction; - Case = (Direction > 0) ? (i >= 0) : (i < SortedCompInfo.LayerCount); - } - *Vertical_Offset = DesiredOffset; } - else if (State->Interact_Active == interact_type_layer_timeadjust) { + if (State->Interact_Active == interact_type_layer_timeadjust) { int Side[2] = {0}; Assert(State->Interact_Offset[1] == 0 || State->Interact_Offset[1] == 1); Side[(int)State->Interact_Offset[1]] = 1; @@ -178,17 +215,8 @@ Layer_Interact_Evaluate(memory *Memory, project_state *State, uint16 Layer_Index *Frame_End += (int32)(State->Interact_Offset[0] * Side[1]); if (*Frame_End <= *Frame_Start) *Frame_End = *Frame_Start + 1; - } else if (State->Interact_Active == interact_type_viewport_transform) { - int i = SortedCompInfo.LayerCount - 1; - while (i >= 0) { - sorted_layer SortEntry = SortedLayerInfo[i]; - uint32 Index_Physical = SortEntry.Block_Layer_Index; - block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, Index_Physical); - i--; - } } } -*/ static void Layer_Select(memory *Memory, project_state *State, int32 i) @@ -292,6 +320,38 @@ void Layer_Sort_CheckPrev(memory *Memory, int i, int Direction, sorted_layer *So } } +// TODO(fox): This _could_ be generalized with the layer sorting code... + +/* +Bezier_SortAll() +{ + while (Block_Loop(Memory, F_Layers, File->Layer_Count, &h, &c, &i)) { + block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, i); + sorted_comp_info *SortedCompInfo = &CompStart[Layer->Block_Composition_Index]; + sorted_layer *SortedLayerInfo = Layer_GetSortedArray(LayerArrayStart, CompStart, Layer->Block_Composition_Index); + uint32 SortedIndex_Playhead = 0; + while (SortedIndex_Playhead < CurrentSortIndex) { + sorted_layer LayerEntry = SortedLayerInfo[SortedIndex_Playhead]; + block_layer *TestLayer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, LayerEntry.Block_Layer_Index); + if (-Layer->Vertical_Offset < -TestLayer->Vertical_Offset) { + break; + } else { + SortedIndex_Playhead++; + } + } + if (SortedIndex_Playhead != CurrentSortIndex) { + uint8 *Address_Start = (uint8 *)(SortedLayerInfo + SortedIndex_Playhead); + uint8 *Address_End = (uint8 *)(SortedLayerInfo + CurrentSortIndex) - 1; + Assert(CurrentSortIndex != SortedCompInfo->LayerCount); + Arbitrary_ShiftData(Address_Start, Address_End, sizeof(sorted_layer), 1); + } + sorted_layer *LayerEntry = SortedLayerInfo + SortedIndex_Playhead; + LayerEntry->Block_Layer_Index = i; + LayerEntry->SortedOffset = Layer->Vertical_Offset; + CurrentSortIndex++; + } +} +*/ void Layer_SortAll(project_data *File, project_state *State, memory *Memory, sorted_layer *LayerArrayStart, sorted_comp_info *CompStart, uint32 LayerCount, uint32 CompCount) { @@ -300,15 +360,15 @@ void Layer_SortAll(project_data *File, project_state *State, memory *Memory, sor block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, i); Assert(Layer->Block_Composition_Index < CompCount); CompStart[Layer->Block_Composition_Index].LayerCount++; - } h = 0, c = 0, i = 0; + uint32 CurrentSortIndex = 0; while (Block_Loop(Memory, F_Layers, File->Layer_Count, &h, &c, &i)) { block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, i); sorted_comp_info *SortedCompInfo = &CompStart[Layer->Block_Composition_Index]; sorted_layer *SortedLayerInfo = Layer_GetSortedArray(LayerArrayStart, CompStart, Layer->Block_Composition_Index); uint32 SortedIndex_Playhead = 0; - while (SortedIndex_Playhead < SortedCompInfo->CurrentSortIndex) { + while (SortedIndex_Playhead < CurrentSortIndex) { sorted_layer LayerEntry = SortedLayerInfo[SortedIndex_Playhead]; block_layer *TestLayer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, LayerEntry.Block_Layer_Index); if (-Layer->Vertical_Offset < -TestLayer->Vertical_Offset) { @@ -317,16 +377,16 @@ void Layer_SortAll(project_data *File, project_state *State, memory *Memory, sor SortedIndex_Playhead++; } } - if (SortedIndex_Playhead != SortedCompInfo->CurrentSortIndex) { + if (SortedIndex_Playhead != CurrentSortIndex) { uint8 *Address_Start = (uint8 *)(SortedLayerInfo + SortedIndex_Playhead); - uint8 *Address_End = (uint8 *)(SortedLayerInfo + SortedCompInfo->CurrentSortIndex) - 1; - Assert(SortedCompInfo->CurrentSortIndex != SortedCompInfo->LayerCount); + uint8 *Address_End = (uint8 *)(SortedLayerInfo + CurrentSortIndex) - 1; + Assert(CurrentSortIndex != SortedCompInfo->LayerCount); Arbitrary_ShiftData(Address_Start, Address_End, sizeof(sorted_layer), 1); } sorted_layer *LayerEntry = SortedLayerInfo + SortedIndex_Playhead; LayerEntry->Block_Layer_Index = i; LayerEntry->SortedOffset = Layer->Vertical_Offset; - SortedCompInfo->CurrentSortIndex++; + CurrentSortIndex++; } if (State->Interact_Active == interact_type_layer_move) { int32 Offset = (int32)State->Interact_Offset[1]; |