medfall

A super great game engine
Log | Files | Refs

commit 259aacee40539d110a8484c17336f2e29c8990e5
parent 65ca8e58ad0288ad54c37973fe8451c8c9f32de9
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Thu May 18 03:36:37 +0300

v3::xyz(), m3::m3( m4 )

Diffstat:
linear_algebra.h | 12++++++++++++
1 file changed, 12 insertions(+), 0 deletions(-)
diff --git a/linear_algebra.h b/linear_algebra.h @@ -9,6 +9,8 @@ #include "intrinsics.h" #include "platform_inline.h" +struct m4; + /* * data definitions */ @@ -148,6 +150,8 @@ struct m3 { col2 = c2; } + explicit m3( const m4 & m ); + v3 row0() const { return v3( col0.x, col1.x, col2.x ); } v3 row1() const { return v3( col0.y, col1.y, col2.y ); } v3 row2() const { return v3( col0.z, col1.z, col2.z ); } @@ -195,6 +199,8 @@ struct v4 { if( idx == 2 ) return z; return w; } + + v3 xyz() const { return v3( x, y, z ); } }; // AUTOVISITOR @@ -228,6 +234,12 @@ struct m4 { v4 row3() const { return v4( col0.w, col1.w, col2.w, col3.w ); } }; +forceinline m3::m3( const m4 & m ) { + col0 = m.col0.xyz(); + col1 = m.col1.xyz(); + col2 = m.col2.xyz(); +} + // AUTOVISITOR struct quat { float x, y, z, w;