[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39310] branches/cycles: Cycles: fix missing update when removing or hiding objects.

Brecht Van Lommel brechtvanlommel at pandora.be
Thu Aug 11 18:48:13 CEST 2011


Revision: 39310
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39310
Author:   blendix
Date:     2011-08-11 16:48:13 +0000 (Thu, 11 Aug 2011)
Log Message:
-----------
Cycles: fix missing update when removing or hiding objects.

Modified Paths:
--------------
    branches/cycles/intern/cycles/blender/blender_sync.cpp
    branches/cycles/source/blender/blenkernel/BKE_depsgraph.h
    branches/cycles/source/blender/blenkernel/intern/depsgraph.c
    branches/cycles/source/blender/editors/object/object_add.c
    branches/cycles/source/blender/editors/object/object_edit.c
    branches/cycles/source/blender/makesrna/intern/rna_main_api.c

Modified: branches/cycles/intern/cycles/blender/blender_sync.cpp
===================================================================
--- branches/cycles/intern/cycles/blender/blender_sync.cpp	2011-08-11 16:46:27 UTC (rev 39309)
+++ branches/cycles/intern/cycles/blender/blender_sync.cpp	2011-08-11 16:48:13 UTC (rev 39310)
@@ -60,6 +60,9 @@
 
 bool BlenderSync::sync_recalc()
 {
+	/* sync recalc flags from blender to cycles. actual update is done separate,
+	   so we can do it later on if doing it immediate is not suitable */
+
 	BL::BlendData::materials_iterator b_mat;
 
 	for(b_mat = b_data.materials.begin(); b_mat != b_data.materials.end(); ++b_mat)
@@ -104,6 +107,7 @@
 		object_map.has_recalc() ||
 		light_map.has_recalc() ||
 		mesh_map.has_recalc() ||
+		BlendDataObjects_recalc_get(&b_data.ptr) ||
 		world_recalc;
 
 	return recalc;

Modified: branches/cycles/source/blender/blenkernel/BKE_depsgraph.h
===================================================================
--- branches/cycles/source/blender/blenkernel/BKE_depsgraph.h	2011-08-11 16:46:27 UTC (rev 39309)
+++ branches/cycles/source/blender/blenkernel/BKE_depsgraph.h	2011-08-11 16:48:13 UTC (rev 39310)
@@ -126,6 +126,7 @@
 void	DAG_ids_check_recalc(struct Main *bmain);
 void	DAG_ids_clear_recalc(struct Main *bmain);
 		/* test if any of this id type is tagged for update */
+void	DAG_id_type_tag(struct Main *bmain, short idtype);
 int		DAG_id_type_tagged(struct Main *bmain, short idtype);
 
 		/* (re)-create dependency graph for armature pose */

Modified: branches/cycles/source/blender/blenkernel/intern/depsgraph.c
===================================================================
--- branches/cycles/source/blender/blenkernel/intern/depsgraph.c	2011-08-11 16:46:27 UTC (rev 39309)
+++ branches/cycles/source/blender/blenkernel/intern/depsgraph.c	2011-08-11 16:48:13 UTC (rev 39310)
@@ -2366,7 +2366,7 @@
 	}
 
 	/* hack to get objects updating on layer changes */
-	bmain->id_tag_update['O'] = 1;
+	DAG_id_type_tag(bmain, ID_OB);
 }
 
 static void dag_id_flush_update__isDependentTexture(void *userData, Object *UNUSED(ob), ID **idpoin)
@@ -2614,6 +2614,11 @@
 	}
 }
 
+void DAG_id_type_tag(struct Main *bmain, short idtype)
+{
+	bmain->id_tag_update[((char*)&idtype)[0]] = 1;
+}
+
 int DAG_id_type_tagged(Main *bmain, short idtype)
 {
 	return bmain->id_tag_update[((char*)&idtype)[0]];

Modified: branches/cycles/source/blender/editors/object/object_add.c
===================================================================
--- branches/cycles/source/blender/editors/object/object_add.c	2011-08-11 16:46:27 UTC (rev 39309)
+++ branches/cycles/source/blender/editors/object/object_add.c	2011-08-11 16:48:13 UTC (rev 39310)
@@ -803,6 +803,7 @@
 /* note: now unlinks constraints as well */
 void ED_base_object_free_and_unlink(Main *bmain, Scene *scene, Base *base)
 {
+	DAG_id_type_tag(bmain, ID_OB);
 	BLI_remlink(&scene->base, base);
 	free_libblock_us(&bmain->object, base->object);
 	if(scene->basact==base) scene->basact= NULL;

Modified: branches/cycles/source/blender/editors/object/object_edit.c
===================================================================
--- branches/cycles/source/blender/editors/object/object_edit.c	2011-08-11 16:46:27 UTC (rev 39309)
+++ branches/cycles/source/blender/editors/object/object_edit.c	2011-08-11 16:48:13 UTC (rev 39310)
@@ -147,6 +147,7 @@
 		}
 	}
 	if (changed) {
+		DAG_id_type_tag(bmain, ID_OB);
 		DAG_scene_sort(bmain, scene);
 		WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene);
 	}
@@ -199,6 +200,7 @@
 	CTX_DATA_END;
 
 	if (changed) {
+		DAG_id_type_tag(bmain, ID_OB);
 		DAG_scene_sort(bmain, scene);
 		
 		WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C));

Modified: branches/cycles/source/blender/makesrna/intern/rna_main_api.c
===================================================================
--- branches/cycles/source/blender/makesrna/intern/rna_main_api.c	2011-08-11 16:46:27 UTC (rev 39309)
+++ branches/cycles/source/blender/makesrna/intern/rna_main_api.c	2011-08-11 16:48:13 UTC (rev 39310)
@@ -63,6 +63,7 @@
 #include "BKE_particle.h"
 #include "BKE_font.h"
 #include "BKE_node.h"
+#include "BKE_depsgraph.h"
 
 #include "DNA_armature_types.h"
 #include "DNA_camera_types.h"
@@ -508,6 +509,8 @@
 void rna_Main_particles_tag(Main *bmain, int value) { tag_main_lb(&bmain->particle, value); }
 void rna_Main_gpencil_tag(Main *bmain, int value) { tag_main_lb(&bmain->gpencil, value); }
 
+static int rna_Main_objects_recalc_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_OB); }
+
 #else
 
 void RNA_api_main(StructRNA *srna)
@@ -590,6 +593,7 @@
 	StructRNA *srna;
 	FunctionRNA *func;
 	PropertyRNA *parm;
+	PropertyRNA *prop;
 
 	RNA_def_property_srna(cprop, "BlendDataObjects");
 	srna= RNA_def_struct(brna, "BlendDataObjects", NULL);
@@ -617,6 +621,10 @@
 	func= RNA_def_function(srna, "tag", "rna_Main_objects_tag");
 	parm= RNA_def_boolean(func, "value", 0, "Value", "");
 	RNA_def_property_flag(parm, PROP_REQUIRED);
+
+	prop= RNA_def_property(srna, "recalc", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+	RNA_def_property_boolean_funcs(prop, "rna_Main_objects_recalc_get", NULL);
 }
 
 void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop)




More information about the Bf-blender-cvs mailing list