Added function to calculate the total area of a mesh.
This commit is contained in:
@@ -477,6 +477,7 @@ void BKE_mesh_calc_poly_center(const struct MPoly *mpoly,
|
|||||||
float BKE_mesh_calc_poly_area(const struct MPoly *mpoly,
|
float BKE_mesh_calc_poly_area(const struct MPoly *mpoly,
|
||||||
const struct MLoop *loopstart,
|
const struct MLoop *loopstart,
|
||||||
const struct MVert *mvarray);
|
const struct MVert *mvarray);
|
||||||
|
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);
|
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,
|
void BKE_mesh_calc_poly_angles(const struct MPoly *mpoly,
|
||||||
const struct MLoop *loopstart,
|
const struct MLoop *loopstart,
|
||||||
|
|||||||
@@ -2320,6 +2320,24 @@ float BKE_mesh_calc_poly_area(const MPoly *mpoly, const MLoop *loopstart, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float BKE_mesh_calc_area(const Mesh *me)
|
||||||
|
{
|
||||||
|
MVert *mvert = me->mvert;
|
||||||
|
MLoop *mloop = me->mloop;
|
||||||
|
MPoly *mpoly = me->mpoly;
|
||||||
|
|
||||||
|
MPoly *mp;
|
||||||
|
int i = me->totpoly;
|
||||||
|
float total_area = 0;
|
||||||
|
|
||||||
|
for (mp = mpoly; i--; mp++) {
|
||||||
|
MLoop *ml_start = &mloop[mp->loopstart];
|
||||||
|
|
||||||
|
total_area += BKE_mesh_calc_poly_area(mp, ml_start, mvert);
|
||||||
|
}
|
||||||
|
return total_area;
|
||||||
|
}
|
||||||
|
|
||||||
float BKE_mesh_calc_poly_uv_area(const MPoly *mpoly, const MLoopUV *uv_array)
|
float BKE_mesh_calc_poly_uv_area(const MPoly *mpoly, const MLoopUV *uv_array)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user