diff --git a/DataSpec/DNACommon/ANIM.cpp b/DataSpec/DNACommon/ANIM.cpp index 25f0ed063..0f1a041b1 100644 --- a/DataSpec/DNACommon/ANIM.cpp +++ b/DataSpec/DNACommon/ANIM.cpp @@ -452,9 +452,9 @@ BitstreamWriter::write(const std::vector>& chanKeys, it != kit->end(); ++it) { - QuantizedValue cur = {atInt32(it->v3.vec[0] * rotDivOut), - atInt32(it->v3.vec[1] * rotDivOut), - atInt32(it->v3.vec[2] * rotDivOut)}; + QuantizedValue cur = {atInt32(it->v3.vec[0] / scaleMultOut), + atInt32(it->v3.vec[1] / scaleMultOut), + atInt32(it->v3.vec[2] / scaleMultOut)}; chan.q[0] = std::max(chan.q[0], atUint8(ceilf(log2f(cur[0] - last[0])))); chan.q[1] = std::max(chan.q[1], atUint8(ceilf(log2f(cur[1] - last[1])))); chan.q[2] = std::max(chan.q[2], atUint8(ceilf(log2f(cur[2] - last[2])))); @@ -469,7 +469,7 @@ BitstreamWriter::write(const std::vector>& chanKeys, /* Generate Bitstream */ sizeOut = ComputeBitstreamSize(keyFrameCount, channels); - atUint8* newData = new atUint8[sizeOut]; + std::unique_ptr newData(new atUint8[sizeOut]); for (size_t f=0 ; f>& chanKeys, ++it) { QuantizedRot qrCur = QuantizeRotation(*it, rotDivOut); - quantizeBit(newData, qrCur.w); - quantize(newData, chan.q[0], qrCur.v[0] - qrLast.v[0]); - quantize(newData, chan.q[1], qrCur.v[1] - qrLast.v[1]); - quantize(newData, chan.q[2], qrCur.v[2] - qrLast.v[2]); + quantizeBit(newData.get(), qrCur.w); + quantize(newData.get(), chan.q[0], qrCur.v[0] - qrLast.v[0]); + quantize(newData.get(), chan.q[1], qrCur.v[1] - qrLast.v[1]); + quantize(newData.get(), chan.q[2], qrCur.v[2] - qrLast.v[2]); qrLast = qrCur; } break; @@ -505,9 +505,9 @@ BitstreamWriter::write(const std::vector>& chanKeys, QuantizedValue cur = {atInt32(it->v3.vec[0] / transMultOut), atInt32(it->v3.vec[1] / transMultOut), atInt32(it->v3.vec[2] / transMultOut)}; - quantize(newData, chan.q[0], cur[0] - last[0]); - quantize(newData, chan.q[1], cur[1] - last[1]); - quantize(newData, chan.q[2], cur[2] - last[2]); + quantize(newData.get(), chan.q[0], cur[0] - last[0]); + quantize(newData.get(), chan.q[1], cur[1] - last[1]); + quantize(newData.get(), chan.q[2], cur[2] - last[2]); last = cur; } break; @@ -524,9 +524,9 @@ BitstreamWriter::write(const std::vector>& chanKeys, QuantizedValue cur = {atInt32(it->v3.vec[0] / scaleMultOut), atInt32(it->v3.vec[1] / scaleMultOut), atInt32(it->v3.vec[2] / scaleMultOut)}; - quantize(newData, chan.q[0], cur[0] - last[0]); - quantize(newData, chan.q[1], cur[1] - last[1]); - quantize(newData, chan.q[2], cur[2] - last[2]); + quantize(newData.get(), chan.q[0], cur[0] - last[0]); + quantize(newData.get(), chan.q[1], cur[1] - last[1]); + quantize(newData.get(), chan.q[2], cur[2] - last[2]); last = cur; } break; @@ -536,7 +536,7 @@ BitstreamWriter::write(const std::vector>& chanKeys, ++kit; } } - return std::unique_ptr(newData); + return newData; } } diff --git a/DataSpec/DNAMP1/ANCS.cpp b/DataSpec/DNAMP1/ANCS.cpp index e7b98210a..4969ec6f9 100644 --- a/DataSpec/DNAMP1/ANCS.cpp +++ b/DataSpec/DNAMP1/ANCS.cpp @@ -1244,7 +1244,7 @@ bool ANCS::Cook(const hecl::ProjectPath& outPath, { hecl::SystemStringView sysStr(act.name); hecl::ProjectPath pathOut = inPath.getWithExtension((_S('.') + sysStr.sys_str()).c_str(), true).ensureAuxInfo(_S("ANIM")); - hecl::ProjectPath cookedOut = inPath.getCookedPath(SpecEntMP1).getWithExtension((_S('.') + sysStr.sys_str()).c_str(), true); + hecl::ProjectPath cookedOut = inPath.getCookedPath(SpecEntMP1PC).getWithExtension((_S('.') + sysStr.sys_str()).c_str(), true); athena::io::FileWriter w(cookedOut.getAbsolutePath(), true, false); if (w.hasError()) Log.report(logvisor::Fatal, _S("unable to open '%s' for writing"), diff --git a/Runtime/Character/CFBStreamedAnimReader.cpp b/Runtime/Character/CFBStreamedAnimReader.cpp index 57dec8114..ffd5a85f2 100644 --- a/Runtime/Character/CFBStreamedAnimReader.cpp +++ b/Runtime/Character/CFBStreamedAnimReader.cpp @@ -10,7 +10,9 @@ void CFBStreamedAnimReaderTotals::Allocate(u32 chanCount) u32 chan2 = chanCount * 2; u32 chan32 = chanCount * 32; - x0_buffer.reset(new u8[chan32 + chanCount + chan2 + chan32]); + size_t sz = chan32 + chanCount + chan2 + chan32; + x0_buffer.reset(new u8[sz]); + memset(x0_buffer.get(), 0, sz); x4_cumulativeInts32 = reinterpret_cast(x0_buffer.get()); x8_hasTrans1 = reinterpret_cast(x4_cumulativeInts32 + chanCount * 8); xc_segIds2 = reinterpret_cast(x8_hasTrans1 + chanCount); @@ -19,6 +21,7 @@ void CFBStreamedAnimReaderTotals::Allocate(u32 chanCount) void CFBStreamedAnimReaderTotals::Initialize(const CFBStreamedCompression& source) { + x20_calculated = false; const u8* chans = source.GetPerChannelHeaders(); u32 boneChanCount = *reinterpret_cast(chans); chans += 4; @@ -194,6 +197,10 @@ CFBStreamedPairOfTotals::CFBStreamedPairOfTotals(const TSubAnimTypeTokenMainHeader(); CCharAnimTime interval(header.interval); const u32* timeBitmap = x0_source->GetTimes(); @@ -262,13 +269,13 @@ u32 CBitLevelLoader::LoadUnsigned(u8 q) /* Fill 32 bit buffer with region containing bits */ /* Make them least significant */ - u32 tempBuf = hecl::SBig(*reinterpret_cast(m_data + byteCur)) >> bitRem; + u32 tempBuf = *reinterpret_cast(m_data + byteCur) >> bitRem; /* If this shift underflows the value, buffer the next 32 bits */ /* And tack onto shifted buffer */ if ((bitRem + q) > 32) { - u32 tempBuf2 = hecl::SBig(*reinterpret_cast(m_data + byteCur + 4)); + u32 tempBuf2 = *reinterpret_cast(m_data + byteCur + 4); tempBuf |= (tempBuf2 << (32 - bitRem)); } @@ -288,13 +295,13 @@ s32 CBitLevelLoader::LoadSigned(u8 q) /* Fill 32 bit buffer with region containing bits */ /* Make them least significant */ - u32 tempBuf = hecl::SBig(*reinterpret_cast(m_data + byteCur)) >> bitRem; + u32 tempBuf = *reinterpret_cast(m_data + byteCur) >> bitRem; /* If this shift underflows the value, buffer the next 32 bits */ /* And tack onto shifted buffer */ if ((bitRem + q) > 32) { - u32 tempBuf2 = hecl::SBig(*reinterpret_cast(m_data + byteCur + 4)); + u32 tempBuf2 = *reinterpret_cast(m_data + byteCur + 4); tempBuf |= (tempBuf2 << (32 - bitRem)); } @@ -319,7 +326,7 @@ bool CBitLevelLoader::LoadBool() /* Fill 32 bit buffer with region containing bits */ /* Make them least significant */ - u32 tempBuf = hecl::SBig(*reinterpret_cast(m_data + byteCur)) >> bitRem; + u32 tempBuf = *reinterpret_cast(m_data + byteCur) >> bitRem; /* That's it */ m_bitIdx += 1;