mirror of https://github.com/AxioDL/metaforce.git
Minor blender exception detection bug fix
This commit is contained in:
parent
88e68e8aa3
commit
72fabc9329
|
@ -1 +1 @@
|
|||
Subproject commit 42581c922a4574f4f34df134a454effa9f9cc8d0
|
||||
Subproject commit ee012692ba6981a5889d38e76e717e2cb0216e57
|
|
@ -1 +1 @@
|
|||
Subproject commit 922fcbb3c23677b3ccc53737fd23ada165ccf9f3
|
||||
Subproject commit 314563614e0e2e2a6f020a423096900e79220119
|
|
@ -45,10 +45,10 @@ class HMDLBuffers;
|
|||
extern logvisor::Module BlenderLog;
|
||||
|
||||
struct PoolSkinIndex {
|
||||
size_t m_poolSz = 0;
|
||||
std::size_t m_poolSz = 0;
|
||||
std::unique_ptr<uint32_t[]> m_poolToSkinIndex;
|
||||
|
||||
void allocate(size_t poolSz) {
|
||||
void allocate(std::size_t poolSz) {
|
||||
m_poolSz = poolSz;
|
||||
if (poolSz)
|
||||
m_poolToSkinIndex.reset(new uint32_t[poolSz]);
|
||||
|
@ -145,15 +145,15 @@ struct Vector4f {
|
|||
};
|
||||
struct Matrix3f {
|
||||
std::array<atVec3f, 3> m;
|
||||
atVec3f& operator[](size_t idx) { return m[idx]; }
|
||||
const atVec3f& operator[](size_t idx) const { return m[idx]; }
|
||||
atVec3f& operator[](std::size_t idx) { return m[idx]; }
|
||||
const atVec3f& operator[](std::size_t idx) const { return m[idx]; }
|
||||
};
|
||||
struct Matrix4f {
|
||||
std::array<atVec4f, 4> val;
|
||||
Matrix4f() = default;
|
||||
Matrix4f(Connection& conn) { read(conn); }
|
||||
void read(Connection& conn);
|
||||
const atVec4f& operator[](size_t idx) const { return val[idx]; }
|
||||
const atVec4f& operator[](std::size_t idx) const { return val[idx]; }
|
||||
};
|
||||
struct Index {
|
||||
uint32_t val;
|
||||
|
@ -289,9 +289,9 @@ struct Material {
|
|||
|
||||
/** Intermediate mesh representation prepared by blender from a single mesh object */
|
||||
struct Mesh {
|
||||
static constexpr size_t MaxColorLayers = 4;
|
||||
static constexpr size_t MaxUVLayers = 8;
|
||||
static constexpr size_t MaxSkinEntries = 16;
|
||||
static constexpr std::size_t MaxColorLayers = 4;
|
||||
static constexpr std::size_t MaxUVLayers = 8;
|
||||
static constexpr std::size_t MaxSkinEntries = 16;
|
||||
|
||||
HMDLTopology topology;
|
||||
|
||||
|
@ -325,10 +325,10 @@ struct Mesh {
|
|||
bool operator==(const SkinBind& other) const { return vg_idx == other.vg_idx && weight == other.weight; }
|
||||
};
|
||||
std::vector<std::array<SkinBind, MaxSkinEntries>> skins;
|
||||
std::vector<size_t> contiguousSkinVertCounts;
|
||||
std::vector<std::size_t> contiguousSkinVertCounts;
|
||||
|
||||
static size_t countSkinBinds(const std::array<SkinBind, MaxSkinEntries>& arr) {
|
||||
size_t ret = 0;
|
||||
static std::size_t countSkinBinds(const std::array<SkinBind, MaxSkinEntries>& arr) {
|
||||
std::size_t ret = 0;
|
||||
for (const auto& b : arr)
|
||||
if (b.valid())
|
||||
++ret;
|
||||
|
@ -553,7 +553,7 @@ struct Armature {
|
|||
std::vector<Bone> bones;
|
||||
const Bone* lookupBone(const char* name) const;
|
||||
const Bone* getParent(const Bone* bone) const;
|
||||
const Bone* getChild(const Bone* bone, size_t child) const;
|
||||
const Bone* getChild(const Bone* bone, std::size_t child) const;
|
||||
const Bone* getRoot() const;
|
||||
Armature(Connection& conn);
|
||||
};
|
||||
|
@ -734,8 +734,8 @@ class Connection {
|
|||
uint32_t _writeStr(const char* str, uint32_t len, int wpipe);
|
||||
uint32_t _writeStr(const char* str, uint32_t len) { return _writeStr(str, len, m_writepipe[1]); }
|
||||
uint32_t _writeStr(std::string_view view) { return _writeStr(view.data(), view.size()); }
|
||||
size_t _readBuf(void* buf, size_t len);
|
||||
size_t _writeBuf(const void* buf, size_t len);
|
||||
std::size_t _readBuf(void* buf, std::size_t len);
|
||||
std::size_t _writeBuf(const void* buf, std::size_t len);
|
||||
std::string _readStdString() {
|
||||
uint32_t bufSz;
|
||||
_readBuf(&bufSz, 4);
|
||||
|
@ -868,14 +868,14 @@ public:
|
|||
|
||||
private:
|
||||
friend struct Mesh;
|
||||
HMDLBuffers(HMDLMeta&& meta, size_t vboSz, const std::vector<atUint32>& iboData, std::vector<Surface>&& surfaces,
|
||||
HMDLBuffers(HMDLMeta&& meta, std::size_t vboSz, const std::vector<atUint32>& iboData, std::vector<Surface>&& surfaces,
|
||||
const Mesh::SkinBanks& skinBanks);
|
||||
|
||||
public:
|
||||
HMDLMeta m_meta;
|
||||
size_t m_vboSz;
|
||||
std::size_t m_vboSz;
|
||||
std::unique_ptr<uint8_t[]> m_vboData;
|
||||
size_t m_iboSz;
|
||||
std::size_t m_iboSz;
|
||||
std::unique_ptr<uint8_t[]> m_iboData;
|
||||
|
||||
struct Surface {
|
||||
|
@ -895,16 +895,16 @@ public:
|
|||
namespace std {
|
||||
template <>
|
||||
struct hash<hecl::blender::Vector2f> {
|
||||
size_t operator()(const hecl::blender::Vector2f& val) const noexcept {
|
||||
size_t h = std::hash<float>()(val.val.simd[0]);
|
||||
std::size_t operator()(const hecl::blender::Vector2f& val) const noexcept {
|
||||
std::size_t h = std::hash<float>()(val.val.simd[0]);
|
||||
hecl::hash_combine_impl(h, std::hash<float>()(val.val.simd[1]));
|
||||
return h;
|
||||
}
|
||||
};
|
||||
template <>
|
||||
struct hash<hecl::blender::Vector3f> {
|
||||
size_t operator()(const hecl::blender::Vector3f& val) const noexcept {
|
||||
size_t h = std::hash<float>()(val.val.simd[0]);
|
||||
std::size_t operator()(const hecl::blender::Vector3f& val) const noexcept {
|
||||
std::size_t h = std::hash<float>()(val.val.simd[0]);
|
||||
hecl::hash_combine_impl(h, std::hash<float>()(val.val.simd[1]));
|
||||
hecl::hash_combine_impl(h, std::hash<float>()(val.val.simd[2]));
|
||||
return h;
|
||||
|
@ -912,8 +912,8 @@ struct hash<hecl::blender::Vector3f> {
|
|||
};
|
||||
template <>
|
||||
struct hash<hecl::blender::Vector4f> {
|
||||
size_t operator()(const hecl::blender::Vector4f& val) const noexcept {
|
||||
size_t h = std::hash<float>()(val.val.simd[0]);
|
||||
std::size_t operator()(const hecl::blender::Vector4f& val) const noexcept {
|
||||
std::size_t h = std::hash<float>()(val.val.simd[0]);
|
||||
hecl::hash_combine_impl(h, std::hash<float>()(val.val.simd[1]));
|
||||
hecl::hash_combine_impl(h, std::hash<float>()(val.val.simd[2]));
|
||||
hecl::hash_combine_impl(h, std::hash<float>()(val.val.simd[3]));
|
||||
|
@ -922,8 +922,8 @@ struct hash<hecl::blender::Vector4f> {
|
|||
};
|
||||
template <>
|
||||
struct hash<array<hecl::blender::Mesh::SkinBind, 16>> {
|
||||
size_t operator()(const array<hecl::blender::Mesh::SkinBind, 16>& val) const noexcept {
|
||||
size_t h = 0;
|
||||
std::size_t operator()(const array<hecl::blender::Mesh::SkinBind, 16>& val) const noexcept {
|
||||
std::size_t h = 0;
|
||||
for (const auto& bind : val) {
|
||||
if (!bind.valid())
|
||||
break;
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
constexpr bool operator!=(uint32_t other) const noexcept { return !operator==(other); }
|
||||
|
||||
std::string toString() const { return std::string(std::begin(fcc), std::end(fcc)); }
|
||||
constexpr std::string_view toStringView() const { return std::string_view(fcc, std::size(fcc)); }
|
||||
constexpr uint32_t toUint32() const noexcept { return num; }
|
||||
constexpr const char* getChars() const noexcept { return fcc; }
|
||||
constexpr char* getChars() noexcept { return fcc; }
|
||||
|
@ -58,10 +59,10 @@ using BigDNA = athena::io::DNA<athena::Endian::Big>;
|
|||
/** FourCC with DNA read/write */
|
||||
class DNAFourCC final : public BigDNA, public FourCC {
|
||||
public:
|
||||
DNAFourCC() : FourCC() {}
|
||||
DNAFourCC(const FourCC& other) : FourCC() { num = other.toUint32(); }
|
||||
DNAFourCC(const char* name) : FourCC(name) {}
|
||||
DNAFourCC(uint32_t n) : FourCC(n) {}
|
||||
constexpr DNAFourCC() : FourCC() {}
|
||||
constexpr DNAFourCC(const FourCC& other) : FourCC() { num = other.toUint32(); }
|
||||
constexpr DNAFourCC(const char* name) : FourCC(name) {}
|
||||
constexpr DNAFourCC(uint32_t n) : FourCC(n) {}
|
||||
AT_DECL_EXPLICIT_DNA_YAML
|
||||
};
|
||||
template <>
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
namespace std {
|
||||
template <>
|
||||
struct hash<std::pair<uint32_t, uint32_t>> {
|
||||
size_t operator()(const std::pair<uint32_t, uint32_t>& val) const noexcept {
|
||||
std::size_t operator()(const std::pair<uint32_t, uint32_t>& val) const noexcept {
|
||||
/* this will potentially truncate the second value if 32-bit size_t,
|
||||
* however, its application here is intended to operate in 16-bit indices */
|
||||
return val.first | (val.second << 16);
|
||||
|
@ -86,7 +86,7 @@ static void InstallAddon(const SystemChar* path) {
|
|||
std::fwrite(HECL_ADDON, 1, HECL_ADDON_SZ, fp.get());
|
||||
}
|
||||
|
||||
static int Read(int fd, void* buf, size_t size) {
|
||||
static int Read(int fd, void* buf, std::size_t size) {
|
||||
int intrCount = 0;
|
||||
do {
|
||||
auto ret = read(fd, buf, size);
|
||||
|
@ -101,7 +101,7 @@ static int Read(int fd, void* buf, size_t size) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
static int Write(int fd, const void* buf, size_t size) {
|
||||
static int Write(int fd, const void* buf, std::size_t size) {
|
||||
int intrCount = 0;
|
||||
do {
|
||||
auto ret = write(fd, buf, size);
|
||||
|
@ -116,6 +116,14 @@ static int Write(int fd, const void* buf, size_t size) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
static std::size_t BoundedStrLen(const char* buf, std::size_t maxLen) {
|
||||
std::size_t ret;
|
||||
for (ret = 0; ret < maxLen; ++ret)
|
||||
if (buf[ret] == '\0')
|
||||
break;
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint32_t Connection::_readStr(char* buf, uint32_t bufSz) {
|
||||
uint32_t readLen;
|
||||
int ret = Read(m_readpipe[0], &readLen, sizeof(readLen));
|
||||
|
@ -138,8 +146,9 @@ uint32_t Connection::_readStr(char* buf, uint32_t bufSz) {
|
|||
}
|
||||
|
||||
constexpr std::string_view exception_str{"EXCEPTION"};
|
||||
if (readLen >= exception_str.size()) {
|
||||
if (exception_str.compare(0, exception_str.size(), buf) == 0) {
|
||||
const std::size_t readStrLen = BoundedStrLen(buf, readLen);
|
||||
if (readStrLen >= exception_str.size()) {
|
||||
if (exception_str.compare(0, exception_str.size(), std::string_view(buf, readStrLen)) == 0) {
|
||||
_blenderDied();
|
||||
return 0;
|
||||
}
|
||||
|
@ -168,14 +177,14 @@ uint32_t Connection::_writeStr(const char* buf, uint32_t len, int wpipe) {
|
|||
return static_cast<uint32_t>(ret);
|
||||
}
|
||||
|
||||
size_t Connection::_readBuf(void* buf, size_t len) {
|
||||
std::size_t Connection::_readBuf(void* buf, std::size_t len) {
|
||||
const auto error = [this] {
|
||||
_blenderDied();
|
||||
return 0U;
|
||||
};
|
||||
|
||||
auto* cBuf = static_cast<uint8_t*>(buf);
|
||||
size_t readLen = 0;
|
||||
std::size_t readLen = 0;
|
||||
|
||||
do {
|
||||
const int ret = Read(m_readpipe[0], cBuf, len);
|
||||
|
@ -184,8 +193,9 @@ size_t Connection::_readBuf(void* buf, size_t len) {
|
|||
}
|
||||
|
||||
constexpr std::string_view exception_str{"EXCEPTION"};
|
||||
if (len >= exception_str.size()) {
|
||||
if (exception_str.compare(0, exception_str.size(), static_cast<char*>(buf)) == 0) {
|
||||
const std::size_t readStrLen = BoundedStrLen(static_cast<char*>(buf), len);
|
||||
if (readStrLen >= exception_str.size()) {
|
||||
if (exception_str.compare(0, exception_str.size(), std::string_view(static_cast<char*>(buf), readStrLen)) == 0) {
|
||||
_blenderDied();
|
||||
}
|
||||
}
|
||||
|
@ -198,14 +208,14 @@ size_t Connection::_readBuf(void* buf, size_t len) {
|
|||
return readLen;
|
||||
}
|
||||
|
||||
size_t Connection::_writeBuf(const void* buf, size_t len) {
|
||||
std::size_t Connection::_writeBuf(const void* buf, std::size_t len) {
|
||||
const auto error = [this] {
|
||||
_blenderDied();
|
||||
return 0U;
|
||||
};
|
||||
|
||||
const auto* cBuf = static_cast<const uint8_t*>(buf);
|
||||
size_t writeLen = 0;
|
||||
std::size_t writeLen = 0;
|
||||
|
||||
do {
|
||||
const int ret = Write(m_writepipe[1], cBuf, len);
|
||||
|
@ -925,9 +935,9 @@ Mesh Mesh::getContiguousSkinningVersion() const {
|
|||
newMesh.norm.clear();
|
||||
newMesh.contiguousSkinVertCounts.clear();
|
||||
newMesh.contiguousSkinVertCounts.reserve(skins.size());
|
||||
for (size_t i = 0; i < skins.size(); ++i) {
|
||||
for (std::size_t i = 0; i < skins.size(); ++i) {
|
||||
std::unordered_map<std::pair<uint32_t, uint32_t>, uint32_t> contigMap;
|
||||
size_t vertCount = 0;
|
||||
std::size_t vertCount = 0;
|
||||
for (Surface& surf : newMesh.surfaces) {
|
||||
for (Surface::Vert& vert : surf.verts) {
|
||||
if (vert.iPos == 0xffffffff)
|
||||
|
@ -1057,7 +1067,7 @@ uint32_t Mesh::SkinBanks::addSurface(const Mesh& mesh, const Surface& surf, int
|
|||
continue;
|
||||
if (!VertInBank(bank.m_skinIdxs, v.iSkin) && !VertInBank(toAdd, v.iSkin)) {
|
||||
toAdd.push_back(v.iSkin);
|
||||
if (skinSlotCount > 0 && bank.m_skinIdxs.size() + toAdd.size() > size_t(skinSlotCount)) {
|
||||
if (skinSlotCount > 0 && bank.m_skinIdxs.size() + toAdd.size() > std::size_t(skinSlotCount)) {
|
||||
toAdd.clear();
|
||||
done = false;
|
||||
break;
|
||||
|
@ -1192,7 +1202,7 @@ const Bone* Armature::getParent(const Bone* bone) const {
|
|||
return &bones[bone->parent];
|
||||
}
|
||||
|
||||
const Bone* Armature::getChild(const Bone* bone, size_t child) const {
|
||||
const Bone* Armature::getChild(const Bone* bone, std::size_t child) const {
|
||||
if (child >= bone->children.size())
|
||||
return nullptr;
|
||||
int32_t cIdx = bone->children[child];
|
||||
|
@ -1692,7 +1702,7 @@ void Token::shutdown() {
|
|||
|
||||
Token::~Token() { shutdown(); }
|
||||
|
||||
HMDLBuffers::HMDLBuffers(HMDLMeta&& meta, size_t vboSz, const std::vector<atUint32>& iboData,
|
||||
HMDLBuffers::HMDLBuffers(HMDLMeta&& meta, std::size_t vboSz, const std::vector<atUint32>& iboData,
|
||||
std::vector<Surface>&& surfaces, const Mesh::SkinBanks& skinBanks)
|
||||
: m_meta(std::move(meta))
|
||||
, m_vboSz(vboSz)
|
||||
|
|
|
@ -269,15 +269,14 @@ static bool RegexSearchLast(const T& str, std::match_results<typename T::const_i
|
|||
static const hecl::SystemRegex regParsedHash32(_SYS_STR(R"(_([0-9a-fA-F]{8}))"),
|
||||
std::regex::ECMAScript | std::regex::optimize);
|
||||
uint32_t ProjectPath::parsedHash32() const {
|
||||
{
|
||||
if (!m_auxInfo.empty()) {
|
||||
hecl::SystemRegexMatch match;
|
||||
if (RegexSearchLast(m_auxInfo, match, regParsedHash32)) {
|
||||
auto hexStr = match[1].str();
|
||||
if (auto val = hecl::StrToUl(hexStr.c_str(), nullptr, 16))
|
||||
return val;
|
||||
}
|
||||
}
|
||||
{
|
||||
} else {
|
||||
hecl::SystemViewRegexMatch match;
|
||||
if (RegexSearchLast(getLastComponent(), match, regParsedHash32)) {
|
||||
auto hexStr = match[1].str();
|
||||
|
|
Loading…
Reference in New Issue