Skip to content

Commit

Permalink
Merge branch 'master' into issue_1728
Browse files Browse the repository at this point in the history
  • Loading branch information
kimkulling committed Jan 24, 2018
2 parents 5baba37 + 68aedce commit 2e7e16b
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 57 deletions.
21 changes: 10 additions & 11 deletions code/FBXConverter.cpp
Expand Up @@ -75,10 +75,9 @@ using namespace Util;


Converter::Converter( aiScene* out, const Document& doc )
: defaultMaterialIndex()
, out( out )
, doc( doc )
{
: defaultMaterialIndex()
, out( out )
, doc( doc ) {
// animations need to be converted first since this will
// populate the node_anim_chain_bits map, which is needed
// to determine which nodes need to be generated.
Expand Down Expand Up @@ -116,8 +115,7 @@ Converter::Converter( aiScene* out, const Document& doc )
}


Converter::~Converter()
{
Converter::~Converter() {
std::for_each( meshes.begin(), meshes.end(), Util::delete_fun<aiMesh>() );
std::for_each( materials.begin(), materials.end(), Util::delete_fun<aiMaterial>() );
std::for_each( animations.begin(), animations.end(), Util::delete_fun<aiAnimation>() );
Expand All @@ -126,8 +124,7 @@ Converter::~Converter()
std::for_each( textures.begin(), textures.end(), Util::delete_fun<aiTexture>() );
}

void Converter::ConvertRootNode()
{
void Converter::ConvertRootNode() {
out->mRootNode = new aiNode();
out->mRootNode->mName.Set( "RootNode" );

Expand Down Expand Up @@ -354,10 +351,12 @@ void Converter::ConvertCamera( const Model& model, const Camera& cam )
out_camera->mName.Set( FixNodeName( model.Name() ) );

out_camera->mAspect = cam.AspectWidth() / cam.AspectHeight();

//cameras are defined along positive x direction
out_camera->mPosition = aiVector3D(0.0f);
out_camera->mLookAt = aiVector3D(1.0f, 0.0f, 0.0f);
out_camera->mUp = aiVector3D(0.0f, 1.0f, 0.0f);
out_camera->mPosition = cam.Position();
out_camera->mLookAt = ( cam.InterestPosition() - out_camera->mPosition ).Normalize();
out_camera->mUp = cam.UpVector();

out_camera->mHorizontalFOV = AI_DEG_TO_RAD( cam.FieldOfView() );
out_camera->mClipPlaneNear = cam.NearPlane();
out_camera->mClipPlaneFar = cam.FarPlane();
Expand Down
27 changes: 12 additions & 15 deletions code/FBXParser.cpp
Expand Up @@ -45,7 +45,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#ifndef ASSIMP_BUILD_NO_FBX_IMPORTER


#ifdef ASSIMP_BUILD_NO_OWN_ZLIB
# include <zlib.h>
#else
Expand All @@ -67,7 +66,6 @@ using namespace Assimp::FBX;

namespace {


// ------------------------------------------------------------------------------------------------
// signal parse error, this is always unrecoverable. Throws DeadlyImportError.
AI_WONT_RETURN void ParseError(const std::string& message, const Token& token) AI_WONT_RETURN_SUFFIX;
Expand Down Expand Up @@ -213,7 +211,6 @@ Scope::~Scope()
}
}


// ------------------------------------------------------------------------------------------------
Parser::Parser (const TokenList& tokens, bool is_binary)
: tokens(tokens)
Expand Down Expand Up @@ -537,18 +534,18 @@ void ReadBinaryDataArray(char type, uint32_t count, const char*& data, const cha
uint32_t stride = 0;
switch(type)
{
case 'f':
case 'i':
stride = 4;
break;

case 'd':
case 'l':
stride = 8;
break;

default:
ai_assert(false);
case 'f':
case 'i':
stride = 4;
break;

case 'd':
case 'l':
stride = 8;
break;

default:
ai_assert(false);
};

const uint32_t full_length = stride * count;
Expand Down
5 changes: 1 addition & 4 deletions code/FBXProperties.cpp
Expand Up @@ -108,7 +108,7 @@ Property* ReadTypedProperty(const Element& element)
ParseTokenAsFloat(*tok[6]))
);
}
else if (!strcmp(cs,"double") || !strcmp(cs,"Number") || !strcmp(cs,"Float") || !strcmp(cs,"FieldOfView")) {
else if (!strcmp(cs,"double") || !strcmp(cs,"Number") || !strcmp(cs,"Float") || !strcmp(cs,"FieldOfView") || !strcmp( cs, "UnitScaleFactor" ) ) {
return new TypedProperty<float>(ParseTokenAsFloat(*tok[4]));
}
return NULL;
Expand Down Expand Up @@ -138,7 +138,6 @@ PropertyTable::PropertyTable()
{
}


// ------------------------------------------------------------------------------------------------
PropertyTable::PropertyTable(const Element& element, std::shared_ptr<const PropertyTable> templateProps)
: templateProps(templateProps)
Expand Down Expand Up @@ -229,8 +228,6 @@ DirectPropertyMap PropertyTable::GetUnparsedProperties() const
return result;
}



} //! FBX
} //! Assimp

Expand Down
2 changes: 0 additions & 2 deletions code/FBXTokenizer.cpp
Expand Up @@ -76,13 +76,11 @@ Token::Token(const char* sbegin, const char* send, TokenType type, unsigned int
ai_assert(static_cast<size_t>(send-sbegin) > 0);
}


// ------------------------------------------------------------------------------------------------
Token::~Token()
{
}


namespace {

// ------------------------------------------------------------------------------------------------
Expand Down
34 changes: 14 additions & 20 deletions code/MDLLoader.cpp
Expand Up @@ -340,9 +340,9 @@ void FlipQuakeHeader(BE_NCONST MDL::Header* pcHeader)

// ------------------------------------------------------------------------------------------------
// Read a Quake 1 file
void MDLImporter::InternReadFile_Quake1( )
{
void MDLImporter::InternReadFile_Quake1() {
ai_assert(NULL != pScene);

BE_NCONST MDL::Header *pcHeader = (BE_NCONST MDL::Header*)this->mBuffer;

#ifdef AI_BUILD_BIG_ENDIAN
Expand All @@ -355,27 +355,27 @@ void MDLImporter::InternReadFile_Quake1( )
const unsigned char* szCurrent = (const unsigned char*)(pcHeader+1);

// need to read all textures
for (unsigned int i = 0; i < (unsigned int)pcHeader->num_skins;++i)
{
union{BE_NCONST MDL::Skin* pcSkin;BE_NCONST MDL::GroupSkin* pcGroupSkin;};
for ( unsigned int i = 0; i < (unsigned int)pcHeader->num_skins; ++i) {
union {
BE_NCONST MDL::Skin* pcSkin;
BE_NCONST MDL::GroupSkin* pcGroupSkin;
};
if (szCurrent + sizeof(MDL::Skin) > this->mBuffer + this->iFileSize) {
throw DeadlyImportError("[Quake 1 MDL] Unexpected EOF");
}
pcSkin = (BE_NCONST MDL::Skin*)szCurrent;

AI_SWAP4( pcSkin->group );

// Quake 1 groupskins
if (1 == pcSkin->group)
{
// Quake 1 group-skins
if (1 == pcSkin->group) {
AI_SWAP4( pcGroupSkin->nb );

// need to skip multiple images
const unsigned int iNumImages = (unsigned int)pcGroupSkin->nb;
szCurrent += sizeof(uint32_t) * 2;

if (0 != iNumImages)
{
if (0 != iNumImages) {
if (!i) {
// however, create only one output image (the first)
this->CreateTextureARGB8_3DGS_MDL3(szCurrent + iNumImages * sizeof(float));
Expand All @@ -384,10 +384,7 @@ void MDLImporter::InternReadFile_Quake1( )
szCurrent += pcHeader->skinheight * pcHeader->skinwidth +
sizeof(float) * iNumImages;
}
}
// 3DGS has a few files that are using other 3DGS like texture formats here
else
{
} else {
szCurrent += sizeof(uint32_t);
unsigned int iSkip = i ? UINT_MAX : 0;
CreateTexture_3DGS_MDL4(szCurrent,pcSkin->group,&iSkip);
Expand All @@ -407,17 +404,14 @@ void MDLImporter::InternReadFile_Quake1( )
BE_NCONST MDL::Frame* pcFrames = (BE_NCONST MDL::Frame*)szCurrent;
BE_NCONST MDL::SimpleFrame* pcFirstFrame;

if (0 == pcFrames->type)
{
if (0 == pcFrames->type) {
// get address of single frame
pcFirstFrame = &pcFrames->frame;
}
else
{
} else {
// get the first frame in the group

#if 1
// FIXME: the cast is wrong and causea a warning on clang 5.0
// FIXME: the cast is wrong and cause a warning on clang 5.0
// disable thi code for now, fix it later
ai_assert(false && "Bad pointer cast");
#else
Expand Down
11 changes: 6 additions & 5 deletions include/assimp/IOStream.hpp
Expand Up @@ -70,7 +70,7 @@ class ASSIMP_API IOStream
{
protected:
/** Constructor protected, use IOSystem::Open() to create an instance. */
IOStream(void);
IOStream();

public:
// -------------------------------------------------------------------
Expand Down Expand Up @@ -124,17 +124,18 @@ class ASSIMP_API IOStream
}; //! class IOStream

// ----------------------------------------------------------------------------------
inline IOStream::IOStream()
{
inline
IOStream::IOStream() {
// empty
}

// ----------------------------------------------------------------------------------
inline IOStream::~IOStream()
{
inline
IOStream::~IOStream() {
// empty
}
// ----------------------------------------------------------------------------------

} //!namespace Assimp

#endif //!!AI_IOSTREAM_H_INC

0 comments on commit 2e7e16b

Please sign in to comment.