fix possible warnings
parent
22d6b761e6
commit
4c177ad72e
|
@ -441,12 +441,34 @@ struct Material {
|
|||
// empty
|
||||
}
|
||||
|
||||
Material(const Material &other) = default;
|
||||
Material &operator=(const Material &other) = default;
|
||||
Material(const Material &other) :
|
||||
mName(other.mName),
|
||||
mDiffuse(other.mDiffuse),
|
||||
mSpecularExponent(other.mSpecularExponent),
|
||||
mShininessStrength(other.mShininessStrength),
|
||||
mSpecular(other.mSpecular),
|
||||
mAmbient(other.mAmbient),
|
||||
mShading(other.mShading),
|
||||
mTransparency(other.mTransparency),
|
||||
sTexDiffuse(other.sTexDiffuse),
|
||||
sTexOpacity(other.sTexOpacity),
|
||||
sTexSpecular(other.sTexSpecular),
|
||||
sTexReflective(other.sTexReflective),
|
||||
sTexBump(other.sTexBump),
|
||||
sTexEmissive(other.sTexEmissive),
|
||||
sTexShininess(other.sTexShininess),
|
||||
mBumpHeight(other.mBumpHeight),
|
||||
mEmissive(other.mEmissive),
|
||||
sTexAmbient(other.sTexAmbient),
|
||||
mTwoSided(other.mTwoSided) {
|
||||
// empty
|
||||
|
||||
}
|
||||
//Material &operator=(const Material &other) = default;
|
||||
|
||||
//! Move constructor. This is explicitly written because MSVC doesn't support defaulting it
|
||||
Material(Material &&other) AI_NO_EXCEPT
|
||||
: mName(std::move(other.mName)),
|
||||
Material(Material &&other) AI_NO_EXCEPT :
|
||||
mName(std::move(other.mName)),
|
||||
mDiffuse(std::move(other.mDiffuse)),
|
||||
mSpecularExponent(std::move(other.mSpecularExponent)),
|
||||
mShininessStrength(std::move(other.mShininessStrength)),
|
||||
|
@ -465,6 +487,7 @@ struct Material {
|
|||
mEmissive(std::move(other.mEmissive)),
|
||||
sTexAmbient(std::move(other.sTexAmbient)),
|
||||
mTwoSided(std::move(other.mTwoSided)) {
|
||||
// empty
|
||||
}
|
||||
|
||||
Material &operator=(Material &&other) AI_NO_EXCEPT {
|
||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
|||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
@ -43,17 +41,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/** @file Implementation of the Terragen importer class */
|
||||
|
||||
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_TERRAGEN_IMPORTER
|
||||
|
||||
#include "TerragenLoader.h"
|
||||
#include <assimp/StreamReader.h>
|
||||
#include <assimp/Importer.hpp>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/importerdesc.h>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <assimp/importerdesc.h>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/Importer.hpp>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
@ -72,19 +68,16 @@ static const aiImporterDesc desc = {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
TerragenImporter::TerragenImporter()
|
||||
: configComputeUVs (false)
|
||||
{}
|
||||
TerragenImporter::TerragenImporter() :
|
||||
configComputeUVs(false) {}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Destructor, private as well
|
||||
TerragenImporter::~TerragenImporter()
|
||||
{}
|
||||
TerragenImporter::~TerragenImporter() {}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Returns whether the class can handle the format of the given file.
|
||||
bool TerragenImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const
|
||||
{
|
||||
bool TerragenImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const {
|
||||
// check file extension
|
||||
std::string extension = GetExtension(pFile);
|
||||
|
||||
|
@ -105,15 +98,13 @@ bool TerragenImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler,
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Build a string of all file extensions supported
|
||||
const aiImporterDesc* TerragenImporter::GetInfo () const
|
||||
{
|
||||
const aiImporterDesc *TerragenImporter::GetInfo() const {
|
||||
return &desc;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Setup import properties
|
||||
void TerragenImporter::SetupProperties(const Importer* pImp)
|
||||
{
|
||||
void TerragenImporter::SetupProperties(const Importer *pImp) {
|
||||
// AI_CONFIG_IMPORT_TER_MAKE_UVS
|
||||
configComputeUVs = (0 != pImp->GetPropertyInteger(AI_CONFIG_IMPORT_TER_MAKE_UVS, 0));
|
||||
}
|
||||
|
@ -121,8 +112,7 @@ void TerragenImporter::SetupProperties(const Importer* pImp)
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
// Imports the given file into the given scene structure.
|
||||
void TerragenImporter::InternReadFile(const std::string &pFile,
|
||||
aiScene* pScene, IOSystem* pIOHandler)
|
||||
{
|
||||
aiScene *pScene, IOSystem *pIOHandler) {
|
||||
IOStream *file = pIOHandler->Open(pFile, "rb");
|
||||
|
||||
// Check whether we can read from the file
|
||||
|
@ -151,8 +141,7 @@ void TerragenImporter::InternReadFile( const std::string& pFile,
|
|||
|
||||
// Now read all chunks until we're finished or an EOF marker is encountered
|
||||
reader.IncPtr(16);
|
||||
while (reader.GetRemainingSize() >= 4)
|
||||
{
|
||||
while (reader.GetRemainingSize() >= 4) {
|
||||
const char *head = (const char *)reader.GetPtr();
|
||||
reader.IncPtr(4);
|
||||
|
||||
|
@ -161,42 +150,35 @@ void TerragenImporter::InternReadFile( const std::string& pFile,
|
|||
break;
|
||||
|
||||
// Number of x-data points
|
||||
if (!::strncmp(head,AI_TERR_CHUNK_XPTS,4))
|
||||
{
|
||||
if (!::strncmp(head, AI_TERR_CHUNK_XPTS, 4)) {
|
||||
x = (uint16_t)reader.GetI2();
|
||||
}
|
||||
// Number of y-data points
|
||||
else if (!::strncmp(head,AI_TERR_CHUNK_YPTS,4))
|
||||
{
|
||||
else if (!::strncmp(head, AI_TERR_CHUNK_YPTS, 4)) {
|
||||
y = (uint16_t)reader.GetI2();
|
||||
}
|
||||
// Squared terrains width-1.
|
||||
else if (!::strncmp(head,AI_TERR_CHUNK_SIZE,4))
|
||||
{
|
||||
else if (!::strncmp(head, AI_TERR_CHUNK_SIZE, 4)) {
|
||||
x = y = (uint16_t)reader.GetI2() + 1;
|
||||
}
|
||||
// terrain scaling
|
||||
else if (!::strncmp(head,AI_TERR_CHUNK_SCAL,4))
|
||||
{
|
||||
else if (!::strncmp(head, AI_TERR_CHUNK_SCAL, 4)) {
|
||||
root->mTransformation.a1 = reader.GetF4();
|
||||
root->mTransformation.b2 = reader.GetF4();
|
||||
root->mTransformation.c3 = reader.GetF4();
|
||||
}
|
||||
// mapping == 1: earth radius
|
||||
else if (!::strncmp(head,AI_TERR_CHUNK_CRAD,4))
|
||||
{
|
||||
else if (!::strncmp(head, AI_TERR_CHUNK_CRAD, 4)) {
|
||||
reader.GetF4();
|
||||
}
|
||||
// mapping mode
|
||||
else if (!::strncmp(head,AI_TERR_CHUNK_CRVM,4))
|
||||
{
|
||||
else if (!::strncmp(head, AI_TERR_CHUNK_CRVM, 4)) {
|
||||
mode = reader.GetI1();
|
||||
if (0 != mode)
|
||||
ASSIMP_LOG_ERROR("TER: Unsupported mapping mode, a flat terrain is returned");
|
||||
}
|
||||
// actual terrain data
|
||||
else if (!::strncmp(head,AI_TERR_CHUNK_ALTW,4))
|
||||
{
|
||||
else if (!::strncmp(head, AI_TERR_CHUNK_ALTW, 4)) {
|
||||
float hscale = (float)reader.GetI2() / 65536;
|
||||
float bheight = (float)reader.GetI2();
|
||||
|
||||
|
@ -247,8 +229,10 @@ void TerragenImporter::InternReadFile( const std::string& pFile,
|
|||
|
||||
// make indices
|
||||
f->mIndices = new unsigned int[f->mNumIndices = 4];
|
||||
for (unsigned int i = 0; i < 4;++i)
|
||||
f->mIndices[i] = t++;
|
||||
for (unsigned int i = 0; i < 4; ++i) {
|
||||
f->mIndices[i] = t;
|
||||
t++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
|
|||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
@ -69,21 +68,17 @@ namespace Assimp {
|
|||
* The loader is basing on the information found here:
|
||||
* http://www.planetside.co.uk/terragen/dev/tgterrain.html#chunks
|
||||
*/
|
||||
class TerragenImporter : public BaseImporter
|
||||
{
|
||||
class TerragenImporter : public BaseImporter {
|
||||
public:
|
||||
TerragenImporter();
|
||||
~TerragenImporter();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
bool CanRead(const std::string &pFile, IOSystem *pIOHandler,
|
||||
bool checkSig) const;
|
||||
|
||||
protected:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
const aiImporterDesc *GetInfo() const;
|
||||
|
||||
|
@ -95,7 +90,6 @@ protected:
|
|||
void SetupProperties(const Importer *pImp);
|
||||
|
||||
private:
|
||||
|
||||
bool configComputeUVs;
|
||||
|
||||
}; //! class TerragenImporter
|
||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
|||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
@ -52,10 +50,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include <assimp/IOStream.hpp>
|
||||
#include <assimp/Defines.h>
|
||||
#include <assimp/ByteSwapper.h>
|
||||
#include <assimp/Defines.h>
|
||||
#include <assimp/Exceptional.h>
|
||||
#include <assimp/IOStream.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
@ -74,10 +72,8 @@ namespace Assimp {
|
|||
template <bool SwapEndianess = false, bool RuntimeSwitch = false>
|
||||
class StreamReader {
|
||||
public:
|
||||
// FIXME: use these data types throughout the whole library,
|
||||
// then change them to 64 bit values :-)
|
||||
using diff = int;
|
||||
using pos = unsigned int;
|
||||
using diff = size_t;
|
||||
using pos = size_t;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Construction from a given stream with a well-defined endianness.
|
||||
|
@ -91,39 +87,44 @@ public:
|
|||
* stream is in little endian byte order. Otherwise the
|
||||
* endianness information is contained in the @c SwapEndianess
|
||||
* template parameter and this parameter is meaningless. */
|
||||
StreamReader(std::shared_ptr<IOStream> stream, bool le = false)
|
||||
: stream(stream)
|
||||
, le(le)
|
||||
{
|
||||
StreamReader(std::shared_ptr<IOStream> stream, bool le = false) :
|
||||
mStream(stream),
|
||||
mBuffer(nullptr),
|
||||
mCurrent(nullptr),
|
||||
mEnd(nullptr),
|
||||
mLimit(nullptr),
|
||||
mLe(le) {
|
||||
ai_assert(stream);
|
||||
InternBegin();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
StreamReader(IOStream* stream, bool le = false)
|
||||
: stream(std::shared_ptr<IOStream>(stream))
|
||||
, le(le)
|
||||
{
|
||||
ai_assert(stream);
|
||||
StreamReader(IOStream *stream, bool le = false) :
|
||||
mStream(std::shared_ptr<IOStream>(stream)),
|
||||
mBuffer(nullptr),
|
||||
mCurrent(nullptr),
|
||||
mEnd(nullptr),
|
||||
mLimit(nullptr),
|
||||
mLe(le) {
|
||||
ai_assert(nullptr != stream);
|
||||
InternBegin();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
~StreamReader() {
|
||||
delete[] buffer;
|
||||
delete[] mBuffer;
|
||||
}
|
||||
|
||||
// deprecated, use overloaded operator>> instead
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Read a float from the stream */
|
||||
float GetF4()
|
||||
{
|
||||
/// Read a float from the stream.
|
||||
float GetF4() {
|
||||
return Get<float>();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Read a double from the stream */
|
||||
/// Read a double from the stream.
|
||||
double GetF8() {
|
||||
return Get<double>();
|
||||
}
|
||||
|
@ -159,42 +160,42 @@ public:
|
|||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Read a unsigned 8 bit integer from the stream */
|
||||
/// Read a unsigned 8 bit integer from the stream
|
||||
uint8_t GetU1() {
|
||||
return Get<uint8_t>();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Read an unsigned 32 bit integer from the stream */
|
||||
/// Read an unsigned 32 bit integer from the stream
|
||||
uint32_t GetU4() {
|
||||
return Get<uint32_t>();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Read a unsigned 64 bit integer from the stream */
|
||||
/// Read a unsigned 64 bit integer from the stream
|
||||
uint64_t GetU8() {
|
||||
return Get<uint64_t>();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Get the remaining stream size (to the end of the stream) */
|
||||
unsigned int GetRemainingSize() const {
|
||||
return (unsigned int)(end - current);
|
||||
/// Get the remaining stream size (to the end of the stream)
|
||||
size_t GetRemainingSize() const {
|
||||
return (unsigned int)(mEnd - mCurrent);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Get the remaining stream size (to the current read limit). The
|
||||
* return value is the remaining size of the stream if no custom
|
||||
* read limit has been set. */
|
||||
unsigned int GetRemainingSizeToLimit() const {
|
||||
return (unsigned int)(limit - current);
|
||||
size_t GetRemainingSizeToLimit() const {
|
||||
return (unsigned int)(mLimit - mCurrent);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Increase the file pointer (relative seeking) */
|
||||
void IncPtr(intptr_t plus) {
|
||||
current += plus;
|
||||
if (current > limit) {
|
||||
mCurrent += plus;
|
||||
if (mCurrent > mLimit) {
|
||||
throw DeadlyImportError("End of file or read limit was reached");
|
||||
}
|
||||
}
|
||||
|
@ -202,7 +203,7 @@ public:
|
|||
// ---------------------------------------------------------------------
|
||||
/** Get the current file pointer */
|
||||
int8_t *GetPtr() const {
|
||||
return current;
|
||||
return mCurrent;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
@ -212,8 +213,8 @@ public:
|
|||
* @param p The new pointer, which is validated against the size
|
||||
* limit and buffer boundaries. */
|
||||
void SetPtr(int8_t *p) {
|
||||
current = p;
|
||||
if (current > limit || current < buffer) {
|
||||
mCurrent = p;
|
||||
if (mCurrent > mLimit || mCurrent < mBuffer) {
|
||||
throw DeadlyImportError("End of file or read limit was reached");
|
||||
}
|
||||
}
|
||||
|
@ -229,14 +230,13 @@ public:
|
|||
::memcpy(out, ur, bytes);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Get the current offset from the beginning of the file */
|
||||
/// @brief Get the current offset from the beginning of the file
|
||||
int GetCurrentPos() const {
|
||||
return (unsigned int)(current - buffer);
|
||||
return (unsigned int)(mCurrent - mBuffer);
|
||||
}
|
||||
|
||||
void SetCurrentPos(size_t pos) {
|
||||
SetPtr(buffer + pos);
|
||||
SetPtr(mBuffer + pos);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
@ -249,12 +249,12 @@ public:
|
|||
unsigned int SetReadLimit(unsigned int _limit) {
|
||||
unsigned int prev = GetReadLimit();
|
||||
if (UINT_MAX == _limit) {
|
||||
limit = end;
|
||||
mLimit = mEnd;
|
||||
return prev;
|
||||
}
|
||||
|
||||
limit = buffer + _limit;
|
||||
if (limit > end) {
|
||||
mLimit = mBuffer + _limit;
|
||||
if (mLimit > mEnd) {
|
||||
throw DeadlyImportError("StreamReader: Invalid read limit");
|
||||
}
|
||||
return prev;
|
||||
|
@ -264,14 +264,14 @@ public:
|
|||
/** Get the current read limit in bytes. Reading over this limit
|
||||
* accidentally raises an exception. */
|
||||
unsigned int GetReadLimit() const {
|
||||
return (unsigned int)(limit - buffer);
|
||||
return (unsigned int)(mLimit - mBuffer);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Skip to the read limit in bytes. Reading over this limit
|
||||
* accidentally raises an exception. */
|
||||
void SkipToReadLimit() {
|
||||
current = limit;
|
||||
mCurrent = mLimit;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
@ -286,14 +286,14 @@ public:
|
|||
/** Generic read method. ByteSwap::Swap(T*) *must* be defined */
|
||||
template <typename T>
|
||||
T Get() {
|
||||
if ( current + sizeof(T) > limit) {
|
||||
if (mCurrent + sizeof(T) > mLimit) {
|
||||
throw DeadlyImportError("End of file or stream limit was reached");
|
||||
}
|
||||
|
||||
T f;
|
||||
::memcpy (&f, current, sizeof(T));
|
||||
Intern::Getter<SwapEndianess,T,RuntimeSwitch>() (&f,le);
|
||||
current += sizeof(T);
|
||||
::memcpy(&f, mCurrent, sizeof(T));
|
||||
Intern::Getter<SwapEndianess, T, RuntimeSwitch>()(&f, mLe);
|
||||
mCurrent += sizeof(T);
|
||||
|
||||
return f;
|
||||
}
|
||||
|
@ -301,31 +301,29 @@ public:
|
|||
private:
|
||||
// ---------------------------------------------------------------------
|
||||
void InternBegin() {
|
||||
if (!stream) {
|
||||
// in case someone wonders: StreamReader is frequently invoked with
|
||||
// no prior validation whether the input stream is valid. Since
|
||||
// no one bothers changing the error message, this message here
|
||||
// is passed down to the caller and 'unable to open file'
|
||||
// simply describes best what happened.
|
||||
if (nullptr == mStream) {
|
||||
throw DeadlyImportError("StreamReader: Unable to open file");
|
||||
}
|
||||
|
||||
const size_t s = stream->FileSize() - stream->Tell();
|
||||
if (!s) {
|
||||
const size_t filesize = mStream->FileSize() - mStream->Tell();
|
||||
if (0 == filesize) {
|
||||
throw DeadlyImportError("StreamReader: File is empty or EOF is already reached");
|
||||
}
|
||||
|
||||
current = buffer = new int8_t[s];
|
||||
const size_t read = stream->Read(current,1,s);
|
||||
mCurrent = mBuffer = new int8_t[filesize];
|
||||
const size_t read = mStream->Read(mCurrent, 1, filesize);
|
||||
// (read < s) can only happen if the stream was opened in text mode, in which case FileSize() is not reliable
|
||||
ai_assert(read <= s);
|
||||
end = limit = &buffer[read-1] + 1;
|
||||
ai_assert(read <= filesize);
|
||||
mEnd = mLimit = &mBuffer[read - 1] + 1;
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<IOStream> stream;
|
||||
int8_t *buffer, *current, *end, *limit;
|
||||
bool le;
|
||||
std::shared_ptr<IOStream> mStream;
|
||||
int8_t *mBuffer;
|
||||
int8_t *mCurrent;
|
||||
int8_t *mEnd;
|
||||
int8_t *mLimit;
|
||||
bool mLe;
|
||||
};
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -140,6 +140,7 @@ SET( IMPORTERS
|
|||
unit/ImportExport/MDL/utMDLImporter_HL1_Nodes.cpp
|
||||
#unit/ImportExport/IRR/utIrrImportExport.cpp
|
||||
unit/ImportExport/RAW/utRAWImportExport.cpp
|
||||
unit/ImportExport/Terragen/utTerragenImportExport.cpp
|
||||
)
|
||||
|
||||
SET( MATERIAL
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue