Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/mesh_evaluate.cc
| Show First 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | float BKE_mesh_calc_area(const Mesh *me) | ||||
| float total_area = 0.0f; | float total_area = 0.0f; | ||||
| for (const MPoly &poly : polys) { | for (const MPoly &poly : polys) { | ||||
| total_area += BKE_mesh_calc_poly_area( | total_area += BKE_mesh_calc_poly_area( | ||||
| &poly, &loops[poly.loopstart], reinterpret_cast<const float(*)[3]>(positions.data())); | &poly, &loops[poly.loopstart], reinterpret_cast<const float(*)[3]>(positions.data())); | ||||
| } | } | ||||
| return total_area; | return total_area; | ||||
| } | } | ||||
| float BKE_mesh_calc_poly_uv_area(const MPoly *mpoly, const MLoopUV *uv_array) | |||||
| { | |||||
| int i, l_iter = mpoly->loopstart; | |||||
| float area; | |||||
| float(*vertexcos)[2] = (float(*)[2])BLI_array_alloca(vertexcos, size_t(mpoly->totloop)); | |||||
| /* pack vertex cos into an array for area_poly_v2 */ | |||||
| for (i = 0; i < mpoly->totloop; i++, l_iter++) { | |||||
| copy_v2_v2(vertexcos[i], uv_array[l_iter].uv); | |||||
| } | |||||
| /* finally calculate the area */ | |||||
| area = area_poly_v2(vertexcos, uint(mpoly->totloop)); | |||||
| return area; | |||||
| } | |||||
| static float UNUSED_FUNCTION(mesh_calc_poly_volume_centroid)(const MPoly *mpoly, | static float UNUSED_FUNCTION(mesh_calc_poly_volume_centroid)(const MPoly *mpoly, | ||||
HooglyBoogly: This whole loop can be removed, now we can just call `area_poly_v2` directly :D | |||||
Done Inline Actionsduh ! That's what you get robotically replacing MLoopUVs ;-) Baardaap: duh ! That's what you get robotically replacing MLoopUVs ;-) | |||||
Done Inline ActionsShouldn't you only take a slice of the uv array though? I'd expect area_poly_v2(&uv_array[mpoly->loopstart], mpoly->totloop); HooglyBoogly: Shouldn't you only take a slice of the uv array though? I'd expect `area_poly_v2(&uv_array… | |||||
Done Inline Actionswhoops! Baardaap: whoops! | |||||
| const MLoop *loopstart, | const MLoop *loopstart, | ||||
| const float (*positions)[3], | const float (*positions)[3], | ||||
| float r_cent[3]) | float r_cent[3]) | ||||
| { | { | ||||
| const float *v_pivot, *v_step1; | const float *v_pivot, *v_step1; | ||||
| float total_volume = 0.0f; | float total_volume = 0.0f; | ||||
| zero_v3(r_cent); | zero_v3(r_cent); | ||||
| ▲ Show 20 Lines • Show All 724 Lines • Show Last 20 Lines | |||||
This whole loop can be removed, now we can just call area_poly_v2 directly :D