summaryrefslogtreecommitdiff
path: root/src/prenderer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/prenderer.cpp')
-rw-r--r--src/prenderer.cpp82
1 files changed, 23 insertions, 59 deletions
diff --git a/src/prenderer.cpp b/src/prenderer.cpp
index 11f72f6..0af9911 100644
--- a/src/prenderer.cpp
+++ b/src/prenderer.cpp
@@ -63,20 +63,9 @@ Transform_ScreenSpaceToLocal(layer_transforms T, uint32 FileWidth, uint32 FileHe
// Transform given data based on state's Interact data.
static void
-Transform_ApplyInteractive(interact_transform Interact, real32 *OutputX, real32 *OutputY, real32 *OutputRotation, real32 *OutputScale)
+Transform_ApplyLocal(interact_transform Interact, v2 Position, v2 Center,
+ real32 *OutputX, real32 *OutputY, real32 *OutputRotation, real32 *OutputScale)
{
- v2 BoxLength = Interact.Max - Interact.Min;
- v2 Center = Interact.Max - (BoxLength/2);
- if (Interact.RadianOffset != 0.0f) {
- v2 LocalCenter = Interact.NewCenter;
- real32 Rad = Interact.RadianOffset;
- real32 Point0X = Center.x - Interact.OGCenter.x;
- real32 Point0Y = Center.y - Interact.OGCenter.y;
- v2 XAxis = (Point0X * 1.0f)*V2(cos(Rad), sin(Rad));
- v2 YAxis = (Point0Y * 1.0f)*V2(sin(Rad), -cos(Rad));
- Center = Interact.OGCenter + XAxis + YAxis;
- }
-
real32 Point0X = Center.x - *OutputX;
real32 Point0Y = Center.y - *OutputY;
@@ -89,13 +78,31 @@ Transform_ApplyInteractive(interact_transform Interact, real32 *OutputX, real32
real32 X0 = -XAxis.x - YAxis.x + Center.x;
real32 Y0 = -XAxis.y - YAxis.y + Center.y;
- *OutputX = X0 + Interact.Position.x;
- *OutputY = Y0 + Interact.Position.y;
+ *OutputX = X0 + Position.x;
+ *OutputY = Y0 + Position.y;
*OutputRotation += Rotation;
- // *OutputScale += Interact.Scale - 1.0f;
*OutputScale *= Interact.Scale;
}
+// TODO(fox): Clean up function to do the RadianOffset rotation earlier in the loops of where the function is called
+static void
+Transform_ApplyInteractive(interact_transform Interact, real32 *OutputX, real32 *OutputY, real32 *OutputRotation, real32 *OutputScale)
+{
+ v2 BoxLength = Interact.Max - Interact.Min;
+ v2 Center = Interact.Max - (BoxLength/2);
+ if (Interact.RadianOffset != 0.0f) {
+ v2 LocalCenter = Interact.NewCenter;
+ real32 Rad = Interact.RadianOffset;
+ real32 Point0X = Center.x - Interact.OGCenter.x;
+ real32 Point0Y = Center.y - Interact.OGCenter.y;
+ v2 XAxis = (Point0X * 1.0f)*V2(cos(Rad), sin(Rad));
+ v2 YAxis = (Point0Y * 1.0f)*V2(sin(Rad), -cos(Rad));
+ Center = Interact.OGCenter + XAxis + YAxis;
+ }
+
+ Transform_ApplyLocal(Interact, Interact.Position, Center, OutputX, OutputY, OutputRotation, OutputScale);
+}
+
static v2
TransformVec(layer_transforms T, real32 Width, real32 Height, v2 Point)
{
@@ -107,36 +114,6 @@ TransformVec(layer_transforms T, real32 Width, real32 Height, v2 Point)
}
static void
-Transform_ApplyLocal(interact_transform Interact, layer_transforms T, layer_transforms ExtraT, v2 Center,
- real32 CompWidth, real32 CompHeight, real32 Width, real32 Height,
- real32 *OutputX, real32 *OutputY, real32 *OutputRotation, real32 *OutputScale)
-{
- v2 Position = Interact.Position;
- if (ExtraT.scale) {
- v2 CompPosition = TransformVec(ExtraT, CompWidth, CompHeight, Interact.Position);
- Position = CompPosition;
- }
-
- real32 Point0X = Center.x - *OutputX;
- real32 Point0Y = Center.y - *OutputY;
-
- real32 Rad = Interact.Radians;
- real32 Rotation = Rad / (PI / 180);
-
- v2 XAxis = (Point0X * Interact.Scale)*V2(cos(Rad), sin(Rad));
- v2 YAxis = (Point0Y * -Interact.Scale)*V2(sin(Rad), -cos(Rad));
-
- real32 X0 = -XAxis.x - YAxis.x + Center.x;
- real32 Y0 = -XAxis.y - YAxis.y + Center.y;
-
- *OutputX = X0 + Position.x;
- *OutputY = Y0 + Position.y;
- *OutputRotation += Rotation;
- // *OutputScale += Interact.Scale - 1.0f;
- *OutputScale *= Interact.Scale;
-}
-
-static void
Transform_IterateOuterBounds(block_layer *Layer, uint32 Width, uint32 Height, real32 *MinX, real32 *MinY, real32 *MaxX, real32 *MaxY)
{
real32 Rad = (Layer->rotation.CurrentValue * (PI / 180));
@@ -353,19 +330,6 @@ 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)
{