Sculpt-dev: finish up merge

This commit is contained in:
Joseph Eagar 2022-04-30 01:09:57 -07:00
parent 2cb7a0066d
commit eb8b7e3292
16 changed files with 177 additions and 262 deletions

View File

@ -261,6 +261,10 @@ def keymap_init_from_data(km, km_items, is_modal=False):
def keyconfig_init_from_data(kc, keyconfig_data):
for item in keyconfig_data:
if len(item) != 3:
print("EEK!", item)
# Load data in the format defined above.
#
# Runs at load time, keep this fast!

View File

@ -4700,6 +4700,30 @@ def radial_control_properties(paint, prop, secondary_prop, secondary_rotation=Fa
],
}
def radial_control_properties_channels(paint, prop, secondary_prop, secondary_rotation=False, color=False, zoom=False, type="float"):
brush_path = 'tool_settings.' + paint + '.brush'
channels_path = brush_path + ".channels"
unified = "tool_settings." + paint + ".channels"
rotation = 'mask_texture_slot_angle' if secondary_rotation else 'texture_slot_angle'
return {
"properties": [("data_path_primary", '%s["%s"].%s_value' % (channels_path, prop, type)),
("data_path_secondary", '%s["%s"].%s_value' % (unified, prop, type) if secondary_prop else ''),
("use_secondary", '%s["%s"].inherit' % (channels_path, prop) if secondary_prop else ''),
#("rotation_path", '%s["%s"].float_value' % (channels_path,
#rotation)),
#("color_path", brush_path + '.cursor_color_add'),
#("fill_color_path", brush_path + '.color' if color else ''),
#("fill_color_override_path", unified_path + '.color' if color else
#''),
#("fill_color_override_test_path", unified_path +
#'.use_unified_color' if color else ''),
#("zoom_path", 'space_data.zoom' if zoom else ''),
#("image_id", brush_path + ''),
#("secondary_tex", secondary_rotation),
],
}
# Radial controls for the paint and sculpt modes.
@ -7394,7 +7418,8 @@ def km_3d_view_tool_sculpt_lasso_project(params):
None),]},)
def km_3d_view_tool_sculpt_box_project(params):
return ("3D View Tool: Sculpt, Box Project",
return ("3D View Tool: Sculpt, Lasso Project",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
{"items": [("sculpt.project_box_gesture", {"type": params.tool_mouse, "value": 'CLICK_DRAG'},
None),]},)

View File

@ -852,8 +852,6 @@ void BKE_pbvh_parallel_range_settings(struct TaskParallelSettings *settings,
struct MVert *BKE_pbvh_get_verts(const PBVH *pbvh);
const float (*BKE_pbvh_get_vert_normals(const PBVH *pbvh))[3];
PBVHColorBufferNode *BKE_pbvh_node_color_buffer_get(PBVHNode *node);
void BKE_pbvh_node_color_buffer_free(PBVH *pbvh);
bool BKE_pbvh_get_color_layer(const struct Mesh *me,
CustomDataLayer **r_layer,
AttributeDomain *r_attr);
@ -1186,6 +1184,7 @@ bool BKE_pbvh_cache_is_valid(const struct Object *ob,
int pbvh_type);
bool BKE_pbvh_cache(const struct Mesh *me, PBVH *pbvh);
PBVH *BKE_pbvh_get_or_free_cached(struct Object *ob, struct Mesh *me, PBVHType pbvh_type);
void BKE_pbvh_invalidate_cache(struct Object *ob);
void BKE_pbvh_set_cached(struct Object *ob, PBVH *pbvh);
void BKE_pbvh_set_face_areas(PBVH *pbvh, float *face_areas);
void BKE_pbvh_set_sculpt_verts(PBVH *pbvh, struct MSculptVert *sverts);

View File

@ -2217,102 +2217,66 @@ const CustomData_MeshMasks CD_MASK_BAREMESH_ORIGINDEX = {
};
const CustomData_MeshMasks CD_MASK_MESH = {
/* vmask */ (CD_MASK_MVERT | CD_MASK_MDEFORMVERT | CD_MASK_MVERT_SKIN | CD_MASK_PAINT_MASK |
<<<<<<< HEAD
CD_MASK_PROP_ALL | CD_MASK_PROP_COLOR | CD_MASK_CREASE | CD_MASK_MESH_ID),
/* emask */ (CD_MASK_MEDGE | CD_MASK_FREESTYLE_EDGE | CD_MASK_PROP_ALL | CD_MASK_MESH_ID),
=======
CD_MASK_PROP_ALL | CD_MASK_CREASE),
/* emask */ (CD_MASK_MEDGE | CD_MASK_FREESTYLE_EDGE | CD_MASK_PROP_ALL),
>>>>>>> origin/master
/* fmask */ 0,
/* pmask */
(CD_MASK_MPOLY | CD_MASK_FACEMAP | CD_MASK_FREESTYLE_FACE | CD_MASK_PROP_ALL |
CD_MASK_SCULPT_FACE_SETS | CD_MASK_MESH_ID),
/* lmask */
<<<<<<< HEAD
(CD_MASK_MLOOP | CD_MASK_MDISPS | CD_MASK_MLOOPUV | CD_MASK_PROP_BYTE_COLOR |
CD_MASK_CUSTOMLOOPNORMAL | CD_MASK_GRID_PAINT_MASK | CD_MASK_PROP_ALL | CD_MASK_MESH_ID),
=======
(CD_MASK_MLOOP | CD_MASK_MDISPS | CD_MASK_MLOOPUV | CD_MASK_CUSTOMLOOPNORMAL |
CD_MASK_GRID_PAINT_MASK | CD_MASK_PROP_ALL),
>>>>>>> origin/master
CD_MASK_GRID_PAINT_MASK | CD_MASK_PROP_ALL | CD_MASK_MESH_ID),
};
const CustomData_MeshMasks CD_MASK_DERIVEDMESH = {
/* vmask */ (CD_MASK_ORIGINDEX | CD_MASK_MDEFORMVERT | CD_MASK_SHAPEKEY | CD_MASK_MVERT_SKIN |
CD_MASK_PAINT_MASK | CD_MASK_ORCO | CD_MASK_CLOTH_ORCO | CD_MASK_PROP_ALL |
<<<<<<< HEAD
CD_MASK_PROP_COLOR | CD_MASK_CREASE | CD_MASK_MESH_ID),
/* emask */
(CD_MASK_ORIGINDEX | CD_MASK_FREESTYLE_EDGE | CD_MASK_PROP_ALL | CD_MASK_MESH_ID),
=======
CD_MASK_CREASE),
/* emask */ (CD_MASK_ORIGINDEX | CD_MASK_FREESTYLE_EDGE | CD_MASK_PROP_ALL),
>>>>>>> origin/master
/* emask */ (CD_MASK_ORIGINDEX | CD_MASK_FREESTYLE_EDGE | CD_MASK_PROP_ALL | CD_MASK_MESH_ID),
/* fmask */ (CD_MASK_ORIGINDEX | CD_MASK_ORIGSPACE | CD_MASK_PREVIEW_MCOL | CD_MASK_TANGENT),
/* pmask */
(CD_MASK_ORIGINDEX | CD_MASK_FREESTYLE_FACE | CD_MASK_FACEMAP | CD_MASK_PROP_ALL |
CD_MASK_SCULPT_FACE_SETS | CD_MASK_MESH_ID),
/* lmask */
<<<<<<< HEAD
(CD_MASK_MLOOPUV | CD_MASK_PROP_BYTE_COLOR | CD_MASK_CUSTOMLOOPNORMAL |
CD_MASK_PREVIEW_MLOOPCOL | CD_MASK_ORIGSPACE_MLOOP | CD_MASK_PROP_ALL |
(CD_MASK_MLOOPUV | CD_MASK_CUSTOMLOOPNORMAL | CD_MASK_PREVIEW_MLOOPCOL |
CD_MASK_ORIGSPACE_MLOOP | CD_MASK_PROP_ALL |
CD_MASK_MESH_ID), /* XXX MISSING CD_MASK_MLOOPTANGENT ? */
};
const CustomData_MeshMasks CD_MASK_BMESH = {
/* vmask */ (CD_MASK_MDEFORMVERT | CD_MASK_BWEIGHT | CD_MASK_MVERT_SKIN | CD_MASK_SHAPEKEY |
CD_MASK_SHAPE_KEYINDEX | CD_MASK_PAINT_MASK | CD_MASK_PROP_ALL |
CD_MASK_PROP_COLOR | CD_MASK_CREASE | CD_MASK_MESH_ID | CD_MASK_DYNTOPO_VERT),
CD_MASK_SHAPE_KEYINDEX | CD_MASK_PAINT_MASK | CD_MASK_PROP_ALL | CD_MASK_CREASE |
CD_MASK_MESH_ID | CD_MASK_DYNTOPO_VERT),
/* emask */
(CD_MASK_BWEIGHT | CD_MASK_CREASE | CD_MASK_FREESTYLE_EDGE | CD_MASK_PROP_ALL |
CD_MASK_MESH_ID),
=======
(CD_MASK_MLOOPUV | CD_MASK_CUSTOMLOOPNORMAL | CD_MASK_PREVIEW_MLOOPCOL |
CD_MASK_ORIGSPACE_MLOOP | CD_MASK_PROP_ALL), /* XXX MISSING CD_MASK_MLOOPTANGENT ? */
};
const CustomData_MeshMasks CD_MASK_BMESH = {
/* vmask */ (CD_MASK_MDEFORMVERT | CD_MASK_BWEIGHT | CD_MASK_MVERT_SKIN | CD_MASK_SHAPEKEY |
CD_MASK_SHAPE_KEYINDEX | CD_MASK_PAINT_MASK | CD_MASK_PROP_ALL | CD_MASK_CREASE),
/* emask */ (CD_MASK_BWEIGHT | CD_MASK_CREASE | CD_MASK_FREESTYLE_EDGE | CD_MASK_PROP_ALL),
>>>>>>> origin/master
/* fmask */ 0,
/* pmask */
(CD_MASK_FREESTYLE_FACE | CD_MASK_FACEMAP | CD_MASK_PROP_ALL | CD_MASK_SCULPT_FACE_SETS |
CD_MASK_MESH_ID),
/* lmask */
<<<<<<< HEAD
(CD_MASK_MDISPS | CD_MASK_MLOOPUV | CD_MASK_PROP_BYTE_COLOR | CD_MASK_CUSTOMLOOPNORMAL |
CD_MASK_GRID_PAINT_MASK | CD_MASK_PROP_ALL | CD_MASK_MESH_ID),
=======
(CD_MASK_MDISPS | CD_MASK_MLOOPUV | CD_MASK_CUSTOMLOOPNORMAL | CD_MASK_GRID_PAINT_MASK |
CD_MASK_PROP_ALL),
>>>>>>> origin/master
CD_MASK_PROP_ALL | CD_MASK_MESH_ID),
};
const CustomData_MeshMasks CD_MASK_EVERYTHING = {
/* vmask */ (CD_MASK_MVERT | CD_MASK_BM_ELEM_PYPTR | CD_MASK_ORIGINDEX | CD_MASK_MDEFORMVERT |
CD_MASK_BWEIGHT | CD_MASK_MVERT_SKIN | CD_MASK_ORCO | CD_MASK_CLOTH_ORCO |
CD_MASK_SHAPEKEY | CD_MASK_SHAPE_KEYINDEX | CD_MASK_PAINT_MASK |
CD_MASK_PROP_ALL | CD_MASK_CREASE),
CD_MASK_PROP_ALL | CD_MASK_CREASE | CD_MASK_MESH_ID | CD_MASK_DYNTOPO_VERT),
/* emask */
(CD_MASK_MEDGE | CD_MASK_BM_ELEM_PYPTR | CD_MASK_ORIGINDEX | CD_MASK_BWEIGHT | CD_MASK_CREASE |
CD_MASK_FREESTYLE_EDGE | CD_MASK_PROP_ALL),
CD_MASK_FREESTYLE_EDGE | CD_MASK_PROP_ALL | CD_MASK_MESH_ID),
/* fmask */
(CD_MASK_MFACE | CD_MASK_ORIGINDEX | CD_MASK_NORMAL | CD_MASK_MTFACE | CD_MASK_MCOL |
CD_MASK_ORIGSPACE | CD_MASK_TANGENT | CD_MASK_TESSLOOPNORMAL | CD_MASK_PREVIEW_MCOL |
CD_MASK_PROP_ALL),
/* pmask */
(CD_MASK_MPOLY | CD_MASK_BM_ELEM_PYPTR | CD_MASK_ORIGINDEX | CD_MASK_FACEMAP |
CD_MASK_FREESTYLE_FACE | CD_MASK_PROP_ALL | CD_MASK_SCULPT_FACE_SETS),
CD_MASK_FREESTYLE_FACE | CD_MASK_PROP_ALL | CD_MASK_SCULPT_FACE_SETS | CD_MASK_MESH_ID),
/* lmask */
(CD_MASK_MLOOP | CD_MASK_BM_ELEM_PYPTR | CD_MASK_MDISPS | CD_MASK_NORMAL | CD_MASK_MLOOPUV |
<<<<<<< HEAD
CD_MASK_PROP_BYTE_COLOR | CD_MASK_CUSTOMLOOPNORMAL | CD_MASK_MLOOPTANGENT |
CD_MASK_PREVIEW_MLOOPCOL | CD_MASK_ORIGSPACE_MLOOP | CD_MASK_GRID_PAINT_MASK |
CD_MASK_PROP_ALL),
=======
CD_MASK_CUSTOMLOOPNORMAL | CD_MASK_MLOOPTANGENT | CD_MASK_PREVIEW_MLOOPCOL |
CD_MASK_ORIGSPACE_MLOOP | CD_MASK_GRID_PAINT_MASK | CD_MASK_PROP_ALL),
>>>>>>> origin/master
CD_MASK_ORIGSPACE_MLOOP | CD_MASK_GRID_PAINT_MASK | CD_MASK_PROP_ALL | CD_MASK_MESH_ID),
};
static const LayerTypeInfo *layerType_getInfo(int type)

View File

@ -1943,17 +1943,12 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
&result->ldata, CD_PROP_BYTE_COLOR, surface->output_name);
/* if output layer is lost from a constructive modifier, re-add it */
if (!mloopcol && dynamicPaint_outputLayerExists(surface, ob, 0)) {
<<<<<<< HEAD
mloopcol = CustomData_add_layer_named(
&result->ldata, CD_PROP_BYTE_COLOR, CD_CALLOC, NULL, totloop, surface->output_name);
=======
mloopcol = CustomData_add_layer_named(&result->ldata,
CD_PROP_BYTE_COLOR,
CD_CALLOC,
NULL,
totloop,
surface->output_name);
>>>>>>> origin/master
}
/* wet layer */
@ -1961,17 +1956,12 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
&result->ldata, CD_PROP_BYTE_COLOR, surface->output_name2);
/* if output layer is lost from a constructive modifier, re-add it */
if (!mloopcol_wet && dynamicPaint_outputLayerExists(surface, ob, 1)) {
<<<<<<< HEAD
mloopcol_wet = CustomData_add_layer_named(
&result->ldata, CD_PROP_BYTE_COLOR, CD_CALLOC, NULL, totloop, surface->output_name2);
=======
mloopcol_wet = CustomData_add_layer_named(&result->ldata,
CD_PROP_BYTE_COLOR,
CD_CALLOC,
NULL,
totloop,
surface->output_name2);
>>>>>>> origin/master
}
data.ob = ob;

View File

@ -1277,17 +1277,6 @@ static ComponentAttributeProviders create_attribute_providers_for_mesh()
make_derived_read_attribute<MLoopUV, float2, get_loop_uv>,
make_derived_write_attribute<MLoopUV, float2, get_loop_uv, set_loop_uv>);
<<<<<<< HEAD
static NamedLegacyCustomDataProvider vertex_colors(
ATTR_DOMAIN_CORNER,
CD_PROP_COLOR,
CD_PROP_BYTE_COLOR,
corner_access,
make_derived_read_attribute<MLoopCol, ColorGeometry4f, get_loop_color>,
make_derived_write_attribute<MLoopCol, ColorGeometry4f, get_loop_color, set_loop_color>);
=======
>>>>>>> origin/master
static VertexGroupsAttributeProvider vertex_groups;
static CustomDataAttributeProvider corner_custom_data(ATTR_DOMAIN_CORNER, corner_access);
static CustomDataAttributeProvider point_custom_data(ATTR_DOMAIN_POINT, point_access);

View File

@ -799,7 +799,7 @@ void BKE_pbvh_free(PBVH *pbvh)
PBVHNode *node = &pbvh->nodes[i];
if (node->flag & PBVH_Leaf) {
pbvh_free_draw_buffers(node);
pbvh_free_draw_buffers(pbvh, node);
if (node->vert_indices) {
MEM_freeN((void *)node->vert_indices);
@ -1547,7 +1547,7 @@ static void pbvh_update_draw_buffer_cb(void *__restrict userdata,
} break;
case PBVH_BMESH:
if (BKE_pbvh_bmesh_check_tris(pbvh, node)) {
pbvh_free_draw_buffers(node);
pbvh_free_draw_buffers(pbvh, node);
node->tot_mat_draw_buffers = node->tot_tri_buffers;
pbvh_bmesh_check_other_verts(node);
@ -1644,7 +1644,7 @@ void pbvh_update_free_all_draw_buffers(PBVH *pbvh, PBVHNode *node)
}
}
static void pbvh_update_draw_buffers(PBVH *pbvh, PBVHNode **nodes, int totnode, int update_flag)
static void pbvh_update_draw_buffers(PBVH *pbvh, Mesh *me, PBVHNode **nodes, int totnode, int update_flag)
{
CustomData *vdata;
@ -1706,9 +1706,6 @@ static void pbvh_update_draw_buffers(PBVH *pbvh, PBVHNode **nodes, int totnode,
PBVHNode *node = nodes[n];
if (node->flag & PBVH_RebuildDrawBuffers) {
pbvh_free_draw_buffers(pbvh, node);
=======
pbvh_free_draw_buffers(pbvh, node);
>>>>>>> origin/master
}
else if ((node->flag & PBVH_UpdateDrawBuffers)) {
pbvh_update_free_all_draw_buffers(pbvh, node);
@ -3478,40 +3475,6 @@ void BKE_pbvh_gather_proxies(PBVH *pbvh, PBVHNode ***r_array, int *r_tot)
*r_tot = tot;
}
PBVHColorBufferNode *BKE_pbvh_node_color_buffer_get(PBVHNode *node)
{
unsigned int totvert;
if (node->bm_unique_verts) {
totvert = BLI_table_gset_len(node->bm_unique_verts);
}
else {
totvert = node->uniq_verts;
}
if (node->color_buffer.color && node->color_buffer.size != totvert) {
MEM_freeN(node->color_buffer.color);
node->color_buffer.color = NULL;
}
if (!node->color_buffer.color) {
node->color_buffer.color = MEM_callocN(sizeof(float[4]) * totvert, "Color buffer");
node->color_buffer.size = totvert;
}
return &node->color_buffer;
}
void BKE_pbvh_node_color_buffer_free(PBVH *pbvh)
{
PBVHNode **nodes;
int totnode;
BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode);
for (int i = 0; i < totnode; i++) {
MEM_SAFE_FREE(nodes[i]->color_buffer.color);
}
MEM_SAFE_FREE(nodes);
}
void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int mode)
{
struct CCGElem **grids;
@ -4942,6 +4905,16 @@ void BKE_pbvh_clear_cache(PBVH *preserve)
pbvh_clear_cached_pbvhs(NULL);
}
void BKE_pbvh_invalidate_cache(Object *ob)
{
Object *ob_orig = DEG_get_original_object(ob);
PBVH *pbvh = BLI_ghash_lookup(cached_pbvhs, ob_orig->id.name);
if (pbvh) {
BKE_pbvh_cache_remove(pbvh);
}
}
PBVH *BKE_pbvh_get_or_free_cached(Object *ob, Mesh *me, PBVHType pbvh_type)
{
Object *ob_orig = DEG_get_original_object(ob);

View File

@ -3227,7 +3227,7 @@ static void BKE_pbvh_bmesh_correct_tree(PBVH *pbvh, PBVHNode *node, PBVHNode *pa
node->children_offset = 0;
pbvh_free_all_draw_buffers(node);
pbvh_free_draw_buffers(pbvh, node);
// rebuild bm_other_verts
BMFace *f;
@ -3333,7 +3333,7 @@ static void pbvh_bmesh_compact_tree(PBVH *bvh)
n->layer_disp = NULL;
}
pbvh_free_all_draw_buffers(n);
pbvh_free_draw_buffers(bvh, n);
if (n->vert_indices) {
MEM_freeN((void *)n->vert_indices);
@ -3742,7 +3742,7 @@ static void pbvh_bmesh_join_nodes(PBVH *bvh)
n->layer_disp = NULL;
}
pbvh_free_all_draw_buffers(n);
pbvh_free_draw_buffers(bvh, n);
if (n->vert_indices) {
MEM_freeN((void *)n->vert_indices);

View File

@ -354,7 +354,6 @@ bool pbvh_bmesh_node_nearest_to_ray(PBVH *pbvh,
void pbvh_bmesh_normals_update(PBVH *pbvh, PBVHNode **nodes, int totnode);
void pbvh_free_all_draw_buffers(PBVHNode *node);
void pbvh_update_free_all_draw_buffers(PBVH *pbvh, PBVHNode *node);
BLI_INLINE int pbvh_bmesh_node_index_from_vert(PBVH *pbvh, const BMVert *key)

View File

@ -60,6 +60,7 @@
#include "BKE_object.h"
#include "BKE_paint.h"
#include "BKE_particle.h"
#include "BKE_pbvh.h"
#include "BKE_pointcache.h"
#include "BKE_report.h"
#include "BKE_scene.h"
@ -745,6 +746,10 @@ bool ED_object_editmode_enter_ex(Main *bmain, Scene *scene, Object *ob, int flag
return false;
}
if (ob->type == OB_MESH) {
BKE_pbvh_invalidate_cache(ob);
}
ob->restore_mode = ob->mode;
ob->mode = OB_MODE_EDIT;

View File

@ -873,7 +873,7 @@ bool ED_object_modifier_apply(Main *bmain,
bool allow_multi_user = mode == MODIFIER_APPLY_SHAPE;
if (md) {
const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
const ModifierTypeInfo *mti = BKE_modifier_get_info((ModifierType)md->type);
allow_multi_user |= ELEM(
mti->type, eModifierTypeType_NonGeometrical, eModifierTypeType_OnlyDeform);

View File

@ -1116,12 +1116,12 @@ static void sculpt_gesture_trim_calculate_depth(SculptGestureContext *sgcontext)
Brush *brush = BKE_paint_brush(&sd->paint);
Scene *scene = CTX_data_scene(vc->C);
if (!BKE_brush_use_locked_size(scene, brush)) {
if (!BKE_brush_use_locked_size(scene, brush, true)) {
depth_radius = paint_calc_object_space_radius(
vc, ss->gesture_initial_location, BKE_brush_size_get(scene, brush));
vc, ss->gesture_initial_location, BKE_brush_size_get(scene, brush, true));
}
else {
depth_radius = BKE_brush_unprojected_radius_get(scene, brush);
depth_radius = BKE_brush_unprojected_radius_get(scene, brush, true);
}
}

View File

@ -1350,7 +1350,7 @@ static void ed_vwpaintmode_enter_generic(
/* Create vertex/weight paint mode session data */
if (ob->sculpt) {
if (ob->sculpt->cache) {
SCULPT_cache_free(ob->sculpt->cache, ob, ob->sculpt->cache);
SCULPT_cache_free(ob->sculpt, ob, ob->sculpt->cache);
ob->sculpt->cache = nullptr;
}
BKE_sculptsession_free(ob);
@ -1419,7 +1419,7 @@ static void ed_vwpaintmode_exit_generic(Object *ob, const eObjectMode mode_flag)
/* If the cache is not released by a cancel or a done, free it now. */
if (ob->sculpt && ob->sculpt->cache) {
SCULPT_cache_free(ob->sculpt->cache, ob, ob->sculpt->cache);
SCULPT_cache_free(ob->sculpt, ob, ob->sculpt->cache);
ob->sculpt->cache = nullptr;
}
@ -2674,7 +2674,7 @@ static void wpaint_stroke_done(const bContext *C, PaintStroke *stroke)
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
SCULPT_cache_free(ob->sculpt->cache, ob, ob->sculpt->cache);
SCULPT_cache_free(ob->sculpt, ob, ob->sculpt->cache);
ob->sculpt->cache = nullptr;
}
@ -2725,7 +2725,7 @@ static void wpaint_cancel(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_active_object(C);
if (ob->sculpt->cache) {
SCULPT_cache_free(ob->sculpt->cache, ob, ob->sculpt->cache);
SCULPT_cache_free(ob->sculpt, ob, ob->sculpt->cache);
ob->sculpt->cache = nullptr;
}
@ -3041,8 +3041,13 @@ static void do_vpaint_brush_blur_loops(bContext *C,
const SculptVertexPaintGeomMap *gmap = &ss->mode.vpaint.gmap;
const StrokeCache *cache = ss->cache;
float brush_size_pressure, brush_alpha_value, brush_alpha_pressure;
get_brush_alpha_data(
scene, ss, brush, &brush_size_pressure, &brush_alpha_value, &brush_alpha_pressure);
get_brush_alpha_data(scene,
ss,
brush,
&brush_size_pressure,
&brush_alpha_value,
&brush_alpha_pressure,
paint_use_channels(C));
const bool use_normal = vwpaint_use_normal(vp);
const bool use_vert_sel = (me->editflag &
(ME_EDIT_PAINT_FACE_SEL | ME_EDIT_PAINT_VERT_SEL)) != 0;
@ -3183,8 +3188,13 @@ static void do_vpaint_brush_blur_verts(bContext *C,
const SculptVertexPaintGeomMap *gmap = &ss->mode.vpaint.gmap;
const StrokeCache *cache = ss->cache;
float brush_size_pressure, brush_alpha_value, brush_alpha_pressure;
get_brush_alpha_data(
scene, ss, brush, &brush_size_pressure, &brush_alpha_value, &brush_alpha_pressure);
get_brush_alpha_data(scene,
ss,
brush,
&brush_size_pressure,
&brush_alpha_value,
&brush_alpha_pressure,
paint_use_channels(C));
const bool use_normal = vwpaint_use_normal(vp);
const bool use_vert_sel = (me->editflag &
(ME_EDIT_PAINT_FACE_SEL | ME_EDIT_PAINT_VERT_SEL)) != 0;
@ -3318,7 +3328,6 @@ static void do_vpaint_brush_smear(bContext *C,
const PBVHType pbvh_type = BKE_pbvh_type(ss->pbvh);
const bool has_grids = (pbvh_type == PBVH_GRIDS);
const Brush *brush = ob->sculpt->cache->brush;
const Scene *scene = CTX_data_scene(C);
Color *color_curr = static_cast<Color *>(vpd->smear.color_curr);
@ -3329,8 +3338,13 @@ static void do_vpaint_brush_smear(bContext *C,
for (int n : range) {
float brush_size_pressure, brush_alpha_value, brush_alpha_pressure;
get_brush_alpha_data(
scene, ss, brush, &brush_size_pressure, &brush_alpha_value, &brush_alpha_pressure);
get_brush_alpha_data(scene,
ss,
brush,
&brush_size_pressure,
&brush_alpha_value,
&brush_alpha_pressure,
paint_use_channels(C));
float brush_dir[3];
const bool use_normal = vwpaint_use_normal(vp);
const bool use_vert_sel = (me->editflag &
@ -3614,8 +3628,13 @@ static void vpaint_do_draw(bContext *C,
const StrokeCache *cache = ss->cache;
float brush_size_pressure, brush_alpha_value, brush_alpha_pressure;
get_brush_alpha_data(
scene, ss, brush, &brush_size_pressure, &brush_alpha_value, &brush_alpha_pressure);
get_brush_alpha_data(scene,
ss,
brush,
&brush_size_pressure,
&brush_alpha_value,
&brush_alpha_pressure,
paint_use_channels(C));
const bool use_normal = vwpaint_use_normal(vp);
const bool use_vert_sel = (me->editflag &
(ME_EDIT_PAINT_FACE_SEL | ME_EDIT_PAINT_VERT_SEL)) != 0;
@ -4027,7 +4046,7 @@ static void vpaint_stroke_done(const bContext *C, PaintStroke *stroke)
SCULPT_undo_push_end(ob);
SCULPT_cache_free(ob->sculpt->cache, ob, ob->sculpt->cache);
SCULPT_cache_free(ob->sculpt, ob, ob->sculpt->cache);
ob->sculpt->cache = nullptr;
}
@ -4087,7 +4106,7 @@ static void vpaint_cancel(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_active_object(C);
if (ob->sculpt->cache) {
SCULPT_cache_free(ob->sculpt->cache, ob, ob->sculpt->cache);
SCULPT_cache_free(ob->sculpt, ob, ob->sculpt->cache);
ob->sculpt->cache = nullptr;
}

View File

@ -116,14 +116,26 @@
static bool sculpt_check_boundary_vertex_in_base_mesh(const SculptSession *ss,
const SculptVertRef index);
typedef void (*BrushActionFunc)(
Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSettings *ups, void *data);
typedef void (*BrushActionFunc)(Sculpt *sd,
Object *ob,
Brush *brush,
UnifiedPaintSettings *ups,
PaintModeSettings *paint_mode_settings,
void *userdata);
void sculpt_combine_proxies(Sculpt *sd, Object *ob);
static void SCULPT_run_commandlist(
Sculpt *sd, Object *ob, Brush *brush, BrushCommandList *list, UnifiedPaintSettings *ups);
static void do_symmetrical_brush_actions(
Sculpt *sd, Object *ob, BrushActionFunc action, UnifiedPaintSettings *ups, void *userdata);
static void SCULPT_run_commandlist(Sculpt *sd,
Object *ob,
Brush *brush,
BrushCommandList *list,
UnifiedPaintSettings *ups,
PaintModeSettings *paint_mode_settings);
static void do_symmetrical_brush_actions(Sculpt *sd,
Object *ob,
BrushActionFunc action,
UnifiedPaintSettings *ups,
PaintModeSettings *paint_mode_settings,
void *userdata);
/* Sculpt API to get brush channel data
If ss->cache exists then ss->cache->channels_final
@ -2903,8 +2915,6 @@ static void paint_mesh_restore_co(Sculpt *sd, Object *ob)
BKE_pbvh_parallel_range_settings(&settings, true, totnode);
BLI_task_parallel_range(0, totnode, &data, paint_mesh_restore_co_task_cb, &settings);
BKE_pbvh_node_color_buffer_free(ss->pbvh);
MEM_SAFE_FREE(nodes);
}
@ -4721,7 +4731,7 @@ static void sculpt_topology_update(Sculpt *sd,
Object *ob,
Brush *brush,
UnifiedPaintSettings *UNUSED(ups),
void *UNUSED(userdata))
void *UNUSED(userdata),
PaintModeSettings *UNUSED(paint_mode_settings))
{
SculptSession *ss = ob->sculpt;
@ -4918,6 +4928,7 @@ static void get_nodes_undo(Sculpt *sd,
Object *ob,
Brush *brush,
UnifiedPaintSettings *ups,
PaintModeSettings *paint_mode_settings,
BrushRunCommandData *data,
int tool)
{
@ -5081,8 +5092,12 @@ static void sculpt_apply_alt_smmoth_settings(SculptSession *ss, Sculpt *sd, Brus
BRUSHSET_LOOKUP(ss->cache->channels_final, projection), ch, parentch, false, true);
}
static void SCULPT_run_command(
Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSettings *ups, void *userdata)
static void SCULPT_run_command(Sculpt *sd,
Object *ob,
Brush *brush,
UnifiedPaintSettings *ups,
PaintModeSettings *paint_mode_settings,
void *userdata)
{
SculptSession *ss = ob->sculpt;
BrushRunCommandData *data = userdata;
@ -5102,7 +5117,7 @@ static void SCULPT_run_command(
ss->cache->radius_squared = radius * radius;
ss->cache->initial_radius = radius;
get_nodes_undo(sd, ob, ss->cache->brush, ups, data, cmd->tool);
get_nodes_undo(sd, ob, ss->cache->brush, ups, paint_mode_settings, data, cmd->tool);
PBVHNode **nodes = data->nodes;
int totnode = data->totnode;
@ -5159,7 +5174,7 @@ static void SCULPT_run_command(
}
else {
ss->cache->bstrength = brush_strength(
sd, ss->cache, calc_symmetry_feather(sd, ss->cache), ups);
sd, ss->cache, calc_symmetry_feather(sd, ss->cache), ups, paint_mode_settings);
}
// do not pressure map brush2->alpha now that we've used it to build ss->cache->bstrength
@ -5359,7 +5374,7 @@ static void SCULPT_run_command(
}
break;
case SCULPT_TOOL_DYNTOPO:
sculpt_topology_update(sd, ob, brush, ups, NULL);
sculpt_topology_update(sd, ob, brush, ups, NULL, paint_mode_settings);
break;
case SCULPT_TOOL_AUTO_FSET:
SCULPT_do_auto_face_set(sd, ob, nodes, totnode);
@ -5398,8 +5413,12 @@ static void SCULPT_run_command(
MEM_SAFE_FREE(nodes);
}
static void SCULPT_run_commandlist(
Sculpt *sd, Object *ob, Brush *brush, BrushCommandList *list, UnifiedPaintSettings *ups)
static void SCULPT_run_commandlist(Sculpt *sd,
Object *ob,
Brush *brush,
BrushCommandList *list,
UnifiedPaintSettings *ups,
PaintModeSettings *paint_mode_settings)
{
SculptSession *ss = ob->sculpt;
Brush *oldbrush = ss->cache->brush;
@ -5530,7 +5549,7 @@ static void SCULPT_run_commandlist(
BKE_brush_channelset_apply_mapping(cmd->params_mapped, &ss->cache->input_mapping);
BKE_brush_channelset_clear_inherit(cmd->params_mapped);
do_symmetrical_brush_actions(sd, ob, SCULPT_run_command, ups, &data);
do_symmetrical_brush_actions(sd, ob, SCULPT_run_command, ups, paint_mode_settings, &data);
sculpt_combine_proxies(sd, ob);
}
@ -5867,26 +5886,13 @@ void SCULPT_cache_calc_brushdata_symm(StrokeCache *cache,
}
}
<<<<<<< HEAD
=======
typedef void (*BrushActionFunc)(Sculpt *sd,
Object *ob,
Brush *brush,
UnifiedPaintSettings *ups,
PaintModeSettings *paint_mode_settings);
>>>>>>> origin/master
static void do_tiled(Sculpt *sd,
Object *ob,
Brush *brush,
UnifiedPaintSettings *ups,
<<<<<<< HEAD
PaintModeSettings *paint_mode_settings,
BrushActionFunc action,
void *userdata)
=======
PaintModeSettings *paint_mode_settings,
BrushActionFunc action)
>>>>>>> origin/master
{
SculptSession *ss = ob->sculpt;
StrokeCache *cache = ss->cache;
@ -5920,11 +5926,7 @@ static void do_tiled(Sculpt *sd,
/* First do the "un-tiled" position to initialize the stroke for this location. */
cache->tile_pass = 0;
<<<<<<< HEAD
action(sd, ob, brush, ups, userdata);
=======
action(sd, ob, brush, ups, paint_mode_settings);
>>>>>>> origin/master
action(sd, ob, brush, ups, paint_mode_settings, userdata);
/* Now do it for all the tiles. */
copy_v3_v3_int(cur, start);
@ -5943,11 +5945,7 @@ static void do_tiled(Sculpt *sd,
cache->plane_offset[dim] = cur[dim] * step[dim];
cache->initial_location[dim] = cur[dim] * step[dim] + original_initial_location[dim];
}
<<<<<<< HEAD
action(sd, ob, brush, ups, userdata);
=======
action(sd, ob, brush, ups, paint_mode_settings);
>>>>>>> origin/master
action(sd, ob, brush, ups, paint_mode_settings, userdata);
}
}
}
@ -5970,11 +5968,7 @@ static void do_radial_symmetry(Sculpt *sd,
const float angle = 2.0f * M_PI * i / sd->radial_symm[axis - 'X'];
ss->cache->radial_symmetry_pass = i;
SCULPT_cache_calc_brushdata_symm(ss->cache, symm, axis, angle);
<<<<<<< HEAD
do_tiled(sd, ob, brush, ups, action, userdata);
=======
do_tiled(sd, ob, brush, ups, paint_mode_settings, action);
>>>>>>> origin/master
do_tiled(sd, ob, brush, ups, paint_mode_settings, action, userdata);
}
}
@ -5993,16 +5987,12 @@ static void sculpt_fix_noise_tear(Sculpt *sd, Object *ob)
}
}
<<<<<<< HEAD
static void do_symmetrical_brush_actions(
Sculpt *sd, Object *ob, BrushActionFunc action, UnifiedPaintSettings *ups, void *userdata)
=======
static void do_symmetrical_brush_actions(Sculpt *sd,
Object *ob,
BrushActionFunc action,
UnifiedPaintSettings *ups,
PaintModeSettings *paint_mode_settings)
>>>>>>> origin/master
PaintModeSettings *paint_mode_settings,
void *userdata)
{
Brush *brush = BKE_paint_brush(&sd->paint);
SculptSession *ss = ob->sculpt;
@ -6024,19 +6014,12 @@ static void do_symmetrical_brush_actions(Sculpt *sd,
cache->radial_symmetry_pass = 0;
SCULPT_cache_calc_brushdata_symm(cache, i, 0, 0);
<<<<<<< HEAD
do_tiled(sd, ob, brush, ups, action, userdata);
do_radial_symmetry(sd, ob, brush, ups, action, i, 'X', feather, userdata);
do_radial_symmetry(sd, ob, brush, ups, action, i, 'Y', feather, userdata);
do_radial_symmetry(sd, ob, brush, ups, action, i, 'Z', feather, userdata);
=======
do_tiled(sd, ob, brush, ups, paint_mode_settings, action);
do_tiled(sd, ob, brush, ups, paint_mode_settings, action, userdata);
do_radial_symmetry(sd, ob, brush, ups, paint_mode_settings, action, i, 'X', feather);
do_radial_symmetry(sd, ob, brush, ups, paint_mode_settings, action, i, 'Y', feather);
do_radial_symmetry(sd, ob, brush, ups, paint_mode_settings, action, i, 'Z', feather);
>>>>>>> origin/master
do_radial_symmetry(sd, ob, brush, ups, paint_mode_settings, action, i, 'X', feather, userdata);
do_radial_symmetry(sd, ob, brush, ups, paint_mode_settings, action, i, 'Y', feather, userdata);
do_radial_symmetry(sd, ob, brush, ups, paint_mode_settings, action, i, 'Z', feather, userdata);
}
}
@ -6067,25 +6050,6 @@ bool SCULPT_mode_poll(bContext *C)
return ob && ob->mode & OB_MODE_SCULPT;
}
<<<<<<< HEAD
bool SCULPT_vertex_colors_poll(bContext *C)
{
return SCULPT_mode_poll(C);
}
bool SCULPT_vertex_colors_poll_no_bmesh(bContext *C)
{
Object *ob = CTX_data_active_object(C);
if (ob && ob->sculpt && ob->sculpt->bm) {
return false;
}
return SCULPT_mode_poll(C);
}
=======
>>>>>>> origin/master
bool SCULPT_mode_poll_view3d(bContext *C)
{
return (SCULPT_mode_poll(C) && CTX_wm_region_view3d(C));
@ -7794,7 +7758,24 @@ static bool over_mesh(bContext *C, struct wmOperator *UNUSED(op), float x, float
return SCULPT_stroke_get_location(C, co, mouse);
}
<<<<<<< HEAD
bool SCULPT_handles_colors_report(SculptSession *ss, ReportList *reports)
{
switch (BKE_pbvh_type(ss->pbvh)) {
case PBVH_FACES:
return true;
case PBVH_BMESH:
BKE_report(reports, RPT_ERROR, "Not supported in dynamic topology mode");
return false;
case PBVH_GRIDS:
BKE_report(reports, RPT_ERROR, "Not supported in multiresolution mode");
return false;
}
BLI_assert_msg(0, "PBVH corruption, type was invalid.");
return false;
}
static bool sculpt_stroke_test_start(bContext *C, struct wmOperator *op, const float mouse[2])
{
if (BKE_paintmode_get_active_from_context(C) == PAINT_MODE_SCULPT) {
@ -7830,28 +7811,6 @@ static bool sculpt_stroke_test_start(bContext *C, struct wmOperator *op, const f
}
}
=======
bool SCULPT_handles_colors_report(SculptSession *ss, ReportList *reports)
{
switch (BKE_pbvh_type(ss->pbvh)) {
case PBVH_FACES:
return true;
case PBVH_BMESH:
BKE_report(reports, RPT_ERROR, "Not supported in dynamic topology mode");
return false;
case PBVH_GRIDS:
BKE_report(reports, RPT_ERROR, "Not supported in multiresolution mode");
return false;
}
BLI_assert_msg(0, "PBVH corruption, type was invalid.");
return false;
}
static bool sculpt_stroke_test_start(bContext *C, struct wmOperator *op, const float mouse[2])
{
>>>>>>> origin/master
/* Don't start the stroke until mouse goes over the mesh.
* NOTE: mouse will only be null when re-executing the saved stroke.
* We have exception for 'exec' strokes since they may not set 'mouse',
@ -7926,11 +7885,13 @@ static void sculpt_stroke_update_step(bContext *C,
{
UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings;
ToolSettings *ts = CTX_data_tool_settings(C);
UnifiedPaintSettings *ups = &ts->unified_paint_settings;
PaintModeSettings *paint_mode_settings = &ts->paint_mode;
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
Object *ob = CTX_data_active_object(C);
SculptSession *ss = ob->sculpt;
<<<<<<< HEAD
Brush *brush = BKE_paint_brush(&sd->paint);
if (ss->cache->channels_final) {
@ -7983,7 +7944,8 @@ static void sculpt_stroke_update_step(bContext *C,
sd->smooth_strength_factor = BRUSHSET_GET_FLOAT(
ss->cache->channels_final, smooth_strength_factor, NULL);
ss->cache->bstrength = brush_strength(sd, ss->cache, calc_symmetry_feather(sd, ss->cache), ups);
ss->cache->bstrength = brush_strength(
sd, ss->cache, calc_symmetry_feather(sd, ss->cache), ups, paint_mode_settings);
// we have to evaluate channel mappings here manually
BrushChannel *ch = BRUSHSET_LOOKUP_FINAL(brush->channels, sd->channels, strength);
@ -8016,10 +7978,7 @@ static void sculpt_stroke_update_step(bContext *C,
if (SCULPT_get_tool(ss, brush) == SCULPT_TOOL_SCENE_PROJECT) {
SCULPT_stroke_cache_snap_context_init(C, ob);
}
=======
const Brush *brush = BKE_paint_brush(&sd->paint);
ToolSettings *tool_settings = CTX_data_tool_settings(C);
>>>>>>> origin/master
SCULPT_stroke_modifiers_check(C, ob, brush);
if (itemptr) {
@ -8087,8 +8046,7 @@ static void sculpt_stroke_update_step(bContext *C,
brush, ss->cache->channels_final, list, tool, &ss->cache->input_mapping);
}
<<<<<<< HEAD
SCULPT_run_commandlist(sd, ob, brush, ss->cache->commandlist, ups);
SCULPT_run_commandlist(sd, ob, brush, ss->cache->commandlist, ups, paint_mode_settings);
float location[3];
@ -8123,14 +8081,6 @@ static void sculpt_stroke_update_step(bContext *C,
if (SCULPT_get_tool(ss, brush) == SCULPT_TOOL_FAIRING) {
SCULPT_fairing_brush_exec_fairing_for_cache(sd, ob);
}
=======
if (SCULPT_stroke_is_dynamic_topology(ss, brush)) {
do_symmetrical_brush_actions(sd, ob, sculpt_topology_update, ups, &tool_settings->paint_mode);
}
do_symmetrical_brush_actions(sd, ob, do_brush_action, ups, &tool_settings->paint_mode);
sculpt_combine_proxies(sd, ob);
>>>>>>> origin/master
/* Hack to fix noise texture tearing mesh. */
sculpt_fix_noise_tear(sd, ob);
@ -8159,10 +8109,9 @@ static void sculpt_stroke_update_step(bContext *C,
if (SCULPT_get_tool(ss, brush) == SCULPT_TOOL_MASK) {
SCULPT_flush_update_step(C, SCULPT_UPDATE_MASK);
}
<<<<<<< HEAD
else if (ELEM(SCULPT_get_tool(ss, brush), SCULPT_TOOL_PAINT, SCULPT_TOOL_SMEAR)) {
SCULPT_flush_update_step(C, SCULPT_UPDATE_COLOR);
=======
}
else if (ELEM(brush->sculpt_tool, SCULPT_TOOL_PAINT, SCULPT_TOOL_SMEAR)) {
if (SCULPT_use_image_paint_brush(&tool_settings->paint_mode, ob)) {
SCULPT_flush_update_step(C, SCULPT_UPDATE_IMAGE);
@ -8170,7 +8119,6 @@ static void sculpt_stroke_update_step(bContext *C,
else {
SCULPT_flush_update_step(C, SCULPT_UPDATE_COLOR);
}
>>>>>>> origin/master
}
else {
SCULPT_flush_update_step(C, SCULPT_UPDATE_COORDS);
@ -8235,7 +8183,6 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str
int tool = SCULPT_get_tool(ss, brush); // save tool for after we've freed ss->cache
BKE_pbvh_node_color_buffer_free(ss->pbvh);
SCULPT_cache_free(ss, ob, ss->cache);
ss->cache = NULL;

View File

@ -167,12 +167,14 @@ template<typename ImageBuffer> class PaintingKernel {
continue;
}
SculptVertRef fakevert = BKE_pbvh_make_vref(0LL);
float4 color = image_accessor.read_pixel(image_buffer);
const float3 normal(0.0f, 0.0f, 0.0f);
const float3 face_normal(0.0f, 0.0f, 0.0f);
const float mask = 0.0f;
const float falloff_strength = SCULPT_brush_strength_factor(
ss, brush, pixel_pos, sqrtf(test.dist), normal, face_normal, mask, 0, thread_id);
ss, brush, pixel_pos, sqrtf(test.dist), normal, face_normal, mask, fakevert, thread_id);
float4 paint_color = brush_color * falloff_strength * brush_strength;
float4 buffer_color;
blend_color_mix_float(buffer_color, color, paint_color);

View File

@ -129,7 +129,6 @@ const EnumPropertyItem rna_enum_brush_sculpt_tool_items[] = {
{SCULPT_TOOL_SMEAR, "SMEAR", ICON_BRUSH_SCULPT_DRAW, "Smear", ""},
{SCULPT_TOOL_FAIRING, "FAIRING", ICON_BRUSH_MASK, "Fairing", ""},
{SCULPT_TOOL_SCENE_PROJECT, "SCENE_PROJECT", ICON_BRUSH_MASK, "Scene Project", ""},
{SCULPT_TOOL_DRAW_FACE_SETS, "DRAW_FACE_SETS", ICON_BRUSH_MASK, "Draw Face Sets", ""},
{SCULPT_TOOL_SYMMETRIZE, "SYMMETRIZE", ICON_BRUSH_SCULPT_DRAW, "Symmetrize", ""},
{SCULPT_TOOL_ARRAY, "ARRAY", ICON_BRUSH_SCULPT_DRAW, "Array", ""},
{SCULPT_TOOL_VCOL_BOUNDARY, "VCOL_BOUNDARY", ICON_BRUSH_VCOL_BOUNDARY, "Sharpen Color Boundary", ""},