Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/modifier.c
| Show All 28 Lines | |||||
| #include <stdarg.h> | #include <stdarg.h> | ||||
| #include <stddef.h> | #include <stddef.h> | ||||
| #include <stdlib.h> | #include <stdlib.h> | ||||
| #include <string.h> | #include <string.h> | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "DNA_armature_types.h" | #include "DNA_armature_types.h" | ||||
| #include "DNA_gpencil_modifier_types.h" | |||||
| #include "DNA_mesh_types.h" | #include "DNA_mesh_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "BLI_linklist.h" | #include "BLI_linklist.h" | ||||
| #include "BLI_listbase.h" | #include "BLI_listbase.h" | ||||
| #include "BLI_path_util.h" | #include "BLI_path_util.h" | ||||
| #include "BLI_string.h" | #include "BLI_string.h" | ||||
| ▲ Show 20 Lines • Show All 587 Lines • ▼ Show 20 Lines | |||||
| /* This is to include things that are not modifiers in the evaluation of the modifier stack, for | /* This is to include things that are not modifiers in the evaluation of the modifier stack, for | ||||
| * example parenting to an armature. */ | * example parenting to an armature. */ | ||||
| ModifierData *BKE_modifiers_get_virtual_modifierlist(const Object *ob, | ModifierData *BKE_modifiers_get_virtual_modifierlist(const Object *ob, | ||||
| VirtualModifierData *virtualModifierData) | VirtualModifierData *virtualModifierData) | ||||
| { | { | ||||
| ModifierData *md; | ModifierData *md; | ||||
| if (ob->type == OB_GPENCIL) { | |||||
| md = ob->greasepencil_modifiers.first; | |||||
campbellbarton: The grease-pencil modifiers use `GpencilModifierData`, we can't rely on them being compatible… | |||||
| } | |||||
| else { | |||||
| md = ob->modifiers.first; | md = ob->modifiers.first; | ||||
| } | |||||
| *virtualModifierData = virtualModifierCommonData; | *virtualModifierData = virtualModifierCommonData; | ||||
| if (ob->parent) { | if (ob->parent) { | ||||
| if (ob->parent->type == OB_ARMATURE && ob->partype == PARSKEL) { | if (ob->parent->type == OB_ARMATURE && ob->partype == PARSKEL) { | ||||
| virtualModifierData->amd.object = ob->parent; | virtualModifierData->amd.object = ob->parent; | ||||
| virtualModifierData->amd.modifier.next = md; | virtualModifierData->amd.modifier.next = md; | ||||
| virtualModifierData->amd.deformflag = ((bArmature *)(ob->parent->data))->deformflag; | virtualModifierData->amd.deformflag = ((bArmature *)(ob->parent->data))->deformflag; | ||||
| Show All 29 Lines | |||||
| } | } | ||||
| /* Takes an object and returns its first selected armature, else just its armature | /* Takes an object and returns its first selected armature, else just its armature | ||||
| * This should work for multiple armatures per object | * This should work for multiple armatures per object | ||||
| */ | */ | ||||
| Object *BKE_modifiers_is_deformed_by_armature(Object *ob) | Object *BKE_modifiers_is_deformed_by_armature(Object *ob) | ||||
| { | { | ||||
| VirtualModifierData virtualModifierData; | VirtualModifierData virtualModifierData; | ||||
| /* Gpencil has GpencilModifierData, but seems compatible. */ | |||||
| ModifierData *md = BKE_modifiers_get_virtual_modifierlist(ob, &virtualModifierData); | ModifierData *md = BKE_modifiers_get_virtual_modifierlist(ob, &virtualModifierData); | ||||
| ArmatureModifierData *amd = NULL; | ArmatureModifierData *amd = NULL; | ||||
| ArmatureGpencilModifierData *agmd = NULL; | |||||
| /* return the first selected armature, this lets us use multiple armatures */ | /* return the first selected armature, this lets us use multiple armatures */ | ||||
| for (; md; md = md->next) { | for (; md; md = md->next) { | ||||
| if (md->type == eModifierType_Armature) { | if (md->type == eGpencilModifierType_Armature) { | ||||
| agmd = (ArmatureGpencilModifierData *)md; | |||||
| if (agmd->object && (agmd->object->base_flag & BASE_SELECTED)) { | |||||
| return agmd->object; | |||||
| } | |||||
| } | |||||
| else if (md->type == eModifierType_Armature) { | |||||
| amd = (ArmatureModifierData *)md; | amd = (ArmatureModifierData *)md; | ||||
| if (amd->object && (amd->object->base_flag & BASE_SELECTED)) { | if (amd->object && (amd->object->base_flag & BASE_SELECTED)) { | ||||
| return amd->object; | return amd->object; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (amd) { /* if we're still here then return the last armature */ | /* If we're still here then return the last armature. */ | ||||
| if (amd) { | |||||
| return amd->object; | return amd->object; | ||||
| } | } | ||||
| else if (agmd) { | |||||
campbellbartonUnsubmitted Done Inline Actionsclang-tidy will kick out the else here :) campbellbarton: clang-tidy will kick out the `else` here :) | |||||
| return agmd->object; | |||||
| } | |||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| Object *BKE_modifiers_is_deformed_by_meshdeform(Object *ob) | Object *BKE_modifiers_is_deformed_by_meshdeform(Object *ob) | ||||
| { | { | ||||
| VirtualModifierData virtualModifierData; | VirtualModifierData virtualModifierData; | ||||
| ModifierData *md = BKE_modifiers_get_virtual_modifierlist(ob, &virtualModifierData); | ModifierData *md = BKE_modifiers_get_virtual_modifierlist(ob, &virtualModifierData); | ||||
| ▲ Show 20 Lines • Show All 367 Lines • Show Last 20 Lines | |||||
The grease-pencil modifiers use GpencilModifierData, we can't rely on them being compatible with ModifierData, there should be a separate function for grease-pencil.