Refactoring: Make GeoUtils reusable
parent
fdcc45d010
commit
2acfc125c3
|
@ -218,6 +218,12 @@ SET( CApi_SRCS
|
||||||
)
|
)
|
||||||
SOURCE_GROUP(CApi FILES ${CApi_SRCS})
|
SOURCE_GROUP(CApi FILES ${CApi_SRCS})
|
||||||
|
|
||||||
|
SET(Geometry_SRCS
|
||||||
|
Geometry/GeometryUtils.h
|
||||||
|
Geometry/GeometryUtils.cpp
|
||||||
|
)
|
||||||
|
SOURCE_GROUP(Geometry FILES ${Geometry_SRCS})
|
||||||
|
|
||||||
SET( STEPParser_SRCS
|
SET( STEPParser_SRCS
|
||||||
AssetLib/STEPParser/STEPFileReader.h
|
AssetLib/STEPParser/STEPFileReader.h
|
||||||
AssetLib/STEPParser/STEPFileReader.cpp
|
AssetLib/STEPParser/STEPFileReader.cpp
|
||||||
|
@ -1129,6 +1135,7 @@ SET( assimp_src
|
||||||
${Core_SRCS}
|
${Core_SRCS}
|
||||||
${CApi_SRCS}
|
${CApi_SRCS}
|
||||||
${Common_SRCS}
|
${Common_SRCS}
|
||||||
|
${Geometry_SRCS}
|
||||||
${Logging_SRCS}
|
${Logging_SRCS}
|
||||||
${Exporter_SRCS}
|
${Exporter_SRCS}
|
||||||
${PostProcessing_SRCS}
|
${PostProcessing_SRCS}
|
||||||
|
|
|
@ -53,6 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
void mydummy() {}
|
void mydummy() {}
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
#include "GeometryUtils.h"
|
||||||
|
|
||||||
|
#include <assimp/vector3.h>
|
||||||
|
|
||||||
|
namespace Assimp {
|
||||||
|
|
||||||
|
ai_real GeometryUtils::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;
|
||||||
|
}
|
||||||
|
|
||||||
|
ai_real GeometryUtils::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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ai_real GeometryUtils::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;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Assimp
|
|
@ -0,0 +1,13 @@
|
||||||
|
#include <assimp/types.h>
|
||||||
|
#include <assimp/mesh.h>
|
||||||
|
|
||||||
|
namespace Assimp {
|
||||||
|
|
||||||
|
class GeometryUtils {
|
||||||
|
public:
|
||||||
|
static ai_real heron( ai_real a, ai_real b, ai_real c );
|
||||||
|
static ai_real distance3D( const aiVector3D &vA, aiVector3D &vB );
|
||||||
|
static ai_real calculateAreaOfTriangle( const aiFace& face, aiMesh* mesh );
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Assimp
|
|
@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "ProcessHelper.h"
|
#include "ProcessHelper.h"
|
||||||
#include "FindDegenerates.h"
|
#include "FindDegenerates.h"
|
||||||
|
#include "Geometry/GeometryUtils.h"
|
||||||
|
|
||||||
#include <assimp/Exceptional.h>
|
#include <assimp/Exceptional.h>
|
||||||
|
|
||||||
|
@ -63,10 +64,6 @@ FindDegeneratesProcess::FindDegeneratesProcess() :
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Destructor, private as well
|
|
||||||
FindDegeneratesProcess::~FindDegeneratesProcess() = default;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the processing step is present in the given flag field.
|
// Returns whether the processing step is present in the given flag field.
|
||||||
bool FindDegeneratesProcess::IsActive( unsigned int pFlags) const {
|
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
|
// Executes the post processing step on the given imported mesh
|
||||||
bool FindDegeneratesProcess::ExecuteOnMesh( aiMesh* mesh) {
|
bool FindDegeneratesProcess::ExecuteOnMesh( aiMesh* mesh) {
|
||||||
|
@ -218,7 +184,7 @@ bool FindDegeneratesProcess::ExecuteOnMesh( aiMesh* mesh) {
|
||||||
|
|
||||||
if ( mConfigCheckAreaOfTriangle ) {
|
if ( mConfigCheckAreaOfTriangle ) {
|
||||||
if ( face.mNumIndices == 3 ) {
|
if ( face.mNumIndices == 3 ) {
|
||||||
ai_real area = calculateAreaOfTriangle( face, mesh );
|
ai_real area = GeometryUtils::calculateAreaOfTriangle( face, mesh );
|
||||||
if (area < ai_epsilon) {
|
if (area < ai_epsilon) {
|
||||||
if ( mConfigRemoveDegenerates ) {
|
if ( mConfigRemoveDegenerates ) {
|
||||||
remove_me[ a ] = true;
|
remove_me[ a ] = true;
|
||||||
|
|
|
@ -59,7 +59,7 @@ namespace Assimp {
|
||||||
class ASSIMP_API FindDegeneratesProcess : public BaseProcess {
|
class ASSIMP_API FindDegeneratesProcess : public BaseProcess {
|
||||||
public:
|
public:
|
||||||
FindDegeneratesProcess();
|
FindDegeneratesProcess();
|
||||||
~FindDegeneratesProcess();
|
~FindDegeneratesProcess() = default;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Check whether step is active
|
// Check whether step is active
|
||||||
|
@ -105,23 +105,19 @@ private:
|
||||||
bool mConfigCheckAreaOfTriangle;
|
bool mConfigCheckAreaOfTriangle;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline
|
inline void FindDegeneratesProcess::EnableInstantRemoval(bool enabled) {
|
||||||
void FindDegeneratesProcess::EnableInstantRemoval(bool enabled) {
|
|
||||||
mConfigRemoveDegenerates = enabled;
|
mConfigRemoveDegenerates = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline bool FindDegeneratesProcess::IsInstantRemoval() const {
|
||||||
bool FindDegeneratesProcess::IsInstantRemoval() const {
|
|
||||||
return mConfigRemoveDegenerates;
|
return mConfigRemoveDegenerates;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline void FindDegeneratesProcess::EnableAreaCheck( bool enabled ) {
|
||||||
void FindDegeneratesProcess::EnableAreaCheck( bool enabled ) {
|
|
||||||
mConfigCheckAreaOfTriangle = enabled;
|
mConfigCheckAreaOfTriangle = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline bool FindDegeneratesProcess::isAreaCheckEnabled() const {
|
||||||
bool FindDegeneratesProcess::isAreaCheckEnabled() const {
|
|
||||||
return mConfigCheckAreaOfTriangle;
|
return mConfigCheckAreaOfTriangle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,10 +58,6 @@ FindInstancesProcess::FindInstancesProcess()
|
||||||
: configSpeedFlag (false)
|
: configSpeedFlag (false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Destructor, private as well
|
|
||||||
FindInstancesProcess::~FindInstancesProcess() = default;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the processing step is present in the given flag field.
|
// Returns whether the processing step is present in the given flag field.
|
||||||
bool FindInstancesProcess::IsActive( unsigned int pFlags) const
|
bool FindInstancesProcess::IsActive( unsigned int pFlags) const
|
||||||
|
|
|
@ -107,14 +107,11 @@ inline bool CompareArrays(const aiColor4D* first, const aiColor4D* second,
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** @brief A post-processing steps to search for instanced meshes
|
/** @brief A post-processing steps to search for instanced meshes
|
||||||
*/
|
*/
|
||||||
class FindInstancesProcess : public BaseProcess
|
class FindInstancesProcess : public BaseProcess {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FindInstancesProcess();
|
FindInstancesProcess();
|
||||||
~FindInstancesProcess();
|
~FindInstancesProcess() = default;
|
||||||
|
|
||||||
public:
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Check whether step is active in given flags combination
|
// Check whether step is active in given flags combination
|
||||||
bool IsActive( unsigned int pFlags) const;
|
bool IsActive( unsigned int pFlags) const;
|
||||||
|
@ -128,10 +125,9 @@ public:
|
||||||
void SetupProperties(const Importer* pImp);
|
void SetupProperties(const Importer* pImp);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool configSpeedFlag;
|
bool configSpeedFlag;
|
||||||
|
|
||||||
}; // ! end class FindInstancesProcess
|
}; // ! end class FindInstancesProcess
|
||||||
|
|
||||||
} // ! end namespace Assimp
|
} // ! end namespace Assimp
|
||||||
|
|
||||||
#endif // !! AI_FINDINSTANCES_H_INC
|
#endif // !! AI_FINDINSTANCES_H_INC
|
||||||
|
|
|
@ -60,10 +60,6 @@ FindInvalidDataProcess::FindInvalidDataProcess() :
|
||||||
// nothing to do here
|
// nothing to do here
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Destructor, private as well
|
|
||||||
FindInvalidDataProcess::~FindInvalidDataProcess() = default;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the processing step is present in the given flag field.
|
// Returns whether the processing step is present in the given flag field.
|
||||||
bool FindInvalidDataProcess::IsActive(unsigned int pFlags) const {
|
bool FindInvalidDataProcess::IsActive(unsigned int pFlags) const {
|
||||||
|
|
|
@ -65,7 +65,7 @@ namespace Assimp {
|
||||||
class ASSIMP_API FindInvalidDataProcess : public BaseProcess {
|
class ASSIMP_API FindInvalidDataProcess : public BaseProcess {
|
||||||
public:
|
public:
|
||||||
FindInvalidDataProcess();
|
FindInvalidDataProcess();
|
||||||
~FindInvalidDataProcess();
|
~FindInvalidDataProcess() = default;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
|
|
@ -56,26 +56,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Constructor to be privately used by Importer
|
|
||||||
FixInfacingNormalsProcess::FixInfacingNormalsProcess() = default;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Destructor, private as well
|
|
||||||
FixInfacingNormalsProcess::~FixInfacingNormalsProcess() = default;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the processing step is present in the given flag field.
|
// Returns whether the processing step is present in the given flag field.
|
||||||
bool FixInfacingNormalsProcess::IsActive( unsigned int pFlags) const
|
bool FixInfacingNormalsProcess::IsActive( unsigned int pFlags) const {
|
||||||
{
|
|
||||||
return (pFlags & aiProcess_FixInfacingNormals) != 0;
|
return (pFlags & aiProcess_FixInfacingNormals) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Executes the post processing step on the given imported data.
|
// Executes the post processing step on the given imported data.
|
||||||
void FixInfacingNormalsProcess::Execute( aiScene* pScene)
|
void FixInfacingNormalsProcess::Execute( aiScene* pScene) {
|
||||||
{
|
|
||||||
ASSIMP_LOG_DEBUG("FixInfacingNormalsProcess begin");
|
ASSIMP_LOG_DEBUG("FixInfacingNormalsProcess begin");
|
||||||
|
|
||||||
bool bHas( false );
|
bool bHas( false );
|
||||||
|
|
|
@ -49,8 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
struct aiMesh;
|
struct aiMesh;
|
||||||
|
|
||||||
namespace Assimp
|
namespace Assimp {
|
||||||
{
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** The FixInfacingNormalsProcess tries to determine whether the normal
|
/** The FixInfacingNormalsProcess tries to determine whether the normal
|
||||||
|
@ -59,8 +58,8 @@ namespace Assimp
|
||||||
*/
|
*/
|
||||||
class FixInfacingNormalsProcess : public BaseProcess {
|
class FixInfacingNormalsProcess : public BaseProcess {
|
||||||
public:
|
public:
|
||||||
FixInfacingNormalsProcess();
|
FixInfacingNormalsProcess() = default;
|
||||||
~FixInfacingNormalsProcess();
|
~FixInfacingNormalsProcess() = default;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Returns whether the processing step is present in the given flag field.
|
/** Returns whether the processing step is present in the given flag field.
|
||||||
|
|
|
@ -48,10 +48,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
||||||
GenBoundingBoxesProcess::GenBoundingBoxesProcess() = default;
|
|
||||||
|
|
||||||
GenBoundingBoxesProcess::~GenBoundingBoxesProcess() = default;
|
|
||||||
|
|
||||||
bool GenBoundingBoxesProcess::IsActive(unsigned int pFlags) const {
|
bool GenBoundingBoxesProcess::IsActive(unsigned int pFlags) const {
|
||||||
return 0 != ( pFlags & aiProcess_GenBoundingBoxes );
|
return 0 != ( pFlags & aiProcess_GenBoundingBoxes );
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ conditions are met:
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer in the documentation and/or other
|
following disclaimer in the documentation and/or other
|
||||||
materials provided with the distribution.
|
materials provided with the distribution.
|
||||||
|
s
|
||||||
* Neither the name of the assimp team, nor the names of its
|
* Neither the name of the assimp team, nor the names of its
|
||||||
contributors may be used to endorse or promote products
|
contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior
|
derived from this software without specific prior
|
||||||
|
@ -54,15 +54,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
||||||
/** Post-processing process to find axis-aligned bounding volumes for amm meshes
|
/**
|
||||||
* used in a scene
|
* @brief Post-processing process to find axis-aligned bounding volumes for amm meshes
|
||||||
|
* used in a scene.
|
||||||
*/
|
*/
|
||||||
class ASSIMP_API GenBoundingBoxesProcess : public BaseProcess {
|
class ASSIMP_API GenBoundingBoxesProcess : public BaseProcess {
|
||||||
public:
|
public:
|
||||||
/// The class constructor.
|
/// The class constructor.
|
||||||
GenBoundingBoxesProcess();
|
GenBoundingBoxesProcess() = default;
|
||||||
/// The class destructor.
|
/// The class destructor.
|
||||||
~GenBoundingBoxesProcess();
|
~GenBoundingBoxesProcess() = default;
|
||||||
/// Will return true, if aiProcess_GenBoundingBoxes is defined.
|
/// Will return true, if aiProcess_GenBoundingBoxes is defined.
|
||||||
bool IsActive(unsigned int pFlags) const override;
|
bool IsActive(unsigned int pFlags) const override;
|
||||||
/// The execution callback.
|
/// The execution callback.
|
||||||
|
|
|
@ -54,14 +54,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Constructor to be privately used by Importer
|
|
||||||
GenFaceNormalsProcess::GenFaceNormalsProcess() = default;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Destructor, private as well
|
|
||||||
GenFaceNormalsProcess::~GenFaceNormalsProcess() = default;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the processing step is present in the given flag field.
|
// Returns whether the processing step is present in the given flag field.
|
||||||
bool GenFaceNormalsProcess::IsActive(unsigned int pFlags) const {
|
bool GenFaceNormalsProcess::IsActive(unsigned int pFlags) const {
|
||||||
|
|
|
@ -47,20 +47,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "Common/BaseProcess.h"
|
#include "Common/BaseProcess.h"
|
||||||
#include <assimp/mesh.h>
|
#include <assimp/mesh.h>
|
||||||
|
|
||||||
namespace Assimp
|
namespace Assimp {
|
||||||
{
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** The GenFaceNormalsProcess computes face normals for all faces of all meshes
|
/**
|
||||||
*/
|
* @brief The GenFaceNormalsProcess computes face normals for all faces of all meshes
|
||||||
class ASSIMP_API_WINONLY GenFaceNormalsProcess : public BaseProcess
|
*/
|
||||||
{
|
class ASSIMP_API_WINONLY GenFaceNormalsProcess : public BaseProcess {
|
||||||
public:
|
public:
|
||||||
|
GenFaceNormalsProcess() = default;
|
||||||
|
~GenFaceNormalsProcess() = default;
|
||||||
|
|
||||||
GenFaceNormalsProcess();
|
|
||||||
~GenFaceNormalsProcess();
|
|
||||||
|
|
||||||
public:
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Returns whether the processing step is present in the given flag field.
|
/** Returns whether the processing step is present in the given flag field.
|
||||||
* @param pFlags The processing flags the importer was called with. A bitwise
|
* @param pFlags The processing flags the importer was called with. A bitwise
|
||||||
|
|
|
@ -60,10 +60,6 @@ GenVertexNormalsProcess::GenVertexNormalsProcess() :
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
// Destructor, private as well
|
|
||||||
GenVertexNormalsProcess::~GenVertexNormalsProcess() = default;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the processing step is present in the given flag field.
|
// Returns whether the processing step is present in the given flag field.
|
||||||
bool GenVertexNormalsProcess::IsActive(unsigned int pFlags) const {
|
bool GenVertexNormalsProcess::IsActive(unsigned int pFlags) const {
|
||||||
|
@ -109,10 +105,10 @@ void GenVertexNormalsProcess::Execute(aiScene *pScene) {
|
||||||
// Executes the post processing step on the given imported data.
|
// Executes the post processing step on the given imported data.
|
||||||
bool GenVertexNormalsProcess::GenMeshVertexNormals(aiMesh *pMesh, unsigned int meshIndex) {
|
bool GenVertexNormalsProcess::GenMeshVertexNormals(aiMesh *pMesh, unsigned int meshIndex) {
|
||||||
if (nullptr != pMesh->mNormals) {
|
if (nullptr != pMesh->mNormals) {
|
||||||
if (force_)
|
if (!force_) {
|
||||||
delete[] pMesh->mNormals;
|
|
||||||
else
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
delete[] pMesh->mNormals;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the mesh consists of lines and/or points but not of
|
// If the mesh consists of lines and/or points but not of
|
||||||
|
@ -144,8 +140,9 @@ bool GenVertexNormalsProcess::GenMeshVertexNormals(aiMesh *pMesh, unsigned int m
|
||||||
const aiVector3D *pV3 = &pMesh->mVertices[face.mIndices[face.mNumIndices - 1]];
|
const aiVector3D *pV3 = &pMesh->mVertices[face.mIndices[face.mNumIndices - 1]];
|
||||||
// Boolean XOR - if either but not both of these flags is set, then the winding order has
|
// Boolean XOR - if either but not both of these flags is set, then the winding order has
|
||||||
// changed and the cross product to calculate the normal needs to be reversed
|
// changed and the cross product to calculate the normal needs to be reversed
|
||||||
if (flippedWindingOrder_ != leftHanded_)
|
if (flippedWindingOrder_ != leftHanded_) {
|
||||||
std::swap(pV2, pV3);
|
std::swap(pV2, pV3);
|
||||||
|
}
|
||||||
const aiVector3D vNor = ((*pV2 - *pV1) ^ (*pV3 - *pV1)).NormalizeSafe();
|
const aiVector3D vNor = ((*pV2 - *pV1) ^ (*pV3 - *pV1)).NormalizeSafe();
|
||||||
|
|
||||||
for (unsigned int i = 0; i < face.mNumIndices; ++i) {
|
for (unsigned int i = 0; i < face.mNumIndices; ++i) {
|
||||||
|
|
|
@ -61,7 +61,7 @@ namespace Assimp {
|
||||||
class ASSIMP_API GenVertexNormalsProcess : public BaseProcess {
|
class ASSIMP_API GenVertexNormalsProcess : public BaseProcess {
|
||||||
public:
|
public:
|
||||||
GenVertexNormalsProcess();
|
GenVertexNormalsProcess();
|
||||||
~GenVertexNormalsProcess();
|
~GenVertexNormalsProcess() = default;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Returns whether the processing step is present in the given flag.
|
/** Returns whether the processing step is present in the given flag.
|
||||||
|
|
Loading…
Reference in New Issue