[Bf-blender-cvs] [eb843af] hair_system: Moved hair render settings into own struct and added strand thickness parameters.
Lukas Tönne
noreply at git.blender.org
Thu Aug 14 14:10:40 CEST 2014
Commit: eb843af7c9dc17e96da1a38ef56540a481824164
Author: Lukas Tönne
Date: Thu Aug 14 12:56:53 2014 +0200
Branches: hair_system
https://developer.blender.org/rBeb843af7c9dc17e96da1a38ef56540a481824164
Moved hair render settings into own struct and added strand thickness
parameters.
===================================================================
M release/scripts/startup/bl_ui/properties_physics_common.py
M release/scripts/startup/bl_ui/properties_physics_hair.py
M source/blender/blenkernel/intern/hair.c
M source/blender/makesdna/DNA_hair_types.h
M source/blender/makesrna/intern/rna_hair.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_physics_common.py b/release/scripts/startup/bl_ui/properties_physics_common.py
index c35713a..fb39428 100644
--- a/release/scripts/startup/bl_ui/properties_physics_common.py
+++ b/release/scripts/startup/bl_ui/properties_physics_common.py
@@ -75,7 +75,7 @@ class PHYSICS_PT_add(PhysicButtonsPanel, Panel):
physics_add(self, col, context.collision, "Collision", 'COLLISION', 'MOD_PHYSICS', False)
physics_add(self, col, context.cloth, "Cloth", 'CLOTH', 'MOD_CLOTH', True)
physics_add(self, col, context.dynamic_paint, "Dynamic Paint", 'DYNAMIC_PAINT', 'MOD_DYNAMICPAINT', True)
- physics_add(self, col, context.hair, "Hair", 'HAIR', 'MOD_HAIR', True)
+ physics_add(self, col, context.hair, "Hair", 'HAIR', 'HAIR', True)
col = split.column()
diff --git a/release/scripts/startup/bl_ui/properties_physics_hair.py b/release/scripts/startup/bl_ui/properties_physics_hair.py
index 91bbcaa..85ac249 100644
--- a/release/scripts/startup/bl_ui/properties_physics_hair.py
+++ b/release/scripts/startup/bl_ui/properties_physics_hair.py
@@ -105,10 +105,22 @@ class PHYSICS_PT_hair_render(PhysicButtonsPanel, Panel):
md = context.hair
hsys = md.hair_system
params = hsys.params
+ render = params.render
col = layout.column()
- col.prop(params, "render_hairs")
- col.prop(params, "curl_smoothing")
+ col.prop(render, "render_hairs")
+
+ col.label("Curl:")
+ col.prop(render, "curl_smoothing")
+
+ col.label("Strands:")
+ col.prop(render, "shape", text="Shape")
+ row = col.row()
+ row.prop(render, "root_width", text="Root")
+ row.prop(render, "tip_width", text="Tip")
+ row = col.row()
+ row.prop(render, "radius_scale", text="Scaling")
+ row.prop(render, "use_closetip", text="Close tip")
class PHYSICS_PT_hair_display(PhysicButtonsPanel, Panel):
diff --git a/source/blender/blenkernel/intern/hair.c b/source/blender/blenkernel/intern/hair.c
index a0b734d..44568bd 100644
--- a/source/blender/blenkernel/intern/hair.c
+++ b/source/blender/blenkernel/intern/hair.c
@@ -47,16 +47,23 @@
HairSystem *BKE_hairsys_new(void)
{
HairSystem *hsys = MEM_callocN(sizeof(HairSystem), "hair system");
-
- hsys->params.substeps_forces = 30;
- hsys->params.substeps_damping = 10;
- hsys->params.stretch_stiffness = 2000.0f;
- hsys->params.stretch_damping = 10.0f;
- hsys->params.bend_stiffness = 40.0f;
- hsys->params.bend_damping = 10.0f;
-
- hsys->params.num_render_hairs = 100;
- hsys->params.curl_smoothing = 1.0f;
+ HairParams *params = &hsys->params;
+ HairRenderSettings *render = ¶ms->render;
+
+ params->substeps_forces = 30;
+ params->substeps_damping = 10;
+ params->stretch_stiffness = 2000.0f;
+ params->stretch_damping = 10.0f;
+ params->bend_stiffness = 40.0f;
+ params->bend_damping = 10.0f;
+
+ render->flag = HAIR_RENDER_CLOSE_TIP;
+ render->num_render_hairs = 100;
+ render->curl_smoothing = 1.0f;
+ render->radius_scale = 0.01f;
+ render->root_width = 1.0f;
+ render->tip_width = 0.0f;
+ render->shape = 0.0f;
return hsys;
}
@@ -252,7 +259,7 @@ static int hair_maxpoints(HairSystem *hsys)
static HairRenderChildData *hair_gen_child_data(HairParams *params, unsigned int seed)
{
- int num_render_hairs = params->num_render_hairs;
+ int num_render_hairs = params->render.num_render_hairs;
HairRenderChildData *hair, *data = MEM_mallocN(sizeof(HairRenderChildData) * num_render_hairs, "hair render data");
RNG *rng;
int i;
@@ -290,6 +297,7 @@ static void get_hair_root_frame(HairCurve *hair, float frame[3][3])
static void hair_precalc_cache(HairRenderIterator *iter)
{
+ HairRenderSettings *render = &iter->hsys->params.render;
struct HAIR_FrameIterator *frame_iter;
HairPointRenderCache *cache;
float initial_frame[3][3];
@@ -301,7 +309,7 @@ static void hair_precalc_cache(HairRenderIterator *iter)
get_hair_root_frame(iter->hair, initial_frame);
cache = iter->hair_cache;
- for (HAIR_frame_iter_init(frame_iter, iter->hair, iter->hair->avg_rest_length, iter->hsys->params.curl_smoothing, initial_frame);
+ for (HAIR_frame_iter_init(frame_iter, iter->hair, iter->hair->avg_rest_length, render->curl_smoothing, initial_frame);
HAIR_frame_iter_valid(frame_iter);
HAIR_frame_iter_next(frame_iter)) {
int k = HAIR_frame_iter_index(frame_iter);
@@ -329,6 +337,7 @@ static void hair_precalc_cache(HairRenderIterator *iter)
void BKE_hair_render_iter_init(HairRenderIterator *iter, HairSystem *hsys)
{
+ HairRenderSettings *render = &hsys->params.render;
int maxpoints = hair_maxpoints(hsys);
iter->hsys = hsys;
@@ -336,12 +345,12 @@ void BKE_hair_render_iter_init(HairRenderIterator *iter, HairSystem *hsys)
iter->maxsteps = (maxpoints - 1) * iter->steps_per_point + 1;
iter->hair_cache = MEM_mallocN(sizeof(HairPointRenderCache) * maxpoints, "hair render cache data");
- iter->maxchildren = hsys->params.num_render_hairs;
+ iter->maxchildren = render->num_render_hairs;
iter->child_data = hair_gen_child_data(&hsys->params, 12345); /* TODO handle seeds properly here ... */
iter->hair = hsys->curves;
iter->i = 0;
- iter->totchildren = hsys->params.num_render_hairs;
+ iter->totchildren = render->num_render_hairs;
iter->child = 0;
/* fill the hair cache to avoid redundant per-child calculations */
@@ -358,7 +367,7 @@ void BKE_hair_render_iter_init_hair(HairRenderIterator *iter)
/* actual new hair or just next child? */
if (iter->child >= iter->totchildren) {
- iter->totchildren = iter->hsys->params.num_render_hairs; /* XXX in principle could differ per hair */
+ iter->totchildren = iter->hsys->params.render.num_render_hairs; /* XXX in principle could differ per hair */
iter->child = 0;
/* fill the hair cache to avoid redundant per-child calculations */
diff --git a/source/blender/makesdna/DNA_hair_types.h b/source/blender/makesdna/DNA_hair_types.h
index b33ba0e..6118f7f 100644
--- a/source/blender/makesdna/DNA_hair_types.h
+++ b/source/blender/makesdna/DNA_hair_types.h
@@ -54,6 +54,24 @@ typedef struct HairCurve {
float rest_tan[3]; /* rest tangent */
} HairCurve;
+typedef struct HairRenderSettings {
+ int flag;
+
+ int num_render_hairs; /* render hairs per simulation hair */
+
+ float radius_scale;
+ float root_width;
+ float tip_width;
+ float shape;
+
+ float curl_smoothing;
+ int pad;
+} HairRenderSettings;
+
+typedef enum eHairRenderSettings_Flag {
+ HAIR_RENDER_CLOSE_TIP = 1,
+} eHairRenderSettings_Flag;
+
typedef struct HairParams {
int substeps_forces;
int substeps_damping;
@@ -70,12 +88,9 @@ typedef struct HairParams {
float restitution;
float friction;
float margin;
-
- /* render settings */
- int num_render_hairs; /* render hairs per simulation hair */
-
- float curl_smoothing;
int pad;
+
+ HairRenderSettings render;
} HairParams;
typedef struct HairDisplaySettings {
diff --git a/source/blender/makesrna/intern/rna_hair.c b/source/blender/makesrna/intern/rna_hair.c
index 1c995a5..1b97ee4 100644
--- a/source/blender/makesrna/intern/rna_hair.c
+++ b/source/blender/makesrna/intern/rna_hair.c
@@ -242,7 +242,18 @@ static void rna_def_hair_params(BlenderRNA *brna)
RNA_def_property_float_default(prop, 0.02f);
RNA_def_property_ui_text(prop, "Margin", "Collision margin to avoid penetration");
- /* Render Settings */
+ prop = RNA_def_property(srna, "render", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "render");
+ RNA_def_property_struct_type(prop, "HairRenderSettings");
+ RNA_def_property_ui_text(prop, "Render Settings", "");
+}
+
+static void rna_def_hair_render_settings(BlenderRNA *brna) {
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "HairRenderSettings", NULL);
+ RNA_def_struct_ui_text(srna, "Hair Render Settings", "Hair render settings");
prop = RNA_def_property(srna, "render_hairs", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "num_render_hairs");
@@ -252,6 +263,40 @@ static void rna_def_hair_params(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Render Hairs", "Number of hairs rendered around each simulated hair");
RNA_def_property_update(prop, 0, "rna_HairParams_render_update");
+ prop = RNA_def_property(srna, "radius_scale", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_range(prop, 0.0, FLT_MAX);
+ RNA_def_property_ui_range(prop, 0.0f, 1000.0f, 0.01f, 3);
+ RNA_def_property_float_default(prop, 0.01f);
+ RNA_def_property_ui_text(prop, "Radius Scaling", "Multiplier of width properties");
+ RNA_def_property_update(prop, 0, "rna_HairParams_render_update");
+
+ prop = RNA_def_property(srna, "root_width", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_range(prop, 0.0, FLT_MAX);
+ RNA_def_property_ui_range(prop, 0.0f, 1000.0f, 0.1f, 2);
+ RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_ui_text(prop, "Root Size", "Strand width at the root");
+ RNA_def_property_update(prop, 0, "rna_HairParams_render_update");
+
+ prop = RNA_def_property(srna, "tip_width", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_range(prop, 0.0, FLT_MAX);
+ RNA_def_property_ui_range(prop, 0.0f, 1000.0f, 0.1f, 2);
+ RNA_def_property_float_default(prop, 0.0f);
+ RNA_def_property_ui_text(prop, "Tip Size", "Strand width at the tip");
+ RNA_def_property_update(prop, 0, "rna_HairParams_render_update");
+
+ prop = RNA_def_property(srna, "shape", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_range(prop, -1.0, 1.0f);
+ RNA_def_property_ui_range(prop, -1.0f, 1.0f, 0.1f, 3);
+ RNA_def_property_float_default(prop, 0.0f);
+ RNA_def_property_ui_text(prop, "Strand Shape", "Strand shape parameter");
+ RNA_def_property_update(prop, 0, "rna_HairParams_render_update");
+
+ prop = RNA_def_property(srna, "use_closetip", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", HAIR_RENDER_CLOSE_TIP);
+ RNA_def_property_ui_text(prop, "Close Tip", "Set tip radius to zero");
+ RNA_def_property_boolean_default(prop, true);
+ RNA_def_property_update(prop, 0, "rna_HairParams_render_update");
+
prop = RNA_def_property(srna, "curl_smoothing", PROP_FLOAT, PROP_FAC
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list