diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_modifier.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_object.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_screen.h | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/fluid.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/modifier.c | 20 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 40 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 4 |
7 files changed, 73 insertions, 3 deletions
diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index 2491f0953c0..b0a7d89e3d8 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -407,6 +407,7 @@ struct ModifierData *BKE_modifier_new(int type); void BKE_modifier_free_ex(struct ModifierData *md, const int flag); void BKE_modifier_free(struct ModifierData *md); +void BKE_modifier_remove_from_list(struct Object *ob, struct ModifierData *md); /* Generate new UUID for the given modifier. */ void BKE_modifier_session_uuid_generate(struct ModifierData *md); diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 28c912a4c9a..a620d9af946 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -77,6 +77,10 @@ bool BKE_object_shaderfx_use_time(struct Object *ob, struct ShaderFxData *md); bool BKE_object_support_modifier_type_check(const struct Object *ob, int modifier_type); +/* Active modifier. */ +void BKE_object_modifier_set_active(struct Object *ob, struct ModifierData *md); +struct ModifierData *BKE_object_active_modifier(const struct Object *ob); + bool BKE_object_copy_modifier(struct Object *ob_dst, const struct Object *ob_src, struct ModifierData *md); diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index 68c341692c2..dea9884f508 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -251,6 +251,11 @@ typedef struct PanelType { /* draw entirely, view changes should be handled here */ void (*draw)(const struct bContext *C, struct Panel *panel); + /** + * Identifier of a boolean property of the panel custom data. Used to draw a highlighted border. + */ + const char *active_property; + /* For instanced panels corresponding to a list: */ /** Reorder function, called when drag and drop finishes. */ diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c index 73ca490c395..1bdc2a5dfd2 100644 --- a/source/blender/blenkernel/intern/fluid.c +++ b/source/blender/blenkernel/intern/fluid.c @@ -4559,7 +4559,7 @@ void BKE_fluid_particle_system_destroy(struct Object *ob, const int particle_typ if (psys->part->type == particle_type) { /* clear modifier */ pfmd = psys_get_modifier(ob, psys); - BLI_remlink(&ob->modifiers, (ModifierData *)pfmd); + BKE_modifier_remove_from_list(ob, (ModifierData *)pfmd); BKE_modifier_free((ModifierData *)pfmd); /* clear particle system */ diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 3c8b685a0e0..c9bdaecfa2a 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -212,6 +212,26 @@ void BKE_modifier_free(ModifierData *md) BKE_modifier_free_ex(md, 0); } +/** + * Use instead of `BLI_remlink` when the object's active modifier should change. + */ +void BKE_modifier_remove_from_list(Object *ob, ModifierData *md) +{ + BLI_assert(BLI_findindex(&ob->modifiers, md) != -1); + + if (md->flag & eModifierFlag_Active) { + /* Prefer the previous modifier but use the next if this modifier is the first in the list. */ + if (md->next != NULL) { + BKE_object_modifier_set_active(ob, md->next); + } + else if (md->prev != NULL) { + BKE_object_modifier_set_active(ob, md->prev); + } + } + + BLI_remlink(&ob->modifiers, md); +} + void BKE_modifier_session_uuid_generate(ModifierData *md) { md->session_uuid = BLI_session_uuid_generate(); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 31d2e3738f4..d747da2213e 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1274,6 +1274,46 @@ void BKE_object_modifier_gpencil_hook_reset(Object *ob, HookGpencilModifierData } } +/** + * Set the object's active modifier. + * + * \param md: If NULL, only clear the active modifier, otherwise + * it must be in the #Object.modifiers list. + */ +void BKE_object_modifier_set_active(Object *ob, ModifierData *md) +{ + LISTBASE_FOREACH (ModifierData *, md_iter, &ob->modifiers) { + md_iter->flag &= ~eModifierFlag_Active; + } + + if (md != NULL) { + BLI_assert(BLI_findindex(&ob->modifiers, md) != -1); + md->flag |= eModifierFlag_Active; + } +} + +ModifierData *BKE_object_active_modifier(const Object *ob) +{ + /* In debug mode, check for only one active modifier. */ +#ifndef NDEBUG + int active_count = 0; + LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) { + if (md->flag & eModifierFlag_Active) { + active_count++; + } + } + BLI_assert(ELEM(active_count, 0, 1)); +#endif + + LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) { + if (md->flag & eModifierFlag_Active) { + return md; + } + } + + return NULL; +} + bool BKE_object_support_modifier_type_check(const Object *ob, int modifier_type) { const ModifierTypeInfo *mti; diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 0b331fb88d2..d516de535f9 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -4046,7 +4046,7 @@ void object_remove_particle_system(Main *bmain, Scene *UNUSED(scene), Object *ob /* Clear modifier, skip empty ones. */ psmd = psys_get_modifier(ob, psys); if (psmd) { - BLI_remlink(&ob->modifiers, psmd); + BKE_modifier_remove_from_list(ob, (ModifierData *)psmd); BKE_modifier_free((ModifierData *)psmd); } @@ -5401,7 +5401,7 @@ void BKE_particle_system_blend_read_lib(BlendLibReader *reader, else { /* particle modifier must be removed before particle system */ ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys); - BLI_remlink(&ob->modifiers, psmd); + BKE_modifier_remove_from_list(ob, (ModifierData *)psmd); BKE_modifier_free((ModifierData *)psmd); BLI_remlink(particles, psys); |