Page MenuHome
Paste P2703

(An Untitled Masterwork)
ActivePublic

Authored by Charlie Jolly (charlie) on Jan 7 2022, 2:58 AM.
auto angle_fn = [edge_map, polys, loops, mesh](const int i) -> float {
if (edge_map[i].face_count == 2) {
const MPoly &mpoly_1 = polys[edge_map[i].face_index_1];
const MPoly &mpoly_2 = polys[edge_map[i].face_index_2];
float3 normal_1, normal_2;
BKE_mesh_calc_poly_normal(&mpoly_1, &loops[mpoly_1.loopstart], mesh->mvert, normal_1);
BKE_mesh_calc_poly_normal(&mpoly_2, &loops[mpoly_2.loopstart], mesh->mvert, normal_2);
float3 point_1, point_2;
const MLoop *loopstart1 = &loops[mpoly_1.loopstart];
const MLoop *loopstart2 = &loops[mpoly_2.loopstart];
point_1 = mesh->mvert[loopstart1[0].v].co;
point_2 = mesh->mvert[loopstart2[0].v].co;
float edge_dot = float3::dot(normal_2 - normal_1, point_2 - point_1);
/* https://blender.stackexchange.com/questions/146819/is-there-a-way-to-calculate-mean-curvature-of-a-triangular-mesh/147371#147371
float curvature = safe_divide(edge_dot, float3(point_2 - point_1).length_squared());
return curvature; */
float angle = angle_normalized_v3v3(normal_2, normal_1);
return angle * signf(edge_dot);
}
else {
return 0.0f;
}
};

Event Timeline

I got this far but I think the edge points are needed and I don't think I'm accessing them properly.