From 908d52020a94fab89a90f5bc32c2fb90be1b079c Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Wed, 19 Feb 2014 15:47:43 +0100 Subject: [PATCH] Some fixes and traps --- .../GameClientState/Camera_FPSV2.cpp | 25 +++++++++++++------ .../GameClient/GameClientState/GameState.cpp | 6 +++++ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/Code/Game/GameClient/GameClientState/Camera_FPSV2.cpp b/Code/Game/GameClient/GameClientState/Camera_FPSV2.cpp index f2f3c1ad..0cf4500d 100644 --- a/Code/Game/GameClient/GameClientState/Camera_FPSV2.cpp +++ b/Code/Game/GameClient/GameClientState/Camera_FPSV2.cpp @@ -4,6 +4,12 @@ using namespace ::Oyster::Math3D; using namespace ::Utility::Value; +inline Quaternion Transform( const Quaternion &transformer, const Quaternion &transformee ) +{ +// return transformer * transformee; + return transformee * transformer; +} + Camera_FPSV2::Camera_FPSV2() { // this->head is default set to identity uniformprojection at origo this->pitchUp = 0.0f; @@ -46,7 +52,7 @@ void Camera_FPSV2::SetRotation( const Quaternion &rotation ) } this->body.rotation = rotation; - this->head.SetRotation( rotation * Rotation(this->pitchUp, WorldAxisOf(rotation, Float3::standard_unit_x) ) ); + this->head.SetRotation( Transform(rotation, Rotation(this->pitchUp, WorldAxisOf(rotation, Float3::standard_unit_x))) ); this->pitchHaveChanged = false; } @@ -74,7 +80,7 @@ void Camera_FPSV2::UpdateOrientation() { if( this->pitchHaveChanged ) { - this->head.SetRotation( this->body.rotation * Rotation(this->pitchUp, WorldAxisOf(this->body.rotation, Float3::standard_unit_x) ) ); + this->head.SetRotation( Transform(this->body.rotation, Rotation(this->pitchUp, WorldAxisOf(this->body.rotation, Float3::standard_unit_x))) ); this->pitchHaveChanged = false; } @@ -87,7 +93,7 @@ void Camera_FPSV2::UpdateOrientation() void Camera_FPSV2::SnapUpToNormal( const Float3 &normal ) { this->body.rotation = Rotation( SnapAngularAxis(AngularAxis(this->body.rotation), WorldAxisOf(this->body.rotation, Float3::standard_unit_y), normal) ); - this->head.SetRotation( this->body.rotation * Rotation(this->pitchUp, WorldAxisOf(this->body.rotation, Float3::standard_unit_x) ) ); + this->head.SetRotation( Transform(this->body.rotation, Rotation(this->pitchUp, WorldAxisOf(this->body.rotation, Float3::standard_unit_x))) ); this->pitchHaveChanged = false; } @@ -130,6 +136,11 @@ void Camera_FPSV2::StrafeLeft( Float distance ) void Camera_FPSV2::PitchUp( Float radian ) { + if( radian >= 0.5f ) + { // HACK: debugging + const char *breakPoint = ""; + } + this->pitchUp = Clamp( this->pitchUp + radian, -0.48f * pi, 0.48f * pi ); this->pitchHaveChanged = true; } @@ -164,7 +175,7 @@ Float4x4 & Camera_FPSV2::GetViewMatrix( Float4x4 &targetMem ) const { if( this->pitchHaveChanged ) { - this->head.SetRotation( this->body.rotation * Rotation(this->pitchUp, WorldAxisOf(this->body.rotation, Float3::standard_unit_x) ) ); + this->head.SetRotation( Transform(this->body.rotation, Rotation(this->pitchUp, WorldAxisOf(this->body.rotation, Float3::standard_unit_x))) ); this->pitchHaveChanged = false; } @@ -180,7 +191,7 @@ Float4x4 & Camera_FPSV2::GetViewsProjMatrix( Float4x4 &targetMem ) const { if( this->pitchHaveChanged ) { - this->head.SetRotation( this->body.rotation * Rotation(this->pitchUp, WorldAxisOf(this->body.rotation, Float3::standard_unit_x) ) ); + this->head.SetRotation( Transform(this->body.rotation, Rotation(this->pitchUp, WorldAxisOf(this->body.rotation, Float3::standard_unit_x))) ); this->pitchHaveChanged = false; } @@ -191,7 +202,7 @@ Float3 Camera_FPSV2::GetNormalOf( const Float3 &axis ) const { if( this->pitchHaveChanged ) { - this->head.SetRotation( this->body.rotation * Rotation(this->pitchUp, WorldAxisOf(this->body.rotation, Float3::standard_unit_x) ) ); + this->head.SetRotation( Transform(this->body.rotation, Rotation(this->pitchUp, WorldAxisOf(this->body.rotation, Float3::standard_unit_x))) ); this->pitchHaveChanged = false; } @@ -212,7 +223,7 @@ Float3 Camera_FPSV2::GetLook() const { if( this->pitchHaveChanged ) { - this->head.SetRotation( this->body.rotation * Rotation(this->pitchUp, WorldAxisOf(this->body.rotation, Float3::standard_unit_x) ) ); + this->head.SetRotation( Transform(this->body.rotation, Rotation(this->pitchUp, WorldAxisOf(this->body.rotation, Float3::standard_unit_x))) ); this->pitchHaveChanged = false; } diff --git a/Code/Game/GameClient/GameClientState/GameState.cpp b/Code/Game/GameClient/GameClientState/GameState.cpp index ed04c009..4192779f 100644 --- a/Code/Game/GameClient/GameClientState/GameState.cpp +++ b/Code/Game/GameClient/GameClientState/GameState.cpp @@ -480,6 +480,12 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState // if is this player. Remember to change camera if( this->privData->myId == decoded.object_ID ) { + if( !Within(position.Dot(position), 2500.0f, 90000.0f) ) + { // HACK: bug trap + const char *breakPoint = "Something is wrong."; + //position = Float3( 0.0f, 160.0f, 0.0f ); + } + this->privData->camera.SetPosition( position ); this->privData->camera.SetRotation( rotation ); this->privData->player.setPos( position );