From 86cd53e555990ec1ed971d5c168ac31dae02e90a Mon Sep 17 00:00:00 2001 From: Bilal Kahraman Date: Fri, 16 Aug 2024 16:03:51 +0300 Subject: [PATCH 1/5] Fix naming in camera package --- src/Camera/CMakeLists.txt | 11 ++--------- src/Camera/include/Camera/camera.h | 21 +++++++++++---------- src/Camera/include/Camera/ray.h | 1 + src/Camera/include/Camera/raycaster.h | 11 ++++++----- src/Camera/src/camera.cpp | 11 ++++++----- src/Camera/src/ray.cpp | 3 ++- src/Camera/src/raycaster.cpp | 5 ++--- 7 files changed, 30 insertions(+), 33 deletions(-) diff --git a/src/Camera/CMakeLists.txt b/src/Camera/CMakeLists.txt index e35aab0..4732e19 100644 --- a/src/Camera/CMakeLists.txt +++ b/src/Camera/CMakeLists.txt @@ -4,42 +4,35 @@ link_directories( ${PROJECT_SOURCE_DIR} ) - +# Ray library add_library( ray STATIC src/ray.cpp ) - -# Specify include directories for this library target_include_directories(ray PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR} ) - target_link_libraries( ray PUBLIC vector ) -# Game object library +# camera library add_library( camera STATIC src/camera.cpp src/raycaster.cpp ) - -# Specify include directories for this library target_include_directories(camera PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR} ) - - target_link_libraries( camera PUBLIC diff --git a/src/Camera/include/Camera/camera.h b/src/Camera/include/Camera/camera.h index 068d59e..57eb961 100644 --- a/src/Camera/include/Camera/camera.h +++ b/src/Camera/include/Camera/camera.h @@ -9,19 +9,19 @@ * */ -#ifndef CAMERA_CAMERA_H -#define CAMERA_CAMERA_H +#ifndef CAMERA_INCLUDE_CAMERA_H +#define CAMERA_INCLUDE_CAMERA_H -#include "Camera/raycaster.h" -#include "Graphics/scene.h" #include +#include #include #include #include +#include #include + #include #include -#include #include namespace wolfenstein { @@ -44,8 +44,8 @@ class Camera2D void Update(const std::shared_ptr& scene); std::shared_ptr GetRays() const; - std::optional GetObjectRay(std::string id); std::shared_ptr GetCrosshairRay() const; + std::optional GetObjectRay(const std::string id); Position2D GetPosition() const; double GetFov() const; double GetDeltaAngle() const; @@ -56,14 +56,15 @@ class Camera2D void InitRays(); void Calculate(const std::shared_ptr& object); double WorldAngleToCameraAngle(double angle) const; + Camera2DConfig config_; - std::shared_ptr rays_; - std::unordered_map objects_; + Position2D position_; std::shared_ptr ray_cast_; + std::shared_ptr rays_; std::shared_ptr crosshair_ray_; - Position2D position_; + std::unordered_map objects_; }; } // namespace wolfenstein -#endif // CAMERA_CAMERA_H \ No newline at end of file +#endif // CAMERA_INCLUDE_CAMERA_H \ No newline at end of file diff --git a/src/Camera/include/Camera/ray.h b/src/Camera/include/Camera/ray.h index fbb0d9d..37c43e4 100644 --- a/src/Camera/include/Camera/ray.h +++ b/src/Camera/include/Camera/ray.h @@ -13,6 +13,7 @@ #define CAMERA_INCLUDE_CAMERA_RAY_H_ #include + #include namespace wolfenstein { diff --git a/src/Camera/include/Camera/raycaster.h b/src/Camera/include/Camera/raycaster.h index 9e07f32..c5ad5dc 100644 --- a/src/Camera/include/Camera/raycaster.h +++ b/src/Camera/include/Camera/raycaster.h @@ -9,13 +9,14 @@ * */ -#ifndef CAMERA_INCLUDE_RAYCASTER_H_ -#define CAMERA_INCLUDE_RAYCASTER_H_ +#ifndef CAMERA_INCLUDE_CAMERA_RAYCASTER_H_ +#define CAMERA_INCLUDE_CAMERA_RAYCASTER_H_ -#include "Camera/ray.h" +#include #include #include #include + #include namespace wolfenstein { @@ -24,7 +25,7 @@ class RayCaster { public: RayCaster(const int num_ray, const double fov, const double depth); - ~RayCaster(); + ~RayCaster() = default; void Update(const std::shared_ptr& map_ptr, const Position2D& position, const std::shared_ptr& rays); @@ -46,4 +47,4 @@ class RayCaster } // namespace wolfenstein -#endif // CAMERA_INCLUDE_RAYCASTER_H_ \ No newline at end of file +#endif // CAMERA_INCLUDE_CAMERA_RAYCASTER_H_ \ No newline at end of file diff --git a/src/Camera/src/camera.cpp b/src/Camera/src/camera.cpp index de47f94..f29a6c4 100644 --- a/src/Camera/src/camera.cpp +++ b/src/Camera/src/camera.cpp @@ -9,10 +9,11 @@ * */ -#include "Camera/camera.h" -#include "Camera/ray.h" -#include "Math/vector.h" +#include +#include +#include #include + #include #include @@ -39,7 +40,7 @@ void Camera2D::Update(const std::shared_ptr& scene) { // Update object rays objects_.clear(); for (const auto& object : scene->GetObjects()) { - if (object->GetObjectType() == ObjectType::STATIC_OBJECT) { + if (object->GetObjectType() != ObjectType::CHARACTER_PLAYER) { Calculate(object); } } @@ -49,7 +50,7 @@ std::shared_ptr Camera2D::GetRays() const { return rays_; } -std::optional Camera2D::GetObjectRay(std::string id) { +std::optional Camera2D::GetObjectRay(const std::string id) { if (objects_.find(id) != objects_.end()) { return objects_[id]; } diff --git a/src/Camera/src/ray.cpp b/src/Camera/src/ray.cpp index 157555b..377b091 100644 --- a/src/Camera/src/ray.cpp +++ b/src/Camera/src/ray.cpp @@ -1,4 +1,5 @@ -#include "Camera/ray.h" +#include + #include namespace wolfenstein { diff --git a/src/Camera/src/raycaster.cpp b/src/Camera/src/raycaster.cpp index 45dc0c1..7d9757a 100644 --- a/src/Camera/src/raycaster.cpp +++ b/src/Camera/src/raycaster.cpp @@ -1,4 +1,5 @@ -#include "Camera/raycaster.h" +#include + #include #include @@ -10,8 +11,6 @@ RayCaster::RayCaster(const int num_ray, const double fov, const double depth) depth_(depth), delta_theta_(fov_ / num_ray) {} -RayCaster::~RayCaster() {} - void RayCaster::Update(const std::shared_ptr& map_ptr, const Position2D& position, const std::shared_ptr& rays) { From 21e8860bb46b6a8bc6f9b3a10936323b81fd0d5b Mon Sep 17 00:00:00 2001 From: Bilal Kahraman Date: Sun, 18 Aug 2024 01:12:40 +0300 Subject: [PATCH 2/5] Fix naming in game object package --- src/GameObjects/CMakeLists.txt | 2 -- src/GameObjects/include/GameObjects/dynamic_object.h | 7 +++---- src/GameObjects/include/GameObjects/game_object.h | 6 +++--- src/GameObjects/include/GameObjects/static_object.h | 8 +++----- src/GameObjects/src/dynamic_object.cpp | 1 - src/GameObjects/src/static_object.cpp | 5 ----- 6 files changed, 9 insertions(+), 20 deletions(-) diff --git a/src/GameObjects/CMakeLists.txt b/src/GameObjects/CMakeLists.txt index c3f4b50..158a5a1 100644 --- a/src/GameObjects/CMakeLists.txt +++ b/src/GameObjects/CMakeLists.txt @@ -4,7 +4,6 @@ link_directories( ${PROJECT_SOURCE_DIR} ) -# Game object library add_library( game_object STATIC @@ -12,7 +11,6 @@ add_library( src/dynamic_object.cpp ) -# Specify include directories for this library target_include_directories(game_object PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include diff --git a/src/GameObjects/include/GameObjects/dynamic_object.h b/src/GameObjects/include/GameObjects/dynamic_object.h index 00fa89a..fe63a07 100644 --- a/src/GameObjects/include/GameObjects/dynamic_object.h +++ b/src/GameObjects/include/GameObjects/dynamic_object.h @@ -9,8 +9,8 @@ * */ -#ifndef GAME_OBJECTS_DYNAMIC_OBJECT_H -#define GAME_OBJECTS_DYNAMIC_OBJECT_H +#ifndef GAME_OBJECTS_INCLUDE_DYNAMIC_OBJECT_H +#define GAME_OBJECTS_INCLUDE_DYNAMIC_OBJECT_H #include "GameObjects/game_object.h" #include @@ -31,11 +31,10 @@ class DynamicObject : public IGameObject std::string GetId() const override; protected: - // Dynamic object specific data vector2d pose; std::string texture_path; std::string id; }; } // namespace wolfenstein -#endif // GAME_OBJECTS_DYNAMIC_OBJECT_H +#endif // GAME_OBJECTS_INCLUDE_DYNAMIC_OBJECT_H diff --git a/src/GameObjects/include/GameObjects/game_object.h b/src/GameObjects/include/GameObjects/game_object.h index f0ace64..a88793d 100644 --- a/src/GameObjects/include/GameObjects/game_object.h +++ b/src/GameObjects/include/GameObjects/game_object.h @@ -9,8 +9,8 @@ * */ -#ifndef GAME_OBJECTS_GAME_OBJECT_H -#define GAME_OBJECTS_GAME_OBJECT_H +#ifndef GAME_OBJECTS_INCLUDE_GAME_OBJECT_H +#define GAME_OBJECTS_INCLUDE_GAME_OBJECT_H #include #include @@ -38,4 +38,4 @@ class IGameObject }; } // namespace wolfenstein -#endif // GAME_OBJECTS_GAME_OBJECT_H +#endif // GAME_OBJECTS_INCLUDE_GAME_OBJECT_H diff --git a/src/GameObjects/include/GameObjects/static_object.h b/src/GameObjects/include/GameObjects/static_object.h index 8adb9d9..d3a09b9 100644 --- a/src/GameObjects/include/GameObjects/static_object.h +++ b/src/GameObjects/include/GameObjects/static_object.h @@ -9,12 +9,11 @@ * */ -#ifndef GAME_OBJECTS_STATIC_OBJECT_H -#define GAME_OBJECTS_STATIC_OBJECT_H +#ifndef GAME_OBJECTS_INCLUDE_STATIC_OBJECT_H +#define GAME_OBJECTS_INCLUDE_STATIC_OBJECT_H #include "GameObjects/game_object.h" #include "Math/vector.h" -#include "third-party/uuid_v4/uuid_v4.h" #include #include @@ -28,7 +27,6 @@ class StaticObject : public IGameObject ~StaticObject(); void Update(double delta_time) override; - void Render(Position2D camera_position); void SetPose(const vector2d& pose) override; @@ -50,4 +48,4 @@ class StaticObject : public IGameObject } // namespace wolfenstein -#endif // GAME_OBJECTS_STATIC_OBJECT_H \ No newline at end of file +#endif // GAME_OBJECTS_INCLUDE_STATIC_OBJECT_H \ No newline at end of file diff --git a/src/GameObjects/src/dynamic_object.cpp b/src/GameObjects/src/dynamic_object.cpp index 553e1a4..5a4fc8d 100644 --- a/src/GameObjects/src/dynamic_object.cpp +++ b/src/GameObjects/src/dynamic_object.cpp @@ -11,7 +11,6 @@ DynamicObject::~DynamicObject() {} void DynamicObject::Update(double delta_time) { (void)delta_time; - // Update dynamic object specific data } void DynamicObject::SetPose(const vector2d& pose) { diff --git a/src/GameObjects/src/static_object.cpp b/src/GameObjects/src/static_object.cpp index 6075336..d3c2860 100644 --- a/src/GameObjects/src/static_object.cpp +++ b/src/GameObjects/src/static_object.cpp @@ -15,11 +15,6 @@ void StaticObject::Update(double delta_time) { (void)delta_time; } -void StaticObject::Render(Position2D camera_position) { - (void)camera_position; - // Render static object -} - void StaticObject::SetPose(const vector2d& pose) { this->pose = pose; } From 2011a1b4fffcafd142cd3459bd24b6bc3ca89b84 Mon Sep 17 00:00:00 2001 From: Bilal Kahraman Date: Sun, 18 Aug 2024 01:20:25 +0300 Subject: [PATCH 3/5] Fix naming in character package --- src/Characters/CMakeLists.txt | 22 ------------------- src/Characters/include/Characters/character.h | 9 +++----- src/Characters/include/Characters/enemy.h | 12 +++++----- src/Characters/include/Characters/player.h | 3 +-- src/Characters/src/enemy.cpp | 4 ++-- src/Characters/src/player.cpp | 7 +++--- src/Core/CMakeLists.txt | 1 - .../include/GameObjects/dynamic_object.h | 2 +- .../include/GameObjects/static_object.h | 5 ++--- src/GameObjects/src/dynamic_object.cpp | 3 ++- src/GameObjects/src/static_object.cpp | 5 +++-- 11 files changed, 24 insertions(+), 49 deletions(-) diff --git a/src/Characters/CMakeLists.txt b/src/Characters/CMakeLists.txt index 8677eee..54d8409 100644 --- a/src/Characters/CMakeLists.txt +++ b/src/Characters/CMakeLists.txt @@ -3,7 +3,6 @@ link_directories( ${CMAKE_CURRENT_SOURCE_DIR}/include ) -# Math library add_library( character STATIC @@ -11,7 +10,6 @@ add_library( src/enemy.cpp ) -# Specify include directories for this library target_include_directories(character PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include @@ -25,23 +23,3 @@ target_link_libraries( collision_manager ) - -# Math library -add_library( - player - STATIC - src/player.cpp -) - -# Specify include directories for this library -target_include_directories(player PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include -) - -target_link_libraries( - player - PUBLIC - character - collision_manager -) \ No newline at end of file diff --git a/src/Characters/include/Characters/character.h b/src/Characters/include/Characters/character.h index 3297944..9b29fea 100644 --- a/src/Characters/include/Characters/character.h +++ b/src/Characters/include/Characters/character.h @@ -9,8 +9,8 @@ * */ -#ifndef CHARACTERS_CHARACTER_H -#define CHARACTERS_CHARACTER_H +#ifndef CHARACTERS_INCLUDE_CHARACTER_H +#define CHARACTERS_INCLUDE_CHARACTER_H #include @@ -34,7 +34,6 @@ struct CharacterConfig double rotation_speed; }; -// Character.h class ICharacter { public: @@ -43,9 +42,7 @@ class ICharacter virtual void SetPosition(Position2D position) = 0; virtual Position2D GetPosition() const = 0; - private: - // Character specific data }; } // namespace wolfenstein -#endif // CHARACTERS_CHARACTER_H \ No newline at end of file +#endif // CHARACTERS_INCLUDE_CHARACTER_H \ No newline at end of file diff --git a/src/Characters/include/Characters/enemy.h b/src/Characters/include/Characters/enemy.h index 20160b6..b2b9775 100644 --- a/src/Characters/include/Characters/enemy.h +++ b/src/Characters/include/Characters/enemy.h @@ -9,11 +9,10 @@ * */ -#ifndef CHARACTERS_ENEMY_H_ -#define CHARACTERS_ENEMY_H_ +#ifndef CHARACTERS_INCLUDE_ENEMY_H_ +#define CHARACTERS_INCLUDE_ENEMY_H_ -#include "character.h" -#include +#include namespace wolfenstein { @@ -26,9 +25,10 @@ class Enemy : public ICharacter, public IGameObject void Update(double delta_time) override; void SetPose(const vector2d& pose) override; + void SetPosition(Position2D position) override; + ObjectType GetObjectType() const override; vector2d GetPose() const override; - void SetPosition(Position2D position) override; Position2D GetPosition() const override; std::string GetId() const override; @@ -41,4 +41,4 @@ class Enemy : public ICharacter, public IGameObject } // namespace wolfenstein -#endif // CHARACTERS_ENEMY_H_ +#endif // CHARACTERS_INCLUDE_ENEMY_H_ diff --git a/src/Characters/include/Characters/player.h b/src/Characters/include/Characters/player.h index aa171ee..98055ba 100644 --- a/src/Characters/include/Characters/player.h +++ b/src/Characters/include/Characters/player.h @@ -12,8 +12,7 @@ #ifndef CHARACTERS_PLAYER_H #define CHARACTERS_PLAYER_H -#include "character.h" -#include +#include #include namespace wolfenstein { diff --git a/src/Characters/src/enemy.cpp b/src/Characters/src/enemy.cpp index fe9567b..3246fb9 100644 --- a/src/Characters/src/enemy.cpp +++ b/src/Characters/src/enemy.cpp @@ -1,4 +1,5 @@ -#include "Characters/enemy.h" +#include +#include namespace wolfenstein { @@ -36,7 +37,6 @@ std::string Enemy::GetId() const { void Enemy::Move(double delta_time) { (void)delta_time; - // Move enemy } } // namespace wolfenstein diff --git a/src/Characters/src/player.cpp b/src/Characters/src/player.cpp index 511e527..0332cfd 100644 --- a/src/Characters/src/player.cpp +++ b/src/Characters/src/player.cpp @@ -1,7 +1,8 @@ -#include "Characters/player.h" -#include "CollisionManager/collision_manager.h" -#include "Math/vector.h" +#include +#include +#include #include +#include namespace wolfenstein { diff --git a/src/Core/CMakeLists.txt b/src/Core/CMakeLists.txt index 247e98d..552d473 100644 --- a/src/Core/CMakeLists.txt +++ b/src/Core/CMakeLists.txt @@ -24,7 +24,6 @@ target_link_libraries( texture_manager camera character - player game_object map vector diff --git a/src/GameObjects/include/GameObjects/dynamic_object.h b/src/GameObjects/include/GameObjects/dynamic_object.h index fe63a07..57438d3 100644 --- a/src/GameObjects/include/GameObjects/dynamic_object.h +++ b/src/GameObjects/include/GameObjects/dynamic_object.h @@ -12,7 +12,7 @@ #ifndef GAME_OBJECTS_INCLUDE_DYNAMIC_OBJECT_H #define GAME_OBJECTS_INCLUDE_DYNAMIC_OBJECT_H -#include "GameObjects/game_object.h" +#include #include namespace wolfenstein { diff --git a/src/GameObjects/include/GameObjects/static_object.h b/src/GameObjects/include/GameObjects/static_object.h index d3a09b9..3d37591 100644 --- a/src/GameObjects/include/GameObjects/static_object.h +++ b/src/GameObjects/include/GameObjects/static_object.h @@ -12,10 +12,9 @@ #ifndef GAME_OBJECTS_INCLUDE_STATIC_OBJECT_H #define GAME_OBJECTS_INCLUDE_STATIC_OBJECT_H -#include "GameObjects/game_object.h" -#include "Math/vector.h" #include -#include +#include +#include namespace wolfenstein { diff --git a/src/GameObjects/src/dynamic_object.cpp b/src/GameObjects/src/dynamic_object.cpp index 5a4fc8d..b2c6f51 100644 --- a/src/GameObjects/src/dynamic_object.cpp +++ b/src/GameObjects/src/dynamic_object.cpp @@ -1,4 +1,5 @@ -#include "GameObjects/dynamic_object.h" +#include +#include namespace wolfenstein { diff --git a/src/GameObjects/src/static_object.cpp b/src/GameObjects/src/static_object.cpp index d3c2860..b645142 100644 --- a/src/GameObjects/src/static_object.cpp +++ b/src/GameObjects/src/static_object.cpp @@ -1,5 +1,6 @@ -#include "GameObjects/static_object.h" -#include "GameObjects/game_object.h" +#include +#include +#include namespace wolfenstein { From d4a0fe85555a0e7a3dc1fda0a8b2fe7e0bcc590a Mon Sep 17 00:00:00 2001 From: Bilal Kahraman Date: Sun, 18 Aug 2024 01:50:53 +0300 Subject: [PATCH 4/5] Fix naming general --- .../CollisionManager/collision_manager.h | 8 ++-- .../src/collision_manager.cpp | 2 +- src/Map/CMakeLists.txt | 2 - src/Map/src/map.cpp | 2 +- src/Math/CMakeLists.txt | 2 - src/Math/include/Math/vector.h | 6 +-- src/Math/src/vector.cpp | 42 +++++++++++++++---- src/TextureManager/CMakeLists.txt | 1 - .../include/TextureManager/texture_manager.h | 9 ++-- src/TextureManager/src/texture_manager.cpp | 2 +- .../include/TimeManager/time_manager.h | 6 +-- src/TimeManager/src/time_manager.cpp | 2 +- src/Utility/CMakeLists.txt | 2 - src/Utility/include/Utility/logger.h | 7 ++-- src/Utility/include/Utility/uuid_generator.h | 6 +-- src/Utility/src/logger.cpp | 2 +- src/Utility/src/uuid_generator.cpp | 2 +- 17 files changed, 61 insertions(+), 42 deletions(-) diff --git a/src/CollisionManager/include/CollisionManager/collision_manager.h b/src/CollisionManager/include/CollisionManager/collision_manager.h index 747c5c8..613506b 100644 --- a/src/CollisionManager/include/CollisionManager/collision_manager.h +++ b/src/CollisionManager/include/CollisionManager/collision_manager.h @@ -9,11 +9,11 @@ * */ -#ifndef COLLISION_MANAGER_COLLISION_MANAGER_H -#define COLLISION_MANAGER_COLLISION_MANAGER_H +#ifndef COLLISION_MANAGER_INCLUDE_COLLISION_MANAGER_H +#define COLLISION_MANAGER_INCLUDE_COLLISION_MANAGER_H -#include "Map/map.h" #include +#include #include #include @@ -44,4 +44,4 @@ class CollisionManager }; } // namespace wolfenstein -#endif // COLLISION_MANAGER_COLLISION_MANAGER_H +#endif // COLLISION_MANAGER_INCLUDE_COLLISION_MANAGER_H diff --git a/src/CollisionManager/src/collision_manager.cpp b/src/CollisionManager/src/collision_manager.cpp index 715a1ba..27d963b 100644 --- a/src/CollisionManager/src/collision_manager.cpp +++ b/src/CollisionManager/src/collision_manager.cpp @@ -1,4 +1,4 @@ -#include "CollisionManager/collision_manager.h" +#include #include namespace wolfenstein { diff --git a/src/Map/CMakeLists.txt b/src/Map/CMakeLists.txt index 04c471b..0da105b 100644 --- a/src/Map/CMakeLists.txt +++ b/src/Map/CMakeLists.txt @@ -3,14 +3,12 @@ link_directories( ${CMAKE_CURRENT_SOURCE_DIR}/include ) -# Math library add_library( map STATIC src/map.cpp ) -# Specify include directories for this library target_include_directories(map PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include diff --git a/src/Map/src/map.cpp b/src/Map/src/map.cpp index b33c19f..049a78b 100644 --- a/src/Map/src/map.cpp +++ b/src/Map/src/map.cpp @@ -1,4 +1,4 @@ -#include "Map/map.h" +#include #include namespace wolfenstein { diff --git a/src/Math/CMakeLists.txt b/src/Math/CMakeLists.txt index 21568bb..c6fec2a 100644 --- a/src/Math/CMakeLists.txt +++ b/src/Math/CMakeLists.txt @@ -3,14 +3,12 @@ link_directories( ${CMAKE_CURRENT_SOURCE_DIR}/include ) -# Math library add_library( vector STATIC src/vector.cpp ) -# Specify include directories for this library target_include_directories(vector PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include diff --git a/src/Math/include/Math/vector.h b/src/Math/include/Math/vector.h index 378e730..2a4f04f 100644 --- a/src/Math/include/Math/vector.h +++ b/src/Math/include/Math/vector.h @@ -9,8 +9,8 @@ * */ -#ifndef MATH_INCLUDE_VECTOR_H_ -#define MATH_INCLUDE_VECTOR_H_ +#ifndef MATH_INCLUDE_MATH_VECTOR_H_ +#define MATH_INCLUDE_MATH_VECTOR_H_ #include @@ -110,4 +110,4 @@ double CalculateAngleBetweenThreeVectorsSigned(const vector2d& v1, } // namespace wolfenstein -#endif // MATH_INCLUDE_VECTOR_H_ +#endif // MATH_INCLUDE_MATH_VECTOR_H_ diff --git a/src/Math/src/vector.cpp b/src/Math/src/vector.cpp index 9ed49be..40f3b46 100644 --- a/src/Math/src/vector.cpp +++ b/src/Math/src/vector.cpp @@ -1,4 +1,4 @@ -#include "Math/vector.h" +#include #include namespace wolfenstein { @@ -150,19 +150,47 @@ std::ostream& operator<<(std::ostream& out, const vector2d& v) { } double SumRadian(const double radian1, const double radian2) { - return std::fmod(radian1 + radian2, (M_PI * 2)); + auto angle = std::fmod(radian1 + radian2, (M_PI * 2)); + if (angle > M_PI) { + angle -= 2 * M_PI; + } + else if (angle < -M_PI) { + angle += 2 * M_PI; + } + return angle; } double SubRadian(const double degree1, const double degree2) { - return std::fmod(degree1 - degree2, (M_PI * 2)); + auto angle = std::fmod(degree1 - degree2, (M_PI * 2)); + if (angle > M_PI) { + angle -= 2 * M_PI; + } + else if (angle < -M_PI) { + angle += 2 * M_PI; + } + return angle; } double SumDegree(const double degree1, const double degree2) { - return std::fmod(degree1 + degree2, 360.0); + auto angle = std::fmod(degree1 + degree2, 360.0); + if (angle > 180.0) { + angle -= 2 * 180.0; + } + else if (angle < -180.0) { + angle += 2 * 180.0; + } + return angle; } double SubDegree(const double degree1, const double degree2) { - return std::fmod(degree1 - degree2, 360.0); + auto angle = std::fmod(degree1 - degree2, 360.0); + if (angle > 180.0) { + angle -= 2 * 180.0; + } + else if (angle < -180.0) { + angle += 2 * 180.0; + } + return angle; } double ToRadians(const double degree) { @@ -188,7 +216,7 @@ double CalculateAngleBetweenTwoVectors(const vector2d& v1, const vector2d& v3) { double CalculateAngleBetweenTwoVectorsSigned(const vector2d& v1, const vector2d& v3) { auto angle = std::acos(v1.Dot(v3) / (v1.Magnitude() * v3.Magnitude())); - // if v1 is on the left side of v2, then angle is negative + const vector2d v2; double orientation_val = (v2.y - v1.y) * (v3.x - v2.x) - (v2.x - v1.x) * (v3.y - v2.y); @@ -205,7 +233,7 @@ double CalculateAngleBetweenThreeVectorsSigned(const vector2d& v1, const auto v3_base = v3 - v2; auto angle = std::acos(v1_base.Dot(v3_base) / (v1_base.Magnitude() * v3_base.Magnitude())); - // if v1 is on the left side of v2, then angle is negative + double orientation_val = (v2.y - v1.y) * (v3.x - v2.x) - (v2.x - v1.x) * (v3.y - v2.y); if (orientation_val > 0.0) { diff --git a/src/TextureManager/CMakeLists.txt b/src/TextureManager/CMakeLists.txt index 59e5b24..cb2b73d 100644 --- a/src/TextureManager/CMakeLists.txt +++ b/src/TextureManager/CMakeLists.txt @@ -3,7 +3,6 @@ link_directories( ${CMAKE_CURRENT_SOURCE_DIR}/include ) - add_library( texture_manager STATIC diff --git a/src/TextureManager/include/TextureManager/texture_manager.h b/src/TextureManager/include/TextureManager/texture_manager.h index a25671e..a682361 100644 --- a/src/TextureManager/include/TextureManager/texture_manager.h +++ b/src/TextureManager/include/TextureManager/texture_manager.h @@ -9,14 +9,13 @@ * */ -#ifndef TEXTURE_MANAGER_TEXTURE_MANAGER_H -#define TEXTURE_MANAGER_TEXTURE_MANAGER_H +#ifndef TEXTURE_MANAGER_INCLUDE_TEXTURE_MANAGER_H +#define TEXTURE_MANAGER_INCLUDE_TEXTURE_MANAGER_H +#include #include #include -#include - namespace wolfenstein { struct Texture @@ -51,4 +50,4 @@ class TextureManager } // namespace wolfenstein -#endif // TEXTURE_MANAGER_TEXTURE_MANAGER_H +#endif // TEXTURE_MANAGER_INCLUDE_TEXTURE_MANAGER_H diff --git a/src/TextureManager/src/texture_manager.cpp b/src/TextureManager/src/texture_manager.cpp index aa40662..06a4c30 100644 --- a/src/TextureManager/src/texture_manager.cpp +++ b/src/TextureManager/src/texture_manager.cpp @@ -1,5 +1,5 @@ -#include "TextureManager/texture_manager.h" #include +#include #include namespace wolfenstein { diff --git a/src/TimeManager/include/TimeManager/time_manager.h b/src/TimeManager/include/TimeManager/time_manager.h index 06dcf05..5362081 100644 --- a/src/TimeManager/include/TimeManager/time_manager.h +++ b/src/TimeManager/include/TimeManager/time_manager.h @@ -9,8 +9,8 @@ * */ -#ifndef TIME_MANAGER_TIME_MANAGER_H_ -#define TIME_MANAGER_TIME_MANAGER_H_ +#ifndef TIME_MANAGER_INCLUDE_TIME_MANAGER_H_ +#define TIME_MANAGER_INCLUDE_TIME_MANAGER_H_ #include @@ -37,4 +37,4 @@ class TimeManager } // namespace wolfenstein -#endif // TIME_MANAGER_TIME_MANAGER_H_ \ No newline at end of file +#endif // TIME_MANAGER_INCLUDE_TIME_MANAGER_H_ diff --git a/src/TimeManager/src/time_manager.cpp b/src/TimeManager/src/time_manager.cpp index 9a1bc2e..019e24d 100644 --- a/src/TimeManager/src/time_manager.cpp +++ b/src/TimeManager/src/time_manager.cpp @@ -1,4 +1,4 @@ -#include "TimeManager/time_manager.h" +#include #include namespace wolfenstein { diff --git a/src/Utility/CMakeLists.txt b/src/Utility/CMakeLists.txt index 33efc64..9102ad1 100644 --- a/src/Utility/CMakeLists.txt +++ b/src/Utility/CMakeLists.txt @@ -11,7 +11,6 @@ add_library(utilities src/logger.cpp ) -# Specify include directories for this library target_include_directories(utilities PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include ) @@ -20,7 +19,6 @@ add_library(uuid_generator src/uuid_generator.cpp ) -# Specify include directories for this library target_include_directories(uuid_generator PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR} diff --git a/src/Utility/include/Utility/logger.h b/src/Utility/include/Utility/logger.h index 2c74bd0..353ba6e 100644 --- a/src/Utility/include/Utility/logger.h +++ b/src/Utility/include/Utility/logger.h @@ -9,9 +9,8 @@ * */ -#ifndef UTILITIES_LOGGER_H -#define UTILITIES_LOGGER_H - +#ifndef UTILITIES_INCLUDE_UTILITIES_LOGGER_H +#define UTILITIES_INCLUDE_UTILITIES_LOGGER_H // Debug macro #ifdef DEBUG @@ -52,4 +51,4 @@ } \ } while (0) -#endif // UTILITIES_LOGGER_H +#endif // UTILITIES_INCLUDE_UTILITIES_LOGGER_H diff --git a/src/Utility/include/Utility/uuid_generator.h b/src/Utility/include/Utility/uuid_generator.h index e668ddb..d6aaf2e 100644 --- a/src/Utility/include/Utility/uuid_generator.h +++ b/src/Utility/include/Utility/uuid_generator.h @@ -9,8 +9,8 @@ * */ -#ifndef UTILITY_UUID_GENERATOR_H -#define UTILITY_UUID_GENERATOR_H +#ifndef UTILITY_INCLUDE_UTILITY_UUID_GENERATOR_H +#define UTILITY_INCLUDE_UTILITY_UUID_GENERATOR_H #include @@ -34,4 +34,4 @@ class UuidGenerator } // namespace wolfenstein -#endif // UTILITY_UUID_GENERATOR_H \ No newline at end of file +#endif // UTILITY_INCLUDE_UTILITY_UUID_GENERATOR_H \ No newline at end of file diff --git a/src/Utility/src/logger.cpp b/src/Utility/src/logger.cpp index 8fbc7dc..f3d68f8 100644 --- a/src/Utility/src/logger.cpp +++ b/src/Utility/src/logger.cpp @@ -1 +1 @@ -#include "Utility/logger.h" \ No newline at end of file +#include \ No newline at end of file diff --git a/src/Utility/src/uuid_generator.cpp b/src/Utility/src/uuid_generator.cpp index c5f1624..d5eb86c 100644 --- a/src/Utility/src/uuid_generator.cpp +++ b/src/Utility/src/uuid_generator.cpp @@ -1,4 +1,4 @@ -#include "Utility/uuid_generator.h" +#include namespace wolfenstein { From 20ecc64d2495a803c2405e843ee41841e198fc09 Mon Sep 17 00:00:00 2001 From: Bilal Kahraman Date: Sun, 18 Aug 2024 01:57:12 +0300 Subject: [PATCH 5/5] Fix naming core and graphics --- src/Core/include/Core/game.h | 6 +++--- src/Core/src/game.cpp | 6 +++--- src/Graphics/include/Graphics/renderer.h | 10 +++++----- src/Graphics/include/Graphics/scene.h | 10 +++++----- src/Graphics/src/renderer.cpp | 10 +++++----- src/Graphics/src/scene.cpp | 2 +- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/Core/include/Core/game.h b/src/Core/include/Core/game.h index 4210bf4..718413a 100644 --- a/src/Core/include/Core/game.h +++ b/src/Core/include/Core/game.h @@ -9,8 +9,8 @@ * */ -#ifndef CORE_GAME_H_ -#define CORE_GAME_H_ +#ifndef CORE_INCLUDE_CORE_GAME_H_ +#define CORE_INCLUDE_CORE_GAME_H_ #include #include @@ -65,4 +65,4 @@ class Game } // namespace wolfenstein -#endif // CORE_GAME_H_ +#endif // CORE_INCLUDE_CORE_GAME_H_ diff --git a/src/Core/src/game.cpp b/src/Core/src/game.cpp index 218a235..9cb84b4 100644 --- a/src/Core/src/game.cpp +++ b/src/Core/src/game.cpp @@ -1,6 +1,6 @@ -#include "Core/game.h" -#include "Graphics/renderer.h" -#include "Math/vector.h" +#include +#include +#include #include #include diff --git a/src/Graphics/include/Graphics/renderer.h b/src/Graphics/include/Graphics/renderer.h index 4561737..fe2a6b8 100644 --- a/src/Graphics/include/Graphics/renderer.h +++ b/src/Graphics/include/Graphics/renderer.h @@ -9,12 +9,12 @@ * */ -#ifndef GRAPHICS_RENDERER_H_ -#define GRAPHICS_RENDERER_H_ +#ifndef GRAPHICS_INCLUDE_GRAPHICS_RENDERER_H_ +#define GRAPHICS_INCLUDE_GRAPHICS_RENDERER_H_ -#include "GameObjects/game_object.h" -#include "scene.h" #include +#include +#include #include #include #include @@ -109,4 +109,4 @@ class Renderer }; } // namespace wolfenstein -#endif // GRAPHICS_RENDERER_H_ +#endif // GRAPHICS_INCLUDE_GRAPHICS_RENDERER_H_ diff --git a/src/Graphics/include/Graphics/scene.h b/src/Graphics/include/Graphics/scene.h index 8bdd68d..59a1f44 100644 --- a/src/Graphics/include/Graphics/scene.h +++ b/src/Graphics/include/Graphics/scene.h @@ -9,14 +9,14 @@ * */ -#ifndef GRAPHICS_SCENE_H_ -#define GRAPHICS_SCENE_H_ +#ifndef GRAPHICS_INCLUDE_GRAPHICS_SCENE_H_ +#define GRAPHICS_INCLUDE_GRAPHICS_SCENE_H_ #include #include -#include "GameObjects/game_object.h" -#include "Map/map.h" +#include +#include namespace wolfenstein { @@ -40,4 +40,4 @@ class Scene } // namespace wolfenstein -#endif // GRAPHICS_SCENE_H_ \ No newline at end of file +#endif // GRAPHICS_INCLUDE_GRAPHICS_SCENE_H_ \ No newline at end of file diff --git a/src/Graphics/src/renderer.cpp b/src/Graphics/src/renderer.cpp index 299540a..a117b80 100644 --- a/src/Graphics/src/renderer.cpp +++ b/src/Graphics/src/renderer.cpp @@ -1,9 +1,9 @@ -#include "Graphics/renderer.h" -#include "Camera/ray.h" -#include "GameObjects/static_object.h" -#include "Map/map.h" -#include "Math/vector.h" +#include #include +#include +#include +#include +#include #include #include #include diff --git a/src/Graphics/src/scene.cpp b/src/Graphics/src/scene.cpp index 46eea69..78808ab 100644 --- a/src/Graphics/src/scene.cpp +++ b/src/Graphics/src/scene.cpp @@ -1,4 +1,4 @@ -#include "Graphics/scene.h" +#include namespace wolfenstein {