mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 00:08:53 +02:00
take care for division by zero when normalizing
This commit is contained in:
parent
7642e9fd1e
commit
e46c15401a
1 changed files with 5 additions and 1 deletions
|
@ -90,7 +90,11 @@ bool copyShapeToMesh(const btTransform& transform, const btConvexShape* shape,
|
||||||
avgVertex = transform * (avgVertex * (1.0f / (float)numHullVertices));
|
avgVertex = transform * (avgVertex * (1.0f / (float)numHullVertices));
|
||||||
|
|
||||||
for (int i = 0; i < numHullVertices; ++i) {
|
for (int i = 0; i < numHullVertices; ++i) {
|
||||||
btVector3 norm = (transform * hullVertices[i] - avgVertex).normalize();
|
btVector3 norm = transform * hullVertices[i] - avgVertex;
|
||||||
|
btScalar normLength = norm.length();
|
||||||
|
if (normLength > FLT_EPSILON) {
|
||||||
|
norm /= normLength;
|
||||||
|
}
|
||||||
memcpy(tempVertices + 3 * i, norm.m_floats, SIZE_OF_VEC3);
|
memcpy(tempVertices + 3 * i, norm.m_floats, SIZE_OF_VEC3);
|
||||||
}
|
}
|
||||||
gpu::BufferView::Size numBytes = sizeof(float) * (3 * numHullVertices);
|
gpu::BufferView::Size numBytes = sizeof(float) * (3 * numHullVertices);
|
||||||
|
|
Loading…
Reference in a new issue