Sculpt-dev: add option to ignore UVs

* Added option to ignore UVs for sculpt
  mode.
* Tweaked sculpt header a bit.
This commit is contained in:
Joseph Eagar 2021-12-14 11:16:10 -08:00
parent 4a9495ef7d
commit 9f7f437af7
15 changed files with 143 additions and 38 deletions

View File

@ -1148,11 +1148,11 @@ class FalloffPanel(BrushPanel):
if mode == "SCULPT" and "falloff_curve" in brush.channels:
ch, path = UnifiedPaintPanel.get_channel(context, brush, "falloff_curve", need_path=True)
path += ".curve.curve"
template_curve(layout, ch.curve, "curve", path, True)
if ch.curve.curve_preset == "CUSTOM":
template_curve(layout, ch.curve, "curve", path, True)
UnifiedPaintPanel.channel_unified(layout, context, brush, "falloff_shape", expand=True)
#layout.prop(brush, "falloff_shape", expand=True)
return
col = layout.column(align=True)

View File

@ -78,13 +78,23 @@ class VIEW3D_HT_tool_header(Header):
def draw_3d_brush_settings(layout, tool_mode):
layout.popover("VIEW3D_PT_tools_brush_settings_channels", text="Brush")
if tool_mode != 'PAINT_WEIGHT':
if tool_mode not in ('PAINT_WEIGHT', 'SCULPT'):
layout.popover("VIEW3D_PT_tools_brush_texture")
if tool_mode == 'PAINT_TEXTURE':
layout.popover("VIEW3D_PT_tools_mask_texture")
layout.popover("VIEW3D_PT_tools_brush_stroke")
layout.popover("VIEW3D_PT_tools_brush_falloff")
layout.popover("VIEW3D_PT_tools_brush_display")
sub = layout.row()
sub.ui_units_x = 5
sub.popover("VIEW3D_PT_tools_brush_falloff_popover")
# why show this in the header? it takes up space - joeedh
#layout.popover("VIEW3D_PT_tools_brush_display")
if tool_mode == 'SCULPT':
layout.popover("VIEW3D_PT_tools_brush_texture")
# Note: general mode options should be added to 'draw_mode_settings'.
if tool_mode == 'SCULPT':

View File

@ -841,6 +841,25 @@ class VIEW3D_PT_tools_brush_falloff(Panel, View3DPaintPanel, FalloffPanel):
bl_label = ""
bl_options = {'DEFAULT_CLOSED'}
class VIEW3D_PT_tools_brush_falloff_popover(Panel, View3DPaintPanel, FalloffPanel):
bl_context = ".brush_editor" # dot on purpose (access from topbar)
#bl_parent_id = "VIEW3D_PT_tools_brush_settings"
bl_label = ""
bl_options = {'DEFAULT_CLOSED'}
def draw_header(self, context):
layout = self.layout
settings = self.paint_settings(context)
mode = self.get_brush_mode(context)
brush = settings.brush
if mode == "SCULPT" and "falloff_curve" in brush.channels:
#layout.label(text="Falloff")
ch = UnifiedPaintPanel.get_channel(context, brush, "falloff_curve")
layout.prop(ch.curve, "curve_preset", text="")
else:
layout.label(text="Falloff")
layout.prop(brush, "curve_preset", text="")
class VIEW3D_PT_tools_brush_falloff_frontface(View3DPaintPanel, Panel):
bl_context = ".imagepaint" # dot on purpose (access from topbar)
@ -1180,6 +1199,7 @@ class VIEW3D_PT_sculpt_dyntopo(Panel, View3DPaintPanel):
#col.prop(sculpt, "use_dyntopo_cleanup")
col.prop(sculpt, "use_smooth_shading")
col.prop(sculpt, "use_flat_vcol_shading")
col.prop(context.object.data, "sculpt_ignore_uvs")
UnifiedPaintPanel.channel_unified(layout, context, brush, "dyntopo_spacing", slider=True, ui_editing=False)
UnifiedPaintPanel.channel_unified(layout, context, brush, "dyntopo_radius_scale", slider=True, ui_editing=False)
@ -1254,6 +1274,7 @@ class VIEW3D_PT_sculpt_options(Panel, View3DPaintPanel):
col.prop(sculpt, "use_fast_draw")
col.prop(sculpt, "use_deform_only")
col.prop(sculpt, "show_sculpt_pivot")
col.prop(context.object.data, "sculpt_ignore_uvs")
UnifiedPaintPanel.channel_unified(layout.column(),
context,
@ -2666,6 +2687,7 @@ classes = (VIEW3D_MT_brush_context_menu,
VIEW3D_PT_tools_brush_stroke,
VIEW3D_PT_tools_brush_stroke_smooth_stroke,
VIEW3D_PT_tools_brush_falloff,
VIEW3D_PT_tools_brush_falloff_popover,
VIEW3D_PT_tools_brush_falloff_frontface,
VIEW3D_PT_tools_brush_falloff_normal,
VIEW3D_PT_tools_brush_display,

View File

@ -764,6 +764,8 @@ typedef struct SculptSession {
int totuv;
bool bm_smooth_shading;
bool ignore_uvs;
/* Undo/redo log for dynamic topology sculpting */
struct BMLog *bm_log;
@ -936,8 +938,9 @@ bool BKE_sculptsession_customlayer_release(struct Object *ob, SculptCustomLayer
void BKE_sculptsession_bmesh_attr_update_internal(struct Object *ob);
void BKE_sculptsession_update_attr_refs(struct Object *ob);
int BKE_sculptsession_get_totvert(const SculptSession *ss);
void BKE_sculptsession_ignore_uvs_set(struct Object *ob, bool value);
/**
/**
* Create new color layer on object if it doesn't have one and if experimental feature set has
* sculpt vertex color enabled. Returns truth if new layer has been added, false otherwise.
*/

View File

@ -348,7 +348,8 @@ void BKE_pbvh_update_sculpt_verts(struct BMesh *bm,
const int boundary_symmetry,
const int vcol_type,
const AttributeDomain vcol_domain,
const int cd_vcol_offset);
const int cd_vcol_offset,
bool do_uvs);
/** update original data, only data whose r_** parameters are passed in will be updated*/
void BKE_pbvh_bmesh_update_origvert(
@ -905,7 +906,8 @@ void BKE_pbvh_update_vert_boundary(int cd_sculpt_vert,
struct BMVert *v,
int bound_symmetry,
const CustomData *ldata,
const int totuv);
const int totuv,
const bool do_uvs);
#define DYNTOPO_DYNAMIC_TESS
@ -1133,3 +1135,5 @@ void BKE_pbvh_pmap_to_edges(PBVH *pbvh,
bool *heap_alloc,
int **r_polys);
void BKE_pbvh_set_vemap(PBVH *pbvh, struct MeshElemMap *vemap);
void BKE_pbvh_ignore_uvs_set(PBVH *pbvh, bool value);

View File

@ -1670,6 +1670,14 @@ char BKE_get_fset_boundary_symflag(Object *object)
return mesh->flag & ME_SCULPT_MIRROR_FSET_BOUNDARIES ? mesh->symmetry : 0;
}
void BKE_sculptsession_ignore_uvs_set(Object *ob, bool value)
{
ob->sculpt->ignore_uvs = value;
if (ob->sculpt->pbvh) {
BKE_pbvh_ignore_uvs_set(ob->sculpt->pbvh, value);
}
}
/**
* \param need_mask: So that the evaluated mesh that is returned has mask data.
*/
@ -1690,6 +1698,7 @@ static void sculpt_update_object(Depsgraph *depsgraph,
ss->depsgraph = depsgraph;
ss->bm_smooth_shading = scene->toolsettings->sculpt->flags & SCULPT_DYNTOPO_SMOOTH_SHADING;
ss->ignore_uvs = me->flag & ME_SCULPT_IGNORE_UVS;
ss->deform_modifiers_active = sculpt_modifiers_active(scene, sd, ob);
ss->show_mask = (sd->flags & SCULPT_HIDE_MASK) == 0;
@ -3235,8 +3244,8 @@ static bool sculpt_temp_customlayer_get(SculptSession *ss,
CustomData_add_layer_named(cdata, proptype, CD_CALLOC, NULL, totelem, name);
idx = CustomData_get_named_layer_index(cdata, proptype, name);
//if (!permanent) {
cdata->layers[idx].flag |= CD_FLAG_TEMPORARY | CD_FLAG_NOCOPY;
// if (!permanent) {
cdata->layers[idx].flag |= CD_FLAG_TEMPORARY | CD_FLAG_NOCOPY;
//}
}

View File

@ -4611,6 +4611,32 @@ void BKE_pbvh_set_stroke_id(PBVH *pbvh, int stroke_id)
pbvh->stroke_id = stroke_id;
}
static void pbvh_boundaries_flag_update(PBVH *pbvh)
{
if (pbvh->bm) {
BMVert *v;
BMIter iter;
BM_ITER_MESH (v, &iter, pbvh->bm, BM_VERTS_OF_MESH) {
MSculptVert *mv = BM_ELEM_CD_GET_VOID_P(v, pbvh->cd_sculpt_vert);
mv->flag |= SCULPTVERT_NEED_BOUNDARY;
}
}
else {
int totvert = pbvh->totvert;
if (BKE_pbvh_type(pbvh) == PBVH_GRIDS) {
totvert = BKE_pbvh_get_grid_num_vertices(pbvh);
}
for (int i = 0; i < totvert; i++) {
pbvh->mdyntopo_verts[i].flag |= SCULPTVERT_NEED_BOUNDARY;
}
}
}
void BKE_pbvh_set_symmetry(PBVH *pbvh, int symmetry, int boundary_symmetry)
{
if (symmetry == pbvh->symmetry && boundary_symmetry == pbvh->boundary_symmetry) {
@ -4620,16 +4646,7 @@ void BKE_pbvh_set_symmetry(PBVH *pbvh, int symmetry, int boundary_symmetry)
pbvh->symmetry = symmetry;
pbvh->boundary_symmetry = boundary_symmetry;
if (pbvh->bm && BKE_pbvh_type(pbvh) == PBVH_BMESH) {
BMIter iter;
BMVert *v;
BM_ITER_MESH (v, &iter, pbvh->bm, BM_VERTS_OF_MESH) {
MSculptVert *mv = BKE_PBVH_SCULPTVERT(pbvh->cd_sculpt_vert, v);
MV_ADD_FLAG(mv, SCULPTVERT_NEED_BOUNDARY);
}
}
pbvh_boundaries_flag_update(pbvh);
}
void BKE_pbvh_set_mdyntopo_verts(PBVH *pbvh, struct MSculptVert *mdyntopoverts)
@ -4752,3 +4769,19 @@ void BKE_pbvh_update_vert_boundary_faces(int *face_sets,
mv->flag |= SCULPTVERT_SEAM_CORNER;
}
}
void BKE_pbvh_ignore_uvs_set(PBVH *pbvh, bool value)
{
if (!!(pbvh->flags & PBVH_IGNORE_UVS) == value) {
return; // no change
}
if (value) {
pbvh->flags |= PBVH_IGNORE_UVS;
}
else {
pbvh->flags &= ~PBVH_IGNORE_UVS;
}
pbvh_boundaries_flag_update(pbvh);
}

View File

@ -1312,7 +1312,7 @@ void pbvh_bmesh_normals_update(PBVH *pbvh, PBVHNode **nodes, int totnode)
{
TaskParallelSettings settings;
UpdateNormalsTaskData *datas = MEM_calloc_arrayN(totnode, sizeof(*datas), "bmesh normal update");
for (int i = 0; i < totnode; i++) {
datas[i].node = nodes[i];
datas[i].cd_sculpt_vert = pbvh->cd_sculpt_vert;
@ -1723,7 +1723,10 @@ int BKE_pbvh_do_fset_symmetry(int fset, const int symflag, const float *co)
return 1;
}
// surely we don't need more then 8 million face sets?
/*
flag symmetry by shifting by 24 bits;
surely we don't need more then 8 million face sets?
*/
if (co[0] < 0.0f) {
fset |= (symflag & 1) << 24;
}
@ -2050,7 +2053,8 @@ void BKE_pbvh_update_vert_boundary(int cd_sculpt_vert,
BMVert *v,
int bound_symmetry,
const CustomData *ldata,
const int totuv)
const int totuv,
const bool do_uvs)
{
bke_pbvh_update_vert_boundary(cd_sculpt_vert,
cd_faceset_offset,
@ -2060,7 +2064,7 @@ void BKE_pbvh_update_vert_boundary(int cd_sculpt_vert,
v,
bound_symmetry,
ldata,
totuv);
do_uvs ? totuv : 0);
}
/*Used by symmetrize to update boundary flags*/
@ -2078,7 +2082,7 @@ void BKE_pbvh_recalc_bmesh_boundary(PBVH *pbvh)
v,
pbvh->boundary_symmetry,
&pbvh->bm->ldata,
pbvh->totuv);
pbvh->flags & PBVH_IGNORE_UVS ? 0 : pbvh->totuv);
}
}
@ -2305,12 +2309,13 @@ void BKE_pbvh_update_sculpt_verts(BMesh *bm,
const int boundary_symmetry,
const int vcol_type,
const AttributeDomain vcol_domain,
const int cd_vcol_offset)
const int cd_vcol_offset,
bool do_uvs)
{
BMVert *v;
BMIter iter;
int totuv = CustomData_number_of_layers(&bm->ldata, CD_MLOOPUV);
int totuv = do_uvs ? CustomData_number_of_layers(&bm->ldata, CD_MLOOPUV) : 0;
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
MSculptVert *mv = BKE_PBVH_SCULPTVERT(cd_sculpt_vert, v);
@ -2499,7 +2504,8 @@ void BKE_pbvh_build_bmesh(PBVH *pbvh,
pbvh->boundary_symmetry,
pbvh->vcol_type,
pbvh->vcol_domain,
pbvh->cd_vcol_offset);
pbvh->cd_vcol_offset,
!(pbvh->flags & PBVH_IGNORE_UVS));
}
pbvh_print_mem_size(pbvh);

View File

@ -133,7 +133,8 @@ struct PBVHNode {
typedef enum {
PBVH_DYNTOPO_SMOOTH_SHADING = 1,
PBVH_FAST_DRAW = 2 // hides facesets/masks and forces smooth to save GPU bandwidth
PBVH_FAST_DRAW = 2, // hides facesets/masks and forces smooth to save GPU bandwidth
PBVH_IGNORE_UVS = 4
} PBVHFlags;
typedef struct PBVHBMeshLog PBVHBMeshLog;
@ -390,7 +391,7 @@ BLI_INLINE bool pbvh_check_vert_boundary(PBVH *pbvh, struct BMVert *v)
v,
pbvh->boundary_symmetry,
&pbvh->bm->ldata,
pbvh->totuv);
pbvh->flags & PBVH_IGNORE_UVS ? 0 : pbvh->totuv);
return true;
}

View File

@ -3484,7 +3484,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (Mesh *me = bmain->meshes.first; me; me = me->id.next) {
me->flag &= ~(ME_REMESH_REPROJECT_MATERIALS | ME_FLAG_UNUSED_1 | ME_FLAG_UNUSED_3 |
ME_FLAG_UNUSED_4 | ME_FLAG_UNUSED_6 | ME_REMESH_REPROJECT_MATERIALS |
ME_FLAG_UNUSED_4 | ME_SCULPT_IGNORE_UVS | ME_REMESH_REPROJECT_MATERIALS |
ME_REMESH_REPROJECT_VERTEX_COLORS);
}

View File

@ -2457,7 +2457,8 @@ SculptCornerType SCULPT_vertex_is_corner(const SculptSession *ss,
(BMVert *)vertex.i,
ss->boundary_symmetry,
&ss->bm->ldata,
ss->totuv);
ss->totuv,
!ss->ignore_uvs);
}
break;
@ -2519,7 +2520,8 @@ SculptBoundaryType SCULPT_vertex_is_boundary(const SculptSession *ss,
(BMVert *)vertex.i,
ss->boundary_symmetry,
&ss->bm->ldata,
ss->totuv);
ss->totuv,
!ss->ignore_uvs);
}
break;
@ -5481,7 +5483,8 @@ void do_brush_action(
SCULPT_uv_brush(sd, ob, nodes, totnode);
break;
case SCULPT_TOOL_ENHANCE_DETAILS:
SCULPT_enhance_details_brush(sd, ob, nodes, totnode, SCULPT_get_int(ss, enhance_detail_presteps, sd, brush));
SCULPT_enhance_details_brush(
sd, ob, nodes, totnode, SCULPT_get_int(ss, enhance_detail_presteps, sd, brush));
break;
}
@ -6817,6 +6820,8 @@ static const char *sculpt_tool_name(Sculpt *sd)
return "Auto Face Set";
case SCULPT_TOOL_RELAX:
return "Relax";
case SCULPT_TOOL_ENHANCE_DETAILS:
return "Enhance Details";
}
return "Sculpting";
@ -7025,6 +7030,9 @@ static void sculpt_update_cache_invariants(
float max_scale;
int mode;
Mesh *me = BKE_object_get_original_mesh(ob);
BKE_sculptsession_ignore_uvs_set(ob, me->flag & ME_SCULPT_IGNORE_UVS);
cache->tool_override = RNA_enum_get(op->ptr, "tool_override");
if (cache->tool_override) {

View File

@ -703,7 +703,8 @@ void SCULPT_dynamic_topology_enable_ex(Main *bmain, Depsgraph *depsgraph, Scene
ss->boundary_symmetry,
ss->vcol_type,
ss->vcol_domain,
ss->cd_vcol_offset);
ss->cd_vcol_offset,
!ss->ignore_uvs);
/* Make sure the data for existing faces are initialized. */
if (me->totpoly != ss->bm->totface) {

View File

@ -807,7 +807,8 @@ static void sculpt_undo_bmesh_enable(Object *ob, SculptUndoNode *unode, bool is_
ss->boundary_symmetry,
ss->vcol_type,
ss->vcol_domain,
ss->cd_vcol_offset);
ss->cd_vcol_offset,
!ss->ignore_uvs);
if (!ss->bm_log) {
/* Restore the BMLog using saved entries. */

View File

@ -409,7 +409,7 @@ enum {
ME_FLAG_UNUSED_3 = 1 << 3, /* cleared */
ME_FLAG_UNUSED_4 = 1 << 4, /* cleared */
ME_AUTOSMOOTH = 1 << 5,
ME_FLAG_UNUSED_6 = 1 << 6, /* cleared */
ME_SCULPT_IGNORE_UVS = 1 << 6, /* cleared */
ME_REMESH_REPROJECT_MATERIALS = 1 << 7,
ME_REMESH_REPROJECT_VERTEX_COLORS = 1 << 8,
ME_DS_EXPAND = 1 << 9,

View File

@ -3374,6 +3374,13 @@ static void rna_def_mesh(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Split Face Sets", "Use mirroring to split face sets for some tools (e.g. boundary smoothing)");
//RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
prop = RNA_def_property(srna, "sculpt_ignore_uvs", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_SCULPT_IGNORE_UVS);
RNA_def_property_ui_text(
prop,
"Ignore UVs",
"");
/* End Symmetry */
prop = RNA_def_property(srna, "use_auto_smooth", PROP_BOOLEAN, PROP_NONE);