forked from bartvdbraak/blender
Some advanced particle rotation modes and reorganization of the rotation panel:
- More angular velocity modes to support creative effects. - Renamed "Initial Rotation" to "Initial Orientation" to better reflect the functionality - Renamed "Spin" angular velocity mode to "Velocity". - Organized the rotation panel a bit better. - Also some better names and tooltips for the different rotation values.
This commit is contained in:
parent
1362523ce6
commit
fcd5550a42
@ -415,12 +415,7 @@ class PARTICLE_PT_rotation(ParticleButtonsPanel, Panel):
|
||||
|
||||
layout.enabled = particle_panel_enabled(context, psys) and part.use_rotations
|
||||
|
||||
layout.prop(part, "use_dynamic_rotation")
|
||||
|
||||
if part.use_dynamic_rotation:
|
||||
layout.label(text="Initial Rotation Axis:")
|
||||
else:
|
||||
layout.label(text="Rotation Axis:")
|
||||
layout.label(text="Initial Orientation:")
|
||||
|
||||
split = layout.split()
|
||||
|
||||
@ -433,16 +428,17 @@ class PARTICLE_PT_rotation(ParticleButtonsPanel, Panel):
|
||||
col.prop(part, "phase_factor_random", text="Random", slider=True)
|
||||
|
||||
if part.type != 'HAIR':
|
||||
col = layout.column()
|
||||
if part.use_dynamic_rotation:
|
||||
col.label(text="Initial Angular Velocity:")
|
||||
else:
|
||||
col.label(text="Angular Velocity:")
|
||||
sub = col.row(align=True)
|
||||
sub.prop(part, "angular_velocity_mode", text="")
|
||||
subsub = sub.column()
|
||||
subsub.active = part.angular_velocity_mode != 'NONE'
|
||||
subsub.prop(part, "angular_velocity_factor", text="")
|
||||
layout.label(text="Angular Velocity:")
|
||||
|
||||
split = layout.split()
|
||||
col = split.column(align=True)
|
||||
col.prop(part, "angular_velocity_mode", text="")
|
||||
sub = col.column()
|
||||
sub.active = part.angular_velocity_mode != 'NONE'
|
||||
sub.prop(part, "angular_velocity_factor", text="")
|
||||
|
||||
col = split.column()
|
||||
col.prop(part, "use_dynamic_rotation")
|
||||
|
||||
|
||||
class PARTICLE_PT_physics(ParticleButtonsPanel, Panel):
|
||||
|
@ -3557,7 +3557,7 @@ static void default_particle_settings(ParticleSettings *part)
|
||||
part->childsize=1.0;
|
||||
|
||||
part->rotmode = PART_ROT_VEL;
|
||||
part->avemode = PART_AVE_SPIN;
|
||||
part->avemode = PART_AVE_VELOCITY;
|
||||
|
||||
part->child_nbr=10;
|
||||
part->ren_child_nbr=100;
|
||||
|
@ -1570,6 +1570,45 @@ static void initialize_all_particles(ParticleSimulationData *sim)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void get_angular_velocity_vector(short avemode, ParticleKey *state, float *vec)
|
||||
{
|
||||
switch(avemode) {
|
||||
case PART_AVE_VELOCITY:
|
||||
copy_v3_v3(vec, state->vel);
|
||||
break;
|
||||
case PART_AVE_HORIZONTAL:
|
||||
{
|
||||
float zvec[3];
|
||||
zvec[0] = zvec[1] = 0;
|
||||
zvec[2] = 1.f;
|
||||
cross_v3_v3v3(vec, state->vel, zvec);
|
||||
break;
|
||||
}
|
||||
case PART_AVE_VERTICAL:
|
||||
{
|
||||
float zvec[3], temp[3];
|
||||
zvec[0] = zvec[1] = 0;
|
||||
zvec[2] = 1.f;
|
||||
cross_v3_v3v3(temp, state->vel, zvec);
|
||||
cross_v3_v3v3(vec, temp, state->vel);
|
||||
break;
|
||||
}
|
||||
case PART_AVE_GLOBAL_X:
|
||||
vec[0] = 1.f;
|
||||
vec[1] = vec[2] = 0;
|
||||
break;
|
||||
case PART_AVE_GLOBAL_Y:
|
||||
vec[1] = 1.f;
|
||||
vec[0] = vec[2] = 0;
|
||||
break;
|
||||
case PART_AVE_GLOBAL_Z:
|
||||
vec[2] = 1.f;
|
||||
vec[0] = vec[1] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, ParticleKey *state, float dtime, float cfra)
|
||||
{
|
||||
Object *ob = sim->ob;
|
||||
@ -1782,14 +1821,11 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
|
||||
zero_v3(state->ave);
|
||||
|
||||
if(part->avemode) {
|
||||
switch(part->avemode) {
|
||||
case PART_AVE_SPIN:
|
||||
copy_v3_v3(state->ave, vel);
|
||||
break;
|
||||
case PART_AVE_RAND:
|
||||
copy_v3_v3(state->ave, r_ave);
|
||||
break;
|
||||
}
|
||||
if(part->avemode == PART_AVE_RAND)
|
||||
copy_v3_v3(state->ave, r_ave);
|
||||
else
|
||||
get_angular_velocity_vector(part->avemode, state, state->ave);
|
||||
|
||||
normalize_v3(state->ave);
|
||||
mul_v3_fl(state->ave, part->avefac);
|
||||
}
|
||||
@ -2692,26 +2728,26 @@ static void basic_rotate(ParticleSettings *part, ParticleData *pa, float dfra, f
|
||||
return;
|
||||
}
|
||||
|
||||
if((part->flag & PART_ROT_DYN)==0) {
|
||||
if(part->avemode==PART_AVE_SPIN) {
|
||||
float angle;
|
||||
float len1 = len_v3(pa->prev_state.vel);
|
||||
float len2 = len_v3(pa->state.vel);
|
||||
if((part->flag & PART_ROT_DYN)==0 && ELEM3(part->avemode, PART_AVE_VELOCITY, PART_AVE_HORIZONTAL, PART_AVE_VERTICAL)) {
|
||||
float angle;
|
||||
float len1 = len_v3(pa->prev_state.vel);
|
||||
float len2 = len_v3(pa->state.vel);
|
||||
float vec[3];
|
||||
|
||||
if(len1==0.0f || len2==0.0f)
|
||||
pa->state.ave[0]=pa->state.ave[1]=pa->state.ave[2]=0.0f;
|
||||
else{
|
||||
cross_v3_v3v3(pa->state.ave,pa->prev_state.vel,pa->state.vel);
|
||||
normalize_v3(pa->state.ave);
|
||||
angle=dot_v3v3(pa->prev_state.vel,pa->state.vel)/(len1*len2);
|
||||
mul_v3_fl(pa->state.ave,saacos(angle)/dtime);
|
||||
}
|
||||
|
||||
axis_angle_to_quat(rot2,pa->state.vel,dtime*part->avefac);
|
||||
if(len1==0.0f || len2==0.0f)
|
||||
pa->state.ave[0] = pa->state.ave[1] = pa->state.ave[2] = 0.0f;
|
||||
else{
|
||||
cross_v3_v3v3(pa->state.ave, pa->prev_state.vel, pa->state.vel);
|
||||
normalize_v3(pa->state.ave);
|
||||
angle = dot_v3v3(pa->prev_state.vel, pa->state.vel) / (len1 * len2);
|
||||
mul_v3_fl(pa->state.ave, saacos(angle) / dtime);
|
||||
}
|
||||
|
||||
get_angular_velocity_vector(part->avemode, &pa->state, vec);
|
||||
axis_angle_to_quat(rot2, vec, dtime*part->avefac);
|
||||
}
|
||||
|
||||
rotfac=len_v3(pa->state.ave);
|
||||
rotfac = len_v3(pa->state.ave);
|
||||
if(rotfac == 0.0f) { /* unit_qt(in VecRotToQuat) doesn't give unit quat [1,0,0,0]?? */
|
||||
rot1[0]=1.0f;
|
||||
rot1[1]=rot1[2]=rot1[3]=0;
|
||||
|
@ -820,7 +820,7 @@ void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *p
|
||||
pid->data_types|= (1<<BPHYS_DATA_ROTATION);
|
||||
|
||||
if(psys->part->rotmode!=PART_ROT_VEL
|
||||
|| psys->part->avemode!=PART_AVE_SPIN || psys->part->avefac!=0.0f)
|
||||
|| psys->part->avemode==PART_AVE_RAND || psys->part->avefac!=0.0f)
|
||||
pid->data_types|= (1<<BPHYS_DATA_AVELOCITY);
|
||||
}
|
||||
|
||||
|
@ -463,8 +463,13 @@ typedef struct ParticleSystem
|
||||
#define PART_ROT_OB_Z 8
|
||||
|
||||
/* part->avemode */
|
||||
#define PART_AVE_SPIN 1
|
||||
#define PART_AVE_VELOCITY 1
|
||||
#define PART_AVE_RAND 2
|
||||
#define PART_AVE_HORIZONTAL 3
|
||||
#define PART_AVE_VERTICAL 4
|
||||
#define PART_AVE_GLOBAL_X 5
|
||||
#define PART_AVE_GLOBAL_Y 6
|
||||
#define PART_AVE_GLOBAL_Z 7
|
||||
|
||||
/* part->reactevent */
|
||||
#define PART_EVENT_DEATH 0
|
||||
|
@ -1510,7 +1510,12 @@ static void rna_def_particle_settings(BlenderRNA *brna)
|
||||
|
||||
static EnumPropertyItem ave_mode_items[] = {
|
||||
{0, "NONE", 0, "None", ""},
|
||||
{PART_AVE_SPIN, "SPIN", 0, "Spin", ""},
|
||||
{PART_AVE_VELOCITY, "VELOCITY", 0, "Velocity", ""},
|
||||
{PART_AVE_HORIZONTAL, "HORIZONTAL", 0, "Horizontal", ""},
|
||||
{PART_AVE_VERTICAL, "VERTICAL", 0, "Vertical", ""},
|
||||
{PART_AVE_GLOBAL_X, "GLOBAL_X", 0, "Global X", ""},
|
||||
{PART_AVE_GLOBAL_Y, "GLOBAL_Y", 0, "Global Y", ""},
|
||||
{PART_AVE_GLOBAL_Z, "GLOBAL_Z", 0, "Global Z", ""},
|
||||
{PART_AVE_RAND, "RAND", 0, "Random", ""} ,
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
@ -1670,7 +1675,7 @@ static void rna_def_particle_settings(BlenderRNA *brna)
|
||||
prop = RNA_def_property(srna, "use_dynamic_rotation", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_ROT_DYN);
|
||||
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
RNA_def_property_ui_text(prop, "Dynamic", "Set rotation to dynamic/constant");
|
||||
RNA_def_property_ui_text(prop, "Dynamic", "Particle rotations are effected by collisions and effectors");
|
||||
RNA_def_property_update(prop, 0, "rna_Particle_reset");
|
||||
|
||||
prop = RNA_def_property(srna, "use_multiply_size_mass", PROP_BOOLEAN, PROP_NONE);
|
||||
@ -1761,14 +1766,14 @@ static void rna_def_particle_settings(BlenderRNA *brna)
|
||||
RNA_def_property_enum_sdna(prop, NULL, "rotmode");
|
||||
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
RNA_def_property_enum_items(prop, rot_mode_items);
|
||||
RNA_def_property_ui_text(prop, "Rotation", "Particle rotation axis");
|
||||
RNA_def_property_ui_text(prop, "Orientation axis", "Particle orientation axis (does not effect eplode modifier results)");
|
||||
RNA_def_property_update(prop, 0, "rna_Particle_reset");
|
||||
|
||||
prop = RNA_def_property(srna, "angular_velocity_mode", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "avemode");
|
||||
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
RNA_def_property_enum_items(prop, ave_mode_items);
|
||||
RNA_def_property_ui_text(prop, "Angular Velocity Mode", "Particle angular velocity mode");
|
||||
RNA_def_property_ui_text(prop, "Angular Velocity Axis", "What axis is used to change particle rotation with time");
|
||||
RNA_def_property_update(prop, 0, "rna_Particle_reset");
|
||||
|
||||
prop = RNA_def_property(srna, "react_event", PROP_ENUM, PROP_NONE);
|
||||
@ -2238,25 +2243,25 @@ static void rna_def_particle_settings(BlenderRNA *brna)
|
||||
RNA_def_property_float_sdna(prop, NULL, "avefac");
|
||||
RNA_def_property_range(prop, -200.0f, 200.0f);
|
||||
RNA_def_property_ui_range(prop, -100, 100, 10, 3);
|
||||
RNA_def_property_ui_text(prop, "Angular Velocity", "Angular velocity amount");
|
||||
RNA_def_property_ui_text(prop, "Angular Velocity", "Angular velocity amount (in radians per second)");
|
||||
RNA_def_property_update(prop, 0, "rna_Particle_reset");
|
||||
|
||||
prop = RNA_def_property(srna, "phase_factor", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_float_sdna(prop, NULL, "phasefac");
|
||||
RNA_def_property_range(prop, -1.0f, 1.0f);
|
||||
RNA_def_property_ui_text(prop, "Phase", "Initial rotation phase");
|
||||
RNA_def_property_ui_text(prop, "Phase", "Rotation around the chosen orientation axis");
|
||||
RNA_def_property_update(prop, 0, "rna_Particle_reset");
|
||||
|
||||
prop = RNA_def_property(srna, "rotation_factor_random", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_float_sdna(prop, NULL, "randrotfac");
|
||||
RNA_def_property_range(prop, 0.0f, 1.0f);
|
||||
RNA_def_property_ui_text(prop, "Random Rotation", "Randomize rotation");
|
||||
RNA_def_property_ui_text(prop, "Random Orientation", "Randomize particle orientation");
|
||||
RNA_def_property_update(prop, 0, "rna_Particle_reset");
|
||||
|
||||
prop = RNA_def_property(srna, "phase_factor_random", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_float_sdna(prop, NULL, "randphasefac");
|
||||
RNA_def_property_range(prop, 0.0f, 1.0f);
|
||||
RNA_def_property_ui_text(prop, "Random Phase", "Randomize rotation phase");
|
||||
RNA_def_property_ui_text(prop, "Random Phase", "Randomize rotation around the chosen orientation axis");
|
||||
RNA_def_property_update(prop, 0, "rna_Particle_reset");
|
||||
|
||||
prop = RNA_def_property(srna, "hair_length", PROP_FLOAT, PROP_NONE);
|
||||
|
Loading…
Reference in New Issue
Block a user