diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2014-04-11 15:08:57 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2014-04-11 15:20:41 +0400 |
commit | 15169c71a6cdd819ba1bbdf9f0713082d64d8cdc (patch) | |
tree | 9c0273645eb1755df8d1fce6988197e3a5c235ef /source/blender | |
parent | 4f6c218f1942089e949c1dd4dae7df788d821ae2 (diff) |
Blender Internal: remove BLI BVH for raytracing.
It has no benefits over other BVH types, as far as I know it was only added
because it was possible. This also fixes T39344.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenloader/intern/versioning_270.c | 7 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_scene_types.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 1 | ||||
-rw-r--r-- | source/blender/render/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/render/intern/include/rayobject.h | 1 | ||||
-rw-r--r-- | source/blender/render/intern/raytrace/rayobject_blibvh.cpp | 169 | ||||
-rw-r--r-- | source/blender/render/intern/source/rayshade.c | 2 |
7 files changed, 8 insertions, 175 deletions
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index 82458e17001..d310c836f59 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -138,6 +138,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } if (!MAIN_VERSION_ATLEAST(main, 270, 1)) { + Scene *sce; Object *ob; /* Update Transform constraint (another deg -> rad stuff). */ @@ -152,5 +153,11 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } } + + for (sce = main->scene.first; sce; sce = sce->id.next) { + if (sce->r.raytrace_structure == R_RAYSTRUCTURE_BLIBVH) { + sce->r.raytrace_structure = R_RAYSTRUCTURE_AUTO; + } + } } } diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 0c950ff9ff0..b92aafd610b 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -1299,7 +1299,7 @@ typedef struct Scene { /* raytrace structure */ #define R_RAYSTRUCTURE_AUTO 0 #define R_RAYSTRUCTURE_OCTREE 1 -#define R_RAYSTRUCTURE_BLIBVH 2 +#define R_RAYSTRUCTURE_BLIBVH 2 /* removed */ #define R_RAYSTRUCTURE_VBVH 3 #define R_RAYSTRUCTURE_SIMD_SVBVH 4 /* needs SIMD */ #define R_RAYSTRUCTURE_SIMD_QBVH 5 /* needs SIMD */ diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index ea9dda40488..1d83206f17f 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -4100,7 +4100,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna) static EnumPropertyItem raytrace_structure_items[] = { {R_RAYSTRUCTURE_AUTO, "AUTO", 0, "Auto", "Automatically select acceleration structure"}, {R_RAYSTRUCTURE_OCTREE, "OCTREE", 0, "Octree", "Use old Octree structure"}, - {R_RAYSTRUCTURE_BLIBVH, "BLIBVH", 0, "BLI BVH", "Use BLI K-Dop BVH.c"}, {R_RAYSTRUCTURE_VBVH, "VBVH", 0, "vBVH", "Use vBVH"}, {R_RAYSTRUCTURE_SIMD_SVBVH, "SIMD_SVBVH", 0, "SIMD SVBVH", "Use SIMD SVBVH"}, {R_RAYSTRUCTURE_SIMD_QBVH, "SIMD_QBVH", 0, "SIMD QBVH", "Use SIMD QBVH"}, diff --git a/source/blender/render/CMakeLists.txt b/source/blender/render/CMakeLists.txt index f369e5a2d77..b56c209ca4a 100644 --- a/source/blender/render/CMakeLists.txt +++ b/source/blender/render/CMakeLists.txt @@ -48,7 +48,6 @@ set(SRC intern/raytrace/rayobject_octree.cpp intern/raytrace/rayobject_raycounter.cpp intern/raytrace/rayobject_svbvh.cpp - intern/raytrace/rayobject_blibvh.cpp intern/raytrace/rayobject_instance.cpp intern/raytrace/rayobject_qbvh.cpp intern/raytrace/rayobject_rtbuild.cpp diff --git a/source/blender/render/intern/include/rayobject.h b/source/blender/render/intern/include/rayobject.h index e9514b8585e..63135d01c23 100644 --- a/source/blender/render/intern/include/rayobject.h +++ b/source/blender/render/intern/include/rayobject.h @@ -59,7 +59,6 @@ RayObject *RE_rayobject_octree_create(int ocres, int size); RayObject *RE_rayobject_instance_create(RayObject *target, float transform[4][4], void *ob, void *target_ob); RayObject *RE_rayobject_empty_create(void); -RayObject *RE_rayobject_blibvh_create(int size); /* BLI_kdopbvh.c */ RayObject *RE_rayobject_vbvh_create(int size); /* raytrace/rayobject_vbvh.c */ RayObject *RE_rayobject_svbvh_create(int size); /* raytrace/rayobject_svbvh.c */ RayObject *RE_rayobject_qbvh_create(int size); /* raytrace/rayobject_qbvh.c */ diff --git a/source/blender/render/intern/raytrace/rayobject_blibvh.cpp b/source/blender/render/intern/raytrace/rayobject_blibvh.cpp deleted file mode 100644 index 18e8ba6cd14..00000000000 --- a/source/blender/render/intern/raytrace/rayobject_blibvh.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2009 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): André Pinto. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/render/intern/raytrace/rayobject_blibvh.cpp - * \ingroup render - */ - -#include <assert.h> - -#include "MEM_guardedalloc.h" - -#include "BLI_kdopbvh.h" -#include "BLI_math.h" -#include "BLI_utildefines.h" - -#include "rayintersection.h" -#include "rayobject.h" - -static int RE_rayobject_blibvh_intersect(RayObject *o, Isect *isec); -static void RE_rayobject_blibvh_add(RayObject *o, RayObject *ob); -static void RE_rayobject_blibvh_done(RayObject *o); -static void RE_rayobject_blibvh_free(RayObject *o); -static void RE_rayobject_blibvh_bb(RayObject *o, float min[3], float max[3]); - -static float RE_rayobject_blibvh_cost(RayObject *UNUSED(o)) -{ - //TODO calculate the expected cost to raycast on this structure - return 1.0; -} - -static void RE_rayobject_blibvh_hint_bb(RayObject *UNUSED(o), RayHint *UNUSED(hint), - float *UNUSED(min), float *UNUSED(max)) -{ - return; -} - -static RayObjectAPI bvh_api = -{ - RE_rayobject_blibvh_intersect, - RE_rayobject_blibvh_add, - RE_rayobject_blibvh_done, - RE_rayobject_blibvh_free, - RE_rayobject_blibvh_bb, - RE_rayobject_blibvh_cost, - RE_rayobject_blibvh_hint_bb -}; - -typedef struct BVHObject { - RayObject rayobj; - RayObject **leafs, **next_leaf; - BVHTree *bvh; - float bb[2][3]; -} BVHObject; - -RayObject *RE_rayobject_blibvh_create(int size) -{ - BVHObject *obj = (BVHObject *)MEM_callocN(sizeof(BVHObject), "BVHObject"); - assert(RE_rayobject_isAligned(obj)); /* RayObject API assumes real data to be 4-byte aligned */ - - obj->rayobj.api = &bvh_api; - obj->bvh = BLI_bvhtree_new(size, 0.0, 4, 6); - obj->next_leaf = obj->leafs = (RayObject **)MEM_callocN(size * sizeof(RayObject *), "BVHObject leafs"); - - INIT_MINMAX(obj->bb[0], obj->bb[1]); - return RE_rayobject_unalignRayAPI((RayObject *) obj); -} - -struct BVHCallbackUserData { - Isect *isec; - RayObject **leafs; -}; - -static void bvh_callback(void *userdata, int index, const BVHTreeRay *UNUSED(ray), BVHTreeRayHit *hit) -{ - struct BVHCallbackUserData *data = (struct BVHCallbackUserData *)userdata; - Isect *isec = data->isec; - RayObject *face = data->leafs[index]; - - if (RE_rayobject_intersect(face, isec)) { - hit->index = index; - - if (isec->mode == RE_RAY_SHADOW) - hit->dist = 0; - else - hit->dist = isec->dist; - } -} - -static int RE_rayobject_blibvh_intersect(RayObject *o, Isect *isec) -{ - BVHObject *obj = (BVHObject *)o; - BVHTreeRayHit hit; - float dir[3]; - struct BVHCallbackUserData data; - data.isec = isec; - data.leafs = obj->leafs; - - copy_v3_v3(dir, isec->dir); - - hit.index = 0; - hit.dist = isec->dist; - - return BLI_bvhtree_ray_cast(obj->bvh, isec->start, dir, 0.0, &hit, bvh_callback, (void *)&data); -} - -static void RE_rayobject_blibvh_add(RayObject *o, RayObject *ob) -{ - BVHObject *obj = (BVHObject *)o; - float min_max[6]; - INIT_MINMAX(min_max, min_max + 3); - RE_rayobject_merge_bb(ob, min_max, min_max + 3); - - DO_MIN(min_max, obj->bb[0]); - DO_MAX(min_max + 3, obj->bb[1]); - - BLI_bvhtree_insert(obj->bvh, obj->next_leaf - obj->leafs, min_max, 2); - *(obj->next_leaf++) = ob; -} - -static void RE_rayobject_blibvh_done(RayObject *o) -{ - BVHObject *obj = (BVHObject *)o; - BLI_bvhtree_balance(obj->bvh); -} - -static void RE_rayobject_blibvh_free(RayObject *o) -{ - BVHObject *obj = (BVHObject *)o; - - if (obj->bvh) - BLI_bvhtree_free(obj->bvh); - - if (obj->leafs) - MEM_freeN(obj->leafs); - - MEM_freeN(obj); -} - -static void RE_rayobject_blibvh_bb(RayObject *o, float min[3], float max[3]) -{ - BVHObject *obj = (BVHObject *)o; - DO_MIN(obj->bb[0], min); - DO_MAX(obj->bb[1], max); -} - diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c index 7e6fd04c3f4..61e8eb2dc61 100644 --- a/source/blender/render/intern/source/rayshade.c +++ b/source/blender/render/intern/source/rayshade.c @@ -119,8 +119,6 @@ RayObject *RE_rayobject_create(int type, int size, int octree_resolution) if (type == R_RAYSTRUCTURE_OCTREE) //TODO dynamic ocres res = RE_rayobject_octree_create(octree_resolution, size); - else if (type == R_RAYSTRUCTURE_BLIBVH) - res = RE_rayobject_blibvh_create(size); else if (type == R_RAYSTRUCTURE_VBVH) res = RE_rayobject_vbvh_create(size); else if (type == R_RAYSTRUCTURE_SIMD_SVBVH) |