You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-30 16:26:50 +00:00
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.
This commit is contained in:
@@ -145,19 +145,33 @@ std::string PeekPropertyName(const Element &element) {
|
||||
} // namespace
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
PropertyTable::PropertyTable() {
|
||||
PropertyTable::PropertyTable() :
|
||||
element(nullptr) {
|
||||
}
|
||||
|
||||
// Is used when dealing with FBX Objects not metadata.
|
||||
PropertyTable::PropertyTable(const ElementPtr element) :
|
||||
element(element) {
|
||||
Setup(element);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
PropertyTable::PropertyTable(const PropertyTable *templateProps) :
|
||||
templateProps(templateProps), element() {
|
||||
PropertyTable::~PropertyTable() {
|
||||
for (PropertyMap::value_type &v : props) {
|
||||
delete v.second;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
PropertyTable::PropertyTable(const ElementPtr element, const PropertyTable *templateProps) :
|
||||
templateProps(templateProps), element(element) {
|
||||
const ScopePtr scope = GetRequiredScope(element);
|
||||
ERR_FAIL_COND(!scope);
|
||||
void PropertyTable::Setup(ElementPtr ptr) {
|
||||
const ScopePtr sc = GetRequiredScope(ptr);
|
||||
const ElementPtr Properties70 = sc->GetElement("Properties70");
|
||||
const ScopePtr scope = GetOptionalScope(Properties70);
|
||||
|
||||
// no scope, no care.
|
||||
if (!scope) {
|
||||
return; // NOTE: this is not an error this is actually a Object, without properties, here we will nullptr it.
|
||||
}
|
||||
|
||||
for (const ElementMap::value_type &v : scope->Elements()) {
|
||||
if (v.first != "P") {
|
||||
DOMWarning("expected only P elements in property table", v.second);
|
||||
@@ -181,13 +195,6 @@ PropertyTable::PropertyTable(const ElementPtr element, const PropertyTable *temp
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
PropertyTable::~PropertyTable() {
|
||||
for (PropertyMap::value_type &v : props) {
|
||||
delete v.second;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
PropertyPtr PropertyTable::Get(const std::string &name) const {
|
||||
PropertyMap::const_iterator it = props.find(name);
|
||||
@@ -203,10 +210,6 @@ PropertyPtr PropertyTable::Get(const std::string &name) const {
|
||||
|
||||
if (it == props.end()) {
|
||||
// check property template
|
||||
if (templateProps) {
|
||||
return templateProps->Get(name);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user