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:
authorCampbell Barton <ideasman42@gmail.com>2016-02-13 09:58:44 +0300
committerCampbell Barton <ideasman42@gmail.com>2016-02-13 10:59:56 +0300
commit2c2d52c2dea1647b84f2d0808ee1834484a6d48d (patch)
treeb6e628fff5126675263f9951b47068a8a6e20052 /source/blender/blenkernel/intern
parent12b996e61b0b6805d1880ad94fe4e192fc6f41ae (diff)
Optimize sculpt undo, avoid redundant updates
On undo, sculpting regular meshes would update _all_ GPU VBO's. Avoiding the update gives noticeably faster undo. This is also a fix/workaround for strange behavior with NVidia's driver (T47232), Where locking and unlocking all buffers for updating slows down redraw speed permanently after the first undo. However the problem isn't avoided entirely since a single brush stroke might modify most of the mesh.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/pbvh.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 00c22e17230..e89873a8a1f 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -1474,6 +1474,30 @@ void BKE_pbvh_node_get_bm_orco_data(
*r_orco_coords = node->bm_orco;
}
+/**
+ * \note doing a full search on all vertices here seems expensive,
+ * however this is important to avoid having to recalculate boundbox & sync the buffers to the GPU
+ * (which is far more expensive!) See: T47232.
+ */
+bool BKE_pbvh_node_vert_update_check_any(PBVH *bvh, PBVHNode *node)
+{
+ BLI_assert(bvh->type == PBVH_FACES);
+ const int *verts = node->vert_indices;
+ const int totvert = node->uniq_verts + node->face_verts;
+
+ for (int i = 0; i < totvert; ++i) {
+ const int v = verts[i];
+ const MVert *mvert = &bvh->verts[v];
+
+ if (mvert->flag & ME_VERT_PBVH_UPDATE) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
/********************************* Raycast ***********************************/
typedef struct {
@@ -1914,8 +1938,11 @@ void BKE_pbvh_apply_vertCos(PBVH *pbvh, float (*vertCos)[3])
MVert *mvert = pbvh->verts;
/* copy new verts coords */
for (int a = 0; a < pbvh->totvert; ++a, ++mvert) {
- copy_v3_v3(mvert->co, vertCos[a]);
- mvert->flag |= ME_VERT_PBVH_UPDATE;
+ /* no need for float comparison here (memory is exactly equal or not) */
+ if (memcmp(mvert->co, vertCos[a], sizeof(float[3])) != 0) {
+ copy_v3_v3(mvert->co, vertCos[a]);
+ mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
/* coordinates are new -- normals should also be updated */