closes assimp/assimp/issues/899: fix parsing of texture name.

pull/1109/head
Kim Kulling 2016-12-12 21:22:03 +01:00
parent d5e399cbf8
commit 859d15d3a0
6 changed files with 3674 additions and 2 deletions

View File

@ -1020,7 +1020,7 @@ void SMDImporter::ParseTriangle(const char* szCurrent,
// read the texture file name // read the texture file name
const char* szLast = szCurrent; const char* szLast = szCurrent;
while (!IsSpaceOrNewLine(*szCurrent++)); while (!IsSpaceOrNewLine(*++szCurrent));
// ... and get the index that belongs to this file name // ... and get the index that belongs to this file name
face.iTexture = GetTextureIndex(std::string(szLast,(uintptr_t)szCurrent-(uintptr_t)szLast)); face.iTexture = GetTextureIndex(std::string(szLast,(uintptr_t)szCurrent-(uintptr_t)szLast));

View File

@ -171,7 +171,7 @@ struct Bone
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/** Used to load Half-life 1 and 2 SMD models /** Used to load Half-life 1 and 2 SMD models
*/ */
class SMDImporter : public BaseImporter class ASSIMP_API SMDImporter : public BaseImporter
{ {
public: public:
SMDImporter(); SMDImporter();

View File

@ -96,6 +96,7 @@ SET( TEST_SRCS
unit/utScenePreprocessor.cpp unit/utScenePreprocessor.cpp
unit/utSharedPPData.cpp unit/utSharedPPData.cpp
unit/utStringUtils.cpp unit/utStringUtils.cpp
unit/utSMLImiportExport.cpp
unit/utSortByPType.cpp unit/utSortByPType.cpp
unit/utSplitLargeMeshes.cpp unit/utSplitLargeMeshes.cpp
unit/utTargetAnimation.cpp unit/utTargetAnimation.cpp

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 512 KiB

View File

@ -0,0 +1,77 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2016, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include "SMDLoader.h"
#include <assimp/Importer.hpp>
#include "AbstractImportExportBase.h"
using namespace ::Assimp;
class utSMDImporter : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/SMD/triangle.smd", 0 );
return nullptr != scene;
}
};
TEST_F( utSMDImporter, createTest ) {
bool ok( true );
try {
SMDImporter myImporter;
}
catch ( ... ) {
ok = false;
}
EXPECT_TRUE( ok );
}
TEST_F( utSMDImporter, importTest ) {
EXPECT_TRUE( importerTest() );
}
TEST_F( utSMDImporter, issue_899_Texture_garbage_at_end_of_string_Test ) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/SMD/holy_grailref.smd", 0 );
EXPECT_NE( nullptr, scene );
}