[Bf-blender-cvs] [f1bd802] alembic: Moved child strand deformation into the general cache processing function.

Lukas Tönne noreply at git.blender.org
Thu May 28 15:27:00 CEST 2015


Commit: f1bd802b118c20eead0be075f5ec7bd59b0610c3
Author: Lukas Tönne
Date:   Thu May 28 15:25:00 2015 +0200
Branches: alembic
https://developer.blender.org/rBf1bd802b118c20eead0be075f5ec7bd59b0610c3

Moved child strand deformation into the general cache processing
function.

Strands processing now has 3 main steps:
1) apply parent modifiers
2) deform child strands
3) apply child modifiers

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

M	source/blender/blenkernel/BKE_cache_library.h
M	source/blender/blenkernel/BKE_strands.h
M	source/blender/blenkernel/intern/cache_library.c
M	source/blender/blenkernel/intern/object_dupli.c
M	source/blender/blenkernel/intern/strands.c
M	source/blender/editors/io/io_cache_library.c
M	source/blender/makesdna/DNA_strands_types.h
M	source/blender/pointcache/alembic/abc_particles.cpp

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

diff --git a/source/blender/blenkernel/BKE_cache_library.h b/source/blender/blenkernel/BKE_cache_library.h
index 3fcd48a..88eb7e9 100644
--- a/source/blender/blenkernel/BKE_cache_library.h
+++ b/source/blender/blenkernel/BKE_cache_library.h
@@ -89,7 +89,8 @@ bool BKE_cache_read_dupli_object(struct CacheLibrary *cachelib, struct DupliObje
                                  struct Scene *scene, struct Object *ob, float frame, bool use_render, bool for_display);
 
 void BKE_cache_process_dupli_cache(struct CacheLibrary *cachelib, struct CacheProcessData *data,
-                                   struct Scene *scene, struct Group *dupgroup, float frame_prev, float frame);
+                                   struct Scene *scene, struct Group *dupgroup, float frame_prev, float frame,
+                                   bool do_modifiers, bool do_strands_child_deform, bool do_strands_motion);
 
 /* ========================================================================= */
 
@@ -108,13 +109,18 @@ typedef struct CacheProcessData {
 	struct DupliCache *dupcache;
 } CacheProcessData;
 
+typedef enum eCacheProcessFlag {
+	eCacheProcessFlag_DoStrands             = (1 << 0),
+	eCacheProcessFlag_DoStrandsChildren     = (1 << 1),
+} eCacheProcessFlag;
+
 typedef void (*CacheModifier_InitFunc)(struct CacheModifier *md);
 typedef void (*CacheModifier_FreeFunc)(struct CacheModifier *md);
 typedef void (*CacheModifier_CopyFunc)(struct CacheModifier *md, struct CacheModifier *target);
 typedef void (*CacheModifier_ForeachIDLinkFunc)(struct CacheModifier *md, struct CacheLibrary *cachelib,
                                                 CacheModifier_IDWalkFunc walk, void *userData);
 typedef void (*CacheModifier_ProcessFunc)(struct CacheModifier *md, struct CacheProcessContext *ctx, struct CacheProcessData *data,
-                                          int frame, int frame_prev);
+                                          int frame, int frame_prev, int process_flag);
 
 typedef struct CacheModifierTypeInfo {
 	/* The user visible name for this modifier */
diff --git a/source/blender/blenkernel/BKE_strands.h b/source/blender/blenkernel/BKE_strands.h
index 61f55e3..2ec1363 100644
--- a/source/blender/blenkernel/BKE_strands.h
+++ b/source/blender/blenkernel/BKE_strands.h
@@ -46,9 +46,6 @@ void BKE_strands_children_free(struct StrandsChildren *strands);
 void BKE_strands_children_add_uvs(struct StrandsChildren *strands, int num_layers);
 void BKE_strands_children_add_vcols(struct StrandsChildren *strands, int num_layers);
 
-int BKE_strands_children_max_length(struct StrandsChildren *strands);
-int *BKE_strands_calc_vertex_start(struct Strands *strands);
-void BKE_strands_children_strand_deform(struct StrandChildIterator *it_strand, struct Strands *parents, int *vertstart, bool use_motion, float (*out)[3]);
 void BKE_strands_children_deform(struct StrandsChildren *strands, struct Strands *parents, bool use_motion);
 
 void BKE_strands_children_ensure_normals(struct StrandsChildren *strands);
diff --git a/source/blender/blenkernel/intern/cache_library.c b/source/blender/blenkernel/intern/cache_library.c
index 4ac1142..1a1672c 100644
--- a/source/blender/blenkernel/intern/cache_library.c
+++ b/source/blender/blenkernel/intern/cache_library.c
@@ -573,7 +573,8 @@ void BKE_cache_modifier_foreachIDLink(struct CacheLibrary *cachelib, struct Cach
 }
 
 void BKE_cache_process_dupli_cache(CacheLibrary *cachelib, CacheProcessData *data,
-                                   Scene *scene, Group *dupgroup, float frame_prev, float frame)
+                                   Scene *scene, Group *dupgroup, float frame_prev, float frame,
+                                   bool do_modifiers, bool do_strands_child_deform, bool do_strands_motion)
 {
 	CacheProcessContext ctx;
 	CacheModifier *md;
@@ -583,11 +584,41 @@ void BKE_cache_process_dupli_cache(CacheLibrary *cachelib, CacheProcessData *dat
 	ctx.cachelib = cachelib;
 	ctx.group = dupgroup;
 	
-	for (md = cachelib->modifiers.first; md; md = md->next) {
-		CacheModifierTypeInfo *mti = cache_modifier_type_get(md->type);
+	if (do_modifiers) {
+		for (md = cachelib->modifiers.first; md; md = md->next) {
+			CacheModifierTypeInfo *mti = cache_modifier_type_get(md->type);
+			
+			// TODO parent modifiers only here
+			if (mti->process)
+				mti->process(md, &ctx, data, frame, frame_prev, eCacheProcessFlag_DoStrands);
+		}
+	}
+	
+	/* deform child strands to follow parent motion */
+	if (do_modifiers || do_strands_child_deform) {
+		struct  DupliCacheIterator *it;
 		
-		if (mti->process)
-			mti->process(md, &ctx, data, frame, frame_prev);
+		it = BKE_dupli_cache_iter_new(data->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, do_strands_motion);
+			}
+		}
+		BKE_dupli_cache_iter_free(it);
+	}
+	
+	if (do_modifiers) {
+		for (md = cachelib->modifiers.first; md; md = md->next) {
+			CacheModifierTypeInfo *mti = cache_modifier_type_get(md->type);
+			
+			// TODO child modifiers only here
+			if (mti->process)
+				mti->process(md, &ctx, data, frame, frame_prev, eCacheProcessFlag_DoStrandsChildren);
+		}
 	}
 }
 
@@ -1115,7 +1146,7 @@ static void hairsim_foreach_id_link(HairSimCacheModifier *hsmd, CacheLibrary *ca
 		walk(userdata, cachelib, &hsmd->modifier, (ID **)(&hsmd->sim_params.effector_weights->group));
 }
 
-static void hairsim_process(HairSimCacheModifier *hsmd, CacheProcessContext *ctx, CacheProcessData *data, int frame, int frame_prev)
+static void hairsim_process(HairSimCacheModifier *hsmd, CacheProcessContext *ctx, CacheProcessData *data, int frame, int frame_prev, int process_flag)
 {
 #define MAX_CACHE_EFFECTORS 64
 	
@@ -1127,9 +1158,9 @@ static void hairsim_process(HairSimCacheModifier *hsmd, CacheProcessContext *ctx
 	int tot_cache_effectors;
 	struct Implicit_Data *solver_data;
 	
-	/* only perform hair sim once */
-//	if (eval_mode != CACHE_LIBRARY_EVAL_REALTIME)
-//		return;
+	/* only applies to parent strands */
+	if (!(process_flag & eCacheProcessFlag_DoStrands))
+		return;
 	
 	if (!BKE_cache_modifier_find_strands(data->dupcache, ob, hsmd->hair_system, NULL, &strands, NULL, NULL))
 		return;
@@ -1438,25 +1469,25 @@ static void shrinkwrap_apply(ShrinkWrapCacheModifier *smd, ShrinkWrapCacheData *
 	}
 }
 
-static void shrinkwrap_process(ShrinkWrapCacheModifier *smd, CacheProcessContext *ctx, CacheProcessData *data, int UNUSED(frame), int UNUSED(frame_prev))
+static void shrinkwrap_process(ShrinkWrapCacheModifier *smd, CacheProcessContext *ctx, CacheProcessData *data, int UNUSED(frame), int UNUSED(frame_prev), int process_flag)
 {
 	bool do_strands_motion = true;
-	bool do_strands_children = true;
 	
 	const bool dupli_target = smd->flag & eShrinkWrapCacheModifier_Flag_InternalTarget;
 	Object *ob = smd->object;
 	DupliObject *dob;
 	Strands *strands = NULL;
-	StrandsChildren *children = NULL;
 	DerivedMesh *target_dm;
 	float mat[4][4];
 	
 	ShrinkWrapCacheData shrinkwrap;
 	
-	if (do_strands_children) {
-		BKE_cache_modifier_find_strands(data->dupcache, ob, smd->hair_system, NULL, NULL, &children, NULL);
-	}
-	BKE_cache_modifier_find_strands(data->dupcache, ob, smd->hair_system, NULL, &strands, NULL, NULL);
+	/* only applies to parent strands */
+	if (!(process_flag & eCacheProcessFlag_DoStrands))
+		return;
+	
+	if (!BKE_cache_modifier_find_strands(data->dupcache, ob, smd->hair_system, NULL, &strands, NULL, NULL))
+		return;
 	
 	if (dupli_target) {
 		DupliObjectData *target_data;
@@ -1489,7 +1520,7 @@ static void shrinkwrap_process(ShrinkWrapCacheModifier *smd, CacheProcessContext
 			shrinkwrap_data_get_instances(&shrinkwrap, smd->target, mat, NULL);
 		}
 		
-		shrinkwrap_apply(smd, &shrinkwrap, strands, children, do_strands_motion);
+		shrinkwrap_apply(smd, &shrinkwrap, strands, NULL, do_strands_motion);
 		
 		shrinkwrap_data_free(&shrinkwrap);
 		
@@ -1544,7 +1575,7 @@ static void strandskey_foreach_id_link(StrandsKeyCacheModifier *skmd, CacheLibra
 	walk(userdata, cachelib, &skmd->modifier, (ID **)(&skmd->object));
 }
 
-static void strandskey_process(StrandsKeyCacheModifier *skmd, CacheProcessContext *UNUSED(ctx), CacheProcessData *data, int UNUSED(frame), int UNUSED(frame_prev))
+static void strandskey_process(StrandsKeyCacheModifier *skmd, CacheProcessContext *UNUSED(ctx), CacheProcessData *data, int UNUSED(frame), int UNUSED(frame_prev), int process_flag)
 {
 	const bool use_motion = skmd->flag & eStrandsKeyCacheModifier_Flag_UseMotionState;
 	Object *ob = skmd->object;
@@ -1552,6 +1583,9 @@ static void strandskey_process(StrandsKeyCacheModifier *skmd, CacheProcessContex
 	KeyBlock *actkb;
 	float *shape;
 	
+	/* only applies to parents */
+	if (!(process_flag & eCacheProcessFlag_DoStrands))
+		return;
 	if (!BKE_cache_modifier_find_strands(data->dupcache, ob, skmd->hair_system, NULL, &strands, NULL, NULL))
 		return;
 	if (use_motion && !strands->state)
@@ -1878,13 +1912,14 @@ static bool haircut_find_segment_cut(HaircutCacheModifier *hmd, HaircutCacheData
 	return false;
 }
 
-static bool haircut_find_first_strand_cut(HaircutCacheModifier *hmd, HaircutCacheData *data, StrandChildIterator *it_strand, float (*strand_deform)[3], float *r_cutoff)
+static bool haircut_find_first_strand_cut(HaircutCacheModifier *hmd, HaircutCacheData *data, StrandChildIterator *it_strand, float *r_cutoff)
 {
 	StrandChildVertexIterator it_vert;
 	int vprev = -1;
 	float cutoff = 0.0f;
 	
 	for (BKE_strand_child_vertex_iter_init(&it_vert, it_strand); BKE_strand_child_vertex_iter_valid(&it_vert); BKE_strand_child_vertex_iter_next(&it_vert)) {
+		StrandsChildVertex *verts = it_strand->verts;
 		bool found_cut = false;
 		float lambda_min = 1.0f;
 		HaircutCacheInstance *inst;
@@ -1892,7 +1927,7 @@ static bool haircut_find_first_strand_cut(HaircutCacheModifier *hmd, HaircutCach
 		if (it_vert.index == 0) {
 			for (inst = data->instances.first; inst; inst = inst->next) {
 				/* test root vertex */
-				if (haircut_test_

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list