Sculpt-dev: bugfixes

* Fixed PBVH_FACES vcol draw bug.
* Fixed boundary smooth being turned on
  if its temp customdata layer exists.
* Fixed unnesting of brush panels from
  last commit improperly showing up
  in the workspace tab for sculpt
  instead of the brush tab.
This commit is contained in:
Joseph Eagar 2021-11-26 15:39:44 -08:00
parent f13bedd649
commit 8de1899c33
9 changed files with 48 additions and 34 deletions

View File

@ -453,7 +453,7 @@ class VIEW3D_PT_tools_brush_settings_channels_preview(Panel, View3DPaintBrushPan
class VIEW3D_PT_tools_brush_settings_advanced(Panel, View3DPaintBrushPanel):
bl_context = ".paint_common"
bl_context = ".brush_editor"
#bl_parent_id = "VIEW3D_PT_tools_brush_settings"
bl_label = "Advanced"
bl_options = {'DEFAULT_CLOSED'}
@ -718,7 +718,7 @@ class VIEW3D_PT_tools_brush_display(Panel, View3DPaintBrushPanel, DisplayPanel):
# TODO, move to space_view3d.py
class VIEW3D_PT_tools_brush_texture(Panel, View3DPaintPanel):
bl_context = ".paint_common"
bl_context = ".brush_editor"
#bl_parent_id = "VIEW3D_PT_tools_brush_settings"
bl_label = "Texture"
bl_options = {'DEFAULT_CLOSED'}
@ -777,14 +777,14 @@ class VIEW3D_PT_tools_mask_texture(Panel, View3DPaintPanel, TextureMaskPanel):
# TODO, move to space_view3d.py
class VIEW3D_PT_tools_brush_stroke(Panel, View3DPaintPanel, StrokePanel):
bl_context = ".paint_common" # dot on purpose (access from topbar)
bl_context = ".brush_editor" # dot on purpose (access from topbar)
bl_label = "Stroke"
#bl_parent_id = "VIEW3D_PT_tools_brush_settings"
bl_options = {'DEFAULT_CLOSED'}
class VIEW3D_PT_tools_brush_stroke_smooth_stroke(Panel, View3DPaintPanel, SmoothStrokePanel):
bl_context = ".paint_common" # dot on purpose (access from topbar)
bl_context = ".brush_editor" # dot on purpose (access from topbar)
bl_label = "Stabilize Stroke"
bl_parent_id = "VIEW3D_PT_tools_brush_stroke"
bl_options = {'DEFAULT_CLOSED'}
@ -825,7 +825,7 @@ class VIEW3D_PT_tools_weight_gradient(Panel, View3DPaintPanel):
# TODO, move to space_view3d.py
class VIEW3D_PT_tools_brush_falloff(Panel, View3DPaintPanel, FalloffPanel):
bl_context = ".paint_common" # dot on purpose (access from topbar)
bl_context = ".brush_editor" # dot on purpose (access from topbar)
#bl_parent_id = "VIEW3D_PT_tools_brush_settings"
bl_label = ""
bl_options = {'DEFAULT_CLOSED'}

View File

@ -1426,6 +1426,17 @@ bool BKE_pbvh_get_color_layer(PBVH *pbvh,
pbvh->cd_vcol_offset = cdata_bm->layers[idx].offset;
cl = *r_cl = cdata_bm->layers + idx;
}
else if (pbvh) { /* check if pbvh is using its own customdata layout */
CustomData *cdata = domain == ATTR_DOMAIN_POINT ? pbvh->vdata : pbvh->ldata;
if (cdata) {
int idx = CustomData_get_named_layer_index(cdata, cl->type, cl->name);
if (idx != -1) {
*r_cl = cdata->layers + idx;
}
}
}
if (pbvh) {
pbvh->vcol_domain = domain;
@ -4394,7 +4405,7 @@ void BKE_pbvh_update_vert_boundary_grids(PBVH *pbvh,
mv->flag &= ~SCULPTVERT_NEED_VALENCE;
}
ATTR_NO_OPT void BKE_pbvh_update_vert_boundary_faces(int *face_sets,
void BKE_pbvh_update_vert_boundary_faces(int *face_sets,
MVert *mvert,
MEdge *medge,
MLoop *mloop,

View File

@ -66,9 +66,9 @@ Topology rake:
#include "GPU_buffers.h"
#include "atomic_ops.h"
#include "bmesh.h"
#include "pbvh_intern.h"
#include "atomic_ops.h"
#include <math.h>
#include <stdio.h>
@ -76,7 +76,7 @@ Topology rake:
#include <stdarg.h>
ATTR_NO_OPT static void _debugprint(const char *fmt, ...)
static void _debugprint(const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
@ -127,7 +127,7 @@ ATTR_NO_OPT void pbvh_bmesh_check_nodes(PBVH *pbvh)
if (ni >= 0 && (!v->e || !v->e->l)) {
_debugprint("wire vert had node reference: %p (type %d)\n", v, v->head.htype);
//BM_ELEM_CD_SET_INT(v, pbvh->cd_vert_node_offset, DYNTOPO_NODE_NONE);
// BM_ELEM_CD_SET_INT(v, pbvh->cd_vert_node_offset, DYNTOPO_NODE_NONE);
}
if (ni < -1 || ni >= pbvh->totnode) {
@ -1576,13 +1576,13 @@ static void pbvh_bmesh_create_leaf_fast_task_cb(void *__restrict userdata,
do {
BMVert *v = l_iter->v;
int old = BM_ELEM_CD_GET_INT(
v, pbvh->cd_vert_node_offset);
int old = BM_ELEM_CD_GET_INT(v, pbvh->cd_vert_node_offset);
char *ptr = (char *)v;
ptr += pbvh->cd_vert_node_offset;
if (old == DYNTOPO_NODE_NONE && atomic_cas_int32((int32_t*)ptr, DYNTOPO_NODE_NONE, node_index) == DYNTOPO_NODE_NONE) {
if (old == DYNTOPO_NODE_NONE &&
atomic_cas_int32((int32_t *)ptr, DYNTOPO_NODE_NONE, node_index) == DYNTOPO_NODE_NONE) {
BLI_table_gset_insert(n->bm_unique_verts, v);
}
else {

View File

@ -91,7 +91,7 @@ static uint bm_id_freelist_pop(BMesh *bm)
void bm_free_ids_check(BMesh *bm, uint id)
{
if (id >> 2UL >= (uint)bm->idmap.free_ids_size) {
if (!bm->idmap.free_ids || id >> 2UL >= (uint)bm->idmap.free_ids_size) {
size_t size = (size_t)(id >> 2) + 2ULL;
size += size >> 1ULL;

View File

@ -971,7 +971,8 @@ static void sculpt_draw_cb(DRWSculptCallbackData *scd, GPU_PBVH_Buffers *buffers
if (SCULPT_DEBUG_BUFFERS) {
/* Color each buffers in different colors. Only work in solid/Xray mode. */
shgrp = DRW_shgroup_create_sub(shgrp);
DRW_shgroup_uniform_vec3(shgrp, "materialDiffuseColor", SCULPT_DEBUG_COLOR(scd->debug_node_nr++), 1);
DRW_shgroup_uniform_vec3(
shgrp, "materialDiffuseColor", SCULPT_DEBUG_COLOR(scd->debug_node_nr++), 1);
}
#if 0
float extramat[4][4], mat[4][4];
@ -1091,7 +1092,7 @@ static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd)
update_only_visible = true;
}
Mesh *mesh = scd->ob->data;
Mesh *mesh = BKE_object_get_original_mesh(scd->ob);
BKE_pbvh_update_normals(pbvh, mesh->runtime.subdiv_ccg);
BKE_pbvh_draw_cb(pbvh,

View File

@ -1731,7 +1731,7 @@ static bool sculpt_check_unique_face_set_for_edge_in_base_mesh(const SculptSessi
return true;
}
ATTR_NO_OPT bool SCULPT_vertex_has_unique_face_set(const SculptSession *ss, SculptVertRef vertex)
bool SCULPT_vertex_has_unique_face_set(const SculptSession *ss, SculptVertRef vertex)
{
return !SCULPT_vertex_is_boundary(ss, vertex, SCULPT_BOUNDARY_FACE_SET);
}
@ -2422,8 +2422,7 @@ static void grids_update_boundary_flags(const SculptSession *ss, SculptVertRef v
}
}
ATTR_NO_OPT static void faces_update_boundary_flags(const SculptSession *ss,
const SculptVertRef vertex)
static void faces_update_boundary_flags(const SculptSession *ss, const SculptVertRef vertex)
{
BKE_pbvh_update_vert_boundary_faces(ss->face_sets,
ss->mvert,
@ -2523,9 +2522,9 @@ SculptCornerType SCULPT_vertex_is_corner(const SculptSession *ss,
return ret;
}
ATTR_NO_OPT SculptBoundaryType SCULPT_vertex_is_boundary(const SculptSession *ss,
const SculptVertRef vertex,
SculptBoundaryType boundary_types)
SculptBoundaryType SCULPT_vertex_is_boundary(const SculptSession *ss,
const SculptVertRef vertex,
SculptBoundaryType boundary_types)
{
MSculptVert *mv = NULL;

View File

@ -324,7 +324,7 @@ static void sculpt_face_sets_automasking_init(Sculpt *sd,
#define EDGE_DISTANCE_INF -1
ATTR_NO_OPT void SCULPT_boundary_automasking_init(Object *ob,
void SCULPT_boundary_automasking_init(Object *ob,
eBoundaryAutomaskMode mode,
int propagation_steps,
SculptCustomLayer *factorlayer)

View File

@ -150,7 +150,7 @@ void SCULPT_reproject_cdata(SculptSession *ss,
bool bad = false;
for (int i = 0; i < totuv; i++) {
snapuvs[i] = true; //!(mv->flag & SCULPTVERT_UV_BOUNDARY);
snapuvs[i] = true; //!(mv->flag & SCULPTVERT_UV_BOUNDARY);
}
do {
@ -209,7 +209,7 @@ void SCULPT_reproject_cdata(SculptSession *ss,
break;
}
} while ((l = l->radial_next) != e->l);
if (bad) {
break;
}
@ -333,8 +333,8 @@ void SCULPT_reproject_cdata(SculptSession *ss,
tots[i] = 0;
}
//re-snap uvs
v = (BMVert*)vertex.i;
// re-snap uvs
v = (BMVert *)vertex.i;
e = v->e;
do {
@ -1545,6 +1545,13 @@ static void do_smooth_brush_task_cb_ex(void *__restrict userdata,
if (vel_scl) {
float *vel = SCULPT_temp_cdata_get(vd.vertex, vel_scl);
# if 0
if (isnan(dot_v3v3(vel, vel)) || !isfinite(dot_v3v3(vel, vel))) {
printf("NaN!");
zero_v3(vel);
}
# endif
copy_v3_v3(startvel, vel);
}
@ -1616,7 +1623,7 @@ static void do_smooth_brush_task_cb_ex(void *__restrict userdata,
void SCULPT_bound_smooth_ensure(SculptSession *ss, Object *ob)
{
SculptLayerParams params = {.permanent = true, .simple_array = false};
SculptLayerParams params = {.permanent = false, .simple_array = false};
if (!ss->custom_layers[SCULPT_SCL_SMOOTH_BDIS]) {
ss->custom_layers[SCULPT_SCL_SMOOTH_BDIS] = MEM_callocN(sizeof(SculptCustomLayer),
@ -1763,7 +1770,7 @@ void SCULPT_smooth(Sculpt *sd,
.fset_slide = fset_slide,
.bound_smooth = bound_smooth,
.scl = do_vel ? ss->custom_layers[SCULPT_SCL_SMOOTH_VEL] : NULL,
.scl2 = ss->custom_layers[SCULPT_SCL_SMOOTH_BDIS],
.scl2 = bound_smooth > 0.0f ? ss->custom_layers[SCULPT_SCL_SMOOTH_BDIS] : NULL,
.vel_smooth_fac = vel_fac,
.do_origco = do_origco,
.iterations = count + 1,

View File

@ -1631,14 +1631,10 @@ bool GPU_pbvh_update_attribute_names(CustomData *vdata,
&g_vbo_id.format, "c", GPU_COMP_U16, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
g_vbo_id.totcol++;
bool is_render = cl == render_vcol_layer;
bool is_active = cl == active_vcol_layer;
bool is_render = render_vcol_layer == cl;
bool is_active = active_vcol_layer == cl;
DRW_make_cdlayer_attr_aliases(&g_vbo_id.format, "c", cdata, cl, is_render, is_active);
if (cl == active_vcol_layer) {
GPU_vertformat_alias_add(&g_vbo_id.format, "ac");
}
}
}
}