diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-08-03 17:44:46 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-08-03 17:44:46 +0300 |
commit | e5f7b0f330c09d6944969a0cc1e496ca112f0711 (patch) | |
tree | 94302281fda57fea1121ae39ca9b33dc471aa838 /source/blender/blenkernel/intern/subsurf_ccg.c | |
parent | 4a0f3bece31be4997dd19c8ee8faa5ae6a1914e3 (diff) |
OpenSubdiv: Avoid crashes when GPU subsurf is tried to be used on CPU
The issue was caused by CCG code being confused by number of geometry returned
by utility functions in the case of the skipped grids.
Made it so that code is always only working with CCG data and handled drawing
code in a bit special way now.
This solves such crashes as i.e. snapping.
Diffstat (limited to 'source/blender/blenkernel/intern/subsurf_ccg.c')
-rw-r--r-- | source/blender/blenkernel/intern/subsurf_ccg.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 71e14eba690..cfc9c32e81e 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -4551,13 +4551,20 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, DerivedMesh *dm, bool use_gpu_backend) { +#ifdef WITH_OPENSUBDIV + const int totedge = dm->getNumEdges(dm); + const int totface = dm->getNumPolys(dm); +#else const int totedge = ccgSubSurf_getNumEdges(ss); const int totface = ccgSubSurf_getNumFaces(ss); +#endif CCGDerivedMesh *ccgdm = MEM_callocN(sizeof(*ccgdm), "ccgdm"); int numTex, numCol; int hasPCol, hasOrigSpace; if (use_gpu_backend == false) { + BLI_assert(totedge == ccgSubSurf_getNumEdges(ss)); + BLI_assert(totface == ccgSubSurf_getNumFaces(ss)); DM_from_template(&ccgdm->dm, dm, DM_TYPE_CCGDM, ccgSubSurf_getNumFinalVerts(ss), ccgSubSurf_getNumFinalEdges(ss), |