[Bf-blender-cvs] [0386350de69] temp_bmesh_multires: * Fixed SCULPT_dynamic_topology_sync_layers to properly sync active/render/clone/mask layers indices. * Fixed sculpt color bugs in pbvh drawing for bmesh.
Joseph Eagar
noreply at git.blender.org
Sun Apr 25 23:03:16 CEST 2021
Commit: 0386350de69e0589cd3f9621df45b9b9a2615d87
Author: Joseph Eagar
Date: Sun Apr 25 14:02:39 2021 -0700
Branches: temp_bmesh_multires
https://developer.blender.org/rB0386350de69e0589cd3f9621df45b9b9a2615d87
* Fixed SCULPT_dynamic_topology_sync_layers to properly sync
active/render/clone/mask layers indices.
* Fixed sculpt color bugs in pbvh drawing for bmesh.
===================================================================
M source/blender/blenkernel/intern/pbvh.c
M source/blender/blenkernel/intern/pbvh_bmesh.c
M source/blender/editors/sculpt_paint/sculpt_boundary.c
M source/blender/editors/sculpt_paint/sculpt_dyntopo.c
M source/blender/gpu/GPU_buffers.h
M source/blender/gpu/intern/gpu_buffers.c
M source/blender/makesrna/intern/rna_brush.c
===================================================================
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index f3b813b4d08..36a236b07c6 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -1415,7 +1415,7 @@ static void pbvh_update_draw_buffers(
ldata = pbvh->ldata;
}
- GPU_pbvh_update_attribute_names(vdata, ldata);
+ GPU_pbvh_update_attribute_names(vdata, ldata, active_vcol_only);
/* Parallel creation and update of draw buffers. */
PBVHUpdateData data = {.pbvh = pbvh,
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index 4346fd854db..efa58cabc95 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -2260,7 +2260,7 @@ static bool pbvh_bmesh_subdivide_long_edges(EdgeQueueContext *eq_ctx,
return any_subdivided;
}
-ATTR_NO_OPT static void pbvh_bmesh_collapse_edge(PBVH *pbvh,
+static void pbvh_bmesh_collapse_edge(PBVH *pbvh,
BMEdge *e,
BMVert *v1,
BMVert *v2,
diff --git a/source/blender/editors/sculpt_paint/sculpt_boundary.c b/source/blender/editors/sculpt_paint/sculpt_boundary.c
index 83204accf95..1c110a6df40 100644
--- a/source/blender/editors/sculpt_paint/sculpt_boundary.c
+++ b/source/blender/editors/sculpt_paint/sculpt_boundary.c
@@ -86,31 +86,6 @@ typedef struct BoundaryInitialVertexFloodFillData {
int *floodfill_steps;
float radius_sq;
} BoundaryInitialVertexFloodFillData;
-#if 0
-ATTR_NO_OPT static bool validVert(SculptSession *ss, SculptVertRef v)
-{
- if (v.i == -1) {
- return false;
- }
-
- if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH && v.i < 1000000) {
- return false;
- }
-
- int totvert = SCULPT_vertex_count_get(ss);
- int idx = BKE_pbvh_vertex_index_to_table(ss->pbvh, v);
-
- return idx >= 0 && idx < totvert;
-}
-ATTR_NO_OPT static void validateVert(SculptSession *ss, SculptVertRef v)
-{
- if (!validVert(ss, v)) {
- printf("Error! %p\n", v.i);
- }
-}
-#endif
-// XXX remove all calls to validateVert before final merge
-#define validateVert(ss, vertex)
static bool boundary_initial_vertex_floodfill_cb(SculptSession *ss,
SculptVertRef from_vref,
@@ -120,9 +95,6 @@ static bool boundary_initial_vertex_floodfill_cb(SculptSession *ss,
{
BoundaryInitialVertexFloodFillData *data = userdata;
- validateVert(ss, from_vref);
- validateVert(ss, to_vref);
-
int to_v = BKE_pbvh_vertex_index_to_table(ss->pbvh, to_vref);
int from_v = BKE_pbvh_vertex_index_to_table(ss->pbvh, from_vref);
@@ -157,8 +129,6 @@ static SculptVertRef sculpt_boundary_get_closest_boundary_vertex(
const int initial_vertex_index,
const float radius)
{
- validateVert(ss, initial_vertex);
-
if (SCULPT_vertex_is_boundary(ss, initial_vertex)) {
return initial_vertex;
}
@@ -320,8 +290,6 @@ static void sculpt_boundary_indices_init(SculptSession *ss,
const SculptVertRef initial_boundary_index)
{
- validateVert(ss, initial_boundary_index);
-
const int totvert = SCULPT_vertex_count_get(ss);
boundary->vertices = MEM_malloc_arrayN(
BOUNDARY_INDICES_BLOCK_SIZE, sizeof(SculptVertRef) * TSTN, "boundary vrefs");
@@ -386,8 +354,6 @@ static void sculpt_boundary_edit_data_init(SculptSession *ss,
const bool has_duplicates = BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS;
- validateVert(ss, initial_vertex);
-
boundary->edit_info = MEM_malloc_arrayN(
totvert, sizeof(SculptBoundaryEditInfo) * TSTN, "Boundary edit info");
@@ -443,8 +409,6 @@ static void sculpt_boundary_edit_data_init(SculptSession *ss,
BLI_gsqueue_pop(current_iteration, &from_v);
const int from_v_i = BKE_pbvh_vertex_index_to_table(ss->pbvh, from_v);
- validateVert(ss, from_v);
-
SculptVertexNeighborIter ni;
SCULPT_VERTEX_DUPLICATES_AND_NEIGHBORS_ITER_BEGIN (ss, from_v, ni) {
const bool is_visible = SCULPT_vertex_visible_get(ss, ni.vertex);
@@ -459,8 +423,6 @@ static void sculpt_boundary_edit_data_init(SculptSession *ss,
boundary->edit_info[ni.index].original_vertex_i =
boundary->edit_info[from_v_i].original_vertex_i;
- validateVert(ss, boundary->edit_info[ni.index].original_vertex);
-
BLI_BITMAP_ENABLE(visited_vertices, ni.index);
if (ni.is_duplicate) {
@@ -474,8 +436,6 @@ static void sculpt_boundary_edit_data_init(SculptSession *ss,
BLI_gsqueue_push(next_iteration, &ni.vertex);
- validateVert(ss, ni.vertex);
-
/* When copying the data to the neighbor for the next iteration, it has to be copied to
* all its duplicates too. This is because it is not possible to know if the updated
* neighbor or one if its uninitialized duplicates is going to come first in order to
@@ -483,8 +443,6 @@ static void sculpt_boundary_edit_data_init(SculptSession *ss,
if (has_duplicates) {
SculptVertexNeighborIter ni_duplis;
SCULPT_VERTEX_DUPLICATES_AND_NEIGHBORS_ITER_BEGIN (ss, ni.vertex, ni_duplis) {
- validateVert(ss, ni_duplis.vertex);
-
if (ni_duplis.is_duplicate) {
boundary->edit_info[ni_duplis.index].original_vertex =
boundary->edit_info[from_v_i].original_vertex;
@@ -690,8 +648,6 @@ static void sculpt_boundary_bend_data_init(SculptSession *ss, SculptBoundary *bo
SCULPT_vertex_co_get(ss, boundary->edit_info[i].original_vertex),
SCULPT_vertex_co_get(ss, vertex));
- validateVert(ss, boundary->edit_info[i].original_vertex);
-
#if 0
/*strategy to increase accuracy for non-quad topologies:
use principle curvature direction. Since SCULPT_curvature_dir_get
@@ -948,8 +904,6 @@ static void do_boundary_brush_bend_task_cb_ex(void *__restrict userdata,
float t_orig_co[3];
float *target_co = SCULPT_brush_deform_target_vertex_co_get(ss, brush->deform_target, &vd);
- validateVert(ss, vd.vertex);
-
sub_v3_v3v3(t_orig_co, orig_data.co, boundary->bend.pivot_positions[vd.index]);
rotate_v3_v3v3fl(target_co,
t_orig_co,
diff --git a/source/blender/editors/sculpt_paint/sculpt_dyntopo.c b/source/blender/editors/sculpt_paint/sculpt_dyntopo.c
index 59d5dee7b42..44e2d19d944 100644
--- a/source/blender/editors/sculpt_paint/sculpt_dyntopo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_dyntopo.c
@@ -259,15 +259,6 @@ void SCULPT_dynamic_topology_sync_layers(Object *ob, Mesh *me)
continue;
}
- modified = modified || CustomData_get_active_layer_index(data1, cl1->type) !=
- CustomData_get_active_layer_index(data2, cl1->type);
- modified = modified || CustomData_get_render_layer_index(data1, cl1->type) !=
- CustomData_get_render_layer_index(data2, cl1->type);
- modified = modified || CustomData_get_stencil_layer_index(data1, cl1->type) !=
- CustomData_get_stencil_layer_index(data2, cl1->type);
- modified = modified || CustomData_get_clone_layer_index(data1, cl1->type) !=
- CustomData_get_clone_layer_index(data2, cl1->type);
-
int idx = CustomData_get_named_layer_index(data2, cl1->type, cl1->name);
if (idx < 0) {
BLI_array_append(newlayers, cl1);
@@ -276,16 +267,13 @@ void SCULPT_dynamic_topology_sync_layers(Object *ob, Mesh *me)
for (int j = 0; j < BLI_array_len(newlayers); j++) {
BM_data_layer_add_named(bm, data2, newlayers[j]->type, newlayers[j]->name);
- modified |= true;
+ modified = true;
}
- char typemap[CD_NUMTYPES] = {
- 0,
- };
+ bool typemap[CD_NUMTYPES] = {0};
for (int j = 0; j < data1->totlayer; j++) {
- CustomDataLayer *cl = data1->layers + j;
- CustomDataLayer *cl1 = cl;
+ CustomDataLayer *cl1 = data1->layers + j;
if ((1 << cl1->type) & badmask) {
continue;
@@ -295,23 +283,56 @@ void SCULPT_dynamic_topology_sync_layers(Object *ob, Mesh *me)
continue;
}
- typemap[cl1->type] = 1;
- cl1 = cl + CustomData_get_active_layer(data1, cl1->type);
+ typemap[cl1->type] = true;
- int idx = CustomData_get_named_layer_index(data2, cl1->type, cl1->name);
- CustomData_set_layer_active_index(data2, cl1->type, idx);
+ // find first layer
+ int baseidx = CustomData_get_layer_index(data2, cl1->type);
- cl1 = cl + CustomData_get_render_layer(data1, cl1->type);
- idx = CustomData_get_named_layer_index(data2, cl1->type, cl1->name);
- CustomData_set_layer_render_index(data2, cl1->type, idx);
+ if (baseidx < 0) {
+ modified |= true;
+ continue;
+ }
- cl1 = cl + CustomData_get_stencil_layer(data1, cl1->type);
- idx = CustomData_get_named_layer_index(data2, cl1->type, cl1->name);
- CustomData_set_layer_stencil_index(data2, cl1->type, idx);
+ CustomDataLayer *cl2 = data2->layers + baseidx;
+
+ int idx = CustomData_get_named_layer_index(data2, cl1->type, cl1[cl1->active].name);
+ if (idx >= 0) {
+ modified |= idx - baseidx != cl2->active;
+ cl2->active = idx - baseidx;
+ }
+
+ idx = CustomData_get_named_layer_index(data2, cl1->type, cl1[cl1->active_rnd].name);
+ if (idx >= 0) {
+ modified |= idx - baseidx != cl2->active_rnd;
+ cl2->active_rnd = idx - baseidx;
+ }
- cl1 = cl + CustomData_get_clone_layer(data1, cl1->type);
- idx = CustomData_get_named_layer_index(data2, cl1->type, cl1->name);
- CustomData_set_layer_clone_index(data2, cl1->type, idx);
+ idx = CustomData_get_named_layer_index(data2, cl1->type, cl1[cl1->active_mask].name);
+ if (idx >= 0) {
+ modified |= idx - baseidx != cl2->active_mask;
+ cl2->active_mask = idx - baseidx;
+ }
+
+ idx = CustomData_get_named_layer_index(data2, cl1->type, cl1[cl1->active_clone].name);
+ if (idx >= 0) {
+ modified |= idx -
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list