[Bf-codereview] Additional billboard scaling options (issue4629045)

lukas.toenne at googlemail.com lukas.toenne at googlemail.com
Fri Jun 17 10:42:07 CEST 2011


Reviewers: bf-codereview_blender.org,

Description:
This adds two more scale factors (width, height) to particle settings.
Since the billboard size is currently just use the particle size, which
is a problem when particle size is used primarily for collision, etc. In
that case it is useful to have additional scale factors to adjust
billboard size to visual requirements.

Please review this at http://codereview.appspot.com/4629045/

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


Index: release/scripts/startup/bl_ui/properties_particle.py
===================================================================
--- release/scripts/startup/bl_ui/properties_particle.py	(revision 37410)
+++ release/scripts/startup/bl_ui/properties_particle.py	(working copy)
@@ -876,8 +876,12 @@
              col.label(text="Tilt:")
              col.prop(part, "billboard_tilt", text="Angle", slider=True)
              col.prop(part, "billboard_tilt_random", text="Random",  
slider=True)
+
+            row = layout.row()
              col = row.column()
              col.prop(part, "billboard_offset")
+            col = row.column()
+            col.prop(part, "billboard_scale")

              if psys:
                  col = layout.column()
Index: source/blender/render/intern/source/convertblender.c
===================================================================
--- source/blender/render/intern/source/convertblender.c	(revision 37410)
+++ source/blender/render/intern/source/convertblender.c	(working copy)
@@ -2015,7 +2015,7 @@

  					if(part->ren_as == PART_DRAW_BB) {
  						bb.random = random;
-						bb.size = pa_size;
+						mul_v2_v2fl(bb.size, part->bb_scale, pa_size);
  						bb.tilt = part->bb_tilt * (1.0f - part->bb_rand_tilt * r_tilt);
  						bb.time = ct;
  						bb.num = a;
@@ -2040,7 +2040,7 @@

  				if(part->ren_as == PART_DRAW_BB) {
  					bb.random = random;
-					bb.size = pa_size;
+					mul_v2_v2fl(bb.size, part->bb_scale, pa_size);
  					bb.tilt = part->bb_tilt * (1.0f - part->bb_rand_tilt * r_tilt);
  					bb.time = pa_time;
  					bb.num = a;
Index: source/blender/blenkernel/BKE_blender.h
===================================================================
--- source/blender/blenkernel/BKE_blender.h	(revision 37410)
+++ source/blender/blenkernel/BKE_blender.h	(working copy)
@@ -44,7 +44,7 @@
   * and keep comment above the defines.
   * Use STRINGIFY() rather than defining with quotes */
  #define BLENDER_VERSION			257
-#define BLENDER_SUBVERSION		1
+#define BLENDER_SUBVERSION		2

  #define BLENDER_MINVERSION		250
  #define BLENDER_MINSUBVERSION	0
Index: source/blender/blenkernel/intern/particle.c
===================================================================
--- source/blender/blenkernel/intern/particle.c	(revision 37410)
+++ source/blender/blenkernel/intern/particle.c	(working copy)
@@ -3534,6 +3534,8 @@
  	part->path_start = 0.0f;
  	part->path_end = 1.0f;

+	part->bb_scale[0] = part->bb_scale[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]);
Index: source/blender/blenkernel/BKE_particle.h
===================================================================
--- source/blender/blenkernel/BKE_particle.h	(revision 37410)
+++ source/blender/blenkernel/BKE_particle.h	(working copy)
@@ -147,7 +147,7 @@
  	struct Object *ob;
  	float vec[3], vel[3];
  	float offset[2];
-	float size, tilt, random, time;
+	float size[2], tilt, random, time;
  	int uv[3];
  	int lock, num;
  	int totnum;
Index: source/blender/makesdna/DNA_particle_types.h
===================================================================
--- source/blender/makesdna/DNA_particle_types.h	(revision 37410)
+++ source/blender/makesdna/DNA_particle_types.h	(working copy)
@@ -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_scale[2];

  	/* draw color */
  	float color_vec_max;
Index: source/blender/makesrna/intern/rna_particle.c
===================================================================
--- source/blender/makesrna/intern/rna_particle.c	(revision 37410)
+++ source/blender/makesrna/intern/rna_particle.c	(working copy)
@@ -1958,6 +1958,13 @@
  	RNA_def_property_ui_text(prop, "Billboard Offset", "");
  	RNA_def_property_update(prop, 0, "rna_Particle_redo");

+	prop= RNA_def_property(srna, "billboard_scale", PROP_FLOAT, PROP_FACTOR);
+	RNA_def_property_float_sdna(prop, NULL, "bb_scale");
+	RNA_def_property_array(prop, 2);
+	RNA_def_property_range(prop, 0.001f, 1000.0f);
+	RNA_def_property_ui_text(prop, "Scale", "Scale of the billboards relative  
to particle size");
+	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);
Index: source/blender/blenloader/intern/readfile.c
===================================================================
--- source/blender/blenloader/intern/readfile.c	(revision 37410)
+++ source/blender/blenloader/intern/readfile.c	(working copy)
@@ -11593,9 +11593,7 @@
  					}
  	}

-	/* put compatibility code here until next subversion bump */
-
-	{
+	if (main->versionfile < 257 || (main->versionfile == 257 &&  
main->subversionfile < 2)){
  		/* 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? */
@@ -11647,8 +11645,22 @@
  				}
  			}
  		}
+
+		{
+			/* Initialize particle billboard scale */
+			ParticleSettings *part;
+			for(part = main->particle.first; part; part = part->id.next) {
+				part->bb_scale[0] = part->bb_scale[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! */

Index: source/blender/editors/space_view3d/drawobject.c
===================================================================
--- source/blender/editors/space_view3d/drawobject.c	(revision 37410)
+++ source/blender/editors/space_view3d/drawobject.c	(working copy)
@@ -3884,7 +3884,7 @@

  					/* create actiual particle data */
  					if(draw_as == PART_DRAW_BB) {
-						bb.size = pa_size;
+						mul_v2_v2fl(bb.size, part->bb_scale, pa_size);
  						bb.tilt = part->bb_tilt * (1.0f - part->bb_rand_tilt * r_tilt);
  						bb.time = ct;
  					}
@@ -3904,7 +3904,7 @@

  					/* create actiual particle data */
  					if(draw_as == PART_DRAW_BB) {
-						bb.size = pa_size;
+						mul_v2_v2fl(bb.size, part->bb_scale, pa_size);
  						bb.tilt = part->bb_tilt * (1.0f - part->bb_rand_tilt * r_tilt);
  						bb.time = pa_time;
  					}




More information about the Bf-codereview mailing list