diff options
author | Gordon MacPherson <gordon@gordonite.tech> | 2021-03-30 02:33:06 +0100 |
---|---|---|
committer | Gordon MacPherson <gordon@gordonite.tech> | 2021-04-15 05:54:50 +0100 |
commit | 061b77e5e6c6e3f446734bf214e395e7e6f1a4b4 (patch) | |
tree | 809e3660221e0bc6d9bb119d0fa8591c3bbdb233 /modules/fbx/fbx_parser/FBXProperties.h | |
parent | a86e7c3bb7d9238e664be8a7c63d1cc19bde0d8c (diff) |
This stops using FBXPropertyTable as a pointer.
The base object will inherit the property table, for every FBX object, if it doesn't exist it will be ignored.
The previous code was dangerous and not simple to understand, this makes the code simpler and should result in no leaks with PropertyTable.
Features/Fixes:
Adds ability for multiple millions of polygons to be loaded.
Fixes memory leaks with tokens
Fixes memory leaks with property table
Fixes loading some corrupt files
Fixes meshes not having a unique name to the mesh node.
Opens up loading for two more versions: 7100 and 7200, up to 2020.
Preliminary support for Cinema4D files in parser now, before this was not possible it would cause memory corruption, which is gone now.
FBXProperties not being pointers presented simpler challenges in the long run also, fixed a bunch of bugs.
Diffstat (limited to 'modules/fbx/fbx_parser/FBXProperties.h')
-rw-r--r-- | modules/fbx/fbx_parser/FBXProperties.h | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/modules/fbx/fbx_parser/FBXProperties.h b/modules/fbx/fbx_parser/FBXProperties.h index 0595b25fa7..bfd27ac94e 100644 --- a/modules/fbx/fbx_parser/FBXProperties.h +++ b/modules/fbx/fbx_parser/FBXProperties.h @@ -137,36 +137,31 @@ class PropertyTable { public: // in-memory property table with no source element PropertyTable(); - PropertyTable(const PropertyTable *templateProps); - PropertyTable(const ElementPtr element, const PropertyTable *templateProps); - ~PropertyTable(); + PropertyTable(const ElementPtr element); + virtual ~PropertyTable(); PropertyPtr Get(const std::string &name) const; + void Setup(ElementPtr ptr); // PropertyTable's need not be coupled with FBX elements so this can be NULL - ElementPtr GetElement() const { + ElementPtr GetElement() { return element; } - PropertyMap &GetProperties() const { + PropertyMap &GetProperties() { return props; } - const LazyPropertyMap &GetLazyProperties() const { + const LazyPropertyMap &GetLazyProperties() { return lazyProps; } - const PropertyTable *TemplateProps() const { - return templateProps; - } - DirectPropertyMap GetUnparsedProperties() const; private: LazyPropertyMap lazyProps; mutable PropertyMap props; - const PropertyTable *templateProps = nullptr; - const ElementPtr element = nullptr; + ElementPtr element = nullptr; }; // ------------------------------------------------------------------------------------------------ @@ -191,16 +186,11 @@ template <typename T> inline T PropertyGet(const PropertyTable *in, const std::string &name, bool &result, bool useTemplate = false) { PropertyPtr prop = in->Get(name); if (nullptr == prop) { - if (!useTemplate) { - result = false; - return T(); - } - const PropertyTable *templ = in->TemplateProps(); - if (nullptr == templ) { + if (nullptr == in) { result = false; return T(); } - prop = templ->Get(name); + prop = in->Get(name); if (nullptr == prop) { result = false; return T(); |