Cleanup: Moving things where they belong
This commit is contained in:
parent
b514cd38a7
commit
8c6a1d7834
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user