diff options
Diffstat (limited to 'src/prenderer.cpp')
-rw-r--r-- | src/prenderer.cpp | 100 |
1 files changed, 16 insertions, 84 deletions
diff --git a/src/prenderer.cpp b/src/prenderer.cpp index 5119d55..7cac63e 100644 --- a/src/prenderer.cpp +++ b/src/prenderer.cpp @@ -191,89 +191,6 @@ Transform_Recurse(project_state *State, memory *Memory, block_composition *MainC } } -// IMPORTANT(fox): The selection state and ordering of layers cannot change -// until this action is exited/committed! -static void -Interact_Transform_Begin(project_data *File, memory *Memory, project_state *State, ImVec2 OGPos, - sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray) -{ - real32 MinX = 100000; - real32 MinY = 100000; - real32 MaxX = -100000; - real32 MaxY = -100000; - block_composition *MainComp = (block_composition *)Memory_Block_AddressAtIndex(Memory, F_Precomps, File->PrincipalCompIndex); - block_layer *ParentLayer[4]; - Transform_Recurse(State, Memory, MainComp, File->PrincipalCompIndex, ParentLayer, 0, - SortedCompArray, SortedLayerArray, - &MinX, &MinY, &MaxX, &MaxY); - if (MinX != 100000) { - State->Interact_Active = interact_type_viewport_transform; - interact_transform *Interact = &State->Interact_Transform; - Interact->Min = V2(MinX, MinY); - Interact->Max = V2(MaxX, MaxY); - Interact->Position = V2(0); - Interact->Radians = 0; - Interact->Scale = 1.0f; - Interact->OGPos = OGPos; - } - /* - bool32 Activate = false; - // Find the max dimensions of all the selected layers. - for (int i = 0; i < File->Layer_Count; i++) { - block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, i); - if (!Layer->IsSelected) - continue; - uint32 Width = 0, Height = 0; - if (!Layer->IsPrecomp) { - block_source *Source = (block_source *)Memory_Block_AddressAtIndex(Memory, F_Sources, Layer->Block_Source_Index); - Width = Source->Width; - Height = Source->Height; - } else { - block_composition *Comp = (block_composition *)Memory_Block_AddressAtIndex(Memory, F_Precomps, Layer->Block_Source_Index); - Width = Comp->Width; - Height = Comp->Height; - } - Transform_IterateOuterBounds(Layer, Width, Height, &MinX, &MinY, &MaxX, &MaxY); - Activate = true; - } - if (Activate) { - State->Interact_Active = interact_type_viewport_transform; - interact_transform *Interact = &State->Interact_Transform; - Interact->Min = V2(MinX, MinY); - Interact->Max = V2(MaxX, MaxY); - Interact->Position = V2(0); - Interact->Radians = 0; - Interact->Scale = 1.0f; - Interact->OGPos = OGPos; - } - */ -} - -static void -Interact_Transform2_Begin(project_data *File, memory *Memory, project_state *State, ImVec2 OGPos, - sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray) -{ - real32 MinX = 100000; - real32 MinY = 100000; - real32 MaxX = -100000; - real32 MaxY = -100000; - block_composition *MainComp = (block_composition *)Memory_Block_AddressAtIndex(Memory, F_Precomps, File->PrincipalCompIndex); - block_layer *ParentLayer[4]; - Transform_Recurse(State, Memory, MainComp, File->PrincipalCompIndex, ParentLayer, 0, - SortedCompArray, SortedLayerArray, - &MinX, &MinY, &MaxX, &MaxY); - if (MinX != 100000) { - State->Interact_Active = interact_type_viewport_transform; - interact_transform *Interact = &State->Interact_Transform; - Interact->Min = V2(MinX, MinY); - Interact->Max = V2(MaxX, MaxY); - Interact->Position = V2(0); - Interact->Radians = 0; - Interact->Scale = 1.0f; - Interact->OGPos = OGPos; - } -} - static v2 TransformPoint(layer_transforms T, real32 Width, real32 Height, v2 Point) { @@ -300,7 +217,9 @@ static layer_transforms Transform_TestInteracts(project_state *State, block_layer *Layer, sorted_layer_array SortEntry, layer_transforms T) { if (State->Interact_Active == interact_type_viewport_transform && Layer->IsSelected & 0x01) { - Transform_ApplyInteractive(State->Interact_Transform, &T.x, &T.y, &T.rotation, &T.scale); + T.x += State->Interact_Offset[0]; + T.y += State->Interact_Offset[1]; + real32 Rand = State->Interact_Offset[3]; } if (State->Interact_Active == interact_type_viewport_transform_gizmo && Layer->IsSelected & 0x01) { Transform_ApplyInteractive(State->Interact_Transform, &T.x, &T.y, &T.rotation, &T.scale); @@ -330,6 +249,19 @@ Transform_Add(layer_transforms T, layer_transforms ExtraT, real32 Width, real32 return T; } +static layer_transforms +Transform_Add2(layer_transforms T, layer_transforms ExtraT, real32 Width, real32 Height) +{ + v2 NewPos = TransformPoint(ExtraT, Width, Height, V2(T.x, T.y)); + T.x = NewPos.x; + T.y = NewPos.y; + T.ax = T.ax; + T.ay = T.ay; + T.rotation = T.rotation + ExtraT.rotation; + T.scale = T.scale / ExtraT.scale; + return T; +} + static ImVec2 Layer_LocalToScreenSpace(project_state *State, memory *Memory, block_layer *Layer, ui *UI, uint32 PrincipalCompIndex, v2 Point) { |