Cleanup: naming of looptri indexing variables
looptris were referred to as both tris & faces, sometimes polygons were referred to as faces too. Was especially error prone with callbacks that took both a tri and a tri_i arguments. Sometimes tri_i represented a looptri index, other times the corner of the triangle from 0-2. Causing expressions such as: `args->mlooptri[tri].tri[tri_i]` - Rename tri & tri_index -> looptri_i. - Rename faces -> looptris. - Rename face_index/poly_index/poly -> poly_i. - Declare looptri_i at the start of the loop and reuse it, in some cases it was declared with args->prim_indices[i] being used as well.
This commit is contained in:
parent
0168c4b893
commit
ee09d75e80
|
@ -720,7 +720,7 @@ typedef struct PBVHFaceIter {
|
|||
const struct BMesh *bm;
|
||||
CCGKey subdiv_key_;
|
||||
|
||||
int last_face_index_;
|
||||
int last_poly_index_;
|
||||
} PBVHFaceIter;
|
||||
|
||||
void BKE_pbvh_face_iter_init(PBVH *pbvh, PBVHNode *node, PBVHFaceIter *fd);
|
||||
|
|
|
@ -162,7 +162,7 @@ static void mesh_recalc_looptri__single_threaded(const Span<int> corner_verts,
|
|||
const float (*poly_normals)[3])
|
||||
{
|
||||
MemArena *pf_arena = nullptr;
|
||||
uint tri_index = 0;
|
||||
uint looptri_i = 0;
|
||||
|
||||
if (poly_normals != nullptr) {
|
||||
for (const int64_t i : polys.index_range()) {
|
||||
|
@ -170,17 +170,17 @@ static void mesh_recalc_looptri__single_threaded(const Span<int> corner_verts,
|
|||
polys,
|
||||
positions,
|
||||
uint(i),
|
||||
&mlooptri[tri_index],
|
||||
&mlooptri[looptri_i],
|
||||
&pf_arena,
|
||||
poly_normals[i]);
|
||||
tri_index += uint(polys[i].size() - 2);
|
||||
looptri_i += uint(polys[i].size() - 2);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (const int64_t i : polys.index_range()) {
|
||||
mesh_calc_tessellation_for_face(
|
||||
corner_verts, polys, positions, uint(i), &mlooptri[tri_index], &pf_arena);
|
||||
tri_index += uint(polys[i].size() - 2);
|
||||
corner_verts, polys, positions, uint(i), &mlooptri[looptri_i], &pf_arena);
|
||||
looptri_i += uint(polys[i].size() - 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ static void mesh_recalc_looptri__single_threaded(const Span<int> corner_verts,
|
|||
BLI_memarena_free(pf_arena);
|
||||
pf_arena = nullptr;
|
||||
}
|
||||
BLI_assert(tri_index == uint(poly_to_tri_count(int(polys.size()), int(corner_verts.size()))));
|
||||
BLI_assert(looptri_i == uint(poly_to_tri_count(int(polys.size()), int(corner_verts.size()))));
|
||||
}
|
||||
|
||||
struct TessellationUserData {
|
||||
|
@ -213,12 +213,12 @@ static void mesh_calc_tessellation_for_face_fn(void *__restrict userdata,
|
|||
{
|
||||
const TessellationUserData *data = static_cast<const TessellationUserData *>(userdata);
|
||||
TessellationUserTLS *tls_data = static_cast<TessellationUserTLS *>(tls->userdata_chunk);
|
||||
const int tri_index = poly_to_tri_count(index, int(data->polys[index].start()));
|
||||
const int looptri_i = poly_to_tri_count(index, int(data->polys[index].start()));
|
||||
mesh_calc_tessellation_for_face_impl(data->corner_verts,
|
||||
data->polys,
|
||||
data->positions,
|
||||
uint(index),
|
||||
&data->mlooptri[tri_index],
|
||||
&data->mlooptri[looptri_i],
|
||||
&tls_data->pf_arena,
|
||||
false,
|
||||
nullptr);
|
||||
|
@ -230,12 +230,12 @@ static void mesh_calc_tessellation_for_face_with_normal_fn(void *__restrict user
|
|||
{
|
||||
const TessellationUserData *data = static_cast<const TessellationUserData *>(userdata);
|
||||
TessellationUserTLS *tls_data = static_cast<TessellationUserTLS *>(tls->userdata_chunk);
|
||||
const int tri_index = poly_to_tri_count(index, int(data->polys[index].start()));
|
||||
const int looptri_i = poly_to_tri_count(index, int(data->polys[index].start()));
|
||||
mesh_calc_tessellation_for_face_impl(data->corner_verts,
|
||||
data->polys,
|
||||
data->positions,
|
||||
uint(index),
|
||||
&data->mlooptri[tri_index],
|
||||
&data->mlooptri[looptri_i],
|
||||
&tls_data->pf_arena,
|
||||
true,
|
||||
data->poly_normals[index]);
|
||||
|
|
|
@ -202,10 +202,10 @@ static int partition_indices_faces(int *prim_indices,
|
|||
int i1 = lo, i2 = 0;
|
||||
|
||||
while (i1 < hi) {
|
||||
int poly = looptri_polys[prim_scratch[i2]];
|
||||
const int poly_i = looptri_polys[prim_scratch[i2]];
|
||||
bool side = prim_bbc[prim_scratch[i2]].bcentroid[axis] >= mid;
|
||||
|
||||
while (i1 < hi && looptri_polys[prim_scratch[i2]] == poly) {
|
||||
while (i1 < hi && looptri_polys[prim_scratch[i2]] == poly_i) {
|
||||
prim_indices[side ? hi2-- : lo2++] = prim_scratch[i2];
|
||||
i1++;
|
||||
i2++;
|
||||
|
@ -232,10 +232,10 @@ static int partition_indices_grids(int *prim_indices,
|
|||
int i1 = lo, i2 = 0;
|
||||
|
||||
while (i1 < hi) {
|
||||
int poly = BKE_subdiv_ccg_grid_to_face_index(subdiv_ccg, prim_scratch[i2]);
|
||||
int poly_i = BKE_subdiv_ccg_grid_to_face_index(subdiv_ccg, prim_scratch[i2]);
|
||||
bool side = prim_bbc[prim_scratch[i2]].bcentroid[axis] >= mid;
|
||||
|
||||
while (i1 < hi && BKE_subdiv_ccg_grid_to_face_index(subdiv_ccg, prim_scratch[i2]) == poly) {
|
||||
while (i1 < hi && BKE_subdiv_ccg_grid_to_face_index(subdiv_ccg, prim_scratch[i2]) == poly_i) {
|
||||
prim_indices[side ? hi2-- : lo2++] = prim_scratch[i2];
|
||||
i1++;
|
||||
i2++;
|
||||
|
@ -516,21 +516,21 @@ static void test_face_boundaries(PBVH *pbvh)
|
|||
switch (BKE_pbvh_type(pbvh)) {
|
||||
case PBVH_FACES: {
|
||||
for (int j = 0; j < node->totprim; j++) {
|
||||
int poly = pbvh->looptri_polys[node->prim_indices[j]];
|
||||
int poly_i = pbvh->looptri_polys[node->prim_indices[j]];
|
||||
|
||||
if (node_map[poly] >= 0 && node_map[poly] != i) {
|
||||
int old_i = node_map[poly];
|
||||
if (node_map[poly_i] >= 0 && node_map[poly_i] != i) {
|
||||
int old_i = node_map[poly_i];
|
||||
int prim_i = node->prim_indices - pbvh->prim_indices + j;
|
||||
|
||||
printf("PBVH split error; poly: %d, prim_i: %d, node1: %d, node2: %d, totprim: %d\n",
|
||||
poly,
|
||||
poly_i,
|
||||
prim_i,
|
||||
old_i,
|
||||
i,
|
||||
node->totprim);
|
||||
}
|
||||
|
||||
node_map[poly] = i;
|
||||
node_map[poly_i] = i;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -794,16 +794,16 @@ static void pbvh_validate_node_prims(PBVH *pbvh)
|
|||
}
|
||||
|
||||
for (int j = 0; j < node->totprim; j++) {
|
||||
int poly;
|
||||
int poly_i;
|
||||
|
||||
if (pbvh->header.type == PBVH_FACES) {
|
||||
poly = pbvh->looptri_polys[node->prim_indices[j]];
|
||||
poly_i = pbvh->looptri_polys[node->prim_indices[j]];
|
||||
}
|
||||
else {
|
||||
poly = BKE_subdiv_ccg_grid_to_face_index(pbvh->subdiv_ccg, node->prim_indices[j]);
|
||||
poly_i = BKE_subdiv_ccg_grid_to_face_index(pbvh->subdiv_ccg, node->prim_indices[j]);
|
||||
}
|
||||
|
||||
totface = max_ii(totface, poly + 1);
|
||||
totface = max_ii(totface, poly_i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -821,23 +821,23 @@ static void pbvh_validate_node_prims(PBVH *pbvh)
|
|||
}
|
||||
|
||||
for (int j = 0; j < node->totprim; j++) {
|
||||
int poly;
|
||||
int poly_i;
|
||||
|
||||
if (pbvh->header.type == PBVH_FACES) {
|
||||
poly = pbvh->looptri_polys[node->prim_indices[j]];
|
||||
poly_i = pbvh->looptri_polys[node->prim_indices[j]];
|
||||
}
|
||||
else {
|
||||
poly = BKE_subdiv_ccg_grid_to_face_index(pbvh->subdiv_ccg, node->prim_indices[j]);
|
||||
poly_i = BKE_subdiv_ccg_grid_to_face_index(pbvh->subdiv_ccg, node->prim_indices[j]);
|
||||
}
|
||||
|
||||
if (facemap[poly] != -1 && facemap[poly] != i) {
|
||||
if (facemap[poly_i] != -1 && facemap[poly_i] != i) {
|
||||
printf("%s: error: face spanned multiple nodes (old: %d new: %d)\n",
|
||||
__func__,
|
||||
facemap[poly],
|
||||
facemap[poly_i],
|
||||
i);
|
||||
}
|
||||
|
||||
facemap[poly] = i;
|
||||
facemap[poly_i] = i;
|
||||
}
|
||||
}
|
||||
MEM_SAFE_FREE(facemap);
|
||||
|
@ -2470,17 +2470,17 @@ static bool pbvh_faces_node_raycast(PBVH *pbvh,
|
|||
{
|
||||
const float(*positions)[3] = pbvh->vert_positions;
|
||||
const int *corner_verts = pbvh->corner_verts;
|
||||
const int *faces = node->prim_indices;
|
||||
int totface = node->totprim;
|
||||
const int *looptris = node->prim_indices;
|
||||
int looptris_num = node->totprim;
|
||||
bool hit = false;
|
||||
float nearest_vertex_co[3] = {0.0f};
|
||||
|
||||
for (int i = 0; i < totface; i++) {
|
||||
const int tri_index = faces[i];
|
||||
const MLoopTri *lt = &pbvh->looptri[tri_index];
|
||||
for (int i = 0; i < looptris_num; i++) {
|
||||
const int looptri_i = looptris[i];
|
||||
const MLoopTri *lt = &pbvh->looptri[looptri_i];
|
||||
const int *face_verts = node->face_vert_indices[i];
|
||||
|
||||
if (paint_is_face_hidden(pbvh->looptri_polys, pbvh->hide_poly, tri_index)) {
|
||||
if (paint_is_face_hidden(pbvh->looptri_polys, pbvh->hide_poly, looptri_i)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -2516,7 +2516,7 @@ static bool pbvh_faces_node_raycast(PBVH *pbvh,
|
|||
len_squared_v3v3(location, co[j]) < len_squared_v3v3(location, nearest_vertex_co)) {
|
||||
copy_v3_v3(nearest_vertex_co, co[j]);
|
||||
r_active_vertex->i = corner_verts[lt->tri[j]];
|
||||
*r_active_face_index = pbvh->looptri_polys[tri_index];
|
||||
*r_active_face_index = pbvh->looptri_polys[looptri_i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2781,16 +2781,16 @@ static bool pbvh_faces_node_nearest_to_ray(PBVH *pbvh,
|
|||
{
|
||||
const float(*positions)[3] = pbvh->vert_positions;
|
||||
const int *corner_verts = pbvh->corner_verts;
|
||||
const int *faces = node->prim_indices;
|
||||
int i, totface = node->totprim;
|
||||
const int *looptris = node->prim_indices;
|
||||
int i, looptris_num = node->totprim;
|
||||
bool hit = false;
|
||||
|
||||
for (i = 0; i < totface; i++) {
|
||||
const int tri_index = faces[i];
|
||||
const MLoopTri *lt = &pbvh->looptri[tri_index];
|
||||
for (i = 0; i < looptris_num; i++) {
|
||||
const int looptri_i = looptris[i];
|
||||
const MLoopTri *lt = &pbvh->looptri[looptri_i];
|
||||
const int *face_verts = node->face_vert_indices[i];
|
||||
|
||||
if (paint_is_face_hidden(pbvh->looptri_polys, pbvh->hide_poly, tri_index)) {
|
||||
if (paint_is_face_hidden(pbvh->looptri_polys, pbvh->hide_poly, looptri_i)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -3573,15 +3573,15 @@ static void pbvh_face_iter_step(PBVHFaceIter *fd, bool do_step)
|
|||
}
|
||||
case PBVH_GRIDS:
|
||||
case PBVH_FACES: {
|
||||
int face_index = 0;
|
||||
int poly_i = 0;
|
||||
|
||||
if (do_step) {
|
||||
fd->prim_index_++;
|
||||
|
||||
while (fd->prim_index_ < fd->node_->totprim) {
|
||||
face_index = face_iter_prim_to_face(fd, fd->node_->prim_indices[fd->prim_index_]);
|
||||
poly_i = face_iter_prim_to_face(fd, fd->node_->prim_indices[fd->prim_index_]);
|
||||
|
||||
if (face_index != fd->last_face_index_) {
|
||||
if (poly_i != fd->last_poly_index_) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -3589,24 +3589,24 @@ static void pbvh_face_iter_step(PBVHFaceIter *fd, bool do_step)
|
|||
}
|
||||
}
|
||||
else if (fd->prim_index_ < fd->node_->totprim) {
|
||||
face_index = face_iter_prim_to_face(fd, fd->node_->prim_indices[fd->prim_index_]);
|
||||
poly_i = face_iter_prim_to_face(fd, fd->node_->prim_indices[fd->prim_index_]);
|
||||
}
|
||||
|
||||
if (fd->prim_index_ >= fd->node_->totprim) {
|
||||
return;
|
||||
}
|
||||
|
||||
fd->last_face_index_ = face_index;
|
||||
const int poly_start = fd->poly_offsets_[face_index];
|
||||
const int poly_size = fd->poly_offsets_[face_index + 1] - poly_start;
|
||||
fd->last_poly_index_ = poly_i;
|
||||
const int poly_start = fd->poly_offsets_[poly_i];
|
||||
const int poly_size = fd->poly_offsets_[poly_i + 1] - poly_start;
|
||||
|
||||
fd->face.i = fd->index = face_index;
|
||||
fd->face.i = fd->index = poly_i;
|
||||
|
||||
if (fd->face_sets_) {
|
||||
fd->face_set = fd->face_sets_ + face_index;
|
||||
fd->face_set = fd->face_sets_ + poly_i;
|
||||
}
|
||||
if (fd->hide_poly_) {
|
||||
fd->hide = fd->hide_poly_ + face_index;
|
||||
fd->hide = fd->hide_poly_ + poly_i;
|
||||
}
|
||||
|
||||
pbvh_face_iter_verts_reserve(fd, poly_size);
|
||||
|
@ -3653,7 +3653,7 @@ void BKE_pbvh_face_iter_init(PBVH *pbvh, PBVHNode *node, PBVHFaceIter *fd)
|
|||
fd->looptri_polys_ = pbvh->looptri_polys;
|
||||
fd->hide_poly_ = pbvh->hide_poly;
|
||||
fd->face_sets_ = pbvh->face_sets;
|
||||
fd->last_face_index_ = -1;
|
||||
fd->last_poly_index_ = -1;
|
||||
|
||||
break;
|
||||
case PBVH_BMESH:
|
||||
|
@ -3737,8 +3737,8 @@ void BKE_pbvh_sync_visibility_from_verts(PBVH *pbvh, Mesh *mesh)
|
|||
&mesh->pdata, CD_PROP_BOOL, ".hide_poly", mesh->totpoly));
|
||||
|
||||
bool delete_hide_poly = true;
|
||||
for (const int face_index : polys.index_range()) {
|
||||
const blender::IndexRange poly = polys[face_index];
|
||||
for (const int poly_i : polys.index_range()) {
|
||||
const blender::IndexRange poly = polys[poly_i];
|
||||
bool hidden = false;
|
||||
|
||||
for (int loop_index = 0; !hidden && loop_index < poly.size(); loop_index++) {
|
||||
|
@ -3765,7 +3765,7 @@ void BKE_pbvh_sync_visibility_from_verts(PBVH *pbvh, Mesh *mesh)
|
|||
|
||||
if (hide_poly) {
|
||||
delete_hide_poly = delete_hide_poly && !hidden;
|
||||
hide_poly[face_index] = hidden;
|
||||
hide_poly[poly_i] = hidden;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -191,9 +191,10 @@ struct PBVHBatches {
|
|||
switch (args->pbvh_type) {
|
||||
case PBVH_FACES: {
|
||||
for (int i = 0; i < args->totprim; i++) {
|
||||
int face_index = args->looptri_polys[args->prim_indices[i]];
|
||||
const int looptri_i = args->prim_indices[i];
|
||||
const int poly_i = args->looptri_polys[looptri_i];
|
||||
|
||||
if (args->hide_poly && args->hide_poly[face_index]) {
|
||||
if (args->hide_poly && args->hide_poly[poly_i]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -336,8 +337,8 @@ struct PBVHBatches {
|
|||
int last_poly = -1;
|
||||
bool flat = false;
|
||||
|
||||
foreach_faces([&](int /*buffer_i*/, int /*tri_i*/, int vertex_i, const int tri) {
|
||||
const int poly_i = args->looptri_polys[tri];
|
||||
foreach_faces([&](int /*buffer_i*/, int /*tri_i*/, int vertex_i, const int looptri_i) {
|
||||
const int poly_i = args->looptri_polys[looptri_i];
|
||||
if (poly_i != last_poly) {
|
||||
last_poly = poly_i;
|
||||
flat = sharp_faces && sharp_faces[poly_i];
|
||||
|
@ -545,20 +546,20 @@ struct PBVHBatches {
|
|||
{
|
||||
const blender::Span<int> corner_verts = args->corner_verts;
|
||||
auto foreach_faces =
|
||||
[&](std::function<void(int buffer_i, int tri_i, int vertex_i, const int tri)> func) {
|
||||
[&](std::function<void(int buffer_i, int tri_i, int vertex_i, const int /*looptri_i*/)>
|
||||
func) {
|
||||
int buffer_i = 0;
|
||||
|
||||
for (int i : IndexRange(args->totprim)) {
|
||||
int face_index = args->looptri_polys[args->prim_indices[i]];
|
||||
const int looptri_i = args->prim_indices[i];
|
||||
const int poly_i = args->looptri_polys[looptri_i];
|
||||
|
||||
if (args->hide_poly && args->hide_poly[face_index]) {
|
||||
if (args->hide_poly && args->hide_poly[poly_i]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const int tri = args->prim_indices[i];
|
||||
|
||||
for (int j : IndexRange(3)) {
|
||||
func(buffer_i, j, corner_verts[args->mlooptri[tri].tri[j]], tri);
|
||||
func(buffer_i, j, corner_verts[args->mlooptri[looptri_i].tri[j]], looptri_i);
|
||||
buffer_i++;
|
||||
}
|
||||
}
|
||||
|
@ -580,7 +581,7 @@ struct PBVHBatches {
|
|||
|
||||
switch (vbo.type) {
|
||||
case CD_PBVH_CO_TYPE:
|
||||
foreach_faces([&](int /*buffer_i*/, int /*tri_i*/, int vertex_i, const int /*tri*/) {
|
||||
foreach_faces([&](int /*buffer_i*/, int /*tri_i*/, int vertex_i, const int /*looptri_i*/) {
|
||||
*static_cast<float3 *>(GPU_vertbuf_raw_step(&access)) = args->vert_positions[vertex_i];
|
||||
});
|
||||
break;
|
||||
|
@ -592,14 +593,17 @@ struct PBVHBatches {
|
|||
CustomData_get_layer(args->vdata, CD_PAINT_MASK));
|
||||
|
||||
if (mask) {
|
||||
foreach_faces([&](int /*buffer_i*/, int /*tri_i*/, int vertex_i, const int /*tri*/) {
|
||||
*static_cast<uchar *>(GPU_vertbuf_raw_step(&access)) = uchar(mask[vertex_i] * 255.0f);
|
||||
});
|
||||
foreach_faces(
|
||||
[&](int /*buffer_i*/, int /*tri_i*/, int vertex_i, const int /*looptri_i*/) {
|
||||
*static_cast<uchar *>(GPU_vertbuf_raw_step(&access)) = uchar(mask[vertex_i] *
|
||||
255.0f);
|
||||
});
|
||||
}
|
||||
else {
|
||||
foreach_faces([&](int /*buffer_i*/, int /*tri_i*/, int /*vertex_i*/, const int /*tri*/) {
|
||||
*static_cast<uchar *>(GPU_vertbuf_raw_step(&access)) = 0;
|
||||
});
|
||||
foreach_faces(
|
||||
[&](int /*buffer_i*/, int /*tri_i*/, int /*vertex_i*/, const int /*looptri_i*/) {
|
||||
*static_cast<uchar *>(GPU_vertbuf_raw_step(&access)) = 0;
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -611,31 +615,34 @@ struct PBVHBatches {
|
|||
int last_poly = -1;
|
||||
uchar fset_color[4] = {UCHAR_MAX, UCHAR_MAX, UCHAR_MAX, UCHAR_MAX};
|
||||
|
||||
foreach_faces([&](int /*buffer_i*/, int /*tri_i*/, int /*vertex_i*/, const int tri) {
|
||||
const int poly_i = args->looptri_polys[tri];
|
||||
if (last_poly != poly_i) {
|
||||
last_poly = poly_i;
|
||||
foreach_faces(
|
||||
[&](int /*buffer_i*/, int /*tri_i*/, int /*vertex_i*/, const int looptri_i) {
|
||||
const int poly_i = args->looptri_polys[looptri_i];
|
||||
if (last_poly != poly_i) {
|
||||
last_poly = poly_i;
|
||||
|
||||
const int fset = face_sets[poly_i];
|
||||
const int fset = face_sets[poly_i];
|
||||
|
||||
if (fset != args->face_sets_color_default) {
|
||||
BKE_paint_face_set_overlay_color_get(fset, args->face_sets_color_seed, fset_color);
|
||||
}
|
||||
else {
|
||||
/* Skip for the default color face set to render it white. */
|
||||
fset_color[0] = fset_color[1] = fset_color[2] = UCHAR_MAX;
|
||||
}
|
||||
}
|
||||
if (fset != args->face_sets_color_default) {
|
||||
BKE_paint_face_set_overlay_color_get(
|
||||
fset, args->face_sets_color_seed, fset_color);
|
||||
}
|
||||
else {
|
||||
/* Skip for the default color face set to render it white. */
|
||||
fset_color[0] = fset_color[1] = fset_color[2] = UCHAR_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
*static_cast<uchar3 *>(GPU_vertbuf_raw_step(&access)) = fset_color;
|
||||
});
|
||||
*static_cast<uchar3 *>(GPU_vertbuf_raw_step(&access)) = fset_color;
|
||||
});
|
||||
}
|
||||
else {
|
||||
uchar fset_color[4] = {255, 255, 255, 255};
|
||||
|
||||
foreach_faces([&](int /*buffer_i*/, int /*tri_i*/, int /*vertex_i*/, const int /*tri*/) {
|
||||
*static_cast<uchar3 *>(GPU_vertbuf_raw_step(&access)) = fset_color;
|
||||
});
|
||||
foreach_faces(
|
||||
[&](int /*buffer_i*/, int /*tri_i*/, int /*vertex_i*/, const int /*looptri_i*/) {
|
||||
*static_cast<uchar3 *>(GPU_vertbuf_raw_step(&access)) = fset_color;
|
||||
});
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -645,25 +652,26 @@ struct PBVHBatches {
|
|||
const MPropCol *mpropcol = static_cast<const MPropCol *>(
|
||||
CustomData_get_layer_named(args->vdata, CD_PROP_COLOR, vbo.name.c_str()));
|
||||
|
||||
foreach_faces([&](int /*buffer_i*/, int /*tri_i*/, int vertex_i, const int /*tri*/) {
|
||||
ushort color[4];
|
||||
const MPropCol *col = mpropcol + vertex_i;
|
||||
foreach_faces(
|
||||
[&](int /*buffer_i*/, int /*tri_i*/, int vertex_i, const int /*looptri_i*/) {
|
||||
ushort color[4];
|
||||
const MPropCol *col = mpropcol + vertex_i;
|
||||
|
||||
color[0] = unit_float_to_ushort_clamp(col->color[0]);
|
||||
color[1] = unit_float_to_ushort_clamp(col->color[1]);
|
||||
color[2] = unit_float_to_ushort_clamp(col->color[2]);
|
||||
color[3] = unit_float_to_ushort_clamp(col->color[3]);
|
||||
color[0] = unit_float_to_ushort_clamp(col->color[0]);
|
||||
color[1] = unit_float_to_ushort_clamp(col->color[1]);
|
||||
color[2] = unit_float_to_ushort_clamp(col->color[2]);
|
||||
color[3] = unit_float_to_ushort_clamp(col->color[3]);
|
||||
|
||||
*static_cast<ushort4 *>(GPU_vertbuf_raw_step(&access)) = color;
|
||||
});
|
||||
*static_cast<ushort4 *>(GPU_vertbuf_raw_step(&access)) = color;
|
||||
});
|
||||
}
|
||||
else if (vbo.domain == ATTR_DOMAIN_CORNER) {
|
||||
const MPropCol *mpropcol = static_cast<const MPropCol *>(
|
||||
CustomData_get_layer_named(args->ldata, CD_PROP_COLOR, vbo.name.c_str()));
|
||||
|
||||
foreach_faces([&](int /*buffer_i*/, int tri_i, int /*vertex_i*/, const int tri) {
|
||||
foreach_faces([&](int /*buffer_i*/, int tri_i, int /*vertex_i*/, const int looptri_i) {
|
||||
ushort color[4];
|
||||
const MPropCol *col = mpropcol + args->mlooptri[tri].tri[tri_i];
|
||||
const MPropCol *col = mpropcol + args->mlooptri[looptri_i].tri[tri_i];
|
||||
|
||||
color[0] = unit_float_to_ushort_clamp(col->color[0]);
|
||||
color[1] = unit_float_to_ushort_clamp(col->color[1]);
|
||||
|
@ -679,25 +687,26 @@ struct PBVHBatches {
|
|||
const MLoopCol *mbytecol = static_cast<const MLoopCol *>(
|
||||
CustomData_get_layer_named(args->vdata, CD_PROP_BYTE_COLOR, vbo.name.c_str()));
|
||||
|
||||
foreach_faces([&](int /*buffer_i*/, int /*tri_i*/, int vertex_i, const int /*tri*/) {
|
||||
ushort color[4];
|
||||
const MLoopCol *col = mbytecol + vertex_i;
|
||||
foreach_faces(
|
||||
[&](int /*buffer_i*/, int /*tri_i*/, int vertex_i, const int /*looptri_i*/) {
|
||||
ushort color[4];
|
||||
const MLoopCol *col = mbytecol + vertex_i;
|
||||
|
||||
color[0] = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[col->r]);
|
||||
color[1] = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[col->g]);
|
||||
color[2] = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[col->b]);
|
||||
color[3] = col->a * 257;
|
||||
color[0] = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[col->r]);
|
||||
color[1] = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[col->g]);
|
||||
color[2] = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[col->b]);
|
||||
color[3] = col->a * 257;
|
||||
|
||||
*static_cast<ushort4 *>(GPU_vertbuf_raw_step(&access)) = color;
|
||||
});
|
||||
*static_cast<ushort4 *>(GPU_vertbuf_raw_step(&access)) = color;
|
||||
});
|
||||
}
|
||||
else if (vbo.domain == ATTR_DOMAIN_CORNER) {
|
||||
const MLoopCol *mbytecol = static_cast<const MLoopCol *>(
|
||||
CustomData_get_layer_named(args->ldata, CD_PROP_BYTE_COLOR, vbo.name.c_str()));
|
||||
|
||||
foreach_faces([&](int /*buffer_i*/, int tri_i, int /*vertex_i*/, const int tri) {
|
||||
foreach_faces([&](int /*buffer_i*/, int tri_i, int /*vertex_i*/, const int looptri_i) {
|
||||
ushort color[4];
|
||||
const MLoopCol *col = mbytecol + args->mlooptri[tri].tri[tri_i];
|
||||
const MLoopCol *col = mbytecol + args->mlooptri[looptri_i].tri[tri_i];
|
||||
|
||||
color[0] = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[col->r]);
|
||||
color[1] = unit_float_to_ushort_clamp(BLI_color_from_srgb_table[col->g]);
|
||||
|
@ -712,9 +721,9 @@ struct PBVHBatches {
|
|||
const float2 *mloopuv = static_cast<const float2 *>(
|
||||
CustomData_get_layer_named(args->ldata, CD_PROP_FLOAT2, vbo.name.c_str()));
|
||||
|
||||
foreach_faces([&](int /*buffer_i*/, int tri_i, int /*vertex_i*/, const int tri) {
|
||||
foreach_faces([&](int /*buffer_i*/, int tri_i, int /*vertex_i*/, const int looptri_i) {
|
||||
*static_cast<float2 *>(
|
||||
GPU_vertbuf_raw_step(&access)) = mloopuv[args->mlooptri[tri].tri[tri_i]];
|
||||
GPU_vertbuf_raw_step(&access)) = mloopuv[args->mlooptri[looptri_i].tri[tri_i]];
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
@ -965,8 +974,9 @@ struct PBVHBatches {
|
|||
CustomData_get_layer_named(args->pdata, CD_PROP_INT32, "material_index"));
|
||||
|
||||
if (mat_index && args->totprim) {
|
||||
int poly_index = args->looptri_polys[args->prim_indices[0]];
|
||||
material_index = mat_index[poly_index];
|
||||
const int looptri_i = args->prim_indices[0];
|
||||
const int poly_i = args->looptri_polys[looptri_i];
|
||||
material_index = mat_index[poly_i];
|
||||
}
|
||||
|
||||
const blender::Span<blender::int2> edges = args->me->edges();
|
||||
|
@ -974,13 +984,13 @@ struct PBVHBatches {
|
|||
/* Calculate number of edges. */
|
||||
int edge_count = 0;
|
||||
for (int i = 0; i < args->totprim; i++) {
|
||||
const int tri_i = args->prim_indices[i];
|
||||
const int poly_i = args->looptri_polys[tri_i];
|
||||
const int looptri_i = args->prim_indices[i];
|
||||
const int poly_i = args->looptri_polys[looptri_i];
|
||||
if (args->hide_poly && args->hide_poly[poly_i]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const MLoopTri *lt = args->mlooptri + args->prim_indices[i];
|
||||
const MLoopTri *lt = &args->mlooptri[looptri_i];
|
||||
int r_edges[3];
|
||||
BKE_mesh_looptri_get_real_edges(
|
||||
edges.data(), args->corner_verts.data(), args->corner_edges.data(), lt, r_edges);
|
||||
|
@ -1001,13 +1011,13 @@ struct PBVHBatches {
|
|||
|
||||
int vertex_i = 0;
|
||||
for (int i = 0; i < args->totprim; i++) {
|
||||
const int tri_i = args->prim_indices[i];
|
||||
const int poly_i = args->looptri_polys[tri_i];
|
||||
const int looptri_i = args->prim_indices[i];
|
||||
const int poly_i = args->looptri_polys[looptri_i];
|
||||
if (args->hide_poly && args->hide_poly[poly_i]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const MLoopTri *lt = args->mlooptri + args->prim_indices[i];
|
||||
const MLoopTri *lt = &args->mlooptri[looptri_i];
|
||||
int r_edges[3];
|
||||
BKE_mesh_looptri_get_real_edges(
|
||||
edges.data(), args->corner_verts.data(), args->corner_edges.data(), lt, r_edges);
|
||||
|
@ -1059,8 +1069,8 @@ struct PBVHBatches {
|
|||
CustomData_get_layer_named(args->pdata, CD_PROP_INT32, "material_index"));
|
||||
|
||||
if (mat_index && args->totprim) {
|
||||
int poly_index = BKE_subdiv_ccg_grid_to_face_index(args->subdiv_ccg, args->grid_indices[0]);
|
||||
material_index = mat_index[poly_index];
|
||||
int poly_i = BKE_subdiv_ccg_grid_to_face_index(args->subdiv_ccg, args->grid_indices[0]);
|
||||
material_index = mat_index[poly_i];
|
||||
}
|
||||
|
||||
needs_tri_index = true;
|
||||
|
|
Loading…
Reference in New Issue