[Bf-blender-cvs] [e7d57628c9] blender2.8: OpenGL: keyframe shape fixes

Mike Erwin noreply at git.blender.org
Tue Feb 28 07:22:46 CET 2017


Commit: e7d57628c955c1843c70c8fc5023f5d8954847bd
Author: Mike Erwin
Date:   Tue Feb 28 01:21:27 2017 -0500
Branches: blender2.8
https://developer.blender.org/rBe7d57628c955c1843c70c8fc5023f5d8954847bd

OpenGL: keyframe shape fixes

- Size parameter is total size of the shape, not its radius (half size). Updated hard-coded sizes to match this.
- Shader expands size to include outline.
- Fixed fringe between outline color and transparent background.

===================================================================

M	source/blender/editors/animation/keyframes_draw.c
M	source/blender/editors/interface/interface_icons.c
M	source/blender/editors/space_nla/nla_draw.c
M	source/blender/gpu/shaders/gpu_shader_keyframe_diamond_frag.glsl
M	source/blender/gpu/shaders/gpu_shader_keyframe_diamond_vert.glsl

===================================================================

diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c
index c8d141eab0..5f96f95e95 100644
--- a/source/blender/editors/animation/keyframes_draw.c
+++ b/source/blender/editors/animation/keyframes_draw.c
@@ -470,7 +470,7 @@ void draw_keyframe_shape(float x, float y, float size, bool sel, short key_type,
 	bool draw_fill = ELEM(mode, KEYFRAME_SHAPE_INSIDE, KEYFRAME_SHAPE_BOTH);
 	bool draw_outline = ELEM(mode, KEYFRAME_SHAPE_FRAME, KEYFRAME_SHAPE_BOTH);
 
-	if (!(draw_fill || draw_outline)) return; /* TODO: assert this? */
+	BLI_assert(draw_fill || draw_outline);
 
 	/* tweak size of keyframe shape according to type of keyframe
 	 * - 'proper' keyframes have key_type = 0, so get drawn at full size
@@ -484,8 +484,7 @@ void draw_keyframe_shape(float x, float y, float size, bool sel, short key_type,
 			break;
 		
 		case BEZT_KEYTYPE_MOVEHOLD:  /* slightly smaller than normal keyframes (but by less than for breakdowns) */
-			//size *= 0.72f;
-			size *= 0.95f;
+			size *= 0.925f;
 			break;
 			
 		case BEZT_KEYTYPE_EXTREME:   /* slightly larger */
@@ -559,8 +558,9 @@ void draw_keyframe_shape(float x, float y, float size, bool sel, short key_type,
 
 static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, float ypos, float yscale_fac, bool channelLocked)
 {
-	const float iconsize = U.widget_unit * 0.25f * yscale_fac;
-	const float mhsize = iconsize * 0.7f;
+	const float icon_sz = U.widget_unit * 0.5f * yscale_fac;
+	const float half_icon_sz = 0.5f * icon_sz;
+	const float smaller_sz = 0.35f * icon_sz;
 	
 	glEnable(GL_BLEND);
 	
@@ -593,12 +593,12 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa
 				if (ab->flag & ACTKEYBLOCK_FLAG_MOVING_HOLD) {
 					/* draw "moving hold" long-keyframe block - slightly smaller */
 					immUniformColor4fv(ab->sel ? sel_mhcol : unsel_mhcol);
-					immRectf(pos_id, ab->start, ypos - mhsize, ab->end, ypos + mhsize);
+					immRectf(pos_id, ab->start, ypos - smaller_sz, ab->end, ypos + smaller_sz);
 				}
 				else {
 					/* draw standard long-keyframe block */
 					immUniformColor4fv(ab->sel ? sel_color : unsel_color);
-					immRectf(pos_id, ab->start, ypos - iconsize, ab->end, ypos + iconsize);
+					immRectf(pos_id, ab->start, ypos - half_icon_sz, ab->end, ypos + half_icon_sz);
 				}
 			}
 		}
@@ -629,7 +629,7 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa
 
 			for (ActKeyColumn *ak = keys->first; ak; ak = ak->next) {
 				if (IN_RANGE_INCL(ak->cfra, v2d->cur.xmin, v2d->cur.xmax)) {
-					draw_keyframe_shape(ak->cfra, ypos, iconsize, (ak->sel & SELECT), ak->key_type, KEYFRAME_SHAPE_BOTH, alpha,
+					draw_keyframe_shape(ak->cfra, ypos, icon_sz, (ak->sel & SELECT), ak->key_type, KEYFRAME_SHAPE_BOTH, alpha,
 					                    pos_id, size_id, color_id, outline_color_id);
 				}
 			}
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index 1c1e6cd357..526e73e33e 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -264,12 +264,12 @@ static void vicon_keytype_draw_wrapper(int x, int y, int w, int h, float alpha,
 	immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND);
 	GPU_enable_program_point_size();
 	immBegin(PRIM_POINTS, 1);
-	
+
 	/* draw keyframe
-	 * - size: 0.3 * h (found out experimentally... dunno why!)
+	 * - size: 0.6 * h (found out experimentally... dunno why!)
 	 * - sel: true (so that "keyframe" state shows the iconic yellow icon)
 	 */
-	draw_keyframe_shape(xco, yco, 0.3f * h, true, key_type, KEYFRAME_SHAPE_BOTH, alpha,
+	draw_keyframe_shape(xco, yco, 0.6f * h, true, key_type, KEYFRAME_SHAPE_BOTH, alpha,
 	                    pos_id, size_id, color_id, outline_color_id);
 
 	immEnd();
diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c
index e744a39fde..65582b994e 100644
--- a/source/blender/editors/space_nla/nla_draw.c
+++ b/source/blender/editors/space_nla/nla_draw.c
@@ -150,11 +150,11 @@ static void nla_action_draw_keyframes(AnimData *adt, bAction *act, float y, floa
 		immBegin(PRIM_POINTS, key_ct);
 
 		/* - disregard the selection status of keyframes so they draw a certain way
-		 *	- size is 3.0f which is smaller than the editable keyframes, so that there is a distinction
+		 *	- size is 6.0f which is smaller than the editable keyframes, so that there is a distinction
 		 */
 		for (ActKeyColumn *ak = keys.first; ak; ak = ak->next) {
-			draw_keyframe_shape(ak->cfra, y, 3.0f, false, ak->key_type, KEYFRAME_SHAPE_FRAME, 1.0f,
-									  pos_id, size_id, color_id, outline_color_id);
+			draw_keyframe_shape(ak->cfra, y, 6.0f, false, ak->key_type, KEYFRAME_SHAPE_FRAME, 1.0f,
+			                    pos_id, size_id, color_id, outline_color_id);
 		}
 
 		immEnd();
diff --git a/source/blender/gpu/shaders/gpu_shader_keyframe_diamond_frag.glsl b/source/blender/gpu/shaders/gpu_shader_keyframe_diamond_frag.glsl
index 43a7e42153..ebda79558c 100644
--- a/source/blender/gpu/shaders/gpu_shader_keyframe_diamond_frag.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_keyframe_diamond_frag.glsl
@@ -29,7 +29,7 @@ void main() {
 
 	float mid_stroke = 0.5 * (radii[1] + radii[2]);
 
-	vec4 backgroundColor = vec4(finalColor.rgb, 0.0);
+	vec4 backgroundColor = vec4(finalOutlineColor.rgb, 0.0);
 
 	if (dist > mid_stroke)
 		fragColor = mix(finalOutlineColor, backgroundColor, smoothstep(radii[1], radii[0], dist));
diff --git a/source/blender/gpu/shaders/gpu_shader_keyframe_diamond_vert.glsl b/source/blender/gpu/shaders/gpu_shader_keyframe_diamond_vert.glsl
index 69afefa685..6f33491af5 100644
--- a/source/blender/gpu/shaders/gpu_shader_keyframe_diamond_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_keyframe_diamond_vert.glsl
@@ -26,7 +26,7 @@ void main() {
 	gl_Position = ModelViewProjectionMatrix * vec4(pos, 0.0, 1.0);
 
 	// pass through unchanged
-	gl_PointSize = size;
+	gl_PointSize = size + pixel_fudge; // 0.5 pixel_fudge on either side
 	finalColor = color;
 	finalOutlineColor = outlineColor;




More information about the Bf-blender-cvs mailing list