Did a bunch of stuff with nodes
This commit is contained in:
parent
25d9fda391
commit
834aab2671
|
@ -571,7 +571,7 @@ int main(int ArgCount, char** ArgV)
|
||||||
InitMemoryArena(&SourceFileArena, 0, 0, StdAlloc);
|
InitMemoryArena(&SourceFileArena, 0, 0, StdAlloc);
|
||||||
|
|
||||||
code_block_builder NodeTypeBlock = InitCodeBlockBuilder();
|
code_block_builder NodeTypeBlock = InitCodeBlockBuilder();
|
||||||
CodeBlockPrint(&NodeTypeBlock, MakeStringLiteral("enum node_type\n{\nNodeType_OutputNode,\n"));
|
CodeBlockPrint(&NodeTypeBlock, MakeStringLiteral("enum node_type\n{\n"));
|
||||||
|
|
||||||
code_block_builder NodeMembersBlock = InitCodeBlockBuilder();
|
code_block_builder NodeMembersBlock = InitCodeBlockBuilder();
|
||||||
|
|
||||||
|
@ -580,7 +580,10 @@ int main(int ArgCount, char** ArgV)
|
||||||
|
|
||||||
code_block_builder CallNodeProcBlock = InitCodeBlockBuilder();
|
code_block_builder CallNodeProcBlock = InitCodeBlockBuilder();
|
||||||
CodeBlockPrint(&CallNodeProcBlock, MakeStringLiteral("internal void CallNodeProc(node_header* Node, u8* Data, led* LEDs, s32 LEDsCount, r32 DeltaTime)\n{\n"));
|
CodeBlockPrint(&CallNodeProcBlock, MakeStringLiteral("internal void CallNodeProc(node_header* Node, u8* Data, led* LEDs, s32 LEDsCount, r32 DeltaTime)\n{\n"));
|
||||||
CodeBlockPrint(&CallNodeProcBlock, MakeStringLiteral("switch (Node->Type)\n{\n"));
|
CodeBlockPrint(&CallNodeProcBlock,
|
||||||
|
MakeStringLiteral("node_specification Spec = NodeSpecifications[Node->Type];\n"));
|
||||||
|
CodeBlockPrint(&CallNodeProcBlock, MakeStringLiteral("switch (Spec.Type)\n{\n"));
|
||||||
|
|
||||||
|
|
||||||
// Build Search Paths Array
|
// Build Search Paths Array
|
||||||
s32 SearchPathsCount = 1; //ArgCount - 1;
|
s32 SearchPathsCount = 1; //ArgCount - 1;
|
||||||
|
|
|
@ -345,6 +345,8 @@ RELOAD_STATIC_DATA(ReloadStaticData)
|
||||||
app_state* State = (app_state*)Context.MemoryBase;
|
app_state* State = (app_state*)Context.MemoryBase;
|
||||||
|
|
||||||
GlobalDebugServices = DebugServices;
|
GlobalDebugServices = DebugServices;
|
||||||
|
GSAlloc = Alloc;
|
||||||
|
GSFree = Free;
|
||||||
|
|
||||||
if (State->DefaultInputCommandRegistry.Size > 0)
|
if (State->DefaultInputCommandRegistry.Size > 0)
|
||||||
{
|
{
|
||||||
|
@ -461,7 +463,7 @@ INITIALIZE_APPLICATION(InitializeApplication)
|
||||||
|
|
||||||
GlobalDebugServices->Interface.RenderSculpture = true;
|
GlobalDebugServices->Interface.RenderSculpture = true;
|
||||||
|
|
||||||
State->NodeList = AllocateNodeList(State->Permanent, 512); //Kilobytes(64));
|
State->NodeList = AllocateNodeList(State->Permanent, 128);
|
||||||
State->OutputNode = PushOutputNodeOnList(State->NodeList, v2{500, 250}, State->Permanent);
|
State->OutputNode = PushOutputNodeOnList(State->NodeList, v2{500, 250}, State->Permanent);
|
||||||
{
|
{
|
||||||
State->NodeRenderSettings.PortColors[MemberType_r32] = RedV4;
|
State->NodeRenderSettings.PortColors[MemberType_r32] = RedV4;
|
||||||
|
@ -469,7 +471,7 @@ INITIALIZE_APPLICATION(InitializeApplication)
|
||||||
State->NodeRenderSettings.PortColors[MemberType_v4] = BlueV4;
|
State->NodeRenderSettings.PortColors[MemberType_v4] = BlueV4;
|
||||||
State->NodeRenderSettings.Font = State->Font;
|
State->NodeRenderSettings.Font = State->Font;
|
||||||
}
|
}
|
||||||
ReloadStaticData(Context, GlobalDebugServices);
|
ReloadStaticData(Context, GlobalDebugServices, Alloc, Free);
|
||||||
|
|
||||||
{ // MODES PLAYGROUND
|
{ // MODES PLAYGROUND
|
||||||
State->Modes.ActiveModesCount = 0;
|
State->Modes.ActiveModesCount = 0;
|
||||||
|
|
|
@ -211,17 +211,9 @@ DrawDebugInterface (render_command_buffer* RenderBuffer, r32 StartX, interface_c
|
||||||
|
|
||||||
r32 FramesPerSecond = 1.0f / DeltaTime;
|
r32 FramesPerSecond = 1.0f / DeltaTime;
|
||||||
|
|
||||||
string ModeName = MakeStringLiteral("Base Mode");
|
PrintF(&DebugString, "Framerate: %.*f s %d fps | Modes: %d Memory Used: %d / %d | Commands: %d",
|
||||||
if (State->Modes.ActiveModesCount > 0 &&
|
|
||||||
State->Modes.ActiveModes[State->Modes.ActiveModesCount - 1].Name.Length > 0)
|
|
||||||
{
|
|
||||||
ModeName = State->Modes.ActiveModes[State->Modes.ActiveModesCount - 1].Name;
|
|
||||||
}
|
|
||||||
|
|
||||||
PrintF(&DebugString, "Framerate: %.*f s %d fps | Current Mode: %.*s Modes: %d Memory Used: %d / %d | Commands: %d",
|
|
||||||
5, DeltaTime,
|
5, DeltaTime,
|
||||||
(u32)FramesPerSecond,
|
(u32)FramesPerSecond,
|
||||||
ModeName.Length, ModeName.Memory,
|
|
||||||
State->Modes.ActiveModesCount,
|
State->Modes.ActiveModesCount,
|
||||||
State->Modes.Arena.CurrentRegion->Used,
|
State->Modes.Arena.CurrentRegion->Used,
|
||||||
State->Modes.Arena.CurrentRegion->Size,
|
State->Modes.Arena.CurrentRegion->Size,
|
||||||
|
|
|
@ -113,7 +113,7 @@ input_command UniverseViewCommands [] = {
|
||||||
|
|
||||||
FOLDHAUS_INPUT_COMMAND_PROC(OpenUniverseView)
|
FOLDHAUS_INPUT_COMMAND_PROC(OpenUniverseView)
|
||||||
{
|
{
|
||||||
operation_mode* UniverseViewMode = ActivateOperationModeWithCommands(&State->Modes, "Universe View", UniverseViewCommands);
|
operation_mode* UniverseViewMode = ActivateOperationModeWithCommands(&State->Modes, UniverseViewCommands);
|
||||||
UniverseViewMode->Render = RenderUniverseView;
|
UniverseViewMode->Render = RenderUniverseView;
|
||||||
|
|
||||||
// State Setup
|
// State Setup
|
||||||
|
@ -183,7 +183,7 @@ FOLDHAUS_INPUT_COMMAND_PROC(SelectAndCloseNodeLister)
|
||||||
if (FilteredNodeIndex >= 0)
|
if (FilteredNodeIndex >= 0)
|
||||||
{
|
{
|
||||||
s32 NodeIndex = OpState->SearchLister.FilteredIndexLUT[FilteredNodeIndex];
|
s32 NodeIndex = OpState->SearchLister.FilteredIndexLUT[FilteredNodeIndex];
|
||||||
PushNodeOnListFromSpecification(State->NodeList, NodeSpecifications[NodeIndex],
|
PushNodeOnListFromSpecification(State->NodeList, (node_type)NodeIndex,
|
||||||
Mouse.Pos, State->Permanent);
|
Mouse.Pos, State->Permanent);
|
||||||
}
|
}
|
||||||
CloseNodeLister(State, Event, Mouse);
|
CloseNodeLister(State, Event, Mouse);
|
||||||
|
@ -200,7 +200,7 @@ input_command UniverseViewCommads [] = {
|
||||||
|
|
||||||
FOLDHAUS_INPUT_COMMAND_PROC(OpenNodeLister)
|
FOLDHAUS_INPUT_COMMAND_PROC(OpenNodeLister)
|
||||||
{
|
{
|
||||||
operation_mode* AddNodeOperation = ActivateOperationModeWithCommands(&State->Modes, "Node Lister", UniverseViewCommads);
|
operation_mode* AddNodeOperation = ActivateOperationModeWithCommands(&State->Modes, UniverseViewCommads);
|
||||||
|
|
||||||
AddNodeOperation->Render = RenderNodeLister;
|
AddNodeOperation->Render = RenderNodeLister;
|
||||||
|
|
||||||
|
@ -246,6 +246,11 @@ CloseColorPicker(app_state* State)
|
||||||
DeactivateCurrentOperationMode(&State->Modes);
|
DeactivateCurrentOperationMode(&State->Modes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FOLDHAUS_INPUT_COMMAND_PROC(CloseColorPickerCommand)
|
||||||
|
{
|
||||||
|
CloseColorPicker(State);
|
||||||
|
}
|
||||||
|
|
||||||
OPERATION_RENDER_PROC(RenderColorPicker)
|
OPERATION_RENDER_PROC(RenderColorPicker)
|
||||||
{
|
{
|
||||||
color_picker_operation_state* OpState = (color_picker_operation_state*)Operation.OpStateMemory;
|
color_picker_operation_state* OpState = (color_picker_operation_state*)Operation.OpStateMemory;
|
||||||
|
@ -260,16 +265,20 @@ OPERATION_RENDER_PROC(RenderColorPicker)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input_command ColorPickerCommands [] = {
|
||||||
|
{ KeyCode_Esc, KeyCode_Invalid, Command_Began, CloseColorPickerCommand },
|
||||||
|
};
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
OpenColorPicker(app_state* State, node_connection* Connection)
|
OpenColorPicker(app_state* State, node_connection* Connection)
|
||||||
{
|
{
|
||||||
operation_mode* ColorPickerMode = ActivateOperationMode(&State->Modes, "Color Picker");
|
operation_mode* ColorPickerMode = ActivateOperationModeWithCommands(&State->Modes, ColorPickerCommands);
|
||||||
ColorPickerMode->Render = RenderColorPicker;
|
ColorPickerMode->Render = RenderColorPicker;
|
||||||
|
|
||||||
color_picker_operation_state* OpState = CreateOperationState(ColorPickerMode,
|
color_picker_operation_state* OpState = CreateOperationState(ColorPickerMode,
|
||||||
&State->Modes,
|
&State->Modes,
|
||||||
color_picker_operation_state);
|
color_picker_operation_state);
|
||||||
OpState->ValueAddr = &Connection->V4Value;
|
OpState->ValueAddr = Connection->V4ValuePtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -294,10 +303,9 @@ internal void
|
||||||
BeginNodeFieldTextEdit(app_state* State, node_connection* Connection)
|
BeginNodeFieldTextEdit(app_state* State, node_connection* Connection)
|
||||||
{
|
{
|
||||||
operation_mode* NodeFieldTextEditMode = ActivateOperationModeWithCommands(&State->Modes,
|
operation_mode* NodeFieldTextEditMode = ActivateOperationModeWithCommands(&State->Modes,
|
||||||
"Node Field Text Edit",
|
|
||||||
NodeFieldTextEditCommands);
|
NodeFieldTextEditCommands);
|
||||||
|
|
||||||
SetTextInputDestinationToFloat(&State->ActiveTextEntry, &Connection->R32Value);
|
SetTextInputDestinationToFloat(&State->ActiveTextEntry, Connection->R32ValuePtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
|
@ -335,7 +343,6 @@ BeginDraggingNodePort(app_state* State, node_interaction Interaction)
|
||||||
{
|
{
|
||||||
operation_mode* DragNodePortMode = ActivateOperationModeWithCommands(
|
operation_mode* DragNodePortMode = ActivateOperationModeWithCommands(
|
||||||
&State->Modes,
|
&State->Modes,
|
||||||
"Drag Node Port",
|
|
||||||
DragNodePortInputCommands);
|
DragNodePortInputCommands);
|
||||||
DragNodePortMode->Render = RenderDraggingNodePort;
|
DragNodePortMode->Render = RenderDraggingNodePort;
|
||||||
|
|
||||||
|
@ -395,7 +402,6 @@ BeginDraggingNode(app_state* State, node_interaction Interaction)
|
||||||
{
|
{
|
||||||
operation_mode* DragNodeMode = ActivateOperationModeWithCommands(
|
operation_mode* DragNodeMode = ActivateOperationModeWithCommands(
|
||||||
&State->Modes,
|
&State->Modes,
|
||||||
"Drag Node",
|
|
||||||
DragNodeInputCommands);
|
DragNodeInputCommands);
|
||||||
DragNodeMode->Render = RenderDraggingNode;
|
DragNodeMode->Render = RenderDraggingNode;
|
||||||
|
|
||||||
|
@ -503,7 +509,8 @@ OPERATION_RENDER_PROC(RenderNodeView)
|
||||||
|
|
||||||
// TODO(Peter): This is just for debug purposes. We can remove and go back to just having
|
// TODO(Peter): This is just for debug purposes. We can remove and go back to just having
|
||||||
// Node->Name in DrawString
|
// Node->Name in DrawString
|
||||||
PrintF(&NodeHeaderBuffer, "%.*s: %d", Node->Name.Length, Node->Name.Memory, Node->Handle);
|
string NodeName = GetNodeName(*Node);
|
||||||
|
PrintF(&NodeHeaderBuffer, "%.*s: %d", NodeName.Length, NodeName.Memory, Node->Handle);
|
||||||
DrawString(RenderBuffer, NodeHeaderBuffer, State->NodeRenderSettings.Font,
|
DrawString(RenderBuffer, NodeHeaderBuffer, State->NodeRenderSettings.Font,
|
||||||
v2{NodeBounds.Min.x + 5, NodeBounds.Max.y - (State->NodeRenderSettings.Font->PixelHeight + NODE_HEADER_HEIGHT + 5)},
|
v2{NodeBounds.Min.x + 5, NodeBounds.Max.y - (State->NodeRenderSettings.Font->PixelHeight + NODE_HEADER_HEIGHT + 5)},
|
||||||
WhiteV4);
|
WhiteV4);
|
||||||
|
@ -527,7 +534,7 @@ OPERATION_RENDER_PROC(RenderNodeView)
|
||||||
//
|
//
|
||||||
if (Node->Type != NodeType_OutputNode && DrawFields)
|
if (Node->Type != NodeType_OutputNode && DrawFields)
|
||||||
{
|
{
|
||||||
node_specification Spec = NodeSpecifications[Node->Type - 1];
|
node_specification Spec = NodeSpecifications[Node->Type];
|
||||||
node_struct_member Member = Spec.MemberList[Connection];
|
node_struct_member Member = Spec.MemberList[Connection];
|
||||||
DrawString(RenderBuffer, MakeString(Member.Name),
|
DrawString(RenderBuffer, MakeString(Member.Name),
|
||||||
State->NodeRenderSettings.Font,
|
State->NodeRenderSettings.Font,
|
||||||
|
@ -558,7 +565,7 @@ OPERATION_RENDER_PROC(RenderNodeView)
|
||||||
|
|
||||||
if (DrawFields)
|
if (DrawFields)
|
||||||
{
|
{
|
||||||
node_specification Spec = NodeSpecifications[Node->Type - 1];
|
node_specification Spec = NodeSpecifications[Node->Type];
|
||||||
node_struct_member Member = Spec.MemberList[Connection];
|
node_struct_member Member = Spec.MemberList[Connection];
|
||||||
DrawString(RenderBuffer, MakeString(Member.Name),
|
DrawString(RenderBuffer, MakeString(Member.Name),
|
||||||
State->NodeRenderSettings.Font,
|
State->NodeRenderSettings.Font,
|
||||||
|
@ -605,12 +612,13 @@ input_command NodeViewCommands [] = {
|
||||||
|
|
||||||
FOLDHAUS_INPUT_COMMAND_PROC(OpenNodeView)
|
FOLDHAUS_INPUT_COMMAND_PROC(OpenNodeView)
|
||||||
{
|
{
|
||||||
operation_mode* NodeViewMode = ActivateOperationModeWithCommands(&State->Modes, "Node View", NodeViewCommands);
|
operation_mode* NodeViewMode = ActivateOperationModeWithCommands(&State->Modes, NodeViewCommands);
|
||||||
NodeViewMode->Render = RenderNodeView;
|
NodeViewMode->Render = RenderNodeView;
|
||||||
|
|
||||||
node_view_operation_state* OpState = CreateOperationState(NodeViewMode,
|
node_view_operation_state* OpState = CreateOperationState(NodeViewMode,
|
||||||
&State->Modes,
|
&State->Modes,
|
||||||
node_view_operation_state);
|
node_view_operation_state);
|
||||||
|
|
||||||
OpState->SelectedNodeHandle = 0;
|
OpState->SelectedNodeHandle = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -649,7 +657,7 @@ input_command MouseRotateViewCommands [] = {
|
||||||
|
|
||||||
FOLDHAUS_INPUT_COMMAND_PROC(Begin3DViewMouseRotate)
|
FOLDHAUS_INPUT_COMMAND_PROC(Begin3DViewMouseRotate)
|
||||||
{
|
{
|
||||||
operation_mode* RotateViewMode = ActivateOperationModeWithCommands(&State->Modes, "Rotate 3D View", MouseRotateViewCommands);
|
operation_mode* RotateViewMode = ActivateOperationModeWithCommands(&State->Modes, MouseRotateViewCommands);
|
||||||
RotateViewMode->Render = Update3DViewMouseRotate;
|
RotateViewMode->Render = Update3DViewMouseRotate;
|
||||||
|
|
||||||
mouse_rotate_view_operation_state* OpState = CreateOperationState(RotateViewMode,
|
mouse_rotate_view_operation_state* OpState = CreateOperationState(RotateViewMode,
|
||||||
|
|
|
@ -122,11 +122,10 @@ PushSize_ (memory_arena* Arena, u32 Size)
|
||||||
s32 RegionPagesNeeded = IntegerDivideRoundUp(SizeNeeded, MEMORY_REGION_PAGE_SIZE);
|
s32 RegionPagesNeeded = IntegerDivideRoundUp(SizeNeeded, MEMORY_REGION_PAGE_SIZE);
|
||||||
s32 SizeToAllocate = RegionPagesNeeded * MEMORY_REGION_PAGE_SIZE;
|
s32 SizeToAllocate = RegionPagesNeeded * MEMORY_REGION_PAGE_SIZE;
|
||||||
|
|
||||||
platform_memory_result AllocResult = Arena->PlatformAlloc(SizeToAllocate);
|
u8* AllocResult = Arena->PlatformAlloc(SizeToAllocate);
|
||||||
Assert(AllocResult.Error == PLATFORM_MEMORY_NO_ERROR);
|
Assert(AllocResult);
|
||||||
Assert(AllocResult.Size >= SizeNeeded);
|
|
||||||
|
|
||||||
memory_region* NewRegion = BootstrapRegionOntoMemory(AllocResult.Base, AllocResult.Size);
|
memory_region* NewRegion = BootstrapRegionOntoMemory(AllocResult, SizeToAllocate);
|
||||||
NewRegion->PreviousRegion = Arena->CurrentRegion;
|
NewRegion->PreviousRegion = Arena->CurrentRegion;
|
||||||
Arena->CurrentRegion = NewRegion;
|
Arena->CurrentRegion = NewRegion;
|
||||||
PushOntoRegion = Arena->CurrentRegion;
|
PushOntoRegion = Arena->CurrentRegion;
|
||||||
|
@ -177,11 +176,10 @@ AllocateNonGrowableArenaWithSpace(platform_alloc* PlatformAlloc, s32 SizeNeeded)
|
||||||
memory_arena Result = {};
|
memory_arena Result = {};
|
||||||
|
|
||||||
s32 AllocateSize = SizeNeeded + sizeof(memory_region);
|
s32 AllocateSize = SizeNeeded + sizeof(memory_region);
|
||||||
platform_memory_result Memory = PlatformAlloc(AllocateSize);
|
u8* Memory = PlatformAlloc(AllocateSize);
|
||||||
Assert(Memory.Error == PLATFORM_MEMORY_NO_ERROR);
|
Assert(Memory);
|
||||||
Assert(Memory.Size == AllocateSize);
|
|
||||||
|
|
||||||
InitMemoryArena(&Result, Memory.Base, Memory.Size, 0);
|
InitMemoryArena(&Result, Memory, AllocateSize, 0);
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,12 @@
|
||||||
inline s32
|
|
||||||
GetNodeMemorySize(s32 ConnectionsCount)
|
|
||||||
{
|
|
||||||
s32 Result = sizeof(node_header) + (sizeof(node_connection) * ConnectionsCount);
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline s32
|
|
||||||
GetNodeMemorySize (node_header Node)
|
|
||||||
{
|
|
||||||
return GetNodeMemorySize(Node.ConnectionsCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal node_list_iterator
|
internal node_list_iterator
|
||||||
GetNodeListIterator(node_list List)
|
GetNodeListIterator(node_list List)
|
||||||
{
|
{
|
||||||
node_list_iterator Result = {};
|
node_list_iterator Result = {};
|
||||||
Result.List = List;
|
Result.List = List;
|
||||||
Result.CurrentBuffer = List.First;
|
Result.CurrentBuffer = List.First;
|
||||||
Result.At = (node_header*)Result.CurrentBuffer->Memory;
|
Result.At = Result.CurrentBuffer->Headers;
|
||||||
|
Result.TotalIndexAt = 0;
|
||||||
|
Result.BufferIndexAt = 0;
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
@ -26,90 +15,106 @@ internal b32
|
||||||
NodeIteratorIsValid(node_list_iterator Iter)
|
NodeIteratorIsValid(node_list_iterator Iter)
|
||||||
{
|
{
|
||||||
b32 Result = (Iter.At != 0);
|
b32 Result = (Iter.At != 0);
|
||||||
Result &= (((u8*)Iter.At - Iter.CurrentBuffer->Memory) < Iter.CurrentBuffer->Used);
|
Result &= Iter.TotalIndexAt < Iter.List.TotalUsed && Iter.TotalIndexAt >= 0;
|
||||||
|
Result &= Iter.BufferIndexAt < Iter.CurrentBuffer->Used && Iter.BufferIndexAt >= 0;
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
Next (node_list_iterator* Iter)
|
Next (node_list_iterator* Iter)
|
||||||
{
|
{
|
||||||
if (Iter->At->Handle == 0)
|
if (Iter->BufferIndexAt < Iter->CurrentBuffer->Used)
|
||||||
{
|
{
|
||||||
node_free_list_member* FreeNode = (node_free_list_member*)Iter->At;
|
Iter->At++;
|
||||||
s32 SkipAmount = FreeNode->Size;
|
Iter->TotalIndexAt++;
|
||||||
Iter->At = (node_header*)((u8*)Iter->At + SkipAmount);
|
Iter->BufferIndexAt++;
|
||||||
|
if (Iter->At->Handle == 0) { Next(Iter); }
|
||||||
|
}
|
||||||
|
else if (Iter->CurrentBuffer->Next)
|
||||||
|
{
|
||||||
|
Iter->CurrentBuffer = Iter->CurrentBuffer->Next;
|
||||||
|
Iter->At = Iter->CurrentBuffer->Headers;
|
||||||
|
Iter->TotalIndexAt++;
|
||||||
|
Iter->BufferIndexAt = 0;
|
||||||
|
if (Iter->At->Handle == 0) { Next(Iter); }
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s32 SkipAmount = GetNodeMemorySize(*Iter->At);
|
Iter->At = 0;
|
||||||
if (((u8*)Iter->At - Iter->CurrentBuffer->Memory) + SkipAmount < Iter->CurrentBuffer->Used)
|
Iter->TotalIndexAt = -1;
|
||||||
{
|
Iter->BufferIndexAt = -1;
|
||||||
Iter->At = (node_header*)((u8*)Iter->At + SkipAmount);
|
|
||||||
if (Iter->At->Handle == 0) { Next(Iter); }
|
|
||||||
}
|
|
||||||
else if (Iter->CurrentBuffer->Next)
|
|
||||||
{
|
|
||||||
Iter->CurrentBuffer = Iter->CurrentBuffer->Next;
|
|
||||||
Iter->At = (node_header*)Iter->CurrentBuffer->Memory;
|
|
||||||
if (Iter->At->Handle == 0) { Next(Iter); }
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Iter->At = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal node_list_buffer*
|
internal node_list_buffer*
|
||||||
AllocateNodeListBuffer (memory_arena* Storage, s32 Size)
|
AllocateNodeListBuffer (memory_arena* Storage, s32 Count)
|
||||||
{
|
{
|
||||||
node_list_buffer* Result = PushStruct(Storage, node_list_buffer);;
|
node_list_buffer* Result = PushStruct(Storage, node_list_buffer);;
|
||||||
Result->Memory = PushSize(Storage, Size);
|
Result->Headers = PushArray(Storage, node_header, Count);
|
||||||
Result->Max = Size;
|
Result->Max = Count;
|
||||||
Result->Used = 0;
|
Result->Used = 0;
|
||||||
Result->Next = 0;
|
Result->Next = 0;
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal node_list*
|
internal node_list*
|
||||||
AllocateNodeList (memory_arena* Storage, s32 InitialSize)
|
AllocateNodeList (memory_arena* Storage, s32 InitialCount)
|
||||||
{
|
{
|
||||||
node_list* Result = PushStruct(Storage, node_list);
|
node_list* Result = PushStruct(Storage, node_list);
|
||||||
Result->First = AllocateNodeListBuffer(Storage, InitialSize);
|
Result->First = AllocateNodeListBuffer(Storage, InitialCount);
|
||||||
Result->Head = Result->First;
|
Result->Head = Result->First;
|
||||||
Result->TotalMax = InitialSize;
|
Result->TotalMax = InitialCount;
|
||||||
Result->TotalUsed = 0;
|
Result->TotalUsed = 0;
|
||||||
Result->HandleAccumulator = 0;
|
Result->HandleAccumulator = 0;
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
global_variable char* OutputName = "Output";
|
||||||
|
|
||||||
|
internal string
|
||||||
|
GetNodeName (node_header Node)
|
||||||
|
{
|
||||||
|
string Result = {};
|
||||||
|
|
||||||
|
node_specification Spec = NodeSpecifications[Node.Type];
|
||||||
|
Result = MakeString(Spec.Name, Spec.NameLength);
|
||||||
|
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
internal node_header*
|
internal node_header*
|
||||||
PushNodeOnList (node_list* List, s32 ConnectionsCount, v2 Min, v2 Dim, memory_arena* Storage)
|
PushNodeOnList (node_list* List, s32 ConnectionsCount, v2 Min, v2 Dim, memory_arena* Storage)
|
||||||
{
|
{
|
||||||
node_header* Result = 0;
|
node_header* Result = 0;
|
||||||
|
|
||||||
s32 NodeMemorySize = GetNodeMemorySize(ConnectionsCount);
|
if ((List->TotalUsed + 1) >= List->TotalMax)
|
||||||
|
|
||||||
if (List->TotalUsed + NodeMemorySize >= List->TotalMax)
|
|
||||||
{
|
{
|
||||||
node_list_buffer* Buf = AllocateNodeListBuffer(Storage, List->Head->Max);
|
node_list_buffer* Buf = AllocateNodeListBuffer(Storage, List->Head->Max);
|
||||||
List->Head->Next = Buf;
|
List->Head->Next = Buf;
|
||||||
List->Head = Buf;
|
List->Head = Buf;
|
||||||
List->TotalMax += Buf->Max;
|
List->TotalMax += Buf->Max;
|
||||||
}
|
}
|
||||||
Assert(List->TotalUsed + NodeMemorySize <= List->TotalMax);
|
Assert(List->TotalUsed + 1 <= List->TotalMax);
|
||||||
|
|
||||||
Result = (node_header*)(List->Head->Memory + List->Head->Used);
|
Result = List->Head->Headers + List->Head->Used;
|
||||||
Result->Handle = ++List->HandleAccumulator;
|
Result->Handle = ++List->HandleAccumulator;
|
||||||
|
|
||||||
|
// :ConnectionsToStretchyBuffer
|
||||||
|
Assert(List->ConnectionsUsed + ConnectionsCount < NODE_LIST_CONNECTIONS_MAX);
|
||||||
Result->ConnectionsCount = ConnectionsCount;
|
Result->ConnectionsCount = ConnectionsCount;
|
||||||
Result->Connections = (node_connection*)(Result + 1);
|
Result->Connections = (node_connection*)(List->Connections + List->ConnectionsUsed);
|
||||||
|
List->ConnectionsUsed += ConnectionsCount;
|
||||||
|
|
||||||
|
for (s32 c = 0; c < Result->ConnectionsCount; c++)
|
||||||
|
{
|
||||||
|
Result->Connections[c].NodeHandle = Result->Handle;
|
||||||
|
}
|
||||||
|
|
||||||
Result->Min = Min;
|
Result->Min = Min;
|
||||||
Result->Dim = Dim;
|
Result->Dim = Dim;
|
||||||
|
|
||||||
List->Head->Used += NodeMemorySize;
|
List->Head->Used++;
|
||||||
List->TotalUsed += NodeMemorySize;
|
List->TotalUsed++;
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
@ -121,38 +126,42 @@ FreeNodeOnList (node_list* List, node_header* Node)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
InitializeNodeConnection (node_connection* Connection, struct_member_type Type, b32 DirectionMask)
|
InitializeNodeConnection (node_connection* Connection, node_struct_member Member, node_header* Node)
|
||||||
{
|
{
|
||||||
Connection->Type = Type;
|
Connection->Type = Member.Type;
|
||||||
Connection->UpstreamNodeHandle = 0;
|
Connection->UpstreamNodeHandle = 0;
|
||||||
Connection->UpstreamNodePortIndex = -1;
|
Connection->UpstreamNodePortIndex = -1;
|
||||||
Connection->DownstreamNodeHandle = 0;
|
Connection->DownstreamNodeHandle = 0;
|
||||||
Connection->DownstreamNodePortIndex = -1;
|
Connection->DownstreamNodePortIndex = -1;
|
||||||
Connection->DirectionMask = DirectionMask;
|
Connection->DirectionMask = Member.IsInput;
|
||||||
switch (Type)
|
|
||||||
|
Connection->Ptr = Node->PersistentData + Member.Offset;
|
||||||
|
|
||||||
|
switch (Member.Type)
|
||||||
{
|
{
|
||||||
case MemberType_s32:
|
case MemberType_s32:
|
||||||
{
|
{
|
||||||
Connection->S32Value = 0;
|
*Connection->S32ValuePtr = 0;
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case MemberType_r32:
|
case MemberType_r32:
|
||||||
{
|
{
|
||||||
Connection->R32Value = 0;
|
*Connection->R32ValuePtr = 0;
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case MemberType_v4:
|
case MemberType_v4:
|
||||||
{
|
{
|
||||||
Connection->V4Value = v4{0, 0, 0, 1};
|
*Connection->V4ValuePtr = v4{0, 0, 0, 1};
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case MemberType_NODE_COLOR_BUFFER:
|
case MemberType_NODE_COLOR_BUFFER:
|
||||||
{
|
{
|
||||||
Connection->LEDsValue = {};
|
*Connection->LEDsValuePtr = {};
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
InvalidDefaultCase;
|
InvalidDefaultCase;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline r32
|
inline r32
|
||||||
|
@ -162,51 +171,38 @@ CalculateNodeHeight (s32 Members)
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal node_header*
|
||||||
PushNodeOnListFromSpecification (node_list* List, node_specification Spec, v2 Min, memory_arena* Storage)
|
PushNodeOnListFromSpecification (node_list* List, node_type Type, v2 Min, memory_arena* Storage)
|
||||||
{
|
{
|
||||||
|
node_header* Node = 0;
|
||||||
|
|
||||||
|
node_specification Spec = NodeSpecifications[Type];
|
||||||
|
|
||||||
// :NodesDontNeedToKnowTheirBounds
|
// :NodesDontNeedToKnowTheirBounds
|
||||||
r32 NodeHeight = CalculateNodeHeight (Spec.MemberListLength);
|
r32 NodeHeight = CalculateNodeHeight (Spec.MemberListLength);
|
||||||
node_header* Node = PushNodeOnList(List,
|
Node = PushNodeOnList(List,
|
||||||
Spec.MemberListLength,
|
Spec.MemberListLength,
|
||||||
Min,
|
Min,
|
||||||
v2{150, NodeHeight},
|
v2{150, NodeHeight},
|
||||||
Storage);
|
Storage);
|
||||||
Node->Type = Spec.Type;
|
Node->Type = Type;
|
||||||
|
Node->PersistentData = PushArray(Storage, u8, Spec.DataStructSize);
|
||||||
// TODO(Peter): This doesn't work with code reloading, probably just want to store the spec index
|
|
||||||
// we'll get there
|
|
||||||
// :HotCodeReloading
|
|
||||||
Node->Name = MakeString(Spec.Name, Spec.NameLength);
|
|
||||||
|
|
||||||
node_struct_member* MemberList = Spec.MemberList;
|
node_struct_member* MemberList = Spec.MemberList;
|
||||||
for (s32 MemberIdx = 0; MemberIdx < Spec.MemberListLength; MemberIdx++)
|
for (s32 MemberIdx = 0; MemberIdx < Spec.MemberListLength; MemberIdx++)
|
||||||
{
|
{
|
||||||
node_struct_member Member = MemberList[MemberIdx];
|
node_struct_member Member = MemberList[MemberIdx];
|
||||||
InitializeNodeConnection(Node->Connections + MemberIdx, Member.Type, Member.IsInput);
|
InitializeNodeConnection(Node->Connections + MemberIdx, Member, Node);
|
||||||
}
|
}
|
||||||
|
|
||||||
Node->PersistentData = PushArray(Storage, u8, Spec.DataStructSize);
|
return Node;
|
||||||
}
|
}
|
||||||
|
|
||||||
global_variable char* OutputName = "Output";
|
|
||||||
|
|
||||||
internal node_header*
|
internal node_header*
|
||||||
PushOutputNodeOnList (node_list* List, v2 Min, memory_arena* Storage)
|
PushOutputNodeOnList (node_list* List, v2 Min, memory_arena* Storage)
|
||||||
{
|
{
|
||||||
node_header* Node = PushNodeOnList(List,
|
node_header* Result = PushNodeOnListFromSpecification(List, NodeType_OutputNode, Min, Storage);
|
||||||
1,
|
return Result;
|
||||||
Min,
|
|
||||||
DEFAULT_NODE_DIMENSION,
|
|
||||||
Storage);
|
|
||||||
Node->Type = NodeType_OutputNode;
|
|
||||||
|
|
||||||
// :HotCodeReloading
|
|
||||||
Node->Name = MakeString(OutputName);
|
|
||||||
|
|
||||||
InitializeNodeConnection(Node->Connections, MemberType_NODE_COLOR_BUFFER, IsInputMember);
|
|
||||||
|
|
||||||
return Node;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal node_header*
|
internal node_header*
|
||||||
|
@ -804,12 +800,12 @@ UpdateDraggingNodeValue (v2 MousePos, v2 LastFrameMousePos, node_interaction Int
|
||||||
{
|
{
|
||||||
case MemberType_s32:
|
case MemberType_s32:
|
||||||
{
|
{
|
||||||
Connection->S32Value += (s32)(MouseDelta.y * .05f);
|
*Connection->S32ValuePtr += (s32)(MouseDelta.y * .05f);
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case MemberType_r32:
|
case MemberType_r32:
|
||||||
{
|
{
|
||||||
Connection->R32Value += (MouseDelta.y * .05f);
|
*Connection->R32ValuePtr += (MouseDelta.y * .05f);
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case MemberType_v4:
|
case MemberType_v4:
|
||||||
|
@ -846,26 +842,29 @@ UpdateNodesConnectedUpstream (node_header* Node, node_list* NodeList,
|
||||||
{
|
{
|
||||||
UpdateNodeCalculation(UpstreamNode, NodeList, Permanent, Transient, LEDs, ColorsInit, LEDCount, DeltaTime);
|
UpdateNodeCalculation(UpstreamNode, NodeList, Permanent, Transient, LEDs, ColorsInit, LEDCount, DeltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
node_connection UpstreamConnection = UpstreamNode->Connections[Connection->UpstreamNodePortIndex];
|
||||||
|
|
||||||
switch (Connection->Type)
|
switch (Connection->Type)
|
||||||
{
|
{
|
||||||
case MemberType_s32:
|
case MemberType_s32:
|
||||||
{
|
{
|
||||||
Connection->S32Value = UpstreamNode->Connections[Connection->UpstreamNodePortIndex].S32Value;
|
*Connection->S32ValuePtr = *UpstreamConnection.S32ValuePtr;
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case MemberType_r32:
|
case MemberType_r32:
|
||||||
{
|
{
|
||||||
Connection->R32Value = UpstreamNode->Connections[Connection->UpstreamNodePortIndex].R32Value;
|
*Connection->R32ValuePtr = *UpstreamConnection.R32ValuePtr;
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case MemberType_v4:
|
case MemberType_v4:
|
||||||
{
|
{
|
||||||
Connection->V4Value = UpstreamNode->Connections[Connection->UpstreamNodePortIndex].V4Value;
|
*Connection->V4ValuePtr = *UpstreamConnection.V4ValuePtr;
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case MemberType_NODE_COLOR_BUFFER:
|
case MemberType_NODE_COLOR_BUFFER:
|
||||||
{
|
{
|
||||||
Connection->LEDsValue = UpstreamNode->Connections[Connection->UpstreamNodePortIndex].LEDsValue;
|
*Connection->LEDsValuePtr = *UpstreamConnection.LEDsValuePtr;
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
InvalidDefaultCase;
|
InvalidDefaultCase;
|
||||||
|
@ -882,10 +881,11 @@ UpdateNodeCalculation (node_header* Node, node_list* NodeList,
|
||||||
{
|
{
|
||||||
DEBUG_TRACK_FUNCTION;
|
DEBUG_TRACK_FUNCTION;
|
||||||
Assert(Node->PersistentData != 0);
|
Assert(Node->PersistentData != 0);
|
||||||
|
Assert(Node->Type != NodeType_OutputNode);
|
||||||
|
|
||||||
// NOTE(Peter): Have to subtract one here so that we account for the
|
// NOTE(Peter): Have to subtract one here so that we account for the
|
||||||
// NodeType_OutputNode entry in the enum
|
// NodeType_OutputNode entry in the enum
|
||||||
node_specification Spec = NodeSpecifications[Node->Type - 1];
|
node_specification Spec = NodeSpecifications[Node->Type];
|
||||||
node_struct_member* MemberList = Spec.MemberList;
|
node_struct_member* MemberList = Spec.MemberList;
|
||||||
|
|
||||||
// NOTE(Peter): We do this at the beginning in case there is a node connected to this one
|
// NOTE(Peter): We do this at the beginning in case there is a node connected to this one
|
||||||
|
@ -907,40 +907,15 @@ UpdateNodeCalculation (node_header* Node, node_list* NodeList,
|
||||||
// needs the leds to request that as its own member/parameter.
|
// needs the leds to request that as its own member/parameter.
|
||||||
if (Connection.Type == MemberType_NODE_COLOR_BUFFER)
|
if (Connection.Type == MemberType_NODE_COLOR_BUFFER)
|
||||||
{
|
{
|
||||||
node_led_color_connection* ColorConnection = (node_led_color_connection*)(Node->PersistentData + MemberList[ConnectionIdx].Offset);
|
node_led_color_connection* ColorConnection = Connection.LEDsValuePtr;
|
||||||
|
|
||||||
ColorConnection->LEDs = LEDs;
|
|
||||||
ColorConnection->LEDCount = LEDCount;
|
|
||||||
ColorConnection->Colors = Connection.LEDsValue.Colors;
|
|
||||||
|
|
||||||
if (!ColorConnection->Colors)
|
if (!ColorConnection->Colors)
|
||||||
{
|
{
|
||||||
sacn_pixel* ColorsCopy = PushArray(Transient, sacn_pixel, LEDCount);
|
sacn_pixel* ColorsCopy = PushArray(Transient, sacn_pixel, LEDCount);
|
||||||
GSMemSet((u8*)ColorsCopy, 0, sizeof(sacn_pixel) * LEDCount);
|
GSMemSet((u8*)ColorsCopy, 0, sizeof(sacn_pixel) * LEDCount);
|
||||||
|
|
||||||
ColorConnection->Colors = ColorsCopy;
|
ColorConnection->Colors = ColorsCopy;
|
||||||
}
|
ColorConnection->LEDs = LEDs;
|
||||||
}
|
ColorConnection->LEDCount = LEDCount;
|
||||||
else if (ConnectionIsInput(Connection))
|
|
||||||
{
|
|
||||||
Assert(Connection.Type != MemberType_NODE_COLOR_BUFFER);
|
|
||||||
switch (Connection.Type)
|
|
||||||
{
|
|
||||||
case MemberType_s32:
|
|
||||||
{
|
|
||||||
GSMemCopy(&Connection.S32Value, (Node->PersistentData + MemberList[ConnectionIdx].Offset), sizeof(s32));
|
|
||||||
}break;
|
|
||||||
|
|
||||||
case MemberType_r32:
|
|
||||||
{
|
|
||||||
GSMemCopy(&Connection.R32Value, (Node->PersistentData + MemberList[ConnectionIdx].Offset), sizeof(r32));
|
|
||||||
}break;
|
|
||||||
|
|
||||||
case MemberType_v4:
|
|
||||||
{
|
|
||||||
GSMemCopy(&Connection.V4Value, (Node->PersistentData + MemberList[ConnectionIdx].Offset), sizeof(v4));
|
|
||||||
}break;
|
|
||||||
|
|
||||||
InvalidDefaultCase;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -949,41 +924,8 @@ UpdateNodeCalculation (node_header* Node, node_list* NodeList,
|
||||||
|
|
||||||
for (s32 ConnectionIdx = 0; ConnectionIdx < Node->ConnectionsCount; ConnectionIdx++)
|
for (s32 ConnectionIdx = 0; ConnectionIdx < Node->ConnectionsCount; ConnectionIdx++)
|
||||||
{
|
{
|
||||||
node_connection* Connection = 0;
|
if (!ConnectionIsOutput(Node, ConnectionIdx)) { continue; }
|
||||||
if (ConnectionIsOutput(Node, ConnectionIdx))
|
node_connection* Connection = Node->Connections + ConnectionIdx;
|
||||||
{
|
|
||||||
Connection = Node->Connections + ConnectionIdx;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (Connection->Type)
|
|
||||||
{
|
|
||||||
case MemberType_s32:
|
|
||||||
{
|
|
||||||
GSMemCopy((Node->PersistentData + MemberList[ConnectionIdx].Offset), &Connection->S32Value, sizeof(s32));
|
|
||||||
}break;
|
|
||||||
|
|
||||||
case MemberType_r32:
|
|
||||||
{
|
|
||||||
GSMemCopy((Node->PersistentData + MemberList[ConnectionIdx].Offset), &Connection->R32Value, sizeof(r32));
|
|
||||||
}break;
|
|
||||||
|
|
||||||
case MemberType_v4:
|
|
||||||
{
|
|
||||||
GSMemCopy((Node->PersistentData + MemberList[ConnectionIdx].Offset), &Connection->V4Value, sizeof(v4));
|
|
||||||
}break;
|
|
||||||
|
|
||||||
case MemberType_NODE_COLOR_BUFFER:
|
|
||||||
{
|
|
||||||
node_led_color_connection* Value = (node_led_color_connection*)(Node->PersistentData + MemberList[ConnectionIdx].Offset);
|
|
||||||
Connection->LEDsValue.Colors = Value->Colors;
|
|
||||||
}break;
|
|
||||||
|
|
||||||
InvalidDefaultCase;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -993,13 +935,14 @@ UpdateOutputNodeCalculations (node_header* OutputNode, node_list* NodeList,
|
||||||
led* LEDs, sacn_pixel* Colors, s32 LEDCount, r32 DeltaTime)
|
led* LEDs, sacn_pixel* Colors, s32 LEDCount, r32 DeltaTime)
|
||||||
{
|
{
|
||||||
Assert(OutputNode->Type == NodeType_OutputNode);
|
Assert(OutputNode->Type == NodeType_OutputNode);
|
||||||
|
|
||||||
UpdateNodesConnectedUpstream(OutputNode, NodeList, Permanent, Transient, LEDs, Colors, LEDCount, DeltaTime);
|
UpdateNodesConnectedUpstream(OutputNode, NodeList, Permanent, Transient, LEDs, Colors, LEDCount, DeltaTime);
|
||||||
|
|
||||||
node_connection ColorsConnection = OutputNode->Connections[0];
|
node_connection ColorsConnection = OutputNode->Connections[0];
|
||||||
if (ColorsConnection.LEDsValue.Colors)
|
if (ColorsConnection.LEDsValuePtr->Colors)
|
||||||
{
|
{
|
||||||
sacn_pixel* DestPixel = Colors;
|
sacn_pixel* DestPixel = Colors;
|
||||||
sacn_pixel* SourcePixel = ColorsConnection.LEDsValue.Colors;
|
sacn_pixel* SourcePixel = ColorsConnection.LEDsValuePtr->Colors;
|
||||||
for (s32 i = 0; i < LEDCount; i++)
|
for (s32 i = 0; i < LEDCount; i++)
|
||||||
{
|
{
|
||||||
*DestPixel++ = *SourcePixel++;
|
*DestPixel++ = *SourcePixel++;
|
||||||
|
@ -1007,6 +950,53 @@ UpdateOutputNodeCalculations (node_header* OutputNode, node_list* NodeList,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// Trying to put updating nodes in terms of connections, rather than nodes.
|
||||||
|
internal void
|
||||||
|
UpdateAllNodesFloodFill (node_list* NodeList, memory_arena* Permanent, memory_arena* Transient, led* LEDs, sacn_pixel* Colors, s32 LEDCount, r32 DeltaTime)
|
||||||
|
{
|
||||||
|
s32 NodesUpdated = 0;
|
||||||
|
|
||||||
|
s32 DEBUGIterations = 0;
|
||||||
|
while(NodesUpdated < NodeList->TotalUsed)
|
||||||
|
{
|
||||||
|
node_list_iterator NodeIter = GetNodeListIterator(*NodeList);
|
||||||
|
while (NodeIteratorIsValid(NodeIter))
|
||||||
|
{
|
||||||
|
node_header* Node = NodeIter.At;
|
||||||
|
|
||||||
|
s32 ConnectionsReady = 0;
|
||||||
|
// Check if all upstream connections have been updated
|
||||||
|
// TODO(Peter): we should move the HasBeenUpdated field into the connections
|
||||||
|
// and have connections push their updates upstream
|
||||||
|
for (s32 c = 0; c < Node->ConnectionsCount; c++)
|
||||||
|
{
|
||||||
|
node_connection* Connection = Node->Connections + c;
|
||||||
|
if (ConnectionIsInput(*Connection) &&
|
||||||
|
ConnectionHasUpstreamConnection(*Connection))
|
||||||
|
{
|
||||||
|
node_header* UpstreamNode = GetNodeWithHandle(NodeList, Connection->UpstreamNodeHandle);
|
||||||
|
if (UpstreamNode->UpdatedThisFrame)
|
||||||
|
{
|
||||||
|
ConnectionsReady += 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ConnectionsReady == Node->ConnectionsCount)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DEBUGIterations++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
UpdateAllNodeCalculations (node_list* NodeList, memory_arena* Permanent, memory_arena* Transient, led* LEDs, sacn_pixel* Colors, s32 LEDCount, r32 DeltaTime)
|
UpdateAllNodeCalculations (node_list* NodeList, memory_arena* Permanent, memory_arena* Transient, led* LEDs, sacn_pixel* Colors, s32 LEDCount, r32 DeltaTime)
|
||||||
{
|
{
|
||||||
|
@ -1034,7 +1024,7 @@ ClearTransientNodeColorBuffers (node_list* NodeList)
|
||||||
node_connection* Connection = Node->Connections + ConnectionIdx;
|
node_connection* Connection = Node->Connections + ConnectionIdx;
|
||||||
if (Connection->Type == MemberType_NODE_COLOR_BUFFER)
|
if (Connection->Type == MemberType_NODE_COLOR_BUFFER)
|
||||||
{
|
{
|
||||||
Connection->LEDsValue.Colors = 0;
|
Connection->LEDsValuePtr->Colors = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Next(&NodeIter);
|
Next(&NodeIter);
|
||||||
|
@ -1053,19 +1043,19 @@ DrawValueDisplay (render_command_buffer* RenderBuffer, rect Bounds, node_connect
|
||||||
{
|
{
|
||||||
case MemberType_s32:
|
case MemberType_s32:
|
||||||
{
|
{
|
||||||
PrintF(&String, "%.*d", 4, Value.S32Value);
|
PrintF(&String, "%.*d", 4, *Value.S32ValuePtr);
|
||||||
DrawString(RenderBuffer, String, Font, Bounds.Min + v2{2, 2}, WhiteV4);
|
DrawString(RenderBuffer, String, Font, Bounds.Min + v2{2, 2}, WhiteV4);
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case MemberType_r32:
|
case MemberType_r32:
|
||||||
{
|
{
|
||||||
PrintF(&String, "%.*f", 4, Value.R32Value);
|
PrintF(&String, "%.*f", 4, *Value.R32ValuePtr);
|
||||||
DrawString(RenderBuffer, String, Font, Bounds.Min + v2{2, 2}, WhiteV4);
|
DrawString(RenderBuffer, String, Font, Bounds.Min + v2{2, 2}, WhiteV4);
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case MemberType_v4:
|
case MemberType_v4:
|
||||||
{
|
{
|
||||||
PushRenderQuad2D(RenderBuffer, Bounds.Min + v2{2, 2}, Bounds.Max - v2{2, 2}, Value.V4Value);
|
PushRenderQuad2D(RenderBuffer, Bounds.Min + v2{2, 2}, Bounds.Max - v2{2, 2}, *Value.V4ValuePtr);
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case MemberType_NODE_COLOR_BUFFER:
|
case MemberType_NODE_COLOR_BUFFER:
|
||||||
|
|
|
@ -64,10 +64,11 @@ struct node_connection
|
||||||
|
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
s32 S32Value;
|
u8* Ptr;
|
||||||
r32 R32Value;
|
s32* S32ValuePtr;
|
||||||
v4 V4Value;
|
r32* R32ValuePtr;
|
||||||
node_led_color_connection LEDsValue;
|
v4* V4ValuePtr;
|
||||||
|
node_led_color_connection* LEDsValuePtr;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -77,19 +78,19 @@ struct node_connection
|
||||||
struct node_header
|
struct node_header
|
||||||
{
|
{
|
||||||
s32 Handle; // NOTE(Peter): stores a non-zero handle. must come first to match node_free_list_member
|
s32 Handle; // NOTE(Peter): stores a non-zero handle. must come first to match node_free_list_member
|
||||||
string Name;
|
node_type Type;
|
||||||
|
|
||||||
v2 Min, Dim;
|
v2 Min, Dim;
|
||||||
|
|
||||||
s32 ConnectionsCount;
|
s32 ConnectionsCount;
|
||||||
node_connection* Connections;
|
node_connection* Connections;
|
||||||
|
|
||||||
node_type Type;
|
|
||||||
b32 UpdatedThisFrame;
|
b32 UpdatedThisFrame;
|
||||||
|
|
||||||
u8* PersistentData;
|
u8* PersistentData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO(Peter): @Remove Confirm we don't need it first
|
||||||
struct node_free_list_member
|
struct node_free_list_member
|
||||||
{
|
{
|
||||||
s32 Handle; // NOTE(Peter): this will always be zero, and must come first to match node_header
|
s32 Handle; // NOTE(Peter): this will always be zero, and must come first to match node_header
|
||||||
|
@ -100,7 +101,7 @@ struct node_free_list_member
|
||||||
|
|
||||||
struct node_list_buffer
|
struct node_list_buffer
|
||||||
{
|
{
|
||||||
u8* Memory;
|
node_header* Headers;
|
||||||
s32 Max;
|
s32 Max;
|
||||||
s32 Used;
|
s32 Used;
|
||||||
|
|
||||||
|
@ -117,6 +118,8 @@ struct node_list
|
||||||
|
|
||||||
s32 HandleAccumulator;
|
s32 HandleAccumulator;
|
||||||
|
|
||||||
|
// TODO(Peter): Replace this with some sort of stretchy bufferf
|
||||||
|
// :ConnectionsToStretchyBuffer
|
||||||
s32 ConnectionsUsed;
|
s32 ConnectionsUsed;
|
||||||
node_connection Connections[NODE_LIST_CONNECTIONS_MAX];
|
node_connection Connections[NODE_LIST_CONNECTIONS_MAX];
|
||||||
};
|
};
|
||||||
|
@ -126,6 +129,8 @@ struct node_list_iterator
|
||||||
node_list List;
|
node_list List;
|
||||||
node_list_buffer* CurrentBuffer;
|
node_list_buffer* CurrentBuffer;
|
||||||
node_header* At;
|
node_header* At;
|
||||||
|
s32 BufferIndexAt;
|
||||||
|
s32 TotalIndexAt;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum node_interaction_flag
|
enum node_interaction_flag
|
||||||
|
@ -206,3 +211,17 @@ void proc_name(input_type* Data, r32 DeltaTime)
|
||||||
#define NODE_IN(type, name) type name
|
#define NODE_IN(type, name) type name
|
||||||
#define NODE_OUT(type, name) type name
|
#define NODE_OUT(type, name) type name
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////
|
||||||
|
// OUTPUT NODE
|
||||||
|
///////////////////////////////////////////////
|
||||||
|
|
||||||
|
NODE_STRUCT(output_node_data)
|
||||||
|
{
|
||||||
|
NODE_COLOR_BUFFER_IN(Result);
|
||||||
|
};
|
||||||
|
|
||||||
|
NODE_PROC(OutputNode, output_node_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
struct gui_node
|
||||||
|
{
|
||||||
|
s32 Handle;
|
||||||
|
node_type Type;
|
||||||
|
v2 Min, Dim;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define GUI_NODES_MAX 256
|
||||||
|
struct gui_node_list
|
||||||
|
{
|
||||||
|
s32 NodesUsed;
|
||||||
|
gui_node Nodes[GUI_NODES_MAX];
|
||||||
|
};
|
|
@ -8,8 +8,6 @@ struct operation_mode
|
||||||
input_command_registry Commands;
|
input_command_registry Commands;
|
||||||
operation_render_proc* Render;
|
operation_render_proc* Render;
|
||||||
u8* OpStateMemory;
|
u8* OpStateMemory;
|
||||||
|
|
||||||
string Name;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define OPERATION_MODES_MAX 32
|
#define OPERATION_MODES_MAX 32
|
||||||
|
@ -25,7 +23,7 @@ struct operation_mode_system
|
||||||
};
|
};
|
||||||
|
|
||||||
internal operation_mode*
|
internal operation_mode*
|
||||||
ActivateOperationMode (operation_mode_system* System, char* ModeName)
|
ActivateOperationMode (operation_mode_system* System)
|
||||||
{
|
{
|
||||||
Assert(System->ActiveModesCount < OPERATION_MODES_MAX);
|
Assert(System->ActiveModesCount < OPERATION_MODES_MAX);
|
||||||
s32 ModeIndex = System->ActiveModesCount++;
|
s32 ModeIndex = System->ActiveModesCount++;
|
||||||
|
@ -33,21 +31,18 @@ ActivateOperationMode (operation_mode_system* System, char* ModeName)
|
||||||
System->ModeMemorySnapshots[ModeIndex] = TakeSnapshotOfArena(System->Arena);
|
System->ModeMemorySnapshots[ModeIndex] = TakeSnapshotOfArena(System->Arena);
|
||||||
|
|
||||||
operation_mode NewMode = {};
|
operation_mode NewMode = {};
|
||||||
s32 NameLength = CharArrayLength(ModeName);
|
|
||||||
NewMode.Name = MakeString(PushArray(&System->Arena, char, NameLength), 0, NameLength);
|
|
||||||
CopyCharArrayToString(ModeName, &NewMode.Name);
|
|
||||||
System->ActiveModes[ModeIndex] = NewMode;
|
System->ActiveModes[ModeIndex] = NewMode;
|
||||||
|
|
||||||
return &System->ActiveModes[ModeIndex];
|
return &System->ActiveModes[ModeIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ActivateOperationModeWithCommands(sys, name, cmds) \
|
#define ActivateOperationModeWithCommands(sys, cmds) \
|
||||||
ActivateOperationModeWithCommands_(sys, name, cmds, (s32)(sizeof(cmds) / sizeof(cmds[0])));
|
ActivateOperationModeWithCommands_(sys, cmds, (s32)(sizeof(cmds) / sizeof(cmds[0])));
|
||||||
|
|
||||||
internal operation_mode*
|
internal operation_mode*
|
||||||
ActivateOperationModeWithCommands_(operation_mode_system* System, char* ModeName, input_command* Commands, s32 CommandsCount)
|
ActivateOperationModeWithCommands_(operation_mode_system* System, input_command* Commands, s32 CommandsCount)
|
||||||
{
|
{
|
||||||
operation_mode* NewMode = ActivateOperationMode(System, ModeName);
|
operation_mode* NewMode = ActivateOperationMode(System);
|
||||||
|
|
||||||
InitializeInputCommandRegistry(&NewMode->Commands, CommandsCount, &System->Arena);
|
InitializeInputCommandRegistry(&NewMode->Commands, CommandsCount, &System->Arena);
|
||||||
for (s32 i = 0; i < CommandsCount; i++)
|
for (s32 i = 0; i < CommandsCount; i++)
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
|
|
||||||
global_variable debug_services* GlobalDebugServices;
|
global_variable debug_services* GlobalDebugServices;
|
||||||
|
|
||||||
|
global_variable platform_alloc* GSAlloc;
|
||||||
|
global_variable platform_free* GSFree;
|
||||||
|
|
||||||
#include "gs_vector_matrix.h"
|
#include "gs_vector_matrix.h"
|
||||||
|
|
||||||
#include "gs_input.h"
|
#include "gs_input.h"
|
||||||
|
@ -19,13 +22,13 @@ typedef struct context context;
|
||||||
|
|
||||||
// Application Functions
|
// Application Functions
|
||||||
|
|
||||||
#define INITIALIZE_APPLICATION(name) void name(context Context)
|
#define INITIALIZE_APPLICATION(name) void name(context Context, platform_alloc* Alloc, platform_free* Free)
|
||||||
typedef INITIALIZE_APPLICATION(initialize_application);
|
typedef INITIALIZE_APPLICATION(initialize_application);
|
||||||
|
|
||||||
#define UPDATE_AND_RENDER(name) void name(context Context, input_queue InputQueue, mouse_state Mouse, render_command_buffer* RenderBuffer)
|
#define UPDATE_AND_RENDER(name) void name(context Context, input_queue InputQueue, mouse_state Mouse, render_command_buffer* RenderBuffer)
|
||||||
typedef UPDATE_AND_RENDER(update_and_render);
|
typedef UPDATE_AND_RENDER(update_and_render);
|
||||||
|
|
||||||
#define RELOAD_STATIC_DATA(name) void name(context Context, debug_services* DebugServices)
|
#define RELOAD_STATIC_DATA(name) void name(context Context, debug_services* DebugServices, platform_alloc* Alloc, platform_free* Free)
|
||||||
typedef RELOAD_STATIC_DATA(reload_static_data);
|
typedef RELOAD_STATIC_DATA(reload_static_data);
|
||||||
|
|
||||||
#define CLEANUP_APPLICATION(name) void name(context Context)
|
#define CLEANUP_APPLICATION(name) void name(context Context)
|
||||||
|
|
|
@ -90,6 +90,13 @@ struct sacn_universe
|
||||||
platform_network_address_handle SendAddress;
|
platform_network_address_handle SendAddress;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct sacn_pixel
|
||||||
|
{
|
||||||
|
u8 R;
|
||||||
|
u8 G;
|
||||||
|
u8 B;
|
||||||
|
};
|
||||||
|
|
||||||
struct sacn_send_buffer
|
struct sacn_send_buffer
|
||||||
{
|
{
|
||||||
u8* Memory;
|
u8* Memory;
|
||||||
|
@ -132,13 +139,6 @@ internal cid StringToCID_ (const char* String);
|
||||||
|
|
||||||
// Utility
|
// Utility
|
||||||
|
|
||||||
struct sacn_pixel
|
|
||||||
{
|
|
||||||
u8 R;
|
|
||||||
u8 G;
|
|
||||||
u8 B;
|
|
||||||
};
|
|
||||||
|
|
||||||
internal sacn_pixel
|
internal sacn_pixel
|
||||||
PackFloatsToSACNPixel (r32 R, r32 G, r32 B)
|
PackFloatsToSACNPixel (r32 R, r32 G, r32 B)
|
||||||
{
|
{
|
||||||
|
@ -246,6 +246,7 @@ struct sacn_add_universes_result
|
||||||
sacn_send_buffer* NewSendBuffer;
|
sacn_send_buffer* NewSendBuffer;
|
||||||
sacn_universe_buffer* NewUniverseBuffer;
|
sacn_universe_buffer* NewUniverseBuffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
internal sacn_add_universes_result
|
internal sacn_add_universes_result
|
||||||
SACNAddUniverses(s32* Universes, s32 UniversesLength, streaming_acn* SACN, context Context)
|
SACNAddUniverses(s32* Universes, s32 UniversesLength, streaming_acn* SACN, context Context)
|
||||||
{
|
{
|
||||||
|
@ -270,7 +271,8 @@ SACNAddUniverses(s32* Universes, s32 UniversesLength, streaming_acn* SACN, conte
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Push On New Send and Universe Buffers
|
// Reallocate and Copy over the send buffer
|
||||||
|
|
||||||
s32 SendBufferSize = CalculateSendBufferSize(UniversesToAdd);
|
s32 SendBufferSize = CalculateSendBufferSize(UniversesToAdd);
|
||||||
u8* SendBufferMemory = PushArray(&SACN->Memory, u8, SendBufferSize);
|
u8* SendBufferMemory = PushArray(&SACN->Memory, u8, SendBufferSize);
|
||||||
sacn_send_buffer* SendBufferHeader = (sacn_send_buffer*)SendBufferMemory;
|
sacn_send_buffer* SendBufferHeader = (sacn_send_buffer*)SendBufferMemory;
|
||||||
|
@ -334,12 +336,6 @@ SACNAddUniverses(s32* Universes, s32 UniversesLength, streaming_acn* SACN, conte
|
||||||
HostToNetU16(DEFAULT_STREAMING_ACN_PORT),
|
HostToNetU16(DEFAULT_STREAMING_ACN_PORT),
|
||||||
HostToNetU32(V4Address));
|
HostToNetU32(V4Address));
|
||||||
|
|
||||||
#if 0 // Old Net Code
|
|
||||||
UniverseBufferHeader->Universes[Index].SendAddress.sin_family = AF_INET;
|
|
||||||
UniverseBufferHeader->Universes[Index].SendAddress.sin_port = HostToNetU16(DEFAULT_STREAMING_ACN_PORT);
|
|
||||||
UniverseBufferHeader->Universes[Index].SendAddress.sin_addr.s_addr = HostToNetU32(V4Address);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
s32 SlotCount = 512;
|
s32 SlotCount = 512;
|
||||||
InitStreamHeader(UniverseBufferHeader->Universes[Index].StartPositionInSendBuffer,
|
InitStreamHeader(UniverseBufferHeader->Universes[Index].StartPositionInSendBuffer,
|
||||||
UniverseBufferHeader->Universes[Index].SizeInSendBuffer,
|
UniverseBufferHeader->Universes[Index].SizeInSendBuffer,
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
enum node_type
|
enum node_type
|
||||||
{
|
{
|
||||||
NodeType_OutputNode,
|
|
||||||
NodeType_FloatValue,
|
NodeType_FloatValue,
|
||||||
NodeType_VectorValue,
|
NodeType_VectorValue,
|
||||||
NodeType_MultiplyNodeProc,
|
NodeType_MultiplyNodeProc,
|
||||||
NodeType_AddNodeProc,
|
NodeType_AddNodeProc,
|
||||||
NodeType_SinWave,
|
NodeType_SinWave,
|
||||||
NodeType_MultiplyPatterns,
|
NodeType_MultiplyPatterns,
|
||||||
|
NodeType_OutputNode,
|
||||||
NodeType_SwdColorProc,
|
NodeType_SwdColorProc,
|
||||||
NodeType_SolidColorProc,
|
NodeType_SolidColorProc,
|
||||||
NodeType_VerticalColorFadeProc,
|
NodeType_VerticalColorFadeProc,
|
||||||
|
@ -52,6 +52,10 @@ node_struct_member MemberList_multiply_patterns_data[] = {
|
||||||
{ MemberType_NODE_COLOR_BUFFER, "ResultLEDs", (u64)&((multiply_patterns_data*)0)->ResultLEDs, IsOutputMember},
|
{ MemberType_NODE_COLOR_BUFFER, "ResultLEDs", (u64)&((multiply_patterns_data*)0)->ResultLEDs, IsOutputMember},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
node_struct_member MemberList_output_node_data[] = {
|
||||||
|
{ MemberType_NODE_COLOR_BUFFER, "ResultLEDs", (u64)&((output_node_data*)0)->ResultLEDs, IsInputMember },
|
||||||
|
};
|
||||||
|
|
||||||
node_struct_member MemberList_swd_color_data[] = {
|
node_struct_member MemberList_swd_color_data[] = {
|
||||||
{ MemberType_v4, "Color", (u64)&((swd_color_data*)0)->Color, IsInputMember },
|
{ MemberType_v4, "Color", (u64)&((swd_color_data*)0)->Color, IsInputMember },
|
||||||
{ MemberType_v4, "ColorB", (u64)&((swd_color_data*)0)->ColorB, IsInputMember },
|
{ MemberType_v4, "ColorB", (u64)&((swd_color_data*)0)->ColorB, IsInputMember },
|
||||||
|
@ -88,16 +92,18 @@ node_specification NodeSpecifications[] = {
|
||||||
{ NodeType_AddNodeProc, "AddNodeProc", 11, MemberList_add_data, 48, 3, false},
|
{ NodeType_AddNodeProc, "AddNodeProc", 11, MemberList_add_data, 48, 3, false},
|
||||||
{ NodeType_SinWave, "SinWave", 7, MemberList_sin_wave_data, 20, 4, false},
|
{ NodeType_SinWave, "SinWave", 7, MemberList_sin_wave_data, 20, 4, false},
|
||||||
{ NodeType_MultiplyPatterns, "MultiplyPatterns", 16, MemberList_multiply_patterns_data, 60, 3, false},
|
{ NodeType_MultiplyPatterns, "MultiplyPatterns", 16, MemberList_multiply_patterns_data, 60, 3, false},
|
||||||
|
{ NodeType_OutputNode, "OutputNode", 10, MemberList_output_node_data, 20, 1, false},
|
||||||
{ NodeType_SwdColorProc, "SwdColorProc", 12, MemberList_swd_color_data, 52, 3, false},
|
{ NodeType_SwdColorProc, "SwdColorProc", 12, MemberList_swd_color_data, 52, 3, false},
|
||||||
{ NodeType_SolidColorProc, "SolidColorProc", 14, MemberList_solid_color_data, 36, 2, false},
|
{ NodeType_SolidColorProc, "SolidColorProc", 14, MemberList_solid_color_data, 36, 2, false},
|
||||||
{ NodeType_VerticalColorFadeProc, "VerticalColorFadeProc", 21, MemberList_vertical_color_fade_data, 44, 4, false},
|
{ NodeType_VerticalColorFadeProc, "VerticalColorFadeProc", 21, MemberList_vertical_color_fade_data, 44, 4, false},
|
||||||
{ NodeType_RevolvingDiscs, "RevolvingDiscs", 14, MemberList_revolving_discs_data, 60, 8, false},
|
{ NodeType_RevolvingDiscs, "RevolvingDiscs", 14, MemberList_revolving_discs_data, 60, 8, false},
|
||||||
};
|
};
|
||||||
s32 NodeSpecificationsCount = 10;
|
s32 NodeSpecificationsCount = 11;
|
||||||
|
|
||||||
internal void CallNodeProc(node_header* Node, u8* Data, led* LEDs, s32 LEDsCount, r32 DeltaTime)
|
internal void CallNodeProc(node_header* Node, u8* Data, led* LEDs, s32 LEDsCount, r32 DeltaTime)
|
||||||
{
|
{
|
||||||
switch (Node->Type)
|
node_specification Spec = NodeSpecifications[Node->Type];
|
||||||
|
switch (Spec.Type)
|
||||||
{
|
{
|
||||||
case NodeType_FloatValue: { FloatValue((float_value_data*)Data, DeltaTime); } break;
|
case NodeType_FloatValue: { FloatValue((float_value_data*)Data, DeltaTime); } break;
|
||||||
case NodeType_VectorValue: { VectorValue((vector_data*)Data, DeltaTime); } break;
|
case NodeType_VectorValue: { VectorValue((vector_data*)Data, DeltaTime); } break;
|
||||||
|
@ -105,6 +111,7 @@ case NodeType_MultiplyNodeProc: { MultiplyNodeProc((multiply_data*)Data, DeltaTi
|
||||||
case NodeType_AddNodeProc: { AddNodeProc((add_data*)Data, DeltaTime); } break;
|
case NodeType_AddNodeProc: { AddNodeProc((add_data*)Data, DeltaTime); } break;
|
||||||
case NodeType_SinWave: { SinWave((sin_wave_data*)Data, DeltaTime); } break;
|
case NodeType_SinWave: { SinWave((sin_wave_data*)Data, DeltaTime); } break;
|
||||||
case NodeType_MultiplyPatterns: { MultiplyPatterns((multiply_patterns_data*)Data, DeltaTime); } break;
|
case NodeType_MultiplyPatterns: { MultiplyPatterns((multiply_patterns_data*)Data, DeltaTime); } break;
|
||||||
|
case NodeType_OutputNode: { OutputNode((output_node_data*)Data, DeltaTime); } break;
|
||||||
case NodeType_SwdColorProc: { SwdColorProc((swd_color_data*)Data, DeltaTime); } break;
|
case NodeType_SwdColorProc: { SwdColorProc((swd_color_data*)Data, DeltaTime); } break;
|
||||||
case NodeType_SolidColorProc: { SolidColorProc((solid_color_data*)Data, DeltaTime); } break;
|
case NodeType_SolidColorProc: { SolidColorProc((solid_color_data*)Data, DeltaTime); } break;
|
||||||
case NodeType_VerticalColorFadeProc: { VerticalColorFadeProc((vertical_color_fade_data*)Data, DeltaTime); } break;
|
case NodeType_VerticalColorFadeProc: { VerticalColorFadeProc((vertical_color_fade_data*)Data, DeltaTime); } break;
|
||||||
|
|
|
@ -69,7 +69,7 @@ struct system_path
|
||||||
s32 IndexOfLastSlash;
|
s32 IndexOfLastSlash;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PLATFORM_ALLOC(name) platform_memory_result name(s32 Size)
|
#define PLATFORM_ALLOC(name) u8* name(s32 Size)
|
||||||
typedef PLATFORM_ALLOC(platform_alloc);
|
typedef PLATFORM_ALLOC(platform_alloc);
|
||||||
|
|
||||||
#define PLATFORM_FREE(name) b32 name(u8* Base, s32 Size)
|
#define PLATFORM_FREE(name) b32 name(u8* Base, s32 Size)
|
||||||
|
|
|
@ -595,19 +595,7 @@ Win32BasicAlloc (s32 Size)
|
||||||
|
|
||||||
PLATFORM_ALLOC(Win32Alloc)
|
PLATFORM_ALLOC(Win32Alloc)
|
||||||
{
|
{
|
||||||
platform_memory_result Result = {};
|
u8* Result = Win32BasicAlloc(Size);
|
||||||
Result.Error = PLATFORM_MEMORY_NO_ERROR;
|
|
||||||
|
|
||||||
Result.Base = Win32BasicAlloc(Size);
|
|
||||||
if (Result.Base)
|
|
||||||
{
|
|
||||||
Result.Size = Size;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Result.Error = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -136,10 +136,10 @@ PLATFORM_GET_SOCKET_HANDLE(Win32GetSocketHandle)
|
||||||
{
|
{
|
||||||
s32 NewDictionaryMax = Win32SocketHandleMax + SOCKET_DICTIONARY_GROW_SIZE;
|
s32 NewDictionaryMax = Win32SocketHandleMax + SOCKET_DICTIONARY_GROW_SIZE;
|
||||||
s32 NewDictionaryDataSize = NewDictionaryMax * sizeof(win32_socket);
|
s32 NewDictionaryDataSize = NewDictionaryMax * sizeof(win32_socket);
|
||||||
platform_memory_result DictionaryMemory = Win32Alloc(NewDictionaryDataSize);
|
u8* DictionaryMemory = Win32Alloc(NewDictionaryDataSize);
|
||||||
Assert(DictionaryMemory.Size > 0);
|
Assert(DictionaryMemory);
|
||||||
|
|
||||||
win32_socket* NewValues = (win32_socket*)(DictionaryMemory.Base);
|
win32_socket* NewValues = (win32_socket*)(DictionaryMemory);
|
||||||
if (SocketValues)
|
if (SocketValues)
|
||||||
{
|
{
|
||||||
GSMemCopy(SocketValues, NewValues, sizeof(win32_socket) * NewDictionaryMax);
|
GSMemCopy(SocketValues, NewValues, sizeof(win32_socket) * NewDictionaryMax);
|
||||||
|
@ -169,10 +169,10 @@ PLATFORM_GET_SEND_ADDRESS_HANDLE(Win32GetSendAddress)
|
||||||
{
|
{
|
||||||
s32 NewDictionaryMax = Win32NetworkAddressHandleMax + NETWORK_ADDRESS_DICTIONARY_GROW_SIZE;
|
s32 NewDictionaryMax = Win32NetworkAddressHandleMax + NETWORK_ADDRESS_DICTIONARY_GROW_SIZE;
|
||||||
s32 NewDictionaryDataSize = NewDictionaryMax * sizeof(sockaddr_in);
|
s32 NewDictionaryDataSize = NewDictionaryMax * sizeof(sockaddr_in);
|
||||||
platform_memory_result DictionaryMemory = Win32Alloc(NewDictionaryDataSize);
|
u8* DictionaryMemory = Win32Alloc(NewDictionaryDataSize);
|
||||||
Assert(DictionaryMemory.Size > 0);
|
Assert(DictionaryMemory);
|
||||||
|
|
||||||
sockaddr_in* NewValues = (sockaddr_in*)(DictionaryMemory.Base);
|
sockaddr_in* NewValues = (sockaddr_in*)(DictionaryMemory);
|
||||||
if (NetworkAddressValues)
|
if (NetworkAddressValues)
|
||||||
{
|
{
|
||||||
GSMemCopy(NetworkAddressValues, NewValues, sizeof(win32_socket) * NewDictionaryMax);
|
GSMemCopy(NetworkAddressValues, NewValues, sizeof(win32_socket) * NewDictionaryMax);
|
||||||
|
@ -556,7 +556,7 @@ INT NCmdShow
|
||||||
input_queue InputQueue;
|
input_queue InputQueue;
|
||||||
{
|
{
|
||||||
s32 InputQueueMemorySize = sizeof(input_entry) * 32;
|
s32 InputQueueMemorySize = sizeof(input_entry) * 32;
|
||||||
u8* InputQueueMemory = Win32Alloc(InputQueueMemorySize).Base;
|
u8* InputQueueMemory = Win32Alloc(InputQueueMemorySize);
|
||||||
InputQueue = InitializeInputQueue(InputQueueMemory, InputQueueMemorySize);
|
InputQueue = InitializeInputQueue(InputQueueMemory, InputQueueMemorySize);
|
||||||
|
|
||||||
Mouse = {0, 0};
|
Mouse = {0, 0};
|
||||||
|
@ -589,10 +589,11 @@ INT NCmdShow
|
||||||
WorkerThreads[i].Handle = CreateThread(0, 0, &WorkerThreadProc, (void*)&WorkerThreads[i], 0, 0);
|
WorkerThreads[i].Handle = CreateThread(0, 0, &WorkerThreadProc, (void*)&WorkerThreads[i], 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
platform_memory_result InitialMemory = Win32Alloc(Megabytes(64));
|
s32 InitialMemorySize = Megabytes(64);
|
||||||
|
u8* InitialMemory = Win32Alloc(InitialMemorySize);
|
||||||
context Context = {};
|
context Context = {};
|
||||||
Context.MemorySize = InitialMemory.Size;
|
Context.MemorySize = InitialMemorySize;
|
||||||
Context.MemoryBase = InitialMemory.Base;
|
Context.MemoryBase = InitialMemory;
|
||||||
Context.WindowWidth = MainWindow.Width;
|
Context.WindowWidth = MainWindow.Width;
|
||||||
Context.WindowHeight = MainWindow.Height;
|
Context.WindowHeight = MainWindow.Height;
|
||||||
|
|
||||||
|
@ -615,7 +616,7 @@ INT NCmdShow
|
||||||
if (HotLoadDLL(&DLLRefresh))
|
if (HotLoadDLL(&DLLRefresh))
|
||||||
{
|
{
|
||||||
SetApplicationLinks(&Context, DLLRefresh, &WorkQueue);
|
SetApplicationLinks(&Context, DLLRefresh, &WorkQueue);
|
||||||
Context.ReloadStaticData(Context, GlobalDebugServices);
|
Context.ReloadStaticData(Context, GlobalDebugServices, Win32BasicAlloc, Win32Free);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -625,10 +626,11 @@ INT NCmdShow
|
||||||
WSADATA WSAData;
|
WSADATA WSAData;
|
||||||
WSAStartup(MAKEWORD(2, 2), &WSAData);
|
WSAStartup(MAKEWORD(2, 2), &WSAData);
|
||||||
|
|
||||||
platform_memory_result RenderMemory = Win32Alloc(Megabytes(12));
|
s32 RenderMemorySize = Megabytes(12);
|
||||||
render_command_buffer RenderBuffer = AllocateRenderCommandBuffer(RenderMemory.Base, RenderMemory.Size, Win32Realloc);
|
u8* RenderMemory = Win32Alloc(RenderMemorySize);
|
||||||
|
render_command_buffer RenderBuffer = AllocateRenderCommandBuffer(RenderMemory, RenderMemorySize, Win32Realloc);
|
||||||
|
|
||||||
Context.InitializeApplication(Context);
|
Context.InitializeApplication(Context, Win32BasicAlloc, Win32Free);
|
||||||
|
|
||||||
Running = true;
|
Running = true;
|
||||||
Context.WindowIsVisible = true;
|
Context.WindowIsVisible = true;
|
||||||
|
@ -644,7 +646,7 @@ INT NCmdShow
|
||||||
if (HotLoadDLL(&DLLRefresh))
|
if (HotLoadDLL(&DLLRefresh))
|
||||||
{
|
{
|
||||||
SetApplicationLinks(&Context, DLLRefresh, &WorkQueue);
|
SetApplicationLinks(&Context, DLLRefresh, &WorkQueue);
|
||||||
Context.ReloadStaticData(Context, GlobalDebugServices);
|
Context.ReloadStaticData(Context, GlobalDebugServices, Win32BasicAlloc, Win32Free);
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Mouse Position
|
{ // Mouse Position
|
||||||
|
|
10
todo.txt
10
todo.txt
|
@ -7,11 +7,19 @@ BUGS
|
||||||
- Typing a period into a float value doesn't register. Problem here is that we arent' translating key presses into characters at the win32 layer. Need to do that.
|
- Typing a period into a float value doesn't register. Problem here is that we arent' translating key presses into characters at the win32 layer. Need to do that.
|
||||||
|
|
||||||
Switch To Nodes
|
Switch To Nodes
|
||||||
|
x output should generate a node_specification
|
||||||
|
x go back to calling SpecificationIndex Type
|
||||||
|
- BUG: Connect a solid color node to output then try and pick a color. I think temporary node buffers are
|
||||||
|
- overwriting other data when they get evaluated. Bigger solution is to create a system of working
|
||||||
|
- led buffers that get assigned to nodes as needed.
|
||||||
|
- gonna need to remove output node from the node lister
|
||||||
- delete nodes
|
- delete nodes
|
||||||
- - Simplify node storage
|
- - Simplify node storage
|
||||||
- x don't pull node names into the struct, just reference the specification
|
- x don't pull node names into the struct, just reference the specification
|
||||||
- - separate storage of node headers from connections
|
- x separate storage of node headers from connections
|
||||||
- - investigate if node connections can be operated on separately from the node headers
|
- - investigate if node connections can be operated on separately from the node headers
|
||||||
|
- - UpdatedThisFrame can probably go into each connection
|
||||||
|
- x connections shouldn't store their own values, they should just point into permanent storage
|
||||||
- - Allow insertion/deletion within connection table
|
- - Allow insertion/deletion within connection table
|
||||||
- - Allow inerstion/deletion within header table
|
- - Allow inerstion/deletion within header table
|
||||||
- - maintain free list of connections and headers
|
- - maintain free list of connections and headers
|
||||||
|
|
Loading…
Reference in New Issue