diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2014-08-27 16:11:49 +0400 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2015-01-20 11:29:21 +0300 |
commit | b331a82910da04b684d680ec94abbf93efbd0696 (patch) | |
tree | c0f6b6748eb56af9923fd8ef20a3d071e17bf921 /source/blender | |
parent | efc0cd16580bfcafb4abddd5465f197ba1915dd9 (diff) |
Support for various data properties of the hair grid in the voxel
texture.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/implicit.c | 38 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_texture_types.h | 7 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_texture.c | 14 |
3 files changed, 54 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index 0bc013efe00..27e7ac79756 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -1494,6 +1494,7 @@ bool implicit_hair_volume_get_texture_data(Object *UNUSED(ob), ClothModifierData HairGridVert *hairgrid/*, *collgrid*/; int numverts; int totres, i; + int depth; if (!clmd->clothObject || !clmd->clothObject->implicit) return false; @@ -1511,15 +1512,44 @@ bool implicit_hair_volume_get_texture_data(Object *UNUSED(ob), ClothModifierData totres = hair_grid_size(hair_grid_res); - vd->data_type = TEX_VD_INTENSITY; + if (vd->hair_type == TEX_VD_HAIRVELOCITY) { + depth = 4; + vd->data_type = TEX_VD_RGBA_PREMUL; + } + else { + depth = 1; + vd->data_type = TEX_VD_INTENSITY; + } + if (totres > 0) { - vd->dataset = (float *)MEM_mapallocN(sizeof(float) * (totres), "hair volume texture data"); + vd->dataset = (float *)MEM_mapallocN(sizeof(float) * depth * (totres), "hair volume texture data"); + for (i = 0; i < totres; ++i) { - vd->dataset[i] = hairgrid[i].density; + switch (vd->hair_type) { + case TEX_VD_HAIRDENSITY: + vd->dataset[i] = hairgrid[i].density; + break; + + case TEX_VD_HAIRRESTDENSITY: + vd->dataset[i] = 0.0f; // TODO + break; + + case TEX_VD_HAIRVELOCITY: + vd->dataset[i + 0*totres] = hairgrid[i].velocity[0]; + vd->dataset[i + 1*totres] = hairgrid[i].velocity[1]; + vd->dataset[i + 2*totres] = hairgrid[i].velocity[2]; + vd->dataset[i + 3*totres] = len_v3(hairgrid[i].velocity); + break; + + case TEX_VD_HAIRENERGY: + vd->dataset[i] = 0.0f; // TODO + break; + } } } - else + else { vd->dataset = NULL; + } MEM_freeN(hairgrid); // MEM_freeN(collgrid); diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h index 4209ce8168d..78e3aeb9c0e 100644 --- a/source/blender/makesdna/DNA_texture_types.h +++ b/source/blender/makesdna/DNA_texture_types.h @@ -175,8 +175,8 @@ typedef struct VoxelData { short flag; short extend; short smoked_type; + short hair_type; short data_type; - short pad; int _pad; struct Object *object; /* for rendering smoke sims */ @@ -627,6 +627,11 @@ enum { #define TEX_VD_SMOKEVEL 2 #define TEX_VD_SMOKEFLAME 3 +#define TEX_VD_HAIRDENSITY 0 +#define TEX_VD_HAIRVELOCITY 1 +#define TEX_VD_HAIRENERGY 2 +#define TEX_VD_HAIRRESTDENSITY 3 + /* data_type */ #define TEX_VD_INTENSITY 0 #define TEX_VD_RGBA_PREMUL 1 diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index 26644ba1a5d..3abe4cde2d0 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -1870,6 +1870,14 @@ static void rna_def_texture_voxeldata(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; + static EnumPropertyItem hair_type_items[] = { + {TEX_VD_HAIRDENSITY, "HAIRDENSITY", 0, "Density", "Use hair density as texture data"}, + {TEX_VD_HAIRRESTDENSITY, "HAIRRESTDENSITY", 0, "Rest Density", "Use hair rest density as texture data"}, + {TEX_VD_HAIRVELOCITY, "HAIRVELOCITY", 0, "Velocity", "Use hair velocity as texture data"}, + {TEX_VD_HAIRENERGY, "HAIRENERGY", 0, "Energy", "Use potential hair energy as texture data"}, + {0, NULL, 0, NULL, NULL} + }; + srna = RNA_def_struct(brna, "VoxelData", NULL); RNA_def_struct_sdna(srna, "VoxelData"); RNA_def_struct_ui_text(srna, "VoxelData", "Voxel data settings"); @@ -1887,6 +1895,12 @@ static void rna_def_texture_voxeldata(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Source", "Simulation value to be used as a texture"); RNA_def_property_update(prop, 0, "rna_Texture_voxeldata_update"); + prop = RNA_def_property(srna, "hair_data_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "hair_type"); + RNA_def_property_enum_items(prop, hair_type_items); + RNA_def_property_ui_text(prop, "Source", "Simulation value to be used as a texture"); + RNA_def_property_update(prop, 0, "rna_Texture_voxeldata_update"); + prop = RNA_def_property(srna, "extension", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "extend"); RNA_def_property_enum_items(prop, voxeldata_extension); |