Debug cleanup and some bug fixes.

This commit is contained in:
William Moberg
2016-02-05 14:38:08 +01:00
parent d61e605093
commit 4fe9e4f1c3
2 changed files with 13 additions and 83 deletions
+8 -20
View File
@@ -39,26 +39,14 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
glm::vec3 inOutVelocity = (glm::vec3)cPhysics["Velocity"];
bool isOnGround = (bool)cPhysics["IsOnGround"];
//glm::vec3 gravity = glm::vec3(0, 9.82f * dt, 0);
//TODO: glm::abs(inOutVelocity - gravity) doesn't work, because of velocity projection on ground normal.
//if (!isOnGround || glm::any(glm::greaterThan(glm::abs(inOutVelocity - gravity), glm::vec3(0.0001f)))) {
float verticalStepHeight = (float)(double)cPhysics["VerticalStepHeight"];
if (Collision::AABBvsTriangles(boxA, model->m_Vertices, model->m_Indices, modelMatrix, inOutVelocity, verticalStepHeight, isOnGround, resolutionVector)) {
glm::vec3 pos = (glm::vec3)cTransform["Position"] + resolutionVector;
//Hack: Force the position to be at discrete values after collision, removes jittering.
//constexpr float discreteValue = 1.0e2f;
//pos = glm::vec3(glm::ivec3(discreteValue * pos)) / discreteValue;
//pos = glm::round(discreteValue * pos) / discreteValue;
(glm::vec3&)cTransform["Position"] = pos;
cPhysics["Velocity"] = inOutVelocity;
(bool)cPhysics["IsOnGround"] = isOnGround;
} else {
(bool)cPhysics["IsOnGround"] = false;
}
//} else {
// (glm::vec3&)cTransform["Position"] -= gravity;
// cPhysics["Velocity"] = glm::vec3(0.f);
//}
float verticalStepHeight = (float)(double)cPhysics["VerticalStepHeight"];
if (Collision::AABBvsTriangles(boxA, model->m_Vertices, model->m_Indices, modelMatrix, inOutVelocity, verticalStepHeight, isOnGround, resolutionVector)) {
(glm::vec3&)cTransform["Position"] += resolutionVector;
cPhysics["Velocity"] = inOutVelocity;
(bool)cPhysics["IsOnGround"] = isOnGround;
} else {
(bool)cPhysics["IsOnGround"] = false;
}
} else if (Collision::AABBVsAABB(boxA, boxB, resolutionVector)) {
//Enter here if boxB has no Model.
(glm::vec3&)cTransform["Position"] += resolutionVector;