[Bf-extensions-cvs] [7aef3e7] master: New setting for dupli templates "use_centered" for switching between blob and world centering of duplis.

Lukas Tönne noreply at git.blender.org
Tue Dec 9 23:56:10 CET 2014


Commit: 7aef3e76b931f868765635764ac94e6c21937ca2
Author: Lukas Tönne
Date:   Tue Dec 9 23:50:34 2014 +0100
Branches: master
https://developer.blender.org/rBAC7aef3e76b931f868765635764ac94e6c21937ca2

New setting for dupli templates "use_centered" for switching between
blob and world centering of duplis.

This is necessary for particle instance duplis: Regular duplis work
relative to the dupli object's position, so its location should be
the same as the duplicator in order to get the correct patch placement.
Particle instance modifier OTOH adds the particle transform //on top of
the dupli transform//. This could be considered a bug, but until it gets
fixed officially this option provides a workaround.

===================================================================

M	object_physics_meadow/blob.py
M	object_physics_meadow/patch.py
M	object_physics_meadow/settings.py
M	object_physics_meadow/ui.py

===================================================================

diff --git a/object_physics_meadow/blob.py b/object_physics_meadow/blob.py
index de0e55f..ddb9975 100644
--- a/object_physics_meadow/blob.py
+++ b/object_physics_meadow/blob.py
@@ -44,6 +44,9 @@ def blob_group_clear(context):
     blob_group = settings.blob_group(context)
     scene = context.scene
     
+    if not blob_group:
+        return
+    
     # local list copy to avoid messing up the iterator
     objects = [ob for ob in blob_group.objects]
     
@@ -230,17 +233,22 @@ def setup_blob_duplis(context, display_radius):
             if not samples:
                 continue
             
-            dob = make_blob_object(context, blob_index, blob.loc, samples, display_radius)
-            # put the duplicator in the patch group,
-            # so it gets removed together with patch copies
-            patch_group_assign(context, dob)
-            
-            # make it a duplicator for the patch object
             if ob.meadow.use_as_dupli:
+                # make a duplicator for the patch object
+                dob = make_blob_object(context, blob_index, blob.loc, samples, display_radius)
+                # put the duplicator in the patch group,
+                # so it gets removed together with patch copies
+                patch_group_assign(context, dob)
+                
+                dob.dupli_type = 'FACES'
+                
                 ob.parent = dob
                 # make sure duplis are placed at the sample locations
-                ob.matrix_world = Matrix.Identity(4)
+                if ob.meadow.use_centered:
+                    # XXX centering is needed for particle instance modifier (this might be a bug!)
+                    ob.matrix_world = Matrix.Identity(4)
+                else:
+                    ob.matrix_world = dob.matrix_world
             else:
                 # move to the blob center
                 ob.matrix_world = dob.matrix_world
-            dob.dupli_type = 'FACES'
diff --git a/object_physics_meadow/patch.py b/object_physics_meadow/patch.py
index 06e9c45..bf41840 100644
--- a/object_physics_meadow/patch.py
+++ b/object_physics_meadow/patch.py
@@ -45,6 +45,9 @@ def patch_group_clear(context):
     patch_group = settings.patch_group(context)
     scene = context.scene
     
+    if not patch_group:
+        return
+    
     # local list copy to avoid messing up the iterator
     objects = [ob for ob in patch_group.objects]
     
diff --git a/object_physics_meadow/settings.py b/object_physics_meadow/settings.py
index 21f8172..b1ea334 100644
--- a/object_physics_meadow/settings.py
+++ b/object_physics_meadow/settings.py
@@ -100,6 +100,12 @@ class MeadowObjectSettings(PropertyGroup):
         default=True
         )
     
+    use_centered = BoolProperty(
+        name="Use Centered",
+        description="Move copies to the center before duplifying (use with particle instance)",
+        default=False
+        )
+    
     seed = IntProperty(
         name="Seed",
         description="General random number seed value",
diff --git a/object_physics_meadow/ui.py b/object_physics_meadow/ui.py
index b6c0473..834507e 100644
--- a/object_physics_meadow/ui.py
+++ b/object_physics_meadow/ui.py
@@ -59,7 +59,11 @@ class OBJECT_PT_Meadow(Panel):
                 row.active = False
                 row.prop(meadow, "density_vgroup_name", text="Density Vertex Group")
             
-            layout.prop(meadow, "use_as_dupli")
+            row = layout.row()
+            row.prop(meadow, "use_as_dupli")
+            sub = row.row()
+            sub.enabled = meadow.use_as_dupli
+            sub.prop(meadow, "use_centered")
             
             layout.operator("meadow.make_patches", icon='PARTICLE_PATH')



More information about the Bf-extensions-cvs mailing list