Fix issue with half sized skinned objects in SW transform.

This commit is contained in:
Henrik Rydgard committed 2013-02-06 19:04:28 +01:00
1 parent cc02deb806
commit 80f4dc4e3a
1 file changed
+16 -8
+16 -8
View File
@@ -289,13 +289,17 @@ public:
}
void ReadWeights(float weights[8]) {
const float *f = (const float *)(data_ + decFmt_.w0off);
const u8 *p = (const u8 *)(data_ + decFmt_.w0off);
const u16 *s = (const u16 *)(data_ + decFmt_.w0off);
switch (decFmt_.w0fmt) {
case DEC_FLOAT_1: memcpy(weights, data_ + decFmt_.w0off, 4); break;
case DEC_FLOAT_2: memcpy(weights, data_ + decFmt_.w0off, 8); break;
case DEC_FLOAT_3: memcpy(weights, data_ + decFmt_.w0off, 12); break;
case DEC_FLOAT_4: memcpy(weights, data_ + decFmt_.w0off, 16); break;
case DEC_FLOAT_1:
case DEC_FLOAT_2:
case DEC_FLOAT_3:
case DEC_FLOAT_4:
for (int i = 0; i <= decFmt_.w0fmt - DEC_FLOAT_1; i++)
weights[i] = f[i] * 2.0;
break;
case DEC_U8_1: weights[0] = p[0] / 128.f; break;
case DEC_U8_2: for (int i = 0; i < 2; i++) weights[i] = p[i] / 128.f; break;
case DEC_U8_3: for (int i = 0; i < 3; i++) weights[i] = p[i] / 128.f; break;
@@ -309,16 +313,20 @@ public:
break;
}
f = (const float*)(data_ + decFmt_.w1off);
p = (const u8 *)(data_ + decFmt_.w1off);
s = (const u16 *)(data_ + decFmt_.w1off);
switch (decFmt_.w1fmt) {
case 0:
// It's fine for there to be w0 weights but not w1.
break;
case DEC_FLOAT_1: memcpy(weights + 4, data_ + decFmt_.w1off, 4); break;
case DEC_FLOAT_2: memcpy(weights + 4, data_ + decFmt_.w1off, 8); break;
case DEC_FLOAT_3: memcpy(weights + 4, data_ + decFmt_.w1off, 12); break;
case DEC_FLOAT_4: memcpy(weights + 4, data_ + decFmt_.w1off, 16); break;
case DEC_FLOAT_1:
case DEC_FLOAT_2:
case DEC_FLOAT_3:
case DEC_FLOAT_4:
for (int i = 0; i <= decFmt_.w1fmt - DEC_FLOAT_1; i++)
weights[i+4] = f[i] * 2.0;
break;
case DEC_U16_1: weights[4] = s[0] / 32768.f; break;
case DEC_U16_2: for (int i = 0; i < 2; i++) weights[i+4] = s[i] / 32768.f; break;
case DEC_U16_3: for (int i = 0; i < 3; i++) weights[i+4] = s[i] / 32768.f; break;