[Bf-blender-cvs] [c9d7056] gooseberry: Removed group pointer from cache libraries and use object->cachelib pointer instead.
Lukas Tönne
noreply at git.blender.org
Mon Mar 23 13:03:56 CET 2015
Commit: c9d7056f767ccb2c1aa4cfa37e8dde7484227106
Author: Lukas Tönne
Date: Wed Mar 18 12:51:26 2015 +0100
Branches: gooseberry
https://developer.blender.org/rBc9d7056f767ccb2c1aa4cfa37e8dde7484227106
Removed group pointer from cache libraries and use object->cachelib
pointer instead.
This change makes it possible to have group duplicators using different
versions of a cache.
===================================================================
M release/scripts/startup/bl_ui/properties_object.py
M release/scripts/startup/bl_ui/properties_scene.py
M source/blender/blenkernel/BKE_cache_library.h
M source/blender/blenkernel/intern/cache_library.c
M source/blender/blenkernel/intern/group.c
M source/blender/blenkernel/intern/object_dupli.c
M source/blender/blenloader/intern/readfile.c
M source/blender/editors/io/io_cache_library.c
M source/blender/makesdna/DNA_cache_library_types.h
M source/blender/makesrna/intern/rna_cache_library.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py
index e655b17..1a03a58 100644
--- a/release/scripts/startup/bl_ui/properties_object.py
+++ b/release/scripts/startup/bl_ui/properties_object.py
@@ -261,9 +261,105 @@ class OBJECT_PT_display(ObjectButtonsPanel, Panel):
row.prop(obj, "show_wire_color", text="", toggle=True, icon='WIRE')
+# XXX temporary solution
+bpy.types.CacheLibrary.filter_string = \
+ bpy.props.StringProperty(
+ name="Filter Object Name",
+ description="Filter cache library objects by name",
+ )
+bpy.types.CacheLibrary.filter_types = \
+ bpy.props.EnumProperty(
+ name="Filter Item Type",
+ description="Filter cache library items by type",
+ options={'ENUM_FLAG'},
+ items=[ (e.identifier, e.name, e.description, e.icon, 2**i) for i, e in enumerate(bpy.types.CacheItem.bl_rna.properties['type'].enum_items) ],
+ default=set( e.identifier for e in bpy.types.CacheItem.bl_rna.properties['type'].enum_items ),
+ )
+
+def cachelib_objects(cachelib, group):
+ if not cachelib or not group:
+ return []
+
+ filter_string = cachelib.filter_string.lower()
+ if filter_string:
+ return filter(lambda ob: filter_string in ob.name.lower(), group.objects)
+ else:
+ return group.objects
+
+# Yields (item, type, index, enabled)
+# Note that item can be None when not included in the cache yet
+def cachelib_object_items(cachelib, ob):
+ filter_types = cachelib.filter_types
+
+ def items_desc():
+ yield 'OBJECT', -1
+
+ if (ob.type == 'MESH'):
+ yield 'DERIVED_MESH', -1
+
+ for index, psys in enumerate(ob.particle_systems):
+ if psys.settings.type == 'EMITTER':
+ yield 'PARTICLES', index
+ if psys.settings.type == 'HAIR':
+ yield 'HAIR', index
+ yield 'HAIR_PATHS', index
+
+ for item_type, item_index in items_desc():
+ item = cachelib.cache_item_find(ob, item_type, item_index)
+
+ show = False
+ enable = False
+ # always show existing items
+ if item and item.enabled:
+ show = True
+ enable = True
+ # always show selected types
+ elif item_type in filter_types:
+ show = True
+ enable = True
+ # special case: OBJECT type used as top level, show but disable
+ elif item_type == 'OBJECT':
+ show = True
+ enable = False
+
+ if show:
+ yield item, item_type, item_index, enable
+
class OBJECT_PT_duplication(ObjectButtonsPanel, Panel):
bl_label = "Duplication"
+ def draw_cachelib(self, context, layout, cachelib, objects):
+ col = layout.column(align=True)
+ colrow = col.row(align=True)
+ colrow.label("Archive:")
+ props = colrow.operator("cachelibrary.archive_info", text="", icon='QUESTION')
+ props.use_stdout = True
+ props.use_popup = True
+ props.use_clipboard = True
+ col.prop(cachelib, "filepath", text="")
+
+ col.operator("cachelibrary.bake")
+ col.prop(cachelib, "eval_mode", expand=False)
+
+ row = layout.row(align=True)
+ row.label("Filter:")
+ row.prop(cachelib, "filter_types", icon_only=True, toggle=True)
+ row.prop(cachelib, "filter_string", icon='VIEWZOOM', text="")
+
+ first = True
+ for ob in objects:
+ if not any(cachelib_object_items(cachelib, ob)):
+ continue
+
+ if first:
+ layout.separator()
+ first = False
+
+ for item, item_type, item_index, enable in cachelib_object_items(cachelib, ob):
+ row = layout.row(align=True)
+ row.alignment = 'LEFT'
+ row.template_cache_library_item(cachelib, ob, item_type, item_index, enable)
+
def draw(self, context):
layout = self.layout
@@ -297,11 +393,15 @@ class OBJECT_PT_duplication(ObjectButtonsPanel, Panel):
elif ob.dupli_type == 'GROUP':
layout.prop(ob, "dupli_group", text="Group")
row = layout.row(align=True)
- row.prop(ob, "cache_library")
+ row.template_ID(ob, "cache_library", new="cachelibrary.new")
sub = row.row(align=True)
sub.active = ob.cache_library is not None
sub.prop(ob, "use_dupli_cache", text="Read", toggle=True)
+ if ob.cache_library:
+ cache_objects = cachelib_objects(ob.cache_library, ob.dupli_group)
+ self.draw_cachelib(context, layout, ob.cache_library, cache_objects)
+
class OBJECT_PT_relations_extras(ObjectButtonsPanel, Panel):
bl_label = "Relations Extras"
diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py
index a2e389b..facf54d 100644
--- a/release/scripts/startup/bl_ui/properties_scene.py
+++ b/release/scripts/startup/bl_ui/properties_scene.py
@@ -402,137 +402,6 @@ class SCENE_PT_simplify(SceneButtonsPanel, Panel):
col.prop(rd, "simplify_ao_sss", text="AO and SSS")
-# XXX temporary solution
-bpy.types.CacheLibrary.filter_string = \
- bpy.props.StringProperty(
- name="Filter Object Name",
- description="Filter cache library objects by name",
- )
-bpy.types.CacheLibrary.filter_types = \
- bpy.props.EnumProperty(
- name="Filter Item Type",
- description="Filter cache library items by type",
- options={'ENUM_FLAG'},
- items=[ (e.identifier, e.name, e.description, e.icon, 2**i) for i, e in enumerate(bpy.types.CacheItem.bl_rna.properties['type'].enum_items) ],
- default=set( e.identifier for e in bpy.types.CacheItem.bl_rna.properties['type'].enum_items ),
- )
-
-def cachelib_objects(cachelib, filter_string = ""):
- filter_string = filter_string.lower()
-
- if not cachelib.group:
- return []
- elif filter_string:
- return filter(lambda ob: filter_string in ob.name.lower(), cachelib.group.objects)
- else:
- return cachelib.group.objects
-
-# Yields (item, type, index, enabled)
-# Note that item can be None when not included in the cache yet
-def cachelib_object_items(cachelib, ob, filter_types = []):
- def items_desc():
- yield 'OBJECT', -1
-
- if (ob.type == 'MESH'):
- yield 'DERIVED_MESH', -1
-
- for index, psys in enumerate(ob.particle_systems):
- if psys.settings.type == 'EMITTER':
- yield 'PARTICLES', index
- if psys.settings.type == 'HAIR':
- yield 'HAIR', index
- yield 'HAIR_PATHS', index
-
- for item_type, item_index in items_desc():
- item = cachelib.cache_item_find(ob, item_type, item_index)
-
- show = False
- enable = False
- # always show existing items
- if item and item.enabled:
- show = True
- enable = True
- # always show selected types
- elif item_type in filter_types:
- show = True
- enable = True
- # special case: OBJECT type used as top level, show but disable
- elif item_type == 'OBJECT':
- show = True
- enable = False
-
- if show:
- yield item, item_type, item_index, enable
-
-class SCENE_PT_cache_manager(SceneButtonsPanel, Panel):
- bl_label = "Cache Manager"
- COMPAT_ENGINES = {'BLENDER_RENDER'}
-
- item_type_icon = { e.identifier : e.icon for e in bpy.types.CacheItem.bl_rna.properties['type'].enum_items }
-
- @classmethod
- def poll(cls, context):
- return True
-
- def draw_cachelib(self, context, layout, cachelib):
- # imitate template_ID without an actual pointer property
- row = layout.row(align=True)
- row.alignment = 'EXPAND'
- row.prop(cachelib, "name", text="")
- sub = row.row(align=True)
- sub.alignment = 'RIGHT'
- sub.prop(cachelib, "use_fake_user", text="F", toggle=True)
- sub.operator("cachelibrary.delete", text="", icon='X')
-
- row = layout.row(align=True)
- row.alignment = 'LEFT'
- row.label("Group:")
- row.template_ID(cachelib, "group")
-
- col = layout.column(align=True)
- colrow = col.row(align=True)
- colrow.label("Archive:")
- props = colrow.operator("cachelibrary.archive_info", text="", icon='QUESTION')
- props.use_stdout = True
- props.use_popup = True
- props.use_clipboard = True
- col.prop(cachelib, "filepath", text="")
-
- col.operator("cachelibrary.bake")
- col.prop(cachelib, "eval_mode", expand=False)
-
- row = layout.row(align=True)
- row.label("Filter:")
- row.prop(cachelib, "filter_types", icon_only=True, toggle=True)
- row.prop(cachelib, "filter_string", icon='VIEWZOOM', text="")
-
- objects = cachelib_objects(cachelib, cachelib.filter_string)
- first = True
- for ob in objects:
- if not any(cachelib_object_items(cachelib, ob, cachelib.filter_types)):
- continue
-
- if first:
- layout.separator()
- first = False
-
- for item, item_type, item_index, enable in cachelib_object_items(cachelib, ob, cachelib.filter_types):
- row = layout.row(align=True)
- row.alignment = 'LEFT'
- row.template_cache_library_item(cachelib, ob, item_type, item_index, enable)
-
-
- def draw(self, context):
- layout = self.layout
-
- layout.operator("cachelibrary.new")
- for cachelib in context.blend_data.cache_libraries:
- box = layout.box()
- box.context_pointer_set("cache_library", cachelib)
-
- self.draw_cachelib(context, box, cachelib)
-
-
class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel, Panel):
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
_context_path = "scene"
diff --git a/source/blender/blenkernel/BKE_cac
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list