Blender: revert fix for suspicious crash in blender on windows.
parent
9e19b5103c
commit
0f2cea7ba6
|
@ -123,7 +123,7 @@ namespace Blender {
|
||||||
|
|
||||||
struct ObjectCompare {
|
struct ObjectCompare {
|
||||||
bool operator() (const Object* left, const Object* right) const {
|
bool operator() (const Object* left, const Object* right) const {
|
||||||
return ::strncmp(left->id.name, right->id.name, strlen( left->id.name ) ) == -1;
|
return ::strncmp(left->id.name, right->id.name, strlen( left->id.name ) ) == 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ namespace Blender {
|
||||||
|
|
||||||
struct ObjectCompare {
|
struct ObjectCompare {
|
||||||
bool operator() (const Object* left, const Object* right) const {
|
bool operator() (const Object* left, const Object* right) const {
|
||||||
return ::strncmp( left->id.name, right->id.name, strlen( left->id.name ) ) == -1;
|
return ::strncmp( left->id.name, right->id.name, strlen( left->id.name ) ) == 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -387,8 +387,7 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel,
|
||||||
const ObjFile::Object* pCurrentObject,
|
const ObjFile::Object* pCurrentObject,
|
||||||
unsigned int uiMeshIndex,
|
unsigned int uiMeshIndex,
|
||||||
aiMesh* pMesh,
|
aiMesh* pMesh,
|
||||||
unsigned int numIndices)
|
unsigned int numIndices) {
|
||||||
{
|
|
||||||
// Checking preconditions
|
// Checking preconditions
|
||||||
ai_assert( NULL != pCurrentObject );
|
ai_assert( NULL != pCurrentObject );
|
||||||
|
|
||||||
|
@ -398,8 +397,9 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel,
|
||||||
|
|
||||||
// Get current mesh
|
// Get current mesh
|
||||||
ObjFile::Mesh *pObjMesh = pModel->m_Meshes[ uiMeshIndex ];
|
ObjFile::Mesh *pObjMesh = pModel->m_Meshes[ uiMeshIndex ];
|
||||||
if ( NULL == pObjMesh || pObjMesh->m_uiNumIndices < 1)
|
if ( NULL == pObjMesh || pObjMesh->m_uiNumIndices < 1 ) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Copy vertices of this mesh instance
|
// Copy vertices of this mesh instance
|
||||||
pMesh->mNumVertices = numIndices;
|
pMesh->mNumVertices = numIndices;
|
||||||
|
@ -427,27 +427,25 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel,
|
||||||
|
|
||||||
// Copy vertices, normals and textures into aiMesh instance
|
// Copy vertices, normals and textures into aiMesh instance
|
||||||
unsigned int newIndex = 0, outIndex = 0;
|
unsigned int newIndex = 0, outIndex = 0;
|
||||||
for ( size_t index=0; index < pObjMesh->m_Faces.size(); index++ )
|
for ( size_t index=0; index < pObjMesh->m_Faces.size(); index++ ) {
|
||||||
{
|
|
||||||
// Get source face
|
// Get source face
|
||||||
ObjFile::Face *pSourceFace = pObjMesh->m_Faces[ index ];
|
ObjFile::Face *pSourceFace = pObjMesh->m_Faces[ index ];
|
||||||
|
|
||||||
// Copy all index arrays
|
// Copy all index arrays
|
||||||
for ( size_t vertexIndex = 0, outVertexIndex = 0; vertexIndex < pSourceFace->m_pVertices->size(); vertexIndex++ )
|
for ( size_t vertexIndex = 0, outVertexIndex = 0; vertexIndex < pSourceFace->m_pVertices->size(); vertexIndex++ ) {
|
||||||
{
|
|
||||||
const unsigned int vertex = pSourceFace->m_pVertices->at( vertexIndex );
|
const unsigned int vertex = pSourceFace->m_pVertices->at( vertexIndex );
|
||||||
if ( vertex >= pModel->m_Vertices.size() )
|
if ( vertex >= pModel->m_Vertices.size() ) {
|
||||||
throw DeadlyImportError( "OBJ: vertex index out of range" );
|
throw DeadlyImportError( "OBJ: vertex index out of range" );
|
||||||
|
}
|
||||||
|
|
||||||
pMesh->mVertices[ newIndex ] = pModel->m_Vertices[ vertex ];
|
pMesh->mVertices[ newIndex ] = pModel->m_Vertices[ vertex ];
|
||||||
|
|
||||||
// Copy all normals
|
// Copy all normals
|
||||||
if ( !pModel->m_Normals.empty() && vertexIndex < pSourceFace->m_pNormals->size())
|
if ( !pModel->m_Normals.empty() && vertexIndex < pSourceFace->m_pNormals->size()) {
|
||||||
{
|
|
||||||
const unsigned int normal = pSourceFace->m_pNormals->at( vertexIndex );
|
const unsigned int normal = pSourceFace->m_pNormals->at( vertexIndex );
|
||||||
if ( normal >= pModel->m_Normals.size() )
|
if ( normal >= pModel->m_Normals.size() ) {
|
||||||
throw DeadlyImportError("OBJ: vertex normal index out of range");
|
throw DeadlyImportError( "OBJ: vertex normal index out of range" );
|
||||||
|
}
|
||||||
pMesh->mNormals[ newIndex ] = pModel->m_Normals[ normal ];
|
pMesh->mNormals[ newIndex ] = pModel->m_Normals[ normal ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -544,20 +542,21 @@ void ObjFileImporter::countObjects(const std::vector<ObjFile::Object*> &rObjects
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Add clamp mode property to material if necessary
|
// Add clamp mode property to material if necessary
|
||||||
void ObjFileImporter::addTextureMappingModeProperty(aiMaterial* mat, aiTextureType type, int clampMode)
|
void ObjFileImporter::addTextureMappingModeProperty( aiMaterial* mat, aiTextureType type, int clampMode) {
|
||||||
{
|
if ( nullptr == mat ) {
|
||||||
ai_assert( NULL != mat);
|
return;
|
||||||
mat->AddProperty<int>(&clampMode, 1, AI_MATKEY_MAPPINGMODE_U(type, 0));
|
}
|
||||||
mat->AddProperty<int>(&clampMode, 1, AI_MATKEY_MAPPINGMODE_V(type, 0));
|
|
||||||
|
mat->AddProperty<int>( &clampMode, 1, AI_MATKEY_MAPPINGMODE_U( type, 0 ) );
|
||||||
|
mat->AddProperty<int>( &clampMode, 1, AI_MATKEY_MAPPINGMODE_V( type, 0 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Creates the material
|
// Creates the material
|
||||||
void ObjFileImporter::createMaterials(const ObjFile::Model* pModel, aiScene* pScene )
|
void ObjFileImporter::createMaterials(const ObjFile::Model* pModel, aiScene* pScene ) {
|
||||||
{
|
if ( NULL == pScene ) {
|
||||||
ai_assert( NULL != pScene );
|
|
||||||
if ( NULL == pScene )
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const unsigned int numMaterials = (unsigned int) pModel->m_MaterialLib.size();
|
const unsigned int numMaterials = (unsigned int) pModel->m_MaterialLib.size();
|
||||||
pScene->mNumMaterials = 0;
|
pScene->mNumMaterials = 0;
|
||||||
|
|
|
@ -37,8 +37,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef OBJ_FILE_IMPORTER_H_INC
|
#ifndef OBJ_FILE_IMPORTER_H_INC
|
||||||
#define OBJ_FILE_IMPORTER_H_INC
|
#define OBJ_FILE_IMPORTER_H_INC
|
||||||
|
|
||||||
|
@ -49,11 +47,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
struct aiMesh;
|
struct aiMesh;
|
||||||
struct aiNode;
|
struct aiNode;
|
||||||
|
|
||||||
namespace Assimp
|
namespace Assimp {
|
||||||
{
|
|
||||||
|
|
||||||
namespace ObjFile
|
namespace ObjFile {
|
||||||
{
|
|
||||||
struct Object;
|
struct Object;
|
||||||
struct Model;
|
struct Model;
|
||||||
}
|
}
|
||||||
|
@ -62,8 +58,7 @@ struct Model;
|
||||||
/// \class ObjFileImporter
|
/// \class ObjFileImporter
|
||||||
/// \brief Imports a waveform obj file
|
/// \brief Imports a waveform obj file
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
class ObjFileImporter : public BaseImporter
|
class ObjFileImporter : public BaseImporter {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
/// \brief Default constructor
|
/// \brief Default constructor
|
||||||
ObjFileImporter();
|
ObjFileImporter();
|
||||||
|
@ -77,7 +72,6 @@ public:
|
||||||
bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const;
|
bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! \brief Appends the supported extension.
|
//! \brief Appends the supported extension.
|
||||||
const aiImporterDesc* GetInfo () const;
|
const aiImporterDesc* GetInfo () const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue