[Bf-blender-cvs] [4b080ff18f4] blender2.8: Cleanup: Make access to widget triangle defines explicit

Julian Eisel noreply at git.blender.org
Sun Apr 15 21:38:11 CEST 2018


Commit: 4b080ff18f4cdfc8f10734b928f4389737b6d487
Author: Julian Eisel
Date:   Sun Apr 15 21:32:04 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB4b080ff18f4cdfc8f10734b928f4389737b6d487

Cleanup: Make access to widget triangle defines explicit

E.g. the vertices created for each of the defines would require a
certain offset. If you don't know what to look for, finding out about
this is pretty difficult. Make them easily searchable instead.

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

M	source/blender/editors/interface/interface_widgets.c
M	source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl

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

diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index e2fd903243a..d72e59beb91 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -221,8 +221,22 @@ static const uint g_shape_preset_hold_action_face[2][3] = {{2, 0, 1}, {3, 5, 4}}
  **/
 
 /* offset in triavec[] in shader per type */
-static const int tria_ofs[ROUNDBOX_TRIA_MAX] = {0, 0, 6, 22, 28, 34};
-static const int tria_vcount[ROUNDBOX_TRIA_MAX] = {0, 3, 16, 3, 6, 3};
+static const int tria_ofs[ROUNDBOX_TRIA_MAX] = {
+	[ROUNDBOX_TRIA_NONE]              = 0,
+	[ROUNDBOX_TRIA_ARROWS]            = 0,
+	[ROUNDBOX_TRIA_SCROLL]            = 6,
+	[ROUNDBOX_TRIA_MENU]              = 22,
+	[ROUNDBOX_TRIA_CHECK]             = 28,
+	[ROUNDBOX_TRIA_HOLD_ACTION_ARROW] = 34,
+};
+static const int tria_vcount[ROUNDBOX_TRIA_MAX] = {
+	[ROUNDBOX_TRIA_NONE]              = 0,
+	[ROUNDBOX_TRIA_ARROWS]            = 3,
+	[ROUNDBOX_TRIA_SCROLL]            = 16,
+	[ROUNDBOX_TRIA_MENU]              = 3,
+	[ROUNDBOX_TRIA_CHECK]             = 6,
+	[ROUNDBOX_TRIA_HOLD_ACTION_ARROW] = 3,
+};
 
 static struct {
 	Gwn_Batch *roundbox_widget[ROUNDBOX_TRIA_MAX];
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl
index 1c8c0ad3850..107480580f9 100644
--- a/source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl
@@ -48,10 +48,10 @@ const vec2 jit[9] = vec2[9](
 /* We can reuse the CORNER_* bits for tria */
 #define TRIA_VEC_RANGE BIT_RANGE(6)
 const vec2 triavec[37] = vec2[37](
-	/* horizontal tria */
+	/* ROUNDBOX_TRIA_ARROWS */
 	vec2(-0.352077, 0.532607), vec2(-0.352077, -0.549313), vec2( 0.330000, -0.008353),
 	vec2( 0.352077, 0.532607), vec2( 0.352077, -0.549313), vec2(-0.330000, -0.008353),
-	/* circle tria (triangle strip) */
+	/* ROUNDBOX_TRIA_SCROLL - circle tria (triangle strip) */
 	vec2(0.000000, 1.000000),
 	vec2(0.382684, 0.923879), vec2(-0.382683, 0.923880),
 	vec2(0.707107, 0.707107), vec2(-0.707107, 0.707107),
@@ -61,13 +61,13 @@ const vec2 triavec[37] = vec2[37](
 	vec2(0.707107, -0.707107), vec2(-0.707107, -0.707107),
 	vec2(0.382684, -0.923879), vec2(-0.382683, -0.923880),
 	vec2(0.000000, -1.000000),
-	/* menu arrow */
+	/* ROUNDBOX_TRIA_MENU - menu arrows */
 	vec2(-0.33, 0.16), vec2(0.33, 0.16), vec2(0.0, 0.82),
 	vec2(0.0, -0.82), vec2(-0.33, -0.16), vec2(0.33, -0.16),
-	/* check mark */
+	/* ROUNDBOX_TRIA_CHECK - check mark */
 	vec2(-0.578579, 0.253369),  vec2(-0.392773, 0.412794),  vec2(-0.004241, -0.328551),
 	vec2(-0.003001, 0.034320),  vec2(1.055313, 0.864744),   vec2(0.866408, 1.026895),
-	/* hold action arrow */
+	/* ROUNDBOX_TRIA_HOLD_ACTION_ARROW - hold action arrows */
 #define OY -0.2
 #define SC 0.35
 //	vec2(-0.5 + SC, 1.0 + OY),  vec2( 0.5, 1.0 + OY),  vec2( 0.5, 0.0 + OY + SC),



More information about the Bf-blender-cvs mailing list