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>2011-05-04 17:15:42 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2011-05-04 17:15:42 +0400
commitd000103e80c076fb5bbdfbc87dc978b5e693564d (patch)
tree17540c107989f234e4b2028c1d273f4a72bbe0f5 /source/blender/blenkernel/intern
parent5d1fdb73ce1457b39df893887951fe6571580897 (diff)
Own TODO item: sculpting on constructive modifiers
- Constructive modifiers are enabled by default in sculpt mode. - There's option to disable all constructive modifiers in the "Options" panel of toolbox in sculpt mode, - Use one column in options panel to make strings easier to read - No modifiers would still be applied on multires
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c13
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c8
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c52
3 files changed, 54 insertions, 19 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 297489ee56f..d9c98bc0200 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -1772,11 +1772,20 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
modifier_setError(md, "Modifier requires original data, bad stack position.");
continue;
}
- if(sculpt_mode && (!has_multires || multires_applied))
- if(mti->type != eModifierTypeType_OnlyDeform || multires_applied) {
+ if(sculpt_mode && (!has_multires || multires_applied)) {
+ int unsupported= 0;
+
+ if(scene->toolsettings->sculpt->flags & SCULPT_ONLY_DEFORM)
+ unsupported|= mti->type != eModifierTypeType_OnlyDeform;
+
+ unsupported|= md->type == eModifierType_Multires && ((MultiresModifierData*)md)->sculptlvl==0;
+ unsupported|= multires_applied;
+
+ if(unsupported) {
modifier_setError(md, "Not supported in sculpt mode.");
continue;
}
+ }
if(needMapping && !modifier_supportsMapping(md)) continue;
if(useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) continue;
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index baf89f9f494..72ee9b55800 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -231,19 +231,21 @@ static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm)
this derivedmesh is just original mesh. it's the multires subsurf dm
that this is actually for, to support a pbvh on a modified mesh */
if(!cddm->pbvh && ob->type == OB_MESH) {
+ SculptSession *ss= ob->sculpt;
Mesh *me= ob->data;
cddm->pbvh = BLI_pbvh_new();
cddm->pbvh_draw = can_pbvh_draw(ob, dm);
BLI_pbvh_build_mesh(cddm->pbvh, me->mface, me->mvert,
me->totface, me->totvert);
- if(ob->sculpt->modifiers_active) {
+ if(ss->modifiers_active && ob->derivedDeform) {
+ DerivedMesh *deformdm= ob->derivedDeform;
float (*vertCos)[3];
int totvert;
- totvert= dm->getNumVerts(dm);
+ totvert= deformdm->getNumVerts(deformdm);
vertCos= MEM_callocN(3*totvert*sizeof(float), "cdDM_getPBVH vertCos");
- dm->getVertCos(dm, vertCos);
+ deformdm->getVertCos(deformdm, vertCos);
BLI_pbvh_apply_vertCos(cddm->pbvh, vertCos);
MEM_freeN(vertCos);
}
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index 33094313acd..5d44841df8b 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -74,6 +74,7 @@
static int ccgDM_getVertMapIndex(CCGSubSurf *ss, CCGVert *v);
static int ccgDM_getEdgeMapIndex(CCGSubSurf *ss, CCGEdge *e);
static int ccgDM_getFaceMapIndex(CCGSubSurf *ss, CCGFace *f);
+static int ccgDM_use_grid_pbvh(CCGDerivedMesh *ccgdm);
///
@@ -1157,7 +1158,7 @@ static void ccgDM_drawVerts(DerivedMesh *dm) {
static void ccgdm_pbvh_update(CCGDerivedMesh *ccgdm)
{
- if(ccgdm->pbvh) {
+ if(ccgdm->pbvh && ccgDM_use_grid_pbvh(ccgdm)) {
CCGFace **faces;
int totface;
@@ -2249,10 +2250,22 @@ static ListBase *ccgDM_getFaceMap(Object *ob, DerivedMesh *dm)
return ccgdm->fmap;
}
+static int ccgDM_use_grid_pbvh(CCGDerivedMesh *ccgdm)
+{
+ MultiresModifierData *mmd= ccgdm->multires.mmd;
+
+ /* both of multires and subsurm modifiers are CCG, but
+ grids should only be used when sculpting on multires */
+ if(!mmd)
+ return 0;
+
+ return 1;
+}
+
static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
{
CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
- int gridSize, numGrids;
+ int gridSize, numGrids, grid_pbvh;
if(!ob) {
ccgdm->pbvh= NULL;
@@ -2262,13 +2275,17 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
if(!ob->sculpt)
return NULL;
+ grid_pbvh= ccgDM_use_grid_pbvh(ccgdm);
+
if(ob->sculpt->pbvh) {
- /* pbvh's grids, gridadj and gridfaces points to data inside ccgdm
- but this can be freed on ccgdm release, this updates the pointers
- when the ccgdm gets remade, the assumption is that the topology
- does not change. */
- ccgdm_create_grids(dm);
- BLI_pbvh_grids_update(ob->sculpt->pbvh, ccgdm->gridData, ccgdm->gridAdjacency, (void**)ccgdm->gridFaces);
+ if(grid_pbvh) {
+ /* pbvh's grids, gridadj and gridfaces points to data inside ccgdm
+ but this can be freed on ccgdm release, this updates the pointers
+ when the ccgdm gets remade, the assumption is that the topology
+ does not change. */
+ ccgdm_create_grids(dm);
+ BLI_pbvh_grids_update(ob->sculpt->pbvh, ccgdm->gridData, ccgdm->gridAdjacency, (void**)ccgdm->gridFaces);
+ }
ccgdm->pbvh = ob->sculpt->pbvh;
}
@@ -2279,14 +2296,21 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
/* no pbvh exists yet, we need to create one. only in case of multires
we build a pbvh over the modified mesh, in other cases the base mesh
is being sculpted, so we build a pbvh from that. */
- ccgdm_create_grids(dm);
+ if(grid_pbvh) {
+ ccgdm_create_grids(dm);
- gridSize = ccgDM_getGridSize(dm);
- numGrids = ccgDM_getNumGrids(dm);
+ gridSize = ccgDM_getGridSize(dm);
+ numGrids = ccgDM_getNumGrids(dm);
- ob->sculpt->pbvh= ccgdm->pbvh = BLI_pbvh_new();
- BLI_pbvh_build_grids(ccgdm->pbvh, ccgdm->gridData, ccgdm->gridAdjacency,
- numGrids, gridSize, (void**)ccgdm->gridFaces);
+ ob->sculpt->pbvh= ccgdm->pbvh = BLI_pbvh_new();
+ BLI_pbvh_build_grids(ccgdm->pbvh, ccgdm->gridData, ccgdm->gridAdjacency,
+ numGrids, gridSize, (void**)ccgdm->gridFaces);
+ } else if(ob->type == OB_MESH) {
+ Mesh *me= ob->data;
+ ob->sculpt->pbvh= ccgdm->pbvh = BLI_pbvh_new();
+ BLI_pbvh_build_mesh(ccgdm->pbvh, me->mface, me->mvert,
+ me->totface, me->totvert);
+ }
return ccgdm->pbvh;
}