diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-09-14 11:56:54 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-09-14 15:43:56 +0300 |
commit | 8e8952b7e363b878cfc97440c1d2254dffbaf840 (patch) | |
tree | 3e313cc676d5c0073ca17810fe818542ee8dc41b /source/blender/blenkernel/intern/multires.c | |
parent | 744233f2078fca85986bc98c7b72393fda9ca58e (diff) |
Multires: Initial work to get sculpting to work with OpenSubdiv
Allows to go to sculpt mode, do brush strokes, get out of sculpt mode
and have deformation preserved.
The issues currently is that the current implementation of CCG
storage is created from the limit surface, without displacement
taken into account. It is trivial to get displaced coordinates,
but it is more tricky to get displaced normals. This is something
to be solved next.
Another limitation is that this only works for sculpting at a maximal
multires level. There is code to be done to support propagation
of displacement onto a higher levels.
Diffstat (limited to 'source/blender/blenkernel/intern/multires.c')
-rw-r--r-- | source/blender/blenkernel/intern/multires.c | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 22a335c7fd4..4dd64e3d8b2 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -57,6 +57,7 @@ #include "BKE_multires.h" #include "BKE_paint.h" #include "BKE_scene.h" +#include "BKE_subdiv_ccg.h" #include "BKE_subsurf.h" #include "BKE_editmesh.h" @@ -389,21 +390,46 @@ static void multires_dm_mark_as_modified(DerivedMesh *dm, MultiresModifiedFlags ccgdm->multires.modified_flags |= flags; } +static void multires_ccg_mark_as_modified(SubdivCCG *subdiv_ccg, + MultiresModifiedFlags flags) +{ + if (flags & MULTIRES_COORDS_MODIFIED) { + subdiv_ccg->dirty.coords = true; + } + if (flags & MULTIRES_HIDDEN_MODIFIED) { + subdiv_ccg->dirty.hidden = true; + } +} + void multires_mark_as_modified(Object *ob, MultiresModifiedFlags flags) { - if (ob && ob->derivedFinal) - multires_dm_mark_as_modified(ob->derivedFinal, flags); + if (ob == NULL) { + return; + } + Mesh *mesh = ob->data; + SubdivCCG *subdiv_ccg = mesh->runtime.subsurf_ccg; + if (subdiv_ccg == NULL) { + return; + } + multires_ccg_mark_as_modified(subdiv_ccg, flags); } void multires_force_update(Object *ob) { - if (ob) { - BKE_object_free_derived_caches(ob); - - if (ob->sculpt && ob->sculpt->pbvh) { - BKE_pbvh_free(ob->sculpt->pbvh); - ob->sculpt->pbvh = NULL; + if (ob == NULL) { + return; + } + if (ob->sculpt && ob->sculpt->pbvh) { + PBVH *pbvh = ob->sculpt->pbvh; + if (BKE_pbvh_type(pbvh) == PBVH_GRIDS) { + multiresModifier_reshapeFromCCG(ob, ob->sculpt->subdiv_ccg); + } + else { + /* NOTE: Disabled for until OpenSubdiv is enabled by default. */ + // BLI_assert(!"multires_force_update is used on non-grids PBVH"); } + BKE_pbvh_free(pbvh); + ob->sculpt->pbvh = NULL; } } |