diff options
-rw-r--r-- | source/blender/blenkernel/BKE_cachefile.h | 2 | ||||
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 21 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 103 | ||||
-rw-r--r-- | source/blender/editors/io/io_cache.c | 10 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_cachefile_types.h | 8 |
5 files changed, 29 insertions, 115 deletions
diff --git a/source/blender/blenkernel/BKE_cachefile.h b/source/blender/blenkernel/BKE_cachefile.h index 0bd0a0c1d87..70d6985153c 100644 --- a/source/blender/blenkernel/BKE_cachefile.h +++ b/source/blender/blenkernel/BKE_cachefile.h @@ -71,8 +71,6 @@ bool BKE_cache_file_uses_render_procedural(const struct CacheFile *cache_file, struct Scene *scene, int dag_eval_mode); -bool BKE_cache_file_supports_layers(const struct CacheFile *cache_file); - /* Add a layer to the cache_file. Return NULL if the filename is already that of an existing layer * or if the number of layers exceeds the maximum allowed layer count. */ struct CacheFileLayer *BKE_cachefile_add_layer(struct CacheFile *cache_file, diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 7028ab8a5c9..8b972a267bc 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -2399,20 +2399,6 @@ void uiTemplateCacheFile(uiLayout *layout, const struct bContext *C, struct PointerRNA *ptr, const char *propname); -void uiTemplateCacheFileVelocity(uiLayout *layout, struct PointerRNA *fileptr); -bool uiTemplateCacheFilePointer(struct PointerRNA *ptr, - const char *propname, - struct PointerRNA *r_file_ptr); -void uiTemplateCacheFileAttributeRemapping(uiLayout *layout, - const struct bContext *C, - struct PointerRNA *fileptr); -void uiTemplateCacheFileLayers(uiLayout *layout, - const struct bContext *C, - struct PointerRNA *fileptr); -void uiTemplateCacheFileProcedural(uiLayout *layout, - const struct bContext *C, - struct PointerRNA *fileptr); -void uiTemplateCacheFileTimeSettings(uiLayout *layout, struct PointerRNA *fileptr); /** * Lookup the CacheFile PointerRNA of the given pointer and return it in the output parameter. @@ -2447,6 +2433,13 @@ void uiTemplateCacheFileLayers(uiLayout *layout, const struct bContext *C, struct PointerRNA *fileptr); +/** + * Draw the attribute remapping related properties of the CacheFile. + */ +void uiTemplateCacheFileAttributeRemapping(uiLayout *layout, + const struct bContext *C, + struct PointerRNA *fileptr); + /* Default UIList class name, keep in sync with its declaration in bl_ui/__init__.py */ #define UI_UL_DEFAULT_CLASS_NAME "UI_UL_list" enum uiTemplateListFlags { diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index ddb74335597..8895d08bae4 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -6395,49 +6395,6 @@ void uiTemplateNodeSocket(uiLayout *layout, bContext *UNUSED(C), float color[4]) /** \name Cache File Template * \{ */ -static void cache_file_layer_item(uiList *UNUSED(ui_list), - bContext *UNUSED(C), - uiLayout *layout, - PointerRNA *UNUSED(dataptr), - PointerRNA *itemptr, - int UNUSED(icon), - PointerRNA *UNUSED(active_dataptr), - const char *UNUSED(active_propname), - int UNUSED(index), - int UNUSED(flt_flag)) -{ - uiLayout *row = uiLayoutRow(layout, true); - uiItemR(row, itemptr, "hide_layer", UI_ITEM_R_NO_BG, "", ICON_NONE); - uiItemR(row, itemptr, "filepath", UI_ITEM_R_NO_BG, "", ICON_NONE); -} - -uiListType *UI_UL_cache_file_layers() -{ - uiListType *list_type = (uiListType *)MEM_callocN(sizeof(*list_type), __func__); - - BLI_strncpy(list_type->idname, "UI_UL_cache_file_layers", sizeof(list_type->idname)); - list_type->draw_item = cache_file_layer_item; - - return list_type; -} - -static void cache_file_attribute_mapping_item(uiList *UNUSED(ui_list), - bContext *UNUSED(C), - uiLayout *layout, - PointerRNA *UNUSED(dataptr), - PointerRNA *itemptr, - int UNUSED(icon), - PointerRNA *UNUSED(active_dataptr), - const char *UNUSED(active_propname), - int UNUSED(index), - int UNUSED(flt_flag)) -{ - uiLayout *row = uiLayoutRow(layout, true); - uiItemR(row, itemptr, "name", UI_ITEM_R_NO_BG, "", ICON_NONE); - uiItemR(row, itemptr, "mapping", UI_ITEM_R_NO_BG, "", ICON_NONE); - uiItemR(row, itemptr, "domain", UI_ITEM_R_NO_BG, "", ICON_NONE); -} - void uiTemplateCacheFileVelocity(uiLayout *layout, PointerRNA *fileptr) { /* Ensure that the context has a CacheFile as this may not be set inside of modifiers panels. */ @@ -6600,6 +6557,23 @@ bool uiTemplateCacheFilePointer(PointerRNA *ptr, const char *propname, PointerRN return true; } +static void cache_file_attribute_mapping_item(uiList *UNUSED(ui_list), + bContext *UNUSED(C), + uiLayout *layout, + PointerRNA *UNUSED(dataptr), + PointerRNA *itemptr, + int UNUSED(icon), + PointerRNA *UNUSED(active_dataptr), + const char *UNUSED(active_propname), + int UNUSED(index), + int UNUSED(flt_flag)) +{ + uiLayout *row = uiLayoutRow(layout, true); + uiItemR(row, itemptr, "name", UI_ITEM_R_NO_BG, "", ICON_NONE); + uiItemR(row, itemptr, "mapping", UI_ITEM_R_NO_BG, "", ICON_NONE); + uiItemR(row, itemptr, "domain", UI_ITEM_R_NO_BG, "", ICON_NONE); +} + uiListType *UI_UL_cache_file_attribute_mappings() { uiListType *list_type = (uiListType *)MEM_callocN(sizeof(*list_type), __func__); @@ -6640,41 +6614,6 @@ void uiTemplateCacheFileAttributeRemapping(uiLayout *layout, uiItemO(col, "", ICON_REMOVE, "cachefile.attribute_mapping_remove"); } -void uiTemplateCacheFileLayers(uiLayout *layout, const bContext *C, PointerRNA *fileptr) -{ - /* Ensure that the context has a CacheFile as this may not be set inside of modifiers panels. */ - uiLayoutSetContextPointer(layout, "edit_cachefile", fileptr); - - CacheFile *file = fileptr->data; - uiLayout *row = uiLayoutRow(layout, false); - uiLayout *col = uiLayoutColumn(row, true); - - uiTemplateList(col, - (bContext *)C, - "UI_UL_cache_file_layers", - "cache_file_layers", - fileptr, - "layers", - fileptr, - "active_index", - "", - 1, - 5, - UILST_LAYOUT_DEFAULT, - 1, - UI_TEMPLATE_LIST_FLAG_NONE); - - col = uiLayoutColumn(row, true); - uiItemO(col, "", ICON_ADD, "cachefile.layer_add"); - uiItemO(col, "", ICON_REMOVE, "cachefile.layer_remove"); - - if (BLI_listbase_count(&file->layers) > 1) { - uiItemS_ex(col, 1.0f); - uiItemO(col, "", ICON_TRIA_UP, "cachefile.layer_move"); - uiItemO(col, "", ICON_TRIA_DOWN, "cachefile.layer_move"); - } -} - void uiTemplateCacheFile(uiLayout *layout, const bContext *C, PointerRNA *ptr, @@ -6721,15 +6660,7 @@ void uiTemplateCacheFile(uiLayout *layout, if (sbuts->mainb == BCONTEXT_CONSTRAINT) { row = uiLayoutRow(layout, false); - uiTemplateCacheFileLayers(row, C, &fileptr); - - uiTemplateCacheFileProcedural(layout, C, &fileptr); - uiTemplateCacheFileTimeSettings(layout, &fileptr); - - row = uiLayoutRow(layout, false); uiItemR(row, &fileptr, "scale", 0, IFACE_("Manual Scale"), ICON_NONE); - - uiTemplateCacheFileVelocity(layout, &fileptr); } /* TODO: unused for now, so no need to expose. */ diff --git a/source/blender/editors/io/io_cache.c b/source/blender/editors/io/io_cache.c index 97a04fdb055..0bd842d3fbe 100644 --- a/source/blender/editors/io/io_cache.c +++ b/source/blender/editors/io/io_cache.c @@ -57,6 +57,7 @@ static void reload_cachefile(bContext *C, CacheFile *cache_file) static void cachefile_init(bContext *C, wmOperator *op) { PropertyPointerRNA *pprop; + op->customdata = pprop = MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA"); UI_context_active_but_prop_get_templateID(C, &pprop->ptr, &pprop->prop); } @@ -345,19 +346,12 @@ static int cachefile_attribute_mapping_add_exec(bContext *C, wmOperator *UNUSED( const int current_mapping_count = BLI_listbase_count(&cache_file->attribute_mappings); - /* We allow only 254 attributes since we store the active index in a char, and we use a 1 (one) - * based index. */ - if (current_mapping_count >= 254) { - WM_report(RPT_ERROR, "Attribute mapping limit reached for the CacheFile"); - return OPERATOR_CANCELLED; - } - CacheAttributeMapping *mapping = MEM_callocN(sizeof(CacheAttributeMapping), "CacheAttributeMapping"); BLI_addtail(&cache_file->attribute_mappings, mapping); - cache_file->active_attribute_mapping = (char)(current_mapping_count + 1); + cache_file->active_attribute_mapping = current_mapping_count + 1; /* Since the mapping is not initialized, adding a mapping does not trigger a CacheFile update. */ diff --git a/source/blender/makesdna/DNA_cachefile_types.h b/source/blender/makesdna/DNA_cachefile_types.h index b33b6b845ea..e5216bbc21e 100644 --- a/source/blender/makesdna/DNA_cachefile_types.h +++ b/source/blender/makesdna/DNA_cachefile_types.h @@ -138,7 +138,8 @@ typedef struct CacheFile { /** The frame offset to subtract. */ float frame_offset; - char _pad[4]; + /** Index of the currently selected attribute mapping in the UI, starts at 1 */ + int active_attribute_mapping; /** Animation flag. */ short flag; @@ -163,10 +164,7 @@ typedef struct CacheFile { /** Index of the currently selected layer in the UI, starts at 1. */ int active_layer; - /** Index, starting at 1, of the active attribute mapping in the UI. */ - char active_attribute_mapping; - - char _pad2[2]; + char _pad2[3]; char velocity_unit; /* Name of the velocity property in the archive. */ |