Notifications
Clear all
[Closed] Need help finishing / debugging script
Page 4 / 4
Prev
Jan 31, 2014 1:42 pm
as i’ve expected the getfacenormal method returns normalized value. so ONLY EXACTLY ZERO area face has zero length normal. so using the getfacenormal method can’t be used to find ‘almost’ zero area faces.
the meshop.getfacearea method is universal for index, face, bitarray, #all, and #selection argument type, and it’s slow because of that.
the kinda single-face get-area function for nodes that can be converted to mesh and trimesh objects could look like:
def_visible_primitive(getMeshFaceArea, "getMeshFaceArea");
Value* getMeshFaceArea_cf(Value** arg_list, int count)
{
check_arg_count(getMeshFaceArea, 2, count);
int faceIndex = arg_list[1]->to_int()-1;
if (is_node(arg_list[0]))
{
INode* node = arg_list[0]->to_node();
Object* obj = Get_Object_Or_XRef_BaseObject(node->GetObjectRef());
if (obj->ClassID() == Class_ID(EDITTRIOBJ_CLASS_ID, 0))
{
TriObject *tri = dynamic_cast<TriObject *>(obj);
if(tri)
{
Mesh &mesh = tri->GetMesh();
float area = Length(mesh.FaceNormal(faceIndex));
return Float::intern(area/2.0f);
}
}
return &undefined;
}
if (is_mesh(arg_list[0]))
{
Mesh* mesh = arg_list[0]->to_mesh();
float area = Length(mesh->FaceNormal(faceIndex));
return Float::intern(area/2.0f);
}
return &undefined;
}
(i don’t check a valid index and some other things). but of course this function is very fast…
Page 4 / 4
Prev