From ac53416289fa272f65dfdfd68dd23a492a6cda62 Mon Sep 17 00:00:00 2001 From: Paolo Cignoni Date: Sun, 9 Sep 2018 11:35:54 +0200 Subject: [PATCH] Cleaned the ofbx.cpp file to make it c++11 --- .../trimesh_import_fbx/trimesh_import_fbx.pro | 2 +- wrap/openfbx/src/ofbx.cpp | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) mode change 100755 => 100644 wrap/openfbx/src/ofbx.cpp diff --git a/apps/sample/trimesh_import_fbx/trimesh_import_fbx.pro b/apps/sample/trimesh_import_fbx/trimesh_import_fbx.pro index df5bedee..48864523 100644 --- a/apps/sample/trimesh_import_fbx/trimesh_import_fbx.pro +++ b/apps/sample/trimesh_import_fbx/trimesh_import_fbx.pro @@ -4,5 +4,5 @@ SOURCES += trimesh_import_fbx.cpp \ ../../../wrap/openfbx/src/ofbx.cpp \ ../../../wrap/openfbx/src/miniz.c -CONFIG += c++14 +CONFIG += c++11 diff --git a/wrap/openfbx/src/ofbx.cpp b/wrap/openfbx/src/ofbx.cpp old mode 100755 new mode 100644 index 52dd9d33..a6e23236 --- a/wrap/openfbx/src/ofbx.cpp +++ b/wrap/openfbx/src/ofbx.cpp @@ -512,7 +512,7 @@ static OptionalError readProperty(Cursor* cursor) { if (cursor->current == cursor->end) return Error("Reading past the end"); - std::unique_ptr prop = std::make_unique(); + std::unique_ptr prop(new Property()); prop->next = nullptr; prop->type = *cursor->current; ++cursor->current; @@ -566,19 +566,20 @@ static void deleteElement(Element* el) { if (!el) return; - delete el->first_property; - deleteElement(el->child); Element* iter = el; - // do not use recursion to avoid stack overflow + // do not use recursion to delete siblings to avoid stack overflow do { Element* next = iter->sibling; + delete iter->first_property; + deleteElement(iter->child); delete iter; iter = next; } while (iter); } + static OptionalError readElementOffset(Cursor* cursor, u16 version) { if (version >= 7500) @@ -716,7 +717,7 @@ static DataView readTextToken(Cursor* cursor) static OptionalError readTextProperty(Cursor* cursor) { - std::unique_ptr prop = std::make_unique(); + std::unique_ptr prop(new Property()); prop->value.is_binary = false; prop->next = nullptr; if (*cursor->current == '"') @@ -1583,7 +1584,7 @@ template static OptionalError parse(const Scene& scene, co static OptionalError parseCluster(const Scene& scene, const Element& element) { - std::unique_ptr obj = std::make_unique(scene, element); + std::unique_ptr obj(new ClusterImpl(scene, element)); const Element* transform_link = findChild(element, "TransformLink"); if (transform_link && transform_link->first_property) @@ -2017,7 +2018,7 @@ template static void remap(std::vector* out, const std::vector parseAnimationCurve(const Scene& scene, const Element& element) { - std::unique_ptr curve = std::make_unique(scene, element); + std::unique_ptr curve(new AnimationCurveImpl(scene, element)); const Element* times = findChild(element, "KeyTime"); const Element* values = findChild(element, "KeyValueFloat"); @@ -2087,7 +2088,7 @@ static OptionalError parseGeometry(const Scene& scene, const Element& e const Element* polys_element = findChild(element, "PolygonVertexIndex"); if (!polys_element || !polys_element->first_property) return Error("Indices missing"); - std::unique_ptr geom = std::make_unique(scene, element); + std::unique_ptr geom(new GeometryImpl(scene, element)); std::vector vertices; if (!parseDoubleVecData(*vertices_element->first_property, &vertices)) return Error("Failed to parse vertices"); @@ -2917,7 +2918,7 @@ Object* Object::getParent() const IScene* load(const u8* data, int size) { - std::unique_ptr scene = std::make_unique(); + std::unique_ptr scene(new Scene()); scene->m_data.resize(size); memcpy(&scene->m_data[0], data, size); OptionalError root = tokenize(&scene->m_data[0], size);