[Bf-blender-cvs] [5de70a0] hair_system: Use the new hair thickness render settings in Cycles.
Lukas Tönne
noreply at git.blender.org
Thu Aug 14 14:10:41 CEST 2014
Commit: 5de70a0ceab6582dc121bfa58dc11f60744ff7a7
Author: Lukas Tönne
Date: Thu Aug 14 14:01:55 2014 +0200
Branches: hair_system
https://developer.blender.org/rB5de70a0ceab6582dc121bfa58dc11f60744ff7a7
Use the new hair thickness render settings in Cycles.
===================================================================
M intern/cycles/blender/blender_curves.cpp
M source/blender/blenkernel/BKE_hair.h
M source/blender/blenkernel/intern/hair.c
M source/blender/makesrna/intern/rna_hair.c
===================================================================
diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp
index 21fafaa..cdb8d81 100644
--- a/intern/cycles/blender/blender_curves.cpp
+++ b/intern/cycles/blender/blender_curves.cpp
@@ -682,10 +682,11 @@ static void ExportParticleCurveSegmentsMotion(Scene *scene, Mesh *mesh, Particle
static void ExportHairCurveSegments(Scene *scene, Mesh *mesh, BL::HairSystem b_hsys)
{
- /* XXX TODO put these into render parameters */
- float shape = 0.0f;
- float root_radius = 0.01f;
- float tip_radius = 0.01f;
+ BL::HairRenderSettings b_render(b_hsys.params().render());
+ float shape = b_render.shape();
+ float root_width = b_render.root_width() * b_render.radius_scale();
+ float tip_width = b_render.tip_width() * b_render.radius_scale();
+ bool closetip = b_render.use_closetip();
int num_keys = 0;
int num_curves = 0;
@@ -714,10 +715,8 @@ static void ExportHairCurveSegments(Scene *scene, Mesh *mesh, BL::HairSystem b_h
int num_curve_keys = 0;
for (; b_step_iter.valid(); b_step_iter.next()) {
- float time = 0.0f; // XXX
-
- bool closetip = true; // XXX
- float radius = shaperadius(shape, root_radius, tip_radius, time);
+ float param = b_step_iter.parameter();
+ float radius = shaperadius(shape, root_width, tip_width, param);
if (closetip && b_step_iter.index() == b_step_iter.totsteps() - 1)
radius = 0.0f;
@@ -726,7 +725,7 @@ static void ExportHairCurveSegments(Scene *scene, Mesh *mesh, BL::HairSystem b_h
mesh->add_curve_key(make_float3(co[0], co[1], co[2]), radius);
if(attr_intercept)
- attr_intercept->add(time);
+ attr_intercept->add(param);
++num_curve_keys;
}
@@ -748,10 +747,11 @@ static void ExportHairCurveSegments(Scene *scene, Mesh *mesh, BL::HairSystem b_h
static void ExportHairCurveSegmentsMotion(Scene *scene, Mesh *mesh, BL::HairSystem b_hsys, int time_index)
{
- /* XXX TODO put these into render parameters */
- float shape = 0.0f;
- float root_radius = 0.01f;
- float tip_radius = 0.01f;
+ BL::HairRenderSettings b_render(b_hsys.params().render());
+ float shape = b_render.shape();
+ float root_width = b_render.root_width() * b_render.radius_scale();
+ float tip_width = b_render.tip_width() * b_render.radius_scale();
+ bool closetip = b_render.use_closetip();
/* find attribute */
Attribute *attr_mP = mesh->curve_attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
@@ -779,10 +779,8 @@ static void ExportHairCurveSegmentsMotion(Scene *scene, Mesh *mesh, BL::HairSyst
for (; b_step_iter.valid(); b_step_iter.next()) {
if(i < mesh->curve_keys.size()) {
- float time = 0.0f; // XXX
-
- bool closetip = true; // XXX
- float radius = shaperadius(shape, root_radius, tip_radius, time);
+ float param = b_step_iter.parameter();
+ float radius = shaperadius(shape, root_width, tip_width, param);
if (closetip && b_step_iter.index() == b_step_iter.totsteps() - 1)
radius = 0.0f;
diff --git a/source/blender/blenkernel/BKE_hair.h b/source/blender/blenkernel/BKE_hair.h
index 71f8712..c462ee5 100644
--- a/source/blender/blenkernel/BKE_hair.h
+++ b/source/blender/blenkernel/BKE_hair.h
@@ -97,5 +97,6 @@ bool BKE_hair_render_iter_valid_step(struct HairRenderIterator *iter);
void BKE_hair_render_iter_next_hair(struct HairRenderIterator *iter);
void BKE_hair_render_iter_next_step(struct HairRenderIterator *iter);
void BKE_hair_render_iter_get(struct HairRenderIterator *iter, float co[3], float *radius);
+float BKE_hair_render_iter_param(struct HairRenderIterator *iter);
#endif
diff --git a/source/blender/blenkernel/intern/hair.c b/source/blender/blenkernel/intern/hair.c
index 44568bd..8425417 100644
--- a/source/blender/blenkernel/intern/hair.c
+++ b/source/blender/blenkernel/intern/hair.c
@@ -479,3 +479,8 @@ void BKE_hair_render_iter_get(HairRenderIterator *iter, float r_co[3], float *r_
if (r_co) copy_v3_v3(r_co, co);
if (r_radius) *r_radius = radius;
}
+
+float BKE_hair_render_iter_param(HairRenderIterator *iter)
+{
+ return iter->totsteps > 1 ? (float)iter->step / (float)(iter->totsteps-1) : 0.0f;
+}
diff --git a/source/blender/makesrna/intern/rna_hair.c b/source/blender/makesrna/intern/rna_hair.c
index 1b97ee4..16a3916 100644
--- a/source/blender/makesrna/intern/rna_hair.c
+++ b/source/blender/makesrna/intern/rna_hair.c
@@ -160,6 +160,11 @@ static void rna_HairRenderStepIterator_eval(HairRenderIterator *iter, float co[3
BKE_hair_render_iter_get(iter, co, radius);
}
+static float rna_HairRenderStepIterator_parameter(HairRenderIterator *iter)
+{
+ return BKE_hair_render_iter_param(iter);
+}
+
#else
static void rna_def_hair_params(BlenderRNA *brna)
@@ -430,6 +435,11 @@ static void rna_def_hair_render_step_iterator(BlenderRNA *brna)
RNA_def_function_output(func, parm);
parm = RNA_def_float(func, "radius", 0.0f, -FLT_MAX, FLT_MAX, "Radius", "Thickness of the hair wisp", -FLT_MAX, FLT_MAX);
RNA_def_function_output(func, parm);
+
+ func = RNA_def_function(srna, "parameter", "rna_HairRenderStepIterator_parameter");
+ RNA_def_function_ui_description(func, "Parameter along the hair curve");
+ parm = RNA_def_float(func, "result", 0.0f, 0.0f, 1.0f, "Result", "", 0.0f, 1.0f);
+ RNA_def_function_return(func, parm);
}
void RNA_def_hair(BlenderRNA *brna)
More information about the Bf-blender-cvs
mailing list