[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53914] trunk/blender/source/blender: Update object bounding box during sculpt

Nicholas Bishop nicholasbishop at gmail.com
Sun Jan 20 01:20:01 CET 2013


Revision: 53914
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53914
Author:   nicholasbishop
Date:     2013-01-20 00:19:57 +0000 (Sun, 20 Jan 2013)
Log Message:
-----------
Update object bounding box during sculpt

Fixes the sculpt object being incorrectly clipped during drawing due
to an out-of-date bounding box making it seem that the object had gone
outside the view.

Added a BKE_pbvh function to get the top-level bounding box. In
sculpt_flush_update(), where the PBVH bounds are updated, the result
is copied to the object's bounding box.

Fixes bug [#33790]
projects.blender.org/tracker/?func=detail&aid=33790&group_id=9&atid=498

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_pbvh.h
    trunk/blender/source/blender/blenkernel/intern/pbvh.c
    trunk/blender/source/blender/editors/sculpt_paint/sculpt.c

Modified: trunk/blender/source/blender/blenkernel/BKE_pbvh.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_pbvh.h	2013-01-19 23:52:33 UTC (rev 53913)
+++ trunk/blender/source/blender/blenkernel/BKE_pbvh.h	2013-01-20 00:19:57 UTC (rev 53914)
@@ -113,6 +113,9 @@
 
 PBVHType BKE_pbvh_type(const PBVH *bvh);
 
+/* Get the PBVH root's bounding box */
+void BKE_pbvh_bounding_box(const PBVH *bvh, float min[3], float max[3]);
+
 /* multires hidden data, only valid for type == PBVH_GRIDS */
 unsigned int **BKE_pbvh_grid_hidden(const PBVH *bvh);
 

Modified: trunk/blender/source/blender/blenkernel/intern/pbvh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/pbvh.c	2013-01-19 23:52:33 UTC (rev 53913)
+++ trunk/blender/source/blender/blenkernel/intern/pbvh.c	2013-01-20 00:19:57 UTC (rev 53914)
@@ -1238,6 +1238,19 @@
 	return bvh->type;
 }
 
+void BKE_pbvh_bounding_box(const PBVH *bvh, float min[3], float max[3])
+{
+	if (bvh->totnode) {
+		const BB *bb = &bvh->nodes[0].vb;
+		copy_v3_v3(min, bb->bmin);
+		copy_v3_v3(max, bb->bmax);
+	}
+	else {
+		zero_v3(min);
+		zero_v3(max);
+	}
+}
+
 BLI_bitmap *BKE_pbvh_grid_hidden(const PBVH *bvh)
 {
 	BLI_assert(bvh->type == PBVH_GRIDS);

Modified: trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/sculpt.c	2013-01-19 23:52:33 UTC (rev 53913)
+++ trunk/blender/source/blender/editors/sculpt_paint/sculpt.c	2013-01-20 00:19:57 UTC (rev 53914)
@@ -4180,6 +4180,17 @@
 	}
 }
 
+/* Copy the PBVH bounding box into the object's bounding box */
+static void sculpt_update_object_bounding_box(Object *ob)
+{
+	if (ob->bb) {
+		float bb_min[3], bb_max[3];
+
+		BKE_pbvh_bounding_box(ob->sculpt->pbvh, bb_min, bb_max);
+		BKE_boundbox_init_from_minmax(ob->bb, bb_min, bb_max);
+	}
+}
+
 static void sculpt_flush_update(bContext *C)
 {
 	Object *ob = CTX_data_active_object(C);
@@ -4200,6 +4211,11 @@
 		rcti r;
 
 		BKE_pbvh_update(ss->pbvh, PBVH_UpdateBB, NULL);
+		/* Update the object's bounding box too so that the object
+		 * doesn't get incorrectly clipped during drawing in
+		 * draw_mesh_object(). [#33790] */
+		sculpt_update_object_bounding_box(ob);
+
 		if (sculpt_get_redraw_rect(ar, CTX_wm_region_view3d(C), ob, &r)) {
 			if (ss->cache)
 				ss->cache->previous_r = r;




More information about the Bf-blender-cvs mailing list