[Bf-blender-cvs] [035d827b5b1] blender2.8: Cleanup: Tag only objects of the scene collections

Antonioya noreply at git.blender.org
Tue Aug 7 16:42:26 CEST 2018


Commit: 035d827b5b132627d5ea73e3fa237d8fd2185b4f
Author: Antonioya
Date:   Tue Aug 7 16:41:38 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB035d827b5b132627d5ea73e3fa237d8fd2185b4f

Cleanup: Tag only objects of the scene collections

In previous commit the bmain loop updated all GP objects, but must tag only scene collection objects.

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

M	source/blender/makesrna/intern/rna_scene.c
M	source/blender/makesrna/intern/rna_sculpt_paint.c

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

diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index bb87dde06c1..bdb905690f3 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -532,13 +532,22 @@ static const EnumPropertyItem transform_orientation_items[] = {
 #endif
 
 /* Grease Pencil update cache */
-static void rna_GPencil_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
+static void rna_GPencil_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
 {
-	/* mark all grease pencil datablocks */
-	for (bGPdata *gpd = bmain->gpencil.first; gpd; gpd = gpd->id.next) {
-		gpd->flag |= GP_DATA_CACHE_IS_DIRTY;
-		DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+	/* mark all grease pencil datablocks of the scene */
+	FOREACH_SCENE_COLLECTION_BEGIN(scene, collection)
+	{
+		FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(collection, ob)
+		{
+			if (ob->type == OB_GPENCIL) {
+				bGPdata *gpd = (bGPdata *)ob->data;
+				gpd->flag |= GP_DATA_CACHE_IS_DIRTY;
+				DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+			}
+		}
+		FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
 	}
+	FOREACH_SCENE_COLLECTION_END;
 
 	WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
 }
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index 37a5376f5d5..faa879b54b1 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -107,6 +107,7 @@ const EnumPropertyItem rna_enum_symmetrize_direction_items[] = {
 #ifdef RNA_RUNTIME
 #include "MEM_guardedalloc.h"
 
+#include "BKE_collection.h"
 #include "BKE_context.h"
 #include "BKE_particle.h"
 #include "BKE_pbvh.h"
@@ -119,13 +120,22 @@ const EnumPropertyItem rna_enum_symmetrize_direction_items[] = {
 
 #include "ED_particle.h"
 
-static void rna_GPencil_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
+static void rna_GPencil_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
 {
-	/* mark all grease pencil datablocks */
-	for (bGPdata *gpd = bmain->gpencil.first; gpd; gpd = gpd->id.next) {
-		gpd->flag |= GP_DATA_CACHE_IS_DIRTY;
-		DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+	/* mark all grease pencil datablocks of the scene */
+	FOREACH_SCENE_COLLECTION_BEGIN(scene, collection)
+	{
+		FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(collection, ob)
+		{
+			if (ob->type == OB_GPENCIL) {
+				bGPdata *gpd = (bGPdata *)ob->data;
+				gpd->flag |= GP_DATA_CACHE_IS_DIRTY;
+				DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
+			}
+		}
+		FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
 	}
+	FOREACH_SCENE_COLLECTION_END;
 
 	WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
 }



More information about the Bf-blender-cvs mailing list