|
@@ -102,16 +102,14 @@ void BoneFrame::getPosition(vec3_t p) {
|
102
|
102
|
p[2] = pos[2];
|
103
|
103
|
}
|
104
|
104
|
|
105
|
|
-AnimationFrame::AnimationFrame(TombRaider &tr, unsigned int index, int a) {
|
|
105
|
+AnimationFrame::AnimationFrame(TombRaider &tr, unsigned int index, int a, unsigned int *frame_offset, int frame_step) {
|
106
|
106
|
tr2_moveable_t *moveable = tr.Moveable();
|
107
|
107
|
tr2_animation_t *animation = tr.Animation();
|
108
|
108
|
|
109
|
|
- unsigned int frame_offset = animation[a].frame_offset / 2;
|
110
|
|
- int frame_step = animation[a].frame_size;
|
111
|
109
|
unsigned int frame_count = (animation[a].frame_end - animation[a].frame_start) + 1;
|
112
|
110
|
rate = animation[a].frame_rate;
|
113
|
111
|
|
114
|
|
- for (unsigned int f = 0; f < frame_count; f++, frame_offset += frame_step) {
|
|
112
|
+ for (unsigned int f = 0; f < frame_count; f++, *frame_offset += frame_step) {
|
115
|
113
|
// HACK: Lara's ObjectID is 315, but her meshes start at 0, so make a
|
116
|
114
|
// quick substitution (so she doesn't appear as a bunch of thighs)
|
117
|
115
|
if ((index == 0) && (tr.Engine() == TR_VERSION_3)) {
|
|
@@ -138,13 +136,13 @@ AnimationFrame::AnimationFrame(TombRaider &tr, unsigned int index, int a) {
|
138
|
136
|
}
|
139
|
137
|
}
|
140
|
138
|
|
141
|
|
- if (frame_offset > tr.NumFrames()) {
|
|
139
|
+ if (*frame_offset > tr.NumFrames()) {
|
142
|
140
|
getConsole().print("WARNING: Bad animation frame %i > %i (%u.%d)",
|
143
|
|
- frame_offset, tr.NumFrames(), index, a);
|
|
141
|
+ *frame_offset, tr.NumFrames(), index, a);
|
144
|
142
|
return;
|
145
|
143
|
}
|
146
|
144
|
|
147
|
|
- frame.push_back(new BoneFrame(tr, index, frame_offset));
|
|
145
|
+ frame.push_back(new BoneFrame(tr, index, *frame_offset));
|
148
|
146
|
}
|
149
|
147
|
}
|
150
|
148
|
|
|
@@ -234,20 +232,27 @@ SkeletalModel::SkeletalModel(TombRaider &tr, unsigned int index, int objectId) {
|
234
|
232
|
unsigned int frame_offset = anim[a].frame_offset / 2;
|
235
|
233
|
int frame_step = anim[a].frame_size;
|
236
|
234
|
|
|
235
|
+ int frame_cycle = 0;
|
|
236
|
+
|
237
|
237
|
if (a >= (int)tr.NumAnimations())
|
238
|
238
|
a = tr.NumFrames() - frame_offset; //! \fixme Couldn't a be already used out of range?!
|
239
|
239
|
else
|
240
|
|
- a = (anim[a].frame_offset / 2) - frame_offset;
|
|
240
|
+ a = (anim[a].frame_offset / 2) - frame_offset; //! \fixme Same as a = 0; ??
|
241
|
241
|
|
242
|
242
|
if (frame_step != 0) // prevent divide-by-zero errors
|
243
|
243
|
a /= frame_step;
|
244
|
244
|
|
|
245
|
+ if (a != 0)
|
|
246
|
+ frame_offset += frame_step * (frame_cycle % a);
|
|
247
|
+
|
245
|
248
|
if (a < 0) {
|
246
|
249
|
getConsole().print("Invalid animation data for model %d. Skip!", index);
|
247
|
250
|
return;
|
248
|
251
|
} else {
|
249
|
252
|
for (; a < tr.getNumAnimsForMoveable(index); a++) {
|
250
|
|
- animation.push_back(new AnimationFrame(tr, index, a));
|
|
253
|
+ animation.push_back(new AnimationFrame(tr, index, a, &frame_offset, frame_step));
|
|
254
|
+ frame_offset = anim[a].frame_offset / 2;
|
|
255
|
+ frame_step = anim[a].frame_size;
|
251
|
256
|
}
|
252
|
257
|
}
|
253
|
258
|
}
|