mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-08 13:44:56 +00:00
CPuddleToadGamma and animation system fixes
This commit is contained in:
@@ -35,21 +35,21 @@ 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);
|
||||
float q = float(div) / (M_PIF / 2.0f);
|
||||
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),
|
||||
atInt32(std::asin(f[3]) / q),
|
||||
atInt32(std::asin(f[1]) * q),
|
||||
atInt32(std::asin(f[2]) * q),
|
||||
atInt32(std::asin(f[3]) * q),
|
||||
},
|
||||
(f[0] < 0.f)};
|
||||
}
|
||||
|
||||
static inline Value DequantizeRotation(const QuantizedRot& v, atUint32 div) {
|
||||
float q = M_PIF / 2.0f / float(div);
|
||||
float q = (M_PIF / 2.0f) / float(div);
|
||||
athena::simd_floats f = {
|
||||
0.0f,
|
||||
std::sin(v.v[0] * q),
|
||||
@@ -259,6 +259,7 @@ void BitstreamWriter::quantize(atUint8* data, atUint8 q, atInt32 val) {
|
||||
atUint32 bitRem = m_bitCur % 32;
|
||||
|
||||
atUint32 masked = val & ((1 << q) - 1);
|
||||
assert(((((val >> 31) & 0x1) == 0x1) || (((masked >> (q - 1)) & 0x1) == 0)) && "Twos compliment fail");
|
||||
|
||||
/* Fill 32 bit buffer with region containing bits */
|
||||
/* Make them least significant */
|
||||
@@ -317,8 +318,8 @@ std::unique_ptr<atUint8[]> BitstreamWriter::write(const std::vector<std::vector<
|
||||
}
|
||||
++kit;
|
||||
}
|
||||
transMultOut = std::max(maxTransDelta / quantRangeF, FLT_EPSILON);
|
||||
scaleMultOut = std::max(maxScaleDelta / quantRangeF, FLT_EPSILON);
|
||||
transMultOut = maxTransDelta / quantRangeF + FLT_EPSILON;
|
||||
scaleMultOut = maxScaleDelta / quantRangeF + FLT_EPSILON;
|
||||
|
||||
/* Output channel inits */
|
||||
std::vector<QuantizedValue> initVals;
|
||||
@@ -404,11 +405,11 @@ std::unique_ptr<atUint8[]> BitstreamWriter::write(const std::vector<std::vector<
|
||||
memset(newData.get(), 0, sizeOut);
|
||||
|
||||
lastVals = initVals;
|
||||
for (size_t f = 0; f < keyFrameCount; ++f) {
|
||||
for (size_t frame = 0; frame < keyFrameCount; ++frame) {
|
||||
kit = chanKeys.begin();
|
||||
vit = lastVals.begin();
|
||||
for (const Channel& chan : channels) {
|
||||
const Value& val = (*kit++)[f + 1];
|
||||
const Value& val = (*kit++)[frame + 1];
|
||||
QuantizedValue& last = *vit++;
|
||||
switch (chan.type) {
|
||||
case Channel::Type::Rotation: {
|
||||
|
||||
@@ -20,10 +20,13 @@ struct QuantizedValue {
|
||||
atInt32 operator[](size_t idx) const { return v[idx]; }
|
||||
|
||||
int qFrom(const QuantizedValue& other, size_t idx) const {
|
||||
atInt32 delta = std::abs(v[idx] - other.v[idx]);
|
||||
if (delta == 0)
|
||||
atInt32 delta = v[idx] - other.v[idx];
|
||||
atInt32 absDelta = std::abs(delta);
|
||||
if (absDelta == 0)
|
||||
return 1;
|
||||
int ret = int(std::ceil(std::log2(delta))) + 1;
|
||||
int ret = int(std::ceil(std::log2(absDelta))) + 1;
|
||||
if (delta > 0 && (delta >> (ret - 1)))
|
||||
++ret;
|
||||
assert(ret <= 24 && "Bad q value");
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -618,7 +618,8 @@ ANIM::ANIM(const BlenderAction& act, const std::unordered_map<std::string, atInt
|
||||
}
|
||||
}
|
||||
|
||||
newAnim.mainInterval = act.interval;
|
||||
/* Retro's original data uses microsecond precision */
|
||||
newAnim.mainInterval = std::trunc(act.interval * 1000000.0) / 1000000.0;
|
||||
}
|
||||
|
||||
} // namespace DataSpec::DNAMP1
|
||||
|
||||
@@ -9,20 +9,20 @@ struct PuddleToadGamma : IScriptObject {
|
||||
AT_DECL_DNA_YAML
|
||||
AT_DECL_DNAV
|
||||
String<-1> name;
|
||||
Value<atUint32> unknown1;
|
||||
Value<atUint32> flavor;
|
||||
Value<atVec3f> location;
|
||||
Value<atVec3f> orientation;
|
||||
Value<atVec3f> scale;
|
||||
PatternedInfo patternedInfo;
|
||||
ActorParameters actorParameters;
|
||||
Value<float> unknown2;
|
||||
Value<float> unknown3;
|
||||
Value<float> unknown4;
|
||||
Value<atVec3f> unknown5;
|
||||
Value<float> unknown6;
|
||||
Value<float> unknown7;
|
||||
Value<float> unknown8;
|
||||
DamageInfo damageInfo1;
|
||||
Value<float> suckForceMultiplier;
|
||||
Value<float> suckAngle;
|
||||
Value<float> playerSuckRange;
|
||||
Value<atVec3f> localShootDir;
|
||||
Value<float> playerShootSpeed;
|
||||
Value<float> shouldAttackWaitTime;
|
||||
Value<float> spotPlayerWaitTime;
|
||||
DamageInfo playerShootDamage;
|
||||
DamageInfo damageInfo2;
|
||||
UniqueID32 dcln;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user