Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/gpencil_modifier.c
| Show All 12 Lines | |||||
| #include "BLI_math_geom.h" | #include "BLI_math_geom.h" | ||||
| #include "BLI_math_vector.h" | #include "BLI_math_vector.h" | ||||
| #include "BLI_string_utils.h" | #include "BLI_string_utils.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLT_translation.h" | #include "BLT_translation.h" | ||||
| #include "DNA_armature_types.h" | #include "DNA_armature_types.h" | ||||
| #include "DNA_collection_types.h" | |||||
| #include "DNA_gpencil_modifier_types.h" | #include "DNA_gpencil_modifier_types.h" | ||||
| #include "DNA_gpencil_types.h" | #include "DNA_gpencil_types.h" | ||||
| #include "DNA_mesh_types.h" | #include "DNA_mesh_types.h" | ||||
| #include "DNA_meshdata_types.h" | #include "DNA_meshdata_types.h" | ||||
| #include "DNA_modifier_types.h" | #include "DNA_modifier_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_screen_types.h" | #include "DNA_screen_types.h" | ||||
| #include "BKE_collection.h" | |||||
| #include "BKE_colortools.h" | #include "BKE_colortools.h" | ||||
| #include "BKE_deform.h" | #include "BKE_deform.h" | ||||
| #include "BKE_duplilist.h" | |||||
| #include "BKE_gpencil.h" | #include "BKE_gpencil.h" | ||||
| #include "BKE_gpencil_geom.h" | #include "BKE_gpencil_geom.h" | ||||
| #include "BKE_gpencil_modifier.h" | #include "BKE_gpencil_modifier.h" | ||||
| #include "BKE_lattice.h" | #include "BKE_lattice.h" | ||||
| #include "BKE_lib_id.h" | #include "BKE_lib_id.h" | ||||
| #include "BKE_lib_query.h" | #include "BKE_lib_query.h" | ||||
| #include "BKE_material.h" | #include "BKE_material.h" | ||||
| #include "BKE_modifier.h" | #include "BKE_modifier.h" | ||||
| ▲ Show 20 Lines • Show All 218 Lines • ▼ Show 20 Lines | if (gmd->type == eGpencilModifierType_Lineart) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| /* If we reach here it means md is not in ob's modifier stack. */ | /* If we reach here it means md is not in ob's modifier stack. */ | ||||
| BLI_assert(false); | BLI_assert(false); | ||||
| return false; | return false; | ||||
| } | } | ||||
| static int lineart_usage_check_dg(Collection *c, Object *ob, bool is_render) | |||||
| { | |||||
| if (!c) { | |||||
| return OBJECT_LRT_INHERIT; | |||||
| } | |||||
| int object_has_special_usage = (ob->lineart.usage != OBJECT_LRT_INHERIT); | |||||
| if (object_has_special_usage) { | |||||
| return ob->lineart.usage; | |||||
| } | |||||
| if (c->gobject.first) { | |||||
| if (BKE_collection_has_object(c, (Object *)(ob->id.orig_id))) { | |||||
| if ((is_render && (c->flag & COLLECTION_HIDE_RENDER)) || | |||||
| ((!is_render) && (c->flag & COLLECTION_HIDE_VIEWPORT))) { | |||||
| return OBJECT_LRT_EXCLUDE; | |||||
| } | |||||
| if (ob->lineart.usage == OBJECT_LRT_INHERIT) { | |||||
| switch (c->lineart_usage) { | |||||
| case COLLECTION_LRT_OCCLUSION_ONLY: | |||||
| return OBJECT_LRT_OCCLUSION_ONLY; | |||||
| case COLLECTION_LRT_EXCLUDE: | |||||
| return OBJECT_LRT_EXCLUDE; | |||||
| case COLLECTION_LRT_INTERSECTION_ONLY: | |||||
| return OBJECT_LRT_INTERSECTION_ONLY; | |||||
| case COLLECTION_LRT_NO_INTERSECTION: | |||||
| return OBJECT_LRT_NO_INTERSECTION; | |||||
| } | |||||
| return OBJECT_LRT_INHERIT; | |||||
| } | |||||
| return ob->lineart.usage; | |||||
| } | |||||
| } | |||||
| LISTBASE_FOREACH (CollectionChild *, cc, &c->children) { | |||||
| int result = lineart_usage_check_dg(cc->collection, ob, is_render); | |||||
| if (result > OBJECT_LRT_INHERIT) { | |||||
| return result; | |||||
| } | |||||
| } | |||||
| return OBJECT_LRT_INHERIT; | |||||
| } | |||||
| static void add_lineart_object(Depsgraph *depsgraph, | |||||
| ListBase *relations, | |||||
| Collection *collection, | |||||
| Object *ob, | |||||
| bool is_render, | |||||
| bool allow_duplicates) | |||||
| { | |||||
| if (lineart_usage_check_dg(collection, ob, is_render) != OBJECT_LRT_EXCLUDE) { | |||||
| LineartRelation *relation = MEM_callocN(sizeof(LineartRelation), "LineartRelation"); | |||||
| relation->ob = ob; | |||||
| BLI_addtail(relations, relation); | |||||
| } | |||||
| /* dupliobjects */ | |||||
| if (allow_duplicates) { | |||||
| ListBase *dupli = object_duplilist(depsgraph, DEG_get_input_scene(depsgraph), ob); | |||||
| LISTBASE_FOREACH (DupliObject *, dob, dupli) { | |||||
| if (BKE_object_visibility(ob, is_render ? DAG_EVAL_RENDER : DAG_EVAL_VIEWPORT) & | |||||
| (OB_VISIBLE_PARTICLES | OB_VISIBLE_INSTANCES)) { | |||||
| add_lineart_object(depsgraph, relations, collection, dob->ob, is_render, false); | |||||
| } | |||||
| } | |||||
| free_object_duplilist(dupli); | |||||
| } | |||||
| } | |||||
| ListBase *BKE_lineart_relations_create(Depsgraph *depsgraph, | |||||
| Collection *collection, | |||||
| bool allow_duplicates) | |||||
| { | |||||
| ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph); | |||||
| Base *base = BKE_collection_or_layer_objects(view_layer, collection); | |||||
| const bool for_render = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER); | |||||
| const int base_flag = (for_render) ? BASE_ENABLED_RENDER : BASE_ENABLED_VIEWPORT; | |||||
| ListBase *relations = MEM_callocN(sizeof(ListBase), "CollisionRelation list"); | |||||
| for (; base; base = base->next) { | |||||
| if (base->flag & base_flag) { | |||||
| add_lineart_object( | |||||
| depsgraph, relations, collection, base->object, for_render, allow_duplicates); | |||||
| } | |||||
| } | |||||
| return relations; | |||||
| } | |||||
| void BKE_lineart_relations_free(ListBase *relations) | |||||
| { | |||||
| if (relations) { | |||||
| BLI_freelistN(relations); | |||||
| MEM_freeN(relations); | |||||
| } | |||||
| } | |||||
| int BKE_gpencil_time_modifier_cfra(Depsgraph *depsgraph, | int BKE_gpencil_time_modifier_cfra(Depsgraph *depsgraph, | ||||
| Scene *scene, | Scene *scene, | ||||
| Object *ob, | Object *ob, | ||||
| bGPDlayer *gpl, | bGPDlayer *gpl, | ||||
| const int cfra, | const int cfra, | ||||
| const bool is_render) | const bool is_render) | ||||
| { | { | ||||
| bGPdata *gpd = ob->data; | bGPdata *gpd = ob->data; | ||||
| ▲ Show 20 Lines • Show All 192 Lines • Show Last 20 Lines | |||||