From 58d57d33044bb93d4bb22d83806600c9c78fb7a5 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 24 Aug 2012 20:20:12 +0200 Subject: [PATCH] Changed: #1440 Simplify --HG-- branch : build_pipeline_v3 --- .../tools/pipeline/max/builtin/node_impl.cpp | 20 ++------- .../pipeline/max/builtin/track_view_node.cpp | 41 +++++-------------- .../pipeline/max/builtin/track_view_node.h | 4 +- code/nel/tools/pipeline/max/scene.cpp | 4 +- code/nel/tools/pipeline/max/scene_class.h | 24 +++++++++++ code/nel/tools/pipeline/max_dump/main.cpp | 4 +- 6 files changed, 44 insertions(+), 53 deletions(-) diff --git a/code/nel/tools/pipeline/max/builtin/node_impl.cpp b/code/nel/tools/pipeline/max/builtin/node_impl.cpp index a23024809..ce9eb7ab3 100644 --- a/code/nel/tools/pipeline/max/builtin/node_impl.cpp +++ b/code/nel/tools/pipeline/max/builtin/node_impl.cpp @@ -68,10 +68,7 @@ void CNodeImpl::parse(uint16 version) INode::parse(version); if (!m_ChunksOwnsPointers) { - CStorageValue *nodeVersion = static_cast *>(getChunk(PMB_NODE_VERSION_CHUNK_ID)); - nlassert(nodeVersion); - m_NodeVersion = nodeVersion->Value; - m_ArchivedChunks.push_back(nodeVersion); + m_NodeVersion = getChunkValue(PMB_NODE_VERSION_CHUNK_ID); CStorageArray *parent = static_cast *>(getChunk(PMB_NODE_PARENT_CHUNK_ID)); nlassert(parent); @@ -81,10 +78,7 @@ void CNodeImpl::parse(uint16 version) m_ParentFlags = parent->Value[1]; m_ArchivedChunks.push_back(parent); - CStorageValue *userName = static_cast *>(getChunk(PMB_NODE_NAME_CHUNK_ID)); - nlassert(userName); - m_UserName = userName->Value; - m_ArchivedChunks.push_back(userName); + m_UserName = getChunkValue(PMB_NODE_NAME_CHUNK_ID); } } @@ -97,10 +91,7 @@ void CNodeImpl::build(uint16 version) { INode::build(version); - CStorageValue *nodeVersion = new CStorageValue(); - nodeVersion->Value = m_NodeVersion; - m_ArchivedChunks.push_back(nodeVersion); - putChunk(PMB_NODE_VERSION_CHUNK_ID, nodeVersion); + putChunkValue(PMB_NODE_VERSION_CHUNK_ID, m_NodeVersion); CStorageArray *parent = new CStorageArray(); parent->Value.resize(2); @@ -109,10 +100,7 @@ void CNodeImpl::build(uint16 version) m_ArchivedChunks.push_back(parent); putChunk(PMB_NODE_PARENT_CHUNK_ID, parent); - CStorageValue *userName = new CStorageValue(); - userName->Value = m_UserName; - m_ArchivedChunks.push_back(userName); - putChunk(PMB_NODE_NAME_CHUNK_ID, userName); + putChunkValue(PMB_NODE_NAME_CHUNK_ID, m_UserName); } void CNodeImpl::disown() diff --git a/code/nel/tools/pipeline/max/builtin/track_view_node.cpp b/code/nel/tools/pipeline/max/builtin/track_view_node.cpp index b0d431b8b..e21b3b3f7 100644 --- a/code/nel/tools/pipeline/max/builtin/track_view_node.cpp +++ b/code/nel/tools/pipeline/max/builtin/track_view_node.cpp @@ -48,7 +48,7 @@ namespace BUILTIN { #define PMB_TVNODE_DISPLAYNAME_CHUNK_ID 0x0110 #define PMB_TVNODE_IDENTIFIER_CHUNK_ID 0x0120 -#define PMB_TVNODE_INTEGER0130_CHUNK_ID 0x0130 /* type? */ +#define PMB_TVNODE_ISNOTNODE_CHUNK_ID 0x0130 CTrackViewNode::CTrackViewNode(CScene *scene) : CReferenceTarget(scene), m_Empty0140(NULL), m_Empty0150(NULL) { @@ -80,20 +80,9 @@ void CTrackViewNode::parse(uint16 version) // Read child nodes for (std::vector::size_type i = 0; i < m_Children.size(); ++i) { - CStorageValue *displayName = static_cast *>(getChunk(PMB_TVNODE_DISPLAYNAME_CHUNK_ID)); - nlassert(displayName); - m_ArchivedChunks.push_back(displayName); - m_Children[i].DisplayName = displayName->Value; - - CStorageValue *identifier = static_cast *>(getChunk(PMB_TVNODE_IDENTIFIER_CHUNK_ID)); - nlassert(identifier); - m_ArchivedChunks.push_back(identifier); - m_Children[i].Identifier = identifier->Value; - - CStorageValue *integer0130 = static_cast *>(getChunk(PMB_TVNODE_INTEGER0130_CHUNK_ID)); - nlassert(integer0130); - m_ArchivedChunks.push_back(integer0130); - m_Children[i].Integer0130 = integer0130->Value; + m_Children[i].DisplayName = getChunkValue(PMB_TVNODE_DISPLAYNAME_CHUNK_ID); + m_Children[i].Identifier = getChunkValue(PMB_TVNODE_IDENTIFIER_CHUNK_ID); + m_Children[i].IsNotAnotherNode = getChunkValue(PMB_TVNODE_ISNOTNODE_CHUNK_ID); } } } @@ -114,25 +103,15 @@ void CTrackViewNode::build(uint16 version) // Write child nodes for (std::vector::size_type i = 0; i < m_Children.size(); ++i) { - CStorageValue *displayName = new CStorageValue(); - displayName->Value = m_Children[i].DisplayName; - m_ArchivedChunks.push_back(displayName); - putChunk(PMB_TVNODE_DISPLAYNAME_CHUNK_ID, displayName); - - CStorageValue *identifier = new CStorageValue(); - identifier->Value = m_Children[i].Identifier; - m_ArchivedChunks.push_back(identifier); - putChunk(PMB_TVNODE_IDENTIFIER_CHUNK_ID, identifier); - - CStorageValue *integer0130 = new CStorageValue(); - integer0130->Value = m_Children[i].Integer0130; - m_ArchivedChunks.push_back(integer0130); - putChunk(PMB_TVNODE_INTEGER0130_CHUNK_ID, integer0130); + putChunkValue(PMB_TVNODE_DISPLAYNAME_CHUNK_ID, m_Children[i].DisplayName); + putChunkValue(PMB_TVNODE_IDENTIFIER_CHUNK_ID, m_Children[i].Identifier); + putChunkValue(PMB_TVNODE_ISNOTNODE_CHUNK_ID, m_Children[i].IsNotAnotherNode); } } void CTrackViewNode::disown() { + m_Children.clear(); CReferenceTarget::disown(); } @@ -171,7 +150,7 @@ void CTrackViewNode::toStringLocal(std::ostream &ostream, const std::string &pad } ostream << "> "; ostream << "(" << ucstring(referenceMaker->classDesc()->displayName()).toUtf8() << ", " << referenceMaker->classDesc()->classId().toString() << ") "; - ostream << "(" << m_Children[i].DisplayName.toUtf8() << ", " << m_Children[i].Identifier.toString() << ", " << m_Children[i].Integer0130 << ") "; + ostream << "(" << m_Children[i].DisplayName.toUtf8() << ", " << m_Children[i].Identifier.toString() << ", " << (m_Children[i].IsNotAnotherNode ? "ENTRY" : "TVNODE") << ") "; } } @@ -200,7 +179,7 @@ IStorageObject *CTrackViewNode::createChunkById(uint16 id, bool container) return new CStorageValue(); case PMB_TVNODE_IDENTIFIER_CHUNK_ID: return new CStorageValue(); - case PMB_TVNODE_INTEGER0130_CHUNK_ID: + case PMB_TVNODE_ISNOTNODE_CHUNK_ID: return new CStorageValue(); } return CReferenceTarget::createChunkById(id, container); diff --git a/code/nel/tools/pipeline/max/builtin/track_view_node.h b/code/nel/tools/pipeline/max/builtin/track_view_node.h index 9300f4af2..e2a1b0f2d 100644 --- a/code/nel/tools/pipeline/max/builtin/track_view_node.h +++ b/code/nel/tools/pipeline/max/builtin/track_view_node.h @@ -51,11 +51,11 @@ class CTrackViewNode : public CReferenceTarget public: struct TChild { - TChild() : Integer0130(0) { } + TChild() : IsNotAnotherNode(0) { } NLMISC::CRefPtr Reference; ucstring DisplayName; NLMISC::CClassId Identifier; - sint32 Integer0130; + sint32 IsNotAnotherNode; }; CTrackViewNode(CScene *scene); diff --git a/code/nel/tools/pipeline/max/scene.cpp b/code/nel/tools/pipeline/max/scene.cpp index 71086dd04..60f0b5fe8 100644 --- a/code/nel/tools/pipeline/max/scene.cpp +++ b/code/nel/tools/pipeline/max/scene.cpp @@ -199,9 +199,9 @@ IStorageObject *CSceneClassContainer::createChunkById(uint16 id, bool container) { // Known unknown special identifiers... case 0x2032: - return m_SceneClassRegistry->createUnknown(m_Scene, 0x0, NLMISC::CClassId(0x29263a68, 0x405f22f5), ucstring("Unknown 0x2032"), ucstring("0x2032_0x2033_dll"), ucstring("Not part of the dll directory!")); + return m_SceneClassRegistry->createUnknown(m_Scene, 0x0, NLMISC::CClassId(0x29263a68, 0x405f22f5), ucstring("OSM Derived"), ucstring("Internal"), ucstring("Internal")); case 0x2033: - return m_SceneClassRegistry->createUnknown(m_Scene, 0x0, NLMISC::CClassId(0x4ec13906, 0x5578130e), ucstring("Unknown 0x2033"), ucstring("0x2032_0x2033_dll"), ucstring("Not part of the dll directory!")); + return m_SceneClassRegistry->createUnknown(m_Scene, 0x0, NLMISC::CClassId(0x4ec13906, 0x5578130e), ucstring("WSM Derived"), ucstring("Internal"), ucstring("Internal")); // return new CSceneClass(m_Scene); // TODO: Make dummy dllentry and classentry for these... // return static_cast(new CSceneClassUnknown(dllEntry, classEntry)); } diff --git a/code/nel/tools/pipeline/max/scene_class.h b/code/nel/tools/pipeline/max/scene_class.h index a6f67583f..83c335a50 100644 --- a/code/nel/tools/pipeline/max/scene_class.h +++ b/code/nel/tools/pipeline/max/scene_class.h @@ -138,6 +138,12 @@ protected: IStorageObject *getChunk(uint16 id); /// Use during file build. Adds a chunk to the chunks that will be written to the file. Build is called when a chunk is passed through void putChunk(uint16 id, IStorageObject *storageObject); + /// Same as getChunk but for lazy programmers, must use together with putChunkValue + template + const T &getChunkValue(uint16 id); + /// Same as putChunk but for lazy programmers, must use together with getChunkValue + template + void putChunkValue(uint16 id, const T &value); //@} protected: @@ -154,6 +160,24 @@ private: }; /* class CSceneClass */ +template +const T &CSceneClass::getChunkValue(uint16 id) +{ + CStorageValue *chunk = static_cast *>(getChunk(id)); + if (!chunk) { nlerror("Try to get required chunk value 0x%x but it does not exist, bad file format"); } + m_ArchivedChunks.push_back(chunk); + return chunk->Value; +} + +template +void CSceneClass::putChunkValue(uint16 id, const T &value) +{ + CStorageValue *chunk = new CStorageValue(); + chunk->Value = value; + m_ArchivedChunks.push_back(chunk); + putChunk(id, chunk); +} + /** * \brief ISceneClassDesc * \date 2012-08-19 19:25GMT diff --git a/code/nel/tools/pipeline/max_dump/main.cpp b/code/nel/tools/pipeline/max_dump/main.cpp index 9df80bef2..b3a9d254a 100644 --- a/code/nel/tools/pipeline/max_dump/main.cpp +++ b/code/nel/tools/pipeline/max_dump/main.cpp @@ -33,8 +33,8 @@ #include "../max/builtin/scene_impl.h" #include "../max/builtin/i_node.h" -static const char *filename = "/srv/work/database/interfaces/anims_max/cp_fy_hof_species.max"; -//static const char *filename = "/home/kaetemi/source/minimax/GE_Acc_MikotoBaniere.max"; +//static const char *filename = "/srv/work/database/interfaces/anims_max/cp_fy_hof_species.max"; +static const char *filename = "/home/kaetemi/source/minimax/GE_Acc_MikotoBaniere.max"; //static const char *filename = "/home/kaetemi/3dsMax/scenes/test2008.max"; //static const char *filename = "/home/kaetemi/3dsMax/scenes/teapot_test_scene.max"; static const char *streamname = "Scene";