aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/crepe/api/Rigidbody.h2
-rw-r--r--src/crepe/system/CollisionSystem.cpp46
-rw-r--r--src/crepe/system/CollisionSystem.h6
-rw-r--r--src/example/collisiontest.cpp5
-rw-r--r--src/example/game.cpp4
-rw-r--r--src/test/CMakeLists.txt46
-rw-r--r--src/test/CollisionTest.cpp4
7 files changed, 55 insertions, 58 deletions
diff --git a/src/crepe/api/Rigidbody.h b/src/crepe/api/Rigidbody.h
index 9dbb42b..28c376b 100644
--- a/src/crepe/api/Rigidbody.h
+++ b/src/crepe/api/Rigidbody.h
@@ -121,7 +121,7 @@ public:
* above 0.0.
*
*/
- float elastisity_coefficient = 0.0;
+ float elasticity_coefficient = 0.0;
/**
* \brief Enables collision handling for objects colliding with kinematic objects.
diff --git a/src/crepe/system/CollisionSystem.cpp b/src/crepe/system/CollisionSystem.cpp
index c9c5c58..00b56a4 100644
--- a/src/crepe/system/CollisionSystem.cpp
+++ b/src/crepe/system/CollisionSystem.cpp
@@ -242,7 +242,7 @@ bool CollisionSystem::detect_collision(CollisionInternal & self,CollisionInterna
// For the 'other' collider, the resolution is the opposite direction of 'self'
other.resolution = -self.resolution;
other.resolution_direction = self.resolution_direction;
-
+
// Return true if a collision was detected and resolution was calculated
return true;
}
@@ -402,8 +402,6 @@ CollisionSystem::Direction CollisionSystem::resolution_correction(vec2 & resolut
CollisionSystem::CollisionInfo CollisionSystem::get_collision_info(const CollisionInternal & in_self, const CollisionInternal & in_other) const{
- ComponentManager & mgr = this->mediator.component_manager;
-
crepe::CollisionSystem::ColliderInfo self {
.transform = in_self.info.transform,
.rigidbody = in_self.info.rigidbody,
@@ -470,7 +468,7 @@ void CollisionSystem::determine_collision_handler(const CollisionInfo & info) {
void CollisionSystem::static_collision_handler(const CollisionInfo & info) {
vec2 & transform_pos = info.self.transform.position;
- float elastisity = info.self.rigidbody.data.elastisity_coefficient;
+ float elasticity = info.self.rigidbody.data.elasticity_coefficient;
vec2 & rigidbody_vel = info.self.rigidbody.data.linear_velocity;
// Move object back using calculate move back value
@@ -479,8 +477,8 @@ void CollisionSystem::static_collision_handler(const CollisionInfo & info) {
switch (info.resolution_direction) {
case Direction::BOTH:
//bounce
- if (elastisity > 0) {
- rigidbody_vel = -rigidbody_vel * elastisity;
+ if (elasticity > 0) {
+ rigidbody_vel = -rigidbody_vel * elasticity;
}
//stop movement
else {
@@ -489,8 +487,8 @@ void CollisionSystem::static_collision_handler(const CollisionInfo & info) {
break;
case Direction::Y_DIRECTION:
// Bounce
- if (elastisity > 0) {
- rigidbody_vel.y = -rigidbody_vel.y * elastisity;
+ if (elasticity > 0) {
+ rigidbody_vel.y = -rigidbody_vel.y * elasticity;
}
// Stop movement
else {
@@ -500,8 +498,8 @@ void CollisionSystem::static_collision_handler(const CollisionInfo & info) {
break;
case Direction::X_DIRECTION:
// Bounce
- if (elastisity > 0) {
- rigidbody_vel.x = -rigidbody_vel.x * elastisity;
+ if (elasticity > 0) {
+ rigidbody_vel.x = -rigidbody_vel.x * elasticity;
}
// Stop movement
else {
@@ -519,8 +517,8 @@ void CollisionSystem::dynamic_collision_handler(const CollisionInfo & info) {
vec2 & self_transform_pos = info.self.transform.position;
vec2 & other_transform_pos = info.other.transform.position;
- float self_elastisity = info.self.rigidbody.data.elastisity_coefficient;
- float other_elastisity = info.other.rigidbody.data.elastisity_coefficient;
+ float self_elasticity = info.self.rigidbody.data.elasticity_coefficient;
+ float other_elasticity = info.other.rigidbody.data.elasticity_coefficient;
vec2 & self_rigidbody_vel = info.self.rigidbody.data.linear_velocity;
vec2 & other_rigidbody_vel = info.other.rigidbody.data.linear_velocity;
@@ -529,21 +527,21 @@ void CollisionSystem::dynamic_collision_handler(const CollisionInfo & info) {
switch (info.resolution_direction) {
case Direction::BOTH:
- if (self_elastisity > 0) {
- self_rigidbody_vel = -self_rigidbody_vel * self_elastisity;
+ if (self_elasticity > 0) {
+ self_rigidbody_vel = -self_rigidbody_vel * self_elasticity;
} else {
self_rigidbody_vel = {0, 0};
}
- if (other_elastisity > 0) {
- other_rigidbody_vel = -other_rigidbody_vel * other_elastisity;
+ if (other_elasticity > 0) {
+ other_rigidbody_vel = -other_rigidbody_vel * other_elasticity;
} else {
other_rigidbody_vel = {0, 0};
}
break;
case Direction::Y_DIRECTION:
- if (self_elastisity > 0) {
- self_rigidbody_vel.y = -self_rigidbody_vel.y * self_elastisity;
+ if (self_elasticity > 0) {
+ self_rigidbody_vel.y = -self_rigidbody_vel.y * self_elasticity;
}
// Stop movement
else {
@@ -551,8 +549,8 @@ void CollisionSystem::dynamic_collision_handler(const CollisionInfo & info) {
self_transform_pos.x -= info.resolution.x;
}
- if (other_elastisity > 0) {
- other_rigidbody_vel.y = -other_rigidbody_vel.y * other_elastisity;
+ if (other_elasticity > 0) {
+ other_rigidbody_vel.y = -other_rigidbody_vel.y * other_elasticity;
}
// Stop movement
else {
@@ -561,8 +559,8 @@ void CollisionSystem::dynamic_collision_handler(const CollisionInfo & info) {
}
break;
case Direction::X_DIRECTION:
- if (self_elastisity > 0) {
- self_rigidbody_vel.x = -self_rigidbody_vel.x * self_elastisity;
+ if (self_elasticity > 0) {
+ self_rigidbody_vel.x = -self_rigidbody_vel.x * self_elasticity;
}
// Stop movement
else {
@@ -570,8 +568,8 @@ void CollisionSystem::dynamic_collision_handler(const CollisionInfo & info) {
self_transform_pos.y -= info.resolution.y;
}
- if (other_elastisity > 0) {
- other_rigidbody_vel.x = -other_rigidbody_vel.x * other_elastisity;
+ if (other_elasticity > 0) {
+ other_rigidbody_vel.x = -other_rigidbody_vel.x * other_elasticity;
}
// Stop movement
else {
diff --git a/src/crepe/system/CollisionSystem.h b/src/crepe/system/CollisionSystem.h
index 30340b5..b7808f1 100644
--- a/src/crepe/system/CollisionSystem.h
+++ b/src/crepe/system/CollisionSystem.h
@@ -74,7 +74,7 @@ private:
/**
* \brief A structure to store the collision data of a single collider.
*
- * This structure all components and id that are for needed within this system when calculating or handeling collisions.
+ * This structure all components and id that are for needed within this system when calculating or handling collisions.
* The transform and rigidbody are mostly needed for location and rotation.
* In rigidbody additional info is written about what the body of the object is,
* and how it should respond on a collision.
@@ -160,7 +160,7 @@ private:
/**
* \brief Calls both collision script
*
- * Calls both collision script to let user add additonal handeling or handle full collision.
+ * Calls both collision script to let user add additonal handling or handle full collision.
*
* \param info Collision information containing data about both colliders.
*/
@@ -218,7 +218,7 @@ private:
* \param other_rigidbody Rigidbody of second collider
* \param this_metadata Rigidbody of first object
* \param other_metadata Rigidbody of second object
- * \return Returns true if there is at least one comparision found.
+ * \return Returns true if there is at least one comparison found.
*/
bool should_collide(const CollisionInternal & self, const CollisionInternal & other) const; //done
diff --git a/src/example/collisiontest.cpp b/src/example/collisiontest.cpp
index 95999c6..b0cb92e 100644
--- a/src/example/collisiontest.cpp
+++ b/src/example/collisiontest.cpp
@@ -75,8 +75,7 @@ class MyScript1 : public Script {
}
break;
- }
- case Keycode::Q: {
+ }case Keycode::Q: {
if(movement){
movement = false;
Rigidbody & tf = this->get_component<Rigidbody>();
@@ -136,7 +135,7 @@ public:
game_object1.add_component<Rigidbody>(Rigidbody::Data{
.gravity_scale = 0,
.body_type = Rigidbody::BodyType::KINEMATIC,
- .elastisity_coefficient = 1,
+ .elasticity_coefficient = 1,
});
// add box with boxcollider
game_object1.add_component<BoxCollider>(vec2{20, 20});
diff --git a/src/example/game.cpp b/src/example/game.cpp
index f757d5f..f5b6f4f 100644
--- a/src/example/game.cpp
+++ b/src/example/game.cpp
@@ -227,7 +227,7 @@ public:
.body_type = Rigidbody::BodyType::DYNAMIC,
.linear_velocity = {0, 0},
.constraints = {0, 0, 0},
- .elastisity_coefficient = 1,
+ .elasticity_coefficient = 1,
});
// add box with boxcollider
game_object1.add_component<BoxCollider>(vec2{20, 20});
@@ -260,7 +260,7 @@ public:
.body_type = Rigidbody::BodyType::STATIC,
.linear_velocity = {0, 0},
.constraints = {0, 0, 0},
- .elastisity_coefficient = 1,
+ .elasticity_coefficient = 1,
});
// add box with boxcollider
game_object2.add_component<BoxCollider>(vec2{20, 20});
diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt
index 61254f1..11b4ca9 100644
--- a/src/test/CMakeLists.txt
+++ b/src/test/CMakeLists.txt
@@ -1,27 +1,27 @@
target_sources(test_main PUBLIC
main.cpp
CollisionTest.cpp
- # PhysicsTest.cpp
- # ScriptTest.cpp
- # ParticleTest.cpp
- # AudioTest.cpp
- # AssetTest.cpp
- # ResourceManagerTest.cpp
- # OptionalRefTest.cpp
- # RenderSystemTest.cpp
- # EventTest.cpp
- # ECSTest.cpp
- # SceneManagerTest.cpp
- # ValueBrokerTest.cpp
- # DBTest.cpp
- # Vector2Test.cpp
- # LoopManagerTest.cpp
- # LoopTimerTest.cpp
- # InputTest.cpp
- # ScriptEventTest.cpp
- # ScriptSceneTest.cpp
- # Profiling.cpp
- # SaveManagerTest.cpp
- # ScriptSaveManagerTest.cpp
- # ScriptECSTest.cpp
+ PhysicsTest.cpp
+ ScriptTest.cpp
+ ParticleTest.cpp
+ AudioTest.cpp
+ AssetTest.cpp
+ ResourceManagerTest.cpp
+ OptionalRefTest.cpp
+ RenderSystemTest.cpp
+ EventTest.cpp
+ ECSTest.cpp
+ SceneManagerTest.cpp
+ ValueBrokerTest.cpp
+ DBTest.cpp
+ Vector2Test.cpp
+ LoopManagerTest.cpp
+ LoopTimerTest.cpp
+ InputTest.cpp
+ ScriptEventTest.cpp
+ ScriptSceneTest.cpp
+ Profiling.cpp
+ SaveManagerTest.cpp
+ ScriptSaveManagerTest.cpp
+ ScriptECSTest.cpp
)
diff --git a/src/test/CollisionTest.cpp b/src/test/CollisionTest.cpp
index a86f7d3..89dfadb 100644
--- a/src/test/CollisionTest.cpp
+++ b/src/test/CollisionTest.cpp
@@ -80,7 +80,7 @@ public:
.body_type = Rigidbody::BodyType::DYNAMIC,
.linear_velocity = {0, 0},
.constraints = {0, 0, 0},
- .elastisity_coefficient = 1,
+ .elasticity_coefficient = 1,
.collision_layers = {0},
});
game_object1.add_component<BoxCollider>(vec2{10, 10}, vec2{0, 0});
@@ -95,7 +95,7 @@ public:
.body_type = Rigidbody::BodyType::DYNAMIC,
.linear_velocity = {0, 0},
.constraints = {0, 0, 0},
- .elastisity_coefficient = 1,
+ .elasticity_coefficient = 1,
.collision_layers = {0},
});
game_object2.add_component<BoxCollider>(vec2{10, 10}, vec2{0, 0});