Fix error cutting node links
Accessing theme from outside drawing code isn't reliable, pass space-type.
This commit is contained in:
parent
833ef0cfdd
commit
46f452e96b
|
@ -334,6 +334,9 @@ void UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, int
|
|||
float UI_GetThemeValuef(int colorid);
|
||||
int UI_GetThemeValue(int colorid);
|
||||
|
||||
float UI_GetThemeValueTypef(int colorid, int spacetype);
|
||||
int UI_GetThemeValueType(int colorid, int spacetype);
|
||||
|
||||
// get three color values, scaled to 0.0-1.0 range
|
||||
void UI_GetThemeColor3fv(int colorid, float col[3]);
|
||||
void UI_GetThemeColorBlend3ubv(int colorid1, int colorid2, float fac, unsigned char col[3]);
|
||||
|
|
|
@ -1382,6 +1382,23 @@ int UI_GetThemeValue(int colorid)
|
|||
return ((int) cp[0]);
|
||||
}
|
||||
|
||||
/* versions of the function above, which take a space-type */
|
||||
float UI_GetThemeValueTypef(int colorid, int spacetype)
|
||||
{
|
||||
const unsigned char *cp;
|
||||
|
||||
cp = UI_ThemeGetColorPtr(theme_active, spacetype, colorid);
|
||||
return ((float)cp[0]);
|
||||
}
|
||||
|
||||
int UI_GetThemeValueType(int colorid, int spacetype)
|
||||
{
|
||||
const unsigned char *cp;
|
||||
|
||||
cp = UI_ThemeGetColorPtr(theme_active, spacetype, colorid);
|
||||
return ((int)cp[0]);
|
||||
}
|
||||
|
||||
|
||||
/* get the color, range 0.0-1.0 */
|
||||
void UI_GetThemeColor3fv(int colorid, float col[3])
|
||||
|
|
|
@ -3335,7 +3335,7 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b
|
|||
|
||||
|
||||
/* if v2d not NULL, it clips and returns 0 if not visible */
|
||||
int node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, float coord_array[][2], int resol)
|
||||
bool node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, float coord_array[][2], int resol)
|
||||
{
|
||||
float dist, vec[4][2];
|
||||
float deltax, deltay;
|
||||
|
@ -3371,7 +3371,8 @@ int node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, floa
|
|||
toreroute = 0;
|
||||
}
|
||||
|
||||
dist = UI_GetThemeValue(TH_NODE_CURVING) * 0.10f * fabsf(vec[0][0] - vec[3][0]);
|
||||
/* may be called outside of drawing (so pass spacetype) */
|
||||
dist = UI_GetThemeValueType(TH_NODE_CURVING, SPACE_NODE) * 0.10f * fabsf(vec[0][0] - vec[3][0]);
|
||||
deltax = vec[3][0] - vec[0][0];
|
||||
deltay = vec[3][1] - vec[0][1];
|
||||
/* check direction later, for top sockets */
|
||||
|
|
|
@ -133,7 +133,7 @@ void NODE_OT_backimage_sample(struct wmOperatorType *ot);
|
|||
/* drawnode.c */
|
||||
void node_draw_link(struct View2D *v2d, struct SpaceNode *snode, struct bNodeLink *link);
|
||||
void node_draw_link_bezier(struct View2D *v2d, struct SpaceNode *snode, struct bNodeLink *link, int th_col1, bool do_shaded, int th_col2, bool do_triple, int th_col3);
|
||||
int node_link_bezier_points(struct View2D *v2d, struct SpaceNode *snode, struct bNodeLink *link, float coord_array[][2], int resol);
|
||||
bool node_link_bezier_points(struct View2D *v2d, struct SpaceNode *snode, struct bNodeLink *link, float coord_array[][2], int resol);
|
||||
// void node_draw_link_straight(View2D *v2d, SpaceNode *snode, bNodeLink *link, int th_col1, int do_shaded, int th_col2, int do_triple, int th_col3 );
|
||||
void draw_nodespace_back_pix(const struct bContext *C, struct ARegion *ar, struct SpaceNode *snode, bNodeInstanceKey parent_key);
|
||||
|
||||
|
|
|
@ -849,7 +849,7 @@ void NODE_OT_link_make(wmOperatorType *ot)
|
|||
}
|
||||
|
||||
/* ********************** Cut Link operator ***************** */
|
||||
static int cut_links_intersect(bNodeLink *link, float mcoords[][2], int tot)
|
||||
static bool cut_links_intersect(bNodeLink *link, float mcoords[][2], int tot)
|
||||
{
|
||||
float coord_array[NODE_LINK_RESOL + 1][2];
|
||||
int i, b;
|
||||
|
|
Loading…
Reference in New Issue