[Bf-blender-cvs] [0d6c8dd] strand_gpu: Refactoring: Renamed the "StrandRoot" arrays to "StrandFiber" for clarity.

Lukas Tönne noreply at git.blender.org
Thu Jul 7 07:54:35 CEST 2016


Commit: 0d6c8dd8e9d6e69cf56119a20550ed3ec66f1e10
Author: Lukas Tönne
Date:   Thu Jul 7 07:50:51 2016 +0200
Branches: strand_gpu
https://developer.blender.org/rB0d6c8dd8e9d6e69cf56119a20550ed3ec66f1e10

Refactoring: Renamed the "StrandRoot" arrays to "StrandFiber" for clarity.

The strand system contains 2 levels of curve geometry:
- "Strands" are the abstract control strands, editable by the user and thus few in number.
- "Fibers" are renderable curves, generated based on those strands.

"Roots" now is used exclusively for hair follicles, which are attached to
the scalp mesh, i.e. follow the mesh deformation.

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

M	release/scripts/startup/bl_ui/properties_data_modifier.py
M	source/blender/blenkernel/BKE_editstrands.h
M	source/blender/blenkernel/BKE_strands.h
M	source/blender/blenkernel/intern/editstrands.c
M	source/blender/blenkernel/intern/strands.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/editors/hair/hair_object_strands.c
M	source/blender/editors/hair/hair_undo.c
M	source/blender/editors/object/object_strands.c
M	source/blender/editors/space_view3d/drawobject.c
M	source/blender/editors/space_view3d/drawstrands.c
M	source/blender/gpu/GPU_buffers.h
M	source/blender/gpu/intern/gpu_buffers.c
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesdna/DNA_strand_types.h
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/modifiers/intern/MOD_strands.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 3c1af94..825dff4 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -885,12 +885,12 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         split = layout.split()
         col = split.column()
         col.prop(md, "seed")
-        col.prop(md, "num_roots")
+        col.prop(md, "num_fibers")
 
         col = split.column()
         col.label(text="Display:")
-        col.prop(md, "show_control_strands", text="Control Strands")
-        col.prop(md, "show_render_strands", text="Render Strands")
+        col.prop(md, "show_strands", text="Control Strands")
+        col.prop(md, "show_fibers", text="Fibers")
 
     def SUBSURF(self, layout, ob, md):
         layout.row().prop(md, "subdivision_type", expand=True)
diff --git a/source/blender/blenkernel/BKE_editstrands.h b/source/blender/blenkernel/BKE_editstrands.h
index 7e56170..4b21104 100644
--- a/source/blender/blenkernel/BKE_editstrands.h
+++ b/source/blender/blenkernel/BKE_editstrands.h
@@ -46,16 +46,16 @@ struct DerivedMesh;
 struct Mesh;
 struct Object;
 struct Strands;
-struct StrandRoot;
+struct StrandFiber;
 
 typedef struct BMEditStrands {
 	BMEditMesh base;
 	
 	/* Hair follicles */
-	struct StrandRoot *roots;
+	struct StrandFiber *fibers;
 	/* Scalp mesh for fixing root vertices */
 	struct DerivedMesh *root_dm;
-	int num_roots;
+	int num_fibers;
 	
 	int flag;
 	
@@ -68,7 +68,7 @@ typedef enum BMEditStrandsFlag {
 } BMEditStrandsFlag;
 
 struct BMEditStrands *BKE_editstrands_create(struct BMesh *bm, struct DerivedMesh *root_dm,
-                                             struct StrandRoot *roots, int num_roots);
+                                             struct StrandFiber *fibers, int num_fibers);
 struct BMEditStrands *BKE_editstrands_copy(struct BMEditStrands *es);
 struct BMEditStrands *BKE_editstrands_from_object(struct Object *ob);
 void BKE_editstrands_update_linked_customdata(struct BMEditStrands *es);
diff --git a/source/blender/blenkernel/BKE_strands.h b/source/blender/blenkernel/BKE_strands.h
index df702cb..f643535 100644
--- a/source/blender/blenkernel/BKE_strands.h
+++ b/source/blender/blenkernel/BKE_strands.h
@@ -48,8 +48,8 @@ void BKE_strands_free(struct Strands *strands);
 bool BKE_strands_get_location(const struct StrandCurve *curve, struct DerivedMesh *root_dm, float loc[3]);
 bool BKE_strands_get_matrix(const struct StrandCurve *curve, struct DerivedMesh *root_dm, float mat[4][4]);
 
-bool BKE_strands_get_root_location(const struct StrandRoot *root, struct DerivedMesh *root_dm, float loc[3]);
-bool BKE_strands_get_root_matrix(const struct StrandRoot *root, struct DerivedMesh *root_dm, float mat[4][4]);
+bool BKE_strands_get_fiber_location(const struct StrandFiber *fiber, struct DerivedMesh *root_dm, float loc[3]);
+bool BKE_strands_get_fiber_matrix(const struct StrandFiber *fiber, struct DerivedMesh *root_dm, float mat[4][4]);
 
 /* ------------------------------------------------------------------------- */
 
@@ -69,35 +69,35 @@ typedef struct StrandCurveData {
 	float mat[4][4];
 } StrandCurveData;
 
-typedef struct StrandRootData {
+typedef struct StrandFiberData {
 	/* Position */
 	float co[3];
 	/* Indices of control strands for interpolation */
 	unsigned int control_index[4];
 	/* Weights of control strands for interpolation */
 	float control_weight[4];
-} StrandRootData;
+} StrandFiberData;
 
 typedef struct StrandData {
 	/* Array of vertices */
 	StrandVertexData *verts;
 	/* Array of curves */
 	StrandCurveData *curves;
-	/* Array of root points */
-	StrandRootData *roots;
+	/* Array of fibers */
+	StrandFiberData *fibers;
 	
 	/* Total number of vertices */
 	int totverts;
 	/* Total number of curves */
 	int totcurves;
-	/* Total number of root points */
-	int totroots;
+	/* Total number of fibers */
+	int totfibers;
 	
 	struct GPUDrawStrands *gpu_buffer;
 } StrandData;
 
 struct StrandData *BKE_strand_data_calc(struct Strands *strands, struct DerivedMesh *scalp,
-                                        StrandRoot *roots, int num_roots);
+                                        StrandFiber *fibers, int num_fibers);
 void BKE_strand_data_free(struct StrandData *data);
 
 /* ------------------------------------------------------------------------- */
@@ -107,7 +107,7 @@ void BKE_strands_test_init(struct Strands *strands, struct DerivedMesh *scalp,
                            unsigned int seed);
 
 
-struct StrandRoot *BKE_strands_scatter(struct Strands *strands,
+struct StrandFiber *BKE_strands_scatter(struct Strands *strands,
                                        struct DerivedMesh *scalp, unsigned int amount,
                                        unsigned int seed);
 
diff --git a/source/blender/blenkernel/intern/editstrands.c b/source/blender/blenkernel/intern/editstrands.c
index 8110aa8..3b077f5 100644
--- a/source/blender/blenkernel/intern/editstrands.c
+++ b/source/blender/blenkernel/intern/editstrands.c
@@ -60,15 +60,15 @@
 #include "intern/bmesh_mesh_conv.h"
 #include "intern/bmesh_strands_conv.h"
 
-BMEditStrands *BKE_editstrands_create(BMesh *bm, DerivedMesh *root_dm, StrandRoot *roots, int num_roots)
+BMEditStrands *BKE_editstrands_create(BMesh *bm, DerivedMesh *root_dm, StrandFiber *fibers, int num_fibers)
 {
 	BMEditStrands *es = MEM_callocN(sizeof(BMEditStrands), __func__);
 	
 	es->base.bm = bm;
 	es->root_dm = CDDM_copy(root_dm);
-	if (roots && num_roots > 0) {
-		es->roots = MEM_dupallocN(roots);
-		es->num_roots = num_roots;
+	if (fibers && num_fibers > 0) {
+		es->fibers = MEM_dupallocN(fibers);
+		es->num_fibers = num_fibers;
 	}
 	
 	return es;
@@ -81,9 +81,9 @@ BMEditStrands *BKE_editstrands_copy(BMEditStrands *es)
 	
 	es_copy->base.bm = BM_mesh_copy(es->base.bm);
 	es_copy->root_dm = CDDM_copy(es->root_dm);
-	if (es->roots) {
-		es_copy->roots = MEM_dupallocN(es->roots);
-		es_copy->num_roots = es->num_roots;
+	if (es->fibers) {
+		es_copy->fibers = MEM_dupallocN(es->fibers);
+		es_copy->num_fibers = es->num_fibers;
 	}
 	
 	es_copy->gpu_buffer = NULL;
@@ -137,8 +137,8 @@ void BKE_editstrands_free(BMEditStrands *es)
 		BM_mesh_free(es->base.bm);
 	if (es->root_dm)
 		es->root_dm->release(es->root_dm);
-	if (es->roots)
-		MEM_freeN(es->roots);
+	if (es->fibers)
+		MEM_freeN(es->fibers);
 	
 	if (es->gpu_buffer)
 		GPU_strands_buffer_free(es->gpu_buffer);
diff --git a/source/blender/blenkernel/intern/strands.c b/source/blender/blenkernel/intern/strands.c
index d0183ba..196638b 100644
--- a/source/blender/blenkernel/intern/strands.c
+++ b/source/blender/blenkernel/intern/strands.c
@@ -111,10 +111,10 @@ bool BKE_strands_get_matrix(const StrandCurve *curve, DerivedMesh *root_dm, floa
 	}
 }
 
-bool BKE_strands_get_root_location(const StrandRoot *root, DerivedMesh *root_dm, float loc[3])
+bool BKE_strands_get_fiber_location(const StrandFiber *fiber, DerivedMesh *root_dm, float loc[3])
 {
 	float nor[3], tang[3];
-	if (BKE_mesh_sample_eval(root_dm, &root->root, loc, nor, tang)) {
+	if (BKE_mesh_sample_eval(root_dm, &fiber->root, loc, nor, tang)) {
 		return true;
 	}
 	else {
@@ -123,9 +123,9 @@ bool BKE_strands_get_root_location(const StrandRoot *root, DerivedMesh *root_dm,
 	}
 }
 
-bool BKE_strands_get_root_matrix(const StrandRoot *root, DerivedMesh *root_dm, float mat[4][4])
+bool BKE_strands_get_fiber_matrix(const StrandFiber *fiber, DerivedMesh *root_dm, float mat[4][4])
 {
-	if (BKE_mesh_sample_eval(root_dm, &root->root, mat[3], mat[2], mat[0])) {
+	if (BKE_mesh_sample_eval(root_dm, &fiber->root, mat[3], mat[2], mat[0])) {
 		cross_v3_v3v3(mat[1], mat[2], mat[0]);
 		mat[0][3] = 0.0f;
 		mat[1][3] = 0.0f;
@@ -142,16 +142,16 @@ bool BKE_strands_get_root_matrix(const StrandRoot *root, DerivedMesh *root_dm, f
 /* ------------------------------------------------------------------------- */
 
 StrandData *BKE_strand_data_calc(Strands *strands, DerivedMesh *scalp,
-                                 StrandRoot *roots, int num_roots)
+                                 StrandFiber *fibers, int num_fibers)
 {
 	StrandData *data = MEM_callocN(sizeof(StrandData), "StrandData");
 	
 	data->totverts = strands->totverts;
 	data->totcurves = strands->totcurves;
-	data->totroots = num_roots;
+	data->totfibers = num_fibers;
 	data->verts = MEM_mallocN(sizeof(StrandVertexData) * data->totverts, "StrandVertexData");
 	data->curves = MEM_mallocN(sizeof(StrandCurveData) * data->totcurves, "StrandCurveData");
-	data->roots = MEM_mallocN(sizeof(StrandRootData) * data->totroots, "StrandRootData");
+	data->fibers = MEM_mallocN(sizeof(StrandFiberData) * data->totfibers, "StrandFiberData");
 	
 	int c;
 	StrandCurve *scurve = strands->curves;
@@ -171,16 +171,16 @@ StrandData *BKE_strand_data_calc(Strands *strands, DerivedMesh *scalp,
 	}
 	
 	int i;
-	StrandRoot *sroot = roots;
-	StrandRootData *root = data->roots;
-	for (i = 0; i < data->totroots; ++i, ++sroot, ++root) {
+	StrandFiber *sfiber = fibers;
+	StrandFiberData *fiber = data->fibers;
+	for (i = 0; i < data->totfibers; ++i, ++sfiber, ++fiber) {
 		float nor[3], tang[3];
-		BKE_mesh_sample_eval(scalp, &sroot->root, root->co, nor, tang);
+		BKE_mesh_sample_eval(scalp, &sfiber->root, fiber->co, nor, tang);
 		
 		int k;
 		for (k = 0; k < 4; ++k) {
-			root->control_index[k] = sroot->control_index[k];
-			root->control_weight[k] = sroot->control_weight[k];
+			fiber->control_index[k] = sfiber->control_index[k];
+			fiber->control_weight[k] = sfiber->control_weight[k];
 		}
 	}
 	
@@ -196,8 +196,8 @@ void BKE_strand_data_free(StrandData *data)
 			MEM_freeN(data->verts);
 		if (data->curves)
 			MEM_freeN(data->curves);
-		if (data->roots)
-			MEM_freeN(data->roots);
+		if (data->fibers)
+			MEM_freeN(data->fibers);
 		MEM_freeN(data);
 	}
 }
@@ -262,9 +262,9 @@ void BKE_strands_test_init(struct Strands *strands, struct DerivedMesh *scalp,
 	BLI_rng_free(rng);
 }
 
-BLI_INLINE void verify_root_weights(StrandRoot *root)
+BLI_INLINE void verify_fiber_weights(StrandFiber *fiber)
 {
-	const float *w = root->control_weight;
+	const float *w = fiber->control_weight;
 	


@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list