Fix #32201: particle size compatibility broken for object/group duplication.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 22 Aug 2012 13:10:43 +0000 (13:10 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 22 Aug 2012 13:10:43 +0000 (13:10 +0000)
After 2.63 there was a bugfix to take object scale into account for the duplicated
objects, but this breaks compatibility on earlier files. Now there is an option to
control if the scale should be used or not.

Scale is used by default on newer files, and not used on older ones.

release/scripts/startup/bl_ui/properties_particle.py
source/blender/blenkernel/intern/anim.c
source/blender/blenloader/intern/readfile.c
source/blender/makesdna/DNA_particle_types.h
source/blender/makesrna/intern/rna_particle.c

index 2c9bcefd2f831ce45a5479f407cc8e86069f4d21..aa0ea1d2d9ef24cb092d5b9a7c0a4fc9236c395e 100644 (file)
@@ -849,6 +849,7 @@ class PARTICLE_PT_render(ParticleButtonsPanel, Panel):
             sub = col.row()
             sub.prop(part, "use_global_dupli")
             sub.prop(part, "use_rotation_dupli")
+            sub.prop(part, "use_scale_dupli")
         elif part.render_type == 'GROUP':
             col.prop(part, "dupli_group")
             split = layout.split()
@@ -865,6 +866,7 @@ class PARTICLE_PT_render(ParticleButtonsPanel, Panel):
             sub.active = (part.use_whole_group is False)
             sub.prop(part, "use_global_dupli")
             sub.prop(part, "use_rotation_dupli")
+            sub.prop(part, "use_scale_dupli")
 
             if part.use_group_count and not part.use_whole_group:
                 row = layout.row()
index 33cdede6fced35ff1d47e89acd416a0bcc4b4479..6e857bacb1ba420e9ba84fd43ce8bc2d7bae00c2 100644 (file)
@@ -1469,6 +1469,18 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
                                        quat_to_mat4(obmat, q);
                                        obmat[3][3] = 1.0f;
                                        
+                                       /* add scaling if requested */
+                                       if ((part->draw & PART_DRAW_NO_SCALE_OB) == 0)
+                                               mult_m4_m4m4(obmat, obmat, size_mat);
+                               }
+                               else if (part->draw & PART_DRAW_NO_SCALE_OB) {
+                                       /* remove scaling */
+                                       float size_mat[4][4], original_size[3];
+
+                                       mat4_to_size(original_size, obmat);
+                                       size_to_mat4(size_mat, original_size);
+                                       invert_m4(size_mat);
+
                                        mult_m4_m4m4(obmat, obmat, size_mat);
                                }
                                
index 719081e378d4432aafdbd2cf3cd3a3b9ca0eabd8..1956cfaedf0240744c5a605cff9b04d9de28de2a 100644 (file)
@@ -7925,10 +7925,17 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
        }
 
        if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 14)) {
+               ParticleSettings *part;
                bNodeTreeType *ntreetype = ntreeGetType(NTREE_COMPOSIT);
 
                if (ntreetype && ntreetype->foreach_nodetree)
                        ntreetype->foreach_nodetree(main, NULL, do_version_ntree_keying_despill_balance);
+
+               /* keep compatibility for dupliobject particle size */
+               for (part=main->particle.first; part; part=part->id.next)
+                       if (ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR))
+                               if ((part->draw & PART_DRAW_ROTATE_OB) == 0)
+                                       part->draw |= PART_DRAW_NO_SCALE_OB;
        }
 
        if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 17)) {
index 0853df87a35c9c40b3ffc510572295a84d47ecd4..5952aa8afb03478c94b2ced00ab149e27e94dd4c 100644 (file)
@@ -154,7 +154,8 @@ typedef struct ParticleSettings {
        short type, from, distr, texact;
        /* physics modes */
        short phystype, rotmode, avemode, reactevent;
-       short draw, draw_as, draw_size, childtype;
+       int draw, pad1;
+       short draw_as, draw_size, childtype, pad2;
        short ren_as, subframes, draw_col;
        /* number of path segments, power of 2 except */
        short draw_step, ren_step;
@@ -398,6 +399,7 @@ typedef struct ParticleSystem {
 #define PART_DRAW_MAT_COL              (1<<13) /* deprecated, but used in do_versions */
 #define PART_DRAW_WHOLE_GR             (1<<14)
 #define PART_DRAW_REN_STRAND   (1<<15)
+#define PART_DRAW_NO_SCALE_OB  (1<<16) /* used with dupliobjects/groups */
 
 /* part->draw_col */
 #define PART_DRAW_COL_NONE             0
index 8cf3b718c3086fca129cdf35e653394bc27e503c..fc3dfafe1337149acc2cae6a8ebefb6548c372f3 100644 (file)
@@ -1846,6 +1846,11 @@ static void rna_def_particle_settings(BlenderRNA *brna)
                                 "particle rotation axis)");
        RNA_def_property_update(prop, 0, "rna_Particle_redo");
 
+       prop = RNA_def_property(srna, "use_scale_dupli", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_negative_sdna(prop, NULL, "draw", PART_DRAW_NO_SCALE_OB);
+       RNA_def_property_ui_text(prop, "Scale", "Use object's scale for duplication");
+       RNA_def_property_update(prop, 0, "rna_Particle_redo");
+
        prop = RNA_def_property(srna, "use_render_adaptive", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_REN_ADAPT);
        RNA_def_property_ui_text(prop, "Adaptive render", "Draw steps of the particle path");