Unbreak Nexuiz weapon animation.
[xonotic/darkplaces.git] / model_sprite.c
1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19 */
20 // models.c -- model loading and caching
21
22 // models are the only shared resource between a client and server running
23 // on the same machine.
24
25 #include "quakedef.h"
26 #include "image.h"
27
28 cvar_t r_mipsprites = {CVAR_SAVE, "r_mipsprites", "1", "mipmaps sprites so they render faster in the distance and do not display noise artifacts"};
29 cvar_t r_labelsprites_scale = {CVAR_SAVE, "r_labelsprites_scale", "1", "global scale to apply to label sprites before conversion to HUD coordinates"};
30 cvar_t r_labelsprites_roundtopixels = {CVAR_SAVE, "r_labelsprites_roundtopixels", "1", "try to make label sprites sharper by rounding their size to 0.5x or 1x and by rounding their position to whole pixels if possible"};
31 cvar_t r_overheadsprites_perspective = {CVAR_SAVE, "r_overheadsprites_perspective", "5", "fake perspective effect for SPR_OVERHEAD sprites"};
32 cvar_t r_overheadsprites_pushback = {CVAR_SAVE, "r_overheadsprites_pushback", "15", "how far to pull the SPR_OVERHEAD sprites toward the eye (used to avoid intersections with 3D models)"};
33 cvar_t r_overheadsprites_scalex = {CVAR_SAVE, "r_overheadsprites_scalex", "1", "additional scale for overhead sprites for x axis"};
34 cvar_t r_overheadsprites_scaley = {CVAR_SAVE, "r_overheadsprites_scaley", "1", "additional scale for overhead sprites for y axis"};
35 cvar_t r_track_sprites = {CVAR_SAVE, "r_track_sprites", "1", "track SPR_LABEL* sprites by putting them as indicator at the screen border to rotate to"};
36 cvar_t r_track_sprites_flags = {CVAR_SAVE, "r_track_sprites_flags", "1", "1: Rotate sprites accordingly, 2: Make it a continuous rotation"};
37 cvar_t r_track_sprites_scalew = {CVAR_SAVE, "r_track_sprites_scalew", "1", "width scaling of tracked sprites"};
38 cvar_t r_track_sprites_scaleh = {CVAR_SAVE, "r_track_sprites_scaleh", "1", "height scaling of tracked sprites"};
39
40 /*
41 ===============
42 Mod_SpriteInit
43 ===============
44 */
45 void Mod_SpriteInit (void)
46 {
47         Cvar_RegisterVariable(&r_mipsprites);
48         Cvar_RegisterVariable(&r_labelsprites_scale);
49         Cvar_RegisterVariable(&r_labelsprites_roundtopixels);
50         Cvar_RegisterVariable(&r_overheadsprites_perspective);
51         Cvar_RegisterVariable(&r_overheadsprites_pushback);
52         Cvar_RegisterVariable(&r_overheadsprites_scalex);
53         Cvar_RegisterVariable(&r_overheadsprites_scaley);
54         Cvar_RegisterVariable(&r_track_sprites);
55         Cvar_RegisterVariable(&r_track_sprites_flags);
56         Cvar_RegisterVariable(&r_track_sprites_scalew);
57         Cvar_RegisterVariable(&r_track_sprites_scaleh);
58 }
59
60 static void Mod_SpriteSetupTexture(texture_t *texture, skinframe_t *skinframe, qboolean fullbright, qboolean additive)
61 {
62         if (!skinframe)
63                 skinframe = R_SkinFrame_LoadMissing();
64         texture->offsetmapping = OFFSETMAPPING_OFF;
65         texture->offsetscale = 1;
66         texture->offsetbias = 0;
67         texture->specularscalemod = 1;
68         texture->specularpowermod = 1;
69         texture->basematerialflags = MATERIALFLAG_WALL;
70         texture->basealpha = 1.0f;
71         if (fullbright)
72                 texture->basematerialflags |= MATERIALFLAG_FULLBRIGHT;
73         if (additive)
74                 texture->basematerialflags |= MATERIALFLAG_ADD | MATERIALFLAG_BLENDED | MATERIALFLAG_NOSHADOW;
75         else if (skinframe->hasalpha)
76                 texture->basematerialflags |= MATERIALFLAG_ALPHA | MATERIALFLAG_BLENDED | MATERIALFLAG_NOSHADOW;
77         texture->currentmaterialflags = texture->basematerialflags;
78         texture->numskinframes = 1;
79         texture->currentskinframe = texture->skinframes[0] = skinframe;
80         texture->surfaceflags = 0;
81         texture->supercontents = SUPERCONTENTS_SOLID;
82         if (!(texture->basematerialflags & MATERIALFLAG_BLENDED))
83                 texture->supercontents |= SUPERCONTENTS_OPAQUE;
84         texture->transparentsort = TRANSPARENTSORT_DISTANCE;
85         // WHEN ADDING DEFAULTS HERE, REMEMBER TO PUT DEFAULTS IN ALL LOADERS
86         // JUST GREP FOR "specularscalemod = 1".
87 }
88
89 extern cvar_t gl_texturecompression_sprites;
90
91 static void Mod_Sprite_SharedSetup(const unsigned char *datapointer, int version, const unsigned int *palette, qboolean additive)
92 {
93         int                                     i, j, groupframes, realframes, x, y, origin[2], width, height;
94         qboolean                        fullbright;
95         dspriteframetype_t      *pinframetype;
96         dspriteframe_t          *pinframe;
97         dspritegroup_t          *pingroup;
98         dspriteinterval_t       *pinintervals;
99         skinframe_t                     *skinframe;
100         float                           modelradius, interval;
101         char                            name[MAX_QPATH], fogname[MAX_QPATH];
102         const void                      *startframes;
103         int                 texflags = (r_mipsprites.integer ? TEXF_MIPMAP : 0) | ((gl_texturecompression.integer && gl_texturecompression_sprites.integer) ? TEXF_COMPRESS : 0) | TEXF_ISSPRITE | TEXF_PICMIP | TEXF_ALPHA | TEXF_CLAMP;
104         modelradius = 0;
105
106         if (loadmodel->numframes < 1)
107                 Host_Error ("Mod_Sprite_SharedSetup: Invalid # of frames: %d", loadmodel->numframes);
108
109         // LordHavoc: hack to allow sprites to be non-fullbright
110         fullbright = true;
111         for (i = 0;i < MAX_QPATH && loadmodel->name[i];i++)
112                 if (loadmodel->name[i] == '!')
113                         fullbright = false;
114
115 //
116 // load the frames
117 //
118         startframes = datapointer;
119         realframes = 0;
120         for (i = 0;i < loadmodel->numframes;i++)
121         {
122                 pinframetype = (dspriteframetype_t *)datapointer;
123                 datapointer += sizeof(dspriteframetype_t);
124
125                 if (LittleLong (pinframetype->type) == SPR_SINGLE)
126                         groupframes = 1;
127                 else
128                 {
129                         pingroup = (dspritegroup_t *)datapointer;
130                         datapointer += sizeof(dspritegroup_t);
131
132                         groupframes = LittleLong(pingroup->numframes);
133
134                         datapointer += sizeof(dspriteinterval_t) * groupframes;
135                 }
136
137                 for (j = 0;j < groupframes;j++)
138                 {
139                         pinframe = (dspriteframe_t *)datapointer;
140                         if (version == SPRITE32_VERSION)
141                                 datapointer += sizeof(dspriteframe_t) + LittleLong(pinframe->width) * LittleLong(pinframe->height) * 4;
142                         else //if (version == SPRITE_VERSION || version == SPRITEHL_VERSION)
143                                 datapointer += sizeof(dspriteframe_t) + LittleLong(pinframe->width) * LittleLong(pinframe->height);
144                 }
145                 realframes += groupframes;
146         }
147
148         loadmodel->animscenes = (animscene_t *)Mem_Alloc(loadmodel->mempool, sizeof(animscene_t) * loadmodel->numframes);
149         loadmodel->sprite.sprdata_frames = (mspriteframe_t *)Mem_Alloc(loadmodel->mempool, sizeof(mspriteframe_t) * realframes);
150         loadmodel->num_textures = realframes;
151         loadmodel->num_texturesperskin = 1;
152         loadmodel->data_textures = (texture_t *)Mem_Alloc(loadmodel->mempool, sizeof(texture_t) * loadmodel->num_textures);
153
154         datapointer = (unsigned char *)startframes;
155         realframes = 0;
156         for (i = 0;i < loadmodel->numframes;i++)
157         {
158                 pinframetype = (dspriteframetype_t *)datapointer;
159                 datapointer += sizeof(dspriteframetype_t);
160
161                 if (LittleLong (pinframetype->type) == SPR_SINGLE)
162                 {
163                         groupframes = 1;
164                         interval = 0.1f;
165                 }
166                 else
167                 {
168                         pingroup = (dspritegroup_t *)datapointer;
169                         datapointer += sizeof(dspritegroup_t);
170
171                         groupframes = LittleLong(pingroup->numframes);
172
173                         pinintervals = (dspriteinterval_t *)datapointer;
174                         datapointer += sizeof(dspriteinterval_t) * groupframes;
175
176                         interval = LittleFloat(pinintervals[0].interval);
177                         if (interval < 0.01f)
178                                 Host_Error("Mod_Sprite_SharedSetup: invalid interval");
179                 }
180
181                 dpsnprintf(loadmodel->animscenes[i].name, sizeof(loadmodel->animscenes[i].name), "frame %i", i);
182                 loadmodel->animscenes[i].firstframe = realframes;
183                 loadmodel->animscenes[i].framecount = groupframes;
184                 loadmodel->animscenes[i].framerate = 1.0f / interval;
185                 loadmodel->animscenes[i].loop = true;
186
187                 for (j = 0;j < groupframes;j++)
188                 {
189                         pinframe = (dspriteframe_t *)datapointer;
190                         datapointer += sizeof(dspriteframe_t);
191
192                         origin[0] = LittleLong (pinframe->origin[0]);
193                         origin[1] = LittleLong (pinframe->origin[1]);
194                         width = LittleLong (pinframe->width);
195                         height = LittleLong (pinframe->height);
196
197                         loadmodel->sprite.sprdata_frames[realframes].left = origin[0];
198                         loadmodel->sprite.sprdata_frames[realframes].right = origin[0] + width;
199                         loadmodel->sprite.sprdata_frames[realframes].up = origin[1];
200                         loadmodel->sprite.sprdata_frames[realframes].down = origin[1] - height;
201
202                         x = (int)max(loadmodel->sprite.sprdata_frames[realframes].left * loadmodel->sprite.sprdata_frames[realframes].left, loadmodel->sprite.sprdata_frames[realframes].right * loadmodel->sprite.sprdata_frames[realframes].right);
203                         y = (int)max(loadmodel->sprite.sprdata_frames[realframes].up * loadmodel->sprite.sprdata_frames[realframes].up, loadmodel->sprite.sprdata_frames[realframes].down * loadmodel->sprite.sprdata_frames[realframes].down);
204                         if (modelradius < x + y)
205                                 modelradius = x + y;
206
207                         if (cls.state != ca_dedicated)
208                         {
209                                 skinframe = NULL;
210                                 // note: Nehahra's null.spr has width == 0 and height == 0
211                                 if (width > 0 && height > 0)
212                                 {
213                                         if (groupframes > 1)
214                                         {
215                                                 dpsnprintf (name, sizeof(name), "%s_%i_%i", loadmodel->name, i, j);
216                                                 dpsnprintf (fogname, sizeof(fogname), "%s_%i_%ifog", loadmodel->name, i, j);
217                                         }
218                                         else
219                                         {
220                                                 dpsnprintf (name, sizeof(name), "%s_%i", loadmodel->name, i);
221                                                 dpsnprintf (fogname, sizeof(fogname), "%s_%ifog", loadmodel->name, i);
222                                         }
223                                         if (!(skinframe = R_SkinFrame_LoadExternal(name, texflags | TEXF_COMPRESS, false)))
224                                         {
225                                                 unsigned char *pixels = (unsigned char *) Mem_Alloc(loadmodel->mempool, width*height*4);
226                                                 if (version == SPRITE32_VERSION)
227                                                 {
228                                                         for (x = 0;x < width*height;x++)
229                                                         {
230                                                                 pixels[x*4+2] = datapointer[x*4+0];
231                                                                 pixels[x*4+1] = datapointer[x*4+1];
232                                                                 pixels[x*4+0] = datapointer[x*4+2];
233                                                                 pixels[x*4+3] = datapointer[x*4+3];
234                                                         }
235                                                 }
236                                                 else //if (version == SPRITEHL_VERSION || version == SPRITE_VERSION)
237                                                         Image_Copy8bitBGRA(datapointer, pixels, width*height, palette ? palette : palette_bgra_transparent);
238                                                 skinframe = R_SkinFrame_LoadInternalBGRA(name, texflags, pixels, width, height, false);
239                                                 // texflags |= TEXF_COMPRESS;
240                                                 Mem_Free(pixels);
241                                         }
242                                 }
243                                 if (skinframe == NULL)
244                                         skinframe = R_SkinFrame_LoadMissing();
245                                 Mod_SpriteSetupTexture(&loadmodel->data_textures[realframes], skinframe, fullbright, additive);
246                         }
247
248                         if (version == SPRITE32_VERSION)
249                                 datapointer += width * height * 4;
250                         else //if (version == SPRITE_VERSION || version == SPRITEHL_VERSION)
251                                 datapointer += width * height;
252                         realframes++;
253                 }
254         }
255
256         modelradius = sqrt(modelradius);
257         for (i = 0;i < 3;i++)
258         {
259                 loadmodel->normalmins[i] = loadmodel->yawmins[i] = loadmodel->rotatedmins[i] = -modelradius;
260                 loadmodel->normalmaxs[i] = loadmodel->yawmaxs[i] = loadmodel->rotatedmaxs[i] = modelradius;
261         }
262         loadmodel->radius = modelradius;
263         loadmodel->radius2 = modelradius * modelradius;
264 }
265
266 void Mod_IDSP_Load(dp_model_t *mod, void *buffer, void *bufferend)
267 {
268         int version;
269         const unsigned char *datapointer;
270
271         datapointer = (unsigned char *)buffer;
272
273         loadmodel->modeldatatypestring = "SPR1";
274
275         loadmodel->type = mod_sprite;
276
277         loadmodel->DrawSky = NULL;
278         loadmodel->Draw = R_Model_Sprite_Draw;
279         loadmodel->DrawDepth = NULL;
280         loadmodel->CompileShadowVolume = NULL;
281         loadmodel->DrawShadowVolume = NULL;
282         loadmodel->DrawLight = NULL;
283         loadmodel->DrawAddWaterPlanes = NULL;
284
285         version = LittleLong(((dsprite_t *)buffer)->version);
286         if (version == SPRITE_VERSION || version == SPRITE32_VERSION)
287         {
288                 dsprite_t *pinqsprite;
289
290                 pinqsprite = (dsprite_t *)datapointer;
291                 datapointer += sizeof(dsprite_t);
292
293                 loadmodel->numframes = LittleLong (pinqsprite->numframes);
294                 loadmodel->sprite.sprnum_type = LittleLong (pinqsprite->type);
295                 loadmodel->synctype = (synctype_t)LittleLong (pinqsprite->synctype);
296
297                 Mod_Sprite_SharedSetup(datapointer, LittleLong (pinqsprite->version), NULL, false);
298         }
299         else if (version == SPRITEHL_VERSION)
300         {
301                 int i, rendermode;
302                 unsigned char palette[256][4];
303                 const unsigned char *in;
304                 dspritehl_t *pinhlsprite;
305
306                 pinhlsprite = (dspritehl_t *)datapointer;
307                 datapointer += sizeof(dspritehl_t);
308
309                 loadmodel->numframes = LittleLong (pinhlsprite->numframes);
310                 loadmodel->sprite.sprnum_type = LittleLong (pinhlsprite->type);
311                 loadmodel->synctype = (synctype_t)LittleLong (pinhlsprite->synctype);
312                 rendermode = pinhlsprite->rendermode;
313
314                 in = datapointer;
315                 datapointer += 2;
316                 i = in[0] + in[1] * 256;
317                 if (i != 256)
318                         Host_Error ("Mod_IDSP_Load: unexpected number of palette colors %i (should be 256)", i);
319                 in = datapointer;
320                 datapointer += 768;
321                 switch(rendermode)
322                 {
323                 case SPRHL_OPAQUE:
324                         for (i = 0;i < 256;i++)
325                         {
326                                 palette[i][2] = in[i*3+0];
327                                 palette[i][1] = in[i*3+1];
328                                 palette[i][0] = in[i*3+2];
329                                 palette[i][3] = 255;
330                         }
331                         break;
332                 case SPRHL_ADDITIVE:
333                         for (i = 0;i < 256;i++)
334                         {
335                                 palette[i][2] = in[i*3+0];
336                                 palette[i][1] = in[i*3+1];
337                                 palette[i][0] = in[i*3+2];
338                                 palette[i][3] = 255;
339                         }
340                         // also passes additive == true to Mod_Sprite_SharedSetup
341                         break;
342                 case SPRHL_INDEXALPHA:
343                         for (i = 0;i < 256;i++)
344                         {
345                                 palette[i][2] = in[765];
346                                 palette[i][1] = in[766];
347                                 palette[i][0] = in[767];
348                                 palette[i][3] = i;
349                                 in += 3;
350                         }
351                         break;
352                 case SPRHL_ALPHATEST:
353                         for (i = 0;i < 256;i++)
354                         {
355                                 palette[i][2] = in[i*3+0];
356                                 palette[i][1] = in[i*3+1];
357                                 palette[i][0] = in[i*3+2];
358                                 palette[i][3] = 255;
359                         }
360                         palette[255][0] = palette[255][1] = palette[255][2] = palette[255][3] = 0;
361                         // should this use alpha test or alpha blend?  (currently blend)
362                         break;
363                 default:
364                         Host_Error("Mod_IDSP_Load: unknown texFormat (%i, should be 0, 1, 2, or 3)", i);
365                         return;
366                 }
367
368                 Mod_Sprite_SharedSetup(datapointer, LittleLong (pinhlsprite->version), (unsigned int *)(&palette[0][0]), rendermode == SPRHL_ADDITIVE);
369         }
370         else
371                 Host_Error("Mod_IDSP_Load: %s has wrong version number (%i). Only %i (quake), %i (HalfLife), and %i (sprite32) supported",
372                                         loadmodel->name, version, SPRITE_VERSION, SPRITEHL_VERSION, SPRITE32_VERSION);
373
374         // TODO: Note that isanimated only means whether vertices change due to
375         // the animation. This may happen due to sprframe parameters changing.
376         // Mere texture chanegs OTOH shouldn't require isanimated to be 1.
377         loadmodel->surfmesh.isanimated = loadmodel->numframes > 1 || (loadmodel->animscenes && loadmodel->animscenes[0].framecount > 1);
378 }
379
380
381 void Mod_IDS2_Load(dp_model_t *mod, void *buffer, void *bufferend)
382 {
383         int i, version;
384         qboolean fullbright;
385         const dsprite2_t *pinqsprite;
386         skinframe_t *skinframe;
387         float modelradius;
388         int texflags = (r_mipsprites.integer ? TEXF_MIPMAP : 0) | TEXF_ISSPRITE | TEXF_PICMIP | TEXF_COMPRESS | TEXF_ALPHA | TEXF_CLAMP;
389
390         loadmodel->modeldatatypestring = "SPR2";
391
392         loadmodel->type = mod_sprite;
393
394         loadmodel->DrawSky = NULL;
395         loadmodel->Draw = R_Model_Sprite_Draw;
396         loadmodel->DrawDepth = NULL;
397         loadmodel->CompileShadowVolume = NULL;
398         loadmodel->DrawShadowVolume = NULL;
399         loadmodel->DrawLight = NULL;
400         loadmodel->DrawAddWaterPlanes = NULL;
401
402         pinqsprite = (dsprite2_t *)buffer;
403
404         version = LittleLong(pinqsprite->version);
405         if (version != SPRITE2_VERSION)
406                 Host_Error("Mod_IDS2_Load: %s has wrong version number (%i should be 2 (quake 2)", loadmodel->name, version);
407
408         loadmodel->numframes = LittleLong (pinqsprite->numframes);
409         if (loadmodel->numframes < 1)
410                 Host_Error ("Mod_IDS2_Load: Invalid # of frames: %d", loadmodel->numframes);
411         loadmodel->sprite.sprnum_type = SPR_VP_PARALLEL;
412         loadmodel->synctype = ST_SYNC;
413
414         // LordHavoc: hack to allow sprites to be non-fullbright
415         fullbright = true;
416         for (i = 0;i < MAX_QPATH && loadmodel->name[i];i++)
417                 if (loadmodel->name[i] == '!')
418                         fullbright = false;
419
420         loadmodel->animscenes = (animscene_t *)Mem_Alloc(loadmodel->mempool, sizeof(animscene_t) * loadmodel->numframes);
421         loadmodel->sprite.sprdata_frames = (mspriteframe_t *)Mem_Alloc(loadmodel->mempool, sizeof(mspriteframe_t) * loadmodel->numframes);
422         loadmodel->num_textures = loadmodel->numframes;
423         loadmodel->num_texturesperskin = 1;
424         loadmodel->data_textures = (texture_t *)Mem_Alloc(loadmodel->mempool, sizeof(texture_t) * loadmodel->num_textures);
425
426         modelradius = 0;
427         for (i = 0;i < loadmodel->numframes;i++)
428         {
429                 int origin[2], x, y, width, height;
430                 const dsprite2frame_t *pinframe;
431                 mspriteframe_t *sprframe;
432
433                 dpsnprintf(loadmodel->animscenes[i].name, sizeof(loadmodel->animscenes[i].name), "frame %i", i);
434                 loadmodel->animscenes[i].firstframe = i;
435                 loadmodel->animscenes[i].framecount = 1;
436                 loadmodel->animscenes[i].framerate = 10;
437                 loadmodel->animscenes[i].loop = true;
438
439                 pinframe = &pinqsprite->frames[i];
440
441                 origin[0] = LittleLong (pinframe->origin_x);
442                 origin[1] = LittleLong (pinframe->origin_y);
443                 width = LittleLong (pinframe->width);
444                 height = LittleLong (pinframe->height);
445
446                 sprframe = &loadmodel->sprite.sprdata_frames[i];
447
448                 // note that sp2 origin[0] is positive, where as it is negative in
449                 // spr/spr32/hlspr
450                 sprframe->left = -origin[0];
451                 sprframe->right = -origin[0] + width;
452                 sprframe->up = origin[1];
453                 sprframe->down = origin[1] - height;
454
455                 x = (int)max(sprframe->left * sprframe->left, sprframe->right * sprframe->right);
456                 y = (int)max(sprframe->up * sprframe->up, sprframe->down * sprframe->down);
457                 if (modelradius < x + y)
458                         modelradius = x + y;
459         }
460
461         if (cls.state != ca_dedicated)
462         {
463                 for (i = 0;i < loadmodel->numframes;i++)
464                 {
465                         const dsprite2frame_t *pinframe;
466                         pinframe = &pinqsprite->frames[i];
467                         if (!(skinframe = R_SkinFrame_LoadExternal(pinframe->name, texflags, false)))
468                         {
469                                 Con_Printf("Mod_IDS2_Load: failed to load %s", pinframe->name);
470                                 skinframe = R_SkinFrame_LoadMissing();
471                         }
472                         Mod_SpriteSetupTexture(&loadmodel->data_textures[i], skinframe, fullbright, false);
473                 }
474         }
475
476         modelradius = sqrt(modelradius);
477         for (i = 0;i < 3;i++)
478         {
479                 loadmodel->normalmins[i] = loadmodel->yawmins[i] = loadmodel->rotatedmins[i] = -modelradius;
480                 loadmodel->normalmaxs[i] = loadmodel->yawmaxs[i] = loadmodel->rotatedmaxs[i] = modelradius;
481         }
482         loadmodel->radius = modelradius;
483         loadmodel->radius2 = modelradius * modelradius;
484
485         // TODO: Note that isanimated only means whether vertices change due to
486         // the animation. This may happen due to sprframe parameters changing.
487         // Mere texture chanegs OTOH shouldn't require isanimated to be 1.
488         loadmodel->surfmesh.isanimated = loadmodel->numframes > 1 || (loadmodel->animscenes && loadmodel->animscenes[0].framecount > 1);
489 }