From 803f5c82aea4f2f4ac353916f3afb97cfa337ac8 Mon Sep 17 00:00:00 2001 From: Peter Slattery Date: Thu, 19 Mar 2020 21:50:11 -0700 Subject: [PATCH] Updated gs_vector_matrix --- gs_libs/gs_vector_matrix.h | 119 +++++++++++++++++++++++++------------ todo.txt | 13 +--- 2 files changed, 83 insertions(+), 49 deletions(-) diff --git a/gs_libs/gs_vector_matrix.h b/gs_libs/gs_vector_matrix.h index 17167d9..a426543 100644 --- a/gs_libs/gs_vector_matrix.h +++ b/gs_libs/gs_vector_matrix.h @@ -906,44 +906,6 @@ Transpose (m44 M) return Result; } -static m44 -GetPositionM44 (v4 Position) -{ -#if 1 - return m44{ - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - Position.x, Position.y, Position.z, Position.w - }; -#else - return m44{ - 1, 0, 0, Position.x, - 0, 1, 0, Position.y, - 0, 0, 1, Position.z, - 0, 0, 0, Position.w}; -#endif -} - -static m44 -GetLookAtMatrix (v4 Position, v4 Target) -{ - // Forward - v4 Forward = Normalize(Target - Position); - // Right - v4 Right = Normalize(Cross(v4{0, 1, 0, 0}, Forward)); - // Up - v4 Up = Normalize(Cross(Forward, Right)); - - m44 RotationMatrix = M44( - Right.x, Up.x, Forward.x, 0, - Right.y, Up.y, Forward.y, 0, - Right.z, Up.z, Forward.z, 0, - 0, 0, 0, 1); - - return RotationMatrix; -} - b32 operator== (m33 A, m33 B) { b32 Result = true; @@ -1107,6 +1069,87 @@ v4 operator* (m44 M, v4 V) return Result; } +static m44 +Translate(m44 M, v3 Delta) +{ + m44 Result = M; + Result.E[12] += Delta.x; + Result.E[13] += Delta.y; + Result.E[14] += Delta.z; + return Result; +} + +static m44 +Rotate(m44 M, v3 Delta) +{ + m44 Result = M; + m44 X = GetXRotation(Delta.x); + m44 Y = GetYRotation(Delta.z); + m44 Z = GetZRotation(Delta.z); + Result = Z * Y * X * Result; + return Result; +} + +static m44 +GetPositionM44 (v4 Position) +{ +#if 1 + return m44{ + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + Position.x, Position.y, Position.z, Position.w + }; +#else + return m44{ + 1, 0, 0, Position.x, + 0, 1, 0, Position.y, + 0, 0, 1, Position.z, + 0, 0, 0, Position.w}; +#endif +} + +static m44 +GetModelViewMatrix (v4 Forward, v4 Right, v4 Up, v4 Position) +{ + m44 RotationMatrix = M44(Right.x, Up.x, Forward.x, 0, + Right.y, Up.y, Forward.y, 0, + Right.z, Up.z, Forward.z, 0, + 0, 0, 0, 1); + m44 PositionMatrix = M44(1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + -Position.x, -Position.y, -Position.z, 1); + m44 ModelViewMatrix = PositionMatrix * RotationMatrix; + return ModelViewMatrix; +} + +static m44 +GetModelViewMatrix (v4 Forward, v4 Right, v4 Position) +{ + v4 Up = Normalize(Cross(Forward, Right)); + return GetModelViewMatrix(Forward, Right, Up, Position); +} + +static m44 +GetLookAtMatrix (v4 Position, v4 Target) +{ + // Forward + v4 Forward = Normalize(Target - Position); + // Right + v4 Right = Normalize(Cross(v4{0, 1, 0, 0}, Forward)); + // Up + v4 Up = Normalize(Cross(Forward, Right)); + + m44 RotationMatrix = M44( + Right.x, Up.x, Forward.x, 0, + Right.y, Up.y, Forward.y, 0, + Right.z, Up.z, Forward.z, 0, + 0, 0, 0, 1); + + return RotationMatrix; +} + b32 Inverse(m44 M_In, m44* M_Out) { b32 Result = false; diff --git a/todo.txt b/todo.txt index ab21e39..be56b23 100644 --- a/todo.txt +++ b/todo.txt @@ -97,13 +97,7 @@ TODO FOLDHAUS - Platform Layer - Mac Platform Layer -Reimplement Node View -- probably want to take a fresh pass at nodes all together - Assembly -> SACN interface -x you need to rebuild the map from leds -> universes -- x thinking about storing a sparse array of { led_start_index, led_count, led_universe, led_channel } -- that we can iterate over to populate dmx buffers - need to create a data structure in CreateDMXBuffers that prevents duplication of DMXBuffers. - - thinking about a dictionary. Key is Universe, length is 256, create parallel arrays as necessary @@ -132,18 +126,13 @@ Switch To Nodes - evaluation step (one node at a time) Hardening -x turn the default sculpture view into an operation mode ? (have to think about this) - Then we want to think about separating out mode render functions from mode update functions. Not sure its necessary but having something that operates like an update funciton but is called render is weird. Might want some sort of coroutine functionality in place, where modes can add and remove optional, parallel update functions - memory visualization -- x Log memory allocations - separate rendering thread UI Improvements -- highlight node field under active edit -- Mouse Held Commands -- Actual cursor states - shift drag to 10x drag speed - Text editing improvements - - draw cursor in node field under active edit @@ -158,6 +147,8 @@ Development Optimization - patterns are asking to be multithreaded + - OOH I KNOW HOW TO DO THIS NOW!!! - each layer gets calculated independently, and combined + so just do each layer on its own thread, then combine as they are finished - probably want to convert as much color functions to use u32 Packed Colors - - Probably want to think about this more. What about supporting different color depths - for different output devices?