Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <mail@jlucke.com>2019-02-21 15:28:21 +0300
committerJacques Lucke <mail@jlucke.com>2019-02-21 15:28:53 +0300
commit4f0b61f15bb46bfb8a949b314d05130c0425c816 (patch)
tree13e2785805b3a1985fc1f1c2bdc20e76d575fdd2 /source/blender/draw/intern/draw_anim_viz.c
parentd542c6a5f3ea7b668c46d9dade20d0af23c090b2 (diff)
Fix T61791: Motion path step is not taken into account
Diffstat (limited to 'source/blender/draw/intern/draw_anim_viz.c')
-rw-r--r--source/blender/draw/intern/draw_anim_viz.c81
1 files changed, 37 insertions, 44 deletions
diff --git a/source/blender/draw/intern/draw_anim_viz.c b/source/blender/draw/intern/draw_anim_viz.c
index 2c2f1a7f0fd..2689d2726d8 100644
--- a/source/blender/draw/intern/draw_anim_viz.c
+++ b/source/blender/draw/intern/draw_anim_viz.c
@@ -142,6 +142,33 @@ static void MPATH_cache_init(void *vedata)
}
}
+static void MPATH_get_frame_range_to_draw(
+ bAnimVizSettings *avs, bMotionPath *mpath, int current_frame,
+ int *r_start, int *r_end, int *r_step)
+{
+ int start, end;
+
+ if (avs->path_type == MOTIONPATH_TYPE_ACFRA) {
+ start = current_frame - avs->path_bc;
+ end = current_frame + avs->path_ac + 1;
+ }
+ else {
+ start = avs->path_sf;
+ end = avs->path_ef;
+ }
+
+ if (start > end) {
+ SWAP(int, start, end);
+ }
+
+ CLAMP(start, mpath->start_frame, mpath->end_frame);
+ CLAMP(end, mpath->start_frame, mpath->end_frame);
+
+ *r_start = start;
+ *r_end = end;
+ *r_step = max_ii(avs->path_step, 1);
+}
+
static void MPATH_cache_motion_path(MPATH_PassList *psl,
Object *ob, bPoseChannel *pchan,
bAnimVizSettings *avs, bMotionPath *mpath)
@@ -149,53 +176,18 @@ static void MPATH_cache_motion_path(MPATH_PassList *psl,
const DRWContextState *draw_ctx = DRW_context_state_get();
struct DRWTextStore *dt = DRW_text_cache_ensure();
int txt_flag = DRW_TEXT_CACHE_GLOBALSPACE | DRW_TEXT_CACHE_ASCII;
- int stepsize = avs->path_step;
- int sfra, efra, sind, len;
int cfra = (int)DEG_get_ctime(draw_ctx->depsgraph);
bool sel = (pchan) ? (pchan->bone->flag & BONE_SELECTED) : (ob->flag & SELECT);
bool show_keyframes = (avs->path_viewflag & MOTIONPATH_VIEW_KFRAS) != 0;
- bMotionPathVert *mpv, *mpv_start;
- /* get frame ranges */
- if (avs->path_type == MOTIONPATH_TYPE_ACFRA) {
- /* With "Around Current", we only choose frames from around
- * the current frame to draw.
- */
- sfra = cfra - avs->path_bc;
- efra = cfra + avs->path_ac + 1;
- }
- else {
- /* Use the current display range */
- sfra = avs->path_sf;
- efra = avs->path_ef;
- }
-
- /* no matter what, we can only show what is in the cache and no more
- * - abort if whole range is past ends of path
- * - otherwise clamp endpoints to extents of path
- */
- if (sfra < mpath->start_frame) {
- /* start clamp */
- sfra = mpath->start_frame;
- }
- if (efra > mpath->end_frame) {
- /* end clamp */
- efra = mpath->end_frame;
- }
-
- if ((sfra > mpath->end_frame) || (efra < mpath->start_frame)) {
- /* whole path is out of bounds */
- return;
- }
-
- len = efra - sfra;
+ int sfra, efra, stepsize;
+ MPATH_get_frame_range_to_draw(avs, mpath, cfra, &sfra, &efra, &stepsize);
- if ((len <= 0) || (mpath->points == NULL)) {
+ int len = efra - sfra;
+ if (len == 0) {
return;
}
-
- sind = sfra - mpath->start_frame;
- mpv_start = (mpath->points + sind);
+ int start_index = sfra - mpath->start_frame;
bool use_custom_col = (mpath->flag & MOTIONPATH_FLAG_CUSTOM) != 0;
@@ -216,16 +208,15 @@ static void MPATH_cache_motion_path(MPATH_PassList *psl,
DRW_shgroup_uniform_vec3(shgrp, "customColor", mpath->color, 1);
}
/* Only draw the required range. */
- DRW_shgroup_call_range_add(shgrp, mpath_batch_line_get(mpath), NULL, sind, len);
+ DRW_shgroup_call_range_add(shgrp, mpath_batch_line_get(mpath), NULL, start_index, len);
}
/* Draw points. */
DRWShadingGroup *shgrp = DRW_shgroup_create(mpath_points_shader_get(), psl->points);
DRW_shgroup_uniform_int_copy(shgrp, "frameCurrent", cfra);
DRW_shgroup_uniform_int_copy(shgrp, "cacheStart", mpath->start_frame);
- DRW_shgroup_uniform_int_copy(shgrp, "pointSize", mpath->line_thickness);
+ DRW_shgroup_uniform_int_copy(shgrp, "pointSize", max_ii(mpath->line_thickness - 1, 1));
DRW_shgroup_uniform_int_copy(shgrp, "stepSize", stepsize);
- DRW_shgroup_uniform_bool_copy(shgrp, "selected", sel);
DRW_shgroup_uniform_bool_copy(shgrp, "showKeyFrames", show_keyframes);
DRW_shgroup_uniform_bool_copy(shgrp, "useCustomColor", use_custom_col);
DRW_shgroup_uniform_block(shgrp, "globalsBlock", G_draw.block_ubo);
@@ -233,7 +224,7 @@ static void MPATH_cache_motion_path(MPATH_PassList *psl,
DRW_shgroup_uniform_vec3(shgrp, "customColor", mpath->color, 1);
}
/* Only draw the required range. */
- DRW_shgroup_call_range_add(shgrp, mpath_batch_points_get(mpath), NULL, sind, len);
+ DRW_shgroup_call_range_add(shgrp, mpath_batch_points_get(mpath), NULL, start_index, len);
/* Draw frame numbers at each framestep value */
bool show_kf_no = (avs->path_viewflag & MOTIONPATH_VIEW_KFNOS) != 0;
@@ -244,6 +235,8 @@ static void MPATH_cache_motion_path(MPATH_PassList *psl,
UI_GetThemeColor3ubv(TH_VERTEX_SELECT, col_kf);
col[3] = col_kf[3] = 255;
+ bMotionPathVert *mpv;
+ bMotionPathVert *mpv_start = mpath->points + start_index;
for (i = 0, mpv = mpv_start; i < len; i += stepsize, mpv += stepsize) {
int frame = sfra + i;
char numstr[32];