[Bf-blender-cvs] [2b8705f] temp_localview_split: Prepare local view OP to work without layer bitfields

Julian Eisel noreply at git.blender.org
Thu Jul 28 17:19:49 CEST 2016


Commit: 2b8705fa001fed6da1036b56a5fa6652a72df23c
Author: Julian Eisel
Date:   Thu Jul 28 17:18:02 2016 +0200
Branches: temp_localview_split
https://developer.blender.org/rB2b8705fa001fed6da1036b56a5fa6652a72df23c

Prepare local view OP to work without layer bitfields

===================================================================

M	source/blender/blenkernel/BKE_utildefines.h
M	source/blender/editors/space_view3d/view3d_view.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_utildefines.h b/source/blender/blenkernel/BKE_utildefines.h
index 2a4c9f6..64605a6 100644
--- a/source/blender/blenkernel/BKE_utildefines.h
+++ b/source/blender/blenkernel/BKE_utildefines.h
@@ -45,9 +45,11 @@ extern "C" {
  * please only access using these macros (or extend it if needed).
  */
 
-/* visibility check */
+/* visibility checks */
+#define BKE_LOCALVIEW_INFO_CMP(a, b) \
+	((a).viewbits & (b).viewbits)
 #define BKE_LOCALVIEW_IS_OBJECT_VISIBLE(v3d, ob) \
-	(((v3d)->localviewd == NULL) || (((v3d)->localviewd->info.viewbits & (ob)->localview.viewbits) != 0))
+	(((v3d)->localviewd == NULL) || BKE_LOCALVIEW_INFO_CMP((v3d)->localviewd->info, (ob)->localview))
 
 /* Adjust local view info of ob to be visible if v3d is in local view */
 #define BKE_LOCALVIEW_OBJECT_ASSIGN(v3d, ob) \
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 2ff8504..1e12c12 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -50,6 +50,7 @@
 #include "BKE_report.h"
 #include "BKE_scene.h"
 #include "BKE_screen.h"
+#include "BKE_utildefines.h"
 
 #include "BIF_gl.h"
 #include "BIF_glutil.h"
@@ -1285,7 +1286,6 @@ static bool view3d_localview_init(
         ReportList *reports)
 {
 	View3D *v3d = sa->spacedata.first;
-	Base *base;
 	float min[3], max[3], box[3], mid[3];
 	float size = 0.0f;
 	unsigned int locallay;
@@ -1306,18 +1306,14 @@ static bool view3d_localview_init(
 			BKE_object_minmax(scene->obedit, min, max, false);
 			
 			ok = true;
-		
-			BASACT->lay |= locallay;
-			scene->obedit->lay = BASACT->lay;
+
 			BASACT->object->localview.viewbits |= locallay;
 			scene->obedit->localview = BASACT->object->localview;
 		}
 		else {
-			for (base = FIRSTBASE; base; base = base->next) {
+			for (Base *base = FIRSTBASE; base; base = base->next) {
 				if (TESTBASE(v3d, base)) {
 					BKE_object_minmax(base->object, min, max, false);
-					base->lay |= locallay;
-					base->object->lay = base->lay;
 					base->object->localview.viewbits |= locallay;
 					ok = true;
 				}
@@ -1329,8 +1325,6 @@ static bool view3d_localview_init(
 	}
 	
 	if (ok == true) {
-		ARegion *ar;
-
 		v3d->localviewd = MEM_callocN(sizeof(*v3d->localviewd), "localview area data");
 		view3d_localview_area_data_init(v3d->localviewd, v3d);
 
@@ -1338,7 +1332,7 @@ static bool view3d_localview_init(
 
 		copy_v3_v3(v3d->cursor, mid);
 
-		for (ar = sa->regionbase.first; ar; ar = ar->next) {
+		for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
 			if (ar->regiontype == RGN_TYPE_WINDOW) {
 				RegionView3D *rv3d = ar->regiondata;
 				bool ok_dist = true;
@@ -1379,20 +1373,20 @@ static bool view3d_localview_init(
 				                .dist = ok_dist ? &dist_new : NULL, .lens = &v3d->lens});
 			}
 		}
-		
+
 		v3d->localviewd->info.viewbits = locallay;
-		v3d->lay = locallay;
 	}
 	else {
 		/* clear flags */ 
-		for (base = FIRSTBASE; base; base = base->next) {
+		for (Base *base = FIRSTBASE; base; base = base->next) {
 			Object *ob = base->object;
 			if (ob->localview.viewbits & locallay) {
-				ob->localview.viewbits -= locallay;
+				ob->localview.viewbits &= ~locallay;
 				if (ob != scene->obedit) {
 					base->flag |= SELECT;
 				}
 			}
+			/* local view used to work with object/base bitfields, check updates didn't break anything */
 			BLI_assert(ob->lay > 0 && ob->lay == base->lay);
 		}
 	}
@@ -1453,29 +1447,25 @@ static bool view3d_localview_exit(
         const int smooth_viewtx)
 {
 	View3D *v3d = sa->spacedata.first;
-	struct Base *base;
-	unsigned int locallay;
+	LocalViewInfo localview = v3d->localviewd->info; /* store for use after v3d local view data is reset */
 
 	BLI_assert(sa->spacetype == SPACE_VIEW3D && v3d->localviewd);
 
-	locallay = v3d->lay & 0xFF000000;
-
 	view3d_localviewdata_restore(wm, win, bmain, scene, sa, smooth_viewtx);
 
-	/* for when in other window the layers have changed */
-	if (v3d->scenelock) v3d->lay = scene->lay;
-
-	for (base = FIRSTBASE; base; base = base->next) {
-		if (base->lay & locallay) {
-			base->lay -= locallay;
-			if (base->lay == 0) base->lay = v3d->layact;
+	for (Base *base = FIRSTBASE; base; base = base->next) {
+		if (BKE_LOCALVIEW_INFO_CMP(localview, base->object->localview)) {
+			base->object->localview.viewbits &= ~localview.viewbits;
 			if (base->object != scene->obedit) {
 				base->flag |= SELECT;
 				base->object->flag |= SELECT;
 			}
-			base->object->lay = base->lay;
 		}
+		/* local view used to work with object/base bitfields, check updates didn't break anything */
+		BLI_assert(base->lay > 0 && base->lay == base->object->lay);
 	}
+	BLI_assert(!v3d->scenelock || v3d->lay == scene->lay);
+
 	DAG_on_visible_update(bmain, false);
 
 	return true;




More information about the Bf-blender-cvs mailing list