Cleanup: Paint Cursor Refactor

The paint_draw_cursor function was handling the cursor drawing for 2D
and 3D views of all paint modes, calculating the brush radius, updating
the SculptSession data and updating and drawing all sculpt cursor
overlays for different tools. It was almost impossible to understand when
and what was being drawn and in which state the GPU matrix was.

Now everyting is organized into different functions, with clear
separation between modes, sculpt tool overlays and different drawing
setups. Update and drawing functions are also separated (this allows to
skip one PBVH query on each cursor drawing).

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D8206
This commit is contained in:
Pablo Dobarro 2020-08-06 01:30:34 +02:00
parent 56af04d31f
commit 5f51438185
Notes: blender-bot 2023-02-13 21:33:57 +01:00
Referenced by issue #79597, Crash when sculpting on geometry and dyntopo enabled
5 changed files with 672 additions and 471 deletions

File diff suppressed because it is too large Load Diff

View File

@ -8160,6 +8160,14 @@ void SCULPT_geometry_preview_lines_update(bContext *C, SculptSession *ss, float
return;
}
if (!ss->deform_modifiers_active) {
return;
}
if (BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS) {
return;
}
BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true, false);
if (!ss->pmap) {

View File

@ -962,7 +962,6 @@ void SCULPT_cloth_simulation_free(struct SculptClothSimulation *cloth_sim)
/* Cursor drawing function. */
void SCULPT_cloth_simulation_limits_draw(const uint gpuattr,
const Brush *brush,
const float obmat[4][4],
const float location[3],
const float normal[3],
const float rds,
@ -973,10 +972,11 @@ void SCULPT_cloth_simulation_limits_draw(const uint gpuattr,
float cursor_trans[4][4], cursor_rot[4][4];
float z_axis[4] = {0.0f, 0.0f, 1.0f, 0.0f};
float quat[4];
copy_m4_m4(cursor_trans, obmat);
unit_m4(cursor_trans);
translate_m4(cursor_trans, location[0], location[1], location[2]);
rotation_between_vecs_to_quat(quat, z_axis, normal);
quat_to_mat4(cursor_rot, quat);
GPU_matrix_push();
GPU_matrix_mul(cursor_trans);
GPU_matrix_mul(cursor_rot);
@ -986,6 +986,7 @@ void SCULPT_cloth_simulation_limits_draw(const uint gpuattr,
gpuattr, 0, 0, rds + (rds * brush->cloth_sim_limit * brush->cloth_sim_falloff), 320);
immUniformColor3fvAlpha(outline_col, alpha * 0.7f);
imm_draw_circle_wire_3d(gpuattr, 0, 0, rds + rds * brush->cloth_sim_limit, 80);
GPU_matrix_pop();
}
void SCULPT_cloth_plane_falloff_preview_draw(const uint gpuattr,

View File

@ -351,7 +351,6 @@ void SCULPT_cloth_simulation_free(struct SculptClothSimulation *cloth_sim);
void SCULPT_cloth_simulation_limits_draw(const uint gpuattr,
const struct Brush *brush,
const float obmat[4][4],
const float location[3],
const float normal[3],
const float rds,
@ -397,6 +396,7 @@ void SCULPT_pose_ik_chain_free(struct SculptPoseIKChain *ik_chain);
/* Multiplane Scrape Brush. */
void SCULPT_do_multiplane_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode);
void SCULPT_multiplane_scrape_preview_draw(const uint gpuattr,
Brush *brush,
SculptSession *ss,
const float outline_col[3],
const float outline_alpha);

View File

@ -399,10 +399,15 @@ void SCULPT_do_multiplane_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes,
}
void SCULPT_multiplane_scrape_preview_draw(const uint gpuattr,
Brush *brush,
SculptSession *ss,
const float outline_col[3],
const float outline_alpha)
{
if (!(brush->flag2 & BRUSH_MULTIPLANE_SCRAPE_PLANES_PREVIEW)) {
return;
}
float local_mat_inv[4][4];
invert_m4_m4(local_mat_inv, ss->cache->stroke_local_mat);
GPU_matrix_mul(local_mat_inv);