diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle_system.c | 84 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/pointcache.c | 2 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_particle_types.h | 7 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_particle.c | 21 |
5 files changed, 81 insertions, 35 deletions
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 21dfe437ba0..8228a9da67f 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -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; diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 50c960d6c56..a0668d621e8 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -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(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); - } + 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]; - 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; diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 622c3ebe119..69e96c7a698 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -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); } diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h index 547a91e7852..63c4806028a 100644 --- a/source/blender/makesdna/DNA_particle_types.h +++ b/source/blender/makesdna/DNA_particle_types.h @@ -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 diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 35b5ca571cb..b10639443c0 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -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); |