Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/assimp/assimp
Browse files Browse the repository at this point in the history
  • Loading branch information
kimkulling committed Nov 14, 2016
2 parents 855031d + 302b804 commit a1f773c
Show file tree
Hide file tree
Showing 64 changed files with 1,178 additions and 599 deletions.
2 changes: 1 addition & 1 deletion .travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if [ $ANDROID ]; then
ant -v -Dmy.dir=${TRAVIS_BUILD_DIR} -f ${TRAVIS_BUILD_DIR}/port/jassimp/build.xml ndk-jni
else
generate \
&& make \
&& make -j4 \
&& sudo make install \
&& sudo ldconfig \
&& (cd test/unit; ../../bin/unit) \
Expand Down
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ ELSE (ASSIMP_BUILD_NONFREE_C4D_IMPORTER)
ADD_DEFINITIONS( -DASSIMP_BUILD_NO_C4D_IMPORTER )
ENDIF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER)


ADD_SUBDIRECTORY( code/ )
IF ( ASSIMP_BUILD_ASSIMP_TOOLS )
IF ( WIN32 )
Expand Down
2 changes: 2 additions & 0 deletions code/3DSExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "3DSExporter.h"
#include "3DSLoader.h"
#include "3DSHelper.h"
#include "SceneCombiner.h"
#include "SplitLargeMeshes.h"
#include "StringComparison.h"
Expand All @@ -54,6 +55,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

using namespace Assimp;
namespace Assimp {
using namespace D3DS;

namespace {

Expand Down
15 changes: 7 additions & 8 deletions code/3DSHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,14 +369,13 @@ struct Material
{
//! Default constructor. Builds a default name for the material
Material()
:
mDiffuse (0.6,0.6,0.6), // FIX ... we won't want object to be black
mSpecularExponent (0.0),
mShininessStrength (1.0),
mShading(Discreet3DS::Gouraud),
mTransparency (1.0),
mBumpHeight (1.0),
mTwoSided (false)
: mDiffuse ( ai_real( 0.6 ), ai_real( 0.6 ), ai_real( 0.6 ) ) // FIX ... we won't want object to be black
, mSpecularExponent ( ai_real( 0.0 ) )
, mShininessStrength ( ai_real( 1.0 ) )
, mShading(Discreet3DS::Gouraud)
, mTransparency ( ai_real( 1.0 ) )
, mBumpHeight ( ai_real( 1.0 ) )
, mTwoSided (false)
{
static int iCnt = 0;

Expand Down
63 changes: 34 additions & 29 deletions code/3DSLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1166,14 +1166,15 @@ void Discreet3DSImporter::ParseMaterialChunk()

case Discreet3DS::CHUNK_MAT_TRANSPARENCY:
{
// This is the material's transparency
ai_real* pcf = &mScene->mMaterials.back().mTransparency;
*pcf = ParsePercentageChunk();

// NOTE: transparency, not opacity
if (is_qnan(*pcf))
*pcf = 1.0;
else *pcf = 1.0 - *pcf * (ai_real)0xFFFF / 100.0;
// This is the material's transparency
ai_real* pcf = &mScene->mMaterials.back().mTransparency;
*pcf = ParsePercentageChunk();

// NOTE: transparency, not opacity
if (is_qnan(*pcf))
*pcf = ai_real( 1.0 );
else
*pcf = ai_real( 1.0 ) - *pcf * (ai_real)0xFFFF / ai_real( 100.0 );
}
break;

Expand All @@ -1199,21 +1200,23 @@ void Discreet3DSImporter::ParseMaterialChunk()

case Discreet3DS::CHUNK_MAT_SHININESS_PERCENT:
{ // This is the shininess strength of the material
ai_real* pcf = &mScene->mMaterials.back().mShininessStrength;
*pcf = ParsePercentageChunk();
if (is_qnan(*pcf))
*pcf = 0.0;
else *pcf *= (ai_real)0xffff / 100.0;
ai_real* pcf = &mScene->mMaterials.back().mShininessStrength;
*pcf = ParsePercentageChunk();
if (is_qnan(*pcf))
*pcf = ai_real( 0.0 );
else
*pcf *= (ai_real)0xffff / ai_real( 100.0 );
}
break;

case Discreet3DS::CHUNK_MAT_SELF_ILPCT:
{ // This is the self illumination strength of the material
ai_real f = ParsePercentageChunk();
if (is_qnan(f))
f = 0.0;
else f *= (ai_real)0xFFFF / 100.0;
mScene->mMaterials.back().mEmissive = aiColor3D(f,f,f);
ai_real f = ParsePercentageChunk();
if (is_qnan(f))
f = ai_real( 0.0 );
else
f *= (ai_real)0xFFFF / ai_real( 100.0 );
mScene->mMaterials.back().mEmissive = aiColor3D(f,f,f);
}
break;

Expand Down Expand Up @@ -1272,7 +1275,7 @@ void Discreet3DSImporter::ParseTextureChunk(D3DS::Texture* pcOut)

case Discreet3DS::CHUNK_PERCENTD:
// Manually parse the blend factor
pcOut->mTextureBlend = stream->GetF8();
pcOut->mTextureBlend = ai_real( stream->GetF8() );
break;

case Discreet3DS::CHUNK_PERCENTF:
Expand All @@ -1282,7 +1285,7 @@ void Discreet3DSImporter::ParseTextureChunk(D3DS::Texture* pcOut)

case Discreet3DS::CHUNK_PERCENTW:
// Manually parse the blend factor
pcOut->mTextureBlend = (ai_real)((uint16_t)stream->GetI2()) / 100.0;
pcOut->mTextureBlend = (ai_real)((uint16_t)stream->GetI2()) / ai_real( 100.0 );
break;

case Discreet3DS::CHUNK_MAT_MAP_USCALE:
Expand Down Expand Up @@ -1355,8 +1358,7 @@ ai_real Discreet3DSImporter::ParsePercentageChunk()

// ------------------------------------------------------------------------------------------------
// Read a color chunk. If a percentage chunk is found instead it is read as a grayscale color
void Discreet3DSImporter::ParseColorChunk(aiColor3D* out,
bool acceptPercent)
void Discreet3DSImporter::ParseColorChunk( aiColor3D* out, bool acceptPercent )
{
ai_assert(out != NULL);

Expand Down Expand Up @@ -1389,13 +1391,16 @@ void Discreet3DSImporter::ParseColorChunk(aiColor3D* out,
case Discreet3DS::CHUNK_LINRGBB:
bGamma = true;
case Discreet3DS::CHUNK_RGBB:
if (sizeof(char) * 3 > diff) {
*out = clrError;
return;
{
if ( sizeof( char ) * 3 > diff ) {
*out = clrError;
return;
}
const ai_real invVal = ai_real( 1.0 ) / ai_real( 255.0 );
out->r = ( ai_real ) ( uint8_t ) stream->GetI1() * invVal;
out->g = ( ai_real ) ( uint8_t ) stream->GetI1() * invVal;
out->b = ( ai_real ) ( uint8_t ) stream->GetI1() * invVal;
}
out->r = (ai_real)(uint8_t)stream->GetI1() / 255.0;
out->g = (ai_real)(uint8_t)stream->GetI1() / 255.0;
out->b = (ai_real)(uint8_t)stream->GetI1() / 255.0;
break;

// Percentage chunks are accepted, too.
Expand All @@ -1409,7 +1414,7 @@ void Discreet3DSImporter::ParseColorChunk(aiColor3D* out,

case Discreet3DS::CHUNK_PERCENTW:
if (acceptPercent && 1 <= diff) {
out->g = out->b = out->r = (ai_real)(uint8_t)stream->GetI1() / 255.0;
out->g = out->b = out->r = (ai_real)(uint8_t)stream->GetI1() / ai_real( 255.0 );
break;
}
*out = clrError;
Expand Down
2 changes: 1 addition & 1 deletion code/AMFImporter_Postprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ std::string TextureConverted_ID;
// check that all textures has same size
if(src_texture_4check.size() > 1)
{
for(uint8_t i = 0, i_e = (src_texture_4check.size() - 1); i < i_e; i++)
for (size_t i = 0, i_e = (src_texture_4check.size() - 1); i < i_e; i++)
{
if((src_texture_4check[i]->Width != src_texture_4check[i + 1]->Width) || (src_texture_4check[i]->Height != src_texture_4check[i + 1]->Height) ||
(src_texture_4check[i]->Depth != src_texture_4check[i + 1]->Depth))
Expand Down
3 changes: 2 additions & 1 deletion code/ASEParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,8 @@ void Parser::ParseLV2MaterialBlock(ASE::Material& mat)
if (TokenMatch(filePtr,"MATERIAL_TRANSPARENCY",21))
{
ParseLV4MeshFloat(mat.mTransparency);
mat.mTransparency = 1.0 - mat.mTransparency;continue;
mat.mTransparency = ai_real( 1.0 ) - mat.mTransparency;
continue;
}
// material self illumination
if (TokenMatch(filePtr,"MATERIAL_SELFILLUM",18))
Expand Down
98 changes: 56 additions & 42 deletions code/BaseImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,21 +481,30 @@ namespace Assimp
BatchLoader::PropertyMap map;
unsigned int id;

bool operator== (const std::string& f) {
bool operator== (const std::string& f) const {
return file == f;
}
};
}

// ------------------------------------------------------------------------------------------------
// BatchLoader::pimpl data structure
struct Assimp::BatchData
{
BatchData()
: pIOSystem()
, pImporter()
, next_id(0xffff)
{}
struct Assimp::BatchData {
BatchData( IOSystem* pIO, bool validate )
: pIOSystem( pIO )
, pImporter( nullptr )
, next_id(0xffff)
, validate( validate ) {
ai_assert( NULL != pIO );

pImporter = new Importer();
pImporter->SetIOHandler( pIO );
}

~BatchData() {
pImporter->SetIOHandler( NULL ); /* get pointer back into our possession */
delete pImporter;
}

// IO system to be used for all imports
IOSystem* pIOSystem;
Expand All @@ -511,74 +520,78 @@ struct Assimp::BatchData

// Id for next item
unsigned int next_id;

// Validation enabled state
bool validate;
};

typedef std::list<LoadRequest>::iterator LoadReqIt;

// ------------------------------------------------------------------------------------------------
BatchLoader::BatchLoader(IOSystem* pIO)
BatchLoader::BatchLoader(IOSystem* pIO, bool validate )
{
ai_assert(NULL != pIO);

data = new BatchData();
data->pIOSystem = pIO;

data->pImporter = new Importer();
data->pImporter->SetIOHandler(data->pIOSystem);
m_data = new BatchData( pIO, validate );
}

// ------------------------------------------------------------------------------------------------
BatchLoader::~BatchLoader()
{
// delete all scenes wthat have not been polled by the user
for (std::list<LoadRequest>::iterator it = data->requests.begin();it != data->requests.end(); ++it) {

// delete all scenes what have not been polled by the user
for ( LoadReqIt it = m_data->requests.begin();it != m_data->requests.end(); ++it) {
delete (*it).scene;
}
data->pImporter->SetIOHandler(NULL); /* get pointer back into our possession */
delete data->pImporter;
delete data;
delete m_data;
}

// ------------------------------------------------------------------------------------------------
void BatchLoader::setValidation( bool enabled ) {
m_data->validate = enabled;
}

// ------------------------------------------------------------------------------------------------
unsigned int BatchLoader::AddLoadRequest (const std::string& file,
bool BatchLoader::getValidation() const {
return m_data->validate;
}

// ------------------------------------------------------------------------------------------------
unsigned int BatchLoader::AddLoadRequest(const std::string& file,
unsigned int steps /*= 0*/, const PropertyMap* map /*= NULL*/)
{
ai_assert(!file.empty());

// check whether we have this loading request already
std::list<LoadRequest>::iterator it;
for (it = data->requests.begin();it != data->requests.end(); ++it) {

for ( LoadReqIt it = m_data->requests.begin();it != m_data->requests.end(); ++it) {
// Call IOSystem's path comparison function here
if (data->pIOSystem->ComparePaths((*it).file,file)) {

if ( m_data->pIOSystem->ComparePaths((*it).file,file)) {
if (map) {
if (!((*it).map == *map))
if ( !( ( *it ).map == *map ) ) {
continue;
}
}
else if (!(*it).map.empty())
else if ( !( *it ).map.empty() ) {
continue;
}

(*it).refCnt++;
return (*it).id;
}
}

// no, we don't have it. So add it to the queue ...
data->requests.push_back(LoadRequest(file,steps,map,data->next_id));
return data->next_id++;
m_data->requests.push_back(LoadRequest(file,steps,map, m_data->next_id));
return m_data->next_id++;
}

// ------------------------------------------------------------------------------------------------
aiScene* BatchLoader::GetImport (unsigned int which)
aiScene* BatchLoader::GetImport( unsigned int which )
{
for (std::list<LoadRequest>::iterator it = data->requests.begin();it != data->requests.end(); ++it) {

for ( LoadReqIt it = m_data->requests.begin();it != m_data->requests.end(); ++it) {
if ((*it).id == which && (*it).loaded) {

aiScene* sc = (*it).scene;
if (!(--(*it).refCnt)) {
data->requests.erase(it);
m_data->requests.erase(it);
}
return sc;
}
Expand All @@ -590,14 +603,15 @@ aiScene* BatchLoader::GetImport (unsigned int which)
void BatchLoader::LoadAll()
{
// no threaded implementation for the moment
for (std::list<LoadRequest>::iterator it = data->requests.begin();it != data->requests.end(); ++it) {
for ( LoadReqIt it = m_data->requests.begin();it != m_data->requests.end(); ++it) {
// force validation in debug builds
unsigned int pp = (*it).flags;
#ifdef ASSIMP_BUILD_DEBUG
pp |= aiProcess_ValidateDataStructure;
#endif
if ( m_data->validate ) {
pp |= aiProcess_ValidateDataStructure;
}

// setup config properties if necessary
ImporterPimpl* pimpl = data->pImporter->Pimpl();
ImporterPimpl* pimpl = m_data->pImporter->Pimpl();
pimpl->mFloatProperties = (*it).map.floats;
pimpl->mIntProperties = (*it).map.ints;
pimpl->mStringProperties = (*it).map.strings;
Expand All @@ -608,8 +622,8 @@ void BatchLoader::LoadAll()
DefaultLogger::get()->info("%%% BEGIN EXTERNAL FILE %%%");
DefaultLogger::get()->info("File: " + (*it).file);
}
data->pImporter->ReadFile((*it).file,pp);
(*it).scene = data->pImporter->GetOrphanedScene();
m_data->pImporter->ReadFile((*it).file,pp);
(*it).scene = m_data->pImporter->GetOrphanedScene();
(*it).loaded = true;

DefaultLogger::get()->info("%%% END EXTERNAL FILE %%%");
Expand Down
15 changes: 8 additions & 7 deletions code/BaseImporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,12 @@ class ASSIMP_API BaseImporter
static void ConvertUTF8toISO8859_1(
std::string& data);

enum TextFileMode { ALLOW_EMPTY, FORBID_EMPTY };
// -------------------------------------------------------------------
/// @brief Enum to define, if empty files are ok or not.
enum TextFileMode {
ALLOW_EMPTY,
FORBID_EMPTY
};

// -------------------------------------------------------------------
/** Utility for text file loaders which copies the contents of the
Expand Down Expand Up @@ -382,14 +387,10 @@ class ASSIMP_API BaseImporter
}
}



protected:

/** Error description in case there was one. */
/// Error description in case there was one.
std::string m_ErrorText;

/** Currently set progress handler */
/// Currently set progress handler.
ProgressHandler* m_progress;
};

Expand Down
Loading

0 comments on commit a1f773c

Please sign in to comment.