Hi;
In this sample I cant get the normal on mesh face, now I’m try to get the normal at mesh vertex but always failed.
static bool meshclosetpoint(ON_Mesh* m_mesh, ON_3dPoint po, ON_3dVector& nor, ON_3dPoint& poi_cl)
{
bool rc=false;
ON_MESH_POINT point;
ON_3dVector normal = ON_UNSET_POINT;
m_mesh->GetClosestPoint(po, &point);
poi_cl = point.m_P;
if (point.m_ci.m_type == ON_COMPONENT_INDEX::mesh_face || point.m_ci.m_type == ON_COMPONENT_INDEX::meshtop_edge)
{
if (0 != point.m_mesh && 0 <= point.m_ci.m_index && point.m_ci.m_index < point.m_mesh->FaceCount())
{
if (point.m_mesh->HasFaceNormals())
normal = point.m_mesh->m_FN[point.m_ci.m_index];
else
{
if (point.m_mesh->HasDoublePrecisionVertices())
point.m_mesh->m_F[point.m_ci.m_index].ComputeFaceNormal(point.m_mesh->DoublePrecisionVertices().Array(), normal);
else
point.m_mesh->m_F[point.m_ci.m_index].ComputeFaceNormal(point.m_mesh->m_V.Array(), normal);
}
if (normal.IsValid())
{
nor = normal;
rc=true;
}
}
else //not work
{
ON_Mesh dupe_mesh( *point.m_mesh );
dupe_mesh.ComputeVertexNormals();
nor = dupe_mesh.m_N[point.m_ci.m_index];
rc=true;
}
}
return rc;
};
How cant I solve it?