Added some notes to various parts of the code base. Also simplified test patterns to ensure that we don't need to use leds_in_universe_range anywhere except in DMX buffer preparation

This commit is contained in:
Peter Slattery 2020-02-05 12:20:03 -08:00
parent 58ef0b460f
commit 75bb2ae86d
10 changed files with 69 additions and 87 deletions

View File

@ -503,7 +503,6 @@ HandleWindowsMessage (
else
{
printf("Translated Char Not Recognized: %c\n", TranslatedChar);
//InvalidCodePath;
}
*/
}break;

View File

@ -113,6 +113,8 @@ GetWallClock ()
if (!QueryPerformanceCounter(&Time))
{
s32 Error = GetLastError();
// TODO(Peter): I'm waiting to see an error actually occur here
// to know what it could possibly be.
InvalidCodePath;
}
return (s64)Time.QuadPart;
@ -125,6 +127,8 @@ GetPerformanceFrequency ()
if (!QueryPerformanceFrequency(&Frequency))
{
s32 Error = GetLastError();
// TODO(Peter): I'm waiting to see an error actually occur here
// to know what it could possibly be.
InvalidCodePath;
}
return (s64)Frequency.QuadPart;

View File

@ -83,9 +83,10 @@ ParseAssemblyVector (char* String)
return Result;
}
internal void
internal b32
ParseAssemblyFileHeader (assembly_definition* Assembly, tokenizer* Tokenizer)
{
b32 HeaderIsValid = false;
if (CharArraysEqualUpToLength(Tokenizer->At, LED_STRIP_COUNT_IDENTIFIER, CharArrayLength(LED_STRIP_COUNT_IDENTIFIER)))
{
@ -95,19 +96,11 @@ ParseAssemblyFileHeader (assembly_definition* Assembly, tokenizer* Tokenizer)
if (CountToken.Type == AssemblyToken_Number)
{
Assembly->LEDStripSize = ParseSignedIntUnsafe(CountToken.Token).SignedIntValue;
}
else
{
InvalidCodePath;
HeaderIsValid = true;
}
EatWhitespace(Tokenizer);
}
else
{
// TODO(Peter): Handle corrupted files, try to recover?
InvalidCodePath;
}
return HeaderIsValid;
}
internal led_strip_definition

View File

@ -92,18 +92,12 @@ internal void OpenColorPicker(app_state* State, v4* Address);
internal void
TestPatternOne(assembly* Assembly, r32 Time)
{
for (u32 Range = 0; Range < Assembly->LEDUniverseMapCount; Range++)
for (u32 LEDIdx = 0; LEDIdx < Assembly->LEDCount; LEDIdx++)
{
leds_in_universe_range LEDUniverseRange = Assembly->LEDUniverseMap[Range];
for (s32 LEDIdx = LEDUniverseRange.RangeStart;
LEDIdx < LEDUniverseRange.RangeOnePastLast;
LEDIdx++)
{
led LED = Assembly->LEDs[LEDIdx];
Assembly->Colors[LED.Index].R = 255;
Assembly->Colors[LED.Index].B = 255;
Assembly->Colors[LED.Index].G = 255;
}
led LED = Assembly->LEDs[LEDIdx];
Assembly->Colors[LED.Index].R = 255;
Assembly->Colors[LED.Index].B = 255;
Assembly->Colors[LED.Index].G = 255;
}
}
@ -127,43 +121,37 @@ TestPatternTwo(assembly* Assembly, r32 Time)
r32 OuterRadiusSquared = 1000000;
r32 InnerRadiusSquared = 0;
for (u32 Range = 0; Range < Assembly->LEDUniverseMapCount; Range++)
for (u32 LEDIdx = 0; LEDIdx < Assembly->LEDCount; LEDIdx++)
{
leds_in_universe_range LEDUniverseRange = Assembly->LEDUniverseMap[Range];
for (s32 LEDIdx = LEDUniverseRange.RangeStart;
LEDIdx < LEDUniverseRange.RangeOnePastLast;
LEDIdx++)
led LED = Assembly->LEDs[LEDIdx];
v4 Position = LED.Position;
v4 ToFront = Position + FrontCenter;
v4 ToBack = Position + BackCenter;
r32 ToFrontDotNormal = Dot(ToFront, Normal);
r32 ToBackDotNormal = Dot(ToBack, Normal);
ToFrontDotNormal = GSClamp01(ToFrontDotNormal * 1000);
ToBackDotNormal = GSClamp01(ToBackDotNormal * 1000);
r32 SqDistToCenter = MagSqr(Position);
if (SqDistToCenter < OuterRadiusSquared && SqDistToCenter > InnerRadiusSquared)
{
led LED = Assembly->LEDs[LEDIdx];
v4 Position = LED.Position;
v4 ToFront = Position + FrontCenter;
v4 ToBack = Position + BackCenter;
r32 ToFrontDotNormal = Dot(ToFront, Normal);
r32 ToBackDotNormal = Dot(ToBack, Normal);
ToFrontDotNormal = GSClamp01(ToFrontDotNormal * 1000);
ToBackDotNormal = GSClamp01(ToBackDotNormal * 1000);
r32 SqDistToCenter = MagSqr(Position);
if (SqDistToCenter < OuterRadiusSquared && SqDistToCenter > InnerRadiusSquared)
if (XOR(ToFrontDotNormal > 0, ToBackDotNormal > 0))
{
if (XOR(ToFrontDotNormal > 0, ToBackDotNormal > 0))
{
Assembly->Colors[LED.Index] = Color;
}
else
{
Assembly->Colors[LED.Index] = {};
}
Assembly->Colors[LED.Index] = Color;
}
else
{
Assembly->Colors[LED.Index] = {};
}
}
else
{
Assembly->Colors[LED.Index] = {};
}
}
}
@ -178,31 +166,26 @@ TestPatternThree(assembly* Assembly, r32 Time)
r32 FadeDist = 35;
for (u32 Range = 0; Range < Assembly->LEDUniverseMapCount; Range++)
for (u32 LEDIdx = 0; LEDIdx < Assembly->LEDCount; LEDIdx++)
{
leds_in_universe_range LEDUniverseRange = Assembly->LEDUniverseMap[Range];
for (s32 LEDIdx = LEDUniverseRange.RangeStart;
LEDIdx < LEDUniverseRange.RangeOnePastLast;
LEDIdx++)
{
led LED = Assembly->LEDs[LEDIdx];
u8 Red = 0;
u8 Green = 0;
u8 Blue = 0;
r32 GreenDist = GSAbs(Mag(LED.Position - GreenCenter) - GreenRadius);
r32 GreenBrightness = GSClamp(0.f, FadeDist - GSAbs(GreenDist), FadeDist);
Green = (u8)(GreenBrightness * 255);
r32 TealDist = GSAbs(Mag(LED.Position - TealCenter) - TealRadius);
r32 TealBrightness = GSClamp(0.f, FadeDist - GSAbs(TealDist), FadeDist);
Red = (u8)(TealBrightness * 255);
Blue = (u8)(TealBrightness * 255);
Assembly->Colors[LED.Index].R = Red;
Assembly->Colors[LED.Index].B = Green;
Assembly->Colors[LED.Index].G = Green;
}
led LED = Assembly->LEDs[LEDIdx];
u8 Red = 0;
u8 Green = 0;
u8 Blue = 0;
r32 GreenDist = GSAbs(Mag(LED.Position - GreenCenter) - GreenRadius);
r32 GreenBrightness = GSClamp(0.f, FadeDist - GSAbs(GreenDist), FadeDist);
Green = (u8)(GreenBrightness * 255);
r32 TealDist = GSAbs(Mag(LED.Position - TealCenter) - TealRadius);
r32 TealBrightness = GSClamp(0.f, FadeDist - GSAbs(TealDist), FadeDist);
Red = (u8)(TealBrightness * 255);
Blue = (u8)(TealBrightness * 255);
Assembly->Colors[LED.Index].R = Red;
Assembly->Colors[LED.Index].B = Green;
Assembly->Colors[LED.Index].G = Green;
}
}

View File

@ -5,15 +5,6 @@
//
#ifndef FOLDHAUS_ASSEMBLY_CPP
internal s32
GetAssemblyMemorySizeFromDefinition(assembly_definition Definition, string Name)
{
s32 Result = (sizeof(led) + sizeof(pixel)) * Definition.TotalLEDCount;
Result += sizeof(leds_in_universe_range) * Definition.LEDStripCount;
Result += Name.Length;
return Result;
}
internal assembly
ConstructAssemblyFromDefinition (assembly_definition Definition,
string AssemblyName,

View File

@ -22,6 +22,10 @@ union pixel
u8 Channels[3];
};
// NOTE(Peter): This structure is so we can keep track of
// what LEDs output to which DMX universe. You don't need
// to use it anywhere else, as all the data for patterns,
// colors, and groups is/will be stored elsewhere.
struct leds_in_universe_range
{
s32 RangeStart;

View File

@ -639,7 +639,8 @@ WinMain (
}
else
{
InvalidCodePath;
MessageBox(MainWindow.Handle, "Unable to load application DLL at startup.\nAborting\n", "Set Up Error", MB_OK);
return -1;
}
WSADATA WSAData;

View File

@ -22,6 +22,8 @@ PLATFORM_FREE(Win32Free)
if (!Result)
{
s32 Error = WSAGetLastError();
// TODO(Peter): I'm waiting to see an error actually occur here
// to know what it could possibly be.
InvalidCodePath;
}
return Result;

View File

@ -15,6 +15,8 @@ GetPerformanceFrequency ()
if (!QueryPerformanceFrequency(&Frequency))
{
s32 Error = GetLastError();
// TODO(Peter): I'm waiting to see an error actually occur here
// to know what it could possibly be.
InvalidCodePath;
}
return (s64)Frequency.QuadPart;
@ -31,6 +33,8 @@ GetWallClock ()
if (!QueryPerformanceCounter(&Time))
{
s32 Error = GetLastError();
// TODO(Peter): I'm waiting to see an error actually occur here
// to know what it could possibly be.
InvalidCodePath;
}
return (s64)Time.QuadPart;

View File

@ -21,8 +21,8 @@ x Hot Code Reloading
- Enumerate Directory Contents (you started this in win32_foldhaus_fileio.h)
-
- File Loading
- Gracefully handle File Not found
x File Loading
x Gracefully handle File Not found
- Buckets & Lists
- Allow them to use memory arenas
@ -57,6 +57,7 @@ x Hot Code Reloading
- styling
- text input
- lister with icon options
- panel system: destroy panel by extending it beyond its max, not just its min
- Sculpture View
- mouse spatial interaction - handles, and hover for info