[Bf-blender-cvs] [ba878a0] alembic: Main shape key implementation for cached strand data.

Lukas Tönne noreply at git.blender.org
Sun May 3 18:30:02 CEST 2015


Commit: ba878a08803b78aa821ccf9f2089efebd02ae15f
Author: Lukas Tönne
Date:   Sun May 3 18:24:43 2015 +0200
Branches: alembic
https://developer.blender.org/rBba878a08803b78aa821ccf9f2089efebd02ae15f

Main shape key implementation for cached strand data.

This includes storage of the shape keys in a `Key` instance in the
modifier data, and accompanying operators for adding, removing, moving,
etc. shape keys, as well as the necessary UI code.

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

M	release/scripts/startup/bl_ui/properties_object.py
M	source/blender/blenkernel/BKE_cache_library.h
M	source/blender/blenkernel/BKE_key.h
M	source/blender/blenkernel/intern/cache_library.c
M	source/blender/blenkernel/intern/key.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/editors/io/CMakeLists.txt
M	source/blender/editors/io/io_cache_library.h
A	source/blender/editors/io/io_cache_shapekey.c
M	source/blender/editors/io/io_ops.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 64c5c08..c9033d5 100644
--- a/release/scripts/startup/bl_ui/properties_object.py
+++ b/release/scripts/startup/bl_ui/properties_object.py
@@ -18,7 +18,7 @@
 
 # <pep8 compliant>
 import bpy
-from bpy.types import Panel, Menu
+from bpy.types import Panel, Menu, UIList
 from rna_prop_ui import PropertyPanel
 from bl_ui.properties_physics_common import effector_weights_ui
 
@@ -346,6 +346,46 @@ class OBJECT_PT_duplication(ObjectButtonsPanel, Panel):
             layout.prop(ob, "dupli_group", text="Group")
 
 
+
+class CACHELIB_MT_shape_key_specials(Menu):
+    bl_label = "Shape Key Specials"
+    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
+
+    def draw(self, context):
+        layout = self.layout
+
+        #layout.operator("object.shape_key_transfer", icon='COPY_ID')  # icon is not ideal
+        #layout.operator("object.join_shapes", icon='COPY_ID')  # icon is not ideal
+        layout.operator("cachelibrary.shape_key_add", icon='ZOOMIN', text="New Shape From Mix").from_mix = True
+        layout.operator("cachelibrary.shape_key_remove", icon='X', text="Delete All Shapes").all = True
+        layout.operator("cachelibrary.shape_key_move", icon='TRIA_UP_BAR', text="Move To Top").type = 'TOP'
+        layout.operator("cachelibrary.shape_key_move", icon='TRIA_DOWN_BAR', text="Move To Bottom").type = 'BOTTOM'
+
+
+class CACHELIB_UL_shape_keys(UIList):
+    def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
+        # assert(isinstance(item, bpy.types.ShapeKey))
+        md = active_data
+        # key = data
+        key_block = item
+        if self.layout_type in {'DEFAULT', 'COMPACT'}:
+            split = layout.split(0.66, False)
+            split.prop(key_block, "name", text="", emboss=False, icon_value=icon)
+            row = split.row(align=True)
+            if key_block.mute:
+                row.active = False
+            if not item.id_data.use_relative:
+                row.prop(key_block, "frame", text="", emboss=False)
+            elif index > 0:
+                row.prop(key_block, "value", text="", emboss=False)
+            else:
+                row.label(text="")
+            row.prop(key_block, "mute", text="", emboss=False)
+        elif self.layout_type == 'GRID':
+            layout.alignment = 'CENTER'
+            layout.label(text="", icon_value=icon)
+
+
 class OBJECT_PT_cache_library(ObjectButtonsPanel, Panel):
     bl_label = "Cache"
 
@@ -355,6 +395,7 @@ class OBJECT_PT_cache_library(ObjectButtonsPanel, Panel):
         return (ob and ob.dupli_type == 'GROUP' and ob.dupli_group)
 
     def draw_cache_modifier(self, context, layout, cachelib, md):
+        layout.context_pointer_set("cache_library", cachelib)
         layout.context_pointer_set("cache_modifier", md)
 
         row = layout.row(align=True)
@@ -522,6 +563,80 @@ class OBJECT_PT_cache_library(ObjectButtonsPanel, Panel):
         layout = layout.column()
         layout.active = md.hair_system is not None
 
+    def STRANDS_KEY(self, context, layout, cachelib, md):
+        col = layout.column(align=True)
+        col.prop_search(md, "object", context.blend_data, "objects", icon='OBJECT_DATA')
+        sub = col.column()
+        if (md.object):
+            sub.prop_search(md, "hair_system", md.object, "particle_systems")
+        else:
+            sub.enabled = False
+            sub.prop(md, "hair_system")
+
+        key = md.shape_keys
+        kb = md.active_shape_key
+        kb_index = md.active_shape_key_index
+
+        row = layout.row()
+
+        rows = 2
+        if kb:
+            rows = 4
+        row.template_list("CACHELIB_UL_shape_keys", "", key, "key_blocks", md, "active_shape_key_index", rows=rows)
+
+        col = row.column()
+
+        sub = col.column(align=True)
+        #sub.operator("object.shape_key_add", icon='ZOOMIN', text="").from_mix = False
+        #sub.operator("object.shape_key_remove", icon='ZOOMOUT', text="").all = False
+        sub.menu("CACHELIB_MT_shape_key_specials", icon='DOWNARROW_HLT', text="")
+
+        if kb:
+            col.separator()
+
+            sub = col.column(align=True)
+            #sub.operator("object.shape_key_move", icon='TRIA_UP', text="").type = 'UP'
+            #sub.operator("object.shape_key_move", icon='TRIA_DOWN', text="").type = 'DOWN'
+
+            split = layout.split(percentage=0.4)
+            row = split.row()
+            row.prop(key, "use_relative")
+
+            row = split.row()
+            row.alignment = 'RIGHT'
+
+            sub = row.row(align=True)
+            sub.label()  # XXX, for alignment only
+            subsub = sub.row(align=True)
+            subsub.prop(md, "show_only_shape_key", text="")
+
+            sub = row.row()
+            #if key.use_relative:
+            #    sub.operator("object.shape_key_clear", icon='X', text="")
+            #else:
+            #    sub.operator("object.shape_key_retime", icon='RECOVER_LAST', text="")
+
+            if key.use_relative:
+                if kb_index != 0:
+                    row = layout.row()
+                    row.prop(kb, "value")
+
+                    split = layout.split()
+
+                    col = split.column(align=True)
+                    col.label(text="Range:")
+                    col.prop(kb, "slider_min", text="Min")
+                    col.prop(kb, "slider_max", text="Max")
+
+                    col = split.column(align=True)
+                    col.label(text="Blend:")
+                    #col.prop_search(kb, "vertex_group", ob, "vertex_groups", text="")
+                    col.prop_search(kb, "relative_key", key, "key_blocks", text="")
+
+            else:
+                layout.prop(kb, "interpolation")
+                row = layout.column()
+                row.prop(key, "eval_time")
 
 
 # Simple human-readable size (based on http://stackoverflow.com/a/1094933)
diff --git a/source/blender/blenkernel/BKE_cache_library.h b/source/blender/blenkernel/BKE_cache_library.h
index dab8fe9..86dd1dc 100644
--- a/source/blender/blenkernel/BKE_cache_library.h
+++ b/source/blender/blenkernel/BKE_cache_library.h
@@ -50,6 +50,8 @@ struct ID;
 struct CacheProcessData;
 struct BVHTreeFromMesh;
 struct Strands;
+struct StrandsKeyCacheModifier;
+struct KeyBlock;
 
 struct ClothModifierData;
 
@@ -174,6 +176,8 @@ void BKE_cache_modifier_foreachIDLink(struct CacheLibrary *cachelib, struct Cach
 bool BKE_cache_modifier_find_object(struct DupliCache *dupcache, struct Object *ob, struct DupliObjectData **r_data);
 bool BKE_cache_modifier_find_strands(struct DupliCache *dupcache, struct Object *ob, int hair_system, struct DupliObjectData **r_data, struct Strands **r_strands);
 
+struct KeyBlock *BKE_cache_modifier_strands_key_insert_key(struct StrandsKeyCacheModifier *md, struct Strands *strands, const char *name, const bool from_mix);
+
 /* ========================================================================= */
 
 typedef struct CacheEffectorInstance {
diff --git a/source/blender/blenkernel/BKE_key.h b/source/blender/blenkernel/BKE_key.h
index 03b781e..4292884 100644
--- a/source/blender/blenkernel/BKE_key.h
+++ b/source/blender/blenkernel/BKE_key.h
@@ -40,6 +40,7 @@ struct Curve;
 struct Object;
 struct Lattice;
 struct Mesh;
+struct Strands;
 struct WeightsArrayCache;
 
 /* Kernel prototypes */
@@ -70,6 +71,12 @@ float *BKE_key_evaluate_object_ex(
         float *arr, size_t arr_size);
 float *BKE_key_evaluate_object(
         struct Object *ob, int *r_totelem);
+float *BKE_key_evaluate_strands_ex(
+        struct Strands *strands, struct Key *key, struct KeyBlock *actkb, bool lock_shape,
+        int *r_totelem, float *arr, size_t arr_size);
+float *BKE_key_evaluate_strands(
+        struct Strands *strand, struct Key *key, struct KeyBlock *actkbs, bool lock_shape,
+        int *r_totelem);
 
 struct Key      *BKE_key_from_object(struct Object *ob);
 struct KeyBlock *BKE_keyblock_from_object(struct Object *ob);
@@ -107,6 +114,10 @@ void    BKE_keyblock_update_from_mesh(struct Mesh *me, struct KeyBlock *kb);
 void    BKE_keyblock_convert_from_mesh(struct Mesh *me, struct KeyBlock *kb);
 void    BKE_keyblock_convert_to_mesh(struct KeyBlock *kb, struct Mesh *me);
 
+void    BKE_keyblock_update_from_strands(struct Strands *strands, struct KeyBlock *kb);
+void    BKE_keyblock_convert_from_strands(struct Strands *strands, struct Key *key, struct KeyBlock *kb);
+void    BKE_keyblock_convert_to_strands(struct KeyBlock *kb, struct Strands *strands);
+
 void    BKE_keyblock_update_from_vertcos(struct Object *ob, struct KeyBlock *kb, float (*vertCos)[3]);
 void    BKE_keyblock_convert_from_vertcos(struct Object *ob, struct KeyBlock *kb, float (*vertCos)[3]);
 float (*BKE_keyblock_convert_to_vertcos(struct Object *ob, struct KeyBlock *kb))[3];
@@ -115,6 +126,7 @@ void    BKE_keyblock_update_from_offset(struct Object *ob, struct KeyBlock *kb,
 
 /* other management */
 bool    BKE_keyblock_move(struct Object *ob, int org_index, int new_index);
+bool    BKE_keyblock_move_ex(struct Key *key, int *shapenr, int org_index, int new_index);
 
 bool    BKE_keyblock_is_basis(struct Key *key, const int index);
 
diff --git a/source/blender/blenkernel/intern/cache_library.c b/source/blender/blenkernel/intern/cache_library.c
index e5d781ea..cbb68e7 100644
--- a/source/blender/blenkernel/intern/cache_library.c
+++ b/source/blender/blenkernel/intern/cache_library.c
@@ -42,6 +42,7 @@
 
 #include "DNA_cache_library_types.h"
 #include "DNA_group_types.h"
+#include "DNA_key_types.h"
 #include "DNA_modifier_types.h"
 #include "DNA_object_force.h"
 #include "DNA_object_types.h"
@@ -59,6 +60,7 @@
 #include "BKE_effect.h"
 #include "BKE_global.h"
 #include "BKE_group.h"
+#include "BKE_key.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
 #include "BKE_modifier.h"
@@ -1224,14 +1226,18 @@ static void strandskey_init(StrandsKeyCacheModifier *skmd)
 {
 	skmd->object = NULL;
 	skmd->hair_system = -1;
+	
+	skmd->key = BKE_key_add_ex(NULL, IPO_FLOAT, 3, 12);
 }
 
-static void strandskey_copy(StrandsKeyCacheModifier *UNUSED(skmd), StrandsKeyCacheMod

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list