Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
| Show All 29 Lines | |||||
| #include "BKE_lib_id.h" | #include "BKE_lib_id.h" | ||||
| #include "BKE_material.h" | #include "BKE_material.h" | ||||
| #include "BKE_mesh.h" | #include "BKE_mesh.h" | ||||
| #include "BKE_mesh_mapping.h" | #include "BKE_mesh_mapping.h" | ||||
| #include "BKE_mesh_runtime.h" | #include "BKE_mesh_runtime.h" | ||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| #include "BKE_pointcache.h" | #include "BKE_pointcache.h" | ||||
| #include "BKE_scene.h" | #include "BKE_scene.h" | ||||
| #include "DEG_depsgraph_lineart.h" | |||||
| #include "DEG_depsgraph_query.h" | #include "DEG_depsgraph_query.h" | ||||
| #include "DNA_camera_types.h" | #include "DNA_camera_types.h" | ||||
| #include "DNA_collection_types.h" | #include "DNA_collection_types.h" | ||||
| #include "DNA_gpencil_types.h" | #include "DNA_gpencil_types.h" | ||||
| #include "DNA_material_types.h" | #include "DNA_material_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" | ||||
| ▲ Show 20 Lines • Show All 384 Lines • ▼ Show 20 Lines | |||||
| unit_m4_db(view); | unit_m4_db(view); | ||||
| copy_m4_m4_db(rb->view, view); | copy_m4_m4_db(rb->view, view); | ||||
| BLI_listbase_clear(&rb->triangle_buffer_pointers); | BLI_listbase_clear(&rb->triangle_buffer_pointers); | ||||
| BLI_listbase_clear(&rb->vertex_buffer_pointers); | BLI_listbase_clear(&rb->vertex_buffer_pointers); | ||||
| int thread_count = rb->thread_count; | int thread_count = rb->thread_count; | ||||
| ListBase *relations = DEG_get_lineart_relations(depsgraph); | |||||
| if (!relations) { | |||||
| return; | |||||
| } | |||||
| /* This memory is in render buffer memory pool. so we don't need to free those after loading. | /* This memory is in render buffer memory pool. so we don't need to free those after loading. | ||||
| */ | */ | ||||
| LineartObjectLoadTaskInfo *olti = lineart_mem_acquire( | LineartObjectLoadTaskInfo *olti = lineart_mem_acquire( | ||||
| &rb->render_data_pool, sizeof(LineartObjectLoadTaskInfo) * thread_count); | &rb->render_data_pool, sizeof(LineartObjectLoadTaskInfo) * thread_count); | ||||
| eEvaluationMode eval_mode = DEG_get_mode(depsgraph); | eEvaluationMode eval_mode = DEG_get_mode(depsgraph); | ||||
| bool is_render = eval_mode == DAG_EVAL_RENDER; | bool is_render = eval_mode == DAG_EVAL_RENDER; | ||||
| FOREACH_SCENE_OBJECT_BEGIN (scene, ob) { | LISTBASE_FOREACH (LineartRelation *, relation, relations) { | ||||
| /* Get evaluated object. */ | |||||
| Object *ob = (Object *)DEG_get_evaluated_id(depsgraph, &relation->ob->id); | |||||
| Object *eval_ob = DEG_get_evaluated_object(depsgraph, ob); | Object *eval_ob = DEG_get_evaluated_object(depsgraph, ob); | ||||
| if (!eval_ob) { | if (!eval_ob) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (BKE_object_visibility(eval_ob, eval_mode) & OB_VISIBLE_SELF) { | if (BKE_object_visibility(eval_ob, eval_mode) & OB_VISIBLE_SELF) { | ||||
| lineart_object_load_single_instance( | lineart_object_load_single_instance( | ||||
| rb, depsgraph, scene, eval_ob, eval_ob, eval_ob->obmat, is_render, olti, thread_count); | rb, depsgraph, scene, eval_ob, eval_ob, eval_ob->obmat, is_render, olti, thread_count); | ||||
| } | } | ||||
| if (allow_duplicates) { | |||||
| ListBase *dupli = object_duplilist(depsgraph, scene, eval_ob); | /* For OB_CURVES_LEGACY, OB_FONT, OB_SURF, object_duplilist will give duplicated geometries, we | ||||
| * don't need to load them twice, so exclude them. */ | |||||
| if (allow_duplicates && (!ELEM(ob->type, OB_CURVES_LEGACY, OB_FONT, OB_SURF))) { | |||||
| /* Because relations to particle/child instances are (supposedly) added, using | |||||
| * object_duplilist here should not access any objects that depsgraph haven't evaluated. | |||||
| * | |||||
| * TODO(Yiming): If the instance object/collection is inhibited by line art flags, they won't | |||||
| * be added for depsgraph evaluation, technically that kind of situation would face the same | |||||
| * problem when we try to create duplilist here? */ | |||||
| ListBase *dupli = object_duplilist(depsgraph, DEG_get_input_scene(depsgraph), ob); | |||||
| LISTBASE_FOREACH (DupliObject *, dob, dupli) { | LISTBASE_FOREACH (DupliObject *, dob, dupli) { | ||||
| if (BKE_object_visibility(eval_ob, eval_mode) & | if (BKE_object_visibility(ob, eval_mode) & (OB_VISIBLE_PARTICLES | OB_VISIBLE_INSTANCES)) { | ||||
| (OB_VISIBLE_PARTICLES | OB_VISIBLE_INSTANCES)) { | |||||
| Object *ob_ref = (dob->type & OB_DUPLIPARTS) ? eval_ob : dob->ob; | Object *ob_ref = (dob->type & OB_DUPLIPARTS) ? eval_ob : dob->ob; | ||||
| lineart_object_load_single_instance( | lineart_object_load_single_instance( | ||||
| rb, depsgraph, scene, dob->ob, ob_ref, dob->mat, is_render, olti, thread_count); | rb, depsgraph, scene, dob->ob, ob_ref, dob->mat, is_render, olti, thread_count); | ||||
| } | } | ||||
| } | } | ||||
| free_object_duplilist(dupli); | free_object_duplilist(dupli); | ||||
| } | } | ||||
| } | } | ||||
| FOREACH_SCENE_OBJECT_END; | |||||
| TaskPool *tp = BLI_task_pool_create(NULL, TASK_PRIORITY_HIGH); | TaskPool *tp = BLI_task_pool_create(NULL, TASK_PRIORITY_HIGH); | ||||
| if (G.debug_value == 4000) { | if (G.debug_value == 4000) { | ||||
| printf("thread count: %d\n", thread_count); | printf("thread count: %d\n", thread_count); | ||||
| } | } | ||||
| for (int i = 0; i < thread_count; i++) { | for (int i = 0; i < thread_count; i++) { | ||||
| olti[i].rb = rb; | olti[i].rb = rb; | ||||
| ▲ Show 20 Lines • Show All 192 Lines • Show Last 20 Lines | |||||