diff options
author | Fox Caminiti <fox@foxcam.net> | 2023-01-04 18:30:56 -0500 |
---|---|---|
committer | Fox Caminiti <fox@foxcam.net> | 2023-01-04 18:30:56 -0500 |
commit | eebbdd012b0d156e9e92369585c6ad82ed3de371 (patch) | |
tree | bbaeec7569de49f68bf853158a95c095878cf825 /src/bezier.cpp | |
parent | a37ea807e93886e6a6ebc22a878a5649e97f015a (diff) |
shapes; remove stencil buffer?
Diffstat (limited to 'src/bezier.cpp')
-rw-r--r-- | src/bezier.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/bezier.cpp b/src/bezier.cpp index ac89ed3..420cae1 100644 --- a/src/bezier.cpp +++ b/src/bezier.cpp @@ -35,6 +35,19 @@ Bezier_SolveYForX(v2 Point_P0, v2 Point_P1, v2 Point_P2, v2 Point_P3, real32 Tar } static bezier_point * +Bezier_LookupAddress(memory *Memory, uint16 *Block_Bezier_Index, uint16 Index, bool32 AssertExists) +{ + Assert(Index < (MAX_KEYFRAMES_PER_BLOCK * MAX_KEYFRAME_BLOCKS)); + int SeekBlock = Index / MAX_KEYFRAMES_PER_BLOCK; + int SeekIndex = Index - (SeekBlock * MAX_KEYFRAMES_PER_BLOCK); + block_bezier *Bezier = (block_bezier *)Memory_Block_AddressAtIndex(Memory, F_Bezier, Block_Bezier_Index[SeekBlock], 0); + Assert(Bezier->Occupied); + if (AssertExists) + Assert(Bezier->Point[SeekIndex].Occupied); + 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! @@ -65,6 +78,32 @@ Bezier_Interact_Evaluate(project_state *State, bezier_point *PointAddress, v2 *P } static void +Bezier_Add(memory *Memory, memory_table_list TableName, uint16 *Block_Bezier_Index, uint16 *Block_Bezier_Count, + uint16 *PointCount, bezier_point PointData) +{ + int k = 0; + for (;;) { + int SeekBlock = k / MAX_KEYFRAMES_PER_BLOCK; + if ((SeekBlock + 1) > *Block_Bezier_Count) { + Block_Bezier_Index[SeekBlock] = Memory_Block_AllocateNew(Memory, F_Bezier); + block_bezier *Bezier = (block_bezier *)Memory_Block_AddressAtIndex(Memory, F_Bezier, Block_Bezier_Index[SeekBlock], 0); + Bezier->Occupied = true; + History_Action_Swap(Memory, TableName, sizeof(*Block_Bezier_Count), Block_Bezier_Count); + *Block_Bezier_Count += 1; + } + bezier_point *Point = Bezier_LookupAddress(Memory, Block_Bezier_Index, k, 0); + if (!Point->Occupied) { + History_Action_Swap(Memory, F_Bezier, sizeof(*Point), Point); + *Point = PointData; + History_Action_Swap(Memory, TableName, sizeof(*PointCount), PointCount); + *PointCount += 1; + return; + } + k++; + } +} + +static void Bezier_Add(memory *Memory, memory_table_list TableName, property_channel *Property, bezier_point PointData, uint16 *ArrayLocation) { if (!Property->Block_Bezier_Count) { |