[Bf-blender-cvs] [f5ae2e1] alembic: Moved the child deformation for strands out of the core cache reading function.

Lukas Tönne noreply at git.blender.org
Wed May 6 16:46:06 CEST 2015


Commit: f5ae2e1bbcd9213b1f8d4aa2347538418f52c626
Author: Lukas Tönne
Date:   Wed May 6 16:44:24 2015 +0200
Branches: alembic
https://developer.blender.org/rBf5ae2e1bbcd9213b1f8d4aa2347538418f52c626

Moved the child deformation for strands out of the core cache reading
function.

This is a feature for display in the viewport and rendering, which has
nothing to do with the core cache reading functionality. In the general
case you'd want the child data to remain unmodified.

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

M	source/blender/blenkernel/BKE_anim.h
M	source/blender/blenkernel/BKE_cache_library.h
M	source/blender/blenkernel/intern/cache_library.c
M	source/blender/blenkernel/intern/object_dupli.c
M	source/blender/makesrna/intern/rna_object.c
M	source/blender/pointcache/alembic/abc_group.cpp
M	source/blender/pointcache/alembic/abc_particles.cpp

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

diff --git a/source/blender/blenkernel/BKE_anim.h b/source/blender/blenkernel/BKE_anim.h
index d14231e..e3d6b41 100644
--- a/source/blender/blenkernel/BKE_anim.h
+++ b/source/blender/blenkernel/BKE_anim.h
@@ -93,8 +93,7 @@ void BKE_dupli_object_data_clear(struct DupliObjectData *data);
 void BKE_dupli_object_data_set_mesh(struct DupliObjectData *data, struct DerivedMesh *dm);
 void BKE_dupli_object_data_add_strands(struct DupliObjectData *data, const char *name, struct Strands *strands);
 void BKE_dupli_object_data_add_strands_children(struct DupliObjectData *data, const char *name, struct StrandsChildren *children);
-struct Strands *BKE_dupli_object_data_find_strands(struct DupliObjectData *data, const char *name);
-struct StrandsChildren *BKE_dupli_object_data_find_strands_children(struct DupliObjectData *data, const char *name);
+bool BKE_dupli_object_data_find_strands(struct DupliObjectData *data, const char *name, struct Strands **r_strands, struct StrandsChildren **r_children);
 bool BKE_dupli_object_data_acquire_strands(struct DupliObjectData *data, struct Strands *strands);
 bool BKE_dupli_object_data_acquire_strands_children(struct DupliObjectData *data, struct StrandsChildren *children);
 
diff --git a/source/blender/blenkernel/BKE_cache_library.h b/source/blender/blenkernel/BKE_cache_library.h
index e0e6189..a097db1 100644
--- a/source/blender/blenkernel/BKE_cache_library.h
+++ b/source/blender/blenkernel/BKE_cache_library.h
@@ -69,6 +69,9 @@ bool BKE_cache_library_validate_item(struct CacheLibrary *cachelib, struct Objec
 
 /* ========================================================================= */
 
+void BKE_cache_library_get_read_flags(struct CacheLibrary *cachelib, eCacheLibrary_EvalMode eval_mode, bool for_display,
+                                      bool *read_strands_motion, bool *read_strands_children);
+
 bool BKE_cache_archive_path_test(struct CacheLibrary *cachelib, const char *path);
 void BKE_cache_archive_path_ex(const char *path, struct Library *lib, const char *default_filename, char *result, int max);
 void BKE_cache_archive_input_path(struct CacheLibrary *cachelib, char *result, int max);
diff --git a/source/blender/blenkernel/intern/cache_library.c b/source/blender/blenkernel/intern/cache_library.c
index 74bdb02..b1534eb 100644
--- a/source/blender/blenkernel/intern/cache_library.c
+++ b/source/blender/blenkernel/intern/cache_library.c
@@ -353,8 +353,8 @@ static struct PTCReaderArchive *find_active_cache(Scene *scene, CacheLibrary *ca
 	return archive;
 }
 
-static void cache_get_read_flags(CacheLibrary *cachelib, eCacheLibrary_EvalMode eval_mode, bool for_display,
-                                 bool *read_strands_motion, bool *read_strands_children)
+void BKE_cache_library_get_read_flags(CacheLibrary *cachelib, eCacheLibrary_EvalMode eval_mode, bool for_display,
+                                      bool *read_strands_motion, bool *read_strands_children)
 {
 	if (for_display) {
 		switch (eval_mode) {
@@ -401,7 +401,7 @@ bool BKE_cache_read_dupli_cache(CacheLibrary *cachelib, DupliCache *dupcache,
 	
 	PTC_reader_archive_use_render(archive, eval_mode == CACHE_LIBRARY_EVAL_RENDER);
 	
-	cache_get_read_flags(cachelib, eval_mode, for_display, &read_strands_motion, &read_strands_children);
+	BKE_cache_library_get_read_flags(cachelib, eval_mode, for_display, &read_strands_motion, &read_strands_children);
 	// TODO duplicache reader should only overwrite data that is not sequentially generated by modifiers (simulations) ...
 	reader = PTC_reader_duplicache(dupgroup->id.name, dupgroup, dupcache,
 	                               read_strands_motion, read_strands_children, read_simdebug);
@@ -412,24 +412,6 @@ bool BKE_cache_read_dupli_cache(CacheLibrary *cachelib, DupliCache *dupcache,
 	PTC_reader_free(reader);
 	PTC_close_reader_archive(archive);
 	
-	/* Deform child strands to follow parent motion.
-	 * Note that this is an optional feature for viewport/render display,
-	 * strand motion is not usually applied to children in caches.
-	 */
-	if (for_display && read_strands_children) {
-		struct  DupliCacheIterator *it = BKE_dupli_cache_iter_new(dupcache);
-		for (; BKE_dupli_cache_iter_valid(it); BKE_dupli_cache_iter_next(it)) {
-			DupliObjectData *dobdata = BKE_dupli_cache_iter_get(it);
-			DupliObjectDataStrands *link;
-			
-			for (link = dobdata->strands.first; link; link = link->next) {
-				if (link->strands_children)
-					BKE_strands_children_deform(link->strands_children, link->strands, read_strands_motion);
-			}
-		}
-		BKE_dupli_cache_iter_free(it);
-	}
-	
 	return (dupcache->result != CACHE_READ_SAMPLE_INVALID);
 }
 
@@ -452,7 +434,7 @@ bool BKE_cache_read_dupli_object(CacheLibrary *cachelib, DupliObjectData *data,
 	
 	PTC_reader_archive_use_render(archive, eval_mode == CACHE_LIBRARY_EVAL_RENDER);
 	
-	cache_get_read_flags(cachelib, eval_mode, for_display, &read_strands_motion, &read_strands_children);
+	BKE_cache_library_get_read_flags(cachelib, eval_mode, for_display, &read_strands_motion, &read_strands_children);
 	reader = PTC_reader_duplicache_object(ob->id.name, ob, data, read_strands_motion, read_strands_children);
 	PTC_reader_init(reader, archive);
 	
@@ -461,18 +443,6 @@ bool BKE_cache_read_dupli_object(CacheLibrary *cachelib, DupliObjectData *data,
 	PTC_reader_free(reader);
 	PTC_close_reader_archive(archive);
 	
-	/* Deform child strands to follow parent motion.
-	 * Note that this is an optional feature for viewport/render display,
-	 * strand motion is not usually applied to children in caches.
-	 */
-	if (for_display && read_strands_children) {
-		DupliObjectDataStrands *link;
-		for (link = data->strands.first; link; link = link->next) {
-			if (link->strands_children)
-				BKE_strands_children_deform(link->strands_children, link->strands, read_strands_motion);
-		}
-	}
-	
 	return true;
 }
 
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index 593bb30..62731d0 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -1463,24 +1463,20 @@ void BKE_dupli_object_data_add_strands_children(DupliObjectData *data, const cha
 	dupli_cache_calc_boundbox(data);
 }
 
-Strands *BKE_dupli_object_data_find_strands(DupliObjectData *data, const char *name)
+bool BKE_dupli_object_data_find_strands(DupliObjectData *data, const char *name, Strands **r_strands, StrandsChildren **r_children)
 {
 	DupliObjectDataStrands *link;
 	for (link = data->strands.first; link; link = link->next) {
-		if (STREQ(link->name, name))
-			return link->strands;
-	}
-	return NULL;
-}
-
-StrandsChildren *BKE_dupli_object_data_find_strands_children(DupliObjectData *data, const char *name)
-{
-	DupliObjectDataStrands *link;
-	for (link = data->strands.first; link; link = link->next) {
-		if (STREQ(link->name, name))
-			return link->strands_children;
+		if (STREQ(link->name, name)) {
+			if (r_strands) *r_strands = link->strands;
+			if (r_children) *r_children = link->strands_children;
+			return true;
+		}
 	}
-	return NULL;
+	
+	if (r_strands) *r_strands = NULL;
+	if (r_children) *r_children = NULL;
+	return false;
 }
 
 bool BKE_dupli_object_data_acquire_strands(DupliObjectData *data, Strands *strands)
@@ -1771,12 +1767,34 @@ void BKE_object_dupli_cache_update(Scene *scene, Object *ob, EvaluationContext *
 			
 			/* skip reading when the cachelib is baking, avoids unnecessary memory allocation */
 			if (!(ob->cache_library->flag & CACHE_LIBRARY_BAKING)) {
+				bool do_strands_motion, do_strands_children;
+				
+				BKE_cache_library_get_read_flags(ob->cache_library, eval_mode, true, &do_strands_motion, &do_strands_children);
+				
 				/* TODO at this point we could apply animation offset */
 				BKE_cache_read_dupli_cache(ob->cache_library, ob->dup_cache, scene, ob->dup_group, frame, eval_mode, true);
 				
 				if (do_modifiers) {
 					object_dupli_cache_apply_modifiers(ob, scene, eval_mode);
 				}
+				
+				/* Deform child strands to follow parent motion.
+				 * Note that this is an optional feature for viewport/render display,
+				 * strand motion is not applied to raw child data in caches.
+				 */
+				if (do_strands_children) {
+					struct  DupliCacheIterator *it = BKE_dupli_cache_iter_new(ob->dup_cache);
+					for (; BKE_dupli_cache_iter_valid(it); BKE_dupli_cache_iter_next(it)) {
+						DupliObjectData *dobdata = BKE_dupli_cache_iter_get(it);
+						DupliObjectDataStrands *link;
+						
+						for (link = dobdata->strands.first; link; link = link->next) {
+							if (link->strands_children)
+								BKE_strands_children_deform(link->strands_children, link->strands, do_strands_motion);
+						}
+					}
+					BKE_dupli_cache_iter_free(it);
+				}
 			}
 			
 			ob->dup_cache->flag &= ~DUPCACHE_FLAG_DIRTY;
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index faeed87..92d6293 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -1545,11 +1545,10 @@ Strands *rna_DupliObject_strands_new(DupliObject *dob, ReportList *UNUSED(report
 			/* use dupli cache for realtime dupli data if possible */
 			data = BKE_dupli_cache_find_data(parent->dup_cache, dob->ob);
 			if (data) {
-				strands = BKE_dupli_object_data_find_strands(data, psys->name);
 				/* TODO(sergey): Consider sharing the data between viewport and
 				 * render engine.
 				 */
-				if (strands != NULL) {
+				if (BKE_dupli_object_data_find_strands(data, psys->name, &strands, NULL)) {
 					strands = BKE_strands_copy(strands);
 				}
 			}
@@ -1559,8 +1558,8 @@ Strands *rna_DupliObject_strands_new(DupliObject *dob, ReportList *UNUSED(report
 			
 			memset(&data, 0, sizeof(data));
 			if (BKE_cache_read_dupli_object(parent->cache_library, &data, scene, dob->ob, frame, eval_mode, true)) {
-				strands = BKE_dupli_object_data_find_strands(&data, psys->name);
-				BKE_dupli_object_data_acquire_strands(&data, strands);
+				if (BKE_dupli_object_data_find_strands(&data, psys->name, &strands, NULL))
+					BKE_dupli_object_data_acquire_strands(&data, strands);
 			}
 			
 			BKE_dupli_object_data_clear(&data);
@@ -1600

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list