[Bf-blender-cvs] [3f99451465a] hair_guides_grooming: Add an offset to ensure hair guide curves start on the scalp in export caches.
Lukas Tönne
noreply at git.blender.org
Sat May 26 15:14:57 CEST 2018
Commit: 3f99451465a87b1938ff5c3538f15494b31b00d6
Author: Lukas Tönne
Date: Sat May 26 14:14:31 2018 +0100
Branches: hair_guides_grooming
https://developer.blender.org/rB3f99451465a87b1938ff5c3538f15494b31b00d6
Add an offset to ensure hair guide curves start on the scalp in export caches.
===================================================================
M source/blender/blenkernel/intern/hair.c
M source/blender/makesrna/intern/rna_groom.c
===================================================================
diff --git a/source/blender/blenkernel/intern/hair.c b/source/blender/blenkernel/intern/hair.c
index 475e0589322..979c799810f 100644
--- a/source/blender/blenkernel/intern/hair.c
+++ b/source/blender/blenkernel/intern/hair.c
@@ -473,14 +473,22 @@ BLI_INLINE int hair_get_strand_subdiv_numverts(int numstrands, int numverts, int
}
/* Subdivide a curve */
-static int hair_guide_subdivide(const HairGuideCurve* curve, const HairGuideVertex* verts, int subdiv, HairGuideVertex *r_verts)
+static int hair_guide_subdivide(const HairGuideCurve* curve, const HairGuideVertex* verts,
+ int subdiv, const float rootpos[3], HairGuideVertex *r_verts)
{
{
- /* Move vertex positions from the dense array to their initial configuration for subdivision. */
+ /* Move vertex positions from the dense array to their initial configuration for subdivision.
+ * Also add offset to ensure the curve starts on the scalp surface.
+ */
const int step = (1 << subdiv);
+
+ BLI_assert(curve->numverts > 0);
+ float offset[3];
+ sub_v3_v3v3(offset, rootpos, verts[0].co);
+
HairGuideVertex *dst = r_verts;
for (int i = 0; i < curve->numverts; ++i) {
- copy_v3_v3(dst->co, verts[i].co);
+ add_v3_v3v3(dst->co, verts[i].co, offset);
dst += step;
}
}
@@ -668,17 +676,15 @@ int BKE_hair_export_cache_update(HairExportCache *cache, const HairSystem *hsys,
float (*tangents)[3] = &cache->guide_tangents[curve->vertstart];
float (*normals)[3] = &cache->guide_normals[curve->vertstart];
- hair_guide_subdivide(curve_orig, verts_orig, subdiv, verts);
+ /* Root matrix for offsetting to the scalp surface and for initial normal direction */
+ float rootpos[3];
+ float rootmat[3][3];
+ BKE_mesh_sample_eval(scalp, &curve->mesh_sample, rootpos, rootmat[2], rootmat[0]);
+ cross_v3_v3v3(rootmat[1], rootmat[2], rootmat[0]);
- {
- /* Root matrix for defining the initial normal direction */
- float rootpos[3];
- float rootmat[3][3];
- BKE_mesh_sample_eval(scalp, &curve->mesh_sample, rootpos, rootmat[2], rootmat[0]);
- cross_v3_v3v3(rootmat[1], rootmat[2], rootmat[0]);
-
- hair_guide_calc_vectors(verts, curve->numverts, rootmat, tangents, normals);
- }
+ hair_guide_subdivide(curve_orig, verts_orig, subdiv, rootpos, verts);
+
+ hair_guide_calc_vectors(verts, curve->numverts, rootmat, tangents, normals);
}
}
diff --git a/source/blender/makesrna/intern/rna_groom.c b/source/blender/makesrna/intern/rna_groom.c
index 6b3e068a68f..cb8e42265fe 100644
--- a/source/blender/makesrna/intern/rna_groom.c
+++ b/source/blender/makesrna/intern/rna_groom.c
@@ -153,6 +153,8 @@ static void rna_def_groom_bundle(BlenderRNA *brna)
RNA_def_property_update(prop, NC_GROOM | ND_DRAW, "rna_Groom_update_data");
prop = RNA_def_property(srna, "guides_count", PROP_INT, PROP_NONE);
+ RNA_def_property_range(prop, 1, INT_MAX);
+ RNA_def_property_ui_range(prop, 1, 1000, 1, -1);
RNA_def_property_ui_text(prop, "Guides Count", "Number of hair guides to generate in this region");
RNA_def_property_update(prop, NC_GROOM | ND_DRAW, "rna_Groom_update_data");
}
More information about the Bf-blender-cvs
mailing list