diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2017-02-12 22:43:06 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2017-02-12 22:47:34 +0300 |
commit | adf355849f5c68bf504ba435cc54872b2e2ee87a (patch) | |
tree | f625dea79bf5e5a04cd9f0b0cb1b035e10fa8167 /source/blender | |
parent | b104057d001d2472cc55c7fa51cff3275e331523 (diff) |
Layers: Per-Collection edit mode settings
I didn't manage to get the proper object context in the collection
properties editor. That said I got it working for now in a temporary way
since this will change once we get workspaces anyways
(see changes in buttons_context.c and
rna_scene.c::rna_LayerCollection_mode_settings_get)
I still need to handle the merging of the settings. I will find a
provisory solution while we wait for depsgraph.
(also layer_collection_create_mode_settings_object and layer_collection_create_mode_settings_edit could probably be elsewhere - under draw/engines likely)
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_layer.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/layer.c | 59 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 2 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_buttons/buttons_context.c | 8 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_layer_types.h | 12 | ||||
-rw-r--r-- | source/blender/makesrna/RNA_enum_types.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 237 |
8 files changed, 269 insertions, 56 deletions
diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h index 9bee353bb3a..e60dddf7768 100644 --- a/source/blender/blenkernel/BKE_layer.h +++ b/source/blender/blenkernel/BKE_layer.h @@ -15,7 +15,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributor(s): Dalai Felinto + * Contributor(s): Blender Foundation, Dalai Felinto * * ***** END GPL LICENSE BLOCK ***** */ @@ -103,7 +103,7 @@ void BKE_collection_override_datablock_add(struct LayerCollection *lc, const cha /* engine settings */ typedef void (*CollectionEngineSettingsCB)(struct RenderEngine *engine, struct CollectionEngineSettings *ces); -struct CollectionEngineSettings *BKE_layer_collection_engine_get(struct LayerCollection *lc, const char *engine_name); +struct CollectionEngineSettings *BKE_layer_collection_engine_get(struct LayerCollection *lc, const int type, const char *engine_name); void BKE_layer_collection_engine_settings_callback_register(struct Main *bmain, const char *engine_name, CollectionEngineSettingsCB func); void BKE_layer_collection_engine_settings_callback_free(void); diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c index ef4816af54d..cfbce5e0ffe 100644 --- a/source/blender/blenkernel/intern/layer.c +++ b/source/blender/blenkernel/intern/layer.c @@ -52,6 +52,7 @@ static LayerCollection *find_layer_collection_by_scene_collection(LayerCollectio static CollectionEngineSettings *collection_engine_settings_create(struct CollectionEngineSettingsCB_Type *ces_type); static void layer_collection_engine_settings_free(LayerCollection *lc); static void layer_collection_create_engine_settings(LayerCollection *lc); +static void layer_collection_create_mode_settings(LayerCollection *lc); static void scene_layer_engine_settings_update(SceneLayer *sl, Object *ob, const char *engine_name); static void object_bases_Iterator_next(Iterator *iter, const int flag); @@ -557,6 +558,7 @@ static LayerCollection *layer_collection_add(SceneLayer *sl, ListBase *lb, Scene lc->flag = COLLECTION_VISIBLE + COLLECTION_SELECTABLE + COLLECTION_FOLDED; layer_collection_create_engine_settings(lc); + layer_collection_create_mode_settings(lc); layer_collection_populate(sl, lc, sc); return lc; } @@ -685,7 +687,7 @@ typedef struct CollectionEngineSettingsCB_Type { static void create_engine_settings_layer_collection(LayerCollection *lc, CollectionEngineSettingsCB_Type *ces_type) { - if (BKE_layer_collection_engine_get(lc, ces_type->name)) { + if (BKE_layer_collection_engine_get(lc, COLLECTION_MODE_NONE, ces_type->name)) { return; } @@ -778,6 +780,11 @@ static void layer_collection_engine_settings_free(LayerCollection *lc) for (CollectionEngineSettings *ces = lc->engine_settings.first; ces; ces = ces->next) { BKE_layer_collection_engine_settings_free(ces); } + + for (CollectionEngineSettings *ces = lc->mode_settings.first; ces; ces = ces->next) { + BKE_layer_collection_engine_settings_free(ces); + } + BLI_freelistN(&lc->engine_settings); } @@ -792,14 +799,54 @@ static void layer_collection_create_engine_settings(LayerCollection *lc) } } +static void layer_collection_create_mode_settings_object(LayerCollection *lc) +{ + CollectionEngineSettings *ces; + + ces = MEM_callocN(sizeof(CollectionEngineSettings), "Object Mode Settings"); + BLI_addtail(&lc->mode_settings, ces); + ces->type = COLLECTION_MODE_OBJECT; + + /* properties */ + BKE_collection_engine_property_add_int(ces, "foo", 2); +} + +static void layer_collection_create_mode_settings_edit(LayerCollection *lc) +{ + CollectionEngineSettings *ces; + + ces = MEM_callocN(sizeof(CollectionEngineSettings), "Edit Mode Settings"); + BLI_addtail(&lc->mode_settings, ces); + ces->type = COLLECTION_MODE_EDIT; + + /* properties */ + BKE_collection_engine_property_add_float(ces, "bar", 0.5); +} + +static void layer_collection_create_mode_settings(LayerCollection *lc) +{ + layer_collection_create_mode_settings_object(lc); + layer_collection_create_mode_settings_edit(lc); +} + /** * Return layer collection engine settings for specified engine */ -CollectionEngineSettings *BKE_layer_collection_engine_get(LayerCollection *lc, const char *engine_name) +CollectionEngineSettings *BKE_layer_collection_engine_get(LayerCollection *lc, const int type, const char *engine_name) { - CollectionEngineSettings *ces; - ces = BLI_findstring(&lc->engine_settings, engine_name, offsetof(CollectionEngineSettings, name)); - return ces; + if (type == COLLECTION_MODE_NONE) { + return BLI_findstring(&lc->engine_settings, engine_name, offsetof(CollectionEngineSettings, name)); + } + else { + CollectionEngineSettings *ces; + for (ces = lc->mode_settings.first; ces; ces = ces->next) { + if (ces->type == type) { + return ces; + } + } + } + BLI_assert(false); + return NULL; } /* ---------------------------------------------------------------------- */ @@ -947,7 +994,7 @@ static void layer_collection_engine_settings_update( CollectionEngineSettings ces = {NULL}; collection_engine_settings_copy(&ces, ces_parent); - CollectionEngineSettings *ces_lc = BKE_layer_collection_engine_get(lc, ces.name); + CollectionEngineSettings *ces_lc = BKE_layer_collection_engine_get(lc, ces.type, ces.name); collection_engine_settings_merge(&ces, ces_lc); if (BLI_findptr(&lc->object_bases, base, offsetof(LinkData, data)) != NULL) { diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index da0650d02f5..35ab1d2a4cb 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -5955,6 +5955,8 @@ static void direct_link_layer_collections(FileData *fd, ListBase *lb) direct_link_engine_settings(fd, &lc->engine_settings); + direct_link_engine_settings(fd, &lc->mode_settings); + direct_link_layer_collections(fd, &lc->layer_collections); } } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 16d73557bb0..f781fbcdb18 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2599,6 +2599,8 @@ static void write_layer_collections(WriteData *wd, ListBase *lb) write_collection_engine_settings(wd, &lc->engine_settings); + write_collection_engine_settings(wd, &lc->mode_settings); + write_layer_collections(wd, &lc->layer_collections); } } diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index f53d98a1b59..34213d3d565 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -571,6 +571,14 @@ static int buttons_context_path_collection(const bContext *C, ButsContextPath *p if (sc) { RNA_pointer_create(NULL, &RNA_LayerCollection, sc, &path->ptr[path->len]); path->len++; + + /* temporary object in context path to get edit mode */ + Object *ob = CTX_data_active_object(C); + if (ob) { + RNA_id_pointer_create(&ob->id, &path->ptr[path->len]); + path->len++; + } + return 1; } diff --git a/source/blender/makesdna/DNA_layer_types.h b/source/blender/makesdna/DNA_layer_types.h index bd456b526c7..5d8bff3ef1d 100644 --- a/source/blender/makesdna/DNA_layer_types.h +++ b/source/blender/makesdna/DNA_layer_types.h @@ -60,6 +60,7 @@ typedef struct LayerCollection { ListBase overrides; ListBase layer_collections; /* synced with collection->collections */ ListBase engine_settings; /* CollectionEngineSettings */ + ListBase mode_settings; /* CollectionModeSettings */ } LayerCollection; typedef struct SceneLayer { @@ -136,6 +137,8 @@ typedef struct CollectionEngineSettings { struct CollectionEngineSettings *next, *prev; char name[32]; /* engine name - MAX_NAME */ ListBase properties; /* CollectionProperty */ + int type; /* CollectionEngineSettingsType */ + int pad; } CollectionEngineSettings; /* CollectionEngineProperty->flag */ @@ -143,12 +146,19 @@ enum { COLLECTION_PROP_USE = (1 << 0), }; -/* CollectionEntineProperty.type */ +/* CollectionEngineProperty.type */ typedef enum CollectionEnginePropertyType { COLLECTION_PROP_TYPE_FLOAT = 0, COLLECTION_PROP_TYPE_INT = 1, } CollectionEnginePropertyType; +/* CollectionEngineSettings->type */ +typedef enum CollectionEngineSettingsType { + COLLECTION_MODE_NONE = 0, + COLLECTION_MODE_OBJECT = 1, + COLLECTION_MODE_EDIT = 2, +} CollectionModeSettingsType; + /* *************************************************************** */ diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index 1c9b3593d17..b9bb741bcde 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -61,6 +61,7 @@ extern EnumPropertyItem rna_enum_object_modifier_type_items[]; extern EnumPropertyItem rna_enum_constraint_type_items[]; extern EnumPropertyItem rna_enum_boidrule_type_items[]; extern EnumPropertyItem rna_enum_sequence_modifier_type_items[]; +extern EnumPropertyItem rna_enum_layer_collection_mode_settings_type_items[]; extern EnumPropertyItem rna_enum_modifier_triangulate_quad_method_items[]; extern EnumPropertyItem rna_enum_modifier_triangulate_ngon_method_items[]; diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 2fb1fa9c8d6..d0ee8a02596 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -438,6 +438,12 @@ EnumPropertyItem rna_enum_gpencil_interpolation_mode_items[] = { {0, NULL, 0, NULL, NULL} }; +EnumPropertyItem rna_enum_layer_collection_mode_settings_type_items[] = { + {COLLECTION_MODE_OBJECT, "OBJECT", 0, "Object", ""}, + {COLLECTION_MODE_EDIT, "EDIT", 0, "Edit", ""}, + {0, NULL, 0, NULL, NULL} +}; + #ifdef RNA_RUNTIME #include "DNA_anim_types.h" @@ -2369,55 +2375,90 @@ static StructRNA *rna_CollectionEngineSettings_refine(struct PointerRNA *ptr) return &RNA_CollectionEngineSettings; } +static StructRNA *rna_CollectionModeSettings_refine(struct PointerRNA *ptr) +{ + CollectionEngineSettings *ces = (CollectionEngineSettings *)ptr->data; + + switch(ces->type) { + case COLLECTION_MODE_OBJECT: + return &RNA_CollectionModeSettingsObject; + break; + case COLLECTION_MODE_EDIT: + return &RNA_CollectionModeSettingsEdit; + break; + } + + return &RNA_CollectionModeSettings; +} + /****** clay engine settings *******/ -#define RNA_LAYER_ENGINE_USE_GET_SET(_NAME_) \ - static int rna_LayerEngineSettings_##_NAME_##_use_get(PointerRNA *ptr) \ +#define RNA_LAYER_ENGINE_USE_GET_SET(_ENGINE_, _NAME_) \ + static int rna_LayerEngineSettings_##_ENGINE_##_##_NAME_##_use_get(PointerRNA *ptr) \ { \ CollectionEngineSettings *ces = (CollectionEngineSettings *)ptr->data; \ return BKE_collection_engine_property_use_get(ces, #_NAME_) ? 1 : 0; \ } \ \ - static void rna_LayerEngineSettings_##_NAME_##_use_set(PointerRNA *ptr, int value) \ + static void rna_LayerEngineSettings_##_ENGINE_##_##_NAME_##_use_set(PointerRNA *ptr, int value) \ { \ CollectionEngineSettings *ces = (CollectionEngineSettings *)ptr->data; \ BKE_collection_engine_property_use_set(ces, #_NAME_, value? true : false); \ } -#define RNA_LAYER_ENGINE_GET_SET(_TYPE_, _NAME_) \ -static _TYPE_ rna_LayerEngineSettings_##_NAME_##_get(PointerRNA *ptr) \ +#define RNA_LAYER_ENGINE_GET_SET(_TYPE_, _ENGINE_, _MODE_, _NAME_) \ +static _TYPE_ rna_LayerEngineSettings_##_ENGINE_##_##_NAME_##_get(PointerRNA *ptr) \ { \ CollectionEngineSettings *ces = (CollectionEngineSettings *)ptr->data; \ return BKE_collection_engine_property_value_get_##_TYPE_(ces, #_NAME_); \ } \ \ -static void rna_LayerEngineSettings_##_NAME_##_set(PointerRNA *ptr, _TYPE_ value) \ +static void rna_LayerEngineSettings_##_ENGINE_##_##_NAME_##_set(PointerRNA *ptr, _TYPE_ value) \ { \ CollectionEngineSettings *ces = (CollectionEngineSettings *)ptr->data; \ BKE_collection_engine_property_value_set_##_TYPE_(ces, #_NAME_, value); \ } \ - RNA_LAYER_ENGINE_USE_GET_SET(_NAME_) + RNA_LAYER_ENGINE_USE_GET_SET(_ENGINE_, _NAME_) + +#define RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(_NAME_) \ + RNA_LAYER_ENGINE_GET_SET(float, Clay, COLLECTION_MODE_NONE, _NAME_) + +#define RNA_LAYER_ENGINE_CLAY_GET_SET_INT(_NAME_) \ + RNA_LAYER_ENGINE_GET_SET(int, Clay, COLLECTION_MODE_NONE, _NAME_) + +/* mode engines */ + +#define RNA_LAYER_MODE_OBJECT_GET_SET_FLOAT(_NAME_) \ + RNA_LAYER_ENGINE_GET_SET(float, ObjectMode, COLLECTION_MODE_OBJECT, _NAME_) + +#define RNA_LAYER_MODE_OBJECT_GET_SET_INT(_NAME_) \ + RNA_LAYER_ENGINE_GET_SET(int, ObjectMode, COLLECTION_MODE_OBJECT, _NAME_) + +#define RNA_LAYER_MODE_EDIT_GET_SET_FLOAT(_NAME_) \ + RNA_LAYER_ENGINE_GET_SET(float, EditMode, COLLECTION_MODE_EDIT, _NAME_) -#define RNA_LAYER_ENGINE_GET_SET_FLOAT(_NAME_) \ - RNA_LAYER_ENGINE_GET_SET(float, _NAME_) +#define RNA_LAYER_MODE_EDIT_GET_SET_INT(_NAME_) \ + RNA_LAYER_ENGINE_GET_SET(int, EditMode, COLLECTION_MODE_EDIT, _NAME_) -#define RNA_LAYER_ENGINE_GET_SET_INT(_NAME_) \ - RNA_LAYER_ENGINE_GET_SET(int, _NAME_) +/* clay engine */ +RNA_LAYER_ENGINE_CLAY_GET_SET_INT(type) +RNA_LAYER_ENGINE_CLAY_GET_SET_INT(matcap_icon) +RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(matcap_rotation) +RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(matcap_hue) +RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(matcap_saturation) +RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(matcap_value) +RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(ssao_factor_cavity) +RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(ssao_factor_edge) +RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(ssao_distance) +RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(ssao_attenuation) +/* object engine */ -RNA_LAYER_ENGINE_GET_SET_INT(type) -RNA_LAYER_ENGINE_GET_SET_INT(matcap_icon) -RNA_LAYER_ENGINE_GET_SET_FLOAT(matcap_rotation) -RNA_LAYER_ENGINE_GET_SET_FLOAT(matcap_hue) -RNA_LAYER_ENGINE_GET_SET_FLOAT(matcap_saturation) -RNA_LAYER_ENGINE_GET_SET_FLOAT(matcap_value) -RNA_LAYER_ENGINE_GET_SET_FLOAT(ssao_factor_cavity) -RNA_LAYER_ENGINE_GET_SET_FLOAT(ssao_factor_edge) -RNA_LAYER_ENGINE_GET_SET_FLOAT(ssao_distance) -RNA_LAYER_ENGINE_GET_SET_FLOAT(ssao_attenuation) +RNA_LAYER_MODE_OBJECT_GET_SET_INT(foo) + +/* mesh engine */ +RNA_LAYER_MODE_EDIT_GET_SET_FLOAT(bar) -#undef RNA_LAYER_ENGINE_GET_SET_INT -#undef RNA_LAYER_ENGINE_GET_SET_FLOAT #undef RNA_LAYER_ENGINE_GET_SET #undef RNA_LAYER_ENGINE_USE_GET_SET @@ -2473,11 +2514,35 @@ static PointerRNA rna_LayerCollection_engine_settings_get(ID *UNUSED(id), LayerC } PointerRNA ptr; - CollectionEngineSettings *ces = BKE_layer_collection_engine_get(lc, engine_name); + CollectionEngineSettings *ces = BKE_layer_collection_engine_get(lc, COLLECTION_MODE_NONE, engine_name); RNA_pointer_create(NULL, &RNA_CollectionEngineSettings, ces, &ptr); return rna_pointer_inherit_refine(&ptr, &RNA_CollectionEngineSettings, ces); } +static PointerRNA rna_LayerCollection_mode_settings_get(ID *UNUSED(id), LayerCollection *lc, bContext *C, int type) +{ + if (type == COLLECTION_MODE_NONE) { + /* temporarily get mode from active object */ + Object *ob = CTX_data_active_object(C); + + if (ob) { + switch (ob->mode) { + case OB_MODE_OBJECT: + type = COLLECTION_MODE_OBJECT; + break; + case OB_MODE_EDIT: + type = COLLECTION_MODE_EDIT; + break; + } + } + } + + PointerRNA ptr; + CollectionEngineSettings *ces = BKE_layer_collection_engine_get(lc, type, ""); + RNA_pointer_create(NULL, &RNA_CollectionEngineSettings, ces, &ptr); + return rna_pointer_inherit_refine(&ptr, &RNA_CollectionModeSettings, ces); +} + static void rna_LayerCollection_hide_update(bContext *C, PointerRNA *ptr) { Scene *scene = CTX_data_scene(C); @@ -5741,14 +5806,23 @@ static void rna_def_layer_collection_override(BlenderRNA *brna) RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, NULL); } -#define RNA_LAYER_ENGINE_USE(_NAME_) \ +#define RNA_LAYER_ENGINE_USE(_ENGINE_, _NAME_) \ prop = RNA_def_property(srna, #_NAME_"_use", PROP_BOOLEAN, PROP_NONE); \ RNA_def_property_boolean_funcs(prop, \ - "rna_LayerEngineSettings_"#_NAME_"_use_get", \ - "rna_LayerEngineSettings_"#_NAME_"_use_set"); \ + "rna_LayerEngineSettings_"#_ENGINE_"_"#_NAME_"_use_get", \ + "rna_LayerEngineSettings_"#_ENGINE_"_"#_NAME_"_use_set"); \ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); \ RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_CollectionEngineSettings_update"); +#define RNA_LAYER_ENGINE_CLAY_USE(_NAME_) \ + RNA_LAYER_ENGINE_USE(Clay, _NAME_) + +#define RNA_LAYER_MODE_OBJECT_USE(_NAME_) \ + RNA_LAYER_ENGINE_USE(ObjectMode, _NAME_) + +#define RNA_LAYER_MODE_EDIT_USE(_NAME_) \ + RNA_LAYER_ENGINE_USE(EditMode, _NAME_) + static void rna_def_layer_collection_engine_settings_clay(BlenderRNA *brna) { StructRNA *srna; @@ -5801,86 +5875,86 @@ static void rna_def_layer_collection_engine_settings_clay(BlenderRNA *brna) /* see RNA_LAYER_ENGINE_GET_SET macro */ prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_funcs(prop, "rna_LayerEngineSettings_type_get", "rna_LayerEngineSettings_type_set", NULL); + RNA_def_property_enum_funcs(prop, "rna_LayerEngineSettings_Clay_type_get", "rna_LayerEngineSettings_Clay_type_set", NULL); RNA_def_property_enum_items(prop, clay_matcap_type); RNA_def_property_ui_text(prop, "Settings Type", "What settings to use for this material"); RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_CollectionEngineSettings_update"); - RNA_LAYER_ENGINE_USE(type) + RNA_LAYER_ENGINE_CLAY_USE(type) prop = RNA_def_property(srna, "matcap_icon", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_funcs(prop, "rna_LayerEngineSettings_matcap_icon_get", "rna_LayerEngineSettings_matcap_icon_set", NULL); + RNA_def_property_enum_funcs(prop, "rna_LayerEngineSettings_Clay_matcap_icon_get", "rna_LayerEngineSettings_Clay_matcap_icon_set", NULL); RNA_def_property_enum_items(prop, clay_matcap_items); RNA_def_property_ui_text(prop, "Matcap", "Image to use for Material Capture by this material"); RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_CollectionEngineSettings_update"); - RNA_LAYER_ENGINE_USE(matcap_icon) + RNA_LAYER_ENGINE_CLAY_USE(matcap_icon) prop = RNA_def_property(srna, "matcap_rotation", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_matcap_rotation_get", "rna_LayerEngineSettings_matcap_rotation_set", NULL); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_matcap_rotation_get", "rna_LayerEngineSettings_Clay_matcap_rotation_set", NULL); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Matcap Rotation", "Orientation of the matcap on the model"); RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_CollectionEngineSettings_update"); - RNA_LAYER_ENGINE_USE(matcap_rotation) + RNA_LAYER_ENGINE_CLAY_USE(matcap_rotation) prop = RNA_def_property(srna, "matcap_hue", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_matcap_hue_get", "rna_LayerEngineSettings_matcap_hue_set", NULL); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_matcap_hue_get", "rna_LayerEngineSettings_Clay_matcap_hue_set", NULL); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Matcap Hue shift", "Hue correction of the matcap"); RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_CollectionEngineSettings_update"); - RNA_LAYER_ENGINE_USE(matcap_hue) + RNA_LAYER_ENGINE_CLAY_USE(matcap_hue) prop = RNA_def_property(srna, "matcap_saturation", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_matcap_saturation_get", "rna_LayerEngineSettings_matcap_saturation_set", NULL); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_matcap_saturation_get", "rna_LayerEngineSettings_Clay_matcap_saturation_set", NULL); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Matcap Saturation", "Saturation correction of the matcap"); RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_CollectionEngineSettings_update"); - RNA_LAYER_ENGINE_USE(matcap_saturation) + RNA_LAYER_ENGINE_CLAY_USE(matcap_saturation) prop = RNA_def_property(srna, "matcap_value", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_matcap_value_get", "rna_LayerEngineSettings_matcap_value_set", NULL); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_matcap_value_get", "rna_LayerEngineSettings_Clay_matcap_value_set", NULL); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Matcap Value", "Value correction of the matcap"); RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_CollectionEngineSettings_update"); - RNA_LAYER_ENGINE_USE(matcap_value) + RNA_LAYER_ENGINE_CLAY_USE(matcap_value) prop = RNA_def_property(srna, "ssao_factor_cavity", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_ssao_factor_cavity_get", "rna_LayerEngineSettings_ssao_factor_cavity_set", NULL); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_ssao_factor_cavity_get", "rna_LayerEngineSettings_Clay_ssao_factor_cavity_set", NULL); RNA_def_property_ui_text(prop, "Cavity Strength", "Strength of the Cavity effect"); RNA_def_property_range(prop, 0.0f, 250.0f); RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_CollectionEngineSettings_update"); - RNA_LAYER_ENGINE_USE(ssao_factor_cavity) + RNA_LAYER_ENGINE_CLAY_USE(ssao_factor_cavity) prop = RNA_def_property(srna, "ssao_factor_edge", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_ssao_factor_edge_get", "rna_LayerEngineSettings_ssao_factor_edge_set", NULL); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_ssao_factor_edge_get", "rna_LayerEngineSettings_Clay_ssao_factor_edge_set", NULL); RNA_def_property_ui_text(prop, "Edge Strength", "Strength of the Edge effect"); RNA_def_property_range(prop, 0.0f, 250.0f); RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_CollectionEngineSettings_update"); - RNA_LAYER_ENGINE_USE(ssao_factor_edge) + RNA_LAYER_ENGINE_CLAY_USE(ssao_factor_edge) prop = RNA_def_property(srna, "ssao_distance", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_ssao_distance_get", "rna_LayerEngineSettings_ssao_distance_set", NULL); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_ssao_distance_get", "rna_LayerEngineSettings_Clay_ssao_distance_set", NULL); RNA_def_property_ui_text(prop, "Distance", "Distance of object that contribute to the Cavity/Edge effect"); RNA_def_property_range(prop, 0.0f, 100000.0f); RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 3); RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_CollectionEngineSettings_update"); - RNA_LAYER_ENGINE_USE(ssao_distance) + RNA_LAYER_ENGINE_CLAY_USE(ssao_distance) prop = RNA_def_property(srna, "ssao_attenuation", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_ssao_attenuation_get", "rna_LayerEngineSettings_ssao_attenuation_set", NULL); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Clay_ssao_attenuation_get", "rna_LayerEngineSettings_Clay_ssao_attenuation_set", NULL); RNA_def_property_ui_text(prop, "Attenuation", "Attenuation constant"); RNA_def_property_range(prop, 1.0f, 100000.0f); RNA_def_property_ui_range(prop, 1.0f, 100.0f, 1, 3); RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_CollectionEngineSettings_update"); - RNA_LAYER_ENGINE_USE(ssao_attenuation) + RNA_LAYER_ENGINE_CLAY_USE(ssao_attenuation) } static void rna_def_layer_collection_engine_settings(BlenderRNA *brna) @@ -5901,6 +5975,65 @@ static void rna_def_layer_collection_engine_settings(BlenderRNA *brna) rna_def_layer_collection_engine_settings_clay(brna); } +static void rna_def_layer_collection_mode_settings_object(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "CollectionModeSettingsObject", NULL); + RNA_def_struct_sdna(srna, "CollectionEngineSettings"); + RNA_def_struct_ui_text(srna, "Collections Object Mode Settings", "Object Mode specific settings for this collection"); + + prop = RNA_def_property(srna, "foo", PROP_INT, PROP_NONE); + RNA_def_property_ui_text(prop, "Foo", ""); + RNA_def_property_int_funcs(prop, "rna_LayerEngineSettings_ObjectMode_foo_get", "rna_LayerEngineSettings_ObjectMode_foo_set", NULL); + RNA_def_property_ui_text(prop, "Foo Object Setting", "Temporary settings"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_CollectionEngineSettings_update"); + RNA_LAYER_MODE_OBJECT_USE(foo) +} + +static void rna_def_layer_collection_mode_settings_edit(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "CollectionModeSettingsEdit", NULL); + RNA_def_struct_sdna(srna, "CollectionEngineSettings"); + RNA_def_struct_ui_text(srna, "Collections Edit Mode Settings", "Edit Mode specific settings for this collection"); + + prop = RNA_def_property(srna, "bar", PROP_FLOAT, PROP_NONE); + RNA_def_property_ui_text(prop, "Bar Object Setting", "Temporary settings"); + RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_EditMode_bar_get", "rna_LayerEngineSettings_EditMode_bar_set", NULL); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_CollectionEngineSettings_update"); + RNA_LAYER_MODE_EDIT_USE(bar) +} + +static void rna_def_layer_collection_mode_settings(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "CollectionModeSettings", NULL); + RNA_def_struct_sdna(srna, "CollectionEngineSettings"); + RNA_def_struct_ui_text(srna, "Collections Mode Settings", "Mode specific settings for this collection"); + RNA_def_struct_refine_func(srna, "rna_CollectionModeSettings_refine"); + + prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "type"); + RNA_def_property_enum_items(prop, rna_enum_layer_collection_mode_settings_type_items); + RNA_def_property_ui_text(prop, "Type", ""); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + + /* the modes specific structs */ + rna_def_layer_collection_mode_settings_object(brna); + rna_def_layer_collection_mode_settings_edit(brna); +} + +#undef RNA_LAYER_MODE_EDIT_USE +#undef RNA_LAYER_MODE_OBJECT_USE +#undef RNA_LAYER_ENGINE_CLAY_USE #undef RNA_LAYER_ENGINE_USE static void rna_def_layer_collection(BlenderRNA *brna) @@ -5951,6 +6084,15 @@ static void rna_def_layer_collection(BlenderRNA *brna) RNA_def_parameter_flags(parm, 0, PARM_RNAPTR); RNA_def_function_return(func, parm); + func = RNA_def_function(srna, "get_mode_settings", "rna_LayerCollection_mode_settings_get"); + RNA_def_function_ui_description(func, "Return the mode settings for this collection"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_CONTEXT); + parm = RNA_def_enum(func, "type", rna_enum_layer_collection_mode_settings_type_items, COLLECTION_MODE_NONE, "Mode", "use context one by default"); + RNA_def_parameter_clear_flags(parm, 0, PARM_REQUIRED); + parm = RNA_def_pointer(func, "result", "CollectionEngineSettings", "", ""); + RNA_def_parameter_flags(parm, 0, PARM_RNAPTR); + RNA_def_function_return(func, parm); + /* Flags */ prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", COLLECTION_VISIBLE); @@ -8655,6 +8797,7 @@ void RNA_def_scene(BlenderRNA *brna) rna_def_layer_collection(brna); rna_def_layer_collection_override(brna); rna_def_layer_collection_engine_settings(brna); + rna_def_layer_collection_mode_settings(brna); rna_def_scene_layer(brna); rna_def_object_base(brna); RNA_define_animate_sdna(true); |