Updated gs_vector_matrix

This commit is contained in:
Peter Slattery 2020-03-19 21:50:11 -07:00
parent f461ee2044
commit 803f5c82ae
2 changed files with 83 additions and 49 deletions

View File

@ -906,44 +906,6 @@ Transpose (m44 M)
return 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
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 operator== (m33 A, m33 B)
{ {
b32 Result = true; b32 Result = true;
@ -1107,6 +1069,87 @@ v4 operator* (m44 M, v4 V)
return Result; 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 Inverse(m44 M_In, m44* M_Out)
{ {
b32 Result = false; b32 Result = false;

View File

@ -97,13 +97,7 @@ TODO FOLDHAUS
- Platform Layer - Platform Layer
- Mac Platform Layer - Mac Platform Layer
Reimplement Node View
- probably want to take a fresh pass at nodes all together
Assembly -> SACN interface 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. - 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 - - 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) - evaluation step (one node at a time)
Hardening 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 - 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 update functions
- memory visualization - memory visualization
- x Log memory allocations
- separate rendering thread - separate rendering thread
UI Improvements UI Improvements
- highlight node field under active edit
- Mouse Held Commands
- Actual cursor states
- shift drag to 10x drag speed - shift drag to 10x drag speed
- Text editing improvements - Text editing improvements
- - draw cursor in node field under active edit - - draw cursor in node field under active edit
@ -158,6 +147,8 @@ Development
Optimization Optimization
- patterns are asking to be multithreaded - 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 convert as much color functions to use u32 Packed Colors
- - Probably want to think about this more. What about supporting different color depths - - Probably want to think about this more. What about supporting different color depths
- for different output devices? - for different output devices?