Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/view3d_cursor_snap.c
| Show First 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | #endif | ||||
| struct wmPaintCursor *handle; | struct wmPaintCursor *handle; | ||||
| bool is_initiated; | bool is_initiated; | ||||
| } SnapCursorDataIntern; | } SnapCursorDataIntern; | ||||
| static SnapCursorDataIntern g_data_intern = { | static SnapCursorDataIntern g_data_intern = { | ||||
| .state_default = {.prevpoint = NULL, | .state_default = {.prevpoint = NULL, | ||||
| .snap_elem_force = (SCE_SNAP_MODE_VERTEX | SCE_SNAP_MODE_EDGE | | .snap_elem_force = SCE_SNAP_MODE_GEOM, | ||||
| SCE_SNAP_MODE_FACE | SCE_SNAP_MODE_EDGE_PERPENDICULAR | | |||||
| SCE_SNAP_MODE_EDGE_MIDPOINT), | |||||
| .plane_axis = 2, | .plane_axis = 2, | ||||
| .color_point = {255, 255, 255, 255}, | .color_point = {255, 255, 255, 255}, | ||||
| .color_line = {255, 255, 255, 128}, | .color_line = {255, 255, 255, 128}, | ||||
| .color_box = {255, 255, 255, 128}, | .color_box = {255, 255, 255, 128}, | ||||
| .box_dimensions = {1.0f, 1.0f, 1.0f}, | .box_dimensions = {1.0f, 1.0f, 1.0f}, | ||||
| .draw_point = true}}; | .draw_point = true}}; | ||||
| /** | /** | ||||
| ▲ Show 20 Lines • Show All 302 Lines • ▼ Show 20 Lines | if (normal) { | ||||
| immBegin(GPU_PRIM_LINES, 2); | immBegin(GPU_PRIM_LINES, 2); | ||||
| immVertex3fv(pos, loc_curr); | immVertex3fv(pos, loc_curr); | ||||
| immVertex3f(pos, loc_curr[0] + normal[0], loc_curr[1] + normal[1], loc_curr[2] + normal[2]); | immVertex3f(pos, loc_curr[0] + normal[0], loc_curr[1] + normal[1], loc_curr[2] + normal[2]); | ||||
| immEnd(); | immEnd(); | ||||
| } | } | ||||
| } | } | ||||
| if (loc_prev) { | if (loc_prev) { | ||||
| /* Draw an "X" indicating where the previous snap point is. | |||||
| * This is useful for indicating perpendicular snap. */ | |||||
| /* v1, v2, v3 and v4 indicate the coordinates of the ends of the "X". */ | |||||
| float vx[3], vy[3], v1[3], v2[3], v3[3], v4[4]; | |||||
| /* Multiply by 0.75f so that the final size of the "X" is close to that of | /* Multiply by 0.75f so that the final size of the "X" is close to that of | ||||
| * the circle. | * the circle. | ||||
| * (A closer value is 0.7071f, but we don't need to be exact here). */ | * (A closer value is 0.7071f, but we don't need to be exact here). */ | ||||
| float x_size = 0.75f * radius * ED_view3d_pixel_size(rv3d, loc_prev); | float x_size = 0.75f * radius * ED_view3d_pixel_size(rv3d, loc_prev); | ||||
| mul_v3_v3fl(vx, view_inv[0], x_size); | |||||
| mul_v3_v3fl(vy, view_inv[1], x_size); | |||||
| add_v3_v3v3(v1, vx, vy); | |||||
| sub_v3_v3v3(v2, vx, vy); | |||||
| negate_v3_v3(v3, v1); | |||||
| negate_v3_v3(v4, v2); | |||||
| add_v3_v3(v1, loc_prev); | |||||
| add_v3_v3(v2, loc_prev); | |||||
| add_v3_v3(v3, loc_prev); | |||||
| add_v3_v3(v4, loc_prev); | |||||
| immUniformColor4ubv(color_line); | immUniformColor4ubv(color_line); | ||||
| immBegin(GPU_PRIM_LINES, 4); | imm_drawX(loc_prev, x_size, view_inv, pos); | ||||
| immVertex3fv(pos, v3); | |||||
| immVertex3fv(pos, v1); | |||||
| immVertex3fv(pos, v4); | |||||
| immVertex3fv(pos, v2); | |||||
| immEnd(); | |||||
| if (loc_curr && (snap_elem_type & SCE_SNAP_MODE_EDGE_PERPENDICULAR)) { | if (loc_curr && (snap_elem_type & SCE_SNAP_MODE_EDGE_PERPENDICULAR)) { | ||||
| /* Dashed line. */ | /* Dashed line. */ | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR); | ||||
| float viewport_size[4]; | float viewport_size[4]; | ||||
| GPU_viewport_size_get_f(viewport_size); | GPU_viewport_size_get_f(viewport_size); | ||||
| ▲ Show 20 Lines • Show All 386 Lines • ▼ Show 20 Lines | static void v3d_cursor_snap_draw_fn(bContext *C, int x, int y, void *UNUSED(customdata)) | ||||
| if (snap_data->snap_elem && (state->draw_point || state->draw_box)) { | if (snap_data->snap_elem && (state->draw_point || state->draw_box)) { | ||||
| const float *prev_point = (snap_data->snap_elem & SCE_SNAP_MODE_EDGE_PERPENDICULAR) ? | const float *prev_point = (snap_data->snap_elem & SCE_SNAP_MODE_EDGE_PERPENDICULAR) ? | ||||
| state->prevpoint : | state->prevpoint : | ||||
| NULL; | NULL; | ||||
| GPU_line_smooth(false); | GPU_line_smooth(false); | ||||
| GPU_line_width(1.0f); | GPU_line_width(1.0f); | ||||
| imm_draw_circle_wire_aspect_2d; | |||||
| ED_view3d_cursor_snap_draw_util(rv3d, | ED_view3d_cursor_snap_draw_util(rv3d, | ||||
| prev_point, | prev_point, | ||||
| snap_data->loc, | snap_data->loc, | ||||
| NULL, | NULL, | ||||
| state->color_line, | state->color_line, | ||||
| state->color_point, | state->color_point, | ||||
| snap_data->snap_elem); | snap_data->snap_elem); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 140 Lines • Show Last 20 Lines | |||||