Skip to content
Snippets Groups Projects
Commit b4a566c6 authored by Shon Ferguson's avatar Shon Ferguson
Browse files

NiGeometry::BindSkin now throws an exception if one of the passed in bone references is NULL.

NiNode::IsSplitMeshProxy now returns false if it is a skin influence.
NiTriShapeData::GetTriangles now only returns valid triangles.
parent bc2dda6f
No related branches found
No related tags found
No related merge requests found
......@@ -99,6 +99,9 @@ void NiGeometry::BindSkin( vector< Ref<NiNode> > bone_nodes ) {
ancestors[bone_nodes.size()] = ListAncestors( GetParent() );
for ( unsigned int i = 0; i < bone_nodes.size(); ++i ) {
if ( bone_nodes[i] == NULL ) {
throw runtime_error("Attempted to bind skin to a NULL bone reference.");
}
NiNodeRef bonePar = bone_nodes[i]->GetParent();
if ( bonePar == NULL ) {
throw runtime_error("Attempted to bind skin to a bone with no parent. A skeleton root cannot be a bone so all bones must have at least one parent.");
......
......@@ -227,11 +227,16 @@ void NiNode::PropagateTransform() {
bool NiNode::IsSplitMeshProxy() const {
//Let us guess that a node is a split mesh proxy if:
// 1) All its children are NiTriBasedGeom derived objects.
// 2) All its children have identity transforms.
// 3) It has more than one child
// 4) All meshes are visible
// 5) ???? May need more criteria as time goes on.
// 1) It is not a skin influence
// 2) All its children are NiTriBasedGeom derived objects.
// 3) All its children have identity transforms.
// 4) It has more than one child
// 5) All meshes are visible
// 6) ???? May need more criteria as time goes on.
if ( this->IsSkinInfluence() ) {
return false;
}
if ( children.size() < 2 ) {
return false;
......
......@@ -66,7 +66,15 @@ bool NiTriShapeData::HasMatchData() {
}
vector<Triangle> NiTriShapeData::GetTriangles() const {
return triangles;
//Remove any bad triangles
vector<Triangle> good_triangles;
for ( unsigned i = 0; i < triangles.size(); ++i ) {
const Triangle & t = triangles[i];
if ( t.v1 != t.v2 && t.v2 != t.v3 && t.v1 != t.v3 ) {
good_triangles.push_back(t);
}
}
return good_triangles;
}
void NiTriShapeData::SetTriangles( const vector<Triangle> & in ) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment