mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-09 02:07:04 +08:00
* refactor(log): convert Logger from namespace to class with static methods - Replace the Logger namespace of free functions with a Logger class containing static methods (info, error, warn, debug). - Simplify log calls by removing explicit source_location parameters; adopt `std::print` for output formatting. - Undefine common macro names (DEBUG, INFO, ERROR, WARN) to avoid collisions. - Update `renderer.cpp` to use `Logger::debug` instead of the old `Logger::log`. - Add missing `#include <source_location>` in `audio_error.hpp`. - Fix early return condition in `WorldScene::set_pause`. * refactor(camera): remove reset_camera method and first-mouse flag * refactor: replace --no-debug with logging options, add assertions, fix typo - Removed `--no-debug` CLI flag and added `--logs-path`, `--log-level`, `--enable-filelog`, `--enable-consolelog`. - Added file logging support with daily rotation, log level threshold, and console/file output control. - Added `m_init` check in `Config::get`/`set` to prevent use before initialization. - Fixed typo in `DebugCollector::destroy` (`distory` → `destory`). - Removed `debug_on` parameter from `Renderer::init`; OpenGL debug output is now unconditionally enabled in debug builds. * feat(debug): enable GL debug context flag in debug builds
54 lines
1.2 KiB
C++
54 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include "Cubed/input/event.hpp"
|
|
|
|
#include <glm/glm.hpp>
|
|
#include <glm/gtc/matrix_transform.hpp>
|
|
#include <glm/gtc/type_ptr.hpp>
|
|
|
|
namespace Cubed {
|
|
|
|
class ClientPlayer;
|
|
|
|
class Camera {
|
|
private:
|
|
enum class Perspective {
|
|
FIRST_PERSON,
|
|
THIRD_PERSON_BACK,
|
|
THIRD_PERSON_FRONT,
|
|
};
|
|
|
|
ClientPlayer* m_player;
|
|
float m_last_mouse_x, m_last_mouse_y;
|
|
glm::vec3 m_camera_pos;
|
|
bool m_under_water = false;
|
|
Perspective m_perspective = Perspective::FIRST_PERSON;
|
|
glm::vec3 m_front;
|
|
glm::vec3 camera_collision(glm::vec3 start, glm::vec3 end,
|
|
float radius = 0.2f);
|
|
|
|
bool handle_key_event(const KeyEvent& e);
|
|
bool handle_mouse_move_event(const MouseMoveEvent& e);
|
|
|
|
public:
|
|
Camera();
|
|
|
|
void update_move_camera();
|
|
|
|
void camera_init(ClientPlayer* player);
|
|
void hot_reload();
|
|
void update_cursor_position_camera(float offset_x, float offset_y);
|
|
|
|
const glm::mat4 get_camera_lookat() const;
|
|
const glm::vec3& get_camera_pos() const;
|
|
|
|
bool is_under_water() const;
|
|
glm::vec3 get_camera_front() const;
|
|
void change_perspective();
|
|
bool is_first_person() const;
|
|
bool handle_event(const Event& e);
|
|
ClientPlayer* player();
|
|
};
|
|
|
|
} // namespace Cubed
|