Fixed so players don't teleport to (NaN, NaN, NaN) on spawning.
This commit is contained in:
@@ -102,7 +102,7 @@ public:
|
|||||||
m_ExtraMemory.push_back((char*)malloc(m_Stride));
|
m_ExtraMemory.push_back((char*)malloc(m_Stride));
|
||||||
//We should preferably not enter here to avoid performance issues. Set more numMaxElements in constructor instead.
|
//We should preferably not enter here to avoid performance issues. Set more numMaxElements in constructor instead.
|
||||||
if (!DisableMemoryPool::Value) {
|
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();
|
return m_ExtraMemory.back();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -412,7 +412,6 @@ bool AABBvsTriangle(const AABB& box,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool groundCollision = triNormal.y > 0.5f;
|
bool groundCollision = triNormal.y > 0.5f;
|
||||||
//ImGui::Text(groundCollision ? "Ground" : "Slope");
|
|
||||||
|
|
||||||
glm::vec3 projNorm;
|
glm::vec3 projNorm;
|
||||||
switch (resolveCase) {
|
switch (resolveCase) {
|
||||||
@@ -446,14 +445,12 @@ bool AABBvsTriangle(const AABB& box,
|
|||||||
if (groundCollision) {
|
if (groundCollision) {
|
||||||
float len = glm::length2(boxVelocity);
|
float len = glm::length2(boxVelocity);
|
||||||
if (len > 0.0001f) {
|
if (len > 0.0001f) {
|
||||||
len = glm::sqrt(len);
|
boxVelocity = glm::sqrt(len) * wantDirection;
|
||||||
boxVelocity = len * glm::normalize(wantDirection);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
len = glm::length(outVector);
|
len = glm::length(outVector);
|
||||||
float ang = glm::half_pi<float>() - glm::acos(outVector.y / len);
|
float ang = glm::half_pi<float>() - glm::acos(outVector.y / len);
|
||||||
if (len > 0.0000001f && ang > 0.0000001f) {
|
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.x = 0;
|
||||||
outVector.y = len / glm::sin(ang);
|
outVector.y = len / glm::sin(ang);
|
||||||
outVector.z = 0;
|
outVector.z = 0;
|
||||||
@@ -475,7 +472,9 @@ bool AABBvsTriangles(const AABB& box,
|
|||||||
outResolutionVector = glm::vec3(0.f);
|
outResolutionVector = glm::vec3(0.f);
|
||||||
glm::vec3 wantDirection(boxVelocity);
|
glm::vec3 wantDirection(boxVelocity);
|
||||||
wantDirection.y = 0;
|
wantDirection.y = 0;
|
||||||
wantDirection = glm::normalize(wantDirection);
|
if (vectorHasLength(wantDirection)) {
|
||||||
|
wantDirection = glm::normalize(wantDirection);
|
||||||
|
}
|
||||||
for (int i = 0; i < modelIndices.size(); ) {
|
for (int i = 0; i < modelIndices.size(); ) {
|
||||||
std::array<glm::vec3, 3> triVertices = {
|
std::array<glm::vec3, 3> triVertices = {
|
||||||
Transform::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix),
|
Transform::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix),
|
||||||
|
|||||||
Reference in New Issue
Block a user