Cleanup: Moving things where they belong

This commit is contained in:
karl 2020-01-07 22:13:47 +01:00
parent b514cd38a7
commit 8c6a1d7834
3 changed files with 12 additions and 12 deletions

View File

@ -9,6 +9,10 @@ struct MouseLook {
explicit MouseLook(float sensitivity) : sensitivity(sensitivity) {}
float sensitivity;
double yaw = 0.0;
double pitch = 0.0;
};
#endif //ECSGAME_MOUSELOOK_H

View File

@ -58,7 +58,6 @@ class KeyboardMovementSystem : public EntitySystem, public EventSubscriber<Input
}
});
}
std::cout << "MyEvent was emitted!" << std::endl;
}
void tick(World *pWorld, float deltaTime) override {

View File

@ -34,22 +34,22 @@ public:
lastX = event.newX;
lastY = event.newY;
yaw += xOffset * mouse->sensitivity;
pitch += yOffset * mouse->sensitivity;
mouse->yaw += xOffset * mouse->sensitivity;
mouse->pitch += yOffset * mouse->sensitivity;
});
}
void tick(World *pWorld, float deltaTime) override {
pWorld->each<Transform, MouseLook, Camera>([&](Entity *ent, ComponentHandle<Transform> transform, ComponentHandle<MouseLook> mouse, ComponentHandle<Camera> camera) {
if(pitch > 89.0f)
pitch = 89.0f;
if(pitch < -89.0f)
pitch = -89.0f;
if(mouse->pitch > 89.0f)
mouse->pitch = 89.0f;
if(mouse->pitch < -89.0f)
mouse->pitch = -89.0f;
glm::mat4x4 newTransform = glm::mat4x4(1.0);
newTransform = glm::rotate(newTransform, glm::radians((float)pitch), transform->right());
newTransform = glm::rotate(newTransform, glm::radians((float)yaw), glm::vec3(0.0, 1.0, 0.0));
newTransform = glm::rotate(newTransform, glm::radians((float)mouse->pitch), transform->right());
newTransform = glm::rotate(newTransform, glm::radians((float)mouse->yaw), glm::vec3(0.0, 1.0, 0.0));
newTransform[3] = transform->matrix[3];
@ -61,9 +61,6 @@ private:
double lastX;
double lastY;
double pitch = 0.0;
double yaw = 0.0;
World *myWorld;
};