[Bf-blender-cvs] [a8487f7] alembic: Optimization for particle baking to caches, skip evaluation of pathcache when not needed.

Lukas Tönne noreply at git.blender.org
Tue Apr 14 11:52:56 CEST 2015


Commit: a8487f7f62d4657eced40b27fe0958faa0483b7c
Author: Lukas Tönne
Date:   Tue Apr 14 11:50:53 2015 +0200
Branches: alembic
https://developer.blender.org/rBa8487f7f62d4657eced40b27fe0958faa0483b7c

Optimization for particle baking to caches, skip evaluation of pathcache
when not needed.

The pathcache data is only required in the first frame to construct the
child strand shapes. For subsequent frames the children are calculated
using the initial shape and parent deformation, so particles don't need
to recalculate all the time.

This gives a significant performance increase of the baking process when
using a lot of complicated child hairs.

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

M	source/blender/editors/io/io_cache_library.c

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

diff --git a/source/blender/editors/io/io_cache_library.c b/source/blender/editors/io/io_cache_library.c
index 30914be..73cb76d 100644
--- a/source/blender/editors/io/io_cache_library.c
+++ b/source/blender/editors/io/io_cache_library.c
@@ -44,7 +44,9 @@
 #include "DNA_group_types.h"
 #include "DNA_listBase.h"
 #include "DNA_modifier_types.h"
+#include "DNA_object_force.h"
 #include "DNA_object_types.h"
+#include "DNA_particle_types.h"
 
 #include "BKE_anim.h"
 #include "BKE_depsgraph.h"
@@ -231,6 +233,24 @@ static void cache_library_bake_set_progress(CacheLibraryBakeJob *data, float pro
 	*data->progress = progress;
 }
 
+static void cache_library_bake_set_particle_baking(Main *bmain, bool baking)
+{
+	/* XXX would be nicer to just loop over scene->base here,
+	 * but this does not catch all objects included in dupli groups ...
+	 */
+	Object *ob;
+	for (ob = bmain->object.first; ob; ob = ob->id.next) {
+		ParticleSystem *psys;
+		
+		for (psys = ob->particlesystem.first; psys; psys = psys->next) {
+			if (baking)
+				psys->pointcache->flag |= PTCACHE_BAKING;
+			else
+				psys->pointcache->flag &= ~PTCACHE_BAKING;
+		}
+	}
+}
+
 static void cache_library_bake_do(CacheLibraryBakeJob *data)
 {
 	Scene *scene = data->scene;
@@ -269,6 +289,12 @@ static void cache_library_bake_do(CacheLibraryBakeJob *data)
 	
 	cache_library_bake_set_progress(data, 0.0f);
 	for (frame = frame_prev = start_frame; frame <= end_frame; frame_prev = frame++) {
+		
+		/* XXX Ugly, but necessary to avoid particle caching of paths when not needed.
+		 * This takes a lot of time, but is only needed in the first frame.
+		 */
+		cache_library_bake_set_particle_baking(data->bmain, frame > start_frame);
+		
 		scene->r.cfra = frame;
 		BKE_scene_update_for_newframe(&data->eval_ctx, data->bmain, scene, scene->lay);
 		
@@ -298,6 +324,7 @@ static void cache_library_bake_do(CacheLibraryBakeJob *data)
 	}
 	
 	data->cachelib->flag &= ~CACHE_LIBRARY_BAKING;
+	cache_library_bake_set_particle_baking(data->bmain, false);
 	
 	BKE_dupli_cache_free(process_data.dupcache);
 }




More information about the Bf-blender-cvs mailing list