[Bf-blender-cvs] [45b4506] master: Cleanup a bit of the locked shape keys painting
Sergey Sharybin
noreply at git.blender.org
Tue May 6 14:52:30 CEST 2014
Commit: 45b4506c0dc6e1acdd40e03be3e4fe50128ed928
Author: Sergey Sharybin
Date: Tue May 6 14:49:50 2014 +0200
https://developer.blender.org/rB45b4506c0dc6e1acdd40e03be3e4fe50128ed928
Cleanup a bit of the locked shape keys painting
It's still gives some slowdown when painting a locked
key in the solid view, but since shape key is now longer
being re-used by DM.
but this change should still give some degree of speedup
propagating delta onto the keyblock if i remember the
code correct.
===================================================================
M source/blender/blenkernel/intern/cdderivedmesh.c
M source/blender/editors/sculpt_paint/sculpt.c
===================================================================
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index 7379039..2650fad 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -222,24 +222,33 @@ static const MeshElemMap *cdDM_getPolyMap(Object *ob, DerivedMesh *dm)
return cddm->pmap;
}
-static bool can_pbvh_draw(Object *ob, DerivedMesh *dm)
+static bool check_sculpt_object_deformed(Object *object)
{
- CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
- Mesh *me = ob->data;
- int deformed = 0;
+ bool deformed = false;
- /* active modifiers means extra deformation, which can't be handled correct
+ /* Active modifiers means extra deformation, which can't be handled correct
* on birth of PBVH and sculpt "layer" levels, so use PBVH only for internal brush
- * stuff and show final DerivedMesh so user would see actual object shape */
- deformed |= ob->sculpt->modifiers_active;
+ * stuff and show final DerivedMesh so user would see actual object shape.
+ */
+ deformed |= object->sculpt->modifiers_active;
/* as in case with modifiers, we can't synchronize deformation made against
* PBVH and non-locked keyblock, so also use PBVH only for brushes and
* final DM to give final result to user */
- deformed |= ob->sculpt->kb && (ob->shapeflag & OB_SHAPE_LOCK) == 0;
+ deformed |= object->sculpt->kb && (object->shapeflag & OB_SHAPE_LOCK) == 0;
+
+ return deformed;
+}
- if (deformed)
- return 0;
+static bool can_pbvh_draw(Object *ob, DerivedMesh *dm)
+{
+ CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
+ Mesh *me = ob->data;
+ bool deformed = check_sculpt_object_deformed(ob);
+
+ if (deformed) {
+ return false;
+ }
return cddm->mvert == me->mvert || ob->sculpt->kb;
}
@@ -279,9 +288,8 @@ static 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;
- int deformed = 0;
+ bool deformed;
cddm->pbvh = BKE_pbvh_new();
cddm->pbvh_draw = can_pbvh_draw(ob, dm);
@@ -293,7 +301,7 @@ static PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm)
pbvh_show_diffuse_color_set(cddm->pbvh, ob->sculpt->show_diffuse_color);
- deformed = ss->modifiers_active || me->key;
+ deformed = check_sculpt_object_deformed(ob);
if (deformed && ob->derivedDeform) {
DerivedMesh *deformdm = ob->derivedDeform;
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index df7477e..b75387d 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -198,7 +198,8 @@ static bool sculpt_modifiers_active(Scene *scene, Sculpt *sd, Object *ob)
if (mmd || ob->sculpt->bm)
return 0;
- if (me->key && ob->shapenr)
+ /* non-locked shape keys could be handled in the same way as deformed mesh */
+ if ((ob->shapeflag & OB_SHAPE_LOCK) == 0 && me->key && ob->shapenr)
return 1;
md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
@@ -3423,7 +3424,7 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob)
MEM_freeN(nodes);
/* Modifiers could depend on mesh normals, so we should update them/
- * Note, then if sculpting happens on key, normals should be re-calculated
+ * Note, then if sculpting happens on locked key, normals should be re-calculated
* after applying coords from keyblock on base mesh */
BKE_mesh_calc_normals(me);
}
@@ -4465,7 +4466,7 @@ static void sculpt_flush_update(bContext *C)
if (ob->derivedFinal) /* VBO no longer valid */
GPU_drawobject_free(ob->derivedFinal);
- if (ss->modifiers_active) {
+ if (ss->kb || ss->modifiers_active) {
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
ED_region_tag_redraw(ar);
}
@@ -4566,8 +4567,19 @@ static void sculpt_stroke_update_step(bContext *C, struct PaintStroke *UNUSED(st
/* hack to fix noise texture tearing mesh */
sculpt_fix_noise_tear(sd, ob);
- if (ss->modifiers_active)
+ /* TODO(sergey): This is not really needed for the solid shading,
+ * which does use pBVH drawing anyway, but texture and wireframe
+ * requires this.
+ *
+ * Could be optimized later, but currently don't think it's so
+ * much common scenario.
+ **
+ ** Same applies to the DAG_id_tag_update() invoked from
+ * sculpt_flush_update().
+ */
+ if (ss->kb || ss->modifiers_active) {
sculpt_flush_stroke_deform(sd, ob);
+ }
ss->cache->first_time = false;
More information about the Bf-blender-cvs
mailing list