[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27856] branches/render25/source/blender: Baking for dupligroup & linked library objects

Campbell Barton ideasman42 at gmail.com
Tue Mar 30 11:18:38 CEST 2010


Revision: 27856
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27856
Author:   campbellbarton
Date:     2010-03-30 11:18:37 +0200 (Tue, 30 Mar 2010)

Log Message:
-----------
Baking for dupligroup & linked library objects
- library data allows pointcache writing (hard to know how this should work long term so ifdef'd for now)
- changing the frame now updates the dupligroup objects
- BKE_ptcache_ids_from_object(), option to get the id's from duplis

note! scene_update_tagged() is called from the main() loop, and runs BKE_ptcache_quick_cache_all(), this could become a performance issue, especially with duplis, should probably not call BKE_ptcache_quick_cache_all() all the time, even when not playing back animation.

Modified Paths:
--------------
    branches/render25/source/blender/blenkernel/BKE_pointcache.h
    branches/render25/source/blender/blenkernel/intern/pointcache.c
    branches/render25/source/blender/blenkernel/intern/scene.c
    branches/render25/source/blender/editors/object/object_edit.c
    branches/render25/source/blender/editors/physics/particle_edit.c
    branches/render25/source/blender/editors/physics/physics_pointcache.c
    branches/render25/source/blender/editors/transform/transform_conversions.c
    branches/render25/source/blender/makesrna/intern/rna_object_force.c

Modified: branches/render25/source/blender/blenkernel/BKE_pointcache.h
===================================================================
--- branches/render25/source/blender/blenkernel/BKE_pointcache.h	2010-03-30 07:57:07 UTC (rev 27855)
+++ branches/render25/source/blender/blenkernel/BKE_pointcache.h	2010-03-30 09:18:37 UTC (rev 27856)
@@ -236,7 +236,7 @@
 void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd);
 void BKE_ptcache_id_from_smoke_turbulence(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd);
 
-void BKE_ptcache_ids_from_object(struct ListBase *lb, struct Object *ob);
+void BKE_ptcache_ids_from_object(struct ListBase *lb, struct Object *ob, struct Scene *scene, int duplis);
 
 /***************** Global funcs ****************************/
 void BKE_ptcache_remove(void);

Modified: branches/render25/source/blender/blenkernel/intern/pointcache.c
===================================================================
--- branches/render25/source/blender/blenkernel/intern/pointcache.c	2010-03-30 07:57:07 UTC (rev 27855)
+++ branches/render25/source/blender/blenkernel/intern/pointcache.c	2010-03-30 09:18:37 UTC (rev 27856)
@@ -48,6 +48,7 @@
 
 #include "WM_api.h"
 
+#include "BKE_anim.h"
 #include "BKE_blender.h"
 #include "BKE_cloth.h"
 #include "BKE_depsgraph.h"
@@ -90,6 +91,9 @@
 #define PTCACHE_DATA_FROM(data, type, from)		if(data[type]) { memcpy(data[type], from, ptcache_data_size[type]); }
 #define PTCACHE_DATA_TO(data, type, index, to)	if(data[type]) { memcpy(to, (char*)data[type] + (index ? index * ptcache_data_size[type] : 0), ptcache_data_size[type]); }
 
+/* could be made into a pointcache option */
+#define DURIAN_POINTCACHE_LIB_OK 1
+
 int ptcache_data_size[] = {	
 		sizeof(int), // BPHYS_DATA_INDEX
 		3 * sizeof(float), // BPHYS_DATA_LOCATION:
@@ -982,7 +986,7 @@
 	pid->info_types= 0;
 }
 
-void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob)
+void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int duplis)
 {
 	PTCacheID *pid;
 	ParticleSystem *psys;
@@ -1024,6 +1028,23 @@
 			}
 		}
 	}
+
+	if(scene && (duplis-- > 0) && (ob->transflag & OB_DUPLI)) {
+		ListBase *lb_dupli_ob;
+
+		if((lb_dupli_ob=object_duplilist(scene, ob))) {
+			DupliObject *dob;
+			for(dob= lb_dupli_ob->first; dob; dob= dob->next) {
+				ListBase lb_dupli_pid;
+				BKE_ptcache_ids_from_object(&lb_dupli_pid, dob->ob, scene, duplis);
+				addlisttolist(lb, &lb_dupli_pid);
+				if(lb_dupli_pid.first)
+					printf("Adding Dupli\n");
+			}
+
+			free_object_duplilist(lb_dupli_ob);	/* does restore */
+		}
+	}
 }
 
 
@@ -1132,10 +1153,11 @@
 	FILE *fp = NULL;
 	char filename[(FILE_MAXDIR+FILE_MAXFILE)*2];
 
+#ifndef DURIAN_POINTCACHE_LIB_OK
 	/* don't allow writing for linked objects */
 	if(pid->ob->id.lib && mode == PTCACHE_FILE_WRITE)
 		return NULL;
-
+#endif
 	if (!G.relbase_valid && (pid->cache->flag & PTCACHE_EXTERNAL)==0) return NULL; /* save blend file before using disk pointcache */
 	
 	BKE_ptcache_id_filename(pid, filename, cfra, 1, 1);
@@ -1873,9 +1895,11 @@
 	if(!pid->cache || pid->cache->flag & PTCACHE_BAKED)
 		return;
 
+#ifndef DURIAN_POINTCACHE_LIB_OK
 	/* don't allow clearing for linked objects */
 	if(pid->ob->id.lib)
 		return;
+#endif
 
 	/*if (!G.relbase_valid) return; *//* save blend file before using pointcache */
 	
@@ -2310,7 +2334,7 @@
 
 	for(base = scene->base.first; base; base = base->next) {
 		if(base->object) {
-			BKE_ptcache_ids_from_object(&pidlist, base->object);
+			BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR);
 
 			for(pid=pidlist.first; pid; pid=pid->next) {
 				if((pid->cache->flag & PTCACHE_BAKED)
@@ -2408,7 +2432,7 @@
 				/* get all pids from the object and search for smoke low res */
 				ListBase pidlist2;
 				PTCacheID *pid2;
-				BKE_ptcache_ids_from_object(&pidlist2, pid->ob);
+				BKE_ptcache_ids_from_object(&pidlist2, pid->ob, scene, MAX_DUPLI_RECUR);
 				for(pid2=pidlist2.first; pid2; pid2=pid2->next) {
 					if(pid2->type == PTCACHE_TYPE_SMOKE_DOMAIN) 
 					{
@@ -2443,7 +2467,7 @@
 	}
 	else for(base=scene->base.first; base; base= base->next) {
 		/* cache/bake everything in the scene */
-		BKE_ptcache_ids_from_object(&pidlist, base->object);
+		BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR);
 
 		for(pid=pidlist.first; pid; pid=pid->next) {
 			cache = pid->cache;
@@ -2525,7 +2549,7 @@
 		}
 	}
 	else for(base=scene->base.first; base; base= base->next) {
-		BKE_ptcache_ids_from_object(&pidlist, base->object);
+		BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR);
 
 		for(pid=pidlist.first; pid; pid=pid->next) {
 			/* skip hair particles */
@@ -2871,4 +2895,4 @@
 	cache->flag &= ~PTCACHE_SIMULATION_VALID;
 	cache->simframe = 0;
 	cache->last_exact = 0;
-}
\ No newline at end of file
+}

Modified: branches/render25/source/blender/blenkernel/intern/scene.c
===================================================================
--- branches/render25/source/blender/blenkernel/intern/scene.c	2010-03-30 07:57:07 UTC (rev 27855)
+++ branches/render25/source/blender/blenkernel/intern/scene.c	2010-03-30 09:18:37 UTC (rev 27856)
@@ -891,15 +891,18 @@
 	return ctime;
 }
 
-static void scene_update_newframe(Scene *sce, unsigned int lay)
+static void scene_update_newframe(Scene *scene, unsigned int lay)
 {
 	Base *base;
 	Object *ob;
 	
-	for(base= sce->base.first; base; base= base->next) {
+	for(base= scene->base.first; base; base= base->next) {
 		ob= base->object;
 		
-		object_handle_update(sce, ob);   // bke_object.h
+		object_handle_update(scene, ob);   // bke_object.h
+
+		if(ob->dup_group && (ob->transflag & OB_DUPLIGROUP))
+			group_handle_recalc_and_update(scene, ob, ob->dup_group);
 		
 		/* only update layer when an ipo */
 			// XXX old animation system
@@ -928,7 +931,7 @@
 
 			object_handle_update(scene, ob);
 
-			if(ob->dup_group)
+			if(ob->dup_group && (ob->transflag & OB_DUPLIGROUP))
 				group_handle_recalc_and_update(scene, ob, ob->dup_group);
 		}
 	}
@@ -938,7 +941,7 @@
 
 		object_handle_update(scene, ob);
 
-		if(ob->dup_group)
+		if(ob->dup_group && (ob->transflag & OB_DUPLIGROUP))
 			group_handle_recalc_and_update(scene, ob, ob->dup_group);
 	}
 

Modified: branches/render25/source/blender/editors/object/object_edit.c
===================================================================
--- branches/render25/source/blender/editors/object/object_edit.c	2010-03-30 07:57:07 UTC (rev 27855)
+++ branches/render25/source/blender/editors/object/object_edit.c	2010-03-30 09:18:37 UTC (rev 27856)
@@ -285,7 +285,7 @@
 		scene->obedit= NULL; // XXX for context
 
 		/* flag object caches as outdated */
-		BKE_ptcache_ids_from_object(&pidlist, obedit);
+		BKE_ptcache_ids_from_object(&pidlist, obedit, NULL, 0);
 		for(pid=pidlist.first; pid; pid=pid->next) {
 			if(pid->type != PTCACHE_TYPE_PARTICLES) /* particles don't need reset on geometry change */
 				pid->cache->flag |= PTCACHE_OUTDATED;

Modified: branches/render25/source/blender/editors/physics/particle_edit.c
===================================================================
--- branches/render25/source/blender/editors/physics/particle_edit.c	2010-03-30 07:57:07 UTC (rev 27855)
+++ branches/render25/source/blender/editors/physics/particle_edit.c	2010-03-30 09:18:37 UTC (rev 27856)
@@ -203,7 +203,7 @@
 	pset->scene = scene;
 	pset->object = ob;
 
-	BKE_ptcache_ids_from_object(&pidlist, ob);
+	BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0);
 
 	/* in the case of only one editable thing, set pset->edittype accordingly */
 	if(pidlist.first && pidlist.first == pidlist.last) {

Modified: branches/render25/source/blender/editors/physics/physics_pointcache.c
===================================================================
--- branches/render25/source/blender/editors/physics/physics_pointcache.c	2010-03-30 07:57:07 UTC (rev 27855)
+++ branches/render25/source/blender/editors/physics/physics_pointcache.c	2010-03-30 09:18:37 UTC (rev 27856)
@@ -33,6 +33,7 @@
 
 #include "DNA_scene_types.h"
 
+#include "BKE_anim.h"
 #include "BKE_context.h"
 #include "BKE_particle.h"
 #include "BKE_report.h"
@@ -125,7 +126,7 @@
 	ListBase pidlist;
 
 	for(base=scene->base.first; base; base= base->next) {
-		BKE_ptcache_ids_from_object(&pidlist, base->object);
+		BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR);
 
 		for(pid=pidlist.first; pid; pid=pid->next) {
 			pid->cache->flag &= ~PTCACHE_BAKED;
@@ -178,7 +179,7 @@
 	PTCacheID *pid;
 	ListBase pidlist;
 
-	BKE_ptcache_ids_from_object(&pidlist, ob);
+	BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR);
 	
 	for(pid=pidlist.first; pid; pid=pid->next) {
 		if(pid->cache == cache)
@@ -290,7 +291,7 @@
 	PTCacheID *pid;
 	ListBase pidlist;
 
-	BKE_ptcache_ids_from_object(&pidlist, ob);
+	BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR);
 	
 	for(pid=pidlist.first; pid; pid=pid->next) {
 		if(pid->cache == cache) {
@@ -308,12 +309,13 @@
 static int ptcache_remove_exec(bContext *C, wmOperator *op)
 {
 	PointerRNA ptr= CTX_data_pointer_get_type(C, "PointCache", &RNA_PointCache);
+	Scene *scene= CTX_data_scene(C);
 	Object *ob= ptr.id.data;
 	PointCache *cache= ptr.data;
 	PTCacheID *pid;
 	ListBase pidlist;
 
-	BKE_ptcache_ids_from_object(&pidlist, ob);
+	BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR);
 	
 	for(pid=pidlist.first; pid; pid=pid->next) {
 		if(pid->cache == cache) {

Modified: branches/render25/source/blender/editors/transform/transform_conversions.c
===================================================================
--- branches/render25/source/blender/editors/transform/transform_conversions.c	2010-03-30 07:57:07 UTC (rev 27855)
+++ branches/render25/source/blender/editors/transform/transform_conversions.c	2010-03-30 09:18:37 UTC (rev 27856)
@@ -48,6 +48,7 @@
 #include "DNA_view3d_types.h"
 #include "DNA_constraint_types.h"
 
+#include "BKE_anim.h"
 #include "BKE_action.h"
 #include "BKE_armature.h"
 #include "BKE_blender.h"
@@ -4946,7 +4947,7 @@
 				continue;
 
 			/* flag object caches as outdated */
-			BKE_ptcache_ids_from_object(&pidlist, ob);
+			BKE_ptcache_ids_from_object(&pidlist, ob, t->scene, MAX_DUPLI_RECUR);
 			for(pid=pidlist.first; pid; pid=pid->next) {
 				if(pid->type != PTCACHE_TYPE_PARTICLES) /* particles don't need reset on geometry change */
 					pid->cache->flag |= PTCACHE_OUTDATED;


@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list