#pragma once #include #include "utils/math.hpp" #include "entities/player.hpp" struct Camera { Vec3 pos{}; uint32_t yaw{}; int32_t pitch{}; void syncFromPlayer(const Player& player, double alpha) { pos = player.interpolatedPos(alpha); yaw = player.yaw; pitch = player.pitch; } }; inline void buildViewMatrix(const Camera& cam, double out[9]) { double bin = SDL_PI_D / 2147483648.0; double yaw = bin * cam.yaw; double pitch = bin * cam.pitch; double cy = SDL_cos(yaw); double sy = SDL_sin(yaw); double cp = SDL_cos(pitch); double sp = SDL_sin(pitch); out[0] = cy; out[1] = 0; out[2] = -sy; out[3] = sy * sp; out[4] = cp; out[5] = cy * sp; out[6] = sy * cp; out[7] = -sp; out[8] = cy * cp; }