This commit is contained in:
Cameron Tacklind 2022-08-28 07:56:12 -07:00
commit 41a143b445
10 changed files with 303 additions and 183 deletions

Binary file not shown.

Binary file not shown.

View File

@ -10,7 +10,7 @@ inline u8*
PackB1(u8* ptr, u8 val) PackB1(u8* ptr, u8 val)
{ {
*ptr = val; *ptr = val;
return ptr + sizeof(val); return ptr + sizeof(val);
} }
//Unpacks a u8 from a known big endian buffer //Unpacks a u8 from a known big endian buffer
@ -25,7 +25,7 @@ inline u8*
PackL1(u8* ptr, u8 val) PackL1(u8* ptr, u8 val)
{ {
*ptr = val; *ptr = val;
return ptr + sizeof(val); return ptr + sizeof(val);
} }
//Unpacks a u8 from a known little endian buffer //Unpacks a u8 from a known little endian buffer
@ -39,19 +39,19 @@ UpackL1(const u8* ptr)
inline u16 inline u16
PackB2(u16 Value) PackB2(u16 Value)
{ {
u16 Result = 0; u16 Result = 0;
u8* Array = (u8*)&Result; u8* Array = (u8*)&Result;
Array[1] = (u8)(Value & 0xFF); Array[1] = (u8)(Value & 0xFF);
Array[0] = (u8)((Value & 0xFF00) >> 8); Array[0] = (u8)((Value & 0xFF00) >> 8);
return Result; return Result;
} }
inline u8* inline u8*
PackB2(u8* ptr, u16 val) PackB2(u8* ptr, u16 val)
{ {
ptr[1] = (u8)(val & 0xff); ptr[1] = (u8)(val & 0xff);
ptr[0] = (u8)((val & 0xff00) >> 8); ptr[0] = (u8)((val & 0xff00) >> 8);
return ptr + sizeof(val); return ptr + sizeof(val);
} }
//Unpacks a u16 from a known big endian buffer //Unpacks a u16 from a known big endian buffer
@ -66,7 +66,7 @@ inline u8*
PackL2(u8* ptr, u16 val) PackL2(u8* ptr, u16 val)
{ {
*((u16*)ptr) = val; *((u16*)ptr) = val;
return ptr + sizeof(val); return ptr + sizeof(val);
} }
//Unpacks a u16 from a known little endian buffer //Unpacks a u16 from a known little endian buffer
@ -84,7 +84,7 @@ PackB4(u8* ptr, u32 val)
ptr[2] = (u8)((val & 0xff00) >> 8); ptr[2] = (u8)((val & 0xff00) >> 8);
ptr[1] = (u8)((val & 0xff0000) >> 16); ptr[1] = (u8)((val & 0xff0000) >> 16);
ptr[0] = (u8)((val & 0xff000000) >> 24); ptr[0] = (u8)((val & 0xff000000) >> 24);
return ptr + sizeof(val); return ptr + sizeof(val);
} }
//Unpacks a u32 from a known big endian buffer //Unpacks a u32 from a known big endian buffer
@ -99,7 +99,7 @@ inline u8*
PackL4(u8* ptr, u32 val) PackL4(u8* ptr, u32 val)
{ {
*((u32*)ptr) = val; *((u32*)ptr) = val;
return ptr + sizeof(val); return ptr + sizeof(val);
} }
//Unpacks a u32 from a known little endian buffer //Unpacks a u32 from a known little endian buffer
@ -121,7 +121,7 @@ PackB8(u8* ptr, u64 val)
ptr[2] = (u8)((val & 0xff0000000000) >> 40); ptr[2] = (u8)((val & 0xff0000000000) >> 40);
ptr[1] = (u8)((val & 0xff000000000000) >> 48); ptr[1] = (u8)((val & 0xff000000000000) >> 48);
ptr[0] = (u8)((val & 0xff00000000000000) >> 56); ptr[0] = (u8)((val & 0xff00000000000000) >> 56);
return ptr + sizeof(val); return ptr + sizeof(val);
} }
//Unpacks a uint64 from a known big endian buffer //Unpacks a uint64 from a known big endian buffer
@ -129,9 +129,9 @@ inline u64
UpackB8(const u8* ptr) UpackB8(const u8* ptr)
{ {
return ((u64)ptr[7]) | (((u64)ptr[6]) << 8) | (((u64)ptr[5]) << 16) | return ((u64)ptr[7]) | (((u64)ptr[6]) << 8) | (((u64)ptr[5]) << 16) |
(((u64)ptr[4]) << 24) | (((u64)ptr[3]) << 32) | (((u64)ptr[4]) << 24) | (((u64)ptr[3]) << 32) |
(((u64)ptr[2]) << 40) | (((u64)ptr[1]) << 48) | (((u64)ptr[2]) << 40) | (((u64)ptr[1]) << 48) |
(((u64)ptr[0]) << 56); (((u64)ptr[0]) << 56);
} }
//Packs a u64 to a known little endian buffer //Packs a u64 to a known little endian buffer
@ -139,7 +139,7 @@ inline u8*
PackL8(u8* ptr, u64 val) PackL8(u8* ptr, u64 val)
{ {
*((u64*)ptr) = val; *((u64*)ptr) = val;
return ptr + sizeof(val); return ptr + sizeof(val);
} }
//Unpacks a u64 from a known little endian buffer //Unpacks a u64 from a known little endian buffer

View File

@ -86,11 +86,11 @@ assembly_add_strip(Assembly_Array* a, Assembly_Handle h, u32 pixels_cap)
void void
assembly_add_led( assembly_add_led(
Assembly_Array* a, Assembly_Array* a,
Assembly_Handle h, Assembly_Handle h,
Assembly_Strip* strip, Assembly_Strip* strip,
v4 position v4 position
){ ){
u32 index = assembly_handle_to_index(h); u32 index = assembly_handle_to_index(h);
Assembly_Pixel_Buffer* pixel_buffer = a->pixel_buffers + index; Assembly_Pixel_Buffer* pixel_buffer = a->pixel_buffers + index;
@ -106,7 +106,7 @@ assembly_add_led(
void void
assembly_strip_create_leds( assembly_strip_create_leds(
Assembly_Array* a, Assembly_Array* a,
Assembly_Handle h, Assembly_Handle h,
Assembly_Strip* strip, Assembly_Strip* strip,
v3 start, v3 end, v3 start, v3 end,

View File

@ -119,7 +119,7 @@ u8*
PackB1(u8* ptr, u8 val) PackB1(u8* ptr, u8 val)
{ {
*ptr = val; *ptr = val;
return ptr + sizeof(val); return ptr + sizeof(val);
} }
//Unpacks a u8 from a known big endian buffer //Unpacks a u8 from a known big endian buffer
@ -134,7 +134,7 @@ u8*
PackL1(u8* ptr, u8 val) PackL1(u8* ptr, u8 val)
{ {
*ptr = val; *ptr = val;
return ptr + sizeof(val); return ptr + sizeof(val);
} }
//Unpacks a u8 from a known little endian buffer //Unpacks a u8 from a known little endian buffer
@ -147,9 +147,9 @@ UpackL1(const u8* ptr)
u8* u8*
PackB2(u8* ptr, u16 val) PackB2(u8* ptr, u16 val)
{ {
ptr[1] = (u8)(val & 0xff); ptr[1] = (u8)(val & 0xff);
ptr[0] = (u8)((val & 0xff00) >> 8); ptr[0] = (u8)((val & 0xff00) >> 8);
return ptr + sizeof(val); return ptr + sizeof(val);
} }
//Unpacks a u16 from a known big endian buffer //Unpacks a u16 from a known big endian buffer
@ -170,13 +170,6 @@ PackB4(u8* ptr, u32 val)
return ptr + sizeof(val); return ptr + sizeof(val);
} }
//Unpacks a u32 from a known big endian buffer
u32
UpackB4(u8* ptr)
{
return (u32)(ptr[3] | (ptr[2] << 8) | (ptr[1] << 16) | (ptr[0] << 24));
}
internal void internal void
VHD_PackFlags_(u8* Buffer, b32 InheritVec, b32 InheritHead, b32 InheritData) VHD_PackFlags_(u8* Buffer, b32 InheritVec, b32 InheritHead, b32 InheritData)
{ {
@ -234,15 +227,15 @@ VHD_PackLength_(u8* Buffer, u32 Length, b32 IncludeLength)
internal void internal void
InitStreamHeader (u8* Buffer, s32 BufferSize, InitStreamHeader (u8* Buffer, s32 BufferSize,
u16 SlotCount, u16 SlotCount,
u8 StartCode, u8 StartCode,
u16 Universe, u16 Universe,
u8 Priority, u8 Priority,
u16 Reserved, u16 Reserved,
u8 Options, u8 Options,
const char* SourceName, const char* SourceName,
Sacn_Cid CID Sacn_Cid CID
) )
{ {
// TODO(pjs): Replace packing with gs_memory_cursor // TODO(pjs): Replace packing with gs_memory_cursor
@ -258,8 +251,8 @@ InitStreamHeader (u8* Buffer, s32 BufferSize,
// TODO(Peter): If you never use this anywhere else, go back and remove the parameters // TODO(Peter): If you never use this anywhere else, go back and remove the parameters
VHD_PackFlags_(Cursor, false, false, false); VHD_PackFlags_(Cursor, false, false, false);
Cursor = VHD_PackLength_(Cursor, Cursor = VHD_PackLength_(Cursor,
SACN_BUFFER_HEADER_SIZE - SACN_RLP_PREAMBLE_SIZE + SlotCount, SACN_BUFFER_HEADER_SIZE - SACN_RLP_PREAMBLE_SIZE + SlotCount,
false); false);
// root vector // root vector
Cursor = PackB4(Cursor, SACN_ROOT_VECTOR); // 22 Cursor = PackB4(Cursor, SACN_ROOT_VECTOR); // 22
@ -272,8 +265,8 @@ InitStreamHeader (u8* Buffer, s32 BufferSize,
VHD_PackFlags_(Cursor, false, false, false); VHD_PackFlags_(Cursor, false, false, false);
Cursor = VHD_PackLength_(Cursor, Cursor = VHD_PackLength_(Cursor,
SACN_BUFFER_HEADER_SIZE - SACN_FRAMING_FLAGS_AND_LEN_ADDR + SlotCount, SACN_BUFFER_HEADER_SIZE - SACN_FRAMING_FLAGS_AND_LEN_ADDR + SlotCount,
false); false);
// 40 // 40
// framing vector // framing vector
Cursor = PackB4(Cursor, SACN_FRAMING_VECTOR); Cursor = PackB4(Cursor, SACN_FRAMING_VECTOR);
@ -302,8 +295,8 @@ InitStreamHeader (u8* Buffer, s32 BufferSize,
VHD_PackFlags_(Cursor, false, false, false); VHD_PackFlags_(Cursor, false, false, false);
Cursor = VHD_PackLength_(Cursor, Cursor = VHD_PackLength_(Cursor,
SACN_BUFFER_HEADER_SIZE - SACN_DMP_FLAGS_AND_LEN_ADDR + SlotCount, SACN_BUFFER_HEADER_SIZE - SACN_DMP_FLAGS_AND_LEN_ADDR + SlotCount,
false); // 117 false); // 117
// DMP Vector // DMP Vector
Cursor = PackB1(Cursor, SACN_DMP_VECTOR); Cursor = PackB1(Cursor, SACN_DMP_VECTOR);
@ -402,6 +395,13 @@ sacn_string_to_cid(String str)
return (Sacn_Cid){}; return (Sacn_Cid){};
} }
//Unpacks a u32 from a known big endian buffer
inline u32
UpackB4(const u8* ptr)
{
return (u32)(ptr[3] | (ptr[2] << 8) | (ptr[1] << 16) | (ptr[0] << 24));
}
internal u32 internal u32
sacn_universe_to_send_addr(u32 universe) sacn_universe_to_send_addr(u32 universe)
{ {
@ -409,10 +409,13 @@ sacn_universe_to_send_addr(u32 universe)
multicast_address_buffer[0] = 239; multicast_address_buffer[0] = 239;
multicast_address_buffer[1] = 255; multicast_address_buffer[1] = 255;
multicast_address_buffer[2] = (u8)((universe & 0xff00) >> 8); // high bit multicast_address_buffer[2] = (u8)((universe & 0xff00) >> 8); // high bit
multicast_address_buffer[3] = (u8)((universe & 0x00ff)); // low bit multicast_address_buffer[3] = (u8)((universe & 0x00ff)); // low bit
u32 v4_addr = (u32)UpackB4(multicast_address_buffer); u32 v4_address = (u32)((multicast_address_buffer[3] ) |
return v4_addr; (multicast_address_buffer[2] << 8) |
(multicast_address_buffer[1] << 16) |
(multicast_address_buffer[0] << 24));
return v4_address;
} }
internal u8* internal u8*
@ -429,14 +432,12 @@ output_network_sacn_init()
s32 ttl = 20; s32 ttl = 20;
result->socket = os_socket_create(AF_INET, SOCK_DGRAM, 0); result->socket = os_socket_create(AF_INET, SOCK_DGRAM, 0);
os_socket_set_opt( os_socket_set_opt(
result->socket, result->socket,
IPPROTO_IP, IPPROTO_IP,
IP_MULTICAST_TTL, IP_MULTICAST_TTL,
(u8*)&ttl, sizeof(ttl) (u8*)&ttl, sizeof(ttl)
); );
printf("Registered SACN Socket\n");
return (u8*)result; return (u8*)result;
} }

View File

@ -170,52 +170,52 @@ pm_random_v2_to_r32(v2 n)
internal r32 internal r32
pm_noise_v3_to_r32(v3 p) pm_noise_v3_to_r32(v3 p)
{ {
p = pm_abs_v3(p); p = pm_abs_v3(p);
v3 p_fl = pm_floor_v3(p); v3 p_fl = pm_floor_v3(p);
v3 p_fr = pm_fract_v3(p); v3 p_fr = pm_fract_v3(p);
v3 f = pm_smoothstep_v3(p_fr); v3 f = pm_smoothstep_v3(p_fr);
v3 p_fl_0 = p_fl; v3 p_fl_0 = p_fl;
v3 p_fl_1 = HMM_AddVec3(p_fl, (v3){1, 0, 0}); v3 p_fl_1 = HMM_AddVec3(p_fl, (v3){1, 0, 0});
v3 p_fl_2 = HMM_AddVec3(p_fl, (v3){0, 1, 0}); v3 p_fl_2 = HMM_AddVec3(p_fl, (v3){0, 1, 0});
v3 p_fl_3 = HMM_AddVec3(p_fl, (v3){1, 1, 0}); v3 p_fl_3 = HMM_AddVec3(p_fl, (v3){1, 1, 0});
v3 p_fl_4 = HMM_AddVec3(p_fl, (v3){0, 0, 1}); v3 p_fl_4 = HMM_AddVec3(p_fl, (v3){0, 0, 1});
v3 p_fl_5 = HMM_AddVec3(p_fl, (v3){1, 0, 1}); v3 p_fl_5 = HMM_AddVec3(p_fl, (v3){1, 0, 1});
v3 p_fl_6 = HMM_AddVec3(p_fl, (v3){0, 1, 1}); v3 p_fl_6 = HMM_AddVec3(p_fl, (v3){0, 1, 1});
v3 p_fl_7 = HMM_AddVec3(p_fl, (v3){1, 1, 1}); v3 p_fl_7 = HMM_AddVec3(p_fl, (v3){1, 1, 1});
r32 h0 = pm_hash_v3_to_r32(p_fl_0); r32 h0 = pm_hash_v3_to_r32(p_fl_0);
r32 h1 = pm_hash_v3_to_r32(p_fl_1); r32 h1 = pm_hash_v3_to_r32(p_fl_1);
r32 h2 = pm_hash_v3_to_r32(p_fl_2); r32 h2 = pm_hash_v3_to_r32(p_fl_2);
r32 h3 = pm_hash_v3_to_r32(p_fl_3); r32 h3 = pm_hash_v3_to_r32(p_fl_3);
r32 h4 = pm_hash_v3_to_r32(p_fl_4); r32 h4 = pm_hash_v3_to_r32(p_fl_4);
r32 h5 = pm_hash_v3_to_r32(p_fl_5); r32 h5 = pm_hash_v3_to_r32(p_fl_5);
r32 h6 = pm_hash_v3_to_r32(p_fl_6); r32 h6 = pm_hash_v3_to_r32(p_fl_6);
r32 h7 = pm_hash_v3_to_r32(p_fl_7); r32 h7 = pm_hash_v3_to_r32(p_fl_7);
r32 h0_1 = lerp(h0, f.x, h1); r32 h0_1 = lerp(h0, f.x, h1);
r32 h2_3 = lerp(h2, f.x, h3); r32 h2_3 = lerp(h2, f.x, h3);
r32 h4_5 = lerp(h4, f.x, h5); r32 h4_5 = lerp(h4, f.x, h5);
r32 h6_7 = lerp(h6, f.x, h7); r32 h6_7 = lerp(h6, f.x, h7);
r32 h01_23 = lerp(h0_1, f.y, h2_3); r32 h01_23 = lerp(h0_1, f.y, h2_3);
r32 h45_67 = lerp(h4_5, f.y, h6_7); r32 h45_67 = lerp(h4_5, f.y, h6_7);
// r32 result = lerp( // r32 result = lerp(
// lerp( // lerp(
// lerp(h0, f.x, h1), // lerp(h0, f.x, h1),
// f.y, // f.y,
// lerp(h2, f.x, h3) // lerp(h2, f.x, h3)
// ), // ),
// f.z, // f.z,
// lerp( // lerp(
// lerp(h4, f.x, h5), // lerp(h4, f.x, h5),
// f.y, // f.y,
// lerp(h6, f.x, h7) // lerp(h6, f.x, h7)
// ) // )
// ); // );
r32 result = lerp(h01_23, f.z, h45_67); r32 result = lerp(h01_23, f.z, h45_67);
assert(result >= 0 && result <= 1); assert(result >= 0 && result <= 1);
return result; return result;
} }
r32 r32
@ -326,6 +326,7 @@ color_ramp_reverse(Color_Ramp ramp)
v3 v3
color_ramp_eval(Color_Ramp ramp, r32 pct) color_ramp_eval(Color_Ramp ramp, r32 pct)
{ {
pct = clamp(0, pct, 1);
// find nearest two anchors // find nearest two anchors
// TODO: do a binary search and we just have to assume that the anchors // TODO: do a binary search and we just have to assume that the anchors
// are in order from least to greatest // are in order from least to greatest

View File

@ -1,6 +1,7 @@
// NOTE: This file is autogenerated by csv_to_cstruct.js // NOTE: This file is autogenerated by csv_to_cstruct.js
// NOTE: These are values for Incenter_City_Id // NOTE: These are values for Incenter_City_Id
enum { enum {
city_black_rock = 0, city_black_rock = 0,
city_bucharest = 1, city_bucharest = 1,
city_brisbane = 2, city_brisbane = 2,
@ -281,283 +282,283 @@ global Incenter_City_Desc city_descs[] = {
.id = city_bucharest, .id = city_bucharest,
.lat = 44.4, .lat = 44.4,
.lon = 26.0833, .lon = 26.0833,
.sacn_universe = city_bucharest, .sacn_universe = 165,
}, },
[city_brisbane] = { [city_brisbane] = {
.id = city_brisbane, .id = city_brisbane,
.lat = -27.4678, .lat = -27.4678,
.lon = 153.0281, .lon = 153.0281,
.sacn_universe = city_brisbane, .sacn_universe = 61,
}, },
[city_chengdu] = { [city_chengdu] = {
.id = city_chengdu, .id = city_chengdu,
.lat = 30.66, .lat = 30.66,
.lon = 104.0633, .lon = 104.0633,
.sacn_universe = city_chengdu, .sacn_universe = 35,
}, },
[city_new_delhi] = { [city_new_delhi] = {
.id = city_new_delhi, .id = city_new_delhi,
.lat = 28.6139, .lat = 28.6139,
.lon = 77.209, .lon = 77.209,
.sacn_universe = city_new_delhi, .sacn_universe = 41,
}, },
[city_paris] = { [city_paris] = {
.id = city_paris, .id = city_paris,
.lat = 48.8566, .lat = 48.8566,
.lon = 2.3522, .lon = 2.3522,
.sacn_universe = city_paris, .sacn_universe = 189,
}, },
[city_san_francisco] = { [city_san_francisco] = {
.id = city_san_francisco, .id = city_san_francisco,
.lat = 37.7562, .lat = 37.7562,
.lon = -122.443, .lon = -122.443,
.sacn_universe = city_san_francisco, .sacn_universe = 21,
}, },
[city_denver] = { [city_denver] = {
.id = city_denver, .id = city_denver,
.lat = 39.7621, .lat = 39.7621,
.lon = -104.8759, .lon = -104.8759,
.sacn_universe = city_denver, .sacn_universe = 7,
}, },
[city_ankara] = { [city_ankara] = {
.id = city_ankara, .id = city_ankara,
.lat = 39.93, .lat = 39.93,
.lon = 32.85, .lon = 32.85,
.sacn_universe = city_ankara, .sacn_universe = 203,
}, },
[city_harare] = { [city_harare] = {
.id = city_harare, .id = city_harare,
.lat = -17.8292, .lat = -17.8292,
.lon = 31.0522, .lon = 31.0522,
.sacn_universe = city_harare, .sacn_universe = 213,
}, },
[city_hanoi] = { [city_hanoi] = {
.id = city_hanoi, .id = city_hanoi,
.lat = 21.0245, .lat = 21.0245,
.lon = 105.8412, .lon = 105.8412,
.sacn_universe = city_hanoi, .sacn_universe = 33,
}, },
[city_washington] = { [city_washington] = {
.id = city_washington, .id = city_washington,
.lat = 38.9047, .lat = 38.9047,
.lon = -77.0163, .lon = -77.0163,
.sacn_universe = city_washington, .sacn_universe = 3,
}, },
[city_bangkok] = { [city_bangkok] = {
.id = city_bangkok, .id = city_bangkok,
.lat = 13.75, .lat = 13.75,
.lon = 100.5167, .lon = 100.5167,
.sacn_universe = city_bangkok, .sacn_universe = 39,
}, },
[city_tunis] = { [city_tunis] = {
.id = city_tunis, .id = city_tunis,
.lat = 36.8008, .lat = 36.8008,
.lon = 10.18, .lon = 10.18,
.sacn_universe = city_tunis, .sacn_universe = 167,
}, },
[city_seoul] = { [city_seoul] = {
.id = city_seoul, .id = city_seoul,
.lat = 37.56, .lat = 37.56,
.lon = 126.99, .lon = 126.99,
.sacn_universe = city_seoul, .sacn_universe = 57,
}, },
[city_belgrade] = { [city_belgrade] = {
.id = city_belgrade, .id = city_belgrade,
.lat = 44.8167, .lat = 44.8167,
.lon = 20.4667, .lon = 20.4667,
.sacn_universe = city_belgrade, .sacn_universe = 171,
}, },
[city_moscow] = { [city_moscow] = {
.id = city_moscow, .id = city_moscow,
.lat = 55.7558, .lat = 55.7558,
.lon = 37.6178, .lon = 37.6178,
.sacn_universe = city_moscow, .sacn_universe = 197,
}, },
[city_lima] = { [city_lima] = {
.id = city_lima, .id = city_lima,
.lat = -12.06, .lat = -12.06,
.lon = -77.0375, .lon = -77.0375,
.sacn_universe = city_lima, .sacn_universe = 19,
}, },
[city_islamabad] = { [city_islamabad] = {
.id = city_islamabad, .id = city_islamabad,
.lat = 33.6989, .lat = 33.6989,
.lon = 73.0369, .lon = 73.0369,
.sacn_universe = city_islamabad, .sacn_universe = 223,
}, },
[city_abuja] = { [city_abuja] = {
.id = city_abuja, .id = city_abuja,
.lat = 9.0556, .lat = 9.0556,
.lon = 7.4914, .lon = 7.4914,
.sacn_universe = city_abuja, .sacn_universe = 183,
}, },
[city_managua] = { [city_managua] = {
.id = city_managua, .id = city_managua,
.lat = 12.15, .lat = 12.15,
.lon = -86.2667, .lon = -86.2667,
.sacn_universe = city_managua, .sacn_universe = 5,
}, },
[city_amsterdam] = { [city_amsterdam] = {
.id = city_amsterdam, .id = city_amsterdam,
.lat = 52.3667, .lat = 52.3667,
.lon = 4.8833, .lon = 4.8833,
.sacn_universe = city_amsterdam, .sacn_universe = 191,
}, },
[city_rabat] = { [city_rabat] = {
.id = city_rabat, .id = city_rabat,
.lat = 34.0253, .lat = 34.0253,
.lon = -6.8361, .lon = -6.8361,
.sacn_universe = city_rabat, .sacn_universe = 187,
}, },
[city_ulaanbaatar] = { [city_ulaanbaatar] = {
.id = city_ulaanbaatar, .id = city_ulaanbaatar,
.lat = 47.9214, .lat = 47.9214,
.lon = 106.9055, .lon = 106.9055,
.sacn_universe = city_ulaanbaatar, .sacn_universe = 53,
}, },
[city_mexico_city] = { [city_mexico_city] = {
.id = city_mexico_city, .id = city_mexico_city,
.lat = 19.4333, .lat = 19.4333,
.lon = -99.1333, .lon = -99.1333,
.sacn_universe = city_mexico_city, .sacn_universe = 9,
}, },
[city_nairobi] = { [city_nairobi] = {
.id = city_nairobi, .id = city_nairobi,
.lat = -1.2864, .lat = -1.2864,
.lon = 36.8172, .lon = 36.8172,
.sacn_universe = city_nairobi, .sacn_universe = 219,
}, },
[city_tokyo] = { [city_tokyo] = {
.id = city_tokyo, .id = city_tokyo,
.lat = 35.6839, .lat = 35.6839,
.lon = 139.7744, .lon = 139.7744,
.sacn_universe = city_tokyo, .sacn_universe = 59,
}, },
[city_baghdad] = { [city_baghdad] = {
.id = city_baghdad, .id = city_baghdad,
.lat = 33.35, .lat = 33.35,
.lon = 44.4167, .lon = 44.4167,
.sacn_universe = city_baghdad, .sacn_universe = 195,
}, },
[city_tehran] = { [city_tehran] = {
.id = city_tehran, .id = city_tehran,
.lat = 35.7, .lat = 35.7,
.lon = 51.4167, .lon = 51.4167,
.sacn_universe = city_tehran, .sacn_universe = 205,
}, },
[city_jakarta] = { [city_jakarta] = {
.id = city_jakarta, .id = city_jakarta,
.lat = -6.2146, .lat = -6.2146,
.lon = 106.8451, .lon = 106.8451,
.sacn_universe = city_jakarta, .sacn_universe = 63,
}, },
[city_guatemala_city] = { [city_guatemala_city] = {
.id = city_guatemala_city, .id = city_guatemala_city,
.lat = 14.6099, .lat = 14.6099,
.lon = -90.5252, .lon = -90.5252,
.sacn_universe = city_guatemala_city, .sacn_universe = 13,
}, },
[city_berlin] = { [city_berlin] = {
.id = city_berlin, .id = city_berlin,
.lat = 52.5167, .lat = 52.5167,
.lon = 13.3833, .lon = 13.3833,
.sacn_universe = city_berlin, .sacn_universe = 169,
}, },
[city_addis_ababa] = { [city_addis_ababa] = {
.id = city_addis_ababa, .id = city_addis_ababa,
.lat = 9.0272, .lat = 9.0272,
.lon = 38.7369, .lon = 38.7369,
.sacn_universe = city_addis_ababa, .sacn_universe = 201,
}, },
[city_cairo] = { [city_cairo] = {
.id = city_cairo, .id = city_cairo,
.lat = 30.0444, .lat = 30.0444,
.lon = 31.2358, .lon = 31.2358,
.sacn_universe = city_cairo, .sacn_universe = 163,
}, },
[city_quito] = { [city_quito] = {
.id = city_quito, .id = city_quito,
.lat = -0.22, .lat = -0.22,
.lon = -78.5125, .lon = -78.5125,
.sacn_universe = city_quito, .sacn_universe = 23,
}, },
[city_bogota] = { [city_bogota] = {
.id = city_bogota, .id = city_bogota,
.lat = 4.6126, .lat = 4.6126,
.lon = -74.0705, .lon = -74.0705,
.sacn_universe = city_bogota, .sacn_universe = 25,
}, },
[city_beijing] = { [city_beijing] = {
.id = city_beijing, .id = city_beijing,
.lat = 39.904, .lat = 39.904,
.lon = 116.4075, .lon = 116.4075,
.sacn_universe = city_beijing, .sacn_universe = 55,
}, },
[city_accra] = { [city_accra] = {
.id = city_accra, .id = city_accra,
.lat = 5.6037, .lat = 5.6037,
.lon = -0.187, .lon = -0.187,
.sacn_universe = city_accra, .sacn_universe = 161,
}, },
[city_ottawa] = { [city_ottawa] = {
.id = city_ottawa, .id = city_ottawa,
.lat = 45.4247, .lat = 45.4247,
.lon = -75.695, .lon = -75.695,
.sacn_universe = city_ottawa, .sacn_universe = 31,
}, },
[city_brasilia] = { [city_brasilia] = {
.id = city_brasilia, .id = city_brasilia,
.lat = -15.7939, .lat = -15.7939,
.lon = -47.8828, .lon = -47.8828,
.sacn_universe = city_brasilia, .sacn_universe = 181,
}, },
[city_la_paz] = { [city_la_paz] = {
.id = city_la_paz, .id = city_la_paz,
.lat = -16.4942, .lat = -16.4942,
.lon = -68.1475, .lon = -68.1475,
.sacn_universe = city_la_paz, .sacn_universe = 27,
}, },
[city_dhaka] = { [city_dhaka] = {
.id = city_dhaka, .id = city_dhaka,
.lat = 23.7289, .lat = 23.7289,
.lon = 90.3944, .lon = 90.3944,
.sacn_universe = city_dhaka, .sacn_universe = 43,
}, },
[city_yerevan] = { [city_yerevan] = {
.id = city_yerevan, .id = city_yerevan,
.lat = 40.1814, .lat = 40.1814,
.lon = 44.5144, .lon = 44.5144,
.sacn_universe = city_yerevan, .sacn_universe = 211,
}, },
[city_chicago] = { [city_chicago] = {
.id = city_chicago, .id = city_chicago,
.lat = 41.8373, .lat = 41.8373,
.lon = -87.6862, .lon = -87.6862,
.sacn_universe = city_chicago, .sacn_universe = 11,
}, },
[city_kyiv] = { [city_kyiv] = {
.id = city_kyiv, .id = city_kyiv,
.lat = 50.45, .lat = 50.45,
.lon = 30.5236, .lon = 30.5236,
.sacn_universe = city_kyiv, .sacn_universe = 199,
}, },
[city_dubai] = { [city_dubai] = {
.id = city_dubai, .id = city_dubai,
.lat = 25.2697, .lat = 25.2697,
.lon = 55.3094, .lon = 55.3094,
.sacn_universe = city_dubai, .sacn_universe = 193,
}, },
[city_mumbai] = { [city_mumbai] = {
.id = city_mumbai, .id = city_mumbai,
.lat = 19.0758, .lat = 19.0758,
.lon = 72.8775, .lon = 72.8775,
.sacn_universe = city_mumbai, .sacn_universe = 217,
}, },
[city_madrid] = { [city_madrid] = {
.id = city_madrid, .id = city_madrid,
.lat = 40.4167, .lat = 40.4167,
.lon = -3.7167, .lon = -3.7167,
.sacn_universe = city_madrid, .sacn_universe = 185,
}, },
// Black Rock City // Black Rock City

View File

@ -576,9 +576,8 @@ global Color_Ramp cities_ramp = {
global Color_Ramp cities_sparkle_ramp = { global Color_Ramp cities_sparkle_ramp = {
.anchors = { .anchors = {
[0] = { .pct = 0, .color = { 0, 0, 0 } }, [0] = { .pct = 0, .color = { 0, 0, 0 } },
[1] = { .pct = .2f, .color = { 0, 0, 0 } }, [1] = { .pct = .7f, .color = { 0, 0, 0 } },
[2] = { .pct = .5f, .color = { 255.f / 255.f, 194.f / 255.f, 86.f / 255.5 } }, [2] = { .pct = .1f, .color = { 255.f / 255.f, 100.f / 255.f, 40.f / 255.5 } },
[3] = { .pct = 1, .color = { 1, 1, 1 } },
}, },
.anchors_count = 3 .anchors_count = 3
}; };
@ -897,18 +896,26 @@ pattern_fast_noise_test(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strip
void void
secondary_pattern_twinkle(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Incenter_State* ins) secondary_pattern_twinkle(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, Incenter_State* ins)
{ {
Assembly_Strip strip = strips.strips[city_secondary_first]; for (u32 i = 0; i < secondary_strips_len; i++) {
for (u32 led = 0; led < strip.pixels_len; led++) Assembly_Strip* strip = secondary_city_strips[i];
{ for (u32 led = 0; led < strip->pixels_len; led++)
u32 led_index = strip.pixels[led]; {
v4 p = pixels.positions[led_index]; u32 led_index = strip->pixels[led];
v4 p_unit = incenter_pos_to_unit(p); v4 p = pixels.positions[led_index];
v3 p_offset = HMM_AddVec3(p.xyz, (v3){ 213.145f, 99.321f, 71.3f }); v4 p_unit = incenter_pos_to_unit(p);
v3 p_scaled = HMM_MultiplyVec3f(p_offset, 2); v3 p_offset = HMM_AddVec3(p.xyz, (v3){ 213.145f, 99.321f, 71.3f });
r32 v = pm_fmb_3d(p_scaled, ins->scene_time); v3 p_scaled = HMM_MultiplyVec3f(p_offset, 2);
r32 vv = pm_smoothstep_r32(v); r32 v = pm_fmb_3d(p_scaled, ins->scene_time);
v3 color = color_ramp_eval(cities_sparkle_ramp, vv); r32 vv = (2 * pm_smoothstep_r32(v)) - 1;
pixels.pixels[led_index] = color_v3_to_assembly_pixel(color);
#define TESTING_LEDS 0
#if !TESTING_LEDS
v3 color = color_ramp_eval(cities_sparkle_ramp, vv);
pixels.pixels[led_index] = color_v3_to_assembly_pixel(color);
#else
pixels.pixels[led_index] = color_v3_to_assembly_pixel((v3){1, 0, 0});
#endif
}
} }
} }
@ -943,7 +950,12 @@ pattern_sun_passive(Assembly_Pixel_Buffer pixels, Assembly_Strip_Array strips, I
v4 pos = pixels.positions[j]; v4 pos = pixels.positions[j];
v4 p = incenter_pos_to_unit(pos); v4 p = incenter_pos_to_unit(pos);
r32 r2 = HMM_LengthSquaredVec3(pos.xyz); r32 r2 = HMM_LengthSquaredVec3(pos.xyz);
#if !TESTING_LEDS
pixels.pixels[j] = sun(pos.xyz, r2, (Assembly_Pixel){0, 0, 0}, st); pixels.pixels[j] = sun(pos.xyz, r2, (Assembly_Pixel){0, 0, 0}, st);
#else
pixels.pixels[j] = color_v3_to_assembly_pixel((v3){0, 0, 1});
#endif
} }
secondary_pattern_twinkle(pixels, strips, ins); secondary_pattern_twinkle(pixels, strips, ins);

View File

@ -1,4 +1,8 @@
#define SECONDARY_CITY_CAP 32
u32 secondary_strips_len = 0;
Assembly_Strip* secondary_city_strips[SECONDARY_CITY_CAP];
#include "../user_space/incenter_patterns.c" #include "../user_space/incenter_patterns.c"
#include "../user_space/incenter_secondary_patterns.c" #include "../user_space/incenter_secondary_patterns.c"
#include "incenter_scenes.h" #include "incenter_scenes.h"
@ -13,7 +17,8 @@ incenter_scenes_init(Incenter_State* ins, u32 cap, Allocator* a)
incenter_scene_descs_init(); incenter_scene_descs_init();
ins->scenes = incenter_scene_descs; ins->scenes = incenter_scene_descs;
ins->scenes_cap = Incenter_Scene_Count; ins->scenes_cap = Incenter_Scene_Count;
ins->scene_at = Incenter_Scene_Question_LostAccessToResources; ins->scene_at = Incenter_Scene_AnyoneHome;
//Incenter_Scene_Question_LostAccessToResources;
} }
internal void internal void
@ -105,6 +110,27 @@ incenter_get_init_desc()
return result; return result;
} }
#define INCENTER_RADIUS INCENTER_FEET(10)
internal Assembly_Strip*
incenter_add_secondary_city_strip(Assembly_Array* assemblies, Assembly_Handle ah, u32 universe, u32 count, Incenter_City_Id city)
{
Assembly_Strip* s = assembly_add_strip(assemblies, ah, count);
s->output_kind = OutputData_NetworkSACN;
s->sacn_universe = universe;
Incenter_City_Desc d = city_descs[city];
v4 city_p = incenter_latlng_to_cartesian(d.lat, d.lon, INCENTER_RADIUS);
v4 end_p = incenter_latlng_to_cartesian(d.lat, d.lon, INCENTER_RADIUS * 2);
for (u32 i = 0; i < count; i++)
{
v4 p = pm_lerp_v4(city_p, (r32)i / (r32)count, end_p);
assembly_add_led(assemblies, ah, s, p);
}
secondary_city_strips[secondary_strips_len++] = s;
return s;
}
internal void internal void
incenter_init(App_State* state) incenter_init(App_State* state)
{ {
@ -119,14 +145,15 @@ incenter_init(App_State* state)
u32 primary_city_lights = (city_count + 1) * lights_per_primary_city; u32 primary_city_lights = (city_count + 1) * lights_per_primary_city;
u32 secondary_city_count = (city_secondary_count - city_secondary_first) + 1; u32 secondary_city_count = (city_secondary_count - city_secondary_first) + 1;
u32 secondary_city_lights = secondary_city_count; u32 secondary_city_lights = secondary_city_count;
u32 lights_cap = primary_city_lights + secondary_city_lights; u32 lights_cap = primary_city_lights + 800;
Assembly_Handle ah = assembly_add(&state->assemblies, lit_str("incenter"), lights_cap, city_count + 2); Assembly_Handle ah = assembly_add(&state->assemblies, lit_str("incenter"), lights_cap, city_count + 50);
scratch_get(scratch); scratch_get(scratch);
Allocator* s = scratch.a; Allocator* s = scratch.a;
v3 start_p = (v3){0, 0, 0}; v3 start_p = (v3){0, 0, 0};
Assembly_Strip* vertical_strip = assembly_add_strip(&state->assemblies, ah, 123); Assembly_Strip* vertical_strip = assembly_add_strip(&state->assemblies, ah, 123);
assembly_strip_create_leds( assembly_strip_create_leds(
&state->assemblies, &state->assemblies,
@ -138,20 +165,97 @@ incenter_init(App_State* state)
); );
// ADDING PRIMARY CITIES // ADDING PRIMARY CITIES
r32 radius = INCENTER_FEET(10); r32 radius = INCENTER_RADIUS;
for (u32 i = 0; i < city_count; i++) for (u32 i = 0; i < city_count; i++)
{ {
Incenter_City_Desc city = city_descs[i]; Incenter_City_Desc city = city_descs[i];
if (city.sacn_universe == 0) {
printf("skipping %s\n", city_strings[i]);
continue;
}
v3 end_p = incenter_latlng_to_cartesian(city.lat, city.lon, radius).xyz; v3 end_p = incenter_latlng_to_cartesian(city.lat, city.lon, radius).xyz;
Assembly_Strip* strip = assembly_add_strip(&state->assemblies, ah, 123); Assembly_Strip* strip = assembly_add_strip(&state->assemblies, ah, 123);
strip->output_kind = OutputData_NetworkSACN; strip->output_kind = OutputData_NetworkSACN;
strip->sacn_universe = city.sacn_universe; strip->sacn_universe = city.sacn_universe;
assembly_strip_create_leds(&state->assemblies, ah, strip, start_p, end_p, 123); assembly_strip_create_leds(&state->assemblies, ah, strip, end_p, start_p, 88);
} }
#define USING_ON_PLAYA_SECONDARY_CITIES 1
#if USING_ON_PLAYA_SECONDARY_CITIES
// ADDING SECONDARY CITIES // ADDING SECONDARY CITIES
{
for (u32 i = 0; i < SECONDARY_CITY_CAP; i++) secondary_city_strips[i] = 0;
Assembly_Array* a = &state->assemblies;
{ // Australia
Assembly_Strip* aus_lef = incenter_add_secondary_city_strip(a, ah, 62, 10, city_brisbane);
Assembly_Strip* aus_rig = incenter_add_secondary_city_strip(a, ah, 64, 8, city_brisbane);
Assembly_Strip* aus_cen = incenter_add_secondary_city_strip(a, ah, 34, 6, city_brisbane);
}
{ // Islands Above Australia
Assembly_Strip* indonesia1 = incenter_add_secondary_city_strip(a, ah, 44, 9, city_jakarta);
Assembly_Strip* indonesia2 = incenter_add_secondary_city_strip(a, ah, 36, 9, city_jakarta);
Assembly_Strip* north_left_asia = incenter_add_secondary_city_strip(a, ah, 54, 6, city_tokyo);
Assembly_Strip* phillipines = incenter_add_secondary_city_strip(a, ah, 56, 10, city_jakarta);
}
{ // East Asia
// TODO(PS): update primary cities
Assembly_Strip* cen_china_to_thailand = incenter_add_secondary_city_strip(a, ah, 37, 19, city_jakarta);
Assembly_Strip* china_coast = incenter_add_secondary_city_strip(a, ah, 38, 29, city_jakarta);
Assembly_Strip* peninsula_below_china = incenter_add_secondary_city_strip(a, ah, 40, 10, city_jakarta);
Assembly_Strip* mainland_right_of_japan_north = incenter_add_secondary_city_strip(a, ah, 40, 10, city_tokyo);
Assembly_Strip* mainland_right_of_japan_south = incenter_add_secondary_city_strip(a, ah, 58, 9, city_tokyo);
}
{ // Japan
Assembly_Strip* japan = incenter_add_secondary_city_strip(a, ah, 60, 10, city_tokyo);
}
{
Assembly_Strip* rig_south_africa = incenter_add_secondary_city_strip(a, ah, 196, 9, city_nairobi);
Assembly_Strip* georgia = incenter_add_secondary_city_strip(a, ah, 198, 10, city_tokyo); // TODO(PS):
Assembly_Strip* ethiopia = incenter_add_secondary_city_strip(a, ah, 200, 5, city_addis_ababa);
Assembly_Strip* turkey = incenter_add_secondary_city_strip(a, ah, 202, 10, city_ankara);
Assembly_Strip* sudan_egypt = incenter_add_secondary_city_strip(a, ah, 204, 7, city_cairo);
Assembly_Strip* iran = incenter_add_secondary_city_strip(a, ah, 206, 9, city_tehran);
Assembly_Strip* west_russia = incenter_add_secondary_city_strip(a, ah, 208, 25, city_kyiv);
Assembly_Strip* saudi_arabia = incenter_add_secondary_city_strip(a, ah, 212, 4, city_ankara);
Assembly_Strip* south_africa = incenter_add_secondary_city_strip(a, ah, 214, 25, city_nairobi); // TODO(PS):
Assembly_Strip* right_india = incenter_add_secondary_city_strip(a, ah, 215, 19, city_mumbai);
Assembly_Strip* central_russia_right = incenter_add_secondary_city_strip(a, ah, 218, 7, city_kyiv);
Assembly_Strip* left_africa = incenter_add_secondary_city_strip(a, ah, 220, 7, city_nairobi);
Assembly_Strip* the_stans = incenter_add_secondary_city_strip(a, ah, 221, 19, city_tehran);
Assembly_Strip* left_india = incenter_add_secondary_city_strip(a, ah, 222, 40, city_mumbai);
}
{
Assembly_Strip* italy = incenter_add_secondary_city_strip(a, ah, 162, 9, city_paris);
Assembly_Strip* nigeria_cameroon = incenter_add_secondary_city_strip(a, ah, 164, 6, city_abuja);
Assembly_Strip* greece = incenter_add_secondary_city_strip(a, ah, 166, 9, city_belgrade);
Assembly_Strip* israel = incenter_add_secondary_city_strip(a, ah, 168, 6, city_cairo);
Assembly_Strip* central_europe = incenter_add_secondary_city_strip(a, ah, 170, 35, city_berlin);
Assembly_Strip* libya = incenter_add_secondary_city_strip(a, ah, 172, 9, city_tunis);
Assembly_Strip* peru = incenter_add_secondary_city_strip(a, ah, 182, 9, city_brasilia);
Assembly_Strip* right_north_africa = incenter_add_secondary_city_strip(a, ah, 184, 13, city_rabat);
Assembly_Strip* france = incenter_add_secondary_city_strip(a, ah, 188, 5, city_paris);
Assembly_Strip* uk = incenter_add_secondary_city_strip(a, ah, 190, 6, city_paris);
Assembly_Strip* scandanavia = incenter_add_secondary_city_strip(a, ah, 192, 5, city_berlin);
}
{
Assembly_Strip* us_east_coast = incenter_add_secondary_city_strip(a, ah, 1, 20, city_washington);
Assembly_Strip* central_americas = incenter_add_secondary_city_strip(a, ah, 2, 19, city_denver);
Assembly_Strip* colombia = incenter_add_secondary_city_strip(a, ah, 6, 9, city_bogota);
Assembly_Strip* missippi_river = incenter_add_secondary_city_strip(a, ah, 12, 9, city_washington);
Assembly_Strip* chile_south = incenter_add_secondary_city_strip(a, ah, 14, 9, city_la_paz);
Assembly_Strip* us_west_coast = incenter_add_secondary_city_strip(a, ah, 22, 17, city_san_francisco);
Assembly_Strip* venezuela = incenter_add_secondary_city_strip(a, ah, 26, 5, city_bogota);
Assembly_Strip* chile_north = incenter_add_secondary_city_strip(a, ah, 28, 10, city_la_paz);
Assembly_Strip* left_canada = incenter_add_secondary_city_strip(a, ah, 32, 5, city_san_francisco);
}
}
#else
// TODO: This probably isn't how these lights will be hooked up // TODO: This probably isn't how these lights will be hooked up
Assembly_Strip* secondary_strip = assembly_add_strip(&state->assemblies, ah, secondary_city_lights); Assembly_Strip* secondary_strip = assembly_add_strip(&state->assemblies, ah, secondary_city_lights);
secondary_strip->output_kind = OutputData_NetworkSACN; secondary_strip->output_kind = OutputData_NetworkSACN;
@ -162,6 +266,7 @@ incenter_init(App_State* state)
v4 light_p = incenter_latlng_to_cartesian(city.lat, city.lon, radius); v4 light_p = incenter_latlng_to_cartesian(city.lat, city.lon, radius);
assembly_add_led(&state->assemblies, ah, secondary_strip, light_p); assembly_add_led(&state->assemblies, ah, secondary_strip, light_p);
} }
#endif
// PATTERN INIT // PATTERN INIT
pattern_random_fill_prep(); pattern_random_fill_prep();
@ -215,7 +320,7 @@ incenter_frame(App_State* state)
incenter_interface_connection_frame(state, ins); incenter_interface_connection_frame(state, ins);
ins->scene_time += state->target_seconds_per_frame; ins->scene_time += state->target_seconds_per_frame * 0.2f;
ins->transition_time += state->target_seconds_per_frame; ins->transition_time += state->target_seconds_per_frame;
incenter_scene_render(state, ins); incenter_scene_render(state, ins);

View File

@ -46,7 +46,7 @@ struct Incenter_Data_Row
}; };
// TODO(PS): fix this to be the real universe // TODO(PS): fix this to be the real universe
#define incenter_secondary_city_universe 128 #define incenter_secondary_city_universe 33
#include "incenter_gen_cities.h" #include "incenter_gen_cities.h"
// Data // Data