forked from townforge/townforge
game: fix free camera not keeping from rolling
This commit is contained in:
parent
56920d6130
commit
c76b4a210a
@ -1,5 +1,7 @@
|
||||
#include "free-camera.h"
|
||||
|
||||
using namespace Urho3D;
|
||||
|
||||
void FreeCamera::move(const Urho3D::Vector3 &direction, float speed)
|
||||
{
|
||||
node->Translate(direction * speed);
|
||||
@ -7,6 +9,9 @@ void FreeCamera::move(const Urho3D::Vector3 &direction, float speed)
|
||||
|
||||
void FreeCamera::rotate(float yaw, float pitch, float roll, float speed)
|
||||
{
|
||||
Urho3D::Quaternion q(pitch, yaw, 0.0f);
|
||||
node->SetRotation(node->GetRotation() * q);
|
||||
Quaternion r = node->GetRotation();
|
||||
pitch += r.PitchAngle();
|
||||
pitch = Clamp(pitch, -80.0f, 80.0f);
|
||||
yaw += r.YawAngle();
|
||||
node->SetRotation(Quaternion(pitch, yaw, 0.0f));
|
||||
}
|
||||
|
@ -933,7 +933,6 @@ void CryptoCityUrho3D::MoveCamera(float timeStep)
|
||||
const IntVector2 mouseMove = input->GetMouseMove();
|
||||
yaw += MOUSE_SENSITIVITY * mouseMove.x_;
|
||||
pitch += MOUSE_SENSITIVITY * mouseMove.y_;
|
||||
pitch = Clamp(pitch, -90.0f, 90.0f);
|
||||
}
|
||||
|
||||
float speed = 1.0f;
|
||||
@ -950,7 +949,6 @@ void CryptoCityUrho3D::MoveCamera(float timeStep)
|
||||
yaw -= KEYBOARD_SENSITIVITY * timeStep * speed;
|
||||
if (input->GetKeyDown(KEY_D))
|
||||
yaw += KEYBOARD_SENSITIVITY * timeStep * speed;
|
||||
pitch = Clamp(pitch, -90.0f, 90.0f);
|
||||
|
||||
// Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
|
||||
camera_->rotate(yaw, pitch, 0.0f, 1.0f);
|
||||
|
Loading…
Reference in New Issue
Block a user