Skip to content

Commit

Permalink
OrbitCamera has better sensitivity
Browse files Browse the repository at this point in the history
  • Loading branch information
BarthPaleologue committed Sep 26, 2023
1 parent 2d06abf commit aaf7cfa
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion core/Transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

Transform::Transform() {}

void Transform::setPositionFromFloats(float x, float y, float z) {
void Transform::setPosition(float x, float y, float z) {
_position->x = x;
_position->y = y;
_position->z = z;
Expand Down
2 changes: 1 addition & 1 deletion core/Transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Transform {

glm::vec3 getLeftDirection();

void setPositionFromFloats(float x, float y, float z);
void setPosition(float x, float y, float z);

void translate(glm::vec3 displacement);

Expand Down
2 changes: 1 addition & 1 deletion core/cameras/Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Camera::Camera(Engine *engine) : Transform(), _engine(engine) {
glfwGetWindowSize(_engine->getWindow(), &width, &height);
setAspectRatio(static_cast<float>(width) / static_cast<float>(height));

setPositionFromFloats(0.0f, 0.0f, 7.0f);
setPosition(0.0f, 0.0f, 7.0f);
setNear(0.1);
setFar(80.1);

Expand Down
4 changes: 2 additions & 2 deletions core/cameras/OrbitCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ OrbitCamera::OrbitCamera(Engine *engine) : Camera(engine), _target(0.0f), _radiu

engine->onMouseMoveObservable.add([this](double mouseDX, double mouseDY) {
if (!this->_engine->isMousePressed()) return;
this->rotatePhi(-(float) mouseDX / 500.0f);
this->rotateTheta(-(float) mouseDY / 500.0f);
this->rotatePhi(-(float) mouseDX / 200.0f);
this->rotateTheta(-(float) mouseDY / 200.0f);
});
}

Expand Down
2 changes: 1 addition & 1 deletion core/meshes/Cube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "Cube.h"

Cube::Cube(const char *name, float x, float y, float z) : AbstractMesh(name) {
setPositionFromFloats(x, y, z);
setPosition(x, y, z);
std::vector<float> vertices = {
-1.0f, -1.0f, -1.0f,
1.0f, -1.0f, -1.0f,
Expand Down
2 changes: 1 addition & 1 deletion core/meshes/Triangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "Triangle.h"

Triangle::Triangle(const char *name, float x, float y, float z) : AbstractMesh(name) {
setPositionFromFloats(x, y, z);
setPosition(x, y, z);
std::vector<GLfloat> points = {
0.0f, 0.5f, 0.0f,
0.5f, -0.5f, 0.0f,
Expand Down
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ int main() {

Scene scene;
OrbitCamera camera(&engine);
camera.setPositionFromFloats(0, 0, 20);
camera.setPosition(0, 0, 20);
camera.setRadius(20.0);
camera.rotateTheta(-3.0f);
scene.setActiveCamera(&camera);
Expand Down

0 comments on commit aaf7cfa

Please sign in to comment.