[Bf-extensions-cvs] [6cab0b8] master: Keep the outliner sane by making the ground object the parent of copied objects and duplicators.

Lukas Tönne noreply at git.blender.org
Wed Dec 10 15:15:38 CET 2014


Commit: 6cab0b8290854d1893f96274a456f1f0b920959f
Author: Lukas Tönne
Date:   Wed Dec 10 15:09:31 2014 +0100
Branches: master
https://developer.blender.org/rBAC6cab0b8290854d1893f96274a456f1f0b920959f

Keep the outliner sane by making the ground object the parent of copied
objects and duplicators.

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

M	object_physics_meadow/blob.py
M	object_physics_meadow/meadow.py
M	object_physics_meadow/patch.py
M	object_physics_meadow/util.py

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

diff --git a/object_physics_meadow/blob.py b/object_physics_meadow/blob.py
index 75e261c..8c6193a 100644
--- a/object_physics_meadow/blob.py
+++ b/object_physics_meadow/blob.py
@@ -185,6 +185,8 @@ def make_blobs(context, gridob, groundob, samples, display_radius):
             ob = make_blob_object(context, index, blob.loc, samples, display_radius)
             # put it in the blob group
             blob_group_assign(context, ob)
+            # use ground object as parent to keep the outliner clean
+            set_object_parent(ob, groundob)
 
 #-----------------------------------------------------------------------
 
@@ -266,9 +268,11 @@ def setup_blob_duplis(context, groundob, display_radius):
                 # put the duplicator in the patch group,
                 # so it gets removed together with patch copies
                 patch_group_assign(context, dob)
+                # use ground object as parent to keep the outliner clean
+                set_object_parent(dob, groundob)
                 
                 dob.dupli_type = 'FACES'
-                
+
                 ob.parent = dob
                 # make sure duplis are placed at the sample locations
                 if ob.meadow.use_centered:
diff --git a/object_physics_meadow/meadow.py b/object_physics_meadow/meadow.py
index 1e6fd43..245de8f 100644
--- a/object_physics_meadow/meadow.py
+++ b/object_physics_meadow/meadow.py
@@ -72,5 +72,5 @@ def make_blobs(context, gridob, groundob):
 def make_patches(context, gridob, groundob):
     scene = context.scene
     template_objects = [ob for ob in scene.objects if ob.meadow.type == 'TEMPLATE']
-    patch.make_patches(context, gridob, template_objects)
+    patch.make_patches(context, groundob, gridob, template_objects)
     blob.setup_blob_duplis(context, groundob, 0.333 * gridob.meadow.patch_radius)
diff --git a/object_physics_meadow/patch.py b/object_physics_meadow/patch.py
index 9c035df..9eb1687 100644
--- a/object_physics_meadow/patch.py
+++ b/object_physics_meadow/patch.py
@@ -122,7 +122,7 @@ def make_copies(scene, gridob, childob):
     
     return duplicates
 
-def make_patches(context, gridob, template_objects):
+def make_patches(context, groundob, gridob, template_objects):
     scene = context.scene
     gridmat = gridob.matrix_world
     
@@ -139,6 +139,8 @@ def make_patches(context, gridob, template_objects):
             patch_group_assign(context, ob)
             # assign the index for mapping
             ob.meadow.blob_index = index
+            # use ground object as parent to keep the outliner clean
+            set_object_parent(ob, groundob)
             
             # apply transform
             vertmat = Matrix.Translation(vert.co)
diff --git a/object_physics_meadow/util.py b/object_physics_meadow/util.py
index 3437bf3..5b4af67 100644
--- a/object_physics_meadow/util.py
+++ b/object_physics_meadow/util.py
@@ -88,6 +88,14 @@ def delete_objects(context, objects):
 
 #-----------------------------------------------------------------------
 
+# set the object parent without modifying world space transform
+def set_object_parent(ob, parent):
+    mat = ob.matrix_world
+    ob.parent = parent
+    ob.matrix_world = mat
+
+#-----------------------------------------------------------------------
+
 class Profiling():
     def __init__(self, name):
         self.name = name



More information about the Bf-extensions-cvs mailing list