[Bf-blender-cvs] [c0f754d9b12] refactor-mesh-position-generic: Merge branch 'master' into refactor-mesh-position-generic
Hans Goudey
noreply at git.blender.org
Fri Oct 7 06:33:47 CEST 2022
Commit: c0f754d9b125543e590f0302e92085836d216f64
Author: Hans Goudey
Date: Sun Oct 2 23:34:27 2022 -0500
Branches: refactor-mesh-position-generic
https://developer.blender.org/rBc0f754d9b125543e590f0302e92085836d216f64
Merge branch 'master' into refactor-mesh-position-generic
===================================================================
===================================================================
diff --cc source/blender/blenkernel/BKE_collision.h
index 44c1b2a3cbd,c390d0a8802..1aaddebed91
--- a/source/blender/blenkernel/BKE_collision.h
+++ b/source/blender/blenkernel/BKE_collision.h
@@@ -84,10 -85,10 +84,10 @@@ typedef struct FaceCollPair
/////////////////////////////////////////////////
/////////////////////////////////////////////////
- // used in modifier.c from collision.c
+ // used in modifier.cc from collision.c
/////////////////////////////////////////////////
-struct BVHTree *bvhtree_build_from_mvert(const struct MVert *mvert,
+struct BVHTree *bvhtree_build_from_mvert(const float (*positions)[3],
const struct MVertTri *tri,
int tri_num,
float epsilon);
diff --cc source/blender/blenkernel/intern/mball_tessellate.cc
index dd10a6f8646,9b32456c6c1..00778ce2d79
--- a/source/blender/blenkernel/intern/mball_tessellate.cc
+++ b/source/blender/blenkernel/intern/mball_tessellate.cc
@@@ -1439,15 -1461,19 +1461,16 @@@ Mesh *BKE_mball_polygonize(Depsgraph *d
Mesh *mesh = (Mesh *)BKE_id_new_nomain(ID_ME, ((ID *)ob->data)->name + 2);
- mesh->totvert = int(process.curvertex);
- MVert *mvert = static_cast<MVert *>(
- CustomData_add_layer(&mesh->vdata, CD_MVERT, CD_CONSTRUCT, NULL, mesh->totvert));
- for (int i = 0; i < mesh->totvert; i++) {
- copy_v3_v3(mvert[i].co, process.co[i]);
- }
- MEM_freeN(process.co);
+ mesh->totvert = (int)process.curvertex;
+ CustomData_add_layer_named(
+ &mesh->vdata, CD_PROP_FLOAT3, CD_ASSIGN, process.co, mesh->totvert, "position");
+ process.co = NULL;
- mesh->totpoly = (int)process.curindex;
- MPoly *mpoly = CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_CONSTRUCT, NULL, mesh->totpoly);
- MLoop *mloop = CustomData_add_layer(
- &mesh->ldata, CD_MLOOP, CD_CONSTRUCT, NULL, mesh->totpoly * 4);
+ mesh->totpoly = int(process.curindex);
+ MPoly *mpoly = static_cast<MPoly *>(
+ CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_CONSTRUCT, NULL, mesh->totpoly));
+ MLoop *mloop = static_cast<MLoop *>(
+ CustomData_add_layer(&mesh->ldata, CD_MLOOP, CD_CONSTRUCT, NULL, mesh->totpoly * 4));
int loop_offset = 0;
for (int i = 0; i < mesh->totpoly; i++) {
diff --cc source/blender/blenkernel/intern/mesh_fair.cc
index 1a219c0b83e,df61169fa5c..2647b3b4990
--- a/source/blender/blenkernel/intern/mesh_fair.cc
+++ b/source/blender/blenkernel/intern/mesh_fair.cc
@@@ -26,7 -26,7 +26,8 @@@
#include "MEM_guardedalloc.h"
#include "eigen_capi.h"
+ using blender::Array;
+using blender::float3;
using blender::Map;
using blender::MutableSpan;
using blender::Span;
diff --cc source/blender/blenkernel/intern/mesh_iterators.cc
index 50a27836c74,46f9780f891..d983cc440b3
--- a/source/blender/blenkernel/intern/mesh_iterators.cc
+++ b/source/blender/blenkernel/intern/mesh_iterators.cc
@@@ -65,15 -65,15 +65,15 @@@ void BKE_mesh_foreach_mapped_vert
}
}
else {
- const MVert *mv = BKE_mesh_verts(mesh);
+ const float(*positions)[3] = BKE_mesh_positions(mesh);
- const int *index = CustomData_get_layer(&mesh->vdata, CD_ORIGINDEX);
+ const int *index = static_cast<const int *>(CustomData_get_layer(&mesh->vdata, CD_ORIGINDEX));
const float(*vert_normals)[3] = (flag & MESH_FOREACH_USE_NORMAL) ?
BKE_mesh_vertex_normals_ensure(mesh) :
- NULL;
+ nullptr;
if (index) {
- for (int i = 0; i < mesh->totvert; i++, mv++) {
+ for (int i = 0; i < mesh->totvert; i++) {
- const float *no = (flag & MESH_FOREACH_USE_NORMAL) ? vert_normals[i] : NULL;
+ const float *no = (flag & MESH_FOREACH_USE_NORMAL) ? vert_normals[i] : nullptr;
const int orig = *index++;
if (orig == ORIGINDEX_NONE) {
continue;
@@@ -82,9 -82,9 +82,9 @@@
}
}
else {
- for (int i = 0; i < mesh->totvert; i++, mv++) {
+ for (int i = 0; i < mesh->totvert; i++) {
- const float *no = (flag & MESH_FOREACH_USE_NORMAL) ? vert_normals[i] : NULL;
+ const float *no = (flag & MESH_FOREACH_USE_NORMAL) ? vert_normals[i] : nullptr;
- func(userData, i, mv->co, no);
+ func(userData, i, positions[i], no);
}
}
}
@@@ -120,9 -120,9 +120,9 @@@ void BKE_mesh_foreach_mapped_edge
}
}
else {
- const MVert *mv = BKE_mesh_verts(mesh);
+ const float(*positions)[3] = BKE_mesh_positions(mesh);
const MEdge *med = BKE_mesh_edges(mesh);
- const int *index = CustomData_get_layer(&mesh->edata, CD_ORIGINDEX);
+ const int *index = static_cast<const int *>(CustomData_get_layer(&mesh->edata, CD_ORIGINDEX));
if (index) {
for (int i = 0; i < mesh->totedge; i++, med++) {
@@@ -185,14 -186,17 +186,17 @@@ void BKE_mesh_foreach_mapped_loop(Mesh
}
else {
const float(*lnors)[3] = (flag & MESH_FOREACH_USE_NORMAL) ?
- CustomData_get_layer(&mesh->ldata, CD_NORMAL) :
- NULL;
+ static_cast<const float(*)[3]>(
+ CustomData_get_layer(&mesh->ldata, CD_NORMAL)) :
+ nullptr;
- const MVert *mv = BKE_mesh_verts(mesh);
+ const float(*positions)[3] = BKE_mesh_positions(mesh);
const MLoop *ml = BKE_mesh_loops(mesh);
const MPoly *mp = BKE_mesh_polys(mesh);
- const int *v_index = CustomData_get_layer(&mesh->vdata, CD_ORIGINDEX);
- const int *f_index = CustomData_get_layer(&mesh->pdata, CD_ORIGINDEX);
+ const int *v_index = static_cast<const int *>(
+ CustomData_get_layer(&mesh->vdata, CD_ORIGINDEX));
+ const int *f_index = static_cast<const int *>(
+ CustomData_get_layer(&mesh->pdata, CD_ORIGINDEX));
int p_idx, i;
if (v_index || f_index) {
@@@ -213,8 -217,8 +217,8 @@@
for (i = 0; i < mp->totloop; i++, ml++) {
const int v_idx = ml->v;
const int f_idx = p_idx;
- const float *no = lnors ? *lnors++ : NULL;
+ const float *no = lnors ? *lnors++ : nullptr;
- func(userData, v_idx, f_idx, mv[ml->v].co, no);
+ func(userData, v_idx, f_idx, positions[ml->v], no);
}
}
}
@@@ -308,12 -312,13 +312,12 @@@ void BKE_mesh_foreach_mapped_subdiv_fac
const MPoly *mp = BKE_mesh_polys(mesh);
const MLoop *loops = BKE_mesh_loops(mesh);
const MLoop *ml;
- const MVert *mv;
const float(*vert_normals)[3] = (flag & MESH_FOREACH_USE_NORMAL) ?
BKE_mesh_vertex_normals_ensure(mesh) :
- NULL;
- const int *index = CustomData_get_layer(&mesh->pdata, CD_ORIGINDEX);
+ nullptr;
+ const int *index = static_cast<const int *>(CustomData_get_layer(&mesh->pdata, CD_ORIGINDEX));
const BLI_bitmap *facedot_tags = mesh->runtime.subsurf_face_dot_tags;
- BLI_assert(facedot_tags != NULL);
+ BLI_assert(facedot_tags != nullptr);
if (index) {
for (int i = 0; i < mesh->totpoly; i++, mp++) {
@@@ -326,8 -331,9 +330,8 @@@
if (BLI_BITMAP_TEST(facedot_tags, ml->v)) {
func(userData,
orig,
- mv->co,
+ positions[ml->v],
- (flag & MESH_FOREACH_USE_NORMAL) ? vert_normals[ml->v] : NULL);
+ (flag & MESH_FOREACH_USE_NORMAL) ? vert_normals[ml->v] : nullptr);
}
}
}
@@@ -339,8 -345,9 +343,8 @@@
if (BLI_BITMAP_TEST(facedot_tags, ml->v)) {
func(userData,
i,
- mv->co,
+ positions[ml->v],
- (flag & MESH_FOREACH_USE_NORMAL) ? vert_normals[ml->v] : NULL);
+ (flag & MESH_FOREACH_USE_NORMAL) ? vert_normals[ml->v] : nullptr);
}
}
}
diff --cc source/blender/blenkernel/intern/pbvh.c
index 5d90287959d,a7595952cac..7a16c6db796
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@@ -513,6 -513,80 +513,80 @@@ static void pbvh_build(PBVH *pbvh, BB *
build_sub(pbvh, 0, cb, prim_bbc, 0, totprim);
}
+ static void pbvh_draw_args_init(PBVH *pbvh, PBVH_GPU_Args *args, PBVHNode *node)
+ {
+ memset((void *)args, 0, sizeof(*args));
+
+ args->pbvh_type = pbvh->header.type;
+ args->mesh_verts_num = pbvh->totvert;
+ args->mesh_grids_num = pbvh->totgrid;
+ args->node = node;
+
+ BKE_pbvh_node_num_verts(pbvh, node, NULL, &args->node_verts_num);
+
+ args->grid_hidden = pbvh->grid_hidden;
+ args->face_sets_color_default = pbvh->face_sets_color_default;
+ args->face_sets_color_seed = pbvh->face_sets_color_seed;
- args->mvert = pbvh->verts;
++ args->mesh_positions = pbvh->mesh_positions;
+ args->mloop = pbvh->mloop;
+ args->mpoly = pbvh->mpoly;
+ args->mlooptri = pbvh->looptri;
+
+ if (ELEM(pbvh->header.type, PBVH_FACES, PBVH_GRIDS)) {
+ args->hide_poly = pbvh->pdata ?
+ CustomData_get_layer_named(pbvh->pdata, CD_PROP_BOOL, ".hide_poly") :
+ NULL;
+ }
+
+ switch (pbvh->header.type) {
+ case PBVH_FACES:
+ args->mesh_faces_num = pbvh->mesh->totpoly;
+ args->vdata = pbvh->vdata;
+ args->ldata = pbvh->ldata;
+ args->pdata = pbvh->pdata;
+ args->totprim = node->totprim;
+ args->me = pbvh->mesh;
+ args->mpoly = pbvh->mpoly;
+ args->vert_normals = pbvh->vert_normals;
+
+ args->prim_indices = node->prim_indices;
+ args->face_sets = pbvh->face_sets;
+ break;
+ case PBVH_GRIDS:
+ args->vdata = pbvh->vdata;
+ args->ldata = pbvh->ldata;
+ args->pdata = pbvh->pdata;
+ args->ccg_key = pbvh->gridkey;
+ args->me = pbvh->mesh;
+ args->totprim = node->totprim;
+ args->grid_indices = node->prim_indices;
+ args->subdiv_ccg = pbvh->subdiv_ccg;
+ args->face_sets = pbvh->face_sets;
+ args->mpoly =
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list