From eebbdd012b0d156e9e92369585c6ad82ed3de371 Mon Sep 17 00:00:00 2001 From: Fox Caminiti Date: Wed, 4 Jan 2023 18:30:56 -0500 Subject: shapes; remove stencil buffer? --- src/bezier.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/bezier.cpp') diff --git a/src/bezier.cpp b/src/bezier.cpp index ac89ed3..420cae1 100644 --- a/src/bezier.cpp +++ b/src/bezier.cpp @@ -34,6 +34,19 @@ Bezier_SolveYForX(v2 Point_P0, v2 Point_P1, v2 Point_P2, v2 Point_P3, real32 Tar return Y; } +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) { @@ -64,6 +77,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) { -- cgit v1.2.3