summaryrefslogtreecommitdiff
path: root/src/layer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/layer.cpp')
-rw-r--r--src/layer.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/layer.cpp b/src/layer.cpp
index 0b278e5..570c7fc 100644
--- a/src/layer.cpp
+++ b/src/layer.cpp
@@ -117,10 +117,11 @@ Layer_UpdateMasksEffects(project_state *State, block_layer *Layer, memory *Memor
Arbitrary_Zero((uint8 *)Data, sizeof(nvg_point) * 128);
layer_transforms T = Layer_GetTransforms(Layer);
v2 Min = {}, Max = {};
+ bool32 IsConvex = 0;
uint32 NumberOfVerts = NVG_FlattenPath(Memory, Shape, ShapeOpt, (nvg_point *)Data,
- State, T, Shape->Width, Shape->Height, Width, Height, 1, &Min, &Max);
+ State, T, Shape->Width, Shape->Height, Width, Height, 1, &Min, &Max, &IsConvex);
void *Data_Stroke = Memory_PushScratch(Memory, sizeof(real32) * 4 * 256);
- uint32 StrokeCount = NVG_ExpandStroke(Memory, NumberOfVerts, ShapeOpt.StrokeWidth, ShapeOpt.LineCapType, ShapeOpt.LineJoinType, Shape->IsClosed, (nvg_point *)Data, (real32 *)Data_Stroke);
+ uint32 StrokeCount = NVG_ExpandStroke(Memory, NumberOfVerts, ShapeOpt.StrokeWidth, ShapeOpt.LineCapType, ShapeOpt.LineJoinType, Shape->IsClosed, (nvg_point *)Data, (real32 *)Data_Stroke, &IsConvex);
void *Data_Fill = Memory_PushScratch(Memory, sizeof(real32) * 4 * NumberOfVerts);
NVG_ExpandFill(Memory, NumberOfVerts, (nvg_point *)Data, (real32 *)Data_Fill);
@@ -421,9 +422,8 @@ Layer_TraverseForPoint(project_data *File, project_state *State, memory *Memory,
return PointUV * V2(InnerWidth, InnerHeight);
}
-// TODO(fox): Precomps?
static bool32
-Layer_TestForPoint(memory *Memory, project_state *State, ui *UI, sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray, uint16 CompIndex, v2 CompUV)
+Layer_TestForPoint(memory *Memory, project_state *State, ui *UI, sorted_comp_array *SortedCompArray, sorted_layer_array *SortedLayerArray, uint16 CompIndex, v2 CompPos, layer_transforms ExtraT)
{
block_composition *Comp = (block_composition *)Memory_Block_AddressAtIndex(Memory, F_Precomps, CompIndex);
sorted_comp_array SortedCompStart = SortedCompArray[CompIndex];
@@ -435,7 +435,16 @@ Layer_TestForPoint(memory *Memory, project_state *State, ui *UI, sorted_comp_arr
int Width, Height;
Layer_GetDimensions(Memory, Layer, &Width, &Height);
layer_transforms T = Layer_GetTransforms(Layer);
- v2 UV = T_CompUVToLayerUV(T, Comp->Width, Comp->Height, Width, Height, CompUV);
+ v2 NewPos = T_CompPosToLayerPos(T, Comp->Width, Comp->Height, Width, Height, CompPos.x, CompPos.y);
+ if (Layer->IsPrecomp) {
+ // only like 20% sure how this works...
+ layer_transforms NewExtraT = T;
+ NewExtraT.rotation = ExtraT.rotation - NewExtraT.rotation;
+ NewExtraT.scale = ExtraT.scale / NewExtraT.scale;
+ if (Layer_TestForPoint(Memory, State, UI, SortedCompArray, SortedLayerArray, Layer->Block_Source_Index, NewPos, NewExtraT))
+ return 1;
+ }
+ v2 UV = NewPos / V2(Width, Height);
if (UV.x <= 1.0f && UV.x >= 0.0f && UV.y <= 1.0f && UV.y >= 0.0f && ((Layer->IsSelected & 0x01) || Layer->IsPrecomp) && !Layer->IsLocked)
{
return 1;
@@ -645,8 +654,9 @@ Layer_TestBoxSelect(memory *Memory, project_state *State, ui *UI, sorted_comp_ar
nvg_point *NVGPointData = (nvg_point *)Memory_PushScratch(Memory, sizeof(nvg_point) * 1024);
v2 ShapeMin = {}, ShapeMax = {};
+ bool32 IsConvex = 0;
uint32 NumberOfVerts = NVG_FlattenPath(Memory, Shape, Layer->ShapeOpt, NVGPointData,
- State, T, Shape->Width, Shape->Height, Comp->Width, Comp->Height, 1, &ShapeMin, &ShapeMax);
+ State, T, Shape->Width, Shape->Height, Comp->Width, Comp->Height, 1, &ShapeMin, &ShapeMax, &IsConvex);
v2 Box[4] = { MinPos, V2(MinPos.x, MaxPos.y), MaxPos, V2(MaxPos.x, MinPos.y) };
if (Shape_TestBoxSelect(T, Comp->Width, Comp->Height, Shape->Width, Shape->Height, Box, NVGPointData, NumberOfVerts)) {
Layer_Select(Memory, State, Index_Physical);