Add more vert prefixes

This commit is contained in:
Hans Goudey 2023-01-09 12:14:43 -05:00
parent 80b93d8932
commit 881b75a0c2
10 changed files with 68 additions and 61 deletions

View File

@ -325,7 +325,7 @@ void BKE_mesh_vert_coords_apply(struct Mesh *mesh, const float (*vert_coords)[3]
*/
void BKE_mesh_recalc_looptri(const struct MLoop *mloop,
const struct MPoly *mpoly,
const float (*positions)[3],
const float (*vert_positions)[3],
int totloop,
int totpoly,
struct MLoopTri *mlooptri);
@ -339,7 +339,7 @@ void BKE_mesh_recalc_looptri(const struct MLoop *mloop,
*/
void BKE_mesh_recalc_looptri_with_normals(const struct MLoop *mloop,
const struct MPoly *mpoly,
const float (*positions)[3],
const float (*vert_positions)[3],
int totloop,
int totpoly,
struct MLoopTri *mlooptri,
@ -421,7 +421,7 @@ bool BKE_mesh_poly_normals_are_dirty(const struct Mesh *mesh);
void BKE_mesh_calc_poly_normal(const struct MPoly *mpoly,
const struct MLoop *loopstart,
const float (*positions)[3],
const float (*vert_positions)[3],
float r_no[3]);
/**
@ -430,7 +430,7 @@ void BKE_mesh_calc_poly_normal(const struct MPoly *mpoly,
* \note Usually #BKE_mesh_poly_normals_ensure is the preferred way to access face normals,
* since they may already be calculated and cached on the mesh.
*/
void BKE_mesh_calc_normals_poly(const float (*positions)[3],
void BKE_mesh_calc_normals_poly(const float (*vert_positions)[3],
int mvert_len,
const struct MLoop *mloop,
int mloop_len,
@ -444,7 +444,7 @@ void BKE_mesh_calc_normals_poly(const float (*positions)[3],
* \note Usually #BKE_mesh_vertex_normals_ensure is the preferred way to access vertex normals,
* since they may already be calculated and cached on the mesh.
*/
void BKE_mesh_calc_normals_poly_and_vertex(const float (*positions)[3],
void BKE_mesh_calc_normals_poly_and_vertex(const float (*vert_positions)[3],
int mvert_len,
const struct MLoop *mloop,
int mloop_len,
@ -594,7 +594,7 @@ void BKE_lnor_space_custom_normal_to_data(const MLoopNorSpace *lnor_space,
*
* \param loop_to_poly_map: Optional pre-created map from loops to their polygon.
*/
void BKE_mesh_normals_loop_split(const float (*positions)[3],
void BKE_mesh_normals_loop_split(const float (*vert_positions)[3],
const float (*vert_normals)[3],
int numVerts,
const struct MEdge *medges,
@ -611,7 +611,7 @@ void BKE_mesh_normals_loop_split(const float (*positions)[3],
MLoopNorSpaceArray *r_lnors_spacearr,
short (*clnors_data)[2]);
void BKE_mesh_normals_loop_custom_set(const float (*positions)[3],
void BKE_mesh_normals_loop_custom_set(const float (*vert_positions)[3],
const float (*vert_normals)[3],
int numVerts,
struct MEdge *medges,
@ -623,7 +623,7 @@ void BKE_mesh_normals_loop_custom_set(const float (*positions)[3],
const float (*poly_normals)[3],
int numPolys,
short (*r_clnors_data)[2]);
void BKE_mesh_normals_loop_custom_from_verts_set(const float (*positions)[3],
void BKE_mesh_normals_loop_custom_from_verts_set(const float (*vert_positions)[3],
const float (*vert_normals)[3],
float (*r_custom_vert_normals)[3],
int numVerts,
@ -686,17 +686,17 @@ void BKE_mesh_set_custom_normals_from_verts(struct Mesh *mesh, float (*r_custom_
void BKE_mesh_calc_poly_center(const struct MPoly *mpoly,
const struct MLoop *loopstart,
const float (*positions)[3],
const float (*vert_positions)[3],
float r_cent[3]);
/* NOTE: passing poly-normal is only a speedup so we can skip calculating it. */
float BKE_mesh_calc_poly_area(const struct MPoly *mpoly,
const struct MLoop *loopstart,
const float (*positions)[3]);
const float (*vert_positions)[3]);
float BKE_mesh_calc_area(const struct Mesh *me);
float BKE_mesh_calc_poly_uv_area(const struct MPoly *mpoly, const struct MLoopUV *uv_array);
void BKE_mesh_calc_poly_angles(const struct MPoly *mpoly,
const struct MLoop *loopstart,
const float (*positions)[3],
const float (*vert_positions)[3],
float angles[]);
void BKE_mesh_poly_edgehash_insert(struct EdgeHash *ehash,
@ -885,7 +885,7 @@ bool BKE_mesh_validate_material_indices(struct Mesh *me);
* by importers that load normals (for example).
*/
bool BKE_mesh_validate_arrays(struct Mesh *me,
float (*positions)[3],
float (*vert_positions)[3],
unsigned int totvert,
struct MEdge *medges,
unsigned int totedge,
@ -1047,7 +1047,7 @@ BLI_INLINE MDeformVert *BKE_mesh_deform_verts_for_write(Mesh *mesh)
#ifdef __cplusplus
# include "BLI_math_vec_types.hh"
# include "BLI_math_vector_types.hh"
# include "BLI_span.hh"
inline blender::Span<blender::float3> Mesh::vert_positions() const

View File

@ -127,7 +127,7 @@ int sample_surface_points_projected(
Vector<int> &r_looptri_indices,
Vector<float3> &r_positions);
float3 compute_bary_coord_in_triangle(Span<float3> positions,
float3 compute_bary_coord_in_triangle(Span<float3> vert_positions,
Span<MLoop> loops,
const MLoopTri &looptri,
const float3 &position);

View File

@ -55,32 +55,35 @@ static void mesh_calc_ngon_center(const MPoly *mpoly,
void BKE_mesh_calc_poly_center(const MPoly *mpoly,
const MLoop *loopstart,
const float (*positions)[3],
const float (*vert_positions)[3],
float r_cent[3])
{
if (mpoly->totloop == 3) {
mid_v3_v3v3v3(
r_cent, positions[loopstart[0].v], positions[loopstart[1].v], positions[loopstart[2].v]);
mid_v3_v3v3v3(r_cent,
vert_positions[loopstart[0].v],
vert_positions[loopstart[1].v],
vert_positions[loopstart[2].v]);
}
else if (mpoly->totloop == 4) {
mid_v3_v3v3v3v3(r_cent,
positions[loopstart[0].v],
positions[loopstart[1].v],
positions[loopstart[2].v],
positions[loopstart[3].v]);
vert_positions[loopstart[0].v],
vert_positions[loopstart[1].v],
vert_positions[loopstart[2].v],
vert_positions[loopstart[3].v]);
}
else {
mesh_calc_ngon_center(mpoly, loopstart, positions, r_cent);
mesh_calc_ngon_center(mpoly, loopstart, vert_positions, r_cent);
}
}
float BKE_mesh_calc_poly_area(const MPoly *mpoly,
const MLoop *loopstart,
const float (*positions)[3])
const float (*vert_positions)[3])
{
if (mpoly->totloop == 3) {
return area_tri_v3(
positions[loopstart[0].v], positions[loopstart[1].v], positions[loopstart[2].v]);
return area_tri_v3(vert_positions[loopstart[0].v],
vert_positions[loopstart[1].v],
vert_positions[loopstart[2].v]);
}
const MLoop *l_iter = loopstart;
@ -88,7 +91,7 @@ float BKE_mesh_calc_poly_area(const MPoly *mpoly,
/* pack vertex cos into an array for area_poly_v3 */
for (int i = 0; i < mpoly->totloop; i++, l_iter++) {
copy_v3_v3(vertexcos[i], positions[l_iter->v]);
copy_v3_v3(vertexcos[i], vert_positions[l_iter->v]);
}
/* finally calculate the area */
@ -234,7 +237,7 @@ static float mesh_calc_poly_area_centroid(const MPoly *mpoly,
void BKE_mesh_calc_poly_angles(const MPoly *mpoly,
const MLoop *loopstart,
const float (*positions)[3],
const float (*vert_positions)[3],
float angles[])
{
float nor_prev[3];
@ -243,11 +246,13 @@ void BKE_mesh_calc_poly_angles(const MPoly *mpoly,
int i_this = mpoly->totloop - 1;
int i_next = 0;
sub_v3_v3v3(nor_prev, positions[loopstart[i_this - 1].v], positions[loopstart[i_this].v]);
sub_v3_v3v3(
nor_prev, vert_positions[loopstart[i_this - 1].v], vert_positions[loopstart[i_this].v]);
normalize_v3(nor_prev);
while (i_next < mpoly->totloop) {
sub_v3_v3v3(nor_next, positions[loopstart[i_this].v], positions[loopstart[i_next].v]);
sub_v3_v3v3(
nor_next, vert_positions[loopstart[i_this].v], vert_positions[loopstart[i_next].v]);
normalize_v3(nor_next);
angles[i_this] = angle_normalized_v3v3(nor_prev, nor_next);

View File

@ -17,7 +17,7 @@
#include "BLI_edgehash.h"
#include "BLI_math.h"
#include "BLI_math_vec_types.hh"
#include "BLI_math_vector_types.hh"
#include "BLI_memarena.h"
#include "BLI_polyfill_2d.h"
#include "BLI_resource_scope.hh"

View File

@ -187,22 +187,24 @@ static void mesh_calc_ngon_normal(const MPoly *mpoly,
void BKE_mesh_calc_poly_normal(const MPoly *mpoly,
const MLoop *loopstart,
const float (*positions)[3],
const float (*vert_positions)[3],
float r_no[3])
{
if (mpoly->totloop > 4) {
mesh_calc_ngon_normal(mpoly, loopstart, positions, r_no);
mesh_calc_ngon_normal(mpoly, loopstart, vert_positions, r_no);
}
else if (mpoly->totloop == 3) {
normal_tri_v3(
r_no, positions[loopstart[0].v], positions[loopstart[1].v], positions[loopstart[2].v]);
normal_tri_v3(r_no,
vert_positions[loopstart[0].v],
vert_positions[loopstart[1].v],
vert_positions[loopstart[2].v]);
}
else if (mpoly->totloop == 4) {
normal_quad_v3(r_no,
positions[loopstart[0].v],
positions[loopstart[1].v],
positions[loopstart[2].v],
positions[loopstart[3].v]);
vert_positions[loopstart[0].v],
vert_positions[loopstart[1].v],
vert_positions[loopstart[2].v],
vert_positions[loopstart[3].v]);
}
else { /* horrible, two sided face! */
r_no[0] = 0.0;
@ -228,7 +230,7 @@ static void calculate_normals_poly(const Span<float3> positions,
});
}
void BKE_mesh_calc_normals_poly(const float (*positions)[3],
void BKE_mesh_calc_normals_poly(const float (*vert_positions)[3],
const int verts_num,
const MLoop *mloop,
const int mloop_len,
@ -236,7 +238,7 @@ void BKE_mesh_calc_normals_poly(const float (*positions)[3],
int mpoly_len,
float (*r_poly_normals)[3])
{
calculate_normals_poly({reinterpret_cast<const float3 *>(positions), verts_num},
calculate_normals_poly({reinterpret_cast<const float3 *>(vert_positions), verts_num},
{mpoly, mpoly_len},
{mloop, mloop_len},
{reinterpret_cast<float3 *>(r_poly_normals), mpoly_len});
@ -341,7 +343,7 @@ static void calculate_normals_poly_and_vert(const Span<float3> positions,
}
}
void BKE_mesh_calc_normals_poly_and_vertex(const float (*positions)[3],
void BKE_mesh_calc_normals_poly_and_vertex(const float (*vert_positions)[3],
const int mvert_len,
const MLoop *mloop,
const int mloop_len,
@ -350,7 +352,7 @@ void BKE_mesh_calc_normals_poly_and_vertex(const float (*positions)[3],
float (*r_poly_normals)[3],
float (*r_vert_normals)[3])
{
calculate_normals_poly_and_vert({reinterpret_cast<const float3 *>(positions), mvert_len},
calculate_normals_poly_and_vert({reinterpret_cast<const float3 *>(vert_positions), mvert_len},
{mpoly, mpoly_len},
{mloop, mloop_len},
{reinterpret_cast<float3 *>(r_poly_normals), mpoly_len},
@ -1440,7 +1442,7 @@ static void loop_split_generator(TaskPool *pool, LoopSplitTaskDataCommon *common
}
}
void BKE_mesh_normals_loop_split(const float (*positions)[3],
void BKE_mesh_normals_loop_split(const float (*vert_positions)[3],
const float (*vert_normals)[3],
const int numVerts,
const MEdge *medges,
@ -1542,7 +1544,7 @@ void BKE_mesh_normals_loop_split(const float (*positions)[3],
common_data.lnors_spacearr = r_lnors_spacearr;
common_data.loop_normals = {reinterpret_cast<float3 *>(r_loop_normals), numLoops};
common_data.clnors_data = {reinterpret_cast<short2 *>(clnors_data), clnors_data ? numLoops : 0};
common_data.positions = {reinterpret_cast<const float3 *>(positions), numVerts};
common_data.positions = {reinterpret_cast<const float3 *>(vert_positions), numVerts};
common_data.edges = {medges, numEdges};
common_data.polys = polys;
common_data.loops = loops;
@ -1847,7 +1849,7 @@ static void mesh_normals_loop_custom_set(const float (*positions)[3],
BKE_lnor_spacearr_free(&lnors_spacearr);
}
void BKE_mesh_normals_loop_custom_set(const float (*positions)[3],
void BKE_mesh_normals_loop_custom_set(const float (*vert_positions)[3],
const float (*vert_normals)[3],
const int numVerts,
MEdge *medges,
@ -1860,7 +1862,7 @@ void BKE_mesh_normals_loop_custom_set(const float (*positions)[3],
const int numPolys,
short (*r_clnors_data)[2])
{
mesh_normals_loop_custom_set(positions,
mesh_normals_loop_custom_set(vert_positions,
vert_normals,
numVerts,
medges,
@ -1875,7 +1877,7 @@ void BKE_mesh_normals_loop_custom_set(const float (*positions)[3],
false);
}
void BKE_mesh_normals_loop_custom_from_verts_set(const float (*positions)[3],
void BKE_mesh_normals_loop_custom_from_verts_set(const float (*vert_positions)[3],
const float (*vert_normals)[3],
float (*r_custom_vert_normals)[3],
const int numVerts,
@ -1888,7 +1890,7 @@ void BKE_mesh_normals_loop_custom_from_verts_set(const float (*positions)[3],
const int numPolys,
short (*r_clnors_data)[2])
{
mesh_normals_loop_custom_set(positions,
mesh_normals_loop_custom_set(vert_positions,
vert_normals,
numVerts,
medges,

View File

@ -408,14 +408,14 @@ int sample_surface_points_projected(
return point_count;
}
float3 compute_bary_coord_in_triangle(const Span<float3> positions,
float3 compute_bary_coord_in_triangle(const Span<float3> vert_positions,
const Span<MLoop> loops,
const MLoopTri &looptri,
const float3 &position)
{
const float3 &v0 = positions[loops[looptri.tri[0]].v];
const float3 &v1 = positions[loops[looptri.tri[1]].v];
const float3 &v2 = positions[loops[looptri.tri[2]].v];
const float3 &v0 = vert_positions[loops[looptri.tri[0]].v];
const float3 &v1 = vert_positions[loops[looptri.tri[1]].v];
const float3 &v2 = vert_positions[loops[looptri.tri[2]].v];
float3 bary_coords;
interp_weights_tri_v3(bary_coords, v0, v1, v2, position);
return bary_coords;

View File

@ -308,24 +308,24 @@ static void mesh_recalc_looptri__multi_threaded(const MLoop *mloop,
void BKE_mesh_recalc_looptri(const MLoop *mloop,
const MPoly *mpoly,
const float (*positions)[3],
const float (*vert_positions)[3],
int totloop,
int totpoly,
MLoopTri *mlooptri)
{
if (totloop < MESH_FACE_TESSELLATE_THREADED_LIMIT) {
mesh_recalc_looptri__single_threaded(
mloop, mpoly, positions, totloop, totpoly, mlooptri, nullptr);
mloop, mpoly, vert_positions, totloop, totpoly, mlooptri, nullptr);
}
else {
mesh_recalc_looptri__multi_threaded(
mloop, mpoly, positions, totloop, totpoly, mlooptri, nullptr);
mloop, mpoly, vert_positions, totloop, totpoly, mlooptri, nullptr);
}
}
void BKE_mesh_recalc_looptri_with_normals(const MLoop *mloop,
const MPoly *mpoly,
const float (*positions)[3],
const float (*vert_positions)[3],
int totloop,
int totpoly,
MLoopTri *mlooptri,
@ -334,11 +334,11 @@ void BKE_mesh_recalc_looptri_with_normals(const MLoop *mloop,
BLI_assert(poly_normals != nullptr);
if (totloop < MESH_FACE_TESSELLATE_THREADED_LIMIT) {
mesh_recalc_looptri__single_threaded(
mloop, mpoly, positions, totloop, totpoly, mlooptri, poly_normals);
mloop, mpoly, vert_positions, totloop, totpoly, mlooptri, poly_normals);
}
else {
mesh_recalc_looptri__multi_threaded(
mloop, mpoly, positions, totloop, totpoly, mlooptri, poly_normals);
mloop, mpoly, vert_positions, totloop, totpoly, mlooptri, poly_normals);
}
}

View File

@ -9,7 +9,7 @@
#pragma once
#include "BLI_math_vec_types.hh"
#include "BLI_math_vector_types.hh"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"

View File

@ -6,7 +6,7 @@
* \ingroup balembic
*/
#include "BLI_math_vec_types.hh"
#include "BLI_math_vector_types.hh"
#include <Alembic/Abc/All.h>
#include <Alembic/AbcGeom/All.h>

View File

@ -244,7 +244,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
sculpt_session->multires.level = mmd->sculptlvl;
sculpt_session->totvert = mesh->totvert;
sculpt_session->totpoly = mesh->totpoly;
sculpt_session->positions = nullptr;
sculpt_session->vert_positions = nullptr;
sculpt_session->mpoly = nullptr;
sculpt_session->mloop = nullptr;
}