Fixed so players don't teleport to (NaN, NaN, NaN) on spawning.

This commit is contained in:
William Moberg
2016-02-01 17:01:58 +01:00
parent 30ad238697
commit 5a45f778e6
2 changed files with 5 additions and 6 deletions
+1 -1
View File
@@ -102,7 +102,7 @@ public:
m_ExtraMemory.push_back((char*)malloc(m_Stride));
//We should preferably not enter here to avoid performance issues. Set more numMaxElements in constructor instead.
if (!DisableMemoryPool::Value) {
LOG_WARNING("Allocated slots exceed Pool size, extra memory allocated dynamically. Pool size: %u, dynamic size: %u.", m_NumSlots, m_ExtraMemory.size());
LOG_DEBUG("Allocated slots exceed Pool size, extra memory allocated dynamically. Pool size: %u, dynamic size: %u.", m_NumSlots, m_ExtraMemory.size());
}
return m_ExtraMemory.back();
}
+3 -4
View File
@@ -412,7 +412,6 @@ bool AABBvsTriangle(const AABB& box,
}
bool groundCollision = triNormal.y > 0.5f;
//ImGui::Text(groundCollision ? "Ground" : "Slope");
glm::vec3 projNorm;
switch (resolveCase) {
@@ -446,14 +445,12 @@ bool AABBvsTriangle(const AABB& box,
if (groundCollision) {
float len = glm::length2(boxVelocity);
if (len > 0.0001f) {
len = glm::sqrt(len);
boxVelocity = len * glm::normalize(wantDirection);
boxVelocity = glm::sqrt(len) * wantDirection;
}
len = glm::length(outVector);
float ang = glm::half_pi<float>() - glm::acos(outVector.y / len);
if (len > 0.0000001f && ang > 0.0000001f) {
//ImGui::Text("ang=%f, len=%f, acos=%f, outY=%f", ang, len, glm::acos(outVector.y / len), outVector.y);
outVector.x = 0;
outVector.y = len / glm::sin(ang);
outVector.z = 0;
@@ -475,7 +472,9 @@ bool AABBvsTriangles(const AABB& box,
outResolutionVector = glm::vec3(0.f);
glm::vec3 wantDirection(boxVelocity);
wantDirection.y = 0;
if (vectorHasLength(wantDirection)) {
wantDirection = glm::normalize(wantDirection);
}
for (int i = 0; i < modelIndices.size(); ) {
std::array<glm::vec3, 3> triVertices = {
Transform::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix),