mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 02:43:32 +02:00
Fix camera in render perf test
This commit is contained in:
parent
8b9c6a45e1
commit
f2118614da
2 changed files with 17 additions and 15 deletions
|
@ -13,11 +13,11 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
glm::quat getOrientation() const {
|
const glm::quat& getOrientation() const {
|
||||||
return glm::angleAxis(yawPitch.x, Vectors::UP) * glm::angleAxis(yawPitch.y, Vectors::RIGHT);
|
return orientation;
|
||||||
}
|
}
|
||||||
|
|
||||||
vec2 yawPitch { 0 };
|
glm::quat orientation;
|
||||||
glm::vec3 position;
|
glm::vec3 position;
|
||||||
float rotationSpeed { 1.0f };
|
float rotationSpeed { 1.0f };
|
||||||
float movementSpeed { 1.0f };
|
float movementSpeed { 1.0f };
|
||||||
|
@ -77,24 +77,25 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
void rotate(const float delta) {
|
void rotate(const float delta) {
|
||||||
yawPitch.x += delta;
|
orientation = glm::angleAxis(delta, Vectors::UP) * orientation;
|
||||||
updateViewMatrix();
|
updateViewMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
void rotate(const glm::vec2& delta) {
|
void rotate(const glm::vec2& delta) {
|
||||||
yawPitch += delta;
|
|
||||||
|
// create orientation vectors
|
||||||
|
auto lookat = orientation * Vectors::UNIT_NEG_Z;
|
||||||
|
auto forward = glm::normalize(vec3(lookat.x, 0, lookat.z));
|
||||||
|
auto side = glm::cross(Vectors::UP, forward);
|
||||||
|
|
||||||
|
// rotate camera with quaternions created from axis and angle
|
||||||
|
orientation = glm::angleAxis(delta.x, Vectors::UP) * orientation;
|
||||||
|
orientation = glm::angleAxis(-delta.y, side) * orientation;
|
||||||
updateViewMatrix();
|
updateViewMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setRotation(const glm::quat& rotation) {
|
void setRotation(const glm::quat& rotation) {
|
||||||
glm::vec3 f = rotation * Vectors::UNIT_NEG_Z;
|
orientation = rotation;
|
||||||
f.y = 0;
|
|
||||||
f = glm::normalize(f);
|
|
||||||
yawPitch.x = angleBetween(Vectors::UNIT_NEG_Z, f);
|
|
||||||
f = rotation * Vectors::UNIT_NEG_Z;
|
|
||||||
f.x = 0;
|
|
||||||
f = glm::normalize(f);
|
|
||||||
yawPitch.y = angleBetween(Vectors::UNIT_NEG_Z, f);
|
|
||||||
updateViewMatrix();
|
updateViewMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -946,7 +946,7 @@ private:
|
||||||
orientationRegex.cap(3).toFloat(),
|
orientationRegex.cap(3).toFloat(),
|
||||||
orientationRegex.cap(4).toFloat());
|
orientationRegex.cap(4).toFloat());
|
||||||
if (!glm::any(glm::isnan(v))) {
|
if (!glm::any(glm::isnan(v))) {
|
||||||
_camera.setRotation(glm::normalize(glm::quat(v.w, v.x, v.y, v.z)));
|
_camera.setRotation(glm::quat(v.w, v.x, v.y, v.z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1008,6 +1008,7 @@ private:
|
||||||
arg(v.x).arg(v.y).arg(v.z).
|
arg(v.x).arg(v.y).arg(v.z).
|
||||||
arg(q.x).arg(q.y).arg(q.z).arg(q.w);
|
arg(q.x).arg(q.y).arg(q.z).arg(q.w);
|
||||||
_settings.setValue(LAST_LOCATION_KEY, viewpoint);
|
_settings.setValue(LAST_LOCATION_KEY, viewpoint);
|
||||||
|
_camera.setRotation(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
void restorePosition() {
|
void restorePosition() {
|
||||||
|
@ -1019,7 +1020,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetPosition() {
|
void resetPosition() {
|
||||||
_camera.yawPitch = vec3(0);
|
_camera.setRotation(quat());
|
||||||
_camera.setPosition(vec3());
|
_camera.setPosition(vec3());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue