diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2016-07-12 01:01:38 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2016-07-12 01:07:44 +0300 |
commit | cfbd605567f48229a923df382baf6db98fbafc61 (patch) | |
tree | d4218c49672047d6c3b37517034660b3b5dcd966 /intern/cycles/bvh/bvh_sort.cpp | |
parent | 71a57a37b2eebbed53b5335019287b4df9c30519 (diff) | |
parent | 7212ebd09f9720883581221be923ae5e97ff5d76 (diff) |
Merge branch 'master' into blender2.8
Conflicts:
intern/cycles/blender/addon/ui.py
source/blender/blenkernel/BKE_particle.h
source/blender/blenkernel/intern/dynamicpaint.c
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/particle_distribute.c
source/blender/blenkernel/intern/texture.c
source/blender/editors/object/object_add.c
source/blender/editors/object/object_relations.c
source/blender/editors/physics/particle_edit.c
source/blender/editors/physics/particle_object.c
source/blender/editors/transform/transform_snap_object.c
Diffstat (limited to 'intern/cycles/bvh/bvh_sort.cpp')
-rw-r--r-- | intern/cycles/bvh/bvh_sort.cpp | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/intern/cycles/bvh/bvh_sort.cpp b/intern/cycles/bvh/bvh_sort.cpp index e9032c61c3b..e5bcf9995bf 100644 --- a/intern/cycles/bvh/bvh_sort.cpp +++ b/intern/cycles/bvh/bvh_sort.cpp @@ -26,23 +26,27 @@ CCL_NAMESPACE_BEGIN static const int BVH_SORT_THRESHOLD = 4096; -/* Silly workaround for float extended precision that happens when compiling - * on x86, due to one float staying in 80 bit precision register and the other - * not, which causes the strictly weak ordering to break. - */ -#if !defined(__i386__) -# define NO_EXTENDED_PRECISION -#else -# define NO_EXTENDED_PRECISION volatile -#endif - struct BVHReferenceCompare { public: int dim; + const BVHUnaligned *unaligned_heuristic; + const Transform *aligned_space; + + BVHReferenceCompare(int dim, + const BVHUnaligned *unaligned_heuristic, + const Transform *aligned_space) + : dim(dim), + unaligned_heuristic(unaligned_heuristic), + aligned_space(aligned_space) + { + } - explicit BVHReferenceCompare(int dim_) + __forceinline BoundBox get_prim_bounds(const BVHReference& prim) const { - dim = dim_; + return (aligned_space != NULL) + ? unaligned_heuristic->compute_aligned_prim_boundbox( + prim, *aligned_space) + : prim.bounds(); } /* Compare two references. @@ -52,8 +56,10 @@ public: __forceinline int compare(const BVHReference& ra, const BVHReference& rb) const { - NO_EXTENDED_PRECISION float ca = ra.bounds().min[dim] + ra.bounds().max[dim]; - NO_EXTENDED_PRECISION float cb = rb.bounds().min[dim] + rb.bounds().max[dim]; + BoundBox ra_bounds = get_prim_bounds(ra), + rb_bounds = get_prim_bounds(rb); + float ca = ra_bounds.min[dim] + ra_bounds.max[dim]; + float cb = rb_bounds.min[dim] + rb_bounds.max[dim]; if(ca < cb) return -1; else if(ca > cb) return 1; @@ -171,10 +177,15 @@ static void bvh_reference_sort_threaded(TaskPool *task_pool, } } -void bvh_reference_sort(int start, int end, BVHReference *data, int dim) +void bvh_reference_sort(int start, + int end, + BVHReference *data, + int dim, + const BVHUnaligned *unaligned_heuristic, + const Transform *aligned_space) { const int count = end - start; - BVHReferenceCompare compare(dim); + BVHReferenceCompare compare(dim, unaligned_heuristic, aligned_space); if(count < BVH_SORT_THRESHOLD) { /* It is important to not use any mutex if array is small enough, * otherwise we end up in situation when we're going to sleep far |