diff --git a/external/openfbx/ofbx.cpp b/external/openfbx/ofbx.cpp index 00b8b91199..75911bae8b 100644 --- a/external/openfbx/ofbx.cpp +++ b/external/openfbx/ofbx.cpp @@ -30,6 +30,12 @@ static int codeIndex(int idx, bool last) return last ? (-idx - 1) : idx; } +template +static T& emplace_back(std::vector& vec) { + vec.emplace_back(); + return vec.back(); +} + struct Allocator { struct Page { struct { @@ -432,7 +438,7 @@ struct ParseDataJob { }; template [[nodiscard]] bool pushJob(std::vector& jobs, Property& prop, std::vector& data) { - ParseDataJob& job = jobs.emplace_back(); + ParseDataJob& job = emplace_back(jobs); job.property = ∝ job.data = (void*)&data; job.f = [](Property* prop, void* data){ return parseVecData(*prop, (std::vector*)data); }; @@ -1207,7 +1213,7 @@ struct GeometryDataImpl : GeometryData { bool postprocess() { if (materials.empty()) { - GeometryPartitionImpl& partition = partitions.emplace_back(); + GeometryPartitionImpl& partition = emplace_back(partitions); int polygon_count = 0; for (int i : positions.indices) { if (i < 0) ++polygon_count;