Cleaned up some extraneous variables in the assembly structure

This commit is contained in:
Peter Slattery 2020-06-19 18:53:23 -07:00
parent 69db4b436c
commit 9c432a3807
10 changed files with 86 additions and 111 deletions

View File

@ -314,8 +314,7 @@ CreateDMXBuffers(assembly Assembly, led_system* LedSystem, s32 BufferHeaderSize,
for (u32 i = 0; i < Strip.LedCount; i++) for (u32 i = 0; i < Strip.LedCount; i++)
{ {
u32 LedIndex = Strip.LedLUT[i]; u32 LedIndex = Strip.LedLUT[i];
led LED = LedBuffer->Leds[LedIndex]; pixel Color = LedBuffer->Colors[LedIndex];
pixel Color = LedBuffer->Colors[LED.Index];
DestChannel[0] = Color.R; DestChannel[0] = Color.R;
DestChannel[1] = Color.G; DestChannel[1] = Color.G;
@ -529,6 +528,7 @@ UPDATE_AND_RENDER(UpdateAndRender)
Context->GeneralWorkQueue->ResetWorkQueue(Context->GeneralWorkQueue); Context->GeneralWorkQueue->ResetWorkQueue(Context->GeneralWorkQueue);
// Checking for overflows // Checking for overflows
#if 0
{ {
DEBUG_TRACK_SCOPE(OverflowChecks); DEBUG_TRACK_SCOPE(OverflowChecks);
AssertAllocationsNoOverflow(State->Permanent); AssertAllocationsNoOverflow(State->Permanent);
@ -538,6 +538,7 @@ UPDATE_AND_RENDER(UpdateAndRender)
AssertAllocationsNoOverflow(Assembly->Arena); AssertAllocationsNoOverflow(Assembly->Arena);
} }
} }
#endif
} }
CLEANUP_APPLICATION(CleanupApplication) CLEANUP_APPLICATION(CleanupApplication)

View File

@ -94,18 +94,18 @@ TestPatternOne(led_buffer* Assembly, r32 Time)
{ {
for (u32 LedIndex = 0; LedIndex < Assembly->LedCount; LedIndex++) for (u32 LedIndex = 0; LedIndex < Assembly->LedCount; LedIndex++)
{ {
led Led = Assembly->Leds[LedIndex]; v4 LedPosition = Assembly->Positions[LedIndex];
if (Led.Position.x < 0) if (LedPosition.x < 0)
{ {
Assembly->Colors[Led.Index].R = 255; Assembly->Colors[LedIndex].R = 255;
Assembly->Colors[Led.Index].B = 255; Assembly->Colors[LedIndex].B = 255;
Assembly->Colors[Led.Index].G = 255; Assembly->Colors[LedIndex].G = 255;
} }
else else
{ {
Assembly->Colors[Led.Index].R = 0; Assembly->Colors[LedIndex].R = 0;
Assembly->Colors[Led.Index].B = 0; Assembly->Colors[LedIndex].B = 0;
Assembly->Colors[Led.Index].G = 0; Assembly->Colors[LedIndex].G = 0;
} }
} }
} }
@ -132,9 +132,7 @@ TestPatternTwo(led_buffer* Assembly, r32 Time)
for (u32 LedIndex = 0; LedIndex < Assembly->LedCount; LedIndex++) for (u32 LedIndex = 0; LedIndex < Assembly->LedCount; LedIndex++)
{ {
led Led = Assembly->Leds[LedIndex]; v4 Position = Assembly->Positions[LedIndex];
v4 Position = Led.Position;
v4 ToFront = Position + FrontCenter; v4 ToFront = Position + FrontCenter;
v4 ToBack = Position + BackCenter; v4 ToBack = Position + BackCenter;
@ -150,16 +148,16 @@ TestPatternTwo(led_buffer* Assembly, r32 Time)
{ {
if (XOR(ToFrontDotNormal > 0, ToBackDotNormal > 0)) if (XOR(ToFrontDotNormal > 0, ToBackDotNormal > 0))
{ {
Assembly->Colors[Led.Index] = Color; Assembly->Colors[LedIndex] = Color;
} }
else else
{ {
//Assembly->Colors[Led.Index] = {}; //Assembly->Colors[LedIndex] = {};
} }
} }
else else
{ {
//Assembly->Colors[Led.Index] = {}; //Assembly->Colors[LedIndex] = {};
} }
} }
} }
@ -178,23 +176,23 @@ TestPatternThree(led_buffer* Assembly, r32 Time)
for (u32 LedIndex = 0; LedIndex < Assembly->LedCount; LedIndex++) for (u32 LedIndex = 0; LedIndex < Assembly->LedCount; LedIndex++)
{ {
led Led = Assembly->Leds[LedIndex]; v4 LedPosition = Assembly->Positions[LedIndex];
u8 Red = 0; u8 Red = 0;
u8 Green = 0; u8 Green = 0;
u8 Blue = 0; u8 Blue = 0;
r32 GreenDist = GSAbs(Mag(Led.Position - GreenCenter) - GreenRadius); r32 GreenDist = GSAbs(Mag(LedPosition - GreenCenter) - GreenRadius);
r32 GreenBrightness = GSClamp(0.f, FadeDist - GSAbs(GreenDist), FadeDist); r32 GreenBrightness = GSClamp(0.f, FadeDist - GSAbs(GreenDist), FadeDist);
Green = (u8)(GreenBrightness * 255); Green = (u8)(GreenBrightness * 255);
r32 TealDist = GSAbs(Mag(Led.Position - TealCenter) - TealRadius); r32 TealDist = GSAbs(Mag(LedPosition - TealCenter) - TealRadius);
r32 TealBrightness = GSClamp(0.f, FadeDist - GSAbs(TealDist), FadeDist); r32 TealBrightness = GSClamp(0.f, FadeDist - GSAbs(TealDist), FadeDist);
Red = (u8)(TealBrightness * 255); Red = (u8)(TealBrightness * 255);
Blue = (u8)(TealBrightness * 255); Blue = (u8)(TealBrightness * 255);
Assembly->Colors[Led.Index].R = Red; Assembly->Colors[LedIndex].R = Red;
Assembly->Colors[Led.Index].B = Green; Assembly->Colors[LedIndex].B = Green;
Assembly->Colors[Led.Index].G = Green; Assembly->Colors[LedIndex].G = Green;
} }
} }

View File

@ -34,7 +34,7 @@ LedSystemTakeFreeBuffer(led_system* System, u32 LedCount)
{ {
if (System->Buffers[i].LedCount == 0 if (System->Buffers[i].LedCount == 0
&& System->Buffers[i].Colors == 0 && System->Buffers[i].Colors == 0
&& System->Buffers[i].Leds == 0) && System->Buffers[i].Positions == 0)
{ {
Result = i; Result = i;
break; break;
@ -46,7 +46,7 @@ LedSystemTakeFreeBuffer(led_system* System, u32 LedCount)
led_buffer* Buffer = &System->Buffers[Result]; led_buffer* Buffer = &System->Buffers[Result];
Buffer->LedCount = LedCount; Buffer->LedCount = LedCount;
Buffer->Colors = PlatformAllocArray(System->PlatformMemory, pixel, Buffer->LedCount); Buffer->Colors = PlatformAllocArray(System->PlatformMemory, pixel, Buffer->LedCount);
Buffer->Leds = PlatformAllocArray(System->PlatformMemory, led, Buffer->LedCount); Buffer->Positions = PlatformAllocArray(System->PlatformMemory, v4, Buffer->LedCount);
System->LedsCountTotal += LedCount; System->LedsCountTotal += LedCount;
@ -59,7 +59,7 @@ LedSystemFreeBuffer(led_system* System, u32 BufferIndex)
Assert(BufferIndex < System->BuffersCountMax); Assert(BufferIndex < System->BuffersCountMax);
led_buffer* Buffer = &System->Buffers[BufferIndex]; led_buffer* Buffer = &System->Buffers[BufferIndex];
PlatformFreeArray(System->PlatformMemory, Buffer->Colors, pixel, Buffer->LedCount); PlatformFreeArray(System->PlatformMemory, Buffer->Colors, pixel, Buffer->LedCount);
PlatformFreeArray(System->PlatformMemory, Buffer->Leds, led, Buffer->LedCount); PlatformFreeArray(System->PlatformMemory, Buffer->Positions, v4, Buffer->LedCount);
System->LedsCountTotal -= Buffer->LedCount; System->LedsCountTotal -= Buffer->LedCount;
*Buffer = {}; *Buffer = {};
} }
@ -75,8 +75,7 @@ internal void
LedBufferSetLed(led_buffer* Buffer, u32 Led, v4 Position) LedBufferSetLed(led_buffer* Buffer, u32 Led, v4 Position)
{ {
Assert(Led < Buffer->LedCount); Assert(Led < Buffer->LedCount);
Buffer->Leds[Led].Position = Position; Buffer->Positions[Led] = Position;
Buffer->Leds[Led].Index = Led;
} }
// Assembly // Assembly

View File

@ -5,13 +5,6 @@
// //
#ifndef FOLDHAUS_ASSEMBLY_H #ifndef FOLDHAUS_ASSEMBLY_H
struct led
{
// TODO(Peter): Pretty sure we don't need this. led and pixel are always parallel arrays
s32 Index;
v4 Position;
};
union pixel union pixel
{ {
struct struct
@ -27,7 +20,7 @@ struct led_buffer
{ {
u32 LedCount; u32 LedCount;
pixel* Colors; pixel* Colors;
led* Leds; v4* Positions;
}; };
struct led_system struct led_system
@ -50,6 +43,7 @@ struct v2_tag
struct v2_strip struct v2_strip
{ {
s32 ControlBoxID; // TODO(Peter): I don't think we need this anymore s32 ControlBoxID; // TODO(Peter): I don't think we need this anymore
// TODO(Peter): Add in info for Serial, ArtNet, etc. // TODO(Peter): Add in info for Serial, ArtNet, etc.
s32 StartUniverse; s32 StartUniverse;
s32 StartChannel; s32 StartChannel;

View File

@ -117,7 +117,7 @@ NODE_PROC(SinWave, sin_wave_data)
// //
///////////////////////////////// /////////////////////////////////
GSMetaTag(node_struct); GSMetaTag(node_struct);
struct multiply_patterns_data struct multiply_patterns_data
{ {
GSMetaTag(node_input); GSMetaTag(node_input);
@ -132,28 +132,25 @@ struct multiply_patterns_data
NODE_PROC(MultiplyPatterns, multiply_patterns_data) NODE_PROC(MultiplyPatterns, multiply_patterns_data)
{ {
led* LED = Data->Result.LEDs; for (s32 LedIndex = 0; LedIndex < Data->Result.LEDCount; LedIndex++)
for (s32 l = 0; l < Data->Result.LEDCount; l++)
{ {
Assert(LED->Index >= 0 && LED->Index < Data->Result.LEDCount); Assert(LedIndex >= 0 && LedIndex < Data->Result.LEDCount);
s32 AR = Data->A.Colors[LED->Index].R; s32 AR = Data->A.Colors[LedIndex].R;
s32 AG = Data->A.Colors[LED->Index].G; s32 AG = Data->A.Colors[LedIndex].G;
s32 AB = Data->A.Colors[LED->Index].B; s32 AB = Data->A.Colors[LedIndex].B;
s32 BR = Data->B.Colors[LED->Index].R; s32 BR = Data->B.Colors[LedIndex].R;
s32 BG = Data->B.Colors[LED->Index].G; s32 BG = Data->B.Colors[LedIndex].G;
s32 BB = Data->B.Colors[LED->Index].B; s32 BB = Data->B.Colors[LedIndex].B;
s32 RCombined = (AR * BR) / 255; s32 RCombined = (AR * BR) / 255;
s32 GCombined = (AG * BG) / 255; s32 GCombined = (AG * BG) / 255;
s32 BCombined = (AB * BB) / 255; s32 BCombined = (AB * BB) / 255;
Data->Result.Colors[LED->Index].R = (u8)RCombined; Data->Result.Colors[LedIndex].R = (u8)RCombined;
Data->Result.Colors[LED->Index].G = (u8)GCombined; Data->Result.Colors[LedIndex].G = (u8)GCombined;
Data->Result.Colors[LED->Index].B = (u8)BCombined; Data->Result.Colors[LedIndex].B = (u8)BCombined;
LED++;
} }
} }

View File

@ -14,7 +14,7 @@ typedef enum node_type node_type;
struct color_buffer struct color_buffer
{ {
led* LEDs; v4* LedPositions;
pixel* Colors; pixel* Colors;
s32 LEDCount; s32 LEDCount;
}; };
@ -66,7 +66,7 @@ struct node_specification_
struct pattern_node struct pattern_node
{ {
// TODO(Peter): Something to think about further down the line is the fact that // TODO(Peter): Something to think about further down the line is the fact that
// SpecificationIndex doesn't have to stay static throughout a single instance of // SpecificationIndex doesn't have to stay static throughout a single instance of
// an application, let alone across separate runs. If you recompile (hot load or not) // an application, let alone across separate runs. If you recompile (hot load or not)
// with a new specification, the indecies all get thrown off. Should we hash the spec // with a new specification, the indecies all get thrown off. Should we hash the spec
// names or something? // names or something?
@ -90,7 +90,7 @@ struct pattern_node_workspace
gs_bucket<pattern_node_connection> Connections; gs_bucket<pattern_node_connection> Connections;
// This is storage for all the structures which follow. // This is storage for all the structures which follow.
// It is cleared when new nodes are added so that the // It is cleared when new nodes are added so that the
// acceleration structures can be recalculated // acceleration structures can be recalculated
memory_arena Storage; memory_arena Storage;
s32* SparseToSortedNodeMap; s32* SparseToSortedNodeMap;
@ -109,7 +109,7 @@ struct data_name
struct data_name struct data_name
#define NODE_PROC(proc_name, input_type) \ #define NODE_PROC(proc_name, input_type) \
void proc_name(input_type* Data, r32 DeltaTime) 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

View File

@ -39,10 +39,9 @@ enum gsm_struct_type
gsm_StructType_v4, gsm_StructType_v4,
gsm_StructType_float, gsm_StructType_float,
gsm_StructType_color_buffer, gsm_StructType_color_buffer,
gsm_StructType_led,
gsm_StructType_s32,
gsm_StructType_pixel, gsm_StructType_pixel,
gsm_StructType_u8, gsm_StructType_u8,
gsm_StructType_s32,
gsm_StructType_sin_wave_data, gsm_StructType_sin_wave_data,
gsm_StructType_r32, gsm_StructType_r32,
gsm_StructType_revolving_discs_data, gsm_StructType_revolving_discs_data,
@ -62,10 +61,6 @@ static gsm_struct_member_type_info StructMembers_v4[] = {
{ "a", 1, (u64)&((v4*)0)->a, {}, 0}, { "a", 1, (u64)&((v4*)0)->a, {}, 0},
{ "E", 1, (u64)&((v4*)0)->E, {}, 0}, { "E", 1, (u64)&((v4*)0)->E, {}, 0},
}; };
static gsm_struct_member_type_info StructMembers_led[] = {
{ "Index", 5, (u64)&((led*)0)->Index, {}, 0},
{ "Position", 8, (u64)&((led*)0)->Position, {}, 0},
};
static gsm_struct_member_type_info StructMembers_pixel[] = { static gsm_struct_member_type_info StructMembers_pixel[] = {
{ "R", 1, (u64)&((pixel*)0)->R, {}, 0}, { "R", 1, (u64)&((pixel*)0)->R, {}, 0},
{ "G", 1, (u64)&((pixel*)0)->G, {}, 0}, { "G", 1, (u64)&((pixel*)0)->G, {}, 0},
@ -73,7 +68,7 @@ static gsm_struct_member_type_info StructMembers_pixel[] = {
{ "Channels", 8, (u64)&((pixel*)0)->Channels, {}, 0}, { "Channels", 8, (u64)&((pixel*)0)->Channels, {}, 0},
}; };
static gsm_struct_member_type_info StructMembers_color_buffer[] = { static gsm_struct_member_type_info StructMembers_color_buffer[] = {
{ "LEDs", 4, (u64)&((color_buffer*)0)->LEDs, {}, 0}, { "LedPositions", 12, (u64)&((color_buffer*)0)->LedPositions, {}, 0},
{ "Colors", 6, (u64)&((color_buffer*)0)->Colors, {}, 0}, { "Colors", 6, (u64)&((color_buffer*)0)->Colors, {}, 0},
{ "LEDCount", 8, (u64)&((color_buffer*)0)->LEDCount, {}, 0}, { "LEDCount", 8, (u64)&((color_buffer*)0)->LEDCount, {}, 0},
}; };
@ -115,14 +110,13 @@ static gsm_struct_type_info StructTypes[] = {
{ gsm_StructType_v4, "v4", 2, 16, 0, 0, StructMembers_v4, 3 }, { gsm_StructType_v4, "v4", 2, 16, 0, 0, StructMembers_v4, 3 },
{ gsm_StructType_float, "float", 5, 4, 0, 0, 0, 0 }, { gsm_StructType_float, "float", 5, 4, 0, 0, 0, 0 },
{ gsm_StructType_color_buffer, "color_buffer", 12, 20, 0, 0, StructMembers_color_buffer, 3 }, { gsm_StructType_color_buffer, "color_buffer", 12, 20, 0, 0, StructMembers_color_buffer, 3 },
{ gsm_StructType_led, "led", 3, 20, 0, 0, StructMembers_led, 2 },
{ gsm_StructType_s32, "s32", 3, 4, 0, 0, 0, 0 },
{ gsm_StructType_pixel, "pixel", 5, 3, 0, 0, StructMembers_pixel, 2 }, { gsm_StructType_pixel, "pixel", 5, 3, 0, 0, StructMembers_pixel, 2 },
{ gsm_StructType_u8, "u8", 2, 1, 0, 0, 0, 0 }, { gsm_StructType_u8, "u8", 2, 1, 0, 0, 0, 0 },
{ gsm_StructType_s32, "s32", 3, 4, 0, 0, 0, 0 },
{ gsm_StructType_sin_wave_data, "sin_wave_data", 13, 20, 0, 0, StructMembers_sin_wave_data, 5 }, { gsm_StructType_sin_wave_data, "sin_wave_data", 13, 20, 0, 0, StructMembers_sin_wave_data, 5 },
{ gsm_StructType_r32, "r32", 3, 4, 0, 0, 0, 0 }, { gsm_StructType_r32, "r32", 3, 4, 0, 0, 0, 0 },
{ gsm_StructType_revolving_discs_data, "revolving_discs_data", 20, 60, 0, 0, StructMembers_revolving_discs_data, 8 }, { gsm_StructType_revolving_discs_data, "revolving_discs_data", 20, 60, 0, 0, StructMembers_revolving_discs_data, 8 },
{ gsm_StructType_vertical_color_fade_data, "vertical_color_fade_data", 24, 44, 0, 0, StructMembers_vertical_color_fade_data, 4 }, { gsm_StructType_vertical_color_fade_data, "vertical_color_fade_data", 24, 44, 0, 0, StructMembers_vertical_color_fade_data, 4 },
{ gsm_StructType_multiply_patterns_data, "multiply_patterns_data", 22, 60, 0, 0, StructMembers_multiply_patterns_data, 3 }, { gsm_StructType_multiply_patterns_data, "multiply_patterns_data", 22, 60, 0, 0, StructMembers_multiply_patterns_data, 3 },
}; };
static gsm_u32 StructTypesCount = 13; static gsm_u32 StructTypesCount = 12;

View File

@ -71,7 +71,7 @@ SculptureView_Cleanup(panel* Panel, app_state* State)
struct draw_leds_job_data struct draw_leds_job_data
{ {
led* LEDs; v4* Positions;
pixel* Colors; pixel* Colors;
s32 StartIndex; s32 StartIndex;
s32 OnePastLastIndex; s32 OnePastLastIndex;
@ -107,15 +107,13 @@ DrawLEDsInBufferRangeJob (s32 ThreadID, void* JobData)
v2 UV2 = v2{1, 1}; v2 UV2 = v2{1, 1};
v2 UV3 = v2{0, 1}; v2 UV3 = v2{0, 1};
led* LED = Data->LEDs + Data->StartIndex;
for (s32 LEDIdx = 0; for (s32 LedIndex = 0; LedIndex < LEDCount; LedIndex++)
LEDIdx < LEDCount;
LEDIdx++)
{ {
pixel PixelColor = Data->Colors[LED->Index]; pixel PixelColor = Data->Colors[LedIndex];
v4 Color = v4{PixelColor.R / 255.f, PixelColor.G / 255.f, PixelColor.B / 255.f, 1.0f}; v4 Color = v4{PixelColor.R / 255.f, PixelColor.G / 255.f, PixelColor.B / 255.f, 1.0f};
v4 V4Position = LED->Position; v4 V4Position = Data->Positions[Data->StartIndex + LedIndex];
V4Position.w = 0; V4Position.w = 0;
v4 P0 = P0_In + V4Position; v4 P0 = P0_In + V4Position;
v4 P1 = P1_In + V4Position; v4 P1 = P1_In + V4Position;
@ -126,8 +124,6 @@ DrawLEDsInBufferRangeJob (s32 ThreadID, void* JobData)
P0, P1, P2, UV0, UV1, UV2, Color, Color, Color); P0, P1, P2, UV0, UV1, UV2, Color, Color, Color);
SetTri3DInBatch(Data->Batch, BatchReservedRange.Start + TrisUsed++, SetTri3DInBatch(Data->Batch, BatchReservedRange.Start + TrisUsed++,
P0, P2, P3, UV0, UV2, UV3, Color, Color, Color); P0, P2, P3, UV0, UV2, UV3, Color, Color, Color);
LED++;
} }
} }
@ -165,7 +161,7 @@ SculptureView_Render(panel Panel, rect PanelBounds, render_command_buffer* Rende
for (u32 Job = 0; Job < JobsNeeded; Job++) for (u32 Job = 0; Job < JobsNeeded; Job++)
{ {
draw_leds_job_data* JobData = PushStruct(&State->Transient, draw_leds_job_data); draw_leds_job_data* JobData = PushStruct(&State->Transient, draw_leds_job_data);
JobData->LEDs = LedBuffer->Leds; JobData->Positions = LedBuffer->Positions;
JobData->Colors = LedBuffer->Colors; JobData->Colors = LedBuffer->Colors;
JobData->StartIndex = Job * MaxLEDsPerJob; JobData->StartIndex = Job * MaxLEDsPerJob;
JobData->OnePastLastIndex = GSMin(JobData->StartIndex + MaxLEDsPerJob, LedBuffer->LedCount); JobData->OnePastLastIndex = GSMin(JobData->StartIndex + MaxLEDsPerJob, LedBuffer->LedCount);

View File

@ -8,49 +8,47 @@
GSMetaTag(node_struct); GSMetaTag(node_struct);
struct solid_color_data struct solid_color_data
{ {
GSMetaTag(node_input); GSMetaTag(node_input);
v4 Color; v4 Color;
GSMetaTag(node_output); GSMetaTag(node_output);
color_buffer Result; color_buffer Result;
}; };
GSMetaTag(node_proc); // :TagParamsForNodeParamStructs GSMetaTag(node_proc); // :TagParamsForNodeParamStructs
void SolidColorProc(solid_color_data* Data) void SolidColorProc(solid_color_data* Data)
{ {
u8 R = (u8)GSClamp(0.f, (Data->Color.r * 255), 255.f); u8 R = (u8)GSClamp(0.f, (Data->Color.r * 255), 255.f);
u8 G = (u8)GSClamp(0.f, (Data->Color.g * 255), 255.f); u8 G = (u8)GSClamp(0.f, (Data->Color.g * 255), 255.f);
u8 B = (u8)GSClamp(0.f, (Data->Color.b * 255), 255.f); u8 B = (u8)GSClamp(0.f, (Data->Color.b * 255), 255.f);
led* LED = Data->Result.LEDs; for (s32 LedIndex = 0; LedIndex < Data->Result.LEDCount; LedIndex++)
for (s32 l = 0; l < Data->Result.LEDCount; l++)
{ {
Assert(LED->Index >= 0 && LED->Index < Data->Result.LEDCount); Assert(LedIndex >= 0 && LedIndex < Data->Result.LEDCount);
Data->Result.Colors[LED->Index].R = R; Data->Result.Colors[LedIndex].R = R;
Data->Result.Colors[LED->Index].G = G; Data->Result.Colors[LedIndex].G = G;
Data->Result.Colors[LED->Index].B = B; Data->Result.Colors[LedIndex].B = B;
LED++;
} }
} }
GSMetaTag(node_struct); GSMetaTag(node_struct);
struct vertical_color_fade_data struct vertical_color_fade_data
{ {
GSMetaTag(node_input); GSMetaTag(node_input);
v4 Color; v4 Color;
GSMetaTag(node_input); GSMetaTag(node_input);
r32 Min; r32 Min;
GSMetaTag(node_input); GSMetaTag(node_input);
r32 Max; r32 Max;
GSMetaTag(node_output); GSMetaTag(node_output);
color_buffer Result; color_buffer Result;
}; };
GSMetaTag(node_proc); // :TagParamsForNodeParamStructs GSMetaTag(node_proc); // :TagParamsForNodeParamStructs
void VerticalColorFadeProc(vertical_color_fade_data* Data) void VerticalColorFadeProc(vertical_color_fade_data* Data)
{ {
r32 R = (Data->Color.r * 255); r32 R = (Data->Color.r * 255);
@ -59,18 +57,18 @@ void VerticalColorFadeProc(vertical_color_fade_data* Data)
r32 Range = Data->Max - Data->Min; r32 Range = Data->Max - Data->Min;
led* LED = Data->Result.LEDs;
for (s32 l = 0; l < Data->Result.LEDCount; l++) for (s32 LedIndex = 0; LedIndex < Data->Result.LEDCount; LedIndex++)
{ {
Assert(LED->Index >= 0 && LED->Index < Data->Result.LEDCount); Assert(LedIndex >= 0 && LedIndex < Data->Result.LEDCount);
v4 LedPosition = Data->Result.LedPositions[LedIndex];
r32 Amount = (LED->Position.y - Data->Min) / Range; r32 Amount = (LedPosition.y - Data->Min) / Range;
Amount = GSClamp01(1.0f - Amount); Amount = GSClamp01(1.0f - Amount);
Data->Result.Colors[LED->Index].R = (u8)(R * Amount); Data->Result.Colors[LedIndex].R = (u8)(R * Amount);
Data->Result.Colors[LED->Index].G = (u8)(G * Amount); Data->Result.Colors[LedIndex].G = (u8)(G * Amount);
Data->Result.Colors[LED->Index].B = (u8)(B * Amount); Data->Result.Colors[LedIndex].B = (u8)(B * Amount);
LED++;
} }
} }
@ -78,32 +76,32 @@ void VerticalColorFadeProc(vertical_color_fade_data* Data)
GSMetaTag(node_struct); GSMetaTag(node_struct);
struct revolving_discs_data struct revolving_discs_data
{ {
GSMetaTag(node_input); GSMetaTag(node_input);
r32 Rotation; r32 Rotation;
GSMetaTag(node_input); GSMetaTag(node_input);
r32 ThetaZ; r32 ThetaZ;
GSMetaTag(node_input); GSMetaTag(node_input);
r32 ThetaY; r32 ThetaY;
GSMetaTag(node_input); GSMetaTag(node_input);
r32 DiscWidth; r32 DiscWidth;
GSMetaTag(node_input); GSMetaTag(node_input);
r32 InnerRadius; r32 InnerRadius;
GSMetaTag(node_input); GSMetaTag(node_input);
r32 OuterRadius; r32 OuterRadius;
GSMetaTag(node_input); GSMetaTag(node_input);
v4 Color; v4 Color;
GSMetaTag(node_output); GSMetaTag(node_output);
color_buffer Result; color_buffer Result;
}; };
GSMetaTag(node_proc); // :TagParamsForNodeParamStructs GSMetaTag(node_proc); // :TagParamsForNodeParamStructs
void RevolvingDiscs(revolving_discs_data* Data) void RevolvingDiscs(revolving_discs_data* Data)
{ {
DEBUG_TRACK_FUNCTION; DEBUG_TRACK_FUNCTION;
@ -124,10 +122,9 @@ void RevolvingDiscs(revolving_discs_data* Data)
r32 OuterRadiusSquared = Data->OuterRadius * Data->OuterRadius; r32 OuterRadiusSquared = Data->OuterRadius * Data->OuterRadius;
r32 InnerRadiusSquared = Data->InnerRadius * Data->InnerRadius; r32 InnerRadiusSquared = Data->InnerRadius * Data->InnerRadius;
led* LED = Data->Result.LEDs; for (s32 LedIndex = 0; LedIndex < Data->Result.LEDCount; LedIndex++)
for (s32 l = 0; l < Data->Result.LEDCount; l++)
{ {
v4 Position = LED->Position; v4 Position = Data->Result.LedPositions[LedIndex];
v4 ToFront = Position + FrontCenter; v4 ToFront = Position + FrontCenter;
v4 ToBack = Position + BackCenter; v4 ToBack = Position + BackCenter;
@ -143,10 +140,9 @@ void RevolvingDiscs(revolving_discs_data* Data)
{ {
if (XOR(ToFrontDotNormal > 0, ToBackDotNormal > 0)) if (XOR(ToFrontDotNormal > 0, ToBackDotNormal > 0))
{ {
Data->Result.Colors[LED->Index] = Color; Data->Result.Colors[LedIndex] = Color;
} }
} }
LED++;
} }
} }

View File

@ -10,8 +10,8 @@
PLATFORM_ALLOC(Win32Alloc) PLATFORM_ALLOC(Win32Alloc)
{ {
u8* Result = (u8*)VirtualAlloc(NULL, Size, u8* Result = (u8*)VirtualAlloc(NULL, Size,
MEM_COMMIT | MEM_RESERVE, MEM_COMMIT | MEM_RESERVE,
PAGE_EXECUTE_READWRITE); PAGE_EXECUTE_READWRITE);
return Result; return Result;
} }
@ -21,7 +21,7 @@ PLATFORM_FREE(Win32Free)
b32 Result = VirtualFree(Base, 0, MEM_RELEASE); b32 Result = VirtualFree(Base, 0, MEM_RELEASE);
if (!Result) if (!Result)
{ {
s32 Error = WSAGetLastError(); s32 Error = GetLastError();
// TODO(Peter): I'm waiting to see an error actually occur here // TODO(Peter): I'm waiting to see an error actually occur here
// to know what it could possibly be. // to know what it could possibly be.
InvalidCodePath; InvalidCodePath;