Mesh: Replace MLoop struct with generic attributes #104424

Merged
Hans Goudey merged 261 commits from refactor-mesh-corners-generic into main 2023-03-20 15:55:25 +01:00
7 changed files with 11 additions and 14 deletions
Showing only changes of commit 579e4ee8df - Show all commits

View File

@ -189,7 +189,6 @@ void MeshesToIMeshInfo::input_mvert_for_orig_index(int orig_index,
int orig_mesh_index = input_mesh_for_imesh_vert(orig_index);
BLI_assert(0 <= orig_mesh_index && orig_mesh_index < meshes.size());
const Mesh *me = meshes[orig_mesh_index];
const Span<float3> positions = me->positions();
int index_in_mesh = orig_index - mesh_vert_offset[orig_mesh_index];
BLI_assert(0 <= index_in_mesh && index_in_mesh < me->totvert);
if (r_orig_mesh) {

View File

@ -1597,7 +1597,7 @@ int mdisp_rot_face_to_crn( struct MPoly *mpoly,
float mindist = FLT_MAX;
for (i = 0; i < mpoly->totloop; i++) {
float len = len_v3v3(NULL, mvert[mloop[mpoly->loopstart + i].v].co);
float len = len_v3v3(NULL, positions[mloop[mpoly->loopstart + i].v].co);
if (len < mindist) {
mindist = len;
minS = i;

View File

@ -97,7 +97,7 @@ static void distribute_grid(Mesh *mesh, ParticleSystem *psys)
{
ParticleData *pa = NULL;
float min[3], max[3], delta[3], d;
float(*positions)[3] = BKE_mesh_positions_for_write(mesh);
const float(*positions)[3] = BKE_mesh_positions(mesh);
int totvert = mesh->totvert, from = psys->part->from;
int i, j, k, p, res = psys->part->grid_res, size[3], axis;

View File

@ -654,9 +654,9 @@ static int bm_to_mesh_shape_layer_index_from_kb(BMesh *bm, KeyBlock *currkey)
*
* \param bm: The source BMesh.
* \param key: The destination key.
* \param mvert: The destination vertex array (in some situations it's coordinates are updated).
* \param positions: The destination vertex array (in some situations its coordinates are updated).
* \param active_shapekey_to_mvert: When editing a non-basis shape key, the coordinates for the
* basis are typically copied into the `mvert` array since it makes sense for the meshes
* basis are typically copied into the `positions` array since it makes sense for the meshes
* vertex coordinates to match the "Basis" key.
* When enabled, skip this step and copy #BMVert.co directly to the mesh position.
* See #BMeshToMeshParams.active_shapekey_to_mvert doc-string.
@ -743,7 +743,7 @@ static void bm_to_mesh_shape(BMesh *bm,
* while users might not notice since the shape-key is applied in the viewport,
* exporters for example may still use the underlying coordinates, see: T30771 & T96135.
*
* Needed when editing any shape that isn't the (`key->refkey`), the vertices in `me->mvert`
* Needed when editing any shape that isn't the (`key->refkey`), the vertices in mesh positions
* currently have vertex coordinates set from the current-shape (initialized from #BMVert.co).
* In this case it's important to overwrite these coordinates with the basis-keys coordinates. */
bool update_vertex_coords_from_refkey = false;

View File

@ -310,7 +310,7 @@ static bool sculpt_undo_restore_coords(bContext *C, Depsgraph *depsgraph, Sculpt
/* Propagate new coords to keyblock. */
SCULPT_vertcos_to_key(ob, ss->shapekey_active, vertCos);
/* PBVH uses its own mvert array, so coords should be */
/* PBVH uses its own vertex array, so coords should be */
/* propagated to PBVH here. */
BKE_pbvh_vert_coords_apply(ss->pbvh, vertCos, ss->shapekey_active->totelem);

View File

@ -384,7 +384,7 @@ typedef struct TFace {
/** #Mesh_Runtime.wrapper_type */
typedef enum eMeshWrapperType {
/** Use mesh data (#Mesh.mvert, #Mesh.medge, #Mesh.mloop, #Mesh.mpoly). */
/** Use mesh data (#positions, #Mesh.medge, #Mesh.mloop, #Mesh.mpoly). */
ME_WRAPPER_TYPE_MDATA = 0,
/** Use edit-mesh data (#Mesh.edit_mesh, #Mesh_Runtime.edit_data). */
ME_WRAPPER_TYPE_BMESH = 1,

View File

@ -19,9 +19,7 @@ extern "C" {
* \{ */
/**
* Mesh Vertices.
*
* Typically accessed from #Mesh.mvert
* Deprecated mesh vertex data structure. Now stored with generic attributes.
*/
#ifdef DNA_DEPRECATED_ALLOW
typedef struct MVert {
@ -178,9 +176,9 @@ enum {
*
* // access vertex locations.
* float *vtri_co[3] = {
* mvert[mloop[lt->tri[0]].v].co,
* mvert[mloop[lt->tri[1]].v].co,
* mvert[mloop[lt->tri[2]].v].co,
* positions[mloop[lt->tri[0]].v],
* positions[mloop[lt->tri[1]].v],
* positions[mloop[lt->tri[2]].v],
* };
*
* // access UV coordinates (works for all loop data, vertex colors... etc).