Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/overlay/overlay_extra.cc
- This file was moved from source/blender/draw/engines/overlay/overlay_extra.c.
| Show All 32 Lines | |||||
| #include "DNA_modifier_types.h" | #include "DNA_modifier_types.h" | ||||
| #include "DNA_pointcache_types.h" | #include "DNA_pointcache_types.h" | ||||
| #include "DNA_rigidbody_types.h" | #include "DNA_rigidbody_types.h" | ||||
| #include "DEG_depsgraph_query.h" | #include "DEG_depsgraph_query.h" | ||||
| #include "ED_view3d.h" | #include "ED_view3d.h" | ||||
| #include "overlay_private.h" | #include "overlay_private.hh" | ||||
| #include "draw_common.h" | #include "draw_common.h" | ||||
| #include "draw_manager_text.h" | #include "draw_manager_text.h" | ||||
| void OVERLAY_extra_cache_init(OVERLAY_Data *vedata) | void OVERLAY_extra_cache_init(OVERLAY_Data *vedata) | ||||
| { | { | ||||
| OVERLAY_PassList *psl = vedata->psl; | OVERLAY_PassList *psl = vedata->psl; | ||||
| OVERLAY_TextureList *txl = vedata->txl; | OVERLAY_TextureList *txl = vedata->txl; | ||||
| Show All 24 Lines | for (int i = 0; i < 2; i++) { | ||||
| struct GPUShader *sh; | struct GPUShader *sh; | ||||
| struct GPUVertFormat *format; | struct GPUVertFormat *format; | ||||
| DRWShadingGroup *grp, *grp_sub; | DRWShadingGroup *grp, *grp_sub; | ||||
| OVERLAY_InstanceFormats *formats = OVERLAY_shader_instance_formats_get(); | OVERLAY_InstanceFormats *formats = OVERLAY_shader_instance_formats_get(); | ||||
| OVERLAY_ExtraCallBuffers *cb = &pd->extra_call_buffers[i]; | OVERLAY_ExtraCallBuffers *cb = &pd->extra_call_buffers[i]; | ||||
| DRWPass **p_extra_ps = &psl->extra_ps[i]; | DRWPass **p_extra_ps = &psl->extra_ps[i]; | ||||
| DRWState infront_state = (DRW_state_is_select() && (i == 1)) ? DRW_STATE_IN_FRONT_SELECT : 0; | DRWState infront_state = (DRW_state_is_select() && (i == 1)) ? DRW_STATE_IN_FRONT_SELECT : | ||||
| DRWState(0); | |||||
| DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL; | DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL; | ||||
| DRW_PASS_CREATE(*p_extra_ps, state | pd->clipping_state | infront_state); | DRW_PASS_CREATE(*p_extra_ps, state | pd->clipping_state | infront_state); | ||||
| DRWPass *extra_ps = *p_extra_ps; | DRWPass *extra_ps = *p_extra_ps; | ||||
| #define BUF_INSTANCE DRW_shgroup_call_buffer_instance | #define BUF_INSTANCE DRW_shgroup_call_buffer_instance | ||||
| #define BUF_POINT(grp, format) DRW_shgroup_call_buffer(grp, format, GPU_PRIM_POINTS) | #define BUF_POINT(grp, format) DRW_shgroup_call_buffer(grp, format, GPU_PRIM_POINTS) | ||||
| #define BUF_LINE(grp, format) DRW_shgroup_call_buffer(grp, format, GPU_PRIM_LINES) | #define BUF_LINE(grp, format) DRW_shgroup_call_buffer(grp, format, GPU_PRIM_LINES) | ||||
| ▲ Show 20 Lines • Show All 256 Lines • ▼ Show 20 Lines | static void OVERLAY_bounds(OVERLAY_ExtraCallBuffers *cb, | ||||
| float center[3], size[3], tmp[4][4], final_mat[4][4]; | float center[3], size[3], tmp[4][4], final_mat[4][4]; | ||||
| if (ob->type == OB_MBALL && !BKE_mball_is_basis(ob)) { | if (ob->type == OB_MBALL && !BKE_mball_is_basis(ob)) { | ||||
| return; | return; | ||||
| } | } | ||||
| const BoundBox *bb = BKE_object_boundbox_get(ob); | const BoundBox *bb = BKE_object_boundbox_get(ob); | ||||
| BoundBox bb_local; | BoundBox bb_local; | ||||
| if (bb == NULL) { | if (bb == nullptr) { | ||||
| const float min[3] = {-1.0f, -1.0f, -1.0f}, max[3] = {1.0f, 1.0f, 1.0f}; | const float min[3] = {-1.0f, -1.0f, -1.0f}, max[3] = {1.0f, 1.0f, 1.0f}; | ||||
| BKE_boundbox_init_from_minmax(&bb_local, min, max); | BKE_boundbox_init_from_minmax(&bb_local, min, max); | ||||
| bb = &bb_local; | bb = &bb_local; | ||||
| } | } | ||||
| BKE_boundbox_calc_size_aabb(bb, size); | BKE_boundbox_calc_size_aabb(bb, size); | ||||
| if (around_origin) { | if (around_origin) { | ||||
| ▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | switch (ob->rigidbody_object->shape) { | ||||
| case RB_SHAPE_CAPSULE: | case RB_SHAPE_CAPSULE: | ||||
| OVERLAY_bounds(cb, ob, color, OB_BOUND_CAPSULE, true); | OVERLAY_bounds(cb, ob, color, OB_BOUND_CAPSULE, true); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| static void OVERLAY_texture_space(OVERLAY_ExtraCallBuffers *cb, Object *ob, const float *color) | static void OVERLAY_texture_space(OVERLAY_ExtraCallBuffers *cb, Object *ob, const float *color) | ||||
| { | { | ||||
| if (ob->data == NULL) { | if (ob->data == nullptr) { | ||||
| return; | return; | ||||
| } | } | ||||
| ID *ob_data = ob->data; | ID *ob_data = static_cast<ID *>(ob->data); | ||||
| float *texcoloc = NULL; | float *texcoloc = nullptr; | ||||
| float *texcosize = NULL; | float *texcosize = nullptr; | ||||
| switch (GS(ob_data->name)) { | switch (GS(ob_data->name)) { | ||||
| case ID_ME: | case ID_ME: | ||||
| BKE_mesh_texspace_get_reference((Mesh *)ob_data, NULL, &texcoloc, &texcosize); | BKE_mesh_texspace_get_reference((Mesh *)ob_data, nullptr, &texcoloc, &texcosize); | ||||
| break; | break; | ||||
| case ID_CU_LEGACY: { | case ID_CU_LEGACY: { | ||||
| Curve *cu = (Curve *)ob_data; | Curve *cu = (Curve *)ob_data; | ||||
| BKE_curve_texspace_ensure(cu); | BKE_curve_texspace_ensure(cu); | ||||
| texcoloc = cu->loc; | texcoloc = cu->loc; | ||||
| texcosize = cu->size; | texcosize = cu->size; | ||||
| break; | break; | ||||
| } | } | ||||
| Show All 10 Lines | case ID_VO: { | ||||
| break; | break; | ||||
| } | } | ||||
| default: | default: | ||||
| BLI_assert(0); | BLI_assert(0); | ||||
| } | } | ||||
| float mat[4][4]; | float mat[4][4]; | ||||
| if (texcoloc != NULL && texcosize != NULL) { | if (texcoloc != nullptr && texcosize != nullptr) { | ||||
| size_to_mat4(mat, texcosize); | size_to_mat4(mat, texcosize); | ||||
| copy_v3_v3(mat[3], texcoloc); | copy_v3_v3(mat[3], texcoloc); | ||||
| } | } | ||||
| else { | else { | ||||
| unit_m4(mat); | unit_m4(mat); | ||||
| } | } | ||||
| mul_m4_m4m4(mat, ob->obmat, mat); | mul_m4_m4m4(mat, ob->obmat, mat); | ||||
| DRW_buffer_add_entry(cb->empty_cube, color, mat); | DRW_buffer_add_entry(cb->empty_cube, color, mat); | ||||
| } | } | ||||
| static void OVERLAY_forcefield(OVERLAY_ExtraCallBuffers *cb, Object *ob, ViewLayer *view_layer) | static void OVERLAY_forcefield(OVERLAY_ExtraCallBuffers *cb, Object *ob, ViewLayer *view_layer) | ||||
| { | { | ||||
| int theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL); | int theme_id = DRW_object_wire_theme_get(ob, view_layer, nullptr); | ||||
| float *color = DRW_color_background_blend_get(theme_id); | float *color = DRW_color_background_blend_get(theme_id); | ||||
| PartDeflect *pd = ob->pd; | PartDeflect *pd = ob->pd; | ||||
| Curve *cu = (ob->type == OB_CURVES_LEGACY) ? ob->data : NULL; | Curve *cu = (ob->type == OB_CURVES_LEGACY) ? static_cast<Curve *>(ob->data) : nullptr; | ||||
| union { | union { | ||||
| float mat[4][4]; | float mat[4][4]; | ||||
| struct { | struct { | ||||
| float _pad00[3], size_x; | float _pad00[3], size_x; | ||||
| float _pad01[3], size_y; | float _pad01[3], size_y; | ||||
| float _pad02[3], size_z; | float _pad02[3], size_z; | ||||
| float pos[3], _pad03[1]; | float pos[3], _pad03[1]; | ||||
| Show All 14 Lines | switch (pd->forcefield) { | ||||
| case PFIELD_VORTEX: | case PFIELD_VORTEX: | ||||
| instdata.size_y = (pd->f_strength < 0.0f) ? -instdata.size_y : instdata.size_y; | instdata.size_y = (pd->f_strength < 0.0f) ? -instdata.size_y : instdata.size_y; | ||||
| DRW_buffer_add_entry(cb->field_vortex, color, &instdata); | DRW_buffer_add_entry(cb->field_vortex, color, &instdata); | ||||
| break; | break; | ||||
| case PFIELD_GUIDE: | case PFIELD_GUIDE: | ||||
| if (cu && (cu->flag & CU_PATH) && ob->runtime.curve_cache->anim_path_accum_length) { | if (cu && (cu->flag & CU_PATH) && ob->runtime.curve_cache->anim_path_accum_length) { | ||||
| instdata.size_x = instdata.size_y = instdata.size_z = pd->f_strength; | instdata.size_x = instdata.size_y = instdata.size_z = pd->f_strength; | ||||
| float pos[4]; | float pos[4]; | ||||
| BKE_where_on_path(ob, 0.0f, pos, NULL, NULL, NULL, NULL); | BKE_where_on_path(ob, 0.0f, pos, nullptr, nullptr, nullptr, nullptr); | ||||
| copy_v3_v3(instdata.pos, ob->obmat[3]); | copy_v3_v3(instdata.pos, ob->obmat[3]); | ||||
| translate_m4(instdata.mat, pos[0], pos[1], pos[2]); | translate_m4(instdata.mat, pos[0], pos[1], pos[2]); | ||||
| DRW_buffer_add_entry(cb->field_curve, color, &instdata); | DRW_buffer_add_entry(cb->field_curve, color, &instdata); | ||||
| BKE_where_on_path(ob, 1.0f, pos, NULL, NULL, NULL, NULL); | BKE_where_on_path(ob, 1.0f, pos, nullptr, nullptr, nullptr, nullptr); | ||||
| copy_v3_v3(instdata.pos, ob->obmat[3]); | copy_v3_v3(instdata.pos, ob->obmat[3]); | ||||
| translate_m4(instdata.mat, pos[0], pos[1], pos[2]); | translate_m4(instdata.mat, pos[0], pos[1], pos[2]); | ||||
| DRW_buffer_add_entry(cb->field_sphere_limit, color, &instdata); | DRW_buffer_add_entry(cb->field_sphere_limit, color, &instdata); | ||||
| /* Restore */ | /* Restore */ | ||||
| copy_v3_v3(instdata.pos, ob->obmat[3]); | copy_v3_v3(instdata.pos, ob->obmat[3]); | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | |||||
| * \{ */ | * \{ */ | ||||
| void OVERLAY_light_cache_populate(OVERLAY_Data *vedata, Object *ob) | void OVERLAY_light_cache_populate(OVERLAY_Data *vedata, Object *ob) | ||||
| { | { | ||||
| OVERLAY_ExtraCallBuffers *cb = OVERLAY_extra_call_buffer_get(vedata, ob); | OVERLAY_ExtraCallBuffers *cb = OVERLAY_extra_call_buffer_get(vedata, ob); | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| ViewLayer *view_layer = draw_ctx->view_layer; | ViewLayer *view_layer = draw_ctx->view_layer; | ||||
| Light *la = ob->data; | Light *la = static_cast<Light *>(ob->data); | ||||
| float *color_p; | float *color_p; | ||||
| DRW_object_wire_theme_get(ob, view_layer, &color_p); | DRW_object_wire_theme_get(ob, view_layer, &color_p); | ||||
| /* Remove the alpha. */ | /* Remove the alpha. */ | ||||
| float color[4] = {UNPACK3(color_p), 1.0f}; | float color[4] = {UNPACK3(color_p), 1.0f}; | ||||
| /* Pack render data into object matrix. */ | /* Pack render data into object matrix. */ | ||||
| union { | union { | ||||
| float mat[4][4]; | float mat[4][4]; | ||||
| struct { | struct { | ||||
| Show All 27 Lines | if (la->type == LA_LOCAL) { | ||||
| DRW_buffer_add_entry(cb->light_point, color, &instdata); | DRW_buffer_add_entry(cb->light_point, color, &instdata); | ||||
| } | } | ||||
| else if (la->type == LA_SUN) { | else if (la->type == LA_SUN) { | ||||
| DRW_buffer_add_entry(cb->light_sun, color, &instdata); | DRW_buffer_add_entry(cb->light_sun, color, &instdata); | ||||
| } | } | ||||
| else if (la->type == LA_SPOT) { | else if (la->type == LA_SPOT) { | ||||
| /* Previous implementation was using the clipend distance as cone size. | /* Previous implementation was using the clipend distance as cone size. | ||||
| * We cannot do this anymore so we use a fixed size of 10. (see T72871) */ | * We cannot do this anymore so we use a fixed size of 10. (see T72871) */ | ||||
| rescale_m4(instdata.mat, (float[3]){10.0f, 10.0f, 10.0f}); | const float3 scale_vec = {10.0f, 10.0f, 10.0f}; | ||||
| rescale_m4(instdata.mat, scale_vec); | |||||
| /* For cycles and eevee the spot attenuation is | /* For cycles and eevee the spot attenuation is | ||||
| * y = (1/(1 + x^2) - a)/((1 - a) b) | * y = (1/(1 + x^2) - a)/((1 - a) b) | ||||
| * We solve the case where spot attenuation y = 1 and y = 0 | * We solve the case where spot attenuation y = 1 and y = 0 | ||||
| * root for y = 1 is (-1 - c) / c | * root for y = 1 is (-1 - c) / c | ||||
| * root for y = 0 is (1 - a) / a | * root for y = 0 is (1 - a) / a | ||||
| * and use that to position the blend circle. */ | * and use that to position the blend circle. */ | ||||
| float a = cosf(la->spotsize * 0.5f); | float a = cosf(la->spotsize * 0.5f); | ||||
| float b = la->spotblend; | float b = la->spotblend; | ||||
| ▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | case LIGHTPROBE_TYPE_GRID: | ||||
| } | } | ||||
| else /* TH_SELECT */ { | else /* TH_SELECT */ { | ||||
| instdata.mat[3][3] = 2.0; | instdata.mat[3][3] = 2.0; | ||||
| } | } | ||||
| uint cell_count = prb->grid_resolution_x * prb->grid_resolution_y * prb->grid_resolution_z; | uint cell_count = prb->grid_resolution_x * prb->grid_resolution_y * prb->grid_resolution_z; | ||||
| DRWShadingGroup *grp = DRW_shgroup_create_sub(vedata->stl->pd->extra_grid_grp); | DRWShadingGroup *grp = DRW_shgroup_create_sub(vedata->stl->pd->extra_grid_grp); | ||||
| DRW_shgroup_uniform_mat4_copy(grp, "gridModelMatrix", instdata.mat); | DRW_shgroup_uniform_mat4_copy(grp, "gridModelMatrix", instdata.mat); | ||||
| DRW_shgroup_call_procedural_points(grp, NULL, cell_count); | DRW_shgroup_call_procedural_points(grp, nullptr, cell_count); | ||||
| } | } | ||||
| break; | break; | ||||
| case LIGHTPROBE_TYPE_PLANAR: | case LIGHTPROBE_TYPE_PLANAR: | ||||
| DRW_buffer_add_entry(cb->probe_planar, color_p, &instdata); | DRW_buffer_add_entry(cb->probe_planar, color_p, &instdata); | ||||
| if (DRW_state_is_select() && (prb->flag & LIGHTPROBE_FLAG_SHOW_DATA)) { | if (DRW_state_is_select() && (prb->flag & LIGHTPROBE_FLAG_SHOW_DATA)) { | ||||
| DRW_buffer_add_entry(cb->solid_quad, color_p, &instdata); | DRW_buffer_add_entry(cb->solid_quad, color_p, &instdata); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | |||||
| static void camera_view3d_reconstruction( | static void camera_view3d_reconstruction( | ||||
| OVERLAY_ExtraCallBuffers *cb, Scene *scene, View3D *v3d, Object *ob, const float color[4]) | OVERLAY_ExtraCallBuffers *cb, Scene *scene, View3D *v3d, Object *ob, const float color[4]) | ||||
| { | { | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| const bool is_select = DRW_state_is_select(); | const bool is_select = DRW_state_is_select(); | ||||
| MovieClip *clip = BKE_object_movieclip_get(scene, ob, false); | MovieClip *clip = BKE_object_movieclip_get(scene, ob, false); | ||||
| if (clip == NULL) { | if (clip == nullptr) { | ||||
| return; | return; | ||||
| } | } | ||||
| const bool is_solid_bundle = (v3d->bundle_drawtype == OB_EMPTY_SPHERE) && | const bool is_solid_bundle = (v3d->bundle_drawtype == OB_EMPTY_SPHERE) && | ||||
| ((v3d->shading.type != OB_SOLID) || !XRAY_FLAG_ENABLED(v3d)); | ((v3d->shading.type != OB_SOLID) || !XRAY_FLAG_ENABLED(v3d)); | ||||
| MovieTracking *tracking = &clip->tracking; | MovieTracking *tracking = &clip->tracking; | ||||
| /* Index must start in 1, to mimic BKE_tracking_track_get_indexed. */ | /* Index must start in 1, to mimic BKE_tracking_track_get_indexed. */ | ||||
| ▲ Show 20 Lines • Show All 119 Lines • ▼ Show 20 Lines | static void camera_view3d_reconstruction( | ||||
| } | } | ||||
| } | } | ||||
| static float camera_offaxis_shiftx_get(Scene *scene, | static float camera_offaxis_shiftx_get(Scene *scene, | ||||
| Object *ob, | Object *ob, | ||||
| const OVERLAY_CameraInstanceData *instdata, | const OVERLAY_CameraInstanceData *instdata, | ||||
| bool right_eye) | bool right_eye) | ||||
| { | { | ||||
| Camera *cam = ob->data; | Camera *cam = static_cast<Camera *>(ob->data); | ||||
| if (cam->stereo.convergence_mode == CAM_S3D_OFFAXIS) { | if (cam->stereo.convergence_mode == CAM_S3D_OFFAXIS) { | ||||
| const char *viewnames[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME}; | const char *viewnames[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME}; | ||||
| const float shiftx = BKE_camera_multiview_shift_x(&scene->r, ob, viewnames[right_eye]); | const float shiftx = BKE_camera_multiview_shift_x(&scene->r, ob, viewnames[right_eye]); | ||||
| const float delta_shiftx = shiftx - cam->shiftx; | const float delta_shiftx = shiftx - cam->shiftx; | ||||
| const float width = instdata->corner_x * 2.0f; | const float width = instdata->corner_x * 2.0f; | ||||
| return delta_shiftx * width; | return delta_shiftx * width; | ||||
| } | } | ||||
| return 0.0; | return 0.0; | ||||
| } | } | ||||
| /** | /** | ||||
| * Draw the stereo 3d support elements (cameras, plane, volume). | * Draw the stereo 3d support elements (cameras, plane, volume). | ||||
| * They are only visible when not looking through the camera: | * They are only visible when not looking through the camera: | ||||
| */ | */ | ||||
| static void camera_stereoscopy_extra(OVERLAY_ExtraCallBuffers *cb, | static void camera_stereoscopy_extra(OVERLAY_ExtraCallBuffers *cb, | ||||
| Scene *scene, | Scene *scene, | ||||
| View3D *v3d, | View3D *v3d, | ||||
| Object *ob, | Object *ob, | ||||
| const OVERLAY_CameraInstanceData *instdata) | const OVERLAY_CameraInstanceData *instdata) | ||||
| { | { | ||||
| OVERLAY_CameraInstanceData stereodata = *instdata; | OVERLAY_CameraInstanceData stereodata = *instdata; | ||||
| Camera *cam = ob->data; | Camera *cam = static_cast<Camera *>(ob->data); | ||||
| const bool is_select = DRW_state_is_select(); | const bool is_select = DRW_state_is_select(); | ||||
| const char *viewnames[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME}; | const char *viewnames[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME}; | ||||
| const bool is_stereo3d_cameras = (v3d->stereo3d_flag & V3D_S3D_DISPCAMERAS) != 0; | const bool is_stereo3d_cameras = (v3d->stereo3d_flag & V3D_S3D_DISPCAMERAS) != 0; | ||||
| const bool is_stereo3d_plane = (v3d->stereo3d_flag & V3D_S3D_DISPPLANE) != 0; | const bool is_stereo3d_plane = (v3d->stereo3d_flag & V3D_S3D_DISPPLANE) != 0; | ||||
| const bool is_stereo3d_volume = (v3d->stereo3d_flag & V3D_S3D_DISPVOLUME) != 0; | const bool is_stereo3d_volume = (v3d->stereo3d_flag & V3D_S3D_DISPVOLUME) != 0; | ||||
| if (!is_stereo3d_cameras) { | if (!is_stereo3d_cameras) { | ||||
| ▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | void OVERLAY_camera_cache_populate(OVERLAY_Data *vedata, Object *ob) | ||||
| OVERLAY_CameraInstanceData instdata; | OVERLAY_CameraInstanceData instdata; | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| ViewLayer *view_layer = draw_ctx->view_layer; | ViewLayer *view_layer = draw_ctx->view_layer; | ||||
| View3D *v3d = draw_ctx->v3d; | View3D *v3d = draw_ctx->v3d; | ||||
| Scene *scene = draw_ctx->scene; | Scene *scene = draw_ctx->scene; | ||||
| RegionView3D *rv3d = draw_ctx->rv3d; | RegionView3D *rv3d = draw_ctx->rv3d; | ||||
| Camera *cam = ob->data; | Camera *cam = static_cast<Camera *>(ob->data); | ||||
| Object *camera_object = DEG_get_evaluated_object(draw_ctx->depsgraph, v3d->camera); | Object *camera_object = DEG_get_evaluated_object(draw_ctx->depsgraph, v3d->camera); | ||||
| const bool is_select = DRW_state_is_select(); | const bool is_select = DRW_state_is_select(); | ||||
| const bool is_active = (ob == camera_object); | const bool is_active = (ob == camera_object); | ||||
| const bool look_through = (is_active && (rv3d->persp == RV3D_CAMOB)); | const bool look_through = (is_active && (rv3d->persp == RV3D_CAMOB)); | ||||
| const bool is_multiview = (scene->r.scemode & R_MULTIVIEW) != 0; | const bool is_multiview = (scene->r.scemode & R_MULTIVIEW) != 0; | ||||
| const bool is_stereo3d_view = (scene->r.views_format == SCE_VIEWS_FORMAT_STEREO_3D); | const bool is_stereo3d_view = (scene->r.views_format == SCE_VIEWS_FORMAT_STEREO_3D); | ||||
| const bool is_stereo3d_display_extra = is_active && is_multiview && (!look_through) && | const bool is_stereo3d_display_extra = is_active && is_multiview && (!look_through) && | ||||
| ▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Lines | static void OVERLAY_relationship_lines(OVERLAY_ExtraCallBuffers *cb, | ||||
| float *constraint_color = G_draw.block.color_grid_axis_z; /* ? */ | float *constraint_color = G_draw.block.color_grid_axis_z; /* ? */ | ||||
| if (ob->parent && (DRW_object_visibility_in_active_context(ob->parent) & OB_VISIBLE_SELF)) { | if (ob->parent && (DRW_object_visibility_in_active_context(ob->parent) & OB_VISIBLE_SELF)) { | ||||
| float *parent_pos = ob->runtime.parent_display_origin; | float *parent_pos = ob->runtime.parent_display_origin; | ||||
| OVERLAY_extra_line_dashed(cb, parent_pos, ob->obmat[3], relation_color); | OVERLAY_extra_line_dashed(cb, parent_pos, ob->obmat[3], relation_color); | ||||
| } | } | ||||
| /* Drawing the hook lines. */ | /* Drawing the hook lines. */ | ||||
| for (ModifierData *md = ob->modifiers.first; md; md = md->next) { | for (ModifierData *md = static_cast<ModifierData *>(ob->modifiers.first); md; md = md->next) { | ||||
| if (md->type == eModifierType_Hook) { | if (md->type == eModifierType_Hook) { | ||||
| HookModifierData *hmd = (HookModifierData *)md; | HookModifierData *hmd = (HookModifierData *)md; | ||||
| float center[3]; | float center[3]; | ||||
| mul_v3_m4v3(center, ob->obmat, hmd->cent); | mul_v3_m4v3(center, ob->obmat, hmd->cent); | ||||
| if (hmd->object) { | if (hmd->object) { | ||||
| OVERLAY_extra_line_dashed(cb, hmd->object->obmat[3], center, relation_color); | OVERLAY_extra_line_dashed(cb, hmd->object->obmat[3], center, relation_color); | ||||
| } | } | ||||
| OVERLAY_extra_point(cb, center, relation_color); | OVERLAY_extra_point(cb, center, relation_color); | ||||
| Show All 12 Lines | static void OVERLAY_relationship_lines(OVERLAY_ExtraCallBuffers *cb, | ||||
| } | } | ||||
| /* Drawing the constraint lines */ | /* Drawing the constraint lines */ | ||||
| if (!BLI_listbase_is_empty(&ob->constraints)) { | if (!BLI_listbase_is_empty(&ob->constraints)) { | ||||
| bConstraint *curcon; | bConstraint *curcon; | ||||
| bConstraintOb *cob; | bConstraintOb *cob; | ||||
| ListBase *list = &ob->constraints; | ListBase *list = &ob->constraints; | ||||
| cob = BKE_constraints_make_evalob(depsgraph, scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT); | cob = BKE_constraints_make_evalob(depsgraph, scene, ob, nullptr, CONSTRAINT_OBTYPE_OBJECT); | ||||
| for (curcon = list->first; curcon; curcon = curcon->next) { | for (curcon = static_cast<bConstraint *>(list->first); curcon; curcon = curcon->next) { | ||||
| if (ELEM(curcon->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_OBJECTSOLVER)) { | if (ELEM(curcon->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_OBJECTSOLVER)) { | ||||
| /* special case for object solver and follow track constraints because they don't fill | /* special case for object solver and follow track constraints because they don't fill | ||||
| * constraint targets properly (design limitation -- scene is needed for their target | * constraint targets properly (design limitation -- scene is needed for their target | ||||
| * but it can't be accessed from get_targets callback) */ | * but it can't be accessed from get_targets callback) */ | ||||
| Object *camob = NULL; | Object *camob = nullptr; | ||||
| if (curcon->type == CONSTRAINT_TYPE_FOLLOWTRACK) { | if (curcon->type == CONSTRAINT_TYPE_FOLLOWTRACK) { | ||||
| bFollowTrackConstraint *data = (bFollowTrackConstraint *)curcon->data; | bFollowTrackConstraint *data = (bFollowTrackConstraint *)curcon->data; | ||||
| camob = data->camera ? data->camera : scene->camera; | camob = data->camera ? data->camera : scene->camera; | ||||
| } | } | ||||
| else if (curcon->type == CONSTRAINT_TYPE_OBJECTSOLVER) { | else if (curcon->type == CONSTRAINT_TYPE_OBJECTSOLVER) { | ||||
| bObjectSolverConstraint *data = (bObjectSolverConstraint *)curcon->data; | bObjectSolverConstraint *data = (bObjectSolverConstraint *)curcon->data; | ||||
| camob = data->camera ? data->camera : scene->camera; | camob = data->camera ? data->camera : scene->camera; | ||||
| } | } | ||||
| if (camob) { | if (camob) { | ||||
| OVERLAY_extra_line_dashed(cb, camob->obmat[3], ob->obmat[3], constraint_color); | OVERLAY_extra_line_dashed(cb, camob->obmat[3], ob->obmat[3], constraint_color); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(curcon); | const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(curcon); | ||||
| ListBase targets = {NULL, NULL}; | ListBase targets = {nullptr, nullptr}; | ||||
| if ((curcon->ui_expand_flag & (1 << 0)) && BKE_constraint_targets_get(curcon, &targets)) { | if ((curcon->ui_expand_flag & (1 << 0)) && BKE_constraint_targets_get(curcon, &targets)) { | ||||
| bConstraintTarget *ct; | bConstraintTarget *ct; | ||||
| BKE_constraint_custom_object_space_init(cob, curcon); | BKE_constraint_custom_object_space_init(cob, curcon); | ||||
| for (ct = targets.first; ct; ct = ct->next) { | for (ct = static_cast<bConstraintTarget *>(targets.first); ct; ct = ct->next) { | ||||
| /* calculate target's matrix */ | /* calculate target's matrix */ | ||||
| if (ct->flag & CONSTRAINT_TAR_CUSTOM_SPACE) { | if (ct->flag & CONSTRAINT_TAR_CUSTOM_SPACE) { | ||||
| copy_m4_m4(ct->matrix, cob->space_obj_world_matrix); | copy_m4_m4(ct->matrix, cob->space_obj_world_matrix); | ||||
| } | } | ||||
| else if (cti->get_target_matrix) { | else if (cti->get_target_matrix) { | ||||
| cti->get_target_matrix(depsgraph, curcon, cob, ct, DEG_get_ctime(depsgraph)); | cti->get_target_matrix(depsgraph, curcon, cob, ct, DEG_get_ctime(depsgraph)); | ||||
| } | } | ||||
| else { | else { | ||||
| ▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | /* Small cube showing voxel size. */ | ||||
| DRW_buffer_add_entry(cb->empty_cube, color, voxel_cubemat); | DRW_buffer_add_entry(cb->empty_cube, color, voxel_cubemat); | ||||
| } | } | ||||
| int slice_axis = -1; | int slice_axis = -1; | ||||
| if (fds->axis_slice_method == AXIS_SLICE_SINGLE) { | if (fds->axis_slice_method == AXIS_SLICE_SINGLE) { | ||||
| float viewinv[4][4]; | float viewinv[4][4]; | ||||
| DRW_view_viewmat_get(NULL, viewinv, true); | DRW_view_viewmat_get(nullptr, viewinv, true); | ||||
| const int axis = (fds->slice_axis == SLICE_AXIS_AUTO) ? axis_dominant_v3_single(viewinv[2]) : | const int axis = (fds->slice_axis == SLICE_AXIS_AUTO) ? axis_dominant_v3_single(viewinv[2]) : | ||||
| fds->slice_axis - 1; | fds->slice_axis - 1; | ||||
| slice_axis = axis; | slice_axis = axis; | ||||
| } | } | ||||
| if (draw_velocity) { | if (draw_velocity) { | ||||
| const bool use_needle = (fds->vector_draw_type == VECTOR_DRAW_NEEDLE); | const bool use_needle = (fds->vector_draw_type == VECTOR_DRAW_NEEDLE); | ||||
| ▲ Show 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | |||||
| void OVERLAY_extra_cache_populate(OVERLAY_Data *vedata, Object *ob) | void OVERLAY_extra_cache_populate(OVERLAY_Data *vedata, Object *ob) | ||||
| { | { | ||||
| OVERLAY_ExtraCallBuffers *cb = OVERLAY_extra_call_buffer_get(vedata, ob); | OVERLAY_ExtraCallBuffers *cb = OVERLAY_extra_call_buffer_get(vedata, ob); | ||||
| OVERLAY_PrivateData *pd = vedata->stl->pd; | OVERLAY_PrivateData *pd = vedata->stl->pd; | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| ViewLayer *view_layer = draw_ctx->view_layer; | ViewLayer *view_layer = draw_ctx->view_layer; | ||||
| Scene *scene = draw_ctx->scene; | Scene *scene = draw_ctx->scene; | ||||
| ModifierData *md = NULL; | ModifierData *md = nullptr; | ||||
| const bool is_select_mode = DRW_state_is_select(); | const bool is_select_mode = DRW_state_is_select(); | ||||
| const bool is_paint_mode = (draw_ctx->object_mode & | const bool is_paint_mode = (draw_ctx->object_mode & | ||||
| (OB_MODE_ALL_PAINT | OB_MODE_ALL_PAINT_GPENCIL)) != 0; | (OB_MODE_ALL_PAINT | OB_MODE_ALL_PAINT_GPENCIL)) != 0; | ||||
| const bool from_dupli = (ob->base_flag & (BASE_FROM_SET | BASE_FROM_DUPLI)) != 0; | const bool from_dupli = (ob->base_flag & (BASE_FROM_SET | BASE_FROM_DUPLI)) != 0; | ||||
| const bool has_bounds = !ELEM(ob->type, OB_LAMP, OB_CAMERA, OB_EMPTY, OB_SPEAKER, OB_LIGHTPROBE); | const bool has_bounds = !ELEM(ob->type, OB_LAMP, OB_CAMERA, OB_EMPTY, OB_SPEAKER, OB_LIGHTPROBE); | ||||
| const bool has_texspace = has_bounds && | const bool has_texspace = has_bounds && | ||||
| !ELEM(ob->type, OB_EMPTY, OB_LATTICE, OB_ARMATURE, OB_GPENCIL); | !ELEM(ob->type, OB_EMPTY, OB_LATTICE, OB_ARMATURE, OB_GPENCIL); | ||||
| const bool draw_relations = ((pd->v3d_flag & V3D_HIDE_HELPLINES) == 0) && !is_select_mode; | const bool draw_relations = ((pd->v3d_flag & V3D_HIDE_HELPLINES) == 0) && !is_select_mode; | ||||
| const bool draw_obcenters = !is_paint_mode && | const bool draw_obcenters = !is_paint_mode && | ||||
| (pd->overlay.flag & V3D_OVERLAY_HIDE_OBJECT_ORIGINS) == 0; | (pd->overlay.flag & V3D_OVERLAY_HIDE_OBJECT_ORIGINS) == 0; | ||||
| const bool draw_texspace = (ob->dtx & OB_TEXSPACE) && has_texspace; | const bool draw_texspace = (ob->dtx & OB_TEXSPACE) && has_texspace; | ||||
| const bool draw_obname = (ob->dtx & OB_DRAWNAME) && DRW_state_show_text(); | const bool draw_obname = (ob->dtx & OB_DRAWNAME) && DRW_state_show_text(); | ||||
| const bool draw_bounds = has_bounds && ((ob->dt == OB_BOUNDBOX) || | const bool draw_bounds = has_bounds && ((ob->dt == OB_BOUNDBOX) || | ||||
| ((ob->dtx & OB_DRAWBOUNDOX) && !from_dupli)); | ((ob->dtx & OB_DRAWBOUNDOX) && !from_dupli)); | ||||
| const bool draw_xform = draw_ctx->object_mode == OB_MODE_OBJECT && | const bool draw_xform = draw_ctx->object_mode == OB_MODE_OBJECT && | ||||
| (scene->toolsettings->transform_flag & SCE_XFORM_DATA_ORIGIN) && | (scene->toolsettings->transform_flag & SCE_XFORM_DATA_ORIGIN) && | ||||
| (ob->base_flag & BASE_SELECTED) && !is_select_mode; | (ob->base_flag & BASE_SELECTED) && !is_select_mode; | ||||
| /* Don't show fluid domain overlay extras outside of cache range. */ | /* Don't show fluid domain overlay extras outside of cache range. */ | ||||
| const bool draw_volume = !from_dupli && | const bool draw_volume = !from_dupli && | ||||
| (md = BKE_modifiers_findby_type(ob, eModifierType_Fluid)) && | (md = BKE_modifiers_findby_type(ob, eModifierType_Fluid)) && | ||||
| (BKE_modifier_is_enabled(scene, md, eModifierMode_Realtime)) && | (BKE_modifier_is_enabled(scene, md, eModifierMode_Realtime)) && | ||||
| (((FluidModifierData *)md)->domain != NULL) && | (((FluidModifierData *)md)->domain != nullptr) && | ||||
| (scene->r.cfra >= | (scene->r.cfra >= | ||||
| (((FluidModifierData *)md)->domain->cache_frame_start)) && | (((FluidModifierData *)md)->domain->cache_frame_start)) && | ||||
| (scene->r.cfra <= (((FluidModifierData *)md)->domain->cache_frame_end)); | (scene->r.cfra <= (((FluidModifierData *)md)->domain->cache_frame_end)); | ||||
| float *color; | float *color; | ||||
| int theme_id = DRW_object_wire_theme_get(ob, view_layer, &color); | int theme_id = DRW_object_wire_theme_get(ob, view_layer, &color); | ||||
| if (ob->pd && ob->pd->forcefield) { | if (ob->pd && ob->pd->forcefield) { | ||||
| Show All 17 Lines | if (draw_relations) { | ||||
| OVERLAY_relationship_lines(cb, draw_ctx->depsgraph, draw_ctx->scene, ob); | OVERLAY_relationship_lines(cb, draw_ctx->depsgraph, draw_ctx->scene, ob); | ||||
| } | } | ||||
| if (draw_obname) { | if (draw_obname) { | ||||
| OVERLAY_object_name(ob, theme_id); | OVERLAY_object_name(ob, theme_id); | ||||
| } | } | ||||
| if (draw_texspace) { | if (draw_texspace) { | ||||
| OVERLAY_texture_space(cb, ob, color); | OVERLAY_texture_space(cb, ob, color); | ||||
| } | } | ||||
| if (ob->rigidbody_object != NULL) { | if (ob->rigidbody_object != nullptr) { | ||||
| OVERLAY_collision(cb, ob, color); | OVERLAY_collision(cb, ob, color); | ||||
| } | } | ||||
| if (ob->dtx & OB_AXIS) { | if (ob->dtx & OB_AXIS) { | ||||
| DRW_buffer_add_entry(cb->empty_axes, color, ob->obmat); | DRW_buffer_add_entry(cb->empty_axes, color, ob->obmat); | ||||
| } | } | ||||
| if (draw_volume) { | if (draw_volume) { | ||||
| OVERLAY_volume_extra(cb, vedata, ob, md, scene, color); | OVERLAY_volume_extra(cb, vedata, ob, md, scene, color); | ||||
| } | } | ||||
| Show All 25 Lines | |||||