From b4a566c6b642d3623584a58fda4d5fb88c60bf78 Mon Sep 17 00:00:00 2001 From: Shon Ferguson <shonferg@users.sourceforge.net> Date: Sat, 30 Sep 2006 07:31:50 +0000 Subject: [PATCH] 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. --- src/obj/NiGeometry.cpp | 3 +++ src/obj/NiNode.cpp | 15 ++++++++++----- src/obj/NiTriShapeData.cpp | 10 +++++++++- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/obj/NiGeometry.cpp b/src/obj/NiGeometry.cpp index fd441e21..0b57bd8f 100644 --- a/src/obj/NiGeometry.cpp +++ b/src/obj/NiGeometry.cpp @@ -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."); diff --git a/src/obj/NiNode.cpp b/src/obj/NiNode.cpp index b20bbe5f..b6e5c052 100644 --- a/src/obj/NiNode.cpp +++ b/src/obj/NiNode.cpp @@ -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; diff --git a/src/obj/NiTriShapeData.cpp b/src/obj/NiTriShapeData.cpp index b8464bc5..5c572fb8 100644 --- a/src/obj/NiTriShapeData.cpp +++ b/src/obj/NiTriShapeData.cpp @@ -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 ) { -- GitLab