Just the functional assimp lib rather than the entire assimp repository unnecessarily.

This commit is contained in:
Areloch 2019-02-28 16:37:15 -06:00
parent 0f7641a282
commit e9ea38eda3
1747 changed files with 9012 additions and 925008 deletions

View file

@ -3,8 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, assimp team
Copyright (c) 2006-2017, assimp team
All rights reserved.
@ -47,7 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// internal headers
#include "FixNormalsStep.h"
#include <assimp/StringUtils.h>
#include "StringUtils.h"
#include <assimp/DefaultLogger.hpp>
#include <assimp/postprocess.h>
#include <assimp/scene.h>
@ -82,35 +81,28 @@ bool FixInfacingNormalsProcess::IsActive( unsigned int pFlags) const
// Executes the post processing step on the given imported data.
void FixInfacingNormalsProcess::Execute( aiScene* pScene)
{
ASSIMP_LOG_DEBUG("FixInfacingNormalsProcess begin");
DefaultLogger::get()->debug("FixInfacingNormalsProcess begin");
bool bHas( false );
for (unsigned int a = 0; a < pScene->mNumMeshes; ++a) {
if (ProcessMesh(pScene->mMeshes[a], a)) {
bHas = true;
}
}
bool bHas = false;
for( unsigned int a = 0; a < pScene->mNumMeshes; a++)
if(ProcessMesh( pScene->mMeshes[a],a))bHas = true;
if (bHas) {
ASSIMP_LOG_DEBUG("FixInfacingNormalsProcess finished. Found issues.");
} else {
ASSIMP_LOG_DEBUG("FixInfacingNormalsProcess finished. No changes to the scene.");
}
if (bHas)
DefaultLogger::get()->debug("FixInfacingNormalsProcess finished. Found issues.");
else DefaultLogger::get()->debug("FixInfacingNormalsProcess finished. No changes to the scene.");
}
// ------------------------------------------------------------------------------------------------
// Apply the step to the mesh
bool FixInfacingNormalsProcess::ProcessMesh( aiMesh* pcMesh, unsigned int index)
{
ai_assert(nullptr != pcMesh);
ai_assert(NULL != pcMesh);
// Nothing to do if there are no model normals
if (!pcMesh->HasNormals()) {
return false;
}
if (!pcMesh->HasNormals())return false;
// Compute the bounding box of both the model vertices + normals and
// the unmodified model vertices. Then check whether the first BB
// the umodified model vertices. Then check whether the first BB
// is smaller than the second. In this case we can assume that the
// normals need to be flipped, although there are a few special cases ..
// convex, concave, planar models ...
@ -162,9 +154,14 @@ bool FixInfacingNormalsProcess::ProcessMesh( aiMesh* pcMesh, unsigned int index)
if (fDelta1_z < 0.05f * std::sqrt( fDelta1_y * fDelta1_x ))return false;
// now compare the volumes of the bounding boxes
if (std::fabs(fDelta0_x * fDelta0_y * fDelta0_z) < std::fabs(fDelta1_x * fDelta1_yz)) {
if (!DefaultLogger::isNullLogger()) {
ASSIMP_LOG_INFO_F("Mesh ", index, ": Normals are facing inwards (or the mesh is planar)", index);
if (std::fabs(fDelta0_x * fDelta0_y * fDelta0_z) <
std::fabs(fDelta1_x * fDelta1_yz))
{
if (!DefaultLogger::isNullLogger())
{
char buffer[128]; // should be sufficiently large
ai_snprintf(buffer,128,"Mesh %u: Normals are facing inwards (or the mesh is planar)",index);
DefaultLogger::get()->info(buffer);
}
// Invert normals