Optional layers setting to directly place new objects in specific layers.
authorLukas Tönne <lukas.toenne@gmail.com>
Tue, 16 Dec 2014 17:30:22 +0000 (18:30 +0100)
committerLukas Tönne <lukas.toenne@gmail.com>
Tue, 16 Dec 2014 17:30:22 +0000 (18:30 +0100)
object_physics_meadow/blob.py
object_physics_meadow/patch.py
object_physics_meadow/settings.py
object_physics_meadow/ui.py

index 6b23115..937ff78 100644 (file)
@@ -229,6 +229,9 @@ def make_blob_visualizer(context, groundob, blobs, display_radius, hide, hide_re
                 blob_group_assign(context, ob)
                 # use parent to keep the outliner clean
                 set_object_parent(ob, blob_parent)
+                # apply layers
+                if groundob.meadow.use_layers:
+                    ob.layers = groundob.meadow.layers
                 
                 ob.hide = hide
                 ob.hide_render = hide_render
@@ -378,6 +381,9 @@ def setup_blob_duplis(context, groundob, display_radius):
                 set_object_parent(dob, blob_parent)
                 # make unselectable by default
                 dob.hide_select = True
+                # apply layers
+                if groundob.meadow.use_layers:
+                    dob.layers = groundob.meadow.layers
 
                 set_object_parent(ob, dob)
                 
index aa48565..d584283 100644 (file)
@@ -145,7 +145,10 @@ def make_patches(context, groundob, gridob, template_objects):
             ob.meadow.blob_index = index
             # use ground object as parent to keep the outliner clean
             set_object_parent(ob, groundob)
-            
+            # apply layers
+            if groundob.meadow.use_layers:
+                ob.layers = groundob.meadow.layers
+
             # apply transform
             vertmat = Matrix.Translation(vert.co)
             duplimat = gridmat * vertmat
index b1ea334..a4de886 100644 (file)
@@ -74,6 +74,7 @@ type_items = [
 unique_types = {'GROUND', 'BLOBGRID'}
 
 def type_update(self, context):
+    # ensure unique types
     if self.type in unique_types:
         scene = context.scene
         for ob in scene.objects:
@@ -86,6 +87,16 @@ def vgroup_items(self, context):
         return [(v.name, v.name, "", 'NONE', v.index) for v in groundob.vertex_groups]
     return []
 
+def use_layers_update(self, context):
+    if self.use_layers:
+        # copy layer settings from the object when enabling for the first time
+        if all(layer == False for layer in self.layers):
+            self.layers = self.id_data.layers
+
+def used_layers_get(self):
+    # XXX dummy property
+    return tuple(False for i in range(20))
+
 class MeadowObjectSettings(PropertyGroup):
     type = EnumProperty(
         name="Type",
@@ -99,6 +110,28 @@ class MeadowObjectSettings(PropertyGroup):
         description="Use the object for dupli instances",
         default=True
         )
+
+    use_layers = BoolProperty(
+        name="Use Layers",
+        description="Put new objects into custom layers",
+        default=False,
+        update=use_layers_update
+        )
+    
+    layers = BoolVectorProperty(
+        name="Layers",
+        description="Object copies and duplicators will be placed in these layers",
+        size=20,
+        options=set()
+        )
+
+    used_layers = BoolVectorProperty(
+        name="Used Layers",
+        description="Object copies and duplicators will be placed in these layers",
+        size=20,
+        get=used_layers_get,
+        options={'HIDDEN'}
+        )
     
     use_centered = BoolProperty(
         name="Use Centered",
index ba5add2..66f5501 100644 (file)
@@ -98,6 +98,15 @@ class OBJECT_PT_Meadow(Panel):
         
         layout.separator()
         
+        row = layout.row()
+        row.prop(groundob.meadow, "use_layers")
+        sub = row.row()
+        if groundob.meadow.use_layers:
+            sub.template_layers(groundob.meadow, "layers", groundob.meadow, "used_layers", -1)
+        else:
+            sub.enabled = False
+            sub.template_layers(groundob, "layers", groundob.meadow, "used_layers", -1)
+
         sub = layout.column()
         sub.enabled = has_samples
         sub.operator("meadow.make_patches", icon='PARTICLE_PATH', text="Update Patches")