[Bf-blender-cvs] [4f0b61f15bb] master: Fix T61791: Motion path step is not taken into account
Jacques Lucke
noreply at git.blender.org
Thu Feb 21 13:29:42 CET 2019
Commit: 4f0b61f15bb46bfb8a949b314d05130c0425c816
Author: Jacques Lucke
Date: Thu Feb 21 13:28:21 2019 +0100
Branches: master
https://developer.blender.org/rB4f0b61f15bb46bfb8a949b314d05130c0425c816
Fix T61791: Motion path step is not taken into account
===================================================================
M source/blender/draw/intern/draw_anim_viz.c
M source/blender/draw/modes/shaders/animviz_mpath_points_vert.glsl
===================================================================
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];
diff --git a/source/blender/draw/modes/shaders/animviz_mpath_points_vert.glsl b/source/blender/draw/modes/shaders/animviz_mpath_points_vert.glsl
index 3b2f170ca22..f662cf5afde 100644
--- a/source/blender/draw/modes/shaders/animviz_mpath_points_vert.glsl
+++ b/source/blender/draw/modes/shaders/animviz_mpath_points_vert.glsl
@@ -7,6 +7,7 @@ uniform int cacheStart;
uniform bool showKeyFrames = true;
uniform bool useCustomColor;
uniform vec3 customColor;
+uniform int stepSize;
in vec3 pos;
in int flag;
@@ -27,6 +28,10 @@ void main()
/* Bias to reduce z fighting with the path */
gl_Position.z -= 1e-4;
+ if (gl_VertexID % stepSize == 0) {
+ gl_PointSize = float(pointSize) + 4;
+ }
+
if (showKeyFrames) {
if ((flag & MOTIONPATH_VERT_KEY) != 0) {
gl_PointSize = float(pointSize + 5);
More information about the Bf-blender-cvs
mailing list