Commit: 0042eb10770f80cb602f7a1a49cef3d531ee9187
Author: Lukas Tönne
Date:   Sat Jun 30 13:01:52 2018 +0100
Branches: tmp_hair_curves
https://developer.blender.org/rB0042eb10770f80cb602f7a1a49cef3d531ee9187

Remove the mesh sample from fiber curve data.

Fiber curves are simple shapes for fibers now, not tied to a particular
place on the scalp mesh (cf. shape keys).

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

M       source/blender/blenkernel/BKE_hair.h
M       source/blender/blenkernel/intern/hair.c
M       source/blender/editors/object/object_modifier.c
M       source/blender/makesdna/DNA_hair_types.h
M       source/blender/makesrna/intern/rna_modifier.c

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

diff --git a/source/blender/blenkernel/BKE_hair.h 
b/source/blender/blenkernel/BKE_hair.h
index afc1fefbcb9..e24effd9227 100644
--- a/source/blender/blenkernel/BKE_hair.h
+++ b/source/blender/blenkernel/BKE_hair.h
@@ -65,7 +65,7 @@ void BKE_hair_fiber_curves_begin(struct HairSystem *hsys, int 
totcurves);
  * \param mesh_sample Origin of the fiber curve on the scalp mesh.
  * \param numverts Number of vertices in this fiber curve
  */
-void BKE_hair_set_fiber_curve(struct HairSystem *hsys, int index, const struct 
MeshSample *mesh_sample, int numverts,
+void BKE_hair_set_fiber_curve(struct HairSystem *hsys, int index, int numverts,
                               float taper_length, float taper_thickness);
 
 /* Finalize fiber curve update */
diff --git a/source/blender/blenkernel/intern/hair.c 
b/source/blender/blenkernel/intern/hair.c
index de52bddb4d9..5020f9774a9 100644
--- a/source/blender/blenkernel/intern/hair.c
+++ b/source/blender/blenkernel/intern/hair.c
@@ -228,13 +228,12 @@ void BKE_hair_fiber_curves_begin(HairSystem *hsys, int 
totcurves)
        }
 }
 
-void BKE_hair_set_fiber_curve(HairSystem *hsys, int index, const MeshSample 
*mesh_sample, int numverts,
+void BKE_hair_set_fiber_curve(HairSystem *hsys, int index, int numverts,
                               float taper_length, float taper_thickness)
 {
        BLI_assert(index <= hsys->curve_data.totcurves);
        
        HairFiberCurve *curve = &hsys->curve_data.curves[index];
-       memcpy(&curve->mesh_sample, mesh_sample, sizeof(MeshSample));
        curve->numverts = numverts;
        curve->taper_length = taper_length;
        curve->taper_thickness = taper_thickness;
@@ -359,22 +358,12 @@ bool BKE_hair_bind_follicles(HairSystem *hsys, const Mesh 
*scalp)
                return false;
        }
        
-       float (*strandloc)[3] = MEM_mallocN(sizeof(float) * 3 * num_strands, 
"strand locations");
-       {
-               for (int i = 0; i < num_strands; ++i)
-               {
-                       float nor[3], tang[3];
-                       if (!BKE_mesh_sample_eval(scalp, 
&hsys->curve_data.curves[i].mesh_sample, strandloc[i], nor, tang))
-                       {
-                               zero_v3(strandloc[i]);
-                       }
-               }
-       }
-       
        KDTree *tree = BLI_kdtree_new(num_strands);
        for (int c = 0; c < num_strands; ++c)
        {
-               BLI_kdtree_insert(tree, c, strandloc[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);
        
@@ -391,7 +380,6 @@ bool BKE_hair_bind_follicles(HairSystem *hsys, const Mesh 
*scalp)
        }
        
        BLI_kdtree_free(tree);
-       MEM_freeN(strandloc);
        
        return true;
 }
@@ -412,21 +400,18 @@ BLI_INLINE int hair_get_strand_subdiv_numverts(int 
numstrands, int numverts, int
 
 /* Subdivide a curve */
 static int hair_curve_subdivide(const HairFiberCurve* curve, const 
HairFiberVertex* verts,
-                                int subdiv, const float rootpos[3], 
HairFiberVertex *r_verts)
+                                int subdiv, HairFiberVertex *r_verts)
 {
        {
                /* 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);
                
                HairFiberVertex *dst = r_verts;
                for (int i = 0; i < curve->numverts; ++i) {
-                       add_v3_v3v3(dst->co, verts[i].co, offset);
+                       copy_v3_v3(dst->co, verts[i].co);
                        dst += step;
                }
        }
@@ -479,15 +464,13 @@ static void hair_curve_transport_frame(const float 
co1[3], const float co2[3],
 }
 
 /* Calculate tangent and normal vectors for all vertices on a curve */
-static void hair_curve_calc_vectors(const HairFiberVertex* verts, int 
numverts, float rootmat[3][3],
+static void hair_curve_calc_vectors(const HairFiberVertex* verts, int numverts,
                                     float (*r_tangents)[3], float 
(*r_normals)[3])
 {
        BLI_assert(numverts >= 2);
        
-       float prev_tang[3], prev_nor[3];
-       
-       copy_v3_v3(prev_tang, rootmat[2]);
-       copy_v3_v3(prev_nor, rootmat[0]);
+       float prev_tang[3] = {0.0f, 0.0f, 1.0f};
+       float prev_nor[3] = {1.0f, 0.0f, 0.0f};
        
        hair_curve_transport_frame(
                verts[0].co, verts[1].co,
@@ -610,15 +593,9 @@ int BKE_hair_export_cache_update(HairExportCache *cache, 
const HairSystem *hsys,
                        float (*tangents)[3] = 
&cache->fiber_tangents[curve->vertstart];
                        float (*normals)[3] = 
&cache->fiber_normals[curve->vertstart];
                        
-                       /* 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]);
-                       
-                       hair_curve_subdivide(curve_orig, verts_orig, subdiv, 
rootpos, verts);
+                       hair_curve_subdivide(curve_orig, verts_orig, subdiv, 
verts);
                        
-                       hair_curve_calc_vectors(verts, curve->numverts, 
rootmat, tangents, normals);
+                       hair_curve_calc_vectors(verts, curve->numverts, 
tangents, normals);
                }
        }
 
diff --git a/source/blender/editors/object/object_modifier.c 
b/source/blender/editors/object/object_modifier.c
index 0c100308bb9..5e753c458c6 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -2467,7 +2467,7 @@ static int hair_generate_follicles_exec(bContext *C, 
wmOperator *op)
                BKE_hair_fiber_curves_begin(hsys, hsys->pattern->num_follicles);
                for (int i = 0; i < hsys->pattern->num_follicles; ++i)
                {
-                       BKE_hair_set_fiber_curve(hsys, i, 
&hsys->pattern->follicles[i].mesh_sample, numverts, taper_length, 
taper_thickness);
+                       BKE_hair_set_fiber_curve(hsys, i, numverts, 
taper_length, taper_thickness);
                }
                BKE_hair_fiber_curves_end(hsys);
                for (int i = 0; i < hsys->pattern->num_follicles; ++i)
diff --git a/source/blender/makesdna/DNA_hair_types.h 
b/source/blender/makesdna/DNA_hair_types.h
index 2faca93592b..790d7952f4a 100644
--- a/source/blender/makesdna/DNA_hair_types.h
+++ b/source/blender/makesdna/DNA_hair_types.h
@@ -52,7 +52,6 @@ typedef struct HairPattern {
 } HairPattern;
 
 typedef struct HairFiberCurve {
-       MeshSample mesh_sample;             /* Sample on the scalp mesh for the 
root vertex */
        int vertstart;                      /* Offset in the vertex array where 
the curve starts */
        int numverts;                       /* Number of vertices in the curve 
*/
 
diff --git a/source/blender/makesrna/intern/rna_modifier.c 
b/source/blender/makesrna/intern/rna_modifier.c
index 7e56c4a4c86..2fa3285a781 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -1224,14 +1224,11 @@ static void rna_Hair_fiber_curves_apply(ID *id, 
HairModifierData *hmd, bContext
        const int totcurves = BLI_listbase_count(&hmd->fiber_curves);
        int i = 0;
        
-       MeshSample msample;
-       memset(&msample, 0, sizeof(msample));
-       
        BKE_hair_fiber_curves_begin(hmd->hair_system, totcurves);
        i = 0;
        for (HairModifierFiberCurve *curve = hmd->fiber_curves.first; curve; 
curve = curve->next, ++i)
        {
-               BKE_hair_set_fiber_curve(hmd->hair_system, i, &msample, 
curve->numverts, 0.1, 1.0);
+               BKE_hair_set_fiber_curve(hmd->hair_system, i, curve->numverts, 
0.1, 1.0);
        }
        BKE_hair_fiber_curves_end(hmd->hair_system);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to