[Bf-blender-cvs] [4a5c60b81be] hair_object: Remove the "bind" flag and function for hair.

Lukas Tönne noreply at git.blender.org
Sun Nov 4 13:02:39 CET 2018


Commit: 4a5c60b81be9ab16e38f077c8720a5b8e5833a4e
Author: Lukas Tönne
Date:   Sun Nov 4 12:00:43 2018 +0000
Branches: hair_object
https://developer.blender.org/rB4a5c60b81be9ab16e38f077c8720a5b8e5833a4e

Remove the "bind" flag and function for hair.

This is a remnant of the previous system where actual fibers were always
interpolated from one or more actual curves. Now each follicle simply gets
its own curve.

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

M	source/blender/blenkernel/BKE_hair.h
M	source/blender/blenkernel/intern/hair.c
M	source/blender/draw/intern/draw_cache_impl_hair.c
M	source/blender/editors/hair/edithair_test.c
M	source/blender/makesdna/DNA_hair_types.h

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

diff --git a/source/blender/blenkernel/BKE_hair.h b/source/blender/blenkernel/BKE_hair.h
index f7b3092f0aa..cf4f44e53bd 100644
--- a/source/blender/blenkernel/BKE_hair.h
+++ b/source/blender/blenkernel/BKE_hair.h
@@ -155,8 +155,6 @@ void BKE_hair_generate_follicles_ex(
         int count,
         const float *loop_weights);
 
-bool BKE_hair_bind_follicles(struct HairSystem *hsys, const struct Mesh *scalp);
-
 /* === Draw Settings === */
 
 struct HairDrawSettings* BKE_hair_draw_settings_new(void);
diff --git a/source/blender/blenkernel/intern/hair.c b/source/blender/blenkernel/intern/hair.c
index bb4cea70b2f..ed9eda56d4f 100644
--- a/source/blender/blenkernel/intern/hair.c
+++ b/source/blender/blenkernel/intern/hair.c
@@ -354,7 +354,6 @@ void BKE_hair_generate_follicles_ex(
 		BKE_mesh_sample_free_generator(gen);
 	}
 	
-	hsys->flag |= HAIR_SYSTEM_UPDATE_FOLLICLE_BINDING;
 	BKE_hair_batch_cache_dirty(hsys, BKE_HAIR_BATCH_DIRTY_ALL);
 }
 
@@ -367,7 +366,6 @@ void BKE_hair_fiber_curves_begin(HairSystem *hsys, int totcurves)
 		hsys->curve_data.curves = MEM_reallocN(hsys->curve_data.curves, sizeof(HairFiberCurve) * totcurves);
 		hsys->curve_data.totcurves = totcurves;
 
-		hsys->flag |= HAIR_SYSTEM_UPDATE_FOLLICLE_BINDING;
 		BKE_hair_batch_cache_dirty(hsys, BKE_HAIR_BATCH_DIRTY_ALL);
 	}
 }
@@ -382,7 +380,6 @@ void BKE_hair_set_fiber_curve(HairSystem *hsys, int index, int numverts,
 	curve->taper_length = taper_length;
 	curve->taper_thickness = taper_thickness;
 	
-	hsys->flag |= HAIR_SYSTEM_UPDATE_FOLLICLE_BINDING;
 	BKE_hair_batch_cache_dirty(hsys, BKE_HAIR_BATCH_DIRTY_ALL);
 }
 
@@ -447,7 +444,6 @@ void BKE_hair_set_fiber_curves(HairSystem *hsys, HairCurveData *curves)
 	BLI_assert(vertcount <= hsys->curve_data.totverts);
 #endif
 
-	hsys->flag |= HAIR_SYSTEM_UPDATE_FOLLICLE_BINDING;
 	BKE_hair_batch_cache_dirty(hsys, BKE_HAIR_BATCH_DIRTY_ALL);
 }
 
@@ -467,66 +463,9 @@ void BKE_hair_clear_fiber_curves(HairSystem *hsys)
 	}
 	hsys->curve_data.totverts = 0;
 
-	hsys->flag &= ~HAIR_SYSTEM_UPDATE_FOLLICLE_BINDING;
 	BKE_hair_batch_cache_dirty(hsys, BKE_HAIR_BATCH_DIRTY_ALL);
 }
 
-/* ================================= */
-
-bool BKE_hair_bind_follicles(HairSystem *hsys, const Mesh *scalp)
-{
-	if (!(hsys->flag & HAIR_SYSTEM_UPDATE_FOLLICLE_BINDING))
-	{
-		return true;
-	}
-	hsys->flag &= ~HAIR_SYSTEM_UPDATE_FOLLICLE_BINDING;
-	
-	HairPattern *pattern = hsys->pattern;
-	if (!pattern)
-	{
-		return true;
-	}
-	
-	const int num_strands = hsys->curve_data.totcurves;
-	/* Need at least one curve for binding */
-	if (num_strands == 0)
-	{
-		HairIterator iter;
-		HairFollicle *follicle;
-		BKE_HAIR_ITER_FOLLICLES(follicle, &iter, pattern) {
-			for (int k = 0; k < 4; ++k) {
-				follicle->curve = HAIR_CURVE_INDEX_NONE;
-			}
-		}
-		return false;
-	}
-	
-	KDTree *tree = BLI_kdtree_new(num_strands);
-	for (int c = 0; c < num_strands; ++c)
-	{
-		const int vertstart = hsys->curve_data.curves[c].vertstart;
-		const float *rootco = hsys->curve_data.verts[vertstart].co;
-		BLI_kdtree_insert(tree, c, rootco);
-	}
-	BLI_kdtree_balance(tree);
-	
-	{
-		HairIterator iter;
-		HairFollicle *follicle;
-		BKE_HAIR_ITER_FOLLICLES(follicle, &iter, pattern) {
-			float loc[3], nor[3], tang[3];
-			if (BKE_mesh_sample_eval(scalp, &follicle->mesh_sample, loc, nor, tang)) {
-				follicle->curve = BLI_kdtree_find_nearest(tree, loc, NULL);
-			}
-		}
-	}
-	
-	BLI_kdtree_free(tree);
-	
-	return true;
-}
-
-
 /* === Depsgraph evaluation === */
 
 void BKE_hair_eval_geometry(const Depsgraph *depsgraph, HairSystem *hsys)
diff --git a/source/blender/draw/intern/draw_cache_impl_hair.c b/source/blender/draw/intern/draw_cache_impl_hair.c
index 97c2b7b3f2a..b97ea359244 100644
--- a/source/blender/draw/intern/draw_cache_impl_hair.c
+++ b/source/blender/draw/intern/draw_cache_impl_hair.c
@@ -113,9 +113,6 @@ static void hair_batch_cache_init(HairSystem *hsys)
 
 static HairBatchCache *hair_batch_cache_get(HairSystem *hsys)
 {
-	// Hair follicle binding needs to be updated after changes
-	BLI_assert(!(hsys->flag & HAIR_SYSTEM_UPDATE_FOLLICLE_BINDING));
-	
 	if (!hair_batch_cache_valid(hsys)) {
 		hair_batch_cache_clear(hsys);
 		hair_batch_cache_init(hsys);
diff --git a/source/blender/editors/hair/edithair_test.c b/source/blender/editors/hair/edithair_test.c
index 030870c4999..a21a22eb38b 100644
--- a/source/blender/editors/hair/edithair_test.c
+++ b/source/blender/editors/hair/edithair_test.c
@@ -126,7 +126,6 @@ static int add_test_hair_exec(bContext *C, wmOperator *op)
 	const int count = RNA_int_get(op->ptr, "count");
 
 	hair_generate_follicles_ex(edit->pattern, scalp, seed, count, NULL);
-	//	hsys->flag |= HAIR_SYSTEM_UPDATE_FOLLICLE_BINDING;
 
 	BKE_hair_batch_cache_dirty(hsys, BKE_HAIR_BATCH_DIRTY_ALL);
 	DEG_id_tag_update(obedit->data, DEG_TAG_SELECT_UPDATE);
diff --git a/source/blender/makesdna/DNA_hair_types.h b/source/blender/makesdna/DNA_hair_types.h
index e863deb9a2e..1cc17f6b843 100644
--- a/source/blender/makesdna/DNA_hair_types.h
+++ b/source/blender/makesdna/DNA_hair_types.h
@@ -125,11 +125,9 @@ typedef struct HairSystem {
 	void *draw_batch_cache;
 } HairSystem;
 
-typedef enum eHairSystemFlag
-{
-	/* Curve positions have changed, rebind hair follicles */
-	HAIR_SYSTEM_UPDATE_FOLLICLE_BINDING = (1 << 8),
-} eHairSystemFlag;
+// typedef enum eHairSystemFlag
+// {
+// } eHairSystemFlag;
 
 typedef struct HairDrawSettings
 {



More information about the Bf-blender-cvs mailing list