Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/overlay/overlay_motion_path.cc
- This file was moved from source/blender/draw/engines/overlay/overlay_motion_path.c.
| Show All 14 Lines | |||||
| #include "DEG_depsgraph_query.h" | #include "DEG_depsgraph_query.h" | ||||
| #include "GPU_batch.h" | #include "GPU_batch.h" | ||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "draw_manager_text.h" | #include "draw_manager_text.h" | ||||
| #include "overlay_private.h" | #include "overlay_private.hh" | ||||
| void OVERLAY_motion_path_cache_init(OVERLAY_Data *vedata) | void OVERLAY_motion_path_cache_init(OVERLAY_Data *vedata) | ||||
| { | { | ||||
| OVERLAY_PassList *psl = vedata->psl; | OVERLAY_PassList *psl = vedata->psl; | ||||
| OVERLAY_PrivateData *pd = vedata->stl->pd; | OVERLAY_PrivateData *pd = vedata->stl->pd; | ||||
| DRWShadingGroup *grp; | DRWShadingGroup *grp; | ||||
| GPUShader *sh; | GPUShader *sh; | ||||
| Show All 26 Lines | memcpy(GPU_vertbuf_get_data(mpath->points_vbo), | ||||
| sizeof(bMotionPathVert) * mpath->length); | sizeof(bMotionPathVert) * mpath->length); | ||||
| } | } | ||||
| return mpath->points_vbo; | return mpath->points_vbo; | ||||
| } | } | ||||
| static GPUBatch *mpath_batch_line_get(bMotionPath *mpath) | static GPUBatch *mpath_batch_line_get(bMotionPath *mpath) | ||||
| { | { | ||||
| if (!mpath->batch_line) { | if (!mpath->batch_line) { | ||||
| mpath->batch_line = GPU_batch_create(GPU_PRIM_LINE_STRIP, mpath_vbo_get(mpath), NULL); | mpath->batch_line = GPU_batch_create(GPU_PRIM_LINE_STRIP, mpath_vbo_get(mpath), nullptr); | ||||
| } | } | ||||
| return mpath->batch_line; | return mpath->batch_line; | ||||
| } | } | ||||
| static GPUBatch *mpath_batch_points_get(bMotionPath *mpath) | static GPUBatch *mpath_batch_points_get(bMotionPath *mpath) | ||||
| { | { | ||||
| if (!mpath->batch_points) { | if (!mpath->batch_points) { | ||||
| mpath->batch_points = GPU_batch_create(GPU_PRIM_POINTS, mpath_vbo_get(mpath), NULL); | mpath->batch_points = GPU_batch_create(GPU_PRIM_POINTS, mpath_vbo_get(mpath), nullptr); | ||||
| } | } | ||||
| return mpath->batch_points; | return mpath->batch_points; | ||||
| } | } | ||||
| static void motion_path_get_frame_range_to_draw(bAnimVizSettings *avs, | static void motion_path_get_frame_range_to_draw(bAnimVizSettings *avs, | ||||
| bMotionPath *mpath, | bMotionPath *mpath, | ||||
| int current_frame, | int current_frame, | ||||
| int *r_start, | int *r_start, | ||||
| ▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | static void motion_path_cache(OVERLAY_Data *vedata, | ||||
| if (show_lines) { | if (show_lines) { | ||||
| const int motion_path_settings[4] = {cfra, sfra, efra, mpath->start_frame}; | const int motion_path_settings[4] = {cfra, sfra, efra, mpath->start_frame}; | ||||
| DRWShadingGroup *grp = DRW_shgroup_create_sub(pd->motion_path_lines_grp); | DRWShadingGroup *grp = DRW_shgroup_create_sub(pd->motion_path_lines_grp); | ||||
| DRW_shgroup_uniform_ivec4_copy(grp, "mpathLineSettings", motion_path_settings); | DRW_shgroup_uniform_ivec4_copy(grp, "mpathLineSettings", motion_path_settings); | ||||
| DRW_shgroup_uniform_int_copy(grp, "lineThickness", mpath->line_thickness); | DRW_shgroup_uniform_int_copy(grp, "lineThickness", mpath->line_thickness); | ||||
| DRW_shgroup_uniform_bool_copy(grp, "selected", selected); | DRW_shgroup_uniform_bool_copy(grp, "selected", selected); | ||||
| DRW_shgroup_uniform_vec3_copy(grp, "customColor", color); | DRW_shgroup_uniform_vec3_copy(grp, "customColor", color); | ||||
| /* Only draw the required range. */ | /* Only draw the required range. */ | ||||
| DRW_shgroup_call_range(grp, NULL, mpath_batch_line_get(mpath), start_index, len); | DRW_shgroup_call_range(grp, nullptr, mpath_batch_line_get(mpath), start_index, len); | ||||
| } | } | ||||
| /* Draw points. */ | /* Draw points. */ | ||||
| { | { | ||||
| int pt_size = max_ii(mpath->line_thickness - 1, 1); | int pt_size = max_ii(mpath->line_thickness - 1, 1); | ||||
| const int motion_path_settings[4] = {pt_size, cfra, mpath->start_frame, stepsize}; | const int motion_path_settings[4] = {pt_size, cfra, mpath->start_frame, stepsize}; | ||||
| DRWShadingGroup *grp = DRW_shgroup_create_sub(pd->motion_path_points_grp); | DRWShadingGroup *grp = DRW_shgroup_create_sub(pd->motion_path_points_grp); | ||||
| DRW_shgroup_uniform_ivec4_copy(grp, "mpathPointSettings", motion_path_settings); | DRW_shgroup_uniform_ivec4_copy(grp, "mpathPointSettings", motion_path_settings); | ||||
| DRW_shgroup_uniform_bool_copy(grp, "showKeyFrames", show_keyframes); | DRW_shgroup_uniform_bool_copy(grp, "showKeyFrames", show_keyframes); | ||||
| DRW_shgroup_uniform_vec3_copy(grp, "customColor", color); | DRW_shgroup_uniform_vec3_copy(grp, "customColor", color); | ||||
| /* Only draw the required range. */ | /* Only draw the required range. */ | ||||
| DRW_shgroup_call_range(grp, NULL, mpath_batch_points_get(mpath), start_index, len); | DRW_shgroup_call_range(grp, nullptr, mpath_batch_points_get(mpath), start_index, len); | ||||
| } | } | ||||
| /* Draw frame numbers at each frame-step value. */ | /* Draw frame numbers at each frame-step value. */ | ||||
| if (show_frame_no || (show_keyframes_no && show_keyframes)) { | if (show_frame_no || (show_keyframes_no && show_keyframes)) { | ||||
| int i; | int i; | ||||
| uchar col[4], col_kf[4]; | uchar col[4], col_kf[4]; | ||||
| /* Color Management: Exception here as texts are drawn in sRGB space directly. */ | /* Color Management: Exception here as texts are drawn in sRGB space directly. */ | ||||
| UI_GetThemeColor3ubv(TH_TEXT_HI, col); | UI_GetThemeColor3ubv(TH_TEXT_HI, col); | ||||
| Show All 36 Lines | if (OVERLAY_armature_is_pose_mode(ob, draw_ctx)) { | ||||
| if (pchan->mpath) { | if (pchan->mpath) { | ||||
| motion_path_cache(vedata, ob, pchan, &ob->pose->avs, pchan->mpath); | motion_path_cache(vedata, ob, pchan, &ob->pose->avs, pchan->mpath); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (ob->mpath) { | if (ob->mpath) { | ||||
| motion_path_cache(vedata, ob, NULL, &ob->avs, ob->mpath); | motion_path_cache(vedata, ob, nullptr, &ob->avs, ob->mpath); | ||||
| } | } | ||||
| } | } | ||||
| void OVERLAY_motion_path_draw(OVERLAY_Data *vedata) | void OVERLAY_motion_path_draw(OVERLAY_Data *vedata) | ||||
| { | { | ||||
| OVERLAY_PassList *psl = vedata->psl; | OVERLAY_PassList *psl = vedata->psl; | ||||
| DRW_draw_pass(psl->motion_paths_ps); | DRW_draw_pass(psl->motion_paths_ps); | ||||
| } | } | ||||