[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58155] branches/soc-2013-depsgraph_mt/ source/blender: Tag object-data level boundbox as invalid rather than freeing it

Sergey Sharybin sergey.vfx at gmail.com
Wed Jul 10 16:26:32 CEST 2013


Revision: 58155
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58155
Author:   nazgul
Date:     2013-07-10 14:26:31 +0000 (Wed, 10 Jul 2013)
Log Message:
-----------
Tag object-data level boundbox as invalid rather than freeing it

Object update used to free object-data level bounding box to trigger
it's re-calculation in the future. Such a freeing performed from
object update isn't thread-safe because mesh could be shared between
multiple objects.

Rather than freeing bounding box, tag it's as invalid, this is safe
from threading point of view and also prevents unnecessary memory
re-allocation.

Object-level bounding box is still reallocating, but think we could
change this easily in the future as well.

Modified Paths:
--------------
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/mesh.c
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/object.c
    branches/soc-2013-depsgraph_mt/source/blender/editors/space_view3d/view3d_draw.c
    branches/soc-2013-depsgraph_mt/source/blender/editors/space_view3d/view3d_view.c
    branches/soc-2013-depsgraph_mt/source/blender/makesdna/DNA_object_types.h
    branches/soc-2013-depsgraph_mt/source/blender/makesrna/intern/rna_mesh.c

Modified: branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/mesh.c
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/mesh.c	2013-07-10 13:06:31 UTC (rev 58154)
+++ branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/mesh.c	2013-07-10 14:26:31 UTC (rev 58155)
@@ -685,15 +685,16 @@
 	if (ob->bb)
 		return ob->bb;
 
-	if (!me->bb)
+	if (me->bb == NULL || (me->bb->flag & BOUNDBOX_INVALID)) {
 		BKE_mesh_texspace_calc(me);
+	}
 
 	return me->bb;
 }
 
 void BKE_mesh_texspace_get(Mesh *me, float r_loc[3], float r_rot[3], float r_size[3])
 {
-	if (!me->bb) {
+	if (me->bb == NULL || (me->bb->flag & BOUNDBOX_INVALID)) {
 		BKE_mesh_texspace_calc(me);
 	}
 

Modified: branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/object.c
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/object.c	2013-07-10 13:06:31 UTC (rev 58154)
+++ branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/object.c	2013-07-10 14:26:31 UTC (rev 58155)
@@ -262,8 +262,7 @@
 		Mesh *me = ob->data;
 
 		if (me->bb) {
-			MEM_freeN(me->bb);
-			me->bb = NULL;
+			me->bb->flag |= BOUNDBOX_INVALID;
 		}
 	}
 
@@ -2362,8 +2361,6 @@
 		case OB_FONT:
 		case OB_SURF:
 		{
-			Curve *cu = ob->data;
-
 			/* Use the object bounding box so that modifier output
 			 * gets taken into account */
 			bb = *(ob->bb);

Modified: branches/soc-2013-depsgraph_mt/source/blender/editors/space_view3d/view3d_draw.c
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/editors/space_view3d/view3d_draw.c	2013-07-10 13:06:31 UTC (rev 58154)
+++ branches/soc-2013-depsgraph_mt/source/blender/editors/space_view3d/view3d_draw.c	2013-07-10 14:26:31 UTC (rev 58155)
@@ -2073,7 +2073,7 @@
 				bb = *bb_tmp; /* must make a copy  */
 
 				/* disable boundbox check for list creation */
-				BKE_object_boundbox_flag(dob->ob, OB_BB_DISABLED, 1);
+				BKE_object_boundbox_flag(dob->ob, BOUNDBOX_DISABLED, 1);
 				/* need this for next part of code */
 				unit_m4(dob->ob->obmat);    /* obmat gets restored */
 
@@ -2083,7 +2083,7 @@
 				glEndList();
 
 				use_displist = true;
-				BKE_object_boundbox_flag(dob->ob, OB_BB_DISABLED, 0);
+				BKE_object_boundbox_flag(dob->ob, BOUNDBOX_DISABLED, 0);
 			}
 		}
 		if (use_displist) {

Modified: branches/soc-2013-depsgraph_mt/source/blender/editors/space_view3d/view3d_view.c
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/editors/space_view3d/view3d_view.c	2013-07-10 13:06:31 UTC (rev 58154)
+++ branches/soc-2013-depsgraph_mt/source/blender/editors/space_view3d/view3d_view.c	2013-07-10 14:26:31 UTC (rev 58155)
@@ -622,7 +622,7 @@
 	int a, flag = -1, fl;
 
 	if (bb == NULL) return true;
-	if (bb->flag & OB_BB_DISABLED) return true;
+	if (bb->flag & BOUNDBOX_DISABLED) return true;
 
 	mul_m4_m4m4(mat, rv3d->persmat, obmat);
 

Modified: branches/soc-2013-depsgraph_mt/source/blender/makesdna/DNA_object_types.h
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/makesdna/DNA_object_types.h	2013-07-10 13:06:31 UTC (rev 58154)
+++ branches/soc-2013-depsgraph_mt/source/blender/makesdna/DNA_object_types.h	2013-07-10 14:26:31 UTC (rev 58155)
@@ -100,7 +100,10 @@
 } BoundBox;
 
 /* boundbox flag */
-#define OB_BB_DISABLED	1
+enum {
+	BOUNDBOX_DISABLED = (1 << 0),
+	BOUNDBOX_INVALID  = (1 << 1),
+};
 
 typedef struct Object {
 	ID id;

Modified: branches/soc-2013-depsgraph_mt/source/blender/makesrna/intern/rna_mesh.c
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/makesrna/intern/rna_mesh.c	2013-07-10 13:06:31 UTC (rev 58154)
+++ branches/soc-2013-depsgraph_mt/source/blender/makesrna/intern/rna_mesh.c	2013-07-10 14:26:31 UTC (rev 58155)
@@ -576,8 +576,9 @@
 {
 	Mesh *me = (Mesh *)ptr->data;
 
-	if (!me->bb)
+	if (me->bb == NULL || (me->bb->flag & BOUNDBOX_INVALID)) {
 		BKE_mesh_texspace_calc(me);
+	}
 
 	copy_v3_v3(values, me->size);
 }
@@ -586,8 +587,9 @@
 {
 	Mesh *me = (Mesh *)ptr->data;
 
-	if (!me->bb)
+	if (me->bb == NULL || (me->bb->flag & BOUNDBOX_INVALID)) {
 		BKE_mesh_texspace_calc(me);
+	}
 
 	copy_v3_v3(values, me->loc);
 }




More information about the Bf-blender-cvs mailing list