2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 13:44:56 +00:00

Various CActorContraption fixes

This commit is contained in:
Jack Andersen
2019-06-14 14:39:20 -10:00
parent 6679f6de72
commit 37307e1cf6
17 changed files with 82 additions and 34 deletions

View File

@@ -37,6 +37,9 @@ size_t ComputeBitstreamSize(size_t keyFrameCount, const std::vector<Channel>& ch
static inline QuantizedRot QuantizeRotation(const Value& quat, atUint32 div) {
float q = M_PIF / 2.0f / float(div);
zeus::simd_floats f(quat.simd);
assert(std::abs(f[1]) <= 1.f && "Out of range quat X component");
assert(std::abs(f[2]) <= 1.f && "Out of range quat Y component");
assert(std::abs(f[3]) <= 1.f && "Out of range quat Z component");
return {{
atInt32(std::asin(f[1]) / q),
atInt32(std::asin(f[2]) / q),

View File

@@ -23,7 +23,9 @@ struct QuantizedValue {
atInt32 delta = std::abs(v[idx] - other.v[idx]);
if (delta == 0)
return 1;
return int(std::ceil(std::log2(delta))) + 1;
int ret = int(std::ceil(std::log2(delta))) + 1;
assert(ret <= 24 && "Bad q value");
return ret;
}
};
struct QuantizedRot {

View File

@@ -597,6 +597,7 @@ ANIM::ANIM(const BlenderAction& act, const std::unordered_map<std::string, atInt
if (sign == 0.f)
sign = q.w() < 0.f ? -1.f : 1.f;
q *= sign;
q.normalize();
rotVals.emplace_back(q.mSimd);
}

View File

@@ -122,8 +122,8 @@ std::unique_ptr<atUint8[]> PAK::Entry::getBuffer(const nod::Node& pak, atUint64&
strm->read(&chunkSz, 2);
chunkSz = hecl::SBig(chunkSz);
strm->read(compBuf, chunkSz);
size_t dsz = rem;
lzokay::decompress(compBuf, chunkSz, bufCur, dsz);
size_t dsz;
lzokay::decompress(compBuf, chunkSz, bufCur, rem, dsz);
bufCur += dsz;
rem -= dsz;
}

View File

@@ -12,8 +12,8 @@ struct CameraHintTrigger : IScriptObject {
Value<atVec3f> location;
Value<atVec3f> orientation;
Value<atVec3f> volume;
Value<bool> unknown1;
Value<bool> unknown2;
Value<bool> unknown3;
Value<bool> active;
Value<bool> deactivateOnEntered;
Value<bool> deactivateOnExited;
};
} // namespace DataSpec::DNAMP1

View File

@@ -47,8 +47,8 @@ void MREA::StreamReader::nextBlock() {
rem -= chunkSz;
} else {
m_source.readUBytesToBuf(m_compBuf.get(), chunkSz);
size_t dsz = rem;
lzokay::decompress(m_compBuf.get(), chunkSz, bufCur, dsz);
size_t dsz;
lzokay::decompress(m_compBuf.get(), chunkSz, bufCur, rem, dsz);
bufCur += dsz;
rem -= dsz;
}

View File

@@ -179,8 +179,8 @@ std::unique_ptr<atUint8[]> PAK::Entry::getBuffer(const nod::Node& pak, atUint64&
while (rem) {
atUint16 chunkSz = hecl::SBig(*(atUint16*)compBufCur);
compBufCur += 2;
size_t dsz = rem;
lzokay::decompress(compBufCur, chunkSz, bufCur, dsz);
size_t dsz;
lzokay::decompress(compBufCur, chunkSz, bufCur, rem, dsz);
compBufCur += chunkSz;
bufCur += dsz;
rem -= dsz;