From 87c3fbb37141827622eeadb89189c267ed4baf87 Mon Sep 17 00:00:00 2001 From: Fox Caminiti Date: Mon, 24 Oct 2022 22:58:07 -0400 Subject: development --- createcalls.cpp | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 74 insertions(+), 10 deletions(-) (limited to 'createcalls.cpp') diff --git a/createcalls.cpp b/createcalls.cpp index 6a830b5..c2122c2 100644 --- a/createcalls.cpp +++ b/createcalls.cpp @@ -35,6 +35,14 @@ Source_Generate(project_data *File, project_state *State, memory *Memory, void * return -1; } +static bezier_point * +Bezier_Lookup(memory *Memory, property_channel *Property, uint16 Index) +{ + Assert(Index < MAX_KEYFRAMES_PER_BLOCK); + block_bezier *Bezier = (block_bezier *)Memory_Block_AddressAtIndex(Memory, F_Bezier, Property->Block_Bezier_Index[0]); + return &Bezier->Point[Index]; +} + 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; @@ -45,19 +53,55 @@ Property_InitFloat(char *Name, real32 Val, real32 ScrubVal, real32 MinVal = PROP return Property; } +static property_info +Property_GetInfo(memory *Memory, property_channel *Property) +{ + property_info PropertyInfo = {}; + for (int k = 0; k < Property->Keyframe_Count; k++) { + bezier_point *Point = Bezier_Lookup(Memory, Property, k); + 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; + } + return PropertyInfo; +} + static void -Layer_Interact_Evaluate(memory *Memory, project_state *State, int32 *Frame_Start, int32 *Frame_End, real32 *Vertical_Offset) +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) { if (State->Interact_Active == interact_type_layer_move) { *Frame_Start += (int32)(State->Interact_Offset[0] + 0); *Frame_End += (int32)(State->Interact_Offset[0] + 0); - *Vertical_Offset += (int32)State->Interact_Offset[1]; - } else if (State->Interact_Active == interact_type_layer_timeadjust) { + + 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) { int Side[2] = {0}; Assert(State->Interact_Offset[1] == 0 || State->Interact_Offset[1] == 1); Side[(int)State->Interact_Offset[1]] = 1; *Frame_Start += (int32)(State->Interact_Offset[0] * Side[0]); + if (*Frame_Start >= *Frame_End) + *Frame_Start = *Frame_End - 1; *Frame_End += (int32)(State->Interact_Offset[0] * Side[1]); + if (*Frame_End <= *Frame_Start) + *Frame_End = *Frame_Start + 1; } } @@ -81,6 +125,24 @@ Layer_GetSortedArray(sorted_layer *LayerArrayStart, sorted_comp_info *SortedComp return LayerArrayStart + LayerOffset; } +void Layer_RecursiveDeselect(memory *Memory, sorted_comp_info *SortedCompArray, sorted_layer *SortedLayerArray, uint16 TargetIndex, uint16 PrincipalIndex) +{ + block_composition *Comp = (block_composition *)Memory_Block_AddressAtIndex(Memory, F_Precomps, PrincipalIndex); + sorted_comp_info SortedCompInfo = SortedCompArray[PrincipalIndex]; + sorted_layer *SortedLayerInfo = Layer_GetSortedArray(SortedLayerArray, SortedCompArray, PrincipalIndex); + for (int i = 0; i < SortedCompInfo.LayerCount; i++) { + 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); + if (Layer->IsPrecomp) { + Layer_RecursiveDeselect(Memory, SortedCompArray, SortedLayerArray, TargetIndex, Layer->Block_Source_Index); + } + if (Layer->Block_Composition_Index != TargetIndex) { + Layer->IsSelected = false; + } + } +} + void Layer_SortAll(memory *Memory, sorted_layer *LayerArrayStart, sorted_comp_info *CompStart, uint32 LayerCount, uint32 CompCount) { for (uint32 i = 0; i < LayerCount; i++) { @@ -98,7 +160,7 @@ void Layer_SortAll(memory *Memory, sorted_layer *LayerArrayStart, sorted_comp_in while (SortedIndex_Playhead < SortedCompInfo->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) { + if (-Layer->Vertical_Offset < -TestLayer->Vertical_Offset) { break; } else { SortedIndex_Playhead++; @@ -106,19 +168,21 @@ void Layer_SortAll(memory *Memory, sorted_layer *LayerArrayStart, sorted_comp_in } if (SortedIndex_Playhead != SortedCompInfo->CurrentSortIndex) { uint8 *Address_Start = (uint8 *)(SortedLayerInfo + SortedIndex_Playhead); - uint8 *Address_End = (uint8 *)(SortedLayerInfo + i); + uint8 *Address_End = (uint8 *)(SortedLayerInfo + SortedCompInfo->CurrentSortIndex) - 1; + Assert(SortedCompInfo->CurrentSortIndex != SortedCompInfo->LayerCount); Arbitrary_ShiftData(Address_Start, Address_End, sizeof(sorted_layer), 1); } sorted_layer *LayerEntry = SortedLayerInfo + SortedIndex_Playhead; LayerEntry->Block_Layer_Index = i; SortedCompInfo->CurrentSortIndex++; } - Assert(CompStart[0].LayerCount == 2); - Assert(CompStart[1].LayerCount == 2); + // Assert(CompStart[0].LayerCount == 3); + // Assert(CompStart[1].LayerCount == 2); // Assert(LayerArrayStart[0].Block_Layer_Index == 0); - // Assert(LayerArrayStart[1].Block_Layer_Index == 1); - // Assert(LayerArrayStart[2].Block_Layer_Index == 2); - // Assert(LayerArrayStart[3].Block_Layer_Index == 3); + // Assert(LayerArrayStart[1].Block_Layer_Index == 2); + // Assert(LayerArrayStart[2].Block_Layer_Index == 4); + // Assert(LayerArrayStart[4].Block_Layer_Index == 1); + // Assert(LayerArrayStart[5].Block_Layer_Index == 3); } block_layer * Layer_Init(project_data *File, memory *Memory) -- cgit v1.2.3