[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34899] trunk/blender: Particle settings can now be pinned too:

Janne Karhu jhkarh at gmail.com
Wed Feb 16 11:57:58 CET 2011


Revision: 34899
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34899
Author:   jhk
Date:     2011-02-16 10:57:58 +0000 (Wed, 16 Feb 2011)
Log Message:
-----------
Particle settings can now be pinned too:
* Particle system's are comparable to texture slots, which can
  only exist within an id block. Particle settings on the other
  hand are idblocks which should be pinnable just like textures.
* When particle settings are pinned only properties that make
  sense without the actual particle system are shown in the
  particle panel.

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/properties_particle.py
    trunk/blender/source/blender/editors/space_buttons/buttons_context.c

Modified: trunk/blender/release/scripts/ui/properties_particle.py
===================================================================
--- trunk/blender/release/scripts/ui/properties_particle.py	2011-02-16 10:23:27 UTC (rev 34898)
+++ trunk/blender/release/scripts/ui/properties_particle.py	2011-02-16 10:57:58 UTC (rev 34899)
@@ -27,6 +27,8 @@
 
 
 def particle_panel_enabled(context, psys):
+    if psys == None:
+        return True
     phystype = psys.settings.physics_type
     if psys.settings.type in ('EMITTER', 'REACTOR') and phystype in ('NO', 'KEYED'):
         return True
@@ -37,13 +39,26 @@
 def particle_panel_poll(cls, context):
     psys = context.particle_system
     engine = context.scene.render.engine
-    if psys is None:
+    settings = 0
+    
+    if psys:
+        settings = psys.settings
+    elif isinstance(context.space_data.pin_id, bpy.types.ParticleSettings):
+        settings = context.space_data.pin_id
+    
+    if not settings:
         return False
-    if psys.settings is None:
-        return False
-    return psys.settings.is_fluid == False and (engine in cls.COMPAT_ENGINES)
 
+    return settings.is_fluid == False and (engine in cls.COMPAT_ENGINES)
+    
+def particle_get_settings(context):
+    if context.particle_system:
+        return context.particle_system.settings
+    elif isinstance(context.space_data.pin_id, bpy.types.ParticleSettings):
+        return context.space_data.pin_id
+    return None
 
+
 class ParticleButtonsPanel():
     bl_space_type = 'PROPERTIES'
     bl_region_type = 'WINDOW'
@@ -62,13 +77,14 @@
     @classmethod
     def poll(cls, context):
         engine = context.scene.render.engine
-        return (context.particle_system or context.object) and (engine in cls.COMPAT_ENGINES)
+        return (context.particle_system or context.object or context.space_data.pin_id) and (engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
 
         ob = context.object
         psys = context.particle_system
+        part = 0
 
         if ob:
             row = layout.row()
@@ -79,7 +95,21 @@
             col.operator("object.particle_system_add", icon='ZOOMIN', text="")
             col.operator("object.particle_system_remove", icon='ZOOMOUT', text="")
 
-        if psys and not psys.settings:
+        if psys == None:
+            part = particle_get_settings(context)
+            
+            if part == None:
+                return
+                
+            layout.template_ID(context.space_data, "pin_id")
+            
+            if part.is_fluid:
+                layout.label(text="Settings used for fluid.")
+                return
+                
+            layout.prop(part, "type", text="Type")
+        
+        elif not psys.settings:
             split = layout.split(percentage=0.32)
 
             col = split.column()
@@ -89,7 +119,7 @@
             col = split.column()
             col.prop(psys, "name", text="")
             col.template_ID(psys, "settings", new="particle.new")
-        elif psys:
+        else:
             part = psys.settings
 
             split = layout.split(percentage=0.32)
@@ -110,39 +140,39 @@
             #row.label(text="Viewport")
             #row.label(text="Render")
 
-            if part:
-                if part.is_fluid:
-                    layout.label(text=str(part.count) + " fluid particles for this frame.")
-                    return
+            if part.is_fluid:
+                layout.label(text=str(part.count) + " fluid particles for this frame.")
+                return
 
-                row = col.row()
-                row.enabled = particle_panel_enabled(context, psys)
-                row.prop(part, "type", text="")
-                row.prop(psys, "seed")
+            row = col.row()
+            row.enabled = particle_panel_enabled(context, psys)
+            row.prop(part, "type", text="")
+            row.prop(psys, "seed")
 
-                split = layout.split(percentage=0.65)
-                if part.type == 'HAIR':
-                    if psys.is_edited:
-                        split.operator("particle.edited_clear", text="Free Edit")
-                    else:
-                        row = split.row()
-                        row.enabled = particle_panel_enabled(context, psys)
-                        row.prop(part, "regrow_hair")
-                        row.prop(part, "use_advanced_hair")
+        if part:
+            split = layout.split(percentage=0.65)
+            if part.type == 'HAIR':
+                if psys != None and psys.is_edited:
+                    split.operator("particle.edited_clear", text="Free Edit")
+                else:
                     row = split.row()
                     row.enabled = particle_panel_enabled(context, psys)
-                    row.prop(part, "hair_step")
-                    if psys.is_edited:
-                        if psys.is_global_hair:
-                            layout.operator("particle.connect_hair")
-                            layout.label(text="Hair is disconnected.")
-                        else:
-                            layout.operator("particle.disconnect_hair")
-                            layout.label(text="")
-                elif part.type == 'REACTOR':
-                    split.enabled = particle_panel_enabled(context, psys)
-                    split.prop(psys, "reactor_target_object")
-                    split.prop(psys, "reactor_target_particle_system", text="Particle System")
+                    row.prop(part, "regrow_hair")
+                    row.prop(part, "use_advanced_hair")
+                row = split.row()
+                row.enabled = particle_panel_enabled(context, psys)
+                row.prop(part, "hair_step")
+                if psys != None and psys.is_edited:
+                    if psys.is_global_hair:
+                        layout.operator("particle.connect_hair")
+                        layout.label(text="Hair is disconnected.")
+                    else:
+                        layout.operator("particle.disconnect_hair")
+                        layout.label(text="")
+            elif psys != None and part.type == 'REACTOR':
+                split.enabled = particle_panel_enabled(context, psys)
+                split.prop(psys, "reactor_target_object")
+                split.prop(psys, "reactor_target_particle_system", text="Particle System")
 
 
 class PARTICLE_PT_emission(ParticleButtonsPanel, bpy.types.Panel):
@@ -152,23 +182,23 @@
     @classmethod
     def poll(cls, context):
         psys = context.particle_system
-        if psys is None:
+        settings = particle_get_settings(context)
+
+        if settings is None:
             return False
-        if psys.settings is None:
+        if settings.is_fluid:
             return False
-        if psys.settings.is_fluid:
-            return False
         if particle_panel_poll(PARTICLE_PT_emission, context):
-            return not context.particle_system.point_cache.use_external
+            return psys == None or not context.particle_system.point_cache.use_external
         return False
 
     def draw(self, context):
         layout = self.layout
 
         psys = context.particle_system
-        part = psys.settings
+        part = particle_get_settings(context)
 
-        layout.enabled = particle_panel_enabled(context, psys) and not psys.has_multiple_caches
+        layout.enabled = particle_panel_enabled(context, psys) and (psys == None or not psys.has_multiple_caches)
 
         row = layout.row()
         row.active = part.distribution != 'GRID'
@@ -309,9 +339,11 @@
     def poll(cls, context):
         if particle_panel_poll(PARTICLE_PT_velocity, context):
             psys = context.particle_system
-            if psys.settings.type == 'HAIR' and not psys.settings.use_advanced_hair:
+            settings = particle_get_settings(context)
+
+            if settings.type == 'HAIR' and not settings.use_advanced_hair:
                 return False
-            return psys.settings.physics_type != 'BOIDS' and not psys.point_cache.use_external
+            return settings.physics_type != 'BOIDS' and (psys == None or not psys.point_cache.use_external)
         else:
             return False
 
@@ -319,7 +351,7 @@
         layout = self.layout
 
         psys = context.particle_system
-        part = psys.settings
+        part = particle_get_settings(context)
 
         layout.enabled = particle_panel_enabled(context, psys)
 
@@ -359,9 +391,11 @@
     def poll(cls, context):
         if particle_panel_poll(PARTICLE_PT_rotation, context):
             psys = context.particle_system
-            if psys.settings.type == 'HAIR' and not psys.settings.use_advanced_hair:
+            settings = particle_get_settings(context)
+            
+            if settings.type == 'HAIR' and not settings.use_advanced_hair:
                 return False
-            return psys.settings.physics_type != 'BOIDS' and not psys.point_cache.use_external
+            return settings.physics_type != 'BOIDS' and (psys == None or not psys.point_cache.use_external)
         else:
             return False
 
@@ -369,7 +403,10 @@
         layout = self.layout
 
         psys = context.particle_system
-        part = psys.settings
+        if psys:
+            part = psys.settings
+        else:
+            part = context.space_data.pin_id
 
         layout.enabled = particle_panel_enabled(context, psys)
 
@@ -404,9 +441,11 @@
     def poll(cls, context):
         if particle_panel_poll(PARTICLE_PT_physics, context):
             psys = context.particle_system
-            if psys.settings.type == 'HAIR' and not psys.settings.use_advanced_hair:
+            settings = particle_get_settings(context)
+
+            if settings.type == 'HAIR' and not settings.use_advanced_hair:
                 return False
-            return not psys.point_cache.use_external
+            return psys == None or not psys.point_cache.use_external
         else:
             return False
 
@@ -414,7 +453,7 @@
         layout = self.layout
 
         psys = context.particle_system
-        part = psys.settings
+        part = particle_get_settings(context)
 
         layout.enabled = particle_panel_enabled(context, psys)
 
@@ -504,7 +543,8 @@
             col = row.column()
             col.active = not psys.use_keyed_timing
             col.prop(part, "keyed_loops", text="Loops")

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list