medfall

A super great game engine
Log | Files | Refs

commit d6ef807a5a3c4ff0b3cd4c79420af4b79fc3b344
parent 35da5c7ee43fe692f087b3f9679009ba3dc0dc2a
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sat, 25 Nov 2017 22:02:14 +0200

Add functions for exact 90/180/270 degree Z rotations

Diffstat:
clipmap.cc | 7+++----
linear_algebra.h | 27+++++++++++++++++++++++++++
2 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/clipmap.cc b/clipmap.cc @@ -748,12 +748,11 @@ GAME_FRAME( game_frame ) { UniformBinding inf_view_uniforms = renderer_uniforms( V, Pinf, game->pos ); UniformBinding sun_uniforms = renderer_uniforms( sun_dir, game->sun_angle ); - // TODO: these need to be exact or there could be cracks in the terrain StaticArray< UniformBinding, 4 > rotation_uniforms; rotation_uniforms[ 0 ] = renderer_uniforms( m4_identity() ); - rotation_uniforms[ 1 ] = renderer_uniforms( m4_rotz( deg_to_rad( 270 ) ) ); - rotation_uniforms[ 2 ] = renderer_uniforms( m4_rotz( deg_to_rad( 90 ) ) ); - rotation_uniforms[ 3 ] = renderer_uniforms( m4_rotz( deg_to_rad( 180 ) ) ); + rotation_uniforms[ 1 ] = renderer_uniforms( m4_rotz270() ); + rotation_uniforms[ 2 ] = renderer_uniforms( m4_rotz90() ); + rotation_uniforms[ 3 ] = renderer_uniforms( m4_rotz180() ); // draw terrain { diff --git a/linear_algebra.h b/linear_algebra.h @@ -732,6 +732,33 @@ forceinline m4 m4_rotz( float theta ) { ); } +forceinline m4 m4_rotz90() { + return m4( + 0, -1, 0, 0, + 1, 0, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + ); +} + +forceinline m4 m4_rotz180() { + return m4( + -1, 0, 0, 0, + 0, -1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + ); +} + +forceinline m4 m4_rotz270() { + return m4( + 0, 1, 0, 0, + -1, 0, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + ); +} + forceinline m4 m4_translation( float x, float y, float z ) { return m4( 1, 0, 0, x,