Skip to content

Commit

Permalink
updated openfbx
Browse files Browse the repository at this point in the history
  • Loading branch information
nem0 committed May 6, 2024
1 parent 9facc72 commit 3622547
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 4 additions & 2 deletions external/openfbx/ofbx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,7 @@ struct GeometryDataImpl : GeometryData {
T res = attr;
if (!attr.values.empty() && attr.mapping == VertexDataMapping::BY_VERTEX && attr.indices.empty()) {
res.indices = positions.indices.data();
res.count = int(positions.indices.size());
}
return res;
}
Expand Down Expand Up @@ -2228,7 +2229,7 @@ struct AnimationLayerImpl : AnimationLayer
std::map<std::string, ofbx::IElementProperty*, std::less<>> allProperties;
mapProperties(element, allProperties);
*/
void mapProperties(const ofbx::IElement& parent, std::map<std::string, ofbx::IElementProperty*, std::less<>>& propMap)
void mapProperties(const ofbx::IElement& parent, std::map<std::string, ofbx::IElementProperty*, std::less<std::string>>& propMap)
{
for (const ofbx::IElement* element = parent.getFirstChild(); element; element = element->getSibling())
{
Expand Down Expand Up @@ -3761,6 +3762,7 @@ static bool parseObjects(const Element& root, Scene& scene, u16 flags, Allocator
struct PostprocessJob {
Object* obj;
bool error = false;
PostprocessJob(Object* o) : obj(o) {}
};
std::vector<PostprocessJob> postprocess_jobs;
for (auto iter : scene.m_object_map)
Expand Down Expand Up @@ -4044,7 +4046,7 @@ bool Scene::finalize() {
return true;
}

IScene* load(const u8* data, int size, u16 flags, JobProcessor job_processor, void* job_user_ptr)
IScene* load(const u8* data, usize size, u16 flags, JobProcessor job_processor, void* job_user_ptr)
{
std::unique_ptr<Scene> scene(new Scene());
scene->m_data.resize(size);
Expand Down
14 changes: 12 additions & 2 deletions external/openfbx/ofbx.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ static_assert(sizeof(u32) == 4, "u32 is not 4 bytes");
static_assert(sizeof(u64) == 8, "u64 is not 8 bytes");
static_assert(sizeof(i64) == 8, "i64 is not 8 bytes");

typedef decltype(sizeof(0)) usize;

using JobFunction = void (*)(void*);
using JobProcessor = void (*)(JobFunction, void*, void*, u32, u32);
Expand Down Expand Up @@ -52,7 +53,7 @@ constexpr LoadFlags operator|(LoadFlags lhs, LoadFlags rhs)
return static_cast<LoadFlags>(static_cast<u16>(lhs) | static_cast<u16>(rhs));
}

constexpr LoadFlags& operator|=(LoadFlags& lhs, LoadFlags rhs)
inline LoadFlags& operator|=(LoadFlags& lhs, LoadFlags rhs)
{
return lhs = lhs | rhs;
}
Expand Down Expand Up @@ -495,6 +496,9 @@ struct Vec2Attributes {
const int* indices = nullptr;
int count = 0;

Vec2Attributes() {}
Vec2Attributes(const Vec2* v, const int* i, int c) : values(v), indices(i), count(c) {}

Vec2 get(int i) const { return indices ? values[indices[i]] : values[i]; }
};

Expand All @@ -504,6 +508,9 @@ struct Vec3Attributes {
int count = 0;
int values_count = 0;

Vec3Attributes() {}
Vec3Attributes(const Vec3* v, const int* i, int c, int vc) : values(v), indices(i), count(c), values_count(vc) {}

Vec3 get(int i) const { return indices ? values[indices[i]] : values[i]; }
};

Expand All @@ -512,6 +519,9 @@ struct Vec4Attributes {
const int* indices = nullptr;
int count = 0;

Vec4Attributes() {}
Vec4Attributes(const Vec4* v, const int* i, int c) : values(v), indices(i), count(c) {}

Vec4 get(int i) const { return indices ? values[indices[i]] : values[i]; }
};

Expand Down Expand Up @@ -750,7 +760,7 @@ struct IScene
};


IScene* load(const u8* data, int size, u16 flags, JobProcessor job_processor = nullptr, void* job_user_ptr = nullptr);
IScene* load(const u8* data, usize size, u16 flags, JobProcessor job_processor = nullptr, void* job_user_ptr = nullptr);
const char* getError();
double fbxTimeToSeconds(i64 value);
i64 secondsToFbxTime(double value);
Expand Down

0 comments on commit 3622547

Please sign in to comment.