diff options
-rw-r--r-- | src/crepe/api/LoopManager.cpp | 1 | ||||
-rw-r--r-- | src/crepe/api/Rigidbody.h | 4 | ||||
-rw-r--r-- | src/crepe/api/Script.h | 2 | ||||
-rw-r--r-- | src/crepe/system/CollisionSystem.cpp | 10 | ||||
-rw-r--r-- | src/crepe/system/CollisionSystem.h | 12 | ||||
-rw-r--r-- | src/test/Profiling.cpp | 4 |
6 files changed, 17 insertions, 16 deletions
diff --git a/src/crepe/api/LoopManager.cpp b/src/crepe/api/LoopManager.cpp index b9e91dd..2c12895 100644 --- a/src/crepe/api/LoopManager.cpp +++ b/src/crepe/api/LoopManager.cpp @@ -34,6 +34,7 @@ void LoopManager::start() { void LoopManager::set_running(bool running) { this->game_running = running; } void LoopManager::fixed_update() { + // TODO: retrieve EventManager from direct member after singleton refactor EventManager & ev = this->mediator.event_manager; ev.dispatch_events(); this->get_system<ScriptSystem>().update(); diff --git a/src/crepe/api/Rigidbody.h b/src/crepe/api/Rigidbody.h index b0a24f7..a6aab26 100644 --- a/src/crepe/api/Rigidbody.h +++ b/src/crepe/api/Rigidbody.h @@ -136,8 +136,8 @@ public: /** * \brief Defines the collision layers of a GameObject. * - * The `collision_layers` vector specifies the layers that the GameObject will collide with. - * Each element in the vector represents a layer ID, and the GameObject will only detect + * The `collision_layers` specifies the layers that the GameObject will collide with. + * Each element represents a layer ID, and the GameObject will only detect * collisions with other GameObjects that belong to these layers. */ std::set<int> collision_layers; diff --git a/src/crepe/api/Script.h b/src/crepe/api/Script.h index 1474a09..3d416a1 100644 --- a/src/crepe/api/Script.h +++ b/src/crepe/api/Script.h @@ -3,7 +3,7 @@ #include <vector> #include "../manager/EventManager.h" -#include "system/CollisionSystem.h" +#include "../system/CollisionSystem.h" #include "../manager/Mediator.h" #include "../types.h" #include "../util/OptionalRef.h" diff --git a/src/crepe/system/CollisionSystem.cpp b/src/crepe/system/CollisionSystem.cpp index 44ea7ee..e196e10 100644 --- a/src/crepe/system/CollisionSystem.cpp +++ b/src/crepe/system/CollisionSystem.cpp @@ -158,8 +158,8 @@ CollisionSystem::collision_handler(CollisionInternal & data1, CollisionInternal data1.rigidbody); vec2 collider_pos2 = this->get_current_position(collider2.offset, data2.transform, data2.rigidbody); - resolution = this->get_circle_box_resolution(collider2, collider1, collider_pos2, - collider_pos1,true); + resolution = -this->get_circle_box_resolution(collider2, collider1, collider_pos2, + collider_pos1); break; } case CollisionInternalType::CIRCLE_CIRCLE: { @@ -185,7 +185,7 @@ CollisionSystem::collision_handler(CollisionInternal & data1, CollisionInternal vec2 collider_pos2 = this->get_current_position(collider2.offset, data2.transform, data2.rigidbody); resolution = this->get_circle_box_resolution(collider1, collider2, collider_pos1, - collider_pos2,false); + collider_pos2); break; } } @@ -272,7 +272,7 @@ vec2 CollisionSystem::get_circle_circle_resolution(const CircleCollider & circle vec2 CollisionSystem::get_circle_box_resolution(const CircleCollider & circle_collider, const BoxCollider & box_collider, const vec2 & circle_position, - const vec2 & box_position,bool inverse) const { + const vec2 & box_position) const { vec2 delta = circle_position - box_position; // Compute half-dimensions of the box @@ -294,7 +294,7 @@ vec2 CollisionSystem::get_circle_box_resolution(const CircleCollider & circle_co // Compute penetration depth float penetration_depth = circle_collider.radius - distance; - if(inverse) collision_normal = -collision_normal; + // Compute the resolution vector vec2 resolution = collision_normal * penetration_depth; diff --git a/src/crepe/system/CollisionSystem.h b/src/crepe/system/CollisionSystem.h index b978dbb..6216af9 100644 --- a/src/crepe/system/CollisionSystem.h +++ b/src/crepe/system/CollisionSystem.h @@ -184,7 +184,7 @@ private: vec2 get_circle_box_resolution(const CircleCollider & circle_collider, const BoxCollider & box_collider, const vec2 & circle_position, - const vec2 & box_position,bool inverse) const; + const vec2 & box_position) const; /** * \brief Determines the appropriate collision handler for a collision. @@ -219,14 +219,14 @@ private: /** * \brief Checks if two collision layers have at least one common layer. * - * This function checks if there is any overlapping layer between the two input - * collision layer vectors. It compares each layer from the first vector to see - * if it exists in the second vector. If at least one common layer is found, + * This function checks if there is any overlapping layer between the two inputs. + * It compares each layer from the first input to see + * if it exists in the second input. If at least one common layer is found, * the function returns true, indicating that the two colliders share a common * collision layer. * - * \param layers1 A vector of collision layers for the first collider. - * \param layers2 A vector of collision layers for the second collider. + * \param layers1 all collision layers for the first collider. + * \param layers2 all collision layers for the second collider. * \return Returns true if there is at least one common layer, false otherwise. */ diff --git a/src/test/Profiling.cpp b/src/test/Profiling.cpp index 91be769..6a6c29f 100644 --- a/src/test/Profiling.cpp +++ b/src/test/Profiling.cpp @@ -165,7 +165,7 @@ TEST_F(Profiling, Profiling_2) { gameobject.add_component<BehaviorScript>().set_script<TestScript>(); Color color(0, 0, 0, 0); - auto img = Texture("asset/texture/green_square.png"); + auto img = Texture("asset/texture/square.png"); Sprite & test_sprite = gameobject.add_component<Sprite>( img, color, Sprite::FlipSettings{false, false}, 1, 1, 500); } @@ -198,7 +198,7 @@ TEST_F(Profiling, Profiling_3) { gameobject.add_component<BoxCollider>(vec2{0, 0}, vec2{1, 1}); gameobject.add_component<BehaviorScript>().set_script<TestScript>(); Color color(0, 0, 0, 0); - auto img = Texture("asset/texture/green_square.png"); + auto img = Texture("asset/texture/square.png"); Sprite & test_sprite = gameobject.add_component<Sprite>( img, color, Sprite::FlipSettings{false, false}, 1, 1, 500); auto & test = gameobject.add_component<ParticleEmitter>(ParticleEmitter::Data{ |