More pattern work
This commit is contained in:
parent
d81b809970
commit
ef4eb84a83
|
@ -25,12 +25,12 @@ load_paths = {
|
|||
|
||||
command_list = {
|
||||
{ .name = "build_application",
|
||||
.out = "*app compilation*", .footer_panel = false, .save_dirty_files = true,
|
||||
.out = "*compilation*", .footer_panel = false, .save_dirty_files = true,
|
||||
.cmd = { { "build\build_app_msvc_win32_debug.bat" , .os = "win" },
|
||||
{ "./build.sh", .os = "linux" },
|
||||
{ "./build.sh", .os = "mac" }, }, },
|
||||
{ .name = "build_meta",
|
||||
.out = "*meta compilation*", .footer_panel = false, .save_dirty_files = true,
|
||||
.out = "*compilation*", .footer_panel = true, .save_dirty_files = true,
|
||||
.cmd = { { "build\build_meta_msvc_win32_debug.bat" , .os = "win" },
|
||||
{ "./build_meta.sh", .os = "linux" },
|
||||
{ "./build_meta.sh", .os = "mac" }, }, },
|
||||
|
|
|
@ -18,6 +18,25 @@ Smoothstep(r32 T, r32 A, r32 B)
|
|||
{
|
||||
return LerpR32(Smoothstep(T), A, B);
|
||||
}
|
||||
internal v3
|
||||
Smoothstep(v3 P)
|
||||
{
|
||||
v3 R = {};
|
||||
R.x = Smoothstep(P.x);
|
||||
R.y = Smoothstep(P.y);
|
||||
R.z = Smoothstep(P.z);
|
||||
return R;
|
||||
}
|
||||
|
||||
internal v3
|
||||
AbsV3(v3 P)
|
||||
{
|
||||
v3 Result = {};
|
||||
Result.x = Abs(P.x);
|
||||
Result.y = Abs(P.y);
|
||||
Result.z = Abs(P.z);
|
||||
return Result;
|
||||
}
|
||||
|
||||
internal v2
|
||||
FloorV2(v2 P)
|
||||
|
@ -112,6 +131,15 @@ Hash3(v2 P)
|
|||
return FractV3(SinV3(Q) * 43758.5453f);
|
||||
}
|
||||
|
||||
internal r32
|
||||
HashV3ToR32(v3 P)
|
||||
{
|
||||
v3 Pp = FractV3(P * 0.3183099f + v3{0.1f, 0.1f, 0.1f});
|
||||
Pp *= 17.0f;
|
||||
r32 Result = FractR32(Pp.x * Pp.y * Pp.z * (Pp.x + Pp.y + Pp.z));
|
||||
return Result;
|
||||
}
|
||||
|
||||
internal r32
|
||||
Random(v2 N)
|
||||
{
|
||||
|
@ -135,7 +163,35 @@ Noise2D(v2 P)
|
|||
}
|
||||
|
||||
internal r32
|
||||
Noise3D(v3 Pp)
|
||||
Noise3D(v3 P)
|
||||
{
|
||||
P = AbsV3(P);
|
||||
v3 PFloor = FloorV3(P);
|
||||
v3 PFract = FractV3(P);
|
||||
v3 F = Smoothstep(PFract);
|
||||
|
||||
r32 Result = LerpR32(F.z,
|
||||
LerpR32(F.y,
|
||||
LerpR32(F.x,
|
||||
HashV3ToR32(PFloor + v3{0, 0, 0}),
|
||||
HashV3ToR32(PFloor + v3{1, 0, 0})),
|
||||
LerpR32(F.x,
|
||||
HashV3ToR32(PFloor + v3{0, 1, 0}),
|
||||
HashV3ToR32(PFloor + v3{1, 1, 0}))),
|
||||
LerpR32(F.y,
|
||||
LerpR32(F.x,
|
||||
HashV3ToR32(PFloor + v3{0, 0, 1}),
|
||||
HashV3ToR32(PFloor + v3{1, 0, 1})),
|
||||
LerpR32(F.x,
|
||||
HashV3ToR32(PFloor + v3{0, 1, 1}),
|
||||
HashV3ToR32(PFloor + v3{1, 1, 1}))));
|
||||
|
||||
Assert(Result >= 0 && Result <= 1);
|
||||
return Result;
|
||||
}
|
||||
|
||||
internal r32
|
||||
Noise3D_(v3 Pp)
|
||||
{
|
||||
v3 P = FloorV3(Pp);
|
||||
v3 W = FractV3(Pp);
|
||||
|
@ -219,6 +275,26 @@ Fbm3D(v3 P)
|
|||
return A;
|
||||
}
|
||||
|
||||
internal r32
|
||||
Fbm3D(v3 P, r32 T)
|
||||
{
|
||||
v3 Tt = v3{T, T, T};
|
||||
r32 SinT = SinR32(T);
|
||||
v3 Tv = v3{SinT, SinT, SinT};
|
||||
v3 Pp = P;
|
||||
r32 F = 0.0;
|
||||
|
||||
F += 0.500000f * Noise3D(Pp + Tt); Pp = Pp * 2.02;
|
||||
F += 0.031250f * Noise3D(Pp); Pp = Pp * 2.01;
|
||||
F += 0.250000f * Noise3D(Pp); Pp = Pp * 2.03;
|
||||
F += 0.125000f * Noise3D(Pp); Pp = Pp * 2.01;
|
||||
F += 0.062500f * Noise3D(Pp); Pp = Pp * 2.04;
|
||||
F += 0.015625f * Noise3D(Pp + Tv);
|
||||
|
||||
F = F / 0.984375f;
|
||||
return F;
|
||||
}
|
||||
|
||||
internal r32
|
||||
Voronoise(v2 P, r32 U, r32 V)
|
||||
{
|
||||
|
@ -974,6 +1050,7 @@ Pattern_Wavy(led_buffer* Leds, assembly Assembly, r32 Time, gs_memory_arena* Tra
|
|||
internal void
|
||||
Pattern_Patchy(led_buffer* Leds, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData)
|
||||
{
|
||||
#if 0
|
||||
for (u32 LedIndex = 0; LedIndex < Leds->LedCount; LedIndex++)
|
||||
{
|
||||
v4 P = Leds->Positions[LedIndex];
|
||||
|
@ -994,6 +1071,49 @@ Pattern_Patchy(led_buffer* Leds, assembly Assembly, r32 Time, gs_memory_arena* T
|
|||
Leds->Colors[LedIndex] = V4ToRGBPixel(C);
|
||||
//Leds->Colors[LedIndex] = pixel{NV, NV, NV};
|
||||
}
|
||||
#elif 1
|
||||
for (u32 LedIndex = 0; LedIndex < Leds->LedCount; LedIndex++)
|
||||
{
|
||||
v4 P = Leds->Positions[LedIndex];
|
||||
r32 LedRange = 300.0f;
|
||||
r32 ScaleFactor = 1.0f / LedRange;
|
||||
v3 Pp = P.xyz + v3{150, 100, 0};
|
||||
|
||||
r32 NoiseA = Noise3D((Pp / 38) + v3{0, 0, Time});
|
||||
NoiseA = PowR32(NoiseA, 3);
|
||||
NoiseA = Smoothstep(NoiseA);
|
||||
v4 CA = v4{1, 0, 1, 1} * NoiseA;
|
||||
|
||||
r32 NoiseB = Noise3D((Pp / 75) + v3{Time * 0.5f, 0, 0});
|
||||
NoiseB = PowR32(NoiseB, 3);
|
||||
NoiseB = Smoothstep(NoiseB);
|
||||
v4 CB = v4{0, 1, 1, 1} * NoiseB;
|
||||
|
||||
v4 C = CA + CB;
|
||||
Leds->Colors[LedIndex] = V4ToRGBPixel(C);
|
||||
}
|
||||
#else
|
||||
for (u32 LedIndex = 0; LedIndex < Leds->LedCount; LedIndex++)
|
||||
{
|
||||
v4 P = Leds->Positions[LedIndex];
|
||||
r32 LedRange = 300.0f;
|
||||
r32 ScaleFactor = 1.0f / LedRange;
|
||||
v3 Pp = P.xyz + v3{150, 100, 0};
|
||||
|
||||
r32 NoiseA = Fbm3D((Pp / 35), Time * 0.5f);
|
||||
//NoiseA = PowR32(NoiseA, 3);
|
||||
NoiseA = Smoothstep(NoiseA);
|
||||
v4 CA = v4{1, 0, 1, 1} * NoiseA;
|
||||
|
||||
r32 NoiseB = Noise3D((Pp / 35) + v3{0, 0, Time * 5});
|
||||
NoiseB = PowR32(NoiseB, 3);
|
||||
NoiseB = Smoothstep(NoiseB);
|
||||
v4 CB = v4{0, 1, 1, 1};
|
||||
|
||||
v4 C = V4Lerp(NoiseB, CA, CB);
|
||||
Leds->Colors[LedIndex] = V4ToRGBPixel(C);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
internal void
|
||||
|
|
|
@ -683,7 +683,7 @@ WinMain (
|
|||
|
||||
Context.UpdateAndRender(&Context, InputQueue, &RenderBuffer, &OutputData);
|
||||
|
||||
bool Multithread = true;
|
||||
bool Multithread = false;
|
||||
if (Multithread)
|
||||
{
|
||||
for (addressed_data_buffer* At = OutputData.Root;
|
||||
|
|
|
@ -74,7 +74,19 @@ HANDLE
|
|||
Win32SerialPort_Open(char* PortName)
|
||||
{
|
||||
DEBUG_TRACK_FUNCTION;
|
||||
HANDLE ComPortHandle = CreateFile(PortName,
|
||||
HANDLE ComPortHandle = INVALID_HANDLE_VALUE;;
|
||||
|
||||
WIN32_FIND_DATA FindData;
|
||||
HANDLE ComPortExists = FindFirstFile(PortName, &FindData);
|
||||
|
||||
// TODO(PS): we aren't sure yet if FindFirstFile will actually work
|
||||
// for the purpose of checking to see if a ComPort actually exists.
|
||||
// When you go to Foldspace next time, make sure we are still connecting
|
||||
// the sculpture
|
||||
if (ComPortExists != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
|
||||
ComPortHandle = CreateFile(PortName,
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
NULL, // Default Security Attr
|
||||
|
@ -82,6 +94,8 @@ Win32SerialPort_Open(char* PortName)
|
|||
0, // Not overlapped I/O
|
||||
NULL);
|
||||
|
||||
bool HasError = false;
|
||||
|
||||
if (ComPortHandle != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
COMMTIMEOUTS Timeouts = { 0 };
|
||||
|
@ -91,21 +105,29 @@ Win32SerialPort_Open(char* PortName)
|
|||
Timeouts.WriteTotalTimeoutConstant = 0; // in milliseconds
|
||||
Timeouts.WriteTotalTimeoutMultiplier = 0; // in milliseconds
|
||||
|
||||
if (SetCommTimeouts(ComPortHandle, &Timeouts))
|
||||
HasError = !SetCommTimeouts(ComPortHandle, &Timeouts);
|
||||
}
|
||||
else
|
||||
{
|
||||
HasError = true;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
s32 Error = GetLastError();
|
||||
// TODO(pjs): Error logging
|
||||
}
|
||||
}
|
||||
else
|
||||
if (HasError)
|
||||
{
|
||||
// Error
|
||||
s32 Error = GetLastError();
|
||||
// TODO(pjs): Error logging
|
||||
switch (Error)
|
||||
{
|
||||
case ERROR_NO_SUCH_DEVICE:
|
||||
case ERROR_FILE_NOT_FOUND:
|
||||
{
|
||||
// NOTE(PS): The outer scope should handle these cases
|
||||
ComPortHandle = INVALID_HANDLE_VALUE;
|
||||
}break;
|
||||
|
||||
InvalidDefaultCase;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ComPortHandle;
|
||||
|
|
|
@ -173,7 +173,7 @@ BlumenLumen_CustomInit(app_state* State, context Context)
|
|||
BLState->MicListenJobData.OutgoingMsgQueue = &BLState->OutgoingMsgQueue;
|
||||
BLState->MicListenJobData.ListenSocket = CreateSocket(Context.SocketManager, "127.0.0.1", "20185");
|
||||
|
||||
#if 1
|
||||
#if 0
|
||||
BLState->MicListenThread = CreateThread(Context.ThreadManager, BlumenLumen_MicListenJob, (u8*)&BLState->MicListenJobData);
|
||||
#endif
|
||||
|
||||
|
@ -213,7 +213,7 @@ BlumenLumen_CustomInit(app_state* State, context Context)
|
|||
Anim2.PlayableRange.Max = SecondsToFrames(15, State->AnimationSystem);
|
||||
Animation_AddLayer(&Anim2, MakeString("Base Layer"), BlendMode_Overwrite, &State->AnimationSystem);
|
||||
|
||||
Animation_AddBlock(&Anim2, 0, Anim0.PlayableRange.Max, Patterns_IndexToHandle(17), 0);
|
||||
Animation_AddBlock(&Anim2, 0, Anim0.PlayableRange.Max, Patterns_IndexToHandle(16), 0);
|
||||
|
||||
BLState->AnimHandles[2] = AnimationArray_Push(&State->AnimationSystem.Animations, Anim2);
|
||||
|
||||
|
|
Loading…
Reference in New Issue