diff --git a/resources/Schema/Components/Collidable.xml b/resources/Schema/Components/Collidable.xml
index 7bd60939..9046ea99 100644
--- a/resources/Schema/Components/Collidable.xml
+++ b/resources/Schema/Components/Collidable.xml
@@ -1,4 +1,3 @@
- true
\ No newline at end of file
diff --git a/resources/Schema/Components/Collidable.xsd b/resources/Schema/Components/Collidable.xsd
index 2dd49a20..93f7ac24 100644
--- a/resources/Schema/Components/Collidable.xsd
+++ b/resources/Schema/Components/Collidable.xsd
@@ -7,10 +7,5 @@
Needs a Model or AABB component to work, uses AABB if both are attached.
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Engine/Collision/Collision.cpp b/src/Engine/Collision/Collision.cpp
index 68d99d92..31768efd 100644
--- a/src/Engine/Collision/Collision.cpp
+++ b/src/Engine/Collision/Collision.cpp
@@ -470,6 +470,7 @@ bool AABBvsTriangle(const AABB& box,
}
glm::vec3 cornerResolution = (1+t) * diagonal;
+ cornerResolution = glm::dot(cornerResolution, triNormal) * triNormal;
//Overwrite the smallest resolution if cornerResolution is smaller.
float lenSq = glm::length2(cornerResolution);
if (lenSq < resolveShortest.DistanceSq) {
diff --git a/src/Engine/Collision/CollisionSystem.cpp b/src/Engine/Collision/CollisionSystem.cpp
index 8333a9ae..1c52209f 100644
--- a/src/Engine/Collision/CollisionSystem.cpp
+++ b/src/Engine/Collision/CollisionSystem.cpp
@@ -66,7 +66,7 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
}
}
}
- bool& jitterGuard = (bool&)entity["Collidable"]["JitterGuard"];
+
// Collide against octree items
m_OctreeResult.clear();
m_Octree->ObjectsInSameRegion(*boundingBox, m_OctreeResult);
@@ -88,12 +88,11 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
glm::mat4 modelMatrix = Transform::ModelMatrix(boxB.Entity);
glm::vec3 inOutVelocity = (glm::vec3)cPhysics["Velocity"];
- bool notMovingxz = glm::all(glm::lessThan(glm::abs(glm::vec2(inOutVelocity.x, inOutVelocity.z)), glm::vec2(0.01f))) && prevPosIt != m_PrevPositions.end();
bool isOnGround = (bool)cPhysics["IsOnGround"];
float verticalStepHeight = (float)(double)cPhysics["VerticalStepHeight"];
if (Collision::AABBvsTriangles(boxA, model->Vertices(), model->m_Indices, modelMatrix, inOutVelocity, verticalStepHeight, isOnGround, resolutionVector)) {
//Move the position to previous position if it is not moving in the xz-plane, else resolve with the resolution vector.
- (glm::vec3&)cTransform["Position"] += jitterGuard && notMovingxz ? prevPosIt->second - boxA.Origin() : resolutionVector;
+ (glm::vec3&)cTransform["Position"] += resolutionVector;
boxA = *Collision::EntityAbsoluteAABB(entity);
cPhysics["Velocity"] = inOutVelocity;
if (isOnGround) {
@@ -118,7 +117,6 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
(bool)cPhysics["IsOnGround"] = false;
}
- jitterGuard = true;
m_PrevPositions[entity] = boxA.Origin();
}
}
diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp
index b0ad37ea..743a8af2 100644
--- a/src/Game/Systems/PlayerMovementSystem.cpp
+++ b/src/Game/Systems/PlayerMovementSystem.cpp
@@ -273,14 +273,10 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
size = glm::vec3(1.f, 1.f, 1.f);
} else {
size = glm::vec3(1.f, 1.6f, 1.f);
- if (controller->CrouchingLastFrame() && player.HasComponent("Collidable")) {
- // Disable jitter guard so player doesn't get stuck in the ground.
- (bool&)player["Collidable"]["JitterGuard"] = false;
- if (isOnGround) {
- // The collision should resolve this anyway, but
- // this is more reliable, since the box gets larger.
- ((glm::vec3&)cTransform["Position"]).y += 0.3f;
- }
+ if (controller->CrouchingLastFrame() && isOnGround) {
+ // The collision should resolve this anyway, but
+ // this is more reliable, since the box gets larger.
+ ((glm::vec3&)cTransform["Position"]).y += 0.3f;
}
}
}