updated sculpture file parsing
This commit is contained in:
parent
0164fea691
commit
af68881e04
|
@ -0,0 +1,23 @@
|
||||||
|
struct hello_struct_t
|
||||||
|
{
|
||||||
|
const int x;
|
||||||
|
float* y;
|
||||||
|
char hello;
|
||||||
|
};
|
||||||
|
|
||||||
|
union Vector
|
||||||
|
{
|
||||||
|
struct {
|
||||||
|
int X;
|
||||||
|
int Y;
|
||||||
|
int Z;
|
||||||
|
};
|
||||||
|
int E[3];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct test_def;
|
||||||
|
|
||||||
|
int main (int ArgCount, char* Args[])
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -1,3 +1,3 @@
|
||||||
@echo off
|
@echo off
|
||||||
|
|
||||||
remedybg build\remedy_win32_foldhaus.rdbg
|
remedybg build\debug_lumenarium.rdbg
|
|
@ -15,6 +15,7 @@ blacklist_patterns = {
|
||||||
load_paths_base = {
|
load_paths_base = {
|
||||||
{ "src", .relative = true, .recursive = true, },
|
{ "src", .relative = true, .recursive = true, },
|
||||||
{ "meta", .relative = true, .recursive = true, },
|
{ "meta", .relative = true, .recursive = true, },
|
||||||
|
{ "C:\programs-dev\gs_libs\src", .relative = false, .recursive = true, }
|
||||||
};
|
};
|
||||||
load_paths = {
|
load_paths = {
|
||||||
{ load_paths_base, .os = "win", },
|
{ load_paths_base, .os = "win", },
|
||||||
|
@ -39,5 +40,5 @@ command_list = {
|
||||||
{ "build/main.exe" , .os = "linux" },
|
{ "build/main.exe" , .os = "linux" },
|
||||||
{ "build/main.exe" , .os = "mac" }, }, },
|
{ "build/main.exe" , .os = "mac" }, }, },
|
||||||
};
|
};
|
||||||
fkey_command[1] = "build";
|
fkey_command[1] = "build_application";
|
||||||
fkey_command[2] = "run";
|
fkey_command[2] = "build_meta";
|
||||||
|
|
|
@ -86,6 +86,7 @@ ParseAssemblyVector (char* String)
|
||||||
internal void
|
internal void
|
||||||
ParseAssemblyFileHeader (assembly_definition* Assembly, tokenizer* Tokenizer)
|
ParseAssemblyFileHeader (assembly_definition* Assembly, tokenizer* Tokenizer)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (CharArraysEqualUpToLength(Tokenizer->At, LED_STRIP_COUNT_IDENTIFIER, CharArrayLength(LED_STRIP_COUNT_IDENTIFIER)))
|
if (CharArraysEqualUpToLength(Tokenizer->At, LED_STRIP_COUNT_IDENTIFIER, CharArrayLength(LED_STRIP_COUNT_IDENTIFIER)))
|
||||||
{
|
{
|
||||||
Tokenizer->At += CharArrayLength(LED_STRIP_COUNT_IDENTIFIER);
|
Tokenizer->At += CharArrayLength(LED_STRIP_COUNT_IDENTIFIER);
|
||||||
|
@ -213,21 +214,237 @@ ParseAssemblyFileBody (assembly_definition* Assembly, tokenizer* Tokenizer)
|
||||||
Assert(Assembly->LEDStripCount == Assembly->LEDStripSize);
|
Assert(Assembly->LEDStripCount == Assembly->LEDStripSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline b32
|
||||||
|
ParseTokenEquals (tokenizer* T, char* Validate)
|
||||||
|
{
|
||||||
|
b32 Result = true;
|
||||||
|
|
||||||
|
char* TAt = T->At;
|
||||||
|
char* VAt = Validate;
|
||||||
|
while (((TAt - T->Memory) < T->MemoryLength) && *VAt)
|
||||||
|
{
|
||||||
|
if (*VAt != *TAt)
|
||||||
|
{
|
||||||
|
Result = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
TAt++;
|
||||||
|
*VAt++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Result)
|
||||||
|
{
|
||||||
|
T->At = TAt;
|
||||||
|
EatWhitespace(T);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal b32
|
||||||
|
ParseComma(tokenizer* T)
|
||||||
|
{
|
||||||
|
b32 Result = ParseTokenEquals(T, ",");
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal b32
|
||||||
|
ParseOpenCurlyBrace(tokenizer* T)
|
||||||
|
{
|
||||||
|
b32 Result = ParseTokenEquals(T, "{");
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal b32
|
||||||
|
ParseCloseCurlyBrace(tokenizer* T)
|
||||||
|
{
|
||||||
|
b32 Result = ParseTokenEquals(T, "}");
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal b32
|
||||||
|
ParseOpenParen(tokenizer* T)
|
||||||
|
{
|
||||||
|
b32 Result = ParseTokenEquals(T, "(");
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal b32
|
||||||
|
ParseCloseParen(tokenizer* T)
|
||||||
|
{
|
||||||
|
b32 Result = ParseTokenEquals(T, ")");
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal b32
|
||||||
|
ParseUnsignedInteger(tokenizer* T, u32* Value)
|
||||||
|
{
|
||||||
|
parse_result Result = ParseUnsignedIntUnsafe(T->At);
|
||||||
|
*Value = Result.UnsignedIntValue;
|
||||||
|
T->At = Result.OnePastLast;
|
||||||
|
|
||||||
|
// TODO(Peter): Parse functions in gs_string don't actually check for errors or
|
||||||
|
// whether or not they actually parsed an int.
|
||||||
|
// :GSStringParseErrors
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal b32
|
||||||
|
ParseFloat(tokenizer* T, r32* Value)
|
||||||
|
{
|
||||||
|
parse_result ParseResult = ParseFloatUnsafe(T->At);
|
||||||
|
*Value = ParseResult.FloatValue;
|
||||||
|
T->At = ParseResult.OnePastLast;
|
||||||
|
|
||||||
|
// TODO(Peter):
|
||||||
|
// :GSStringParseErrors
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal b32
|
||||||
|
ParseVector(tokenizer* T, v3* Value)
|
||||||
|
{
|
||||||
|
b32 Result = true;
|
||||||
|
|
||||||
|
if (ParseOpenParen(T))
|
||||||
|
{
|
||||||
|
for (u32 i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
b32 ValueSuccess = ParseFloat(T, &(Value->E[i]));
|
||||||
|
if (!ValueSuccess)
|
||||||
|
{
|
||||||
|
Result = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
b32 CommaSuccess = ParseComma(T);
|
||||||
|
if (!CommaSuccess)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ParseCloseParen(T))
|
||||||
|
{
|
||||||
|
Result = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Result = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(Peter): Error reporting
|
||||||
|
#define ParseLEDStripToken(tokenizer, parse_expr, error_msg) \
|
||||||
|
(parse_expr) && (ParseComma(tokenizer))
|
||||||
|
|
||||||
|
internal b32
|
||||||
|
ParseLEDStripCount (tokenizer* T, u32* Value)
|
||||||
|
{
|
||||||
|
b32 Result = false;
|
||||||
|
|
||||||
|
if (ParseTokenEquals(T, LED_STRIP_COUNT_IDENTIFIER))
|
||||||
|
{
|
||||||
|
EatWhitespace(T);
|
||||||
|
if (ParseUnsignedInteger(T, Value))
|
||||||
|
{
|
||||||
|
Result = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal b32
|
||||||
|
ParseLEDStrip (led_strip_definition* Strip, tokenizer* T, memory_arena* Arena)
|
||||||
|
{
|
||||||
|
b32 Result = false;
|
||||||
|
|
||||||
|
if (ParseTokenEquals(T, LED_STRIP_IDENTIFIER) &&
|
||||||
|
ParseOpenCurlyBrace(T))
|
||||||
|
{
|
||||||
|
Result = true;
|
||||||
|
|
||||||
|
u32 ControlBoxIndex, StartUniverse, StartChannel;
|
||||||
|
ParseLEDStripToken(T, ParseUnsignedInteger(T, &Strip->ControlBoxID), "Control Box Error");
|
||||||
|
ParseLEDStripToken(T, ParseUnsignedInteger(T, &Strip->StartUniverse), "Start Universe Error");
|
||||||
|
ParseLEDStripToken(T, ParseUnsignedInteger(T, &Strip->StartChannel), "Start Channel Error");
|
||||||
|
|
||||||
|
if (ParseTokenEquals(T, INTERPOLATE_POINTS_IDENTIFIER) &&
|
||||||
|
ParseComma(T))
|
||||||
|
{
|
||||||
|
Strip->InterpolationType = StripInterpolate_Points;
|
||||||
|
|
||||||
|
ParseLEDStripToken(T, ParseVector(T, &Strip->InterpolatePositionStart), "Position Start Error");
|
||||||
|
ParseLEDStripToken(T, ParseVector(T, &Strip->InterpolatePositionEnd), "Position End Error");
|
||||||
|
}
|
||||||
|
|
||||||
|
ParseLEDStripToken(T, ParseUnsignedInteger(T, &Strip->LEDsPerStrip), "LEDs Per Strip Error");
|
||||||
|
|
||||||
|
EatWhitespace(T);
|
||||||
|
if (!ParseCloseCurlyBrace(T))
|
||||||
|
{
|
||||||
|
Result = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
internal assembly_definition
|
internal assembly_definition
|
||||||
ParseAssemblyFile (u8* FileBase, s32 FileSize, memory_arena* Arena)
|
ParseAssemblyFile (u8* FileBase, s32 FileSize, memory_arena* Arena)
|
||||||
{
|
{
|
||||||
assembly_definition AssemblyDefinition = {};
|
assembly_definition Assembly = {};
|
||||||
|
|
||||||
tokenizer AssemblyFileTokenizer = {};
|
tokenizer Tokenizer = {};
|
||||||
AssemblyFileTokenizer.At = (char*)FileBase;
|
Tokenizer.At = (char*)FileBase;
|
||||||
AssemblyFileTokenizer.Memory = (char*)FileBase;
|
Tokenizer.Memory = (char*)FileBase;
|
||||||
AssemblyFileTokenizer.MemoryLength = FileSize;
|
Tokenizer.MemoryLength = FileSize;
|
||||||
|
|
||||||
ParseAssemblyFileHeader(&AssemblyDefinition, &AssemblyFileTokenizer);
|
if (ParseLEDStripCount(&Tokenizer, &Assembly.LEDStripSize))
|
||||||
AssemblyDefinition.LEDStrips = PushArray(Arena, led_strip_definition, AssemblyDefinition.LEDStripSize);
|
{
|
||||||
ParseAssemblyFileBody(&AssemblyDefinition, &AssemblyFileTokenizer);
|
Assembly.LEDStrips = PushArray(Arena, led_strip_definition, Assembly.LEDStripSize);
|
||||||
|
|
||||||
return AssemblyDefinition;
|
while (AtValidPosition(Tokenizer))
|
||||||
|
{
|
||||||
|
EatWhitespace(&Tokenizer);
|
||||||
|
|
||||||
|
if (Assembly.LEDStripCount < Assembly.LEDStripSize)
|
||||||
|
{
|
||||||
|
led_strip_definition* LEDStrip = Assembly.LEDStrips + Assembly.LEDStripCount++;
|
||||||
|
|
||||||
|
if (ParseLEDStrip(LEDStrip, &Tokenizer, Arena))
|
||||||
|
{
|
||||||
|
Assembly.TotalLEDCount += LEDStrip->LEDsPerStrip;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
InvalidCodePath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (ParseTokenEquals(&Tokenizer, END_ASSEMBLY_FILE_IDENTIFIER))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
InvalidCodePath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// TODO(Peter): Error reporting
|
||||||
|
InvalidCodePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Assembly;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ASSEMBLY_PARSER_CPP
|
#define ASSEMBLY_PARSER_CPP
|
||||||
|
|
|
@ -47,23 +47,28 @@ enum strip_interpolation_type
|
||||||
|
|
||||||
struct led_strip_definition
|
struct led_strip_definition
|
||||||
{
|
{
|
||||||
s32 ControlBoxID;
|
u32 ControlBoxID;
|
||||||
s32 StartUniverse, StartChannel;
|
u32 StartUniverse;
|
||||||
|
u32 StartChannel;
|
||||||
|
|
||||||
strip_interpolation_type InterpolationType;
|
strip_interpolation_type InterpolationType;
|
||||||
// Interpolate Boxes
|
// Interpolate Boxes
|
||||||
s32 StartBoxIndex, EndBoxIndex;
|
u32 StartBoxIndex;
|
||||||
|
u32 EndBoxIndex;
|
||||||
|
|
||||||
// Interpolate Positions
|
// Interpolate Positions
|
||||||
v3 InterpolatePositionStart, InterpolatePositionEnd;
|
v3 InterpolatePositionStart;
|
||||||
|
v3 InterpolatePositionEnd;
|
||||||
|
|
||||||
// Universal Interpolation
|
// Universal Interpolation
|
||||||
s32 LEDsPerStrip;
|
u32 LEDsPerStrip;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct assembly_definition
|
struct assembly_definition
|
||||||
{
|
{
|
||||||
s32 LEDStripSize;
|
u32 LEDStripSize;
|
||||||
s32 LEDStripCount;
|
u32 LEDStripCount;
|
||||||
s32 TotalLEDCount;
|
u32 TotalLEDCount;
|
||||||
led_strip_definition* LEDStrips;
|
led_strip_definition* LEDStrips;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -269,7 +269,7 @@ CreateDMXBuffers(assembly Assembly, s32 BufferHeaderSize, memory_arena* Arena)
|
||||||
|
|
||||||
s32 BufferSize = BufferHeaderSize + 512;
|
s32 BufferSize = BufferHeaderSize + 512;
|
||||||
|
|
||||||
for (s32 Range = 0; Range < Assembly.LEDUniverseMapCount; Range++)
|
for (u32 Range = 0; Range < Assembly.LEDUniverseMapCount; Range++)
|
||||||
{
|
{
|
||||||
leds_in_universe_range LEDUniverseRange = Assembly.LEDUniverseMap[Range];
|
leds_in_universe_range LEDUniverseRange = Assembly.LEDUniverseMap[Range];
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ internal void OpenColorPicker(app_state* State, v4* Address);
|
||||||
internal void
|
internal void
|
||||||
TestPatternOne(assembly* Assembly, r32 Time)
|
TestPatternOne(assembly* Assembly, r32 Time)
|
||||||
{
|
{
|
||||||
for (s32 Range = 0; Range < Assembly->LEDUniverseMapCount; Range++)
|
for (u32 Range = 0; Range < Assembly->LEDUniverseMapCount; Range++)
|
||||||
{
|
{
|
||||||
leds_in_universe_range LEDUniverseRange = Assembly->LEDUniverseMap[Range];
|
leds_in_universe_range LEDUniverseRange = Assembly->LEDUniverseMap[Range];
|
||||||
for (s32 LEDIdx = LEDUniverseRange.RangeStart;
|
for (s32 LEDIdx = LEDUniverseRange.RangeStart;
|
||||||
|
@ -122,7 +122,7 @@ TestPatternTwo(assembly* Assembly, r32 Time)
|
||||||
r32 OuterRadiusSquared = 1000000;
|
r32 OuterRadiusSquared = 1000000;
|
||||||
r32 InnerRadiusSquared = 0;
|
r32 InnerRadiusSquared = 0;
|
||||||
|
|
||||||
for (s32 Range = 0; Range < Assembly->LEDUniverseMapCount; Range++)
|
for (u32 Range = 0; Range < Assembly->LEDUniverseMapCount; Range++)
|
||||||
{
|
{
|
||||||
leds_in_universe_range LEDUniverseRange = Assembly->LEDUniverseMap[Range];
|
leds_in_universe_range LEDUniverseRange = Assembly->LEDUniverseMap[Range];
|
||||||
for (s32 LEDIdx = LEDUniverseRange.RangeStart;
|
for (s32 LEDIdx = LEDUniverseRange.RangeStart;
|
||||||
|
@ -173,7 +173,7 @@ TestPatternThree(assembly* Assembly, r32 Time)
|
||||||
r32 BluePosition = -BlueSize + (Time * 25);
|
r32 BluePosition = -BlueSize + (Time * 25);
|
||||||
r32 RedPosition = (100 + RedSize) + (Time * -35);
|
r32 RedPosition = (100 + RedSize) + (Time * -35);
|
||||||
|
|
||||||
for (s32 Range = 0; Range < Assembly->LEDUniverseMapCount; Range++)
|
for (u32 Range = 0; Range < Assembly->LEDUniverseMapCount; Range++)
|
||||||
{
|
{
|
||||||
leds_in_universe_range LEDUniverseRange = Assembly->LEDUniverseMap[Range];
|
leds_in_universe_range LEDUniverseRange = Assembly->LEDUniverseMap[Range];
|
||||||
for (s32 LEDIdx = LEDUniverseRange.RangeStart;
|
for (s32 LEDIdx = LEDUniverseRange.RangeStart;
|
||||||
|
|
|
@ -37,7 +37,7 @@ ConstructAssemblyFromDefinition (assembly_definition Definition,
|
||||||
Assembly.LEDUniverseMap = PushArray(&Assembly.Arena, leds_in_universe_range, Definition.LEDStripCount);
|
Assembly.LEDUniverseMap = PushArray(&Assembly.Arena, leds_in_universe_range, Definition.LEDStripCount);
|
||||||
|
|
||||||
// Add LEDs
|
// Add LEDs
|
||||||
for (s32 StripIdx = 0; StripIdx < Definition.LEDStripCount; StripIdx++)
|
for (u32 StripIdx = 0; StripIdx < Definition.LEDStripCount; StripIdx++)
|
||||||
{
|
{
|
||||||
led_strip_definition StripDef = Definition.LEDStrips[StripIdx];
|
led_strip_definition StripDef = Definition.LEDStrips[StripIdx];
|
||||||
|
|
||||||
|
|
|
@ -36,11 +36,11 @@ struct assembly
|
||||||
string Name;
|
string Name;
|
||||||
string FilePath;
|
string FilePath;
|
||||||
|
|
||||||
s32 LEDCount;
|
u32 LEDCount;
|
||||||
pixel* Colors;
|
pixel* Colors;
|
||||||
led* LEDs;
|
led* LEDs;
|
||||||
|
|
||||||
s32 LEDUniverseMapCount;
|
u32 LEDUniverseMapCount;
|
||||||
leds_in_universe_range* LEDUniverseMap;
|
leds_in_universe_range* LEDUniverseMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ PANEL_RENDER_PROC(HierarchyView_Render)
|
||||||
};
|
};
|
||||||
|
|
||||||
v2 TextOffset = v2{10, 4};
|
v2 TextOffset = v2{10, 4};
|
||||||
string TempString = MakeString(PushArray(&State->Transient, char, 256), 256);
|
string TempString = MakeString(PushArray(&State->Transient, char, 256), 0, 256);
|
||||||
|
|
||||||
u32 LineCount = (u32)(PanelHeight / List.ListElementDimensions.y) + 1;
|
u32 LineCount = (u32)(PanelHeight / List.ListElementDimensions.y) + 1;
|
||||||
for (u32 i = 0; i < LineCount; i++)
|
for (u32 i = 0; i < LineCount; i++)
|
||||||
|
|
|
@ -141,16 +141,16 @@ PANEL_RENDER_PROC(SculptureView_Render)
|
||||||
m44 FaceCameraMatrix = GetLookAtMatrix(v4{0, 0, 0, 1}, V4(State->Camera.Position, 1));
|
m44 FaceCameraMatrix = GetLookAtMatrix(v4{0, 0, 0, 1}, V4(State->Camera.Position, 1));
|
||||||
FaceCameraMatrix = FaceCameraMatrix;
|
FaceCameraMatrix = FaceCameraMatrix;
|
||||||
|
|
||||||
s32 MaxLEDsPerJob = 2048;
|
u32 MaxLEDsPerJob = 2048;
|
||||||
render_quad_batch_constructor RenderLEDsBatch = PushRenderQuad3DBatch(RenderBuffer, State->TotalLEDsCount);
|
render_quad_batch_constructor RenderLEDsBatch = PushRenderQuad3DBatch(RenderBuffer, State->TotalLEDsCount);
|
||||||
|
|
||||||
for (u32 i = 0; i < State->ActiveAssemblyIndecies.Used; i++)
|
for (u32 i = 0; i < State->ActiveAssemblyIndecies.Used; i++)
|
||||||
{
|
{
|
||||||
gs_list_handle AssemblyHandle = *State->ActiveAssemblyIndecies.GetElementAtIndex(i);
|
gs_list_handle AssemblyHandle = *State->ActiveAssemblyIndecies.GetElementAtIndex(i);
|
||||||
assembly Assembly = *State->AssemblyList.GetElementWithHandle(AssemblyHandle);
|
assembly Assembly = *State->AssemblyList.GetElementWithHandle(AssemblyHandle);
|
||||||
s32 JobsNeeded = IntegerDivideRoundUp(Assembly.LEDCount, MaxLEDsPerJob);
|
u32 JobsNeeded = IntegerDivideRoundUp(Assembly.LEDCount, MaxLEDsPerJob);
|
||||||
|
|
||||||
for (s32 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 = Assembly.LEDs;
|
JobData->LEDs = Assembly.LEDs;
|
||||||
|
|
Loading…
Reference in New Issue