diff --git a/code/FBXDocument.cpp b/code/FBXDocument.cpp index 2fe90a5c1..1560e2a13 100644 --- a/code/FBXDocument.cpp +++ b/code/FBXDocument.cpp @@ -734,14 +734,15 @@ LazyObject* Document::GetObject(uint64_t id) const return it == objects.end() ? NULL : (*it).second; } +#define MAX_CLASSNAMES 6 // ------------------------------------------------------------------------------------------------ -std::vector Document::GetConnectionsBySourceSequenced(uint64_t source) const +std::vector Document::GetConnectionsSequenced(uint64_t id, const ConnectionMap& conns) const { std::vector temp; const std::pair range = - ConnectionsBySource().equal_range(source); + conns.equal_range(id); temp.reserve(std::distance(range.first,range.second)); for (ConnectionMap::const_iterator it = range.first; it != range.second; ++it) { @@ -755,24 +756,76 @@ std::vector Document::GetConnectionsBySourceSequenced(uint64_ // ------------------------------------------------------------------------------------------------ -std::vector Document::GetConnectionsByDestinationSequenced(uint64_t dest) const +std::vector Document::GetConnectionsSequenced(uint64_t id, const ConnectionMap& conns, const char* const* classnames, size_t count) const { + ai_assert(classnames); + ai_assert(count != 0 && count <= MAX_CLASSNAMES); + + size_t lenghts[MAX_CLASSNAMES]; + + const size_t c = count; + for (size_t i = 0; i < c; ++i) { + lenghts[i] = strlen(classnames[i]); + } + std::vector temp; const std::pair range = - ConnectionsByDestination().equal_range(dest); + conns.equal_range(id); temp.reserve(std::distance(range.first,range.second)); for (ConnectionMap::const_iterator it = range.first; it != range.second; ++it) { + const Token& key = (*it).second->LazyDestinationObject().GetElement().KeyToken(); + const char* obtype = key.begin(); + + for (size_t i = 0; i < c; ++i) { + ai_assert(classnames[i]); + if(!strncmp(classnames[i],obtype,lenghts[i])) { + obtype = NULL; + break; + } + } + + if(obtype) { + continue; + } + temp.push_back((*it).second); } std::sort(temp.begin(), temp.end(), std::mem_fun(&Connection::Compare)); - return temp; // NRVO should handle this } +// ------------------------------------------------------------------------------------------------ +std::vector Document::GetConnectionsBySourceSequenced(uint64_t source) const +{ + return GetConnectionsSequenced(source, ConnectionsBySource()); +} + + +// ------------------------------------------------------------------------------------------------ +std::vector Document::GetConnectionsBySourceSequenced(uint64_t source, const char* const* classnames, size_t count) const +{ + return GetConnectionsSequenced(source, ConnectionsBySource(),classnames, count); +} + + +// ------------------------------------------------------------------------------------------------ +std::vector Document::GetConnectionsByDestinationSequenced(uint64_t dest) const +{ + return GetConnectionsSequenced(dest, ConnectionsByDestination()); +} + + +// ------------------------------------------------------------------------------------------------ +std::vector Document::GetConnectionsByDestinationSequenced(uint64_t dest, const char* const* classnames, size_t count) const +{ + return GetConnectionsSequenced(dest, ConnectionsByDestination(),classnames, count); +} + + // ------------------------------------------------------------------------------------------------ Connection::Connection(uint64_t insertionOrder, uint64_t src, uint64_t dest, const std::string& prop, const Document& doc) : insertionOrder(insertionOrder) diff --git a/code/FBXDocument.h b/code/FBXDocument.h index a2cf8a811..99eff3e32 100644 --- a/code/FBXDocument.h +++ b/code/FBXDocument.h @@ -89,6 +89,14 @@ public: return being_constructed; } + const Element& GetElement() const { + return element; + } + + const Document& GetDocument() const { + return doc; + } + private: const Document& doc; @@ -669,8 +677,16 @@ public: std::vector GetConnectionsBySourceSequenced(uint64_t source) const; std::vector GetConnectionsByDestinationSequenced(uint64_t dest) const; + std::vector GetConnectionsBySourceSequenced(uint64_t source, const char* const* classnames, size_t count) const; + std::vector GetConnectionsByDestinationSequenced(uint64_t dest, const char* const* classnames, size_t count) const; + const std::vector& AnimationStacks() const; +private: + + std::vector GetConnectionsSequenced(uint64_t id, const ConnectionMap&) const; + std::vector GetConnectionsSequenced(uint64_t id, const ConnectionMap&, const char* const* classnames, size_t count) const; + private: void ReadHeader();