Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2015-08-05 15:43:51 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2015-08-05 15:43:51 +0300
commit6cba20a8e60513ce73c4a75f44caafb854b359a1 (patch)
treec661567c8612ea4040c3fb8e7bf7529b43b1f171
parent5b76f72904f83a80525cbea9cca4881358961bc0 (diff)
OpenSubdiv: Tweaks to AABB calculation when using opensubdiv for subsurf
Use coarse coordinates to calculate AABB which gives much better approximation of AABB than using unity AABB size.
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf.h2
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf_opensubdiv.c9
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c23
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c7
4 files changed, 20 insertions, 21 deletions
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.h b/source/blender/blenkernel/intern/CCGSubSurf.h
index 1649cec1e3d..e9ad4c52531 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf.h
+++ b/source/blender/blenkernel/intern/CCGSubSurf.h
@@ -236,6 +236,8 @@ void ccgSubSurf_evaluatorFVarUV(CCGSubSurf *ss,
void ccgSubSurf_free_osd_mesh(CCGSubSurf *ss);
+void ccgSubSurf_getMinMax(CCGSubSurf *ss, float r_min[3], float r_max[3]);
+
#endif
#endif /* __CCGSUBSURF_H__ */
diff --git a/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv.c b/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv.c
index 81f9ea6dc16..882ede09d29 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv.c
+++ b/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv.c
@@ -876,4 +876,13 @@ void ccgSubSurf_free_osd_mesh(CCGSubSurf *ss)
}
}
+void ccgSubSurf_getMinMax(CCGSubSurf *ss, float r_min[3], float r_max[3])
+{
+ int i;
+ BLI_assert(ss->use_grids == false);
+ for (i = 0; i < ss->osd_num_coarse_coords; i++) {
+ DO_MINMAX(ss->osd_coarse_coords[i], r_min, r_max);
+ }
+}
+
#endif /* WITH_OPENSUBDIV */
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index b52bd087fb4..6c13c791da9 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -78,8 +78,6 @@ static DerivedMesh *navmesh_dm_createNavMeshForVisualization(DerivedMesh *dm);
#ifdef WITH_OPENSUBDIV
# include "DNA_userdef_types.h"
-# include "BKE_subsurf.h"
-# include "CCGSubSurf.h"
#endif
/* very slow! enable for testing only! */
@@ -3523,25 +3521,8 @@ void DM_set_object_boundbox(Object *ob, DerivedMesh *dm)
{
float min[3], max[3];
-#ifdef WITH_OPENSUBDIV
- /* TODO(sergey): Currently no way to access bounding box from hi-res mesh. */
- if (dm->type == DM_TYPE_CCGDM) {
- CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
- if (!ccgSubSurf_needGrids(ccgdm->ss)) {
- copy_v3_fl3(min, -1.0f, -1.0f, -1.0f);
- copy_v3_fl3(max, 1.0f, 1.0f, 1.0f);
- }
- else {
- INIT_MINMAX(min, max);
- dm->getMinMax(dm, min, max);
- }
- }
- else
-#endif
- {
- INIT_MINMAX(min, max);
- dm->getMinMax(dm, min, max);
- }
+ INIT_MINMAX(min, max);
+ dm->getMinMax(dm, min, max);
if (!ob->bb)
ob->bb = MEM_callocN(sizeof(BoundBox), "DM-BoundBox");
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index a3e4b47fd15..617bf70c081 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -848,6 +848,13 @@ static void ccgDM_getMinMax(DerivedMesh *dm, float r_min[3], float r_max[3])
int i, edgeSize = ccgSubSurf_getEdgeSize(ss);
int gridSize = ccgSubSurf_getGridSize(ss);
+#ifdef WITH_OPENSUBDIV
+ if (ccgdm->useGpuBackend) {
+ ccgSubSurf_getMinMax(ccgdm->ss, r_min, r_max);
+ return;
+ }
+#endif
+
CCG_key_top_level(&key, ss);
if (!ccgSubSurf_getNumVerts(ss))