summaryrefslogtreecommitdiff
path: root/src/bezier.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/bezier.cpp')
-rw-r--r--src/bezier.cpp58
1 files changed, 20 insertions, 38 deletions
diff --git a/src/bezier.cpp b/src/bezier.cpp
index dd3974d..8bfcf2b 100644
--- a/src/bezier.cpp
+++ b/src/bezier.cpp
@@ -134,14 +134,6 @@ Bezier_LookupAddress(memory *Memory, uint16 *Block_Bezier_Index, uint16 Index, b
return &Bezier->Point[SeekIndex];
}
-static bezier_point *
-Bezier_LookupAddress(memory *Memory, property_channel *Property, uint16 Index, bool32 AssertExists)
-{
- Assert(Index < MAX_KEYFRAMES_PER_BLOCK); // TODO(fox): Test multiple keyframe blocks!
- block_bezier *Bezier = (block_bezier *)Memory_Block_AddressAtIndex(Memory, F_Bezier, Property->Block_Bezier_Index[0], AssertExists);
- return &Bezier->Point[Index];
-}
-
static void
Bezier_Interact_Evaluate(project_state *State, bezier_point *PointAddress, v2 *Pos, real32 GraphZoomHeight, real32 Y_Increment)
{
@@ -191,41 +183,31 @@ Bezier_Add(memory *Memory, memory_table_list TableName, uint16 *Block_Bezier_Ind
}
static void
-Bezier_Add(memory *Memory, memory_table_list TableName, property_channel *Property, bezier_point PointData, uint16 *ArrayLocation)
+Bezier_Delete(memory *Memory, memory_table_list TableName, uint16 *Block_Bezier_Index, uint16 *PointCount, uint16 *ArrayLocation)
{
- if (!Property->Block_Bezier_Count) {
- // TODO(fox): Test multiple keyframe blocks!
- Assert(Property->Keyframe_Count < MAX_KEYFRAMES_PER_BLOCK);
- Property->Block_Bezier_Index[0] = Memory_Block_AllocateNew(Memory, F_Bezier);
- block_bezier *Bezier = (block_bezier *)Memory_Block_AddressAtIndex(Memory, F_Bezier, Property->Block_Bezier_Index[0], 0);
- Bezier->Occupied = true;
- History_Action_Swap(Memory, TableName, sizeof(Property->Block_Bezier_Count), &Property->Block_Bezier_Count);
- Property->Block_Bezier_Count++;
- }
- // First check to see if the point to add overlaps an existing keyframe:
- if (ArrayLocation) {
- for (int p = 0; p < Property->Keyframe_Count; p++) {
- int k = ArrayLocation[p];
- bezier_point *Point = Bezier_LookupAddress(Memory, Property, k);
- if (Point->Pos[0].x == PointData.Pos[0].x) {
- History_Action_Swap(Memory, F_Bezier, sizeof(*Point), Point);
- *Point = PointData;
- return;
- }
+ for (int p = 0; p < *PointCount; p++) {
+ int k = ArrayLocation[p];
+ bezier_point *Point = Bezier_LookupAddress(Memory, Block_Bezier_Index, k);
+ if (Point->IsSelected) {
+ History_Action_Swap(Memory, F_Bezier, sizeof(Point->Occupied), &Point->Occupied);
+ Point->Occupied = 0;
+ History_Action_Swap(Memory, TableName, sizeof(*PointCount), PointCount);
+ *PointCount -= 1;
}
}
- int k = 0;
- for (;;) {
- bezier_point *Point = Bezier_LookupAddress(Memory, Property, k, 0);
- if (!Point->Occupied) {
- History_Action_Swap(Memory, F_Bezier, sizeof(*Point), Point);
- *Point = PointData;
- History_Action_Swap(Memory, TableName, sizeof(Property->Keyframe_Count), &Property->Keyframe_Count);
- Property->Keyframe_Count++;
- return;
+}
+
+static int32
+Bezier_CheckSameX(memory *Memory, memory_table_list TableName, uint16 *Block_Bezier_Index, uint16 KeyframeCount, uint16 *ArrayLocation, real32 ValX)
+{
+ for (int p = 0; p < KeyframeCount; p++) {
+ int k = ArrayLocation[p];
+ bezier_point *Point = Bezier_LookupAddress(Memory, Block_Bezier_Index, k);
+ if (Point->Pos[0].x == ValX) {
+ return k;
}
- k++;
}
+ return -1;
}
// return all points