OpenSubdiv: Fix crash happening when disabling Use OpenSubdiv option
The issue was caused by the changes from this morning.
This commit is contained in:
@@ -234,6 +234,8 @@ void ccgSubSurf_evaluatorFVarUV(CCGSubSurf *ss,
|
||||
float grid_u, float grid_v,
|
||||
float uv[2]);
|
||||
|
||||
void ccgSubSurf_free_osd_mesh(CCGSubSurf *ss);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* __CCGSUBSURF_H__ */
|
||||
|
||||
@@ -863,4 +863,17 @@ void ccgSubSurf__sync_opensubdiv(CCGSubSurf *ss)
|
||||
#endif
|
||||
}
|
||||
|
||||
void ccgSubSurf_free_osd_mesh(CCGSubSurf *ss)
|
||||
{
|
||||
if (ss->osd_mesh != NULL) {
|
||||
/* TODO(sergey): Make sure free happens form the main thread! */
|
||||
openSubdiv_deleteOsdGLMesh(ss->osd_mesh);
|
||||
ss->osd_mesh = NULL;
|
||||
}
|
||||
if (ss->osd_vao != 0) {
|
||||
glDeleteVertexArrays(1, &ss->osd_vao);
|
||||
ss->osd_vao = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* WITH_OPENSUBDIV */
|
||||
|
||||
@@ -1573,6 +1573,14 @@ static void scene_free_unused_opensubdiv_cache(Scene *scene)
|
||||
if (md != NULL && md->type == eModifierType_Subsurf) {
|
||||
SubsurfModifierData *smd = (SubsurfModifierData *) md;
|
||||
bool object_in_editmode = object->mode == OB_MODE_EDIT;
|
||||
if (!smd->use_opensubdiv) {
|
||||
if (smd->mCache != NULL) {
|
||||
ccgSubSurf_free_osd_mesh(smd->mCache);
|
||||
}
|
||||
if (smd->emCache != NULL) {
|
||||
ccgSubSurf_free_osd_mesh(smd->emCache);
|
||||
}
|
||||
}
|
||||
if (object_in_editmode && smd->mCache != NULL) {
|
||||
ccgSubSurf_free(smd->mCache);
|
||||
smd->mCache = NULL;
|
||||
|
||||
Reference in New Issue
Block a user