diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-12-04 00:22:21 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-12-04 00:22:21 +0400 |
commit | f2ae6b158913e817c0aab43eafb599af337a274e (patch) | |
tree | e860dbb9965e004835cf7bc8dd5f29541cd172f9 /intern/cycles | |
parent | 4344d84c02809e58faaf9516ec6431f3194389c4 (diff) |
Fix #29444: cycles problem building BVH with NaN vertices.
Diffstat (limited to 'intern/cycles')
-rw-r--r-- | intern/cycles/bvh/bvh_build.cpp | 12 | ||||
-rw-r--r-- | intern/cycles/util/util_boundbox.h | 5 | ||||
-rw-r--r-- | intern/cycles/util/util_math.h | 1 |
3 files changed, 12 insertions, 6 deletions
diff --git a/intern/cycles/bvh/bvh_build.cpp b/intern/cycles/bvh/bvh_build.cpp index 67cff3f5873..38674c2c561 100644 --- a/intern/cycles/bvh/bvh_build.cpp +++ b/intern/cycles/bvh/bvh_build.cpp @@ -59,16 +59,18 @@ 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); } - references.push_back(ref); - root.bounds.grow(ref.bounds); + if(ref.bounds.valid()) { + ref.prim_index = j; + ref.prim_object = i; + + references.push_back(ref); + root.bounds.grow(ref.bounds); + } } } diff --git a/intern/cycles/util/util_boundbox.h b/intern/cycles/util/util_boundbox.h index 34cc1d6e11c..b4c5e4e71ca 100644 --- a/intern/cycles/util/util_boundbox.h +++ b/intern/cycles/util/util_boundbox.h @@ -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) diff --git a/intern/cycles/util/util_math.h b/intern/cycles/util/util_math.h index 2f9e00dbfcb..7c56f0fbb12 100644 --- a/intern/cycles/util/util_math.h +++ b/intern/cycles/util/util_math.h @@ -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 |