Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_manager.c
| Show All 27 Lines | |||||
| #include "BLI_rect.h" | #include "BLI_rect.h" | ||||
| #include "BLI_string.h" | #include "BLI_string.h" | ||||
| #include "BLI_threads.h" | #include "BLI_threads.h" | ||||
| #include "BLF_api.h" | #include "BLF_api.h" | ||||
| #include "BKE_anim.h" | #include "BKE_anim.h" | ||||
| #include "BKE_colortools.h" | #include "BKE_colortools.h" | ||||
| #include "BKE_context.h" | |||||
| #include "BKE_curve.h" | #include "BKE_curve.h" | ||||
| #include "BKE_editmesh.h" | #include "BKE_editmesh.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_gpencil.h" | #include "BKE_gpencil.h" | ||||
| #include "BKE_lattice.h" | #include "BKE_lattice.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_mball.h" | #include "BKE_mball.h" | ||||
| #include "BKE_mesh.h" | #include "BKE_mesh.h" | ||||
| #include "BKE_modifier.h" | |||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| #include "BKE_particle.h" | #include "BKE_particle.h" | ||||
| #include "BKE_paint.h" | #include "BKE_paint.h" | ||||
| #include "BKE_pbvh.h" | #include "BKE_pbvh.h" | ||||
| #include "BKE_pointcache.h" | #include "BKE_pointcache.h" | ||||
| #include "draw_manager.h" | #include "draw_manager.h" | ||||
| #include "DNA_camera_types.h" | #include "DNA_camera_types.h" | ||||
| ▲ Show 20 Lines • Show All 2,147 Lines • ▼ Show 20 Lines | #ifndef USE_GPU_SELECT | ||||
| UNUSED_VARS(vc, scene, view_layer, v3d, ar, rect); | UNUSED_VARS(vc, scene, view_layer, v3d, ar, rect); | ||||
| #else | #else | ||||
| RegionView3D *rv3d = ar->regiondata; | RegionView3D *rv3d = ar->regiondata; | ||||
| /* Reset before using it. */ | /* Reset before using it. */ | ||||
| drw_state_prepare_clean_for_draw(&DST); | drw_state_prepare_clean_for_draw(&DST); | ||||
| bool use_obedit = false; | bool use_obedit = false; | ||||
| int obedit_mode = 0; | /* obedit_ctx_mode is used for selecting the right draw engines */ | ||||
| eContextObjectMode obedit_ctx_mode; | |||||
| /* object_mode is used for filtering objects in the depsgraph */ | |||||
| eObjectMode object_mode; | |||||
| int object_type = 0; | |||||
| if (obedit != NULL) { | if (obedit != NULL) { | ||||
| object_type = obedit->type; | |||||
| object_mode = obedit->mode; | |||||
| if (obedit->type == OB_MBALL) { | if (obedit->type == OB_MBALL) { | ||||
| use_obedit = true; | use_obedit = true; | ||||
| obedit_mode = CTX_MODE_EDIT_METABALL; | obedit_ctx_mode = CTX_MODE_EDIT_METABALL; | ||||
| } | } | ||||
| else if (obedit->type == OB_ARMATURE) { | else if (obedit->type == OB_ARMATURE) { | ||||
| use_obedit = true; | use_obedit = true; | ||||
| obedit_mode = CTX_MODE_EDIT_ARMATURE; | obedit_ctx_mode = CTX_MODE_EDIT_ARMATURE; | ||||
| } | } | ||||
| } | } | ||||
| if (v3d->overlay.flag & V3D_OVERLAY_BONE_SELECT) { | if (v3d->overlay.flag & V3D_OVERLAY_BONE_SELECT) { | ||||
| if (!(v3d->flag2 & V3D_HIDE_OVERLAYS)) { | if (!(v3d->flag2 & V3D_HIDE_OVERLAYS)) { | ||||
| /* Note: don't use "BKE_object_pose_armature_get" here, it breaks selection. */ | /* Note: don't use "BKE_object_pose_armature_get" here, it breaks selection. */ | ||||
| Object *obpose = OBPOSE_FROM_OBACT(obact); | Object *obpose = OBPOSE_FROM_OBACT(obact); | ||||
| if (obpose == NULL) { | |||||
| Object *obweight = OBWEIGHTPAINT_FROM_OBACT(obact); | |||||
| if (obweight) { | |||||
| /* Only use Armature pose selection, when connected armature is in pose mode. */ | |||||
| Object *ob_armature = modifiers_isDeformedByArmature(obweight); | |||||
| if (ob_armature && ob_armature->mode == OB_MODE_POSE) { | |||||
| obpose = ob_armature; | |||||
| } | |||||
| } | |||||
| } | |||||
| if (obpose) { | if (obpose) { | ||||
| use_obedit = true; | use_obedit = true; | ||||
| obedit_mode = CTX_MODE_POSE; | object_type = obpose->type; | ||||
| object_mode = obpose->mode; | |||||
| obedit_ctx_mode = CTX_MODE_POSE; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| int viewport_size[2] = {BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)}; | int viewport_size[2] = {BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)}; | ||||
| struct GPUViewport *viewport = GPU_viewport_create(); | struct GPUViewport *viewport = GPU_viewport_create(); | ||||
| GPU_viewport_size_set(viewport, viewport_size); | GPU_viewport_size_set(viewport, viewport_size); | ||||
| DST.viewport = viewport; | DST.viewport = viewport; | ||||
| DST.options.is_select = true; | DST.options.is_select = true; | ||||
| /* Get list of enabled engines */ | /* Get list of enabled engines */ | ||||
| if (use_obedit) { | if (use_obedit) { | ||||
| drw_engines_enable_from_paint_mode(obedit_mode); | drw_engines_enable_from_paint_mode(obedit_ctx_mode); | ||||
| drw_engines_enable_from_mode(obedit_mode); | drw_engines_enable_from_mode(obedit_ctx_mode); | ||||
| } | } | ||||
| else if (!draw_surface) { | else if (!draw_surface) { | ||||
| /* grease pencil selection */ | /* grease pencil selection */ | ||||
| use_drw_engine(&draw_engine_gpencil_type); | use_drw_engine(&draw_engine_gpencil_type); | ||||
| drw_engines_enable_from_overlays(v3d->overlay.flag); | drw_engines_enable_from_overlays(v3d->overlay.flag); | ||||
| drw_engines_enable_from_object_mode(); | drw_engines_enable_from_object_mode(); | ||||
| } | } | ||||
| Show All 30 Lines | #else | ||||
| drw_engines_init(); | drw_engines_init(); | ||||
| DRW_hair_init(); | DRW_hair_init(); | ||||
| { | { | ||||
| drw_engines_cache_init(); | drw_engines_cache_init(); | ||||
| drw_engines_world_update(scene); | drw_engines_world_update(scene); | ||||
| if (use_obedit) { | if (use_obedit) { | ||||
| FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, v3d, obact->type, obact->mode, ob_iter) { | FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, v3d, object_type, object_mode, ob_iter) { | ||||
| drw_engines_cache_populate(ob_iter); | drw_engines_cache_populate(ob_iter); | ||||
| } | } | ||||
| FOREACH_OBJECT_IN_MODE_END; | FOREACH_OBJECT_IN_MODE_END; | ||||
| } | } | ||||
| else { | else { | ||||
| const int object_type_exclude_select = (v3d->object_type_exclude_viewport | | const int object_type_exclude_select = (v3d->object_type_exclude_viewport | | ||||
| v3d->object_type_exclude_select); | v3d->object_type_exclude_select); | ||||
| bool filter_exclude = false; | bool filter_exclude = false; | ||||
| ▲ Show 20 Lines • Show All 748 Lines • Show Last 20 Lines | |||||