[Bf-blender-cvs] [38e54a7] gooseberry: Rotation randomization feature for the particle instance modifier.

Lukas Tönne noreply at git.blender.org
Fri May 1 13:09:56 CEST 2015


Commit: 38e54a70608317793bd9b07e2c75cc50cede6847
Author: Lukas Tönne
Date:   Fri May 1 13:07:46 2015 +0200
Branches: gooseberry
https://developer.blender.org/rB38e54a70608317793bd9b07e2c75cc50cede6847

Rotation randomization feature for the particle instance modifier.

When using the hair path deformation feature of the modifier, each copy
of the mesh can now be rotated around the path, in addition to changing
length and offset. This includes a constant phase angle as well as a
randomization factor.

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

M	release/scripts/startup/bl_ui/properties_data_modifier.py
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/modifiers/intern/MOD_particleinstance.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 9f4772a..24f7c1e 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -682,8 +682,12 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         col.prop(md, "use_preserve_shape")
 
         col = split.column()
-        col.prop(md, "position", slider=True)
-        col.prop(md, "random_position", text="Random", slider=True)
+        col2 = col.column(align=True)
+        col2.prop(md, "position", slider=True)
+        col2.prop(md, "random_position", text="Random", slider=True)
+        col2 = col.column(align=True)
+        col2.prop(md, "rotation", slider=True)
+        col2.prop(md, "random_rotation", text="Random", slider=True)
 
         col = layout.column(align=True)
         col.prop(md, "index_layer_name", text="Index Layer")
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index fde2294..c03fb80 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -734,6 +734,7 @@ typedef struct ParticleInstanceModifierData {
 	struct Object *ob;
 	short psys, flag, axis, space;
 	float position, random_position;
+	float rotation, random_rotation;
 	float particle_amount, particle_offset;
 	char index_layer_name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */
 	char value_layer_name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index b28dc2d..30e7e8b 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -2600,6 +2600,18 @@ static void rna_def_modifier_particleinstance(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Random Position", "Randomize position along path");
 	RNA_def_property_update(prop, 0, "rna_Modifier_update");
 
+	prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_FACTOR);
+	RNA_def_property_float_sdna(prop, NULL, "rotation");
+	RNA_def_property_range(prop, 0.0, 1.0);
+	RNA_def_property_ui_text(prop, "Rotation", "Rotation around path");
+	RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+	prop = RNA_def_property(srna, "random_rotation", PROP_FLOAT, PROP_FACTOR);
+	RNA_def_property_float_sdna(prop, NULL, "random_rotation");
+	RNA_def_property_range(prop, 0.0, 1.0);
+	RNA_def_property_ui_text(prop, "Random Rotation", "Randomize rotation around path");
+	RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
 	prop = RNA_def_property(srna, "particle_amount", PROP_FLOAT, PROP_FACTOR);
 	RNA_def_property_range(prop, 0.0, 1.0);
 	RNA_def_property_ui_text(prop, "Particle Amount", "Amount of particles to use for instancing");
diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c b/source/blender/modifiers/intern/MOD_particleinstance.c
index 3c51632..a1a2e5d 100644
--- a/source/blender/modifiers/intern/MOD_particleinstance.c
+++ b/source/blender/modifiers/intern/MOD_particleinstance.c
@@ -400,6 +400,15 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
 					/* to quaternion */
 					mat3_to_quat(frame, mat);
 					
+					if (pimd->rotation > 0.0f || pimd->random_rotation > 0.0f) {
+						float angle = 2.0f*M_PI * (pimd->rotation + pimd->random_rotation * (psys_frand(psys, 19957323 + p) - 0.5f));
+						float eul[3] = { 0.0f, 0.0f, angle };
+						float rot[4];
+						
+						eul_to_quat(rot, eul);
+						mul_qt_qtqt(frame, frame, rot);
+					}
+					
 					/* note: direction is same as normal vector currently,
 					 * but best to keep this separate so the frame can be
 					 * rotated later if necessary




More information about the Bf-blender-cvs mailing list