next warnings.

pull/3012/head
Kim Kulling 2020-02-18 14:41:19 +01:00
parent 22118dff1d
commit 6e13381bdb
12 changed files with 1110 additions and 1282 deletions

View File

@ -45,18 +45,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef AI_3DSFILEHELPER_H_INC #ifndef AI_3DSFILEHELPER_H_INC
#define AI_3DSFILEHELPER_H_INC #define AI_3DSFILEHELPER_H_INC
#include <assimp/SpatialSort.h>
#include <assimp/SmoothingGroups.h> #include <assimp/SmoothingGroups.h>
#include <assimp/SpatialSort.h>
#include <assimp/StringUtils.h> #include <assimp/StringUtils.h>
#include <assimp/qnan.h> #include <assimp/anim.h>
#include <assimp/material.h>
#include <assimp/camera.h> #include <assimp/camera.h>
#include <assimp/light.h> #include <assimp/light.h>
#include <assimp/anim.h> #include <assimp/material.h>
#include <assimp/qnan.h>
#include <stdio.h> //sprintf #include <stdio.h> //sprintf
namespace Assimp { namespace Assimp {
namespace D3DS { namespace D3DS {
#include <assimp/Compiler/pushpack1.h> #include <assimp/Compiler/pushpack1.h>
@ -77,15 +77,13 @@ private:
public: public:
//! data structure for a single chunk in a .3ds file //! data structure for a single chunk in a .3ds file
struct Chunk { struct Chunk {
uint16_t Flag; uint16_t Flag;
uint32_t Size; uint32_t Size;
} PACK_STRUCT; } PACK_STRUCT;
//! Used for shading field in material3ds structure //! Used for shading field in material3ds structure
//! From AutoDesk 3ds SDK //! From AutoDesk 3ds SDK
typedef enum typedef enum {
{
// translated to gouraud shading with wireframe active // translated to gouraud shading with wireframe active
Wire = 0x0, Wire = 0x0,
@ -109,59 +107,57 @@ public:
} shadetype3ds; } shadetype3ds;
// Flags for animated keys // Flags for animated keys
enum enum {
{ KEY_USE_TENS = 0x1,
KEY_USE_TENS = 0x1, KEY_USE_CONT = 0x2,
KEY_USE_CONT = 0x2, KEY_USE_BIAS = 0x4,
KEY_USE_BIAS = 0x4, KEY_USE_EASE_TO = 0x8,
KEY_USE_EASE_TO = 0x8, KEY_USE_EASE_FROM = 0x10
KEY_USE_EASE_FROM = 0x10 };
} ;
enum enum {
{
// ******************************************************************** // ********************************************************************
// Basic chunks which can be found everywhere in the file // Basic chunks which can be found everywhere in the file
CHUNK_VERSION = 0x0002, CHUNK_VERSION = 0x0002,
CHUNK_RGBF = 0x0010, // float4 R; float4 G; float4 B CHUNK_RGBF = 0x0010, // float4 R; float4 G; float4 B
CHUNK_RGBB = 0x0011, // int1 R; int1 G; int B CHUNK_RGBB = 0x0011, // int1 R; int1 G; int B
// Linear color values (gamma = 2.2?) // Linear color values (gamma = 2.2?)
CHUNK_LINRGBF = 0x0013, // float4 R; float4 G; float4 B CHUNK_LINRGBF = 0x0013, // float4 R; float4 G; float4 B
CHUNK_LINRGBB = 0x0012, // int1 R; int1 G; int B CHUNK_LINRGBB = 0x0012, // int1 R; int1 G; int B
CHUNK_PERCENTW = 0x0030, // int2 percentage CHUNK_PERCENTW = 0x0030, // int2 percentage
CHUNK_PERCENTF = 0x0031, // float4 percentage CHUNK_PERCENTF = 0x0031, // float4 percentage
CHUNK_PERCENTD = 0x0032, // float8 percentage CHUNK_PERCENTD = 0x0032, // float8 percentage
// ******************************************************************** // ********************************************************************
// Prj master chunk // Prj master chunk
CHUNK_PRJ = 0xC23D, CHUNK_PRJ = 0xC23D,
// MDLI master chunk // MDLI master chunk
CHUNK_MLI = 0x3DAA, CHUNK_MLI = 0x3DAA,
// Primary main chunk of the .3ds file // Primary main chunk of the .3ds file
CHUNK_MAIN = 0x4D4D, CHUNK_MAIN = 0x4D4D,
// Mesh main chunk // Mesh main chunk
CHUNK_OBJMESH = 0x3D3D, CHUNK_OBJMESH = 0x3D3D,
// Specifies the background color of the .3ds file // Specifies the background color of the .3ds file
// This is passed through the material system for // This is passed through the material system for
// viewing purposes. // viewing purposes.
CHUNK_BKGCOLOR = 0x1200, CHUNK_BKGCOLOR = 0x1200,
// Specifies the ambient base color of the scene. // Specifies the ambient base color of the scene.
// This is added to all materials in the file // This is added to all materials in the file
CHUNK_AMBCOLOR = 0x2100, CHUNK_AMBCOLOR = 0x2100,
// Specifies the background image for the whole scene // Specifies the background image for the whole scene
// This value is passed through the material system // This value is passed through the material system
// to the viewer // to the viewer
CHUNK_BIT_MAP = 0x1100, CHUNK_BIT_MAP = 0x1100,
CHUNK_BIT_MAP_EXISTS = 0x1101, CHUNK_BIT_MAP_EXISTS = 0x1101,
// ******************************************************************** // ********************************************************************
// Viewport related stuff. Ignored // Viewport related stuff. Ignored
@ -177,183 +173,204 @@ public:
// ******************************************************************** // ********************************************************************
// Mesh chunks // Mesh chunks
CHUNK_OBJBLOCK = 0x4000, CHUNK_OBJBLOCK = 0x4000,
CHUNK_TRIMESH = 0x4100, CHUNK_TRIMESH = 0x4100,
CHUNK_VERTLIST = 0x4110, CHUNK_VERTLIST = 0x4110,
CHUNK_VERTFLAGS = 0x4111, CHUNK_VERTFLAGS = 0x4111,
CHUNK_FACELIST = 0x4120, CHUNK_FACELIST = 0x4120,
CHUNK_FACEMAT = 0x4130, CHUNK_FACEMAT = 0x4130,
CHUNK_MAPLIST = 0x4140, CHUNK_MAPLIST = 0x4140,
CHUNK_SMOOLIST = 0x4150, CHUNK_SMOOLIST = 0x4150,
CHUNK_TRMATRIX = 0x4160, CHUNK_TRMATRIX = 0x4160,
CHUNK_MESHCOLOR = 0x4165, CHUNK_MESHCOLOR = 0x4165,
CHUNK_TXTINFO = 0x4170, CHUNK_TXTINFO = 0x4170,
CHUNK_LIGHT = 0x4600, CHUNK_LIGHT = 0x4600,
CHUNK_CAMERA = 0x4700, CHUNK_CAMERA = 0x4700,
CHUNK_HIERARCHY = 0x4F00, CHUNK_HIERARCHY = 0x4F00,
// Specifies the global scaling factor. This is applied // Specifies the global scaling factor. This is applied
// to the root node's transformation matrix // to the root node's transformation matrix
CHUNK_MASTER_SCALE = 0x0100, CHUNK_MASTER_SCALE = 0x0100,
// ******************************************************************** // ********************************************************************
// Material chunks // Material chunks
CHUNK_MAT_MATERIAL = 0xAFFF, CHUNK_MAT_MATERIAL = 0xAFFF,
// asciiz containing the name of the material // asciiz containing the name of the material
CHUNK_MAT_MATNAME = 0xA000, CHUNK_MAT_MATNAME = 0xA000,
CHUNK_MAT_AMBIENT = 0xA010, // followed by color chunk CHUNK_MAT_AMBIENT = 0xA010, // followed by color chunk
CHUNK_MAT_DIFFUSE = 0xA020, // followed by color chunk CHUNK_MAT_DIFFUSE = 0xA020, // followed by color chunk
CHUNK_MAT_SPECULAR = 0xA030, // followed by color chunk CHUNK_MAT_SPECULAR = 0xA030, // followed by color chunk
// Specifies the shininess of the material // Specifies the shininess of the material
// followed by percentage chunk // followed by percentage chunk
CHUNK_MAT_SHININESS = 0xA040, CHUNK_MAT_SHININESS = 0xA040,
CHUNK_MAT_SHININESS_PERCENT = 0xA041 , CHUNK_MAT_SHININESS_PERCENT = 0xA041,
// Specifies the shading mode to be used // Specifies the shading mode to be used
// followed by a short // followed by a short
CHUNK_MAT_SHADING = 0xA100, CHUNK_MAT_SHADING = 0xA100,
// NOTE: Emissive color (self illumination) seems not // NOTE: Emissive color (self illumination) seems not
// to be a color but a single value, type is unknown. // to be a color but a single value, type is unknown.
// Make the parser accept both of them. // Make the parser accept both of them.
// followed by percentage chunk (?) // followed by percentage chunk (?)
CHUNK_MAT_SELF_ILLUM = 0xA080, CHUNK_MAT_SELF_ILLUM = 0xA080,
// Always followed by percentage chunk (?) // Always followed by percentage chunk (?)
CHUNK_MAT_SELF_ILPCT = 0xA084, CHUNK_MAT_SELF_ILPCT = 0xA084,
// Always followed by percentage chunk // Always followed by percentage chunk
CHUNK_MAT_TRANSPARENCY = 0xA050, CHUNK_MAT_TRANSPARENCY = 0xA050,
// Diffuse texture channel 0 // Diffuse texture channel 0
CHUNK_MAT_TEXTURE = 0xA200, CHUNK_MAT_TEXTURE = 0xA200,
// Contains opacity information for each texel // Contains opacity information for each texel
CHUNK_MAT_OPACMAP = 0xA210, CHUNK_MAT_OPACMAP = 0xA210,
// Contains a reflection map to be used to reflect // Contains a reflection map to be used to reflect
// the environment. This is partially supported. // the environment. This is partially supported.
CHUNK_MAT_REFLMAP = 0xA220, CHUNK_MAT_REFLMAP = 0xA220,
// Self Illumination map (emissive colors) // Self Illumination map (emissive colors)
CHUNK_MAT_SELFIMAP = 0xA33d, CHUNK_MAT_SELFIMAP = 0xA33d,
// Bumpmap. Not specified whether it is a heightmap // Bumpmap. Not specified whether it is a heightmap
// or a normal map. Assme it is a heightmap since // or a normal map. Assme it is a heightmap since
// artist normally prefer this format. // artist normally prefer this format.
CHUNK_MAT_BUMPMAP = 0xA230, CHUNK_MAT_BUMPMAP = 0xA230,
// Specular map. Seems to influence the specular color // Specular map. Seems to influence the specular color
CHUNK_MAT_SPECMAP = 0xA204, CHUNK_MAT_SPECMAP = 0xA204,
// Holds shininess data. // Holds shininess data.
CHUNK_MAT_MAT_SHINMAP = 0xA33C, CHUNK_MAT_MAT_SHINMAP = 0xA33C,
// Scaling in U/V direction. // Scaling in U/V direction.
// (need to gen separate UV coordinate set // (need to gen separate UV coordinate set
// and do this by hand) // and do this by hand)
CHUNK_MAT_MAP_USCALE = 0xA354, CHUNK_MAT_MAP_USCALE = 0xA354,
CHUNK_MAT_MAP_VSCALE = 0xA356, CHUNK_MAT_MAP_VSCALE = 0xA356,
// Translation in U/V direction. // Translation in U/V direction.
// (need to gen separate UV coordinate set // (need to gen separate UV coordinate set
// and do this by hand) // and do this by hand)
CHUNK_MAT_MAP_UOFFSET = 0xA358, CHUNK_MAT_MAP_UOFFSET = 0xA358,
CHUNK_MAT_MAP_VOFFSET = 0xA35a, CHUNK_MAT_MAP_VOFFSET = 0xA35a,
// UV-coordinates rotation around the z-axis // UV-coordinates rotation around the z-axis
// Assumed to be in radians. // Assumed to be in radians.
CHUNK_MAT_MAP_ANG = 0xA35C, CHUNK_MAT_MAP_ANG = 0xA35C,
// Tiling flags for 3DS files // Tiling flags for 3DS files
CHUNK_MAT_MAP_TILING = 0xa351, CHUNK_MAT_MAP_TILING = 0xa351,
// Specifies the file name of a texture // Specifies the file name of a texture
CHUNK_MAPFILE = 0xA300, CHUNK_MAPFILE = 0xA300,
// Specifies whether a materail requires two-sided rendering // Specifies whether a materail requires two-sided rendering
CHUNK_MAT_TWO_SIDE = 0xA081, CHUNK_MAT_TWO_SIDE = 0xA081,
// ******************************************************************** // ********************************************************************
// Main keyframer chunk. Contains translation/rotation/scaling data // Main keyframer chunk. Contains translation/rotation/scaling data
CHUNK_KEYFRAMER = 0xB000, CHUNK_KEYFRAMER = 0xB000,
// Supported sub chunks // Supported sub chunks
CHUNK_TRACKINFO = 0xB002, CHUNK_TRACKINFO = 0xB002,
CHUNK_TRACKOBJNAME = 0xB010, CHUNK_TRACKOBJNAME = 0xB010,
CHUNK_TRACKDUMMYOBJNAME = 0xB011, CHUNK_TRACKDUMMYOBJNAME = 0xB011,
CHUNK_TRACKPIVOT = 0xB013, CHUNK_TRACKPIVOT = 0xB013,
CHUNK_TRACKPOS = 0xB020, CHUNK_TRACKPOS = 0xB020,
CHUNK_TRACKROTATE = 0xB021, CHUNK_TRACKROTATE = 0xB021,
CHUNK_TRACKSCALE = 0xB022, CHUNK_TRACKSCALE = 0xB022,
// ******************************************************************** // ********************************************************************
// Keyframes for various other stuff in the file // Keyframes for various other stuff in the file
// Partially ignored // Partially ignored
CHUNK_AMBIENTKEY = 0xB001, CHUNK_AMBIENTKEY = 0xB001,
CHUNK_TRACKMORPH = 0xB026, CHUNK_TRACKMORPH = 0xB026,
CHUNK_TRACKHIDE = 0xB029, CHUNK_TRACKHIDE = 0xB029,
CHUNK_OBJNUMBER = 0xB030, CHUNK_OBJNUMBER = 0xB030,
CHUNK_TRACKCAMERA = 0xB003, CHUNK_TRACKCAMERA = 0xB003,
CHUNK_TRACKFOV = 0xB023, CHUNK_TRACKFOV = 0xB023,
CHUNK_TRACKROLL = 0xB024, CHUNK_TRACKROLL = 0xB024,
CHUNK_TRACKCAMTGT = 0xB004, CHUNK_TRACKCAMTGT = 0xB004,
CHUNK_TRACKLIGHT = 0xB005, CHUNK_TRACKLIGHT = 0xB005,
CHUNK_TRACKLIGTGT = 0xB006, CHUNK_TRACKLIGTGT = 0xB006,
CHUNK_TRACKSPOTL = 0xB007, CHUNK_TRACKSPOTL = 0xB007,
CHUNK_FRAMES = 0xB008, CHUNK_FRAMES = 0xB008,
// ******************************************************************** // ********************************************************************
// light sub-chunks // light sub-chunks
CHUNK_DL_OFF = 0x4620, CHUNK_DL_OFF = 0x4620,
CHUNK_DL_OUTER_RANGE = 0x465A, CHUNK_DL_OUTER_RANGE = 0x465A,
CHUNK_DL_INNER_RANGE = 0x4659, CHUNK_DL_INNER_RANGE = 0x4659,
CHUNK_DL_MULTIPLIER = 0x465B, CHUNK_DL_MULTIPLIER = 0x465B,
CHUNK_DL_EXCLUDE = 0x4654, CHUNK_DL_EXCLUDE = 0x4654,
CHUNK_DL_ATTENUATE = 0x4625, CHUNK_DL_ATTENUATE = 0x4625,
CHUNK_DL_SPOTLIGHT = 0x4610, CHUNK_DL_SPOTLIGHT = 0x4610,
// camera sub-chunks // camera sub-chunks
CHUNK_CAM_RANGES = 0x4720 CHUNK_CAM_RANGES = 0x4720
}; };
}; };
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/** Helper structure representing a 3ds mesh face */ /** Helper structure representing a 3ds mesh face */
struct Face : public FaceWithSmoothingGroup struct Face : public FaceWithSmoothingGroup {
{
}; };
#pragma warning(disable : 4315 )
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/** Helper structure representing a texture */ /** Helper structure representing a texture */
struct Texture { struct Texture {
//! Default constructor //! Default constructor
Texture() AI_NO_EXCEPT Texture() AI_NO_EXCEPT
: mOffsetU (0.0) : mTextureBlend(0.0f),
, mOffsetV (0.0) mMapName(),
, mScaleU (1.0) mOffsetU(0.0),
, mScaleV (1.0) mOffsetV(0.0),
, mRotation (0.0) mScaleU(1.0),
, mMapMode (aiTextureMapMode_Wrap) mScaleV(1.0),
, bPrivate() mRotation(0.0),
, iUVSrc (0) { mMapMode(aiTextureMapMode_Wrap),
bPrivate(),
iUVSrc(0) {
mTextureBlend = get_qnan(); mTextureBlend = get_qnan();
} }
Texture(Texture &&other) AI_NO_EXCEPT : Texture(Texture &&other) AI_NO_EXCEPT : mTextureBlend(std::move(other.mTextureBlend)),
mTextureBlend(std::move(other.mTextureBlend)), mMapName(std::move(mMapName)),
mMapName(std::move(mMapName)), mOffsetU(std::move(mOffsetU)),
mOffsetU(std::move(mOffsetU)), mOffsetV(std::move(mOffsetV)),
mOffsetV(std::move(mOffsetV)), mScaleU(std::move(mScaleU)),
mScaleU(std::move(mScaleU)), mScaleV(std::move(mScaleV)),
mScaleV(std::move(mScaleV)), mRotation(std::move(mRotation)),
mRotation(std::move(mRotation)), mMapMode(std::move(mMapMode)),
mMapMode(std::move(mMapMode)), bPrivate(std::move(bPrivate)),
bPrivate(std::move(bPrivate)), iUVSrc(std::move(iUVSrc)) {
iUVSrc(std::move(iUVSrc)) { // empty
}
Texture &operator=(Texture &&other) AI_NO_EXCEPT {
if (this == &other) {
return *this;
}
mTextureBlend = std::move(other.mTextureBlend);
mMapName = std::move(other.mMapName);
mOffsetU = std::move(other.mOffsetU);
mOffsetV = std::move(other.mOffsetV);
mScaleU = std::move(other.mScaleU);
mScaleV = std::move(other.mScaleV);
mRotation = std::move(other.mRotation);
mMapMode = std::move(other.mMapMode);
bPrivate = std::move(other.bPrivate);
iUVSrc = std::move(other.iUVSrc);
return *this;
} }
//! Specifies the blend factor for the texture //! Specifies the blend factor for the texture
@ -381,55 +398,48 @@ struct Texture {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/** Helper structure representing a 3ds material */ /** Helper structure representing a 3ds material */
struct Material struct Material {
{
//! Default constructor has been deleted //! Default constructor has been deleted
Material() = delete; Material() = delete;
//! Constructor with explicit name //! Constructor with explicit name
explicit Material(const std::string &name) explicit Material(const std::string &name) :
: mName(name) mName(name), mDiffuse(ai_real(0.6), ai_real(0.6), ai_real(0.6)) // FIX ... we won't want object to be black
, 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 ) ) mSpecularExponent(ai_real(0.0)),
, mShininessStrength ( ai_real( 1.0 ) ) mShininessStrength(ai_real(1.0)),
, mShading(Discreet3DS::Gouraud) mShading(Discreet3DS::Gouraud),
, mTransparency ( ai_real( 1.0 ) ) mTransparency(ai_real(1.0)),
, mBumpHeight ( ai_real( 1.0 ) ) mBumpHeight(ai_real(1.0)),
, mTwoSided (false) mTwoSided(false) {
{
} }
Material(const Material &other) = default;
Material(const Material &other) = default;
Material &operator=(const Material &other) = default; Material &operator=(const Material &other) = default;
//! Move constructor. This is explicitly written because MSVC doesn't support defaulting it //! Move constructor. This is explicitly written because MSVC doesn't support defaulting it
Material(Material &&other) AI_NO_EXCEPT Material(Material &&other) AI_NO_EXCEPT
: mName(std::move(other.mName)) : mName(std::move(other.mName)),
, mDiffuse(std::move(other.mDiffuse)) mDiffuse(std::move(other.mDiffuse)),
, mSpecularExponent(std::move(other.mSpecularExponent)) mSpecularExponent(std::move(other.mSpecularExponent)),
, mShininessStrength(std::move(other.mShininessStrength)) mShininessStrength(std::move(other.mShininessStrength)),
, mSpecular(std::move(other.mSpecular)) mSpecular(std::move(other.mSpecular)),
, mAmbient(std::move(other.mAmbient)) mAmbient(std::move(other.mAmbient)),
, mShading(std::move(other.mShading)) mShading(std::move(other.mShading)),
, mTransparency(std::move(other.mTransparency)) mTransparency(std::move(other.mTransparency)),
, sTexDiffuse(std::move(other.sTexDiffuse)) sTexDiffuse(std::move(other.sTexDiffuse)),
, sTexOpacity(std::move(other.sTexOpacity)) sTexOpacity(std::move(other.sTexOpacity)),
, sTexSpecular(std::move(other.sTexSpecular)) sTexSpecular(std::move(other.sTexSpecular)),
, sTexReflective(std::move(other.sTexReflective)) sTexReflective(std::move(other.sTexReflective)),
, sTexBump(std::move(other.sTexBump)) sTexBump(std::move(other.sTexBump)),
, sTexEmissive(std::move(other.sTexEmissive)) sTexEmissive(std::move(other.sTexEmissive)),
, sTexShininess(std::move(other.sTexShininess)) sTexShininess(std::move(other.sTexShininess)),
, mBumpHeight(std::move(other.mBumpHeight)) mBumpHeight(std::move(other.mBumpHeight)),
, mEmissive(std::move(other.mEmissive)) mEmissive(std::move(other.mEmissive)),
, sTexAmbient(std::move(other.sTexAmbient)) sTexAmbient(std::move(other.sTexAmbient)),
, mTwoSided(std::move(other.mTwoSided)) mTwoSided(std::move(other.mTwoSided)) {
{
} }
Material &operator=(Material &&other) AI_NO_EXCEPT { Material &operator=(Material &&other) AI_NO_EXCEPT {
if (this == &other) { if (this == &other) {
return *this; return *this;
@ -458,10 +468,8 @@ struct Material
return *this; return *this;
} }
virtual ~Material() {} virtual ~Material() {}
//! Name of the material //! Name of the material
std::string mName; std::string mName;
//! Diffuse color of the material //! Diffuse color of the material
@ -505,18 +513,15 @@ struct Material
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/** Helper structure to represent a 3ds file mesh */ /** Helper structure to represent a 3ds file mesh */
struct Mesh : public MeshWithSmoothingGroups<D3DS::Face> struct Mesh : public MeshWithSmoothingGroups<D3DS::Face> {
{
//! Default constructor has been deleted //! Default constructor has been deleted
Mesh() = delete; Mesh() = delete;
//! Constructor with explicit name //! Constructor with explicit name
explicit Mesh(const std::string &name) explicit Mesh(const std::string &name) :
: mName(name) mName(name) {
{
} }
//! Name of the mesh //! Name of the mesh
std::string mName; std::string mName;
@ -533,62 +538,48 @@ struct Mesh : public MeshWithSmoothingGroups<D3DS::Face>
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/** Float key - quite similar to aiVectorKey and aiQuatKey. Both are in the /** Float key - quite similar to aiVectorKey and aiQuatKey. Both are in the
C-API, so it would be difficult to make them a template. */ C-API, so it would be difficult to make them a template. */
struct aiFloatKey struct aiFloatKey {
{ double mTime; ///< The time of this key
double mTime; ///< The time of this key ai_real mValue; ///< The value of this key
ai_real mValue; ///< The value of this key
#ifdef __cplusplus #ifdef __cplusplus
// time is not compared // time is not compared
bool operator == (const aiFloatKey& o) const bool operator==(const aiFloatKey &o) const { return o.mValue == this->mValue; }
{return o.mValue == this->mValue;}
bool operator != (const aiFloatKey& o) const bool operator!=(const aiFloatKey &o) const { return o.mValue != this->mValue; }
{return o.mValue != this->mValue;}
// Only time is compared. This operator is defined // Only time is compared. This operator is defined
// for use with std::sort // for use with std::sort
bool operator < (const aiFloatKey& o) const bool operator<(const aiFloatKey &o) const { return mTime < o.mTime; }
{return mTime < o.mTime;}
bool operator > (const aiFloatKey& o) const bool operator>(const aiFloatKey &o) const { return mTime > o.mTime; }
{return mTime > o.mTime;}
#endif #endif
}; };
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/** Helper structure to represent a 3ds file node */ /** Helper structure to represent a 3ds file node */
struct Node struct Node {
{
Node() = delete; Node() = delete;
explicit Node(const std::string &name) explicit Node(const std::string &name) :
: mParent(NULL) mParent(NULL), mName(name), mInstanceNumber(0), mHierarchyPos(0), mHierarchyIndex(0), mInstanceCount(1) {
, mName(name) aRotationKeys.reserve(20);
, mInstanceNumber(0) aPositionKeys.reserve(20);
, mHierarchyPos (0) aScalingKeys.reserve(20);
, mHierarchyIndex (0)
, mInstanceCount (1)
{
aRotationKeys.reserve (20);
aPositionKeys.reserve (20);
aScalingKeys.reserve (20);
} }
~Node() {
~Node() for (unsigned int i = 0; i < mChildren.size(); ++i)
{
for (unsigned int i = 0; i < mChildren.size();++i)
delete mChildren[i]; delete mChildren[i];
} }
//! Pointer to the parent node //! Pointer to the parent node
Node* mParent; Node *mParent;
//! Holds all child nodes //! Holds all child nodes
std::vector<Node*> mChildren; std::vector<Node *> mChildren;
//! Name of the node //! Name of the node
std::string mName; std::string mName;
@ -614,13 +605,12 @@ struct Node
//! Scaling keys loaded from the file //! Scaling keys loaded from the file
std::vector<aiVectorKey> aScalingKeys; std::vector<aiVectorKey> aScalingKeys;
// For target lights (spot lights and directional lights): // For target lights (spot lights and directional lights):
// The position of the target // The position of the target
std::vector< aiVectorKey > aTargetPositionKeys; std::vector<aiVectorKey> aTargetPositionKeys;
// For cameras: the camera roll angle // For cameras: the camera roll angle
std::vector< aiFloatKey > aCameraRollKeys; std::vector<aiFloatKey> aCameraRollKeys;
//! Pivot position loaded from the file //! Pivot position loaded from the file
aiVector3D vPivot; aiVector3D vPivot;
@ -630,8 +620,7 @@ struct Node
//! Add a child node, setup the right parent node for it //! Add a child node, setup the right parent node for it
//! \param pc Node to be 'adopted' //! \param pc Node to be 'adopted'
inline Node& push_back(Node* pc) inline Node &push_back(Node *pc) {
{
mChildren.push_back(pc); mChildren.push_back(pc);
pc->mParent = this; pc->mParent = this;
return *this; return *this;
@ -639,8 +628,7 @@ struct Node
}; };
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/** Helper structure analogue to aiScene */ /** Helper structure analogue to aiScene */
struct Scene struct Scene {
{
//! List of all materials loaded //! List of all materials loaded
//! NOTE: 3ds references materials globally //! NOTE: 3ds references materials globally
std::vector<Material> mMaterials; std::vector<Material> mMaterials;
@ -649,17 +637,16 @@ struct Scene
std::vector<Mesh> mMeshes; std::vector<Mesh> mMeshes;
//! List of all cameras loaded //! List of all cameras loaded
std::vector<aiCamera*> mCameras; std::vector<aiCamera *> mCameras;
//! List of all lights loaded //! List of all lights loaded
std::vector<aiLight*> mLights; std::vector<aiLight *> mLights;
//! Pointer to the root node of the scene //! Pointer to the root node of the scene
// --- moved to main class // --- moved to main class
// Node* pcRootNode; // Node* pcRootNode;
}; };
} // end of namespace D3DS } // end of namespace D3DS
} // end of namespace Assimp } // end of namespace Assimp

View File

@ -158,13 +158,13 @@ void Discreet3DSImporter::SetupProperties(const Importer* /*pImp*/)
void Discreet3DSImporter::InternReadFile( const std::string& pFile, void Discreet3DSImporter::InternReadFile( const std::string& pFile,
aiScene* pScene, IOSystem* pIOHandler) aiScene* pScene, IOSystem* pIOHandler)
{ {
StreamReaderLE stream(pIOHandler->Open(pFile,"rb")); StreamReaderLE theStream(pIOHandler->Open(pFile,"rb"));
// We should have at least one chunk // We should have at least one chunk
if (stream.GetRemainingSize() < 16) { if (theStream.GetRemainingSize() < 16) {
throw DeadlyImportError("3DS file is either empty or corrupt: " + pFile); throw DeadlyImportError("3DS file is either empty or corrupt: " + pFile);
} }
this->stream = &stream; this->stream = &theStream;
// Allocate our temporary 3DS representation // Allocate our temporary 3DS representation
D3DS::Scene _scene; D3DS::Scene _scene;
@ -599,16 +599,19 @@ void Discreet3DSImporter::InverseNodeSearch(D3DS::Node* pcNode,D3DS::Node* pcCur
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Find a node with a specific name in the import hierarchy // Find a node with a specific name in the import hierarchy
D3DS::Node* FindNode(D3DS::Node* root, const std::string& name) D3DS::Node* FindNode(D3DS::Node* root, const std::string& name) {
{ if (root->mName == name) {
if (root->mName == name)
return root; return root;
for (std::vector<D3DS::Node*>::iterator it = root->mChildren.begin();it != root->mChildren.end(); ++it) {
D3DS::Node* nd;
if (( nd = FindNode(*it,name)))
return nd;
} }
return NULL;
for (std::vector<D3DS::Node*>::iterator it = root->mChildren.begin();it != root->mChildren.end(); ++it) {
D3DS::Node *nd = FindNode(*it, name);
if (nullptr != nd) {
return nd;
}
}
return nullptr;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------

File diff suppressed because it is too large Load Diff

View File

@ -268,7 +268,7 @@ private:
std::vector<aiLight*>* mLights; std::vector<aiLight*>* mLights;
// name counters // name counters
unsigned int lights, groups, polys, worlds; unsigned int mLightsCounter, mGroupsCounter, mPolysCounter, mWorldsCounter;
}; };
} // end of namespace Assimp } // end of namespace Assimp

View File

@ -465,7 +465,7 @@ std::list<unsigned int> mesh_idx;
{ {
auto VertexIndex_GetMinimal = [](const std::list<SComplexFace>& pFaceList, const size_t* pBiggerThan) -> size_t auto VertexIndex_GetMinimal = [](const std::list<SComplexFace>& pFaceList, const size_t* pBiggerThan) -> size_t
{ {
size_t rv; size_t rv=0;
if(pBiggerThan != nullptr) if(pBiggerThan != nullptr)
{ {

View File

@ -118,11 +118,11 @@ void HMPImporter::InternReadFile( const std::string& pFile,
aiScene* _pScene, IOSystem* _pIOHandler) aiScene* _pScene, IOSystem* _pIOHandler)
{ {
pScene = _pScene; pScene = _pScene;
pIOHandler = _pIOHandler; mIOHandler = _pIOHandler;
std::unique_ptr<IOStream> file( pIOHandler->Open( pFile)); std::unique_ptr<IOStream> file(mIOHandler->Open(pFile));
// Check whether we can read from the file // Check whether we can read from the file
if( file.get() == NULL) if( file.get() == nullptr)
throw DeadlyImportError( "Failed to open HMP file " + pFile + "."); throw DeadlyImportError( "Failed to open HMP file " + pFile + ".");
// Check whether the HMP file is large enough to contain // Check whether the HMP file is large enough to contain

View File

@ -185,9 +185,11 @@ void AnimResolver::UpdateAnimRangeSetup()
for (unsigned int i = 0; i < num; ++i) { for (unsigned int i = 0; i < num; ++i) {
m = n+old_size*(i+1); m = n+old_size*(i+1);
std::copy(n,n+old_size,m); std::copy(n,n+old_size,m);
const bool res = ((*it).pre == LWO::PrePostBehaviour_Oscillate);
if ((*it).pre == LWO::PrePostBehaviour_Oscillate && (reverse = !reverse)) reverse = !reverse;
if (res && reverse ) {
std::reverse(m,m+old_size-1); std::reverse(m,m+old_size-1);
}
} }
// update time values // update time values
@ -533,7 +535,7 @@ void AnimResolver::GetKeys(std::vector<aiVectorKey>& out,
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Extract animation channel // Extract animation channel
void AnimResolver::ExtractAnimChannel(aiNodeAnim** out, unsigned int flags /*= 0*/) void AnimResolver::ExtractAnimChannel(aiNodeAnim** out, unsigned int /*= 0*/)
{ {
*out = NULL; *out = NULL;

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2020, assimp team Copyright (c) 2006-2020, assimp team
All rights reserved. All rights reserved.
Redistribution and use of this software in source and binary forms, Redistribution and use of this software in source and binary forms,
@ -58,7 +57,6 @@ struct aiTexture;
namespace Assimp { namespace Assimp {
using namespace MDL; using namespace MDL;
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
@ -436,7 +434,7 @@ protected:
unsigned int iGSFileVersion; unsigned int iGSFileVersion;
/** Output I/O handler. used to load external lmp files */ /** Output I/O handler. used to load external lmp files */
IOSystem* pIOHandler; IOSystem* mIOHandler;
/** Output scene to be filled */ /** Output scene to be filled */
aiScene* pScene; aiScene* pScene;

View File

@ -561,7 +561,8 @@ uint32_t Assimp::ComputeMaterialHash(const aiMaterial* mat, bool includeMatName
// Exclude all properties whose first character is '?' from the hash // Exclude all properties whose first character is '?' from the hash
// See doc for aiMaterialProperty. // See doc for aiMaterialProperty.
if ((prop = mat->mProperties[i]) && (includeMatName || prop->mKey.data[0] != '?')) { prop = mat->mProperties[ i ];
if ( nullptr != prop && (includeMatName || prop->mKey.data[0] != '?')) {
hash = SuperFastHash(prop->mKey.data,(unsigned int)prop->mKey.length,hash); hash = SuperFastHash(prop->mKey.data,(unsigned int)prop->mKey.length,hash);
hash = SuperFastHash(prop->mData,prop->mDataLength,hash); hash = SuperFastHash(prop->mData,prop->mDataLength,hash);

View File

@ -575,8 +575,9 @@ void SplitLargeMeshesProcess_Vertex::SplitMesh(
for (unsigned int k = 0; k < pMesh->mNumBones;++k) { for (unsigned int k = 0; k < pMesh->mNumBones;++k) {
// check whether the bone is existing // check whether the bone is existing
BoneWeightList* pcWeightList; BoneWeightList* pcWeightList;
if ((pcWeightList = (BoneWeightList*)pcMesh->mBones[k])) { pcWeightList = (BoneWeightList *)pcMesh->mBones[k];
aiBone* pcOldBone = pMesh->mBones[k]; if (nullptr != pcWeightList) {
aiBone *pcOldBone = pMesh->mBones[k];
aiBone* pcOut( nullptr ); aiBone* pcOut( nullptr );
*ppCurrent++ = pcOut = new aiBone(); *ppCurrent++ = pcOut = new aiBone();
pcOut->mName = aiString(pcOldBone->mName); pcOut->mName = aiString(pcOldBone->mName);

View File

@ -125,7 +125,8 @@ void TextureTransformStep::PreProcessUVTransform(STransformVecInfo& info)
* type (e.g. if mirroring is active there IS a difference between * type (e.g. if mirroring is active there IS a difference between
* offset 2 and 3) * offset 2 and 3)
*/ */
if ((rounded = (int)info.mTranslation.x)) { rounded = (int)info.mTranslation.x;
if (rounded) {
float out = 0.0f; float out = 0.0f;
szTemp[0] = 0; szTemp[0] = 0;
if (aiTextureMapMode_Wrap == info.mapU) { if (aiTextureMapMode_Wrap == info.mapU) {
@ -158,7 +159,8 @@ void TextureTransformStep::PreProcessUVTransform(STransformVecInfo& info)
* type (e.g. if mirroring is active there IS a difference between * type (e.g. if mirroring is active there IS a difference between
* offset 2 and 3) * offset 2 and 3)
*/ */
if ((rounded = (int)info.mTranslation.y)) { rounded = (int)info.mTranslation.y;
if (rounded) {
float out = 0.0f; float out = 0.0f;
szTemp[0] = 0; szTemp[0] = 0;
if (aiTextureMapMode_Wrap == info.mapV) { if (aiTextureMapMode_Wrap == info.mapV) {