From b58006441492de8934328cac3f5bb040b2f80713 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sat, 27 Jan 2018 17:11:19 +0200 Subject: [PATCH 01/22] 3DS: Add Mesh constructor with takes name --- code/3DSHelper.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/code/3DSHelper.h b/code/3DSHelper.h index 150eb27b6..21ef6f5e9 100644 --- a/code/3DSHelper.h +++ b/code/3DSHelper.h @@ -505,6 +505,14 @@ struct Mesh : public MeshWithSmoothingGroups mName = szTemp; } + + //! Constructor with explicit name + explicit Mesh(const std::string &name) + : mName(name) + { + } + + //! Name of the mesh std::string mName; From 93fa3732060488a9692838c191f6b0586f243b55 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sat, 27 Jan 2018 17:15:58 +0200 Subject: [PATCH 02/22] 3DS: Pass name to Mesh constructor --- code/3DSLoader.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/code/3DSLoader.cpp b/code/3DSLoader.cpp index d003fec4a..73bfba748 100644 --- a/code/3DSLoader.cpp +++ b/code/3DSLoader.cpp @@ -402,11 +402,7 @@ void Discreet3DSImporter::ParseChunk(const char* name, unsigned int num) case Discreet3DS::CHUNK_TRIMESH: { // this starts a new triangle mesh - mScene->mMeshes.push_back(D3DS::Mesh()); - D3DS::Mesh& m = mScene->mMeshes.back(); - - // Setup the name of the mesh - m.mName = std::string(name, num); + mScene->mMeshes.push_back(D3DS::Mesh(std::string(name, num))); // Read mesh chunks ParseMeshChunk(); From 8c219c7bd1b419cde7982b0ab03f12af0337be67 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sat, 27 Jan 2018 17:17:31 +0200 Subject: [PATCH 03/22] 3DS: Delete Mesh default constructor --- code/3DSHelper.h | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/code/3DSHelper.h b/code/3DSHelper.h index 21ef6f5e9..eb664a262 100644 --- a/code/3DSHelper.h +++ b/code/3DSHelper.h @@ -494,17 +494,8 @@ struct Material /** Helper structure to represent a 3ds file mesh */ struct Mesh : public MeshWithSmoothingGroups { - //! Default constructor - Mesh() - { - static int iCnt = 0; - - // Generate a default name for the mesh - char szTemp[128]; - ai_snprintf(szTemp, 128, "UNNAMED_%i",iCnt++); - mName = szTemp; - } - + //! Default constructor has been deleted + Mesh() = delete; //! Constructor with explicit name explicit Mesh(const std::string &name) From c0c06093b473fc3d65ebc94b38431875a0876af1 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sat, 27 Jan 2018 17:20:00 +0200 Subject: [PATCH 04/22] 3DS: Whitespace --- code/3DSHelper.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/code/3DSHelper.h b/code/3DSHelper.h index eb664a262..a2498fc2f 100644 --- a/code/3DSHelper.h +++ b/code/3DSHelper.h @@ -549,12 +549,12 @@ struct aiFloatKey /** Helper structure to represent a 3ds file node */ struct Node { - Node(): - mParent(NULL) - , mInstanceNumber(0) - , mHierarchyPos (0) - , mHierarchyIndex (0) - , mInstanceCount (1) + Node() + : mParent(NULL) + , mInstanceNumber(0) + , mHierarchyPos (0) + , mHierarchyIndex (0) + , mInstanceCount (1) { static int iCnt = 0; From 56a19ac492a99fad3a8cee78815b0c90edb86cde Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sat, 27 Jan 2018 17:24:47 +0200 Subject: [PATCH 05/22] 3DS: Add Node constructor which takes name --- code/3DSHelper.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/code/3DSHelper.h b/code/3DSHelper.h index a2498fc2f..e174b94de 100644 --- a/code/3DSHelper.h +++ b/code/3DSHelper.h @@ -568,6 +568,21 @@ struct Node aScalingKeys.reserve (20); } + + explicit Node(const std::string &name) + : mParent(NULL) + , mName(name) + , mInstanceNumber(0) + , mHierarchyPos (0) + , mHierarchyIndex (0) + , mInstanceCount (1) + { + aRotationKeys.reserve (20); + aPositionKeys.reserve (20); + aScalingKeys.reserve (20); + } + + ~Node() { for (unsigned int i = 0; i < mChildren.size();++i) From 6c23b5720815b4e7c22410166eeb6284c4f465c6 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sat, 27 Jan 2018 17:30:01 +0200 Subject: [PATCH 06/22] 3DS: Pass name to Node constructor --- code/3DSLoader.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/code/3DSLoader.cpp b/code/3DSLoader.cpp index 73bfba748..1dd3ad4be 100644 --- a/code/3DSLoader.cpp +++ b/code/3DSLoader.cpp @@ -686,8 +686,7 @@ void Discreet3DSImporter::ParseHierarchyChunk(uint16_t parent) pcNode->mInstanceCount++; instanceNumber = pcNode->mInstanceCount; } - pcNode = new D3DS::Node(); - pcNode->mName = name; + pcNode = new D3DS::Node(name); pcNode->mInstanceNumber = instanceNumber; // There are two unknown values which we can safely ignore From 0d69b15238e70edd4fe2cf74a33c3b97b0cb12cc Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sat, 27 Jan 2018 17:35:03 +0200 Subject: [PATCH 07/22] 3DS: Explicitly pass "UNNAMED" as 3DS root node name --- code/3DSLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/3DSLoader.cpp b/code/3DSLoader.cpp index 1dd3ad4be..17c06f44d 100644 --- a/code/3DSLoader.cpp +++ b/code/3DSLoader.cpp @@ -170,7 +170,7 @@ void Discreet3DSImporter::InternReadFile( const std::string& pFile, // Initialize members mLastNodeIndex = -1; - mCurrentNode = new D3DS::Node(); + mCurrentNode = new D3DS::Node("UNNAMED"); mRootNode = mCurrentNode; mRootNode->mHierarchyPos = -1; mRootNode->mHierarchyIndex = -1; From 3f377e11f5d85694de90959f80efb10c5309644b Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sat, 27 Jan 2018 17:35:44 +0200 Subject: [PATCH 08/22] 3DS: Delete Node default constructor --- code/3DSHelper.h | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/code/3DSHelper.h b/code/3DSHelper.h index e174b94de..c4dbfcc38 100644 --- a/code/3DSHelper.h +++ b/code/3DSHelper.h @@ -549,25 +549,7 @@ struct aiFloatKey /** Helper structure to represent a 3ds file node */ struct Node { - Node() - : mParent(NULL) - , mInstanceNumber(0) - , mHierarchyPos (0) - , mHierarchyIndex (0) - , mInstanceCount (1) - { - static int iCnt = 0; - - // Generate a default name for the node - char szTemp[128]; - ::ai_snprintf(szTemp, 128, "UNNAMED_%i",iCnt++); - mName = szTemp; - - aRotationKeys.reserve (20); - aPositionKeys.reserve (20); - aScalingKeys.reserve (20); - } - + Node() = delete; explicit Node(const std::string &name) : mParent(NULL) From e75f7a596497b16a0e2be6f33ee8ef6d6cfb1e58 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sat, 27 Jan 2018 17:42:36 +0200 Subject: [PATCH 09/22] ASE: Explicitly pass "UNNAMED" as default bone name --- code/ASEParser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ASEParser.cpp b/code/ASEParser.cpp index 79624ad2e..7c1197139 100644 --- a/code/ASEParser.cpp +++ b/code/ASEParser.cpp @@ -1553,7 +1553,7 @@ void Parser::ParseLV3MeshWeightsBlock(ASE::Mesh& mesh) void Parser::ParseLV4MeshBones(unsigned int iNumBones,ASE::Mesh& mesh) { AI_ASE_PARSER_INIT(); - mesh.mBones.resize(iNumBones); + mesh.mBones.resize(iNumBones, Bone("UNNAMED")); while (true) { if ('*' == *filePtr) From 1836b00f5107cc68074d95896db37d91f247087c Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sat, 27 Jan 2018 17:43:04 +0200 Subject: [PATCH 10/22] ASE: Delete Bone default constructor --- code/ASEParser.h | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/code/ASEParser.h b/code/ASEParser.h index 843cec6ab..88fc8dfd7 100644 --- a/code/ASEParser.h +++ b/code/ASEParser.h @@ -168,15 +168,7 @@ struct Face : public FaceWithSmoothingGroup struct Bone { //! Constructor - Bone() - { - static int iCnt = 0; - - // Generate a default name for the bone - char szTemp[128]; - ::ai_snprintf(szTemp, 128, "UNNAMED_%i",iCnt++); - mName = szTemp; - } + Bone() = delete; //! Construction from an existing name explicit Bone( const std::string& name) From 3874720947df842e0ed18fc641de4677130f7948 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sat, 27 Jan 2018 17:59:09 +0200 Subject: [PATCH 11/22] ASE: Add BaseNode constructor which takes name --- code/ASEParser.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/code/ASEParser.h b/code/ASEParser.h index 88fc8dfd7..cfa01b5ad 100644 --- a/code/ASEParser.h +++ b/code/ASEParser.h @@ -264,6 +264,19 @@ struct BaseNode mTargetPosition.x = qnan; } + + //! Construction from an existing name + BaseNode(Type _mType, const std::string &name) + : mType (_mType) + , mName (name) + , mProcessed (false) + { + // Set mTargetPosition to qnan + const ai_real qnan = get_qnan(); + mTargetPosition.x = qnan; + } + + //! Name of the mesh std::string mName; From f3474fb399550b41c377988363ccb048f3458cf9 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sat, 27 Jan 2018 18:03:57 +0200 Subject: [PATCH 12/22] ASE: Add Mesh constructor which takes name --- code/ASEParser.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/code/ASEParser.h b/code/ASEParser.h index cfa01b5ad..71d87b6c3 100644 --- a/code/ASEParser.h +++ b/code/ASEParser.h @@ -321,6 +321,19 @@ struct Mesh : public MeshWithSmoothingGroups, public BaseNode iMaterialIndex = Face::DEFAULT_MATINDEX; } + + //! Construction from an existing name + explicit Mesh(const std::string &name) + : BaseNode (BaseNode::Mesh, name) + , iMaterialIndex(Face::DEFAULT_MATINDEX) + , bSkip (false) + { + // use 2 texture vertex components by default + for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS;++c) + this->mNumUVComponents[c] = 2; + } + + //! List of all texture coordinate sets std::vector amTexCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS]; From 59ab30cb25d24f77825ceaac460f767c433e01fc Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sat, 27 Jan 2018 18:08:52 +0200 Subject: [PATCH 13/22] ASE: Explicitly pass "UNNAMED" as default mesh name --- code/ASEParser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ASEParser.cpp b/code/ASEParser.cpp index 7c1197139..166782d77 100644 --- a/code/ASEParser.cpp +++ b/code/ASEParser.cpp @@ -292,7 +292,7 @@ void Parser::Parse() if (TokenMatch(filePtr,"GEOMOBJECT",10)) { - m_vMeshes.push_back(Mesh()); + m_vMeshes.push_back(Mesh("UNNAMED")); ParseLV1ObjectBlock(m_vMeshes.back()); continue; } From 17f801ae8a510770f2b662f6a06667c16e542474 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sat, 27 Jan 2018 18:09:23 +0200 Subject: [PATCH 14/22] ASE: Delete Mesh default constructor --- code/ASEParser.h | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/code/ASEParser.h b/code/ASEParser.h index 71d87b6c3..cde324216 100644 --- a/code/ASEParser.h +++ b/code/ASEParser.h @@ -308,18 +308,8 @@ struct BaseNode /** Helper structure to represent an ASE file mesh */ struct Mesh : public MeshWithSmoothingGroups, public BaseNode { - //! Constructor. - Mesh() - : BaseNode (BaseNode::Mesh) - , bSkip (false) - { - // use 2 texture vertex components by default - for (unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS;++c) - this->mNumUVComponents[c] = 2; - - // setup the default material index by default - iMaterialIndex = Face::DEFAULT_MATINDEX; - } + //! Default constructor has been deleted + Mesh() = delete; //! Construction from an existing name From f3d702339c24ba456ef00a426a9df5aa53b2b5fb Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sat, 27 Jan 2018 18:14:01 +0200 Subject: [PATCH 15/22] ASE: Add Light constructor which takes name --- code/ASEParser.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/code/ASEParser.h b/code/ASEParser.h index cde324216..4a9fd71fe 100644 --- a/code/ASEParser.h +++ b/code/ASEParser.h @@ -369,6 +369,19 @@ struct Light : public BaseNode { } + + //! Construction from an existing name + explicit Light(const std::string &name) + : BaseNode (BaseNode::Light, name) + , mLightType (OMNI) + , mColor (1.f,1.f,1.f) + , mIntensity (1.f) // light is white by default + , mAngle (45.f) + , mFalloff (0.f) + { + } + + LightType mLightType; aiColor3D mColor; ai_real mIntensity; From 4fd791796cc6eb2af899ae5c1483d60d1580dd1a Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sat, 27 Jan 2018 18:19:17 +0200 Subject: [PATCH 16/22] ASE: Explicitly pass "UNNAMED" as default Light name --- code/ASEParser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ASEParser.cpp b/code/ASEParser.cpp index 166782d77..12023c239 100644 --- a/code/ASEParser.cpp +++ b/code/ASEParser.cpp @@ -308,7 +308,7 @@ void Parser::Parse() if (TokenMatch(filePtr,"LIGHTOBJECT",11)) { - m_vLights.push_back(Light()); + m_vLights.push_back(Light("UNNAMED")); ParseLV1ObjectBlock(m_vLights.back()); continue; } From 039ca38542a8493299bb5d195c1ed1f5d98c1468 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sat, 27 Jan 2018 18:19:44 +0200 Subject: [PATCH 17/22] ASE: Delete Light default constructor --- code/ASEParser.h | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/code/ASEParser.h b/code/ASEParser.h index 4a9fd71fe..352cc0832 100644 --- a/code/ASEParser.h +++ b/code/ASEParser.h @@ -358,17 +358,8 @@ struct Light : public BaseNode DIRECTIONAL }; - //! Constructor. - Light() - : BaseNode (BaseNode::Light) - , mLightType (OMNI) - , mColor (1.f,1.f,1.f) - , mIntensity (1.f) // light is white by default - , mAngle (45.f) - , mFalloff (0.f) - { - } - + //! Default constructor has been deleted + Light() = delete; //! Construction from an existing name explicit Light(const std::string &name) From 945f2bed09510244ca3555d5234329dbf70de6d6 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sat, 27 Jan 2018 18:25:01 +0200 Subject: [PATCH 18/22] ASE: Add Camera constructor which takes name --- code/ASEParser.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/code/ASEParser.h b/code/ASEParser.h index 352cc0832..cb5a30af5 100644 --- a/code/ASEParser.h +++ b/code/ASEParser.h @@ -400,6 +400,18 @@ struct Camera : public BaseNode { } + + //! Construction from an existing name + explicit Camera(const std::string &name) + : BaseNode (BaseNode::Camera, name) + , mFOV (0.75f) // in radians + , mNear (0.1f) + , mFar (1000.f) // could be zero + , mCameraType (FREE) + { + } + + ai_real mFOV, mNear, mFar; CameraType mCameraType; }; From 7fef5e6d2319ac064a40f8c9a227cfc0e66d7dd1 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sat, 27 Jan 2018 18:27:41 +0200 Subject: [PATCH 19/22] ASE: Explicitly pass "UNNAMED" as default camera name --- code/ASEParser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ASEParser.cpp b/code/ASEParser.cpp index 12023c239..7d361b6f7 100644 --- a/code/ASEParser.cpp +++ b/code/ASEParser.cpp @@ -315,7 +315,7 @@ void Parser::Parse() // camera object if (TokenMatch(filePtr,"CAMERAOBJECT",12)) { - m_vCameras.push_back(Camera()); + m_vCameras.push_back(Camera("UNNAMED")); ParseLV1ObjectBlock(m_vCameras.back()); continue; } From 2d1bd1eec4f2f1b02e5b1dcf1aebe5ea4e64adb6 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sat, 27 Jan 2018 18:29:29 +0200 Subject: [PATCH 20/22] ASE: Delete Camera default constructor --- code/ASEParser.h | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/code/ASEParser.h b/code/ASEParser.h index cb5a30af5..c80342ece 100644 --- a/code/ASEParser.h +++ b/code/ASEParser.h @@ -390,15 +390,8 @@ struct Camera : public BaseNode TARGET }; - //! Constructor - Camera() - : BaseNode (BaseNode::Camera) - , mFOV (0.75f) // in radians - , mNear (0.1f) - , mFar (1000.f) // could be zero - , mCameraType (FREE) - { - } + //! Default constructor has been deleted + Camera() = delete; //! Construction from an existing name From 4b20e9712ccadff3c3d0d4ca1b06b6a53ef08c01 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sat, 27 Jan 2018 18:33:15 +0200 Subject: [PATCH 21/22] ASE: Explicitly pass "DUMMY" as Dummy node name --- code/ASEParser.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ASEParser.h b/code/ASEParser.h index c80342ece..8d0db71e0 100644 --- a/code/ASEParser.h +++ b/code/ASEParser.h @@ -415,7 +415,7 @@ struct Dummy : public BaseNode { //! Constructor Dummy() - : BaseNode (BaseNode::Dummy) + : BaseNode (BaseNode::Dummy, "DUMMY") { } }; From e0cbd92da4c9bcaed287bc2998948eecbb1f5d63 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sat, 27 Jan 2018 18:34:04 +0200 Subject: [PATCH 22/22] ASE: Delete BaseNode constructor which doesn't take name --- code/ASEParser.h | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/code/ASEParser.h b/code/ASEParser.h index 8d0db71e0..7c8e1b158 100644 --- a/code/ASEParser.h +++ b/code/ASEParser.h @@ -248,22 +248,6 @@ struct BaseNode { enum Type {Light, Camera, Mesh, Dummy} mType; - //! Constructor. Creates a default name for the node - explicit BaseNode(Type _mType) - : mType (_mType) - , mProcessed (false) - { - // generate a default name for the node - static int iCnt = 0; - char szTemp[128]; // should be sufficiently large - ::ai_snprintf(szTemp, 128, "UNNAMED_%i",iCnt++); - mName = szTemp; - - // Set mTargetPosition to qnan - const ai_real qnan = get_qnan(); - mTargetPosition.x = qnan; - } - //! Construction from an existing name BaseNode(Type _mType, const std::string &name)