|
@@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
#include "ProcessHelper.h"
|
|
|
#include "FindDegenerates.h"
|
|
|
+#include "Geometry/GeometryUtils.h"
|
|
|
|
|
|
#include <assimp/Exceptional.h>
|
|
|
|
|
@@ -63,10 +64,6 @@ FindDegeneratesProcess::FindDegeneratesProcess() :
|
|
|
// empty
|
|
|
}
|
|
|
|
|
|
-// ------------------------------------------------------------------------------------------------
|
|
|
-// Destructor, private as well
|
|
|
-FindDegeneratesProcess::~FindDegeneratesProcess() = default;
|
|
|
-
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
// Returns whether the processing step is present in the given flag field.
|
|
|
bool FindDegeneratesProcess::IsActive( unsigned int pFlags) const {
|
|
@@ -132,37 +129,6 @@ static void updateSceneGraph(aiNode* pNode, const std::unordered_map<unsigned in
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static ai_real heron( ai_real a, ai_real b, ai_real c ) {
|
|
|
- ai_real s = (a + b + c) / 2;
|
|
|
- ai_real area = pow((s * ( s - a ) * ( s - b ) * ( s - c ) ), (ai_real)0.5 );
|
|
|
- return area;
|
|
|
-}
|
|
|
-
|
|
|
-static ai_real distance3D( const aiVector3D &vA, aiVector3D &vB ) {
|
|
|
- const ai_real lx = ( vB.x - vA.x );
|
|
|
- const ai_real ly = ( vB.y - vA.y );
|
|
|
- const ai_real lz = ( vB.z - vA.z );
|
|
|
- ai_real a = lx*lx + ly*ly + lz*lz;
|
|
|
- ai_real d = pow( a, (ai_real)0.5 );
|
|
|
-
|
|
|
- return d;
|
|
|
-}
|
|
|
-
|
|
|
-static ai_real calculateAreaOfTriangle( const aiFace& face, aiMesh* mesh ) {
|
|
|
- ai_real area = 0;
|
|
|
-
|
|
|
- aiVector3D vA( mesh->mVertices[ face.mIndices[ 0 ] ] );
|
|
|
- aiVector3D vB( mesh->mVertices[ face.mIndices[ 1 ] ] );
|
|
|
- aiVector3D vC( mesh->mVertices[ face.mIndices[ 2 ] ] );
|
|
|
-
|
|
|
- ai_real a( distance3D( vA, vB ) );
|
|
|
- ai_real b( distance3D( vB, vC ) );
|
|
|
- ai_real c( distance3D( vC, vA ) );
|
|
|
- area = heron( a, b, c );
|
|
|
-
|
|
|
- return area;
|
|
|
-}
|
|
|
-
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
// Executes the post processing step on the given imported mesh
|
|
|
bool FindDegeneratesProcess::ExecuteOnMesh( aiMesh* mesh) {
|
|
@@ -218,7 +184,7 @@ bool FindDegeneratesProcess::ExecuteOnMesh( aiMesh* mesh) {
|
|
|
|
|
|
if ( mConfigCheckAreaOfTriangle ) {
|
|
|
if ( face.mNumIndices == 3 ) {
|
|
|
- ai_real area = calculateAreaOfTriangle( face, mesh );
|
|
|
+ ai_real area = GeometryUtils::calculateAreaOfTriangle( face, mesh );
|
|
|
if (area < ai_epsilon) {
|
|
|
if ( mConfigRemoveDegenerates ) {
|
|
|
remove_me[ a ] = true;
|