Fix #29444: cycles problem building BVH with NaN vertices.

This commit is contained in:
Brecht Van Lommel 2011-12-03 20:22:21 +00:00
parent 4344d84c02
commit f2ae6b1589
3 changed files with 12 additions and 6 deletions

@ -59,17 +59,19 @@ void BVHBuild::add_reference_mesh(NodeSpec& root, Mesh *mesh, int i)
Mesh::Triangle t = mesh->triangles[j];
Reference ref;
ref.prim_index = j;
ref.prim_object = i;
for(int k = 0; k < 3; k++) {
float3 pt = mesh->verts[t.v[k]];
ref.bounds.grow(pt);
}
if(ref.bounds.valid()) {
ref.prim_index = j;
ref.prim_object = i;
references.push_back(ref);
root.bounds.grow(ref.bounds);
}
}
}
void BVHBuild::add_reference_object(NodeSpec& root, Object *ob, int i)

@ -21,6 +21,7 @@
#include <float.h>
#include "util_math.h"
#include "util_transform.h"
#include "util_types.h"
@ -71,7 +72,9 @@ public:
bool valid(void) const
{
return (min.x <= max.x) && (min.y <= max.y) && (min.z <= max.z);
return (min.x <= max.x) && (min.y <= max.y) && (min.z <= max.z) &&
!(isnan(min.x) || isnan(min.y) || isnan(min.z)) &&
!(isnan(max.x) || isnan(max.y) || isnan(max.z));
}
BoundBox transformed(const Transform *tfm)

@ -63,6 +63,7 @@ CCL_NAMESPACE_BEGIN
#if(!defined(FREE_WINDOWS))
#define copysignf(x, y) ((float)_copysign(x, y))
#define hypotf(x, y) _hypotf(x, y)
#define isnan(x) _isnan(x)
#endif
#endif