Signed read bug fix

This commit is contained in:
Jack Andersen 2016-08-28 16:28:55 -10:00
parent 7953ca4828
commit e2f342d107
3 changed files with 26 additions and 24 deletions

View File

@ -471,6 +471,7 @@ BitstreamWriter::write(const std::vector<std::vector<Value>>& chanKeys,
/* Generate Bitstream */ /* Generate Bitstream */
sizeOut = ComputeBitstreamSize(keyFrameCount, channels); sizeOut = ComputeBitstreamSize(keyFrameCount, channels);
std::unique_ptr<atUint8[]> newData(new atUint8[sizeOut]); std::unique_ptr<atUint8[]> newData(new atUint8[sizeOut]);
memset(newData.get(), 0, sizeOut);
lastVals = initVals; lastVals = initVals;
for (size_t f=0 ; f<keyFrameCount ; ++f) for (size_t f=0 ; f<keyFrameCount ; ++f)
@ -479,7 +480,7 @@ BitstreamWriter::write(const std::vector<std::vector<Value>>& chanKeys,
vit = lastVals.begin(); vit = lastVals.begin();
for (const Channel& chan : channels) for (const Channel& chan : channels)
{ {
const Value& val = (*kit++)[f]; const Value& val = (*kit++)[f+1];
QuantizedValue& last = *vit++; QuantizedValue& last = *vit++;
switch (chan.type) switch (chan.type)
{ {

View File

@ -386,16 +386,17 @@ void ANIM::ANIM2::write(athena::io::IStreamWriter& writer) const
size_t frameCount = 0; size_t frameCount = 0;
for (atUint32 frame : frames) for (atUint32 frame : frames)
{ {
while (keyBmp.getBit(frame)) if (!keyBmp.getBit(frame))
++frame; {
keyBmp.setBit(frame); keyBmp.setBit(frame);
frameCount = frame + 1; frameCount += 1;
}
} }
head.keyBitmapBitCount = frameCount; head.keyBitmapBitCount = frameCount;
head.duration = frameCount * mainInterval; head.duration = frameCount * mainInterval;
head.boneChannelCount = bones.size(); head.boneChannelCount = bones.size();
size_t keyframeCount = frames.size(); size_t keyframeCount = frameCount - 1;
std::vector<DNAANIM::Channel> qChannels = channels; std::vector<DNAANIM::Channel> qChannels = channels;
DNAANIM::BitstreamWriter bsWriter; DNAANIM::BitstreamWriter bsWriter;
size_t bsSize; size_t bsSize;

View File

@ -77,38 +77,38 @@ struct ANIM : BigDNA
Delete expl; Delete expl;
Value<atUint32> id = 0; Value<atUint32> id = 0;
Value<atUint16> keyCount1 = 0; Value<atUint16> keyCount1 = 0;
Value<atUint16> initRX = 0; Value<atInt16> initRX = 0;
Value<atUint8> qRX = 0; Value<atUint8> qRX = 0;
Value<atUint16> initRY = 0; Value<atInt16> initRY = 0;
Value<atUint8> qRY = 0; Value<atUint8> qRY = 0;
Value<atUint16> initRZ = 0; Value<atInt16> initRZ = 0;
Value<atUint8> qRZ = 0; Value<atUint8> qRZ = 0;
Value<atUint16> keyCount2 = 0; Value<atUint16> keyCount2 = 0;
Value<atUint16> initTX = 0; Value<atInt16> initTX = 0;
Value<atUint8> qTX = 0; Value<atUint8> qTX = 0;
Value<atUint16> initTY = 0; Value<atInt16> initTY = 0;
Value<atUint8> qTY = 0; Value<atUint8> qTY = 0;
Value<atUint16> initTZ = 0; Value<atInt16> initTZ = 0;
Value<atUint8> qTZ = 0; Value<atUint8> qTZ = 0;
void read(athena::io::IStreamReader& reader) void read(athena::io::IStreamReader& reader)
{ {
id = reader.readUint32Big(); id = reader.readUint32Big();
keyCount1 = reader.readUint16Big(); keyCount1 = reader.readUint16Big();
initRX = reader.readUint16Big(); initRX = reader.readInt16Big();
qRX = reader.readUByte(); qRX = reader.readUByte();
initRY = reader.readUint16Big(); initRY = reader.readInt16Big();
qRY = reader.readUByte(); qRY = reader.readUByte();
initRZ = reader.readUint16Big(); initRZ = reader.readInt16Big();
qRZ = reader.readUByte(); qRZ = reader.readUByte();
keyCount2 = reader.readUint16Big(); keyCount2 = reader.readUint16Big();
if (keyCount2) if (keyCount2)
{ {
initTX = reader.readUint16Big(); initTX = reader.readInt16Big();
qTX = reader.readUByte(); qTX = reader.readUByte();
initTY = reader.readUint16Big(); initTY = reader.readInt16Big();
qTY = reader.readUByte(); qTY = reader.readUByte();
initTZ = reader.readUint16Big(); initTZ = reader.readInt16Big();
qTZ = reader.readUByte(); qTZ = reader.readUByte();
} }
} }
@ -116,20 +116,20 @@ struct ANIM : BigDNA
{ {
writer.writeUint32Big(id); writer.writeUint32Big(id);
writer.writeUint16Big(keyCount1); writer.writeUint16Big(keyCount1);
writer.writeUint16Big(initRX); writer.writeInt16Big(initRX);
writer.writeUByte(qRX); writer.writeUByte(qRX);
writer.writeUint16Big(initRY); writer.writeInt16Big(initRY);
writer.writeUByte(qRY); writer.writeUByte(qRY);
writer.writeUint16Big(initRZ); writer.writeInt16Big(initRZ);
writer.writeUByte(qRZ); writer.writeUByte(qRZ);
writer.writeUint16Big(keyCount2); writer.writeUint16Big(keyCount2);
if (keyCount2) if (keyCount2)
{ {
writer.writeUint16Big(initTX); writer.writeInt16Big(initTX);
writer.writeUByte(qTX); writer.writeUByte(qTX);
writer.writeUint16Big(initTY); writer.writeInt16Big(initTY);
writer.writeUByte(qTY); writer.writeUByte(qTY);
writer.writeUint16Big(initTZ); writer.writeInt16Big(initTZ);
writer.writeUByte(qTZ); writer.writeUByte(qTZ);
} }
} }