Cleanup: Sculpt, Comment formatting
Reviewed By: brecht Differential Revision: https://developer.blender.org/D6792
This commit is contained in:
parent
af6ba4dce5
commit
395e91b87c
|
@ -98,7 +98,7 @@ static TexSnapshot primary_snap = {0};
|
|||
static TexSnapshot secondary_snap = {0};
|
||||
static CursorSnapshot cursor_snap = {0};
|
||||
|
||||
/* delete overlay cursor textures to preserve memory and invalidate all overlay flags */
|
||||
/* Delete overlay cursor textures to preserve memory and invalidate all overlay flags. */
|
||||
void paint_cursor_delete_textures(void)
|
||||
{
|
||||
if (primary_snap.overlay_texture) {
|
||||
|
@ -173,7 +173,7 @@ static void load_tex_task_cb_ex(void *__restrict userdata,
|
|||
|
||||
if (mtex->tex && mtex->tex->type == TEX_IMAGE && mtex->tex->ima) {
|
||||
ImBuf *tex_ibuf = BKE_image_pool_acquire_ibuf(mtex->tex->ima, &mtex->tex->iuser, pool);
|
||||
/* For consistency, sampling always returns color in linear space */
|
||||
/* For consistency, sampling always returns color in linear space. */
|
||||
if (tex_ibuf && tex_ibuf->rect_float == NULL) {
|
||||
convert_to_linear = true;
|
||||
colorspace = tex_ibuf->rect_colorspace;
|
||||
|
@ -182,7 +182,7 @@ static void load_tex_task_cb_ex(void *__restrict userdata,
|
|||
}
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
// largely duplicated from tex_strength
|
||||
/* Largely duplicated from tex_strength. */
|
||||
|
||||
int index = j * size + i;
|
||||
|
||||
|
@ -227,7 +227,7 @@ static void load_tex_task_cb_ex(void *__restrict userdata,
|
|||
|
||||
avg += br->texture_sample_bias;
|
||||
|
||||
/* clamp to avoid precision overflow */
|
||||
/* Clamp to avoid precision overflow. */
|
||||
CLAMP(avg, 0.0f, 1.0f);
|
||||
buffer[index] = 255 - (GLubyte)(255 * avg);
|
||||
}
|
||||
|
@ -269,7 +269,7 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima
|
|||
|
||||
if (refresh) {
|
||||
struct ImagePool *pool = NULL;
|
||||
/* stencil is rotated later */
|
||||
/* Stencil is rotated later. */
|
||||
const float rotation = (mtex->brush_map_mode != MTEX_MAP_MODE_STENCIL) ? -mtex->rot : 0.0f;
|
||||
const float radius = BKE_brush_size_get(vc->scene, br) * zoom;
|
||||
|
||||
|
@ -317,7 +317,7 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima
|
|||
pool = BKE_image_pool_new();
|
||||
|
||||
if (mtex->tex && mtex->tex->nodetree) {
|
||||
/* has internal flag to detect it only does it once */
|
||||
/* Has internal flag to detect it only does it once. */
|
||||
ntreeTexBeginExecTree(mtex->tex->nodetree);
|
||||
}
|
||||
|
||||
|
@ -400,7 +400,7 @@ static void load_tex_cursor_task_cb(void *__restrict userdata,
|
|||
const int size = data->size;
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
// largely duplicated from tex_strength
|
||||
/* Largely duplicated from tex_strength. */
|
||||
|
||||
const int index = j * size + i;
|
||||
const float x = (((float)i / size) - 0.5f) * 2.0f;
|
||||
|
@ -408,7 +408,9 @@ static void load_tex_cursor_task_cb(void *__restrict userdata,
|
|||
const float len = sqrtf(x * x + y * y);
|
||||
|
||||
if (len <= 1.0f) {
|
||||
float avg = BKE_brush_curve_strength_clamped(br, len, 1.0f); /* Falloff curve */
|
||||
|
||||
/* Falloff curve. */
|
||||
float avg = BKE_brush_curve_strength_clamped(br, len, 1.0f);
|
||||
|
||||
buffer[index] = (GLubyte)(255 * avg);
|
||||
}
|
||||
|
@ -520,7 +522,7 @@ static int project_brush_radius(ViewContext *vc, float radius, const float locat
|
|||
|
||||
ED_view3d_global_to_vector(vc->rv3d, location, view);
|
||||
|
||||
/* create a vector that is not orthogonal to view */
|
||||
/* Create a vector that is not orthogonal to view. */
|
||||
|
||||
if (fabsf(view[0]) < 0.1f) {
|
||||
nonortho[0] = view[0] + 1.0f;
|
||||
|
@ -538,23 +540,24 @@ static int project_brush_radius(ViewContext *vc, float radius, const float locat
|
|||
nonortho[2] = view[2] + 1.0f;
|
||||
}
|
||||
|
||||
/* get a vector in the plane of the view */
|
||||
/* Get a vector in the plane of the view. */
|
||||
cross_v3_v3v3(ortho, nonortho, view);
|
||||
normalize_v3(ortho);
|
||||
|
||||
/* make a point on the surface of the brush tangent to the view */
|
||||
/* Make a point on the surface of the brush tangent to the view. */
|
||||
mul_v3_fl(ortho, radius);
|
||||
add_v3_v3v3(offset, location, ortho);
|
||||
|
||||
/* project the center of the brush, and the tangent point to the view onto the screen */
|
||||
/* Project the center of the brush, and the tangent point to the view onto the screen. */
|
||||
if ((ED_view3d_project_float_global(vc->ar, location, p1, V3D_PROJ_TEST_NOP) ==
|
||||
V3D_PROJ_RET_OK) &&
|
||||
(ED_view3d_project_float_global(vc->ar, offset, p2, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK)) {
|
||||
/* the distance between these points is the size of the projected brush in pixels */
|
||||
/* The distance between these points is the size of the projected brush in pixels. */
|
||||
return len_v2v2(p1, p2);
|
||||
}
|
||||
else {
|
||||
BLI_assert(0); /* assert because the code that sets up the vectors should disallow this */
|
||||
/* Assert because the code that sets up the vectors should disallow this. */
|
||||
BLI_assert(0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -608,7 +611,7 @@ static bool sculpt_get_brush_geometry(bContext *C,
|
|||
}
|
||||
|
||||
/* Draw an overlay that shows what effect the brush's texture will
|
||||
* have on brush strength */
|
||||
* have on brush strength. */
|
||||
static bool paint_draw_tex_overlay(UnifiedPaintSettings *ups,
|
||||
Brush *brush,
|
||||
ViewContext *vc,
|
||||
|
@ -619,7 +622,7 @@ static bool paint_draw_tex_overlay(UnifiedPaintSettings *ups,
|
|||
bool primary)
|
||||
{
|
||||
rctf quad;
|
||||
/* check for overlay mode */
|
||||
/* Check for overlay mode. */
|
||||
|
||||
MTex *mtex = (primary) ? &brush->mtex : &brush->mask_mtex;
|
||||
bool valid = ((primary) ? (brush->overlay_flags & BRUSH_OVERLAY_PRIMARY) != 0 :
|
||||
|
@ -642,12 +645,12 @@ static bool paint_draw_tex_overlay(UnifiedPaintSettings *ups,
|
|||
if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW) {
|
||||
GPU_matrix_push();
|
||||
|
||||
/* brush rotation */
|
||||
/* Brush rotation. */
|
||||
GPU_matrix_translate_2f(x, y);
|
||||
GPU_matrix_rotate_2d(-RAD2DEGF(primary ? ups->brush_rotation : ups->brush_rotation_sec));
|
||||
GPU_matrix_translate_2f(-x, -y);
|
||||
|
||||
/* scale based on tablet pressure */
|
||||
/* Scale based on tablet pressure. */
|
||||
if (primary && ups->stroke_active && BKE_brush_use_size_pressure(brush)) {
|
||||
const float scale = ups->size_pressure_value;
|
||||
GPU_matrix_translate_2f(x, y);
|
||||
|
@ -675,7 +678,7 @@ static bool paint_draw_tex_overlay(UnifiedPaintSettings *ups,
|
|||
quad.xmax = BLI_rcti_size_x(&vc->ar->winrct);
|
||||
quad.ymax = BLI_rcti_size_y(&vc->ar->winrct);
|
||||
}
|
||||
/* Stencil code goes here */
|
||||
/* Stencil code goes here. */
|
||||
else {
|
||||
if (primary) {
|
||||
quad.xmin = -brush->stencil_dimension[0];
|
||||
|
@ -699,7 +702,7 @@ static bool paint_draw_tex_overlay(UnifiedPaintSettings *ups,
|
|||
GPU_matrix_rotate_2d(RAD2DEGF(mtex->rot));
|
||||
}
|
||||
|
||||
/* set quad color. Colored overlay does not get blending */
|
||||
/* Set quad color. Colored overlay does not get blending. */
|
||||
GPUVertFormat *format = immVertexFormat();
|
||||
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
||||
uint texCoord = GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
||||
|
@ -714,7 +717,7 @@ static bool paint_draw_tex_overlay(UnifiedPaintSettings *ups,
|
|||
immUniformColor3fvAlpha(U.sculpt_paint_overlay_col, overlay_alpha * 0.01f);
|
||||
}
|
||||
|
||||
/* draw textured quad */
|
||||
/* Draw textured quad. */
|
||||
immUniform1i("image", 0);
|
||||
|
||||
immBegin(GPU_PRIM_TRI_FAN, 4);
|
||||
|
@ -739,12 +742,12 @@ static bool paint_draw_tex_overlay(UnifiedPaintSettings *ups,
|
|||
}
|
||||
|
||||
/* Draw an overlay that shows what effect the brush's texture will
|
||||
* have on brush strength */
|
||||
* have on brush strength. */
|
||||
static bool paint_draw_cursor_overlay(
|
||||
UnifiedPaintSettings *ups, Brush *brush, ViewContext *vc, int x, int y, float zoom)
|
||||
{
|
||||
rctf quad;
|
||||
/* check for overlay mode */
|
||||
/* Check for overlay mode. */
|
||||
|
||||
if (!(brush->overlay_flags & BRUSH_OVERLAY_CURSOR)) {
|
||||
return false;
|
||||
|
@ -777,7 +780,7 @@ static bool paint_draw_cursor_overlay(
|
|||
quad.ymax = y + radius;
|
||||
}
|
||||
|
||||
/* scale based on tablet pressure */
|
||||
/* Scale based on tablet pressure. */
|
||||
if (ups->stroke_active && BKE_brush_use_size_pressure(brush)) {
|
||||
do_pop = true;
|
||||
GPU_matrix_push();
|
||||
|
@ -795,9 +798,9 @@ static bool paint_draw_cursor_overlay(
|
|||
|
||||
immUniformColor3fvAlpha(U.sculpt_paint_overlay_col, brush->cursor_overlay_alpha * 0.01f);
|
||||
|
||||
/* draw textured quad */
|
||||
/* Draw textured quad. */
|
||||
|
||||
/* draw textured quad */
|
||||
/* Draw textured quad. */
|
||||
immUniform1i("image", 0);
|
||||
|
||||
immBegin(GPU_PRIM_TRI_FAN, 4);
|
||||
|
@ -980,7 +983,7 @@ static void paint_draw_curve_cursor(Brush *brush, ViewContext *vc)
|
|||
GPU_line_smooth(true);
|
||||
GPU_blend(true);
|
||||
|
||||
/* draw the bezier handles and the curve segment between the current and next point */
|
||||
/* Draw the bezier handles and the curve segment between the current and next point. */
|
||||
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
@ -994,7 +997,7 @@ static void paint_draw_curve_cursor(Brush *brush, ViewContext *vc)
|
|||
int j;
|
||||
PaintCurvePoint *cp_next = cp + 1;
|
||||
float data[(PAINT_CURVE_NUM_SEGMENTS + 1) * 2];
|
||||
/* use color coding to distinguish handles vs curve segments */
|
||||
/* Use color coding to distinguish handles vs curve segments. */
|
||||
draw_bezier_handle_lines(pos, selec_col, &cp->bez);
|
||||
draw_tri_point(pos, selec_col, pivot_col, &cp->bez.vec[1][0], 10.0f, cp->bez.f2);
|
||||
draw_rect_point(
|
||||
|
@ -1031,7 +1034,7 @@ static void paint_draw_curve_cursor(Brush *brush, ViewContext *vc)
|
|||
immEnd();
|
||||
}
|
||||
|
||||
/* draw last line segment */
|
||||
/* Draw last line segment. */
|
||||
draw_bezier_handle_lines(pos, selec_col, &cp->bez);
|
||||
draw_tri_point(pos, selec_col, pivot_col, &cp->bez.vec[1][0], 10.0f, cp->bez.f2);
|
||||
draw_rect_point(
|
||||
|
@ -1048,7 +1051,7 @@ static void paint_draw_curve_cursor(Brush *brush, ViewContext *vc)
|
|||
}
|
||||
|
||||
/* Special actions taken when paint cursor goes over mesh */
|
||||
/* TODO: sculpt only for now */
|
||||
/* TODO: sculpt only for now. */
|
||||
static void paint_cursor_on_hit(UnifiedPaintSettings *ups,
|
||||
Brush *brush,
|
||||
ViewContext *vc,
|
||||
|
@ -1056,9 +1059,9 @@ static void paint_cursor_on_hit(UnifiedPaintSettings *ups,
|
|||
{
|
||||
float unprojected_radius, projected_radius;
|
||||
|
||||
/* update the brush's cached 3D radius */
|
||||
/* Update the brush's cached 3D radius. */
|
||||
if (!BKE_brush_use_locked_size(vc->scene, brush)) {
|
||||
/* get 2D brush radius */
|
||||
/* Get 2D brush radius. */
|
||||
if (ups->draw_anchored) {
|
||||
projected_radius = ups->anchored_size;
|
||||
}
|
||||
|
@ -1071,15 +1074,15 @@ static void paint_cursor_on_hit(UnifiedPaintSettings *ups,
|
|||
}
|
||||
}
|
||||
|
||||
/* convert brush radius from 2D to 3D */
|
||||
/* Convert brush radius from 2D to 3D. */
|
||||
unprojected_radius = paint_calc_object_space_radius(vc, location, projected_radius);
|
||||
|
||||
/* scale 3D brush radius by pressure */
|
||||
/* Scale 3D brush radius by pressure. */
|
||||
if (ups->stroke_active && BKE_brush_use_size_pressure(brush)) {
|
||||
unprojected_radius *= ups->size_pressure_value;
|
||||
}
|
||||
|
||||
/* set cached value in either Brush or UnifiedPaintSettings */
|
||||
/* Set cached value in either Brush or UnifiedPaintSettings. */
|
||||
BKE_brush_unprojected_radius_set(vc->scene, brush, unprojected_radius);
|
||||
}
|
||||
}
|
||||
|
@ -1142,7 +1145,7 @@ static void cursor_draw_tiling_preview(const uint gpuattr,
|
|||
for (cur[1] = start[1]; cur[1] <= end[1]; cur[1]++) {
|
||||
for (cur[2] = start[2]; cur[2] <= end[2]; cur[2]++) {
|
||||
if (!cur[0] && !cur[1] && !cur[2]) {
|
||||
/* skip tile at orgLoc, this was already handled before all others */
|
||||
/* Skip tile at orgLoc, this was already handled before all others. */
|
||||
continue;
|
||||
}
|
||||
tile_pass++;
|
||||
|
@ -1168,14 +1171,14 @@ static void cursor_draw_point_with_symmetry(const uint gpuattr,
|
|||
for (int i = 0; i <= symm; i++) {
|
||||
if (i == 0 || (symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5)))) {
|
||||
|
||||
/* Axis Symmetry */
|
||||
/* Axis Symmetry. */
|
||||
flip_v3_v3(location, true_location, (char)i);
|
||||
cursor_draw_point_screen_space(gpuattr, ar, location, ob->obmat, 3);
|
||||
|
||||
/* Tiling */
|
||||
/* Tiling. */
|
||||
cursor_draw_tiling_preview(gpuattr, ar, location, sd, ob, radius);
|
||||
|
||||
/* Radial Symmetry */
|
||||
/* Radial Symmetry. */
|
||||
for (char raxis = 0; raxis < 3; raxis++) {
|
||||
for (int r = 1; r < sd->radial_symm[raxis]; r++) {
|
||||
float angle = 2 * M_PI * r / sd->radial_symm[(int)raxis];
|
||||
|
@ -1311,8 +1314,8 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
|
|||
return;
|
||||
}
|
||||
|
||||
/* can't use stroke vc here because this will be called during
|
||||
* mouse over too, not just during a stroke */
|
||||
/* Can't use stroke vc here because this will be called during
|
||||
* mouse over too, not just during a stroke. */
|
||||
ViewContext vc;
|
||||
ED_view3d_viewcontext_init(C, &vc, depsgraph);
|
||||
|
||||
|
@ -1320,7 +1323,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
|
|||
return;
|
||||
}
|
||||
|
||||
/* skip everything and draw brush here */
|
||||
/* Skip everything and draw brush here. */
|
||||
if (brush->flag & BRUSH_CURVE) {
|
||||
paint_draw_curve_cursor(brush, &vc);
|
||||
return;
|
||||
|
@ -1330,20 +1333,20 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
|
|||
get_imapaint_zoom(C, &zoomx, &zoomy);
|
||||
zoomx = max_ff(zoomx, zoomy);
|
||||
|
||||
/* set various defaults */
|
||||
/* Set various defaults. */
|
||||
const float *outline_col = brush->add_col;
|
||||
const float outline_alpha = brush->add_col[3];
|
||||
float translation[2] = {x, y};
|
||||
float final_radius = (BKE_brush_size_get(scene, brush) * zoomx);
|
||||
|
||||
/* don't calculate rake angles while a stroke is active because the rake variables are global
|
||||
/* Don't calculate rake angles while a stroke is active because the rake variables are global
|
||||
* and we may get interference with the stroke itself.
|
||||
* For line strokes, such interference is visible */
|
||||
* For line strokes, such interference is visible. */
|
||||
if (!ups->stroke_active) {
|
||||
paint_calculate_rake_rotation(ups, brush, translation);
|
||||
}
|
||||
|
||||
/* draw overlay */
|
||||
/* Draw overlay. */
|
||||
bool alpha_overlay_active = paint_draw_alpha_overlay(ups, brush, &vc, x, y, zoomx, mode);
|
||||
|
||||
if (ups->draw_anchored) {
|
||||
|
@ -1353,9 +1356,12 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
|
|||
ups->anchored_initial_mouse[1] + ar->winrct.ymin);
|
||||
}
|
||||
|
||||
/* make lines pretty */
|
||||
/* Make lines pretty. */
|
||||
GPU_line_width(2.0f);
|
||||
GPU_blend(true); /* TODO: also set blend mode? */
|
||||
|
||||
/* TODO: also set blend mode? */
|
||||
GPU_blend(true);
|
||||
|
||||
GPU_line_smooth(true);
|
||||
|
||||
if (use_2d_cursor) {
|
||||
|
@ -1364,45 +1370,46 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
|
|||
|
||||
immUniformColor3fvAlpha(outline_col, outline_alpha);
|
||||
|
||||
/* draw brush outline */
|
||||
/* Draw brush outline. */
|
||||
if (ups->stroke_active && BKE_brush_use_size_pressure(brush)) {
|
||||
imm_draw_circle_wire_2d(
|
||||
pos, translation[0], translation[1], final_radius * ups->size_pressure_value, 40);
|
||||
/* outer at half alpha */
|
||||
/* Outer at half alpha. */
|
||||
immUniformColor3fvAlpha(outline_col, outline_alpha * 0.5f);
|
||||
}
|
||||
|
||||
GPU_line_width(1.0f);
|
||||
imm_draw_circle_wire_2d(pos, translation[0], translation[1], final_radius, 40);
|
||||
}
|
||||
else { /* 3d painting */
|
||||
else {
|
||||
/* 3D Painting. */
|
||||
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
|
||||
/* TODO: as sculpt and other paint modes are unified, this
|
||||
* special mode of drawing will go away */
|
||||
* special mode of drawing will go away. */
|
||||
Object *obact = vc.obact;
|
||||
SculptSession *ss = obact ? obact->sculpt : NULL;
|
||||
if ((mode == PAINT_MODE_SCULPT) && ss) {
|
||||
float location[3];
|
||||
int pixel_radius;
|
||||
|
||||
/* test if brush is over the mesh */
|
||||
/* Test if brush is over the mesh. */
|
||||
bool hit = sculpt_get_brush_geometry(C, &vc, x, y, &pixel_radius, location, ups);
|
||||
|
||||
if (BKE_brush_use_locked_size(scene, brush)) {
|
||||
BKE_brush_size_set(scene, brush, pixel_radius);
|
||||
}
|
||||
|
||||
/* check if brush is subtracting, use different color then */
|
||||
/* Check if brush is subtracting, use different color then */
|
||||
/* TODO: no way currently to know state of pen flip or
|
||||
* invert key modifier without starting a stroke */
|
||||
* invert key modifier without starting a stroke. */
|
||||
if (((ups->draw_inverted == 0) ^ ((brush->flag & BRUSH_DIR_IN) == 0)) &&
|
||||
BKE_brush_sculpt_has_secondary_color(brush)) {
|
||||
outline_col = brush->sub_col;
|
||||
}
|
||||
|
||||
/* only do if brush is over the mesh */
|
||||
/* Only do if brush is over the mesh. */
|
||||
if (hit) {
|
||||
paint_cursor_on_hit(ups, brush, &vc, location);
|
||||
}
|
||||
|
@ -1413,12 +1420,12 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
|
|||
if (ups->stroke_active && BKE_brush_use_size_pressure(brush) && mode != PAINT_MODE_SCULPT) {
|
||||
imm_draw_circle_wire_3d(
|
||||
pos, translation[0], translation[1], final_radius * ups->size_pressure_value, 40);
|
||||
/* outer at half alpha */
|
||||
/* Outer at half alpha. */
|
||||
immUniformColor3fvAlpha(outline_col, outline_alpha * 0.5f);
|
||||
}
|
||||
|
||||
/* Only sculpt mode cursor for now */
|
||||
/* Disable for PBVH_GRIDS */
|
||||
/* Only sculpt mode cursor for now. */
|
||||
/* Disable for PBVH_GRIDS. */
|
||||
bool is_multires = ss && ss->pbvh && BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS;
|
||||
|
||||
SculptCursorGeometryInfo gi;
|
||||
|
@ -1426,13 +1433,13 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
|
|||
int prev_active_vertex_index = -1;
|
||||
bool is_cursor_over_mesh = false;
|
||||
|
||||
/* Update the active vertex */
|
||||
/* Update the active vertex. */
|
||||
if ((mode == PAINT_MODE_SCULPT) && ss && !ups->stroke_active) {
|
||||
prev_active_vertex_index = ss->active_vertex_index;
|
||||
is_cursor_over_mesh = sculpt_cursor_geometry_info_update(
|
||||
C, &gi, mouse, (brush->falloff_shape == PAINT_FALLOFF_SHAPE_SPHERE));
|
||||
}
|
||||
/* Use special paint crosshair cursor in all paint modes*/
|
||||
/* Use special paint crosshair cursor in all paint modes. */
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
WM_cursor_set(win, WM_CURSOR_PAINT);
|
||||
|
||||
|
@ -1459,7 +1466,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
|
|||
|
||||
wmViewport(&ar->winrct);
|
||||
|
||||
/* Draw 3D active vertex preview with symmetry*/
|
||||
/* Draw 3D active vertex preview with symmetry. */
|
||||
if (len_v3v3(gi.active_vertex_co, gi.location) < rds) {
|
||||
cursor_draw_point_with_symmetry(pos, ar, gi.active_vertex_co, sd, vc.obact, rds);
|
||||
}
|
||||
|
@ -1490,7 +1497,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
|
|||
}
|
||||
}
|
||||
|
||||
/* Draw 3D brush cursor */
|
||||
/* Draw 3D brush cursor. */
|
||||
GPU_matrix_push_projection();
|
||||
ED_view3d_draw_setup_view(CTX_wm_window(C),
|
||||
CTX_data_depsgraph_pointer(C),
|
||||
|
@ -1521,7 +1528,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
|
|||
imm_draw_circle_wire_3d(pos, 0, 0, rds * clamp_f(brush->alpha, 0.0f, 1.0f), 80);
|
||||
GPU_matrix_pop();
|
||||
|
||||
/* Update and draw dynamic mesh preview lines */
|
||||
/* Update and draw dynamic mesh preview lines. */
|
||||
GPU_matrix_push();
|
||||
GPU_matrix_mul(vc.obact->obmat);
|
||||
if (brush->sculpt_tool == SCULPT_TOOL_GRAB && (brush->flag & BRUSH_GRAB_ACTIVE_VERTEX) &&
|
||||
|
@ -1532,7 +1539,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
|
|||
}
|
||||
}
|
||||
|
||||
/* Draw pose brush line preview */
|
||||
/* Draw pose brush line preview. */
|
||||
if (brush->sculpt_tool == SCULPT_TOOL_POSE) {
|
||||
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.8f);
|
||||
GPU_line_width(2.0f);
|
||||
|
@ -1554,9 +1561,9 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
|
|||
}
|
||||
else {
|
||||
/* Draw default cursor when the mouse is not over the mesh or there are no supported
|
||||
* overlays active */
|
||||
* overlays active. */
|
||||
GPU_line_width(1.0f);
|
||||
/* Reduce alpha to increase the contrast when the cursor is over the mesh */
|
||||
/* Reduce alpha to increase the contrast when the cursor is over the mesh. */
|
||||
immUniformColor3fvAlpha(outline_col, outline_alpha * 0.8);
|
||||
imm_draw_circle_wire_3d(pos, translation[0], translation[1], final_radius, 80);
|
||||
immUniformColor3fvAlpha(outline_col, outline_alpha * 0.35f);
|
||||
|
@ -1571,7 +1578,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
|
|||
if (vc.obact->sculpt->cache && !vc.obact->sculpt->cache->first_time) {
|
||||
wmViewport(&ar->winrct);
|
||||
|
||||
/* Draw cached dynamic mesh preview lines */
|
||||
/* Draw cached dynamic mesh preview lines. */
|
||||
if (brush->sculpt_tool == SCULPT_TOOL_GRAB && (brush->flag & BRUSH_GRAB_ACTIVE_VERTEX) &&
|
||||
!is_multires) {
|
||||
if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES && ss->deform_modifiers_active) {
|
||||
|
@ -1615,7 +1622,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
|
|||
}
|
||||
}
|
||||
else {
|
||||
/* Draw default cursor in unsupported modes */
|
||||
/* Draw default cursor in unsupported modes. */
|
||||
GPU_line_width(1.0f);
|
||||
imm_draw_circle_wire_3d(pos, translation[0], translation[1], final_radius, 40);
|
||||
}
|
||||
|
@ -1623,7 +1630,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
|
|||
|
||||
immUnbindProgram();
|
||||
|
||||
/* restore GL state */
|
||||
/* Restore GL state. */
|
||||
GPU_blend(false);
|
||||
GPU_line_smooth(false);
|
||||
}
|
||||
|
@ -1639,7 +1646,7 @@ void paint_cursor_start(bContext *C, bool (*poll)(bContext *C))
|
|||
CTX_wm_manager(C), SPACE_TYPE_ANY, RGN_TYPE_ANY, poll, paint_draw_cursor, NULL);
|
||||
}
|
||||
|
||||
/* invalidate the paint cursors */
|
||||
/* Invalidate the paint cursors. */
|
||||
BKE_paint_invalidate_overlay_all();
|
||||
}
|
||||
|
||||
|
|
|
@ -55,11 +55,13 @@
|
|||
#include "bmesh.h"
|
||||
|
||||
#include "paint_intern.h"
|
||||
#include "sculpt_intern.h" /* for undo push */
|
||||
|
||||
/* For undo push. */
|
||||
#include "sculpt_intern.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
/* return true if the element should be hidden/shown */
|
||||
/* Return true if the element should be hidden/shown. */
|
||||
static bool is_effected(PartialVisArea area,
|
||||
float planes[4][4],
|
||||
const float co[3],
|
||||
|
@ -101,7 +103,7 @@ static void partialvis_update_mesh(Object *ob,
|
|||
MVert *v = &mvert[vert_indices[i]];
|
||||
float vmask = paint_mask ? paint_mask[vert_indices[i]] : 0;
|
||||
|
||||
/* hide vertex if in the hide volume */
|
||||
/* Hide vertex if in the hide volume. */
|
||||
if (is_effected(area, planes, v->co, vmask)) {
|
||||
if (action == PARTIALVIS_HIDE) {
|
||||
v->flag |= ME_HIDE;
|
||||
|
@ -138,7 +140,7 @@ static void partialvis_update_grids(Depsgraph *depsgraph,
|
|||
int *grid_indices, totgrid, i;
|
||||
bool any_changed = false, any_visible = false;
|
||||
|
||||
/* get PBVH data */
|
||||
/* Get PBVH data. */
|
||||
BKE_pbvh_node_get_grids(pbvh, node, &grid_indices, &totgrid, NULL, NULL, &grids);
|
||||
grid_hidden = BKE_pbvh_grid_hidden(pbvh);
|
||||
CCGKey key = *BKE_pbvh_get_grid_key(pbvh);
|
||||
|
@ -153,17 +155,16 @@ static void partialvis_update_grids(Depsgraph *depsgraph,
|
|||
if (!gh) {
|
||||
switch (action) {
|
||||
case PARTIALVIS_HIDE:
|
||||
/* create grid flags data */
|
||||
/* Create grid flags data. */
|
||||
gh = grid_hidden[g] = BLI_BITMAP_NEW(key.grid_area, "partialvis_update_grids");
|
||||
break;
|
||||
case PARTIALVIS_SHOW:
|
||||
/* entire grid is visible, nothing to show */
|
||||
/* Entire grid is visible, nothing to show. */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (action == PARTIALVIS_SHOW && area == PARTIALVIS_ALL) {
|
||||
/* special case if we're showing all, just free the
|
||||
* grid */
|
||||
/* Special case if we're showing all, just free the grid. */
|
||||
MEM_freeN(gh);
|
||||
grid_hidden[g] = NULL;
|
||||
any_changed = true;
|
||||
|
@ -177,15 +178,15 @@ static void partialvis_update_grids(Depsgraph *depsgraph,
|
|||
const float *co = CCG_elem_co(&key, elem);
|
||||
float mask = key.has_mask ? *CCG_elem_mask(&key, elem) : 0.0f;
|
||||
|
||||
/* skip grid element if not in the effected area */
|
||||
/* Skip grid element if not in the effected area. */
|
||||
if (is_effected(area, planes, co, mask)) {
|
||||
/* set or clear the hide flag */
|
||||
/* Set or clear the hide flag. */
|
||||
BLI_BITMAP_SET(gh, y * key.grid_size + x, action == PARTIALVIS_HIDE);
|
||||
|
||||
any_changed = true;
|
||||
}
|
||||
|
||||
/* keep track of whether any elements are still hidden */
|
||||
/* Keep track of whether any elements are still hidden. */
|
||||
if (BLI_BITMAP_TEST(gh, y * key.grid_size + x)) {
|
||||
any_hidden = true;
|
||||
}
|
||||
|
@ -195,15 +196,14 @@ static void partialvis_update_grids(Depsgraph *depsgraph,
|
|||
}
|
||||
}
|
||||
|
||||
/* if everything in the grid is now visible, free the grid
|
||||
* flags */
|
||||
/* If everything in the grid is now visible, free the grid flags. */
|
||||
if (!any_hidden) {
|
||||
MEM_freeN(gh);
|
||||
grid_hidden[g] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* mark updates if anything was hidden/shown */
|
||||
/* Mark updates if anything was hidden/shown. */
|
||||
if (any_changed) {
|
||||
BKE_pbvh_node_mark_rebuild_draw(node);
|
||||
BKE_pbvh_node_fully_hidden_set(node, !any_visible);
|
||||
|
@ -225,7 +225,7 @@ static void partialvis_update_bmesh_verts(BMesh *bm,
|
|||
BMVert *v = BLI_gsetIterator_getKey(&gs_iter);
|
||||
float *vmask = CustomData_bmesh_get(&bm->vdata, v->head.data, CD_PAINT_MASK);
|
||||
|
||||
/* hide vertex if in the hide volume */
|
||||
/* Hide vertex if in the hide volume. */
|
||||
if (is_effected(area, planes, v->co, *vmask)) {
|
||||
if (action == PARTIALVIS_HIDE) {
|
||||
BM_elem_flag_enable(v, BM_ELEM_HIDDEN);
|
||||
|
@ -280,7 +280,7 @@ static void partialvis_update_bmesh(Object *ob,
|
|||
|
||||
partialvis_update_bmesh_verts(bm, other, action, area, planes, &any_changed, &any_visible);
|
||||
|
||||
/* finally loop over node faces and tag the ones that are fully hidden */
|
||||
/* Finally loop over node faces and tag the ones that are fully hidden. */
|
||||
partialvis_update_bmesh_faces(faces);
|
||||
|
||||
if (any_changed) {
|
||||
|
@ -319,7 +319,7 @@ static void get_pbvh_nodes(
|
|||
{
|
||||
BKE_pbvh_SearchCallback cb = NULL;
|
||||
|
||||
/* select search callback */
|
||||
/* Select search callback. */
|
||||
switch (mode) {
|
||||
case PARTIALVIS_INSIDE:
|
||||
cb = BKE_pbvh_node_frustum_contain_AABB;
|
||||
|
@ -351,7 +351,7 @@ static int hide_show_exec(bContext *C, wmOperator *op)
|
|||
rcti rect;
|
||||
int totnode, i;
|
||||
|
||||
/* read operator properties */
|
||||
/* Read operator properties. */
|
||||
action = RNA_enum_get(op->ptr, "action");
|
||||
area = RNA_enum_get(op->ptr, "area");
|
||||
rect_from_props(&rect, op->ptr);
|
||||
|
@ -366,7 +366,7 @@ static int hide_show_exec(bContext *C, wmOperator *op)
|
|||
|
||||
negate_m4(clip_planes);
|
||||
|
||||
/* start undo */
|
||||
/* Start undo. */
|
||||
switch (action) {
|
||||
case PARTIALVIS_HIDE:
|
||||
sculpt_undo_push_begin("Hide area");
|
||||
|
@ -394,11 +394,11 @@ static int hide_show_exec(bContext *C, wmOperator *op)
|
|||
MEM_freeN(nodes);
|
||||
}
|
||||
|
||||
/* end undo */
|
||||
/* End undo. */
|
||||
sculpt_undo_push_end();
|
||||
|
||||
/* ensure that edges and faces get hidden as well (not used by
|
||||
* sculpt but it looks wrong when entering editmode otherwise) */
|
||||
/* Ensure that edges and faces get hidden as well (not used by
|
||||
* sculpt but it looks wrong when entering editmode otherwise). */
|
||||
if (pbvh_type == PBVH_FACES) {
|
||||
BKE_mesh_flush_hidden_from_verts(me);
|
||||
}
|
||||
|
@ -440,21 +440,21 @@ void PAINT_OT_hide_show(struct wmOperatorType *ot)
|
|||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
/* identifiers */
|
||||
/* Identifiers. */
|
||||
ot->name = "Hide/Show";
|
||||
ot->idname = "PAINT_OT_hide_show";
|
||||
ot->description = "Hide/show some vertices";
|
||||
|
||||
/* api callbacks */
|
||||
/* API callbacks. */
|
||||
ot->invoke = hide_show_invoke;
|
||||
ot->modal = WM_gesture_box_modal;
|
||||
ot->exec = hide_show_exec;
|
||||
/* sculpt-only for now */
|
||||
/* Sculpt-only for now. */
|
||||
ot->poll = sculpt_mode_poll_view3d;
|
||||
|
||||
ot->flag = OPTYPE_REGISTER;
|
||||
|
||||
/* rna */
|
||||
/* RNA. */
|
||||
RNA_def_enum(ot->srna,
|
||||
"action",
|
||||
action_items,
|
||||
|
|
|
@ -55,7 +55,9 @@
|
|||
#include "bmesh.h"
|
||||
|
||||
#include "paint_intern.h"
|
||||
#include "sculpt_intern.h" /* for undo push */
|
||||
|
||||
/* For undo push. */
|
||||
#include "sculpt_intern.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -191,18 +193,18 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op)
|
|||
|
||||
void PAINT_OT_mask_flood_fill(struct wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
/* Identifiers. */
|
||||
ot->name = "Mask Flood Fill";
|
||||
ot->idname = "PAINT_OT_mask_flood_fill";
|
||||
ot->description = "Fill the whole mask with a given value, or invert its values";
|
||||
|
||||
/* api callbacks */
|
||||
/* API callbacks. */
|
||||
ot->exec = mask_flood_fill_exec;
|
||||
ot->poll = sculpt_mode_poll;
|
||||
|
||||
ot->flag = OPTYPE_REGISTER;
|
||||
|
||||
/* rna */
|
||||
/* RNA. */
|
||||
RNA_def_enum(ot->srna, "mode", mode_items, PAINT_MASK_FLOOD_VALUE, "Mode", NULL);
|
||||
RNA_def_float(
|
||||
ot->srna,
|
||||
|
@ -216,7 +218,7 @@ void PAINT_OT_mask_flood_fill(struct wmOperatorType *ot)
|
|||
1);
|
||||
}
|
||||
|
||||
/* Box select, operator is VIEW3D_OT_select_box, defined in view3d_select.c */
|
||||
/* Box select, operator is VIEW3D_OT_select_box, defined in view3d_select.c. */
|
||||
|
||||
static bool is_effected(float planes[4][4], const float co[3])
|
||||
{
|
||||
|
@ -309,7 +311,7 @@ bool ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *
|
|||
mode = PAINT_MASK_FLOOD_VALUE;
|
||||
value = select ? 1.0 : 0.0;
|
||||
|
||||
/* transform the clip planes in object space */
|
||||
/* Transform the clip planes in object space. */
|
||||
ED_view3d_clipping_calc(&bb, clip_planes, vc->ar, vc->obact, rect);
|
||||
|
||||
BKE_sculpt_update_object_for_edit(depsgraph, ob, false, true);
|
||||
|
@ -323,7 +325,7 @@ bool ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *
|
|||
(symm != 6 || (symmpass != 3 && symmpass != 5)))) {
|
||||
int j = 0;
|
||||
|
||||
/* flip the planes symmetrically as needed */
|
||||
/* Flip the planes symmetrically as needed. */
|
||||
for (; j < 4; j++) {
|
||||
flip_plane(clip_planes_final[j], clip_planes[j], symmpass);
|
||||
}
|
||||
|
@ -373,7 +375,8 @@ typedef struct LassoMaskData {
|
|||
float projviewobjmat[4][4];
|
||||
BLI_bitmap *px;
|
||||
int width;
|
||||
rcti rect; /* bounding box for scanfilling */
|
||||
/* Bounding box for scanfilling. */
|
||||
rcti rect;
|
||||
int symmpass;
|
||||
|
||||
MaskTaskData task_data;
|
||||
|
@ -390,13 +393,13 @@ static bool is_effected_lasso(LassoMaskData *data, float co[3])
|
|||
float co_final[3];
|
||||
|
||||
flip_v3_v3(co_final, co, data->symmpass);
|
||||
/* first project point to 2d space */
|
||||
/* First project point to 2d space. */
|
||||
ED_view3d_project_float_v2_m4(data->vc->ar, co_final, scr_co_f, data->projviewobjmat);
|
||||
|
||||
scr_co_s[0] = scr_co_f[0];
|
||||
scr_co_s[1] = scr_co_f[1];
|
||||
|
||||
/* clip against screen, because lasso is limited to screen only */
|
||||
/* Clip against screen, because lasso is limited to screen only. */
|
||||
if ((scr_co_s[0] < data->rect.xmin) || (scr_co_s[1] < data->rect.ymin) ||
|
||||
(scr_co_s[0] >= data->rect.xmax) || (scr_co_s[1] >= data->rect.ymax)) {
|
||||
return false;
|
||||
|
@ -476,10 +479,10 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op)
|
|||
|
||||
/* Calculations of individual vertices are done in 2D screen space to diminish the amount of
|
||||
* calculations done. Bounding box PBVH collision is not computed against enclosing rectangle
|
||||
* of lasso */
|
||||
* of lasso. */
|
||||
ED_view3d_viewcontext_init(C, &vc, depsgraph);
|
||||
|
||||
/* lasso data calculations */
|
||||
/* Lasso data calculations. */
|
||||
data.vc = &vc;
|
||||
ob = vc.obact;
|
||||
ED_view3d_ob_project_mat_get(vc.rv3d, ob, data.projviewobjmat);
|
||||
|
@ -510,15 +513,15 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op)
|
|||
(symm != 6 || (symmpass != 3 && symmpass != 5)))) {
|
||||
int j = 0;
|
||||
|
||||
/* flip the planes symmetrically as needed */
|
||||
/* Flip the planes symmetrically as needed. */
|
||||
for (; j < 4; j++) {
|
||||
flip_plane(clip_planes_final[j], clip_planes[j], symmpass);
|
||||
}
|
||||
|
||||
data.symmpass = symmpass;
|
||||
|
||||
/* gather nodes inside lasso's enclosing rectangle
|
||||
* (should greatly help with bigger meshes) */
|
||||
/* Gather nodes inside lasso's enclosing rectangle
|
||||
* (should greatly help with bigger meshes). */
|
||||
PBVHFrustumPlanes frustum = {.planes = clip_planes_final, .num_planes = 4};
|
||||
BKE_pbvh_search_gather(
|
||||
pbvh, BKE_pbvh_node_frustum_contain_AABB, &frustum, &nodes, &totnode);
|
||||
|
@ -575,7 +578,7 @@ void PAINT_OT_mask_lasso_gesture(wmOperatorType *ot)
|
|||
|
||||
ot->flag = OPTYPE_REGISTER;
|
||||
|
||||
/* properties */
|
||||
/* Properties. */
|
||||
WM_operator_properties_gesture_lasso(ot);
|
||||
|
||||
RNA_def_enum(ot->srna, "mode", mode_items, PAINT_MASK_FLOOD_VALUE, "Mode", NULL);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -119,7 +119,7 @@ static void update_cb_partial(PBVHNode *node, void *userdata)
|
|||
|
||||
static bool test_swap_v3_v3(float a[3], float b[3])
|
||||
{
|
||||
/* no need for float comparison here (memory is exactly equal or not) */
|
||||
/* No need for float comparison here (memory is exactly equal or not). */
|
||||
if (memcmp(a, b, sizeof(float[3])) != 0) {
|
||||
swap_v3_v3(a, b);
|
||||
return true;
|
||||
|
@ -151,10 +151,10 @@ static bool sculpt_undo_restore_coords(bContext *C, Depsgraph *depsgraph, Sculpt
|
|||
int *index;
|
||||
|
||||
if (unode->maxvert) {
|
||||
/* regular mesh restore */
|
||||
/* Regular mesh restore. */
|
||||
|
||||
if (ss->shapekey_active && !STREQ(ss->shapekey_active->name, unode->shapeName)) {
|
||||
/* shape key has been changed before calling undo operator */
|
||||
/* Shape key has been changed before calling undo operator. */
|
||||
|
||||
Key *key = BKE_key_from_object(ob);
|
||||
KeyBlock *kb = key ? BKE_keyblock_find_name(key, unode->shapeName) : NULL;
|
||||
|
@ -166,12 +166,12 @@ static bool sculpt_undo_restore_coords(bContext *C, Depsgraph *depsgraph, Sculpt
|
|||
WM_event_add_notifier(C, NC_OBJECT | ND_DATA, ob);
|
||||
}
|
||||
else {
|
||||
/* key has been removed -- skip this undo node */
|
||||
/* Key has been removed -- skip this undo node. */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* no need for float comparison here (memory is exactly equal or not) */
|
||||
/* No need for float comparison here (memory is exactly equal or not). */
|
||||
index = unode->index;
|
||||
mvert = ss->mvert;
|
||||
|
||||
|
@ -197,11 +197,11 @@ static bool sculpt_undo_restore_coords(bContext *C, Depsgraph *depsgraph, Sculpt
|
|||
}
|
||||
}
|
||||
|
||||
/* propagate new coords to keyblock */
|
||||
/* Propagate new coords to keyblock. */
|
||||
sculpt_vertcos_to_key(ob, ss->shapekey_active, vertCos);
|
||||
|
||||
/* pbvh uses it's own mvert array, so coords should be */
|
||||
/* propagated to pbvh here */
|
||||
/* PBVH uses it's own mvert array, so coords should be */
|
||||
/* propagated to PBVH here. */
|
||||
BKE_pbvh_vert_coords_apply(ss->pbvh, vertCos, ss->shapekey_active->totelem);
|
||||
|
||||
MEM_freeN(vertCos);
|
||||
|
@ -230,7 +230,7 @@ static bool sculpt_undo_restore_coords(bContext *C, Depsgraph *depsgraph, Sculpt
|
|||
}
|
||||
}
|
||||
else if (unode->maxgrid && subdiv_ccg != NULL) {
|
||||
/* multires restore */
|
||||
/* Multires restore. */
|
||||
CCGElem **grids, *grid;
|
||||
CCGKey key;
|
||||
float(*co)[3];
|
||||
|
@ -295,7 +295,7 @@ static bool sculpt_undo_restore_mask(bContext *C, SculptUndoNode *unode)
|
|||
int *index, i, j;
|
||||
|
||||
if (unode->maxvert) {
|
||||
/* regular mesh restore */
|
||||
/* Regular mesh restore. */
|
||||
|
||||
index = unode->index;
|
||||
mvert = ss->mvert;
|
||||
|
@ -309,7 +309,7 @@ static bool sculpt_undo_restore_mask(bContext *C, SculptUndoNode *unode)
|
|||
}
|
||||
}
|
||||
else if (unode->maxgrid && subdiv_ccg != NULL) {
|
||||
/* multires restore */
|
||||
/* Multires restore. */
|
||||
CCGElem **grids, *grid;
|
||||
CCGKey key;
|
||||
float *mask;
|
||||
|
@ -375,7 +375,7 @@ static void sculpt_undo_bmesh_restore_generic(bContext *C,
|
|||
}
|
||||
}
|
||||
|
||||
/* Create empty sculpt BMesh and enable logging */
|
||||
/* Create empty sculpt BMesh and enable logging. */
|
||||
static void sculpt_undo_bmesh_enable(Object *ob, SculptUndoNode *unode)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
|
@ -383,7 +383,7 @@ static void sculpt_undo_bmesh_enable(Object *ob, SculptUndoNode *unode)
|
|||
|
||||
sculpt_pbvh_clear(ob);
|
||||
|
||||
/* Create empty BMesh and enable logging */
|
||||
/* Create empty BMesh and enable logging. */
|
||||
ss->bm = BM_mesh_create(&bm_mesh_allocsize_default,
|
||||
&((struct BMeshCreateParams){
|
||||
.use_toolflags = false,
|
||||
|
@ -392,7 +392,7 @@ static void sculpt_undo_bmesh_enable(Object *ob, SculptUndoNode *unode)
|
|||
sculpt_dyntopo_node_layers_add(ss);
|
||||
me->flag |= ME_SCULPT_DYNAMIC_TOPOLOGY;
|
||||
|
||||
/* Restore the BMLog using saved entries */
|
||||
/* Restore the BMLog using saved entries. */
|
||||
ss->bm_log = BM_log_from_existing_entries_create(ss->bm, unode->bm_entry);
|
||||
}
|
||||
|
||||
|
@ -408,7 +408,7 @@ static void sculpt_undo_bmesh_restore_begin(bContext *C,
|
|||
else {
|
||||
sculpt_undo_bmesh_enable(ob, unode);
|
||||
|
||||
/* Restore the mesh from the first log entry */
|
||||
/* Restore the mesh from the first log entry. */
|
||||
BM_log_redo(ss->bm, ss->bm_log);
|
||||
|
||||
unode->applied = true;
|
||||
|
@ -423,13 +423,13 @@ static void sculpt_undo_bmesh_restore_end(bContext *C,
|
|||
if (unode->applied) {
|
||||
sculpt_undo_bmesh_enable(ob, unode);
|
||||
|
||||
/* Restore the mesh from the last log entry */
|
||||
/* Restore the mesh from the last log entry. */
|
||||
BM_log_undo(ss->bm, ss->bm_log);
|
||||
|
||||
unode->applied = false;
|
||||
}
|
||||
else {
|
||||
/* Disable dynamic topology sculpting */
|
||||
/* Disable dynamic topology sculpting. */
|
||||
sculpt_dynamic_topology_disable(C, NULL);
|
||||
unode->applied = true;
|
||||
}
|
||||
|
@ -502,13 +502,13 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase
|
|||
bool need_mask = false;
|
||||
|
||||
for (unode = lb->first; unode; unode = unode->next) {
|
||||
/* restore pivot */
|
||||
/* Restore pivot. */
|
||||
copy_v3_v3(ss->pivot_pos, unode->pivot_pos);
|
||||
copy_v3_v3(ss->pivot_rot, unode->pivot_rot);
|
||||
if (STREQ(unode->idname, ob->id.name)) {
|
||||
if (unode->type == SCULPT_UNDO_MASK) {
|
||||
/* is possible that we can't do the mask undo (below)
|
||||
* because of the vertex count */
|
||||
/* Is possible that we can't do the mask undo (below)
|
||||
* because of the vertex count. */
|
||||
need_mask = true;
|
||||
break;
|
||||
}
|
||||
|
@ -550,8 +550,8 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase
|
|||
continue;
|
||||
}
|
||||
|
||||
/* check if undo data matches current data well enough to
|
||||
* continue */
|
||||
/* Check if undo data matches current data well enough to
|
||||
* continue. */
|
||||
if (unode->maxvert) {
|
||||
if (ss->totvert != unode->maxvert) {
|
||||
continue;
|
||||
|
@ -609,9 +609,9 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase
|
|||
|
||||
if (update || rebuild) {
|
||||
bool tag_update = false;
|
||||
/* we update all nodes still, should be more clever, but also
|
||||
/* We update all nodes still, should be more clever, but also
|
||||
* needs to work correct when exiting/entering sculpt mode and
|
||||
* the nodes get recreated, though in that case it could do all */
|
||||
* the nodes get recreated, though in that case it could do all. */
|
||||
struct PartialUpdateData data = {
|
||||
.rebuild = rebuild,
|
||||
.pbvh = ss->pbvh,
|
||||
|
@ -794,9 +794,9 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, Sculpt
|
|||
maxgrid = 0;
|
||||
}
|
||||
|
||||
/* we will use this while sculpting, is mapalloc slow to access then? */
|
||||
/* We will use this while sculpting, is mapalloc slow to access then? */
|
||||
|
||||
/* general TODO, fix count_alloc */
|
||||
/* General TODO, fix count_alloc. */
|
||||
switch (type) {
|
||||
case SCULPT_UNDO_COORDS:
|
||||
unode->co = MEM_mapallocN(sizeof(float[3]) * allvert, "SculptUndoNode.co");
|
||||
|
@ -830,14 +830,14 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, Sculpt
|
|||
BLI_addtail(&usculpt->nodes, unode);
|
||||
|
||||
if (maxgrid) {
|
||||
/* multires */
|
||||
/* Multires. */
|
||||
unode->maxgrid = maxgrid;
|
||||
unode->totgrid = totgrid;
|
||||
unode->gridsize = gridsize;
|
||||
unode->grids = MEM_mapallocN(sizeof(int) * totgrid, "SculptUndoNode.grids");
|
||||
}
|
||||
else {
|
||||
/* regular mesh */
|
||||
/* Regular mesh. */
|
||||
unode->maxvert = ss->totvert;
|
||||
unode->index = MEM_mapallocN(sizeof(int) * allvert, "SculptUndoNode.index");
|
||||
}
|
||||
|
@ -877,7 +877,7 @@ static void sculpt_undo_store_hidden(Object *ob, SculptUndoNode *unode)
|
|||
PBVHNode *node = unode->node;
|
||||
|
||||
if (unode->grids) {
|
||||
/* already stored during allocation */
|
||||
/* Already stored during allocation. */
|
||||
}
|
||||
else {
|
||||
MVert *mvert;
|
||||
|
@ -912,7 +912,7 @@ static SculptUndoNode *sculpt_undo_geometry_push(Object *ob, SculptUndoType type
|
|||
bool applied;
|
||||
|
||||
SculptUndoNode *unode = usculpt->nodes.first;
|
||||
/* Store the original mesh in the first node, modifications in the second */
|
||||
/* Store the original mesh in the first node, modifications in the second. */
|
||||
applied = unode != NULL;
|
||||
|
||||
unode = MEM_callocN(sizeof(*unode), __func__);
|
||||
|
@ -961,7 +961,7 @@ static SculptUndoNode *sculpt_undo_bmesh_push(Object *ob, PBVHNode *node, Sculpt
|
|||
* polys. A full copy like this is needed because entering
|
||||
* dynamic-topology immediately does topological edits
|
||||
* (converting polys to triangles) that the BMLog can't
|
||||
* fully restore from */
|
||||
* fully restore from. */
|
||||
CustomData_copy(
|
||||
&me->vdata, &unode->geom_vdata, CD_MASK_MESH.vmask, CD_DUPLICATE, me->totvert);
|
||||
CustomData_copy(
|
||||
|
@ -990,7 +990,7 @@ static SculptUndoNode *sculpt_undo_bmesh_push(Object *ob, PBVHNode *node, Sculpt
|
|||
case SCULPT_UNDO_COORDS:
|
||||
case SCULPT_UNDO_MASK:
|
||||
/* Before any vertex values get modified, ensure their
|
||||
* original positions are logged */
|
||||
* original positions are logged. */
|
||||
BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_ALL)
|
||||
{
|
||||
BM_log_vert_before_modified(ss->bm_log, vd.bm_vert, vd.cd_vert_mask_offset);
|
||||
|
@ -1030,14 +1030,14 @@ SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType
|
|||
SculptSession *ss = ob->sculpt;
|
||||
SculptUndoNode *unode;
|
||||
|
||||
/* list is manipulated by multiple threads, so we lock */
|
||||
/* List is manipulated by multiple threads, so we lock. */
|
||||
BLI_thread_lock(LOCK_CUSTOM1);
|
||||
|
||||
ss->needs_flush_to_id = 1;
|
||||
|
||||
if (ss->bm || ELEM(type, SCULPT_UNDO_DYNTOPO_BEGIN, SCULPT_UNDO_DYNTOPO_END)) {
|
||||
/* Dynamic topology stores only one undo node per stroke,
|
||||
* regardless of the number of PBVH nodes modified */
|
||||
* regardless of the number of PBVH nodes modified. */
|
||||
unode = sculpt_undo_bmesh_push(ob, node, type);
|
||||
BLI_thread_unlock(LOCK_CUSTOM1);
|
||||
return unode;
|
||||
|
@ -1090,11 +1090,11 @@ SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType
|
|||
break;
|
||||
}
|
||||
|
||||
/* store sculpt pivot */
|
||||
/* Store sculpt pivot. */
|
||||
copy_v3_v3(unode->pivot_pos, ss->pivot_pos);
|
||||
copy_v3_v3(unode->pivot_rot, ss->pivot_rot);
|
||||
|
||||
/* store active shape key */
|
||||
/* Store active shape key. */
|
||||
if (ss->shapekey_active) {
|
||||
BLI_strncpy(unode->shapeName, ss->shapekey_active->name, sizeof(ss->shapekey_active->name));
|
||||
}
|
||||
|
@ -1110,7 +1110,10 @@ SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType
|
|||
void sculpt_undo_push_begin(const char *name)
|
||||
{
|
||||
UndoStack *ustack = ED_undo_stack_get();
|
||||
bContext *C = NULL; /* special case, we never read from this. */
|
||||
|
||||
/* Special case, we never read from this. */
|
||||
bContext *C = NULL;
|
||||
|
||||
BKE_undosys_step_push_init_with_type(ustack, C, name, BKE_UNDOSYS_TYPE_SCULPT);
|
||||
}
|
||||
|
||||
|
@ -1119,7 +1122,7 @@ void sculpt_undo_push_end(void)
|
|||
UndoSculpt *usculpt = sculpt_undo_get_nodes();
|
||||
SculptUndoNode *unode;
|
||||
|
||||
/* we don't need normals in the undo stack */
|
||||
/* We don't need normals in the undo stack. */
|
||||
for (unode = usculpt->nodes.first; unode; unode = unode->next) {
|
||||
if (unode->no) {
|
||||
MEM_freeN(unode->no);
|
||||
|
@ -1146,14 +1149,14 @@ void sculpt_undo_push_end(void)
|
|||
|
||||
typedef struct SculptUndoStep {
|
||||
UndoStep step;
|
||||
/* note: will split out into list for multi-object-sculpt-mode. */
|
||||
/* Note: will split out into list for multi-object-sculpt-mode. */
|
||||
UndoSculpt data;
|
||||
} SculptUndoStep;
|
||||
|
||||
static void sculpt_undosys_step_encode_init(struct bContext *UNUSED(C), UndoStep *us_p)
|
||||
{
|
||||
SculptUndoStep *us = (SculptUndoStep *)us_p;
|
||||
/* dummy, memory is cleared anyway. */
|
||||
/* Dummy, memory is cleared anyway. */
|
||||
BLI_listbase_clear(&us->data.nodes);
|
||||
}
|
||||
|
||||
|
@ -1161,7 +1164,7 @@ static bool sculpt_undosys_step_encode(struct bContext *UNUSED(C),
|
|||
struct Main *bmain,
|
||||
UndoStep *us_p)
|
||||
{
|
||||
/* dummy, encoding is done along the way by adding tiles
|
||||
/* Dummy, encoding is done along the way by adding tiles
|
||||
* to the current 'SculptUndoStep' added by encode_init. */
|
||||
SculptUndoStep *us = (SculptUndoStep *)us_p;
|
||||
us->step.data_size = us->data.undo_size;
|
||||
|
@ -1248,7 +1251,7 @@ static void sculpt_undosys_step_decode(
|
|||
Object *ob = OBACT(view_layer);
|
||||
if (ob && (ob->type == OB_MESH)) {
|
||||
if (ob->mode & OB_MODE_SCULPT) {
|
||||
/* pass */
|
||||
/* Pass. */
|
||||
}
|
||||
else {
|
||||
ED_object_mode_generic_exit(bmain, depsgraph, scene, ob);
|
||||
|
|
Loading…
Reference in New Issue