summaryrefslogtreecommitdiff
path: root/src/layer.cpp
diff options
context:
space:
mode:
authorFox Caminiti <fox@foxcam.net>2023-01-06 10:26:43 -0500
committerFox Caminiti <fox@foxcam.net>2023-01-06 10:26:43 -0500
commit1de48570b220acc1ca7063e2a9cda1e89178c0f9 (patch)
tree1edd38bd7ad7f95f865793a9d0e54c62aa3bf37e /src/layer.cpp
parenteebbdd012b0d156e9e92369585c6ad82ed3de371 (diff)
bad shape positioning
Diffstat (limited to 'src/layer.cpp')
-rw-r--r--src/layer.cpp46
1 files changed, 37 insertions, 9 deletions
diff --git a/src/layer.cpp b/src/layer.cpp
index 93db19d..7d40310 100644
--- a/src/layer.cpp
+++ b/src/layer.cpp
@@ -94,7 +94,7 @@ Layer_GetTopOffset(project_data *File, memory *Memory)
static void
Layer_UpdateMasksEffects(project_state *State, block_layer *Layer, memory *Memory, void *EffectBitmapAddress,
- int Width, int Height, int BytesPerPixel, int *L_Width, int *L_Height)
+ int Width, int Height, int BytesPerPixel)
{
uint64 Size = Width*Height*BytesPerPixel;
@@ -109,15 +109,24 @@ Layer_UpdateMasksEffects(project_state *State, block_layer *Layer, memory *Memor
if (Layer->IsShapeLayer) {
shape_layer *Shape = &Layer->Shape;
void *Data = Memory_PushScratch(Memory, sizeof(nvg_point) * 128);
- uint32 NumberOfVerts = NVG_FlattenPath(Memory, Shape, (nvg_point *)Data, L_Width, L_Height);
+ Arbitrary_Zero((uint8 *)Data, sizeof(nvg_point) * 128);
+ layer_transforms T = Layer_GetTransforms(Layer);
+ v2 Min = {}, Max = {};
+ if (State->Interact_Active == interact_type_keyframe_move) {
+ NVG_FlattenPath(Memory, Shape, (nvg_point *)Data, State, T, 0, 0, Width, Height, 0, &Min, &Max);
+ Shape->Width = Max.x - Min.x;
+ Shape->Height = Max.y - Min.y;
+ }
+ uint32 NumberOfVerts = NVG_FlattenPath(Memory, Shape, (nvg_point *)Data,
+ State, T, Shape->Width, Shape->Height, Width, Height, 1, &Min, &Max);
void *Data_Stroke = Memory_PushScratch(Memory, sizeof(real32) * 4 * 256);
- uint32 StrokeCount = NVG_ExpandStroke(Memory, NumberOfVerts, Shape->Opt.StrokeWidth, Shape->IsClosed, (nvg_point *)Data, (real32 *)Data_Stroke);
+ uint32 StrokeCount = NVG_ExpandStroke(Memory, NumberOfVerts, Shape->Opt.StrokeWidth, Shape->Opt.LineCapType, Shape->Opt.LineJoinType, Shape->IsClosed, (nvg_point *)Data, (real32 *)Data_Stroke);
void *Data_Fill = Memory_PushScratch(Memory, sizeof(real32) * 4 * NumberOfVerts);
NVG_ExpandFill(Memory, NumberOfVerts, (nvg_point *)Data, (real32 *)Data_Fill);
- layer_transforms T = Layer_GetTransforms(Layer);
GL_RasterizeShape(&TestL, &TestM, Data_Stroke, Data_Fill, StrokeCount, NumberOfVerts, T,
- Width, Height, BytesPerPixel, EffectBitmapAddress, *L_Width, *L_Height, Layer->Shape.Opt.StrokeCol, Shape->Opt.Visibility);
+ Width, Height, BytesPerPixel, EffectBitmapAddress, Shape->Width, Shape->Height,
+ Shape->Opt.StrokeCol, Shape->Opt.FillCol, Shape->Opt.Visibility);
Memory_PopScratch(Memory, sizeof(real32) * 4 * NumberOfVerts);
Memory_PopScratch(Memory, sizeof(real32) * 4 * 256);
@@ -309,6 +318,23 @@ Layer_Select_Traverse(uint16 PrincipalCompIndex, memory *Memory, project_state *
}
}
+static void
+Layer_GetDimensions(memory *Memory, block_layer *Layer, int *Width, int *Height)
+{
+ if (Layer->IsPrecomp) {
+ block_composition *Comp = (block_composition *)Memory_Block_AddressAtIndex(Memory, F_Precomps, Layer->Block_Source_Index);
+ *Width = Comp->Width;
+ *Height = Comp->Height;
+ } else if (Layer->IsShapeLayer) {
+ *Width = Layer->Shape.Width;
+ *Height = Layer->Shape.Height;
+ } else {
+ block_source *Source = (block_source *)Memory_Block_AddressAtIndex(Memory, F_Sources, Layer->Block_Source_Index);
+ *Width = Source->Width;
+ *Height = Source->Height;
+ }
+}
+
static v2
Layer_TraverseForPoint(project_data *File, project_state *State, memory *Memory, v2 PrincipalCompUV, sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray)
{
@@ -352,9 +378,10 @@ Layer_TestSelection(memory *Memory, project_state *State, ui *UI, sorted_comp_ar
sorted_layer_array SortEntry = SortedLayerStart[i];
uint32 Index_Physical = SortEntry.Block_Layer_Index;
block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, Index_Physical);
- block_source *Source = (block_source *)Memory_Block_AddressAtIndex(Memory, F_Sources, Layer->Block_Source_Index);
+ int Width, Height;
+ Layer_GetDimensions(Memory, Layer, &Width, &Height);
layer_transforms T = Layer_GetTransforms(Layer);
- v2 UV = T_CompUVToLayerUV(T, Comp->Width, Comp->Height, Source->Width, Source->Height, State->LastClickedPoint);
+ v2 UV = T_CompUVToLayerUV(T, Comp->Width, Comp->Height, Width, Height, State->LastClickedPoint);
if (UV.x <= 1.0f && UV.x >= 0.0f && UV.y <= 1.0f && UV.y >= 0.0f && Layer->IsSelected)
{
SelectionCount++;
@@ -366,9 +393,10 @@ Layer_TestSelection(memory *Memory, project_state *State, ui *UI, sorted_comp_ar
sorted_layer_array SortEntry = SortedLayerStart[i];
uint32 Index_Physical = SortEntry.Block_Layer_Index;
block_layer *Layer = (block_layer *)Memory_Block_AddressAtIndex(Memory, F_Layers, Index_Physical);
- block_source *Source = (block_source *)Memory_Block_AddressAtIndex(Memory, F_Sources, Layer->Block_Source_Index);
+ int Width, Height;
+ Layer_GetDimensions(Memory, Layer, &Width, &Height);
layer_transforms T = Layer_GetTransforms(Layer);
- v2 UV = T_CompUVToLayerUV(T, Comp->Width, Comp->Height, Source->Width, Source->Height, State->LastClickedPoint);
+ v2 UV = T_CompUVToLayerUV(T, Comp->Width, Comp->Height, Width, Height, State->LastClickedPoint);
if (UV.x <= 1.0f && UV.x >= 0.0f && UV.y <= 1.0f && UV.y >= 0.0f && !Layer->IsSelected)
{
if (SelectionCount == 1) {