More flexible size options for particle billboards. This adds scale factors for width and height of billboards, relative to the particle size. It's useful when the particle size is primarily used for collision and the like, so the billboard appearance can be adjusted independently. Also allows non-square billboards.

In addition the billboards can be scaled by the particle velocity with optional head and tail factors (similar to line drawing options). This allows for pseudo-motionblur effects.
This commit is contained in:
Lukas Toenne 2011-06-23 18:59:47 +00:00
parent e7c6b535b0
commit 587b51831d
9 changed files with 112 additions and 21 deletions

@ -878,6 +878,15 @@ class PARTICLE_PT_render(ParticleButtonsPanel, bpy.types.Panel):
col.prop(part, "billboard_tilt_random", text="Random", slider=True)
col = row.column()
col.prop(part, "billboard_offset")
row = layout.row()
col = row.column()
col.prop(part, "billboard_size", text="Scale")
if part.billboard_align == 'VEL':
col = row.column(align=True)
col.label("Velocity Scale:")
col.prop(part, "billboard_velocity_head", text="Head")
col.prop(part, "billboard_velocity_tail", text="Tail")
if psys:
col = layout.column()

@ -44,7 +44,7 @@ extern "C" {
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 258
#define BLENDER_SUBVERSION 0
#define BLENDER_SUBVERSION 1
#define BLENDER_MINVERSION 250
#define BLENDER_MINSUBVERSION 0

@ -147,7 +147,8 @@ typedef struct ParticleBillboardData
struct Object *ob;
float vec[3], vel[3];
float offset[2];
float size, tilt, random, time;
float size[2];
float tilt, random, time;
int uv[3];
int lock, num;
int totnum;

@ -3534,6 +3534,8 @@ static void default_particle_settings(ParticleSettings *part)
part->path_start = 0.0f;
part->path_end = 1.0f;
part->bb_size[0] = part->bb_size[1] = 1.0f;
part->keyed_loops = 1;
part->color_vec_max = 1.f;
@ -4505,8 +4507,8 @@ void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3]
mul_v3_fl(tvec, -sin(bb->tilt * (float)M_PI));
VECADD(yvec, yvec, tvec);
mul_v3_fl(xvec, bb->size);
mul_v3_fl(yvec, bb->size);
mul_v3_fl(xvec, bb->size[0]);
mul_v3_fl(yvec, bb->size[1]);
VECADDFAC(center, bb->vec, xvec, bb->offset[0]);
VECADDFAC(center, center, yvec, bb->offset[1]);

@ -11594,9 +11594,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
}
/* put compatibility code here until next subversion bump */
{
if (main->versionfile < 258 || (main->versionfile == 258 && main->subversionfile < 1)){
/* screen view2d settings were not properly initialized [#27164]
* v2d->scroll caused the bug but best reset other values too which are in old blend files only.
* need to make less ugly - possibly an iterator? */
@ -11663,6 +11661,20 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
}
}
{
ParticleSettings *part;
for(part = main->particle.first; part; part = part->id.next) {
/* Initialize particle billboard scale */
part->bb_size[0] = part->bb_size[1] = 1.0f;
}
}
}
/* put compatibility code here until next subversion bump */
{
}
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */

@ -3613,8 +3613,6 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
bb.align = part->bb_align;
bb.anim = part->bb_anim;
bb.lock = part->draw & PART_DRAW_BB_LOCK;
bb.offset[0] = part->bb_offset[0];
bb.offset[1] = part->bb_offset[1];
break;
case PART_DRAW_PATH:
break;
@ -3784,7 +3782,20 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
/* create actiual particle data */
if(draw_as == PART_DRAW_BB) {
bb.size = pa_size;
bb.offset[0] = part->bb_offset[0];
bb.offset[1] = part->bb_offset[1];
bb.size[0] = part->bb_size[0] * pa_size;
if (part->bb_align==PART_BB_VEL) {
float pa_vel = len_v3(state.vel);
float head = part->bb_vel_head*pa_vel;
float tail = part->bb_vel_tail*pa_vel;
bb.size[1] = part->bb_size[1]*pa_size + head + tail;
/* use offset to adjust the particle center. this is relative to size, so need to divide! */
if (bb.size[1] > 0.0f)
bb.offset[1] += (head-tail) / bb.size[1];
}
else
bb.size[1] = part->bb_size[1] * pa_size;
bb.tilt = part->bb_tilt * (1.0f - part->bb_rand_tilt * r_tilt);
bb.time = ct;
}
@ -3804,7 +3815,20 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
/* create actiual particle data */
if(draw_as == PART_DRAW_BB) {
bb.size = pa_size;
bb.offset[0] = part->bb_offset[0];
bb.offset[1] = part->bb_offset[1];
bb.size[0] = part->bb_size[0] * pa_size;
if (part->bb_align==PART_BB_VEL) {
float pa_vel = len_v3(state.vel);
float head = part->bb_vel_head*pa_vel;
float tail = part->bb_vel_tail*pa_vel;
bb.size[1] = part->bb_size[1]*pa_size + head + tail;
/* use offset to adjust the particle center. this is relative to size, so need to divide! */
if (bb.size[1] > 0.0f)
bb.offset[1] += (head-tail) / bb.size[1];
}
else
bb.size[1] = part->bb_size[1] * pa_size;
bb.tilt = part->bb_tilt * (1.0f - part->bb_rand_tilt * r_tilt);
bb.time = pa_time;
}

@ -168,7 +168,7 @@ typedef struct ParticleSettings {
/* billboards */
short bb_align, bb_uv_split, bb_anim, bb_split_offset;
float bb_tilt, bb_rand_tilt, bb_offset[2];
float bb_tilt, bb_rand_tilt, bb_offset[2], bb_size[2], bb_vel_head, bb_vel_tail;
/* draw color */
float color_vec_max;

@ -1757,11 +1757,6 @@ static void rna_def_particle_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Absolute Path Time", "Path timing is in absolute frames");
RNA_def_property_update(prop, 0, "rna_Particle_abspathtime_update");
prop= RNA_def_property(srna, "lock_billboard", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_BB_LOCK);
RNA_def_property_ui_text(prop, "Lock Billboard", "Lock the billboards align axis");
RNA_def_property_update(prop, 0, "rna_Particle_redo");
prop= RNA_def_property(srna, "use_parent_particles", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_PARENT);
RNA_def_property_ui_text(prop, "Parents", "Render parent particles");
@ -1910,6 +1905,11 @@ static void rna_def_particle_settings(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
/* billboards */
prop= RNA_def_property(srna, "lock_billboard", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_BB_LOCK);
RNA_def_property_ui_text(prop, "Lock Billboard", "Lock the billboards align axis");
RNA_def_property_update(prop, 0, "rna_Particle_redo");
prop= RNA_def_property(srna, "billboard_align", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "bb_align");
RNA_def_property_enum_items(prop, bb_align_items);
@ -1958,6 +1958,25 @@ static void rna_def_particle_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Billboard Offset", "");
RNA_def_property_update(prop, 0, "rna_Particle_redo");
prop= RNA_def_property(srna, "billboard_size", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "bb_size");
RNA_def_property_array(prop, 2);
RNA_def_property_range(prop, 0.001f, 10.0f);
RNA_def_property_ui_text(prop, "Billboard Scale", "Scale billboards relative to particle size");
RNA_def_property_update(prop, 0, "rna_Particle_redo");
prop= RNA_def_property(srna, "billboard_velocity_head", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "bb_vel_head");
RNA_def_property_range(prop, 0.0f, 10.0f);
RNA_def_property_ui_text(prop, "Billboard Velocity Head", "Scale billboards by velocity");
RNA_def_property_update(prop, 0, "rna_Particle_redo");
prop= RNA_def_property(srna, "billboard_velocity_tail", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "bb_vel_tail");
RNA_def_property_range(prop, 0.0f, 10.0f);
RNA_def_property_ui_text(prop, "Billboard Velocity Tail", "Scale billboards by velocity");
RNA_def_property_update(prop, 0, "rna_Particle_redo");
/* simplification */
prop= RNA_def_property(srna, "use_simplify", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "simplify_flag", PART_SIMPLIFY_ENABLE);

@ -1680,8 +1680,6 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
bb.anim = part->bb_anim;
bb.lock = part->draw & PART_DRAW_BB_LOCK;
bb.ob = (part->bb_ob ? part->bb_ob : RE_GetCamera(re));
bb.offset[0] = part->bb_offset[0];
bb.offset[1] = part->bb_offset[1];
bb.split_offset = part->bb_split_offset;
bb.totnum = totpart+totchild;
bb.uv_split = part->bb_uv_split;
@ -2015,7 +2013,20 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
if(part->ren_as == PART_DRAW_BB) {
bb.random = random;
bb.size = pa_size;
bb.offset[0] = part->bb_offset[0];
bb.offset[1] = part->bb_offset[1];
bb.size[0] = part->bb_size[0] * pa_size;
if (part->bb_align==PART_BB_VEL) {
float pa_vel = len_v3(state.vel);
float head = part->bb_vel_head*pa_vel;
float tail = part->bb_vel_tail*pa_vel;
bb.size[1] = part->bb_size[1]*pa_size + head + tail;
/* use offset to adjust the particle center. this is relative to size, so need to divide! */
if (bb.size[1] > 0.0f)
bb.offset[1] += (head-tail) / bb.size[1];
}
else
bb.size[1] = part->bb_size[1] * pa_size;
bb.tilt = part->bb_tilt * (1.0f - part->bb_rand_tilt * r_tilt);
bb.time = ct;
bb.num = a;
@ -2040,7 +2051,20 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
if(part->ren_as == PART_DRAW_BB) {
bb.random = random;
bb.size = pa_size;
bb.offset[0] = part->bb_offset[0];
bb.offset[1] = part->bb_offset[1];
bb.size[0] = part->bb_size[0] * pa_size;
if (part->bb_align==PART_BB_VEL) {
float pa_vel = len_v3(state.vel);
float head = part->bb_vel_head*pa_vel;
float tail = part->bb_vel_tail*pa_vel;
bb.size[1] = part->bb_size[1]*pa_size + head + tail;
/* use offset to adjust the particle center. this is relative to size, so need to divide! */
if (bb.size[1] > 0.0f)
bb.offset[1] += (head-tail) / bb.size[1];
}
else
bb.size[1] = part->bb_size[1] * pa_size;
bb.tilt = part->bb_tilt * (1.0f - part->bb_rand_tilt * r_tilt);
bb.time = pa_time;
bb.num = a;