[Bf-blender-cvs] [24f68e7] temp_merge_gooseberry_hair: Support for various data properties of the hair grid in the voxel texture.

Lukas Tönne noreply at git.blender.org
Mon Jan 19 20:47:36 CET 2015


Commit: 24f68e7cea8223057516c873c0065949fd5f3e2c
Author: Lukas Tönne
Date:   Wed Aug 27 14:11:49 2014 +0200
Branches: temp_merge_gooseberry_hair
https://developer.blender.org/rB24f68e7cea8223057516c873c0065949fd5f3e2c

Support for various data properties of the hair grid in the voxel
texture.

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

M	release/scripts/startup/bl_ui/properties_texture.py
M	source/blender/blenkernel/intern/implicit.c
M	source/blender/makesdna/DNA_texture_types.h
M	source/blender/makesrna/intern/rna_texture.c

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

diff --git a/release/scripts/startup/bl_ui/properties_texture.py b/release/scripts/startup/bl_ui/properties_texture.py
index 675655e..884ef54 100644
--- a/release/scripts/startup/bl_ui/properties_texture.py
+++ b/release/scripts/startup/bl_ui/properties_texture.py
@@ -773,6 +773,7 @@ class TEXTURE_PT_voxeldata(TextureButtonsPanel, Panel):
             layout.prop(vd, "smoke_data_type")
         elif vd.file_format == 'HAIR':
             layout.prop(vd, "domain_object")
+            layout.prop(vd, "hair_data_type")
         elif vd.file_format == 'IMAGE_SEQUENCE':
             layout.template_ID(tex, "image", open="image.open")
             layout.template_image(tex, "image", tex.image_user, compact=True)
diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c
index 0bc013e..27e7ac7 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 653cca8..3eef75e 100644
--- a/source/blender/makesdna/DNA_texture_types.h
+++ b/source/blender/makesdna/DNA_texture_types.h
@@ -174,8 +174,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 */
@@ -622,6 +622,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 26644ba..3abe4cd 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);




More information about the Bf-blender-cvs mailing list