Revision: 37760
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37760
Author:   lukastoenne
Date:     2011-06-23 18:59:47 +0000 (Thu, 23 Jun 2011)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/properties_particle.py
    trunk/blender/source/blender/blenkernel/BKE_blender.h
    trunk/blender/source/blender/blenkernel/BKE_particle.h
    trunk/blender/source/blender/blenkernel/intern/particle.c
    trunk/blender/source/blender/blenloader/intern/readfile.c
    trunk/blender/source/blender/editors/space_view3d/drawobject.c
    trunk/blender/source/blender/makesdna/DNA_particle_types.h
    trunk/blender/source/blender/makesrna/intern/rna_particle.c
    trunk/blender/source/blender/render/intern/source/convertblender.c

Modified: trunk/blender/release/scripts/startup/bl_ui/properties_particle.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_particle.py  
2011-06-23 17:32:21 UTC (rev 37759)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_particle.py  
2011-06-23 18:59:47 UTC (rev 37760)
@@ -878,6 +878,15 @@
             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()

Modified: trunk/blender/source/blender/blenkernel/BKE_blender.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_blender.h       2011-06-23 
17:32:21 UTC (rev 37759)
+++ trunk/blender/source/blender/blenkernel/BKE_blender.h       2011-06-23 
18:59:47 UTC (rev 37760)
@@ -44,7 +44,7 @@
  * 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

Modified: trunk/blender/source/blender/blenkernel/BKE_particle.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_particle.h      2011-06-23 
17:32:21 UTC (rev 37759)
+++ trunk/blender/source/blender/blenkernel/BKE_particle.h      2011-06-23 
18:59:47 UTC (rev 37760)
@@ -147,7 +147,8 @@
        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;

Modified: trunk/blender/source/blender/blenkernel/intern/particle.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/particle.c   2011-06-23 
17:32:21 UTC (rev 37759)
+++ trunk/blender/source/blender/blenkernel/intern/particle.c   2011-06-23 
18:59:47 UTC (rev 37760)
@@ -3534,6 +3534,8 @@
        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 @@
        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]);

Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c   2011-06-23 
17:32:21 UTC (rev 37759)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c   2011-06-23 
18:59:47 UTC (rev 37760)
@@ -11594,9 +11594,7 @@
                                        }
        }
 
-       /* 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,8 +11661,22 @@
                                }
                        }
                }
+
+               {
+                       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! 
*/
        /* WATCH IT 2!: Userdef struct init has to be in 
editors/interface/resources.c! */
 

Modified: trunk/blender/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/drawobject.c      
2011-06-23 17:32:21 UTC (rev 37759)
+++ trunk/blender/source/blender/editors/space_view3d/drawobject.c      
2011-06-23 18:59:47 UTC (rev 37760)
@@ -3613,8 +3613,6 @@
                        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 @@
 
                                        /* 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 @@
 
                                        /* 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;
                                        }

Modified: trunk/blender/source/blender/makesdna/DNA_particle_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_particle_types.h  2011-06-23 
17:32:21 UTC (rev 37759)
+++ trunk/blender/source/blender/makesdna/DNA_particle_types.h  2011-06-23 
18:59:47 UTC (rev 37760)
@@ -168,7 +168,7 @@
 
        /* 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;

Modified: trunk/blender/source/blender/makesrna/intern/rna_particle.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_particle.c 2011-06-23 
17:32:21 UTC (rev 37759)
+++ trunk/blender/source/blender/makesrna/intern/rna_particle.c 2011-06-23 
18:59:47 UTC (rev 37760)
@@ -1757,11 +1757,6 @@
        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 @@
        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 @@
        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);

Modified: trunk/blender/source/blender/render/intern/source/convertblender.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/convertblender.c  
2011-06-23 17:32:21 UTC (rev 37759)

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to