Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_node/drawnode.c
| Context not available. | |||||
| GPUBatch *batch_single; /* for single line */ | GPUBatch *batch_single; /* for single line */ | ||||
| GPUVertBuf *inst_vbo; | GPUVertBuf *inst_vbo; | ||||
| uint p0_id, p1_id, p2_id, p3_id; | uint p0_id, p1_id, p2_id, p3_id; | ||||
| uint colid_id; | uint colid_id, start_color_id, end_color_id; | ||||
| GPUVertBufRaw p0_step, p1_step, p2_step, p3_step; | GPUVertBufRaw p0_step, p1_step, p2_step, p3_step; | ||||
| GPUVertBufRaw colid_step; | GPUVertBufRaw colid_step, start_color_step, end_color_step; | ||||
| uint count; | uint count; | ||||
| bool enabled; | bool enabled; | ||||
| } g_batch_link = {0}; | } g_batch_link = {0}; | ||||
| Context not available. | |||||
| GPU_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.p3_id, &g_batch_link.p3_step); | GPU_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.p3_id, &g_batch_link.p3_step); | ||||
| GPU_vertbuf_attr_get_raw_data( | GPU_vertbuf_attr_get_raw_data( | ||||
| g_batch_link.inst_vbo, g_batch_link.colid_id, &g_batch_link.colid_step); | g_batch_link.inst_vbo, g_batch_link.colid_id, &g_batch_link.colid_step); | ||||
| GPU_vertbuf_attr_get_raw_data( | |||||
| g_batch_link.inst_vbo, g_batch_link.start_color_id, &g_batch_link.start_color_step); | |||||
| GPU_vertbuf_attr_get_raw_data( | |||||
| g_batch_link.inst_vbo, g_batch_link.end_color_id, &g_batch_link.end_color_step); | |||||
| g_batch_link.count = 0; | g_batch_link.count = 0; | ||||
| } | } | ||||
| Context not available. | |||||
| &format_inst, "P3", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | &format_inst, "P3", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| g_batch_link.colid_id = GPU_vertformat_attr_add( | g_batch_link.colid_id = GPU_vertformat_attr_add( | ||||
| &format_inst, "colid_doarrow", GPU_COMP_U8, 4, GPU_FETCH_INT); | &format_inst, "colid_doarrow", GPU_COMP_U8, 4, GPU_FETCH_INT); | ||||
| g_batch_link.start_color_id = GPU_vertformat_attr_add( | |||||
| &format_inst, "start_color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); | |||||
| g_batch_link.end_color_id = GPU_vertformat_attr_add( | |||||
| &format_inst, "end_color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); | |||||
| g_batch_link.inst_vbo = GPU_vertbuf_create_with_format_ex(&format_inst, GPU_USAGE_STREAM); | g_batch_link.inst_vbo = GPU_vertbuf_create_with_format_ex(&format_inst, GPU_USAGE_STREAM); | ||||
| /* Alloc max count but only draw the range we need. */ | /* Alloc max count but only draw the range we need. */ | ||||
| GPU_vertbuf_data_alloc(g_batch_link.inst_vbo, NODELINK_GROUP_SIZE); | GPU_vertbuf_data_alloc(g_batch_link.inst_vbo, NODELINK_GROUP_SIZE); | ||||
| Context not available. | |||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| float colors[6][4] = {{0.0f}}; | float colors[6][4] = {{0.0f}}; | ||||
| UI_GetThemeColor4fv(TH_WIRE_INNER, colors[nodelink_get_color_id(TH_WIRE_INNER)]); | UI_GetThemeColor4fv(TH_WIRE_INNER, colors[nodelink_get_color_id(TH_WIRE_INNER)]); | ||||
| UI_GetThemeColor4fv(TH_WIRE, colors[nodelink_get_color_id(TH_WIRE)]); | UI_GetThemeColor4fv(TH_WIRE, colors[nodelink_get_color_id(TH_WIRE)]); | ||||
| UI_GetThemeColor4fv(TH_ACTIVE, colors[nodelink_get_color_id(TH_ACTIVE)]); | UI_GetThemeColor4fv(TH_ACTIVE, colors[nodelink_get_color_id(TH_ACTIVE)]); | ||||
| Context not available. | |||||
| int th_col1, | int th_col1, | ||||
| int th_col2, | int th_col2, | ||||
| int th_col3, | int th_col3, | ||||
| const float start_color[4], | |||||
| const float end_color[4], | |||||
| bool drawarrow) | bool drawarrow) | ||||
| { | { | ||||
| /* Only allow these colors. If more is needed, you need to modify the shader accordingly. */ | /* Only allow these colors. If more is needed, you need to modify the shader accordingly. */ | ||||
| Context not available. | |||||
| colid[1] = nodelink_get_color_id(th_col2); | colid[1] = nodelink_get_color_id(th_col2); | ||||
| colid[2] = nodelink_get_color_id(th_col3); | colid[2] = nodelink_get_color_id(th_col3); | ||||
| colid[3] = drawarrow; | colid[3] = drawarrow; | ||||
| copy_v4_v4(GPU_vertbuf_raw_step(&g_batch_link.start_color_step), start_color); | |||||
| copy_v4_v4(GPU_vertbuf_raw_step(&g_batch_link.end_color_step), end_color); | |||||
| if (g_batch_link.count == NODELINK_GROUP_SIZE) { | if (g_batch_link.count == NODELINK_GROUP_SIZE) { | ||||
| nodelink_batch_draw(snode); | nodelink_batch_draw(snode); | ||||
| Context not available. | |||||
| if (g_batch_link.enabled) { | if (g_batch_link.enabled) { | ||||
| /* Add link to batch. */ | /* Add link to batch. */ | ||||
| nodelink_batch_add_link( | nodelink_batch_add_link( | ||||
| snode, vec[0], vec[1], vec[2], vec[3], th_col1, th_col2, th_col3, drawarrow); | snode, | ||||
| vec[0], | |||||
| vec[1], | |||||
| vec[2], | |||||
| vec[3], | |||||
| th_col1, | |||||
| th_col2, | |||||
| th_col3, | |||||
| std_node_socket_colors[link->fromsock->typeinfo->type], | |||||
| std_node_socket_colors[link->tosock->typeinfo->type], | |||||
| drawarrow); | |||||
| } | } | ||||
| else { | else { | ||||
| /* Draw single link. */ | /* Draw single link. */ | ||||
| Context not available. | |||||
| if (th_col3 != -1) { | if (th_col3 != -1) { | ||||
| UI_GetThemeColor4fv(th_col3, colors[0]); | UI_GetThemeColor4fv(th_col3, colors[0]); | ||||
| } | } | ||||
| UI_GetThemeColor4fv(th_col1, colors[1]); | |||||
| UI_GetThemeColor4fv(th_col2, colors[2]); | if (link->fromsock) { | ||||
| copy_v4_v4(colors[1], std_node_socket_colors[link->fromsock->typeinfo->type]); | |||||
| } | |||||
| else { | |||||
| copy_v4_v4(colors[1], std_node_socket_colors[link->tosock->typeinfo->type]); | |||||
| } | |||||
| if (link->tosock) { | |||||
| copy_v4_v4(colors[2], std_node_socket_colors[link->tosock->typeinfo->type]); | |||||
| } | |||||
| else { | |||||
| copy_v4_v4(colors[2], std_node_socket_colors[link->fromsock->typeinfo->type]); | |||||
| } | |||||
| GPUBatch *batch = g_batch_link.batch_single; | GPUBatch *batch = g_batch_link.batch_single; | ||||
| GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_NODELINK); | GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_NODELINK); | ||||
| Context not available. | |||||