[Bf-blender-cvs] [c4b7ffa6f50] refactor-mesh-position-generic: Merge branch 'master' into refactor-mesh-position-generic
Hans Goudey
noreply at git.blender.org
Wed Sep 28 06:40:11 CEST 2022
Commit: c4b7ffa6f50c9680059fd221b5d7391fae6e6f29
Author: Hans Goudey
Date: Tue Sep 27 23:04:21 2022 -0500
Branches: refactor-mesh-position-generic
https://developer.blender.org/rBc4b7ffa6f50c9680059fd221b5d7391fae6e6f29
Merge branch 'master' into refactor-mesh-position-generic
===================================================================
===================================================================
diff --cc source/blender/blenkernel/BKE_mesh_legacy_convert.h
index 1cc9523f5cf,92182f8045b..b5bd9d17a22
--- a/source/blender/blenkernel/BKE_mesh_legacy_convert.h
+++ b/source/blender/blenkernel/BKE_mesh_legacy_convert.h
@@@ -10,12 -10,10 +10,14 @@@
#include "BLI_utildefines.h"
#ifdef __cplusplus
+# include "BLI_resource_scope.hh"
+ # include "BLI_span.hh"
+# include "BLI_vector.hh"
+ # include "DNA_customdata_types.h"
#endif
+#include "DNA_customdata_types.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@@ -81,15 -82,8 +86,15 @@@ void BKE_mesh_legacy_convert_material_i
*/
void BKE_mesh_legacy_convert_mpoly_to_material_indices(struct Mesh *mesh);
- #ifdef __cplusplus
+struct MVert *BKE_mesh_legacy_convert_positions_to_verts(
+ Mesh *mesh,
+ blender::ResourceScope &temp_arrays_for_convert,
+ blender::Vector<CustomDataLayer, 16> &vert_layers_to_write);
- #endif
+
+void BKE_mesh_legacy_convert_verts_to_positions(Mesh *mesh);
+
+ #endif
+
/**
* Recreate #MFace Tessellation.
*
diff --cc source/blender/blenkernel/intern/cloth.c
index 7300ca9a8eb,e85e19f04c9..31f3353c91d
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@@ -1147,8 -1148,8 +1148,8 @@@ static void cloth_update_springs(ClothM
/* Update rest verts, for dynamically deformable cloth */
static void cloth_update_verts(Object *ob, ClothModifierData *clmd, Mesh *mesh)
{
- unsigned int i = 0;
+ uint i = 0;
- const MVert *mvert = BKE_mesh_verts(mesh);
+ const float(*positions)[3] = BKE_mesh_positions(mesh);
ClothVertex *verts = clmd->clothObject->verts;
/* vertex count is already ensured to match */
diff --cc source/blender/blenkernel/intern/dynamicpaint.c
index bd201da0692,03358f50d40..756b4946a54
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@@ -6057,14 -6063,12 +6057,12 @@@ static bool dynamicPaint_generateBakeDa
/* Init bdata */
bData->bNormal = (struct PaintBakeNormal *)MEM_mallocN(
sData->total_points * sizeof(struct PaintBakeNormal), "Dynamic Paint step data");
- bData->s_pos = MEM_mallocN(sData->total_points * sizeof(unsigned int),
- "Dynamic Paint bData s_pos");
- bData->s_num = MEM_mallocN(sData->total_points * sizeof(unsigned int),
- "Dynamic Paint bData s_num");
+ bData->s_pos = MEM_mallocN(sData->total_points * sizeof(uint), "Dynamic Paint bData s_pos");
+ bData->s_num = MEM_mallocN(sData->total_points * sizeof(uint), "Dynamic Paint bData s_num");
bData->realCoord = (struct Vec3f *)MEM_mallocN(surface_totalSamples(surface) * sizeof(Vec3f),
"Dynamic Paint point coords");
- bData->prev_verts = MEM_mallocN(canvasNumOfVerts * sizeof(MVert),
- "Dynamic Paint bData prev_verts");
+ bData->prev_positions = MEM_mallocN(canvasNumOfVerts * sizeof(float[3]),
+ "Dynamic Paint bData prev_positions");
/* if any allocation failed, free everything */
if (!bData->bNormal || !bData->s_pos || !bData->s_num || !bData->realCoord || !canvas_verts) {
diff --cc source/blender/blenkernel/intern/mesh.cc
index 2d27d185cd9,4d98efde5f9..2fec68932b0
--- a/source/blender/blenkernel/intern/mesh.cc
+++ b/source/blender/blenkernel/intern/mesh.cc
@@@ -261,16 -263,8 +261,16 @@@ static void mesh_blend_write(BlendWrite
".select_edge",
".select_poly"});
+ mesh->mvert = BKE_mesh_legacy_convert_positions_to_verts(
+ mesh, temp_arrays_for_legacy_format, vert_layers);
+ BKE_mesh_legacy_convert_hide_layers_to_flags(mesh);
+ BKE_mesh_legacy_convert_selection_layers_to_flags(mesh);
+ BKE_mesh_legacy_convert_material_indices_to_mpoly(mesh);
+ BKE_mesh_legacy_bevel_weight_from_layers(mesh);
- BKE_mesh_legacy_face_set_from_generic(mesh);
++ BKE_mesh_legacy_face_set_from_generic(mesh, poly_layers);
+ BKE_mesh_legacy_edge_crease_from_layers(mesh);
+
/* Set deprecated mesh data pointers for forward compatibility. */
- mesh->mvert = const_cast<MVert *>(mesh->verts().data());
mesh->medge = const_cast<MEdge *>(mesh->edges().data());
mesh->mpoly = const_cast<MPoly *>(mesh->polys().data());
mesh->mloop = const_cast<MLoop *>(mesh->loops().data());
diff --cc source/blender/blenkernel/intern/mesh_boolean_convert.cc
index c7cc89cbbb6,360c7da2ae2..62f73eb4626
--- a/source/blender/blenkernel/intern/mesh_boolean_convert.cc
+++ b/source/blender/blenkernel/intern/mesh_boolean_convert.cc
@@@ -111,10 -111,10 +111,10 @@@ class MeshesToIMeshInfo
};
/* Given an index `imesh_v` in the `IMesh`, return the index of the
- * input `Mesh` that contained the `MVert` that it came from. */
+ * input `Mesh` that contained the vertex that it came from. */
int MeshesToIMeshInfo::input_mesh_for_imesh_vert(int imesh_v) const
{
- int n = static_cast<int>(mesh_vert_offset.size());
+ int n = int(mesh_vert_offset.size());
for (int i = 0; i < n - 1; ++i) {
if (imesh_v < mesh_vert_offset[i + 1]) {
return i;
@@@ -124,10 -124,10 +124,10 @@@
}
/* Given an index `imesh_e` used as an original index in the `IMesh`,
- * return the index of the input `Mesh` that contained the `MVert` that it came from. */
+ * return the index of the input `Mesh` that contained the vertex that it came from. */
int MeshesToIMeshInfo::input_mesh_for_imesh_edge(int imesh_e) const
{
- int n = static_cast<int>(mesh_edge_offset.size());
+ int n = int(mesh_edge_offset.size());
for (int i = 0; i < n - 1; ++i) {
if (imesh_e < mesh_edge_offset[i + 1]) {
return i;
diff --cc source/blender/blenkernel/intern/mesh_evaluate.cc
index 9c968521a07,ae0d5efa112..0c33767ba72
--- a/source/blender/blenkernel/intern/mesh_evaluate.cc
+++ b/source/blender/blenkernel/intern/mesh_evaluate.cc
@@@ -148,10 -147,10 +148,10 @@@ void BKE_mesh_calc_poly_normal_coords(c
static void mesh_calc_ngon_center(const MPoly *mpoly,
const MLoop *loopstart,
- const MVert *mvert,
+ const float (*positions)[3],
float cent[3])
{
- const float w = 1.0f / (float)mpoly->totloop;
+ const float w = 1.0f / float(mpoly->totloop);
zero_v3(cent);
diff --cc source/blender/blenkernel/intern/mesh_normals.cc
index f9540b51f21,154840e2ef7..904ea9eccb9
--- a/source/blender/blenkernel/intern/mesh_normals.cc
+++ b/source/blender/blenkernel/intern/mesh_normals.cc
@@@ -961,13 -962,13 +961,13 @@@ void BKE_edges_sharp_from_angle_set(con
/* Mapping edge -> loops. See BKE_mesh_normals_loop_split() for details. */
int(*edge_to_loops)[2] = (int(*)[2])MEM_calloc_arrayN(
- (size_t)numEdges, sizeof(*edge_to_loops), __func__);
+ size_t(numEdges), sizeof(*edge_to_loops), __func__);
/* Simple mapping from a loop to its polygon index. */
- int *loop_to_poly = (int *)MEM_malloc_arrayN((size_t)numLoops, sizeof(*loop_to_poly), __func__);
+ int *loop_to_poly = (int *)MEM_malloc_arrayN(size_t(numLoops), sizeof(*loop_to_poly), __func__);
LoopSplitTaskDataCommon common_data = {};
- common_data.mverts = mverts;
+ common_data.positions = positions;
common_data.medges = medges;
common_data.mloops = mloops;
common_data.mpolys = mpolys;
diff --cc source/blender/blenkernel/intern/mesh_remesh_voxel.cc
index 26b14d26de9,62354c83df1..1ea01e6e45e
--- a/source/blender/blenkernel/intern/mesh_remesh_voxel.cc
+++ b/source/blender/blenkernel/intern/mesh_remesh_voxel.cc
@@@ -185,10 -192,9 +185,9 @@@ Mesh *BKE_mesh_remesh_quadriflow(const
static openvdb::FloatGrid::Ptr remesh_voxel_level_set_create(const Mesh *mesh,
const float voxel_size)
{
- const Span<MVert> verts = mesh->verts();
+ const Span<float3> positions = mesh->positions();
const Span<MLoop> loops = mesh->loops();
- Span<MLoopTri> looptris{BKE_mesh_runtime_looptri_ensure(mesh),
- BKE_mesh_runtime_looptri_len(mesh)};
+ const Span<MLoopTri> looptris = mesh->looptris();
std::vector<openvdb::Vec3s> points(mesh->totvert);
std::vector<openvdb::Vec3I> triangles(looptris.size());
@@@ -400,11 -404,11 +399,11 @@@ void BKE_remesh_reproject_vertex_paint(
nearest.index = -1;
nearest.dist_sq = FLT_MAX;
BLI_bvhtree_find_nearest(
- bvhtree.tree, target_verts[i].co, &nearest, bvhtree.nearest_callback, &bvhtree);
+ bvhtree.tree, target_positions[i], &nearest, bvhtree.nearest_callback, &bvhtree);
if (nearest.index != -1) {
- memcpy(POINTER_OFFSET(target_data, (size_t)i * data_size),
- POINTER_OFFSET(source_data, (size_t)nearest.index * data_size),
+ memcpy(POINTER_OFFSET(target_data, size_t(i) * data_size),
+ POINTER_OFFSET(source_data, size_t(nearest.index) * data_size),
data_size);
}
}
diff --cc source/blender/blenkernel/intern/mesh_sample.cc
index 6e59bc59fef,ed7ae8113a7..005986cb767
--- a/source/blender/blenkernel/intern/mesh_sample.cc
+++ b/source/blender/blenkernel/intern/mesh_sample.cc
@@@ -159,10 -156,9 +156,9 @@@ Span<float3> MeshAttributeInterpolator:
}
bary_coords_.reinitialize(mask_.min_array_size());
- const Span<MVert> verts = mesh_->verts();
+ const Span<float3> positions = mesh_->positions();
const Span<MLoop> loops = mesh_->loops();
- const Span<MLoopTri> looptris{BKE_mesh_runtime_looptri_ensure(mesh_),
- BKE_mesh_runtime_looptri_len(mesh_)};
+ const Span<MLoopTri> looptris = mesh_->looptris();
for (const int i : mask_) {
const int looptri_index = looptri_indices_[i];
@@@ -189,10 -185,9 +185,9 @@@ Span<float3> MeshAttributeInterpolator:
}
nearest_weights_.reinitialize(mask_.min_array_size());
- con
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list