]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - model_sprite.c
model_shared: Rename dp_model_t to model_t, to avoid confusion with the dpm format
[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 = {CF_CLIENT | CF_ARCHIVE, "r_mipsprites", "1", "mipmaps sprites so they render faster in the distance and do not display noise artifacts"};
29 cvar_t r_labelsprites_scale = {CF_CLIENT | CF_ARCHIVE, "r_labelsprites_scale", "1", "global scale to apply to label sprites before conversion to HUD coordinates"};
30 cvar_t r_labelsprites_roundtopixels = {CF_CLIENT | CF_ARCHIVE, "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 = {CF_CLIENT | CF_ARCHIVE, "r_overheadsprites_perspective", "5", "fake perspective effect for SPR_OVERHEAD sprites"};
32 cvar_t r_overheadsprites_pushback = {CF_CLIENT | CF_ARCHIVE, "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 = {CF_CLIENT | CF_ARCHIVE, "r_overheadsprites_scalex", "1", "additional scale for overhead sprites for x axis"};
34 cvar_t r_overheadsprites_scaley = {CF_CLIENT | CF_ARCHIVE, "r_overheadsprites_scaley", "1", "additional scale for overhead sprites for y axis"};
35 cvar_t r_track_sprites = {CF_CLIENT | CF_ARCHIVE, "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 = {CF_CLIENT | CF_ARCHIVE, "r_track_sprites_flags", "1", "1: Rotate sprites accordingly, 2: Make it a continuous rotation"};
37 cvar_t r_track_sprites_scalew = {CF_CLIENT | CF_ARCHIVE, "r_track_sprites_scalew", "1", "width scaling of tracked sprites"};
38 cvar_t r_track_sprites_scaleh = {CF_CLIENT | CF_ARCHIVE, "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, qbool fullbright, qbool 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->materialshaderpass = texture->shaderpasses[0] = Mod_CreateShaderPass(loadmodel->mempool, skinframe);
79         texture->currentskinframe = 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, qbool additive)
92 {
93         int                                     i, j, groupframes, realframes, x, y, origin[2], width, height;
94         qbool                   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         // LadyHavoc: 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, 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, 0, 0, 0, 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(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->DrawLight = NULL;
281         loadmodel->DrawAddWaterPlanes = NULL;
282
283         version = LittleLong(((dsprite_t *)buffer)->version);
284         if (version == SPRITE_VERSION || version == SPRITE32_VERSION)
285         {
286                 dsprite_t *pinqsprite;
287
288                 pinqsprite = (dsprite_t *)datapointer;
289                 datapointer += sizeof(dsprite_t);
290
291                 loadmodel->numframes = LittleLong (pinqsprite->numframes);
292                 loadmodel->sprite.sprnum_type = LittleLong (pinqsprite->type);
293                 loadmodel->synctype = (synctype_t)LittleLong (pinqsprite->synctype);
294
295                 Mod_Sprite_SharedSetup(datapointer, LittleLong (pinqsprite->version), NULL, false);
296         }
297         else if (version == SPRITEHL_VERSION)
298         {
299                 int i, rendermode;
300                 unsigned char palette[256][4];
301                 const unsigned char *in;
302                 dspritehl_t *pinhlsprite;
303
304                 pinhlsprite = (dspritehl_t *)datapointer;
305                 datapointer += sizeof(dspritehl_t);
306
307                 loadmodel->numframes = LittleLong (pinhlsprite->numframes);
308                 loadmodel->sprite.sprnum_type = LittleLong (pinhlsprite->type);
309                 loadmodel->synctype = (synctype_t)LittleLong (pinhlsprite->synctype);
310                 rendermode = pinhlsprite->rendermode;
311
312                 in = datapointer;
313                 datapointer += 2;
314                 i = in[0] + in[1] * 256;
315                 if (i != 256)
316                         Host_Error ("Mod_IDSP_Load: unexpected number of palette colors %i (should be 256)", i);
317                 in = datapointer;
318                 datapointer += 768;
319                 switch(rendermode)
320                 {
321                 case SPRHL_OPAQUE:
322                         for (i = 0;i < 256;i++)
323                         {
324                                 palette[i][2] = in[i*3+0];
325                                 palette[i][1] = in[i*3+1];
326                                 palette[i][0] = in[i*3+2];
327                                 palette[i][3] = 255;
328                         }
329                         break;
330                 case SPRHL_ADDITIVE:
331                         for (i = 0;i < 256;i++)
332                         {
333                                 palette[i][2] = in[i*3+0];
334                                 palette[i][1] = in[i*3+1];
335                                 palette[i][0] = in[i*3+2];
336                                 palette[i][3] = 255;
337                         }
338                         // also passes additive == true to Mod_Sprite_SharedSetup
339                         break;
340                 case SPRHL_INDEXALPHA:
341                         for (i = 0;i < 256;i++)
342                         {
343                                 palette[i][2] = in[765];
344                                 palette[i][1] = in[766];
345                                 palette[i][0] = in[767];
346                                 palette[i][3] = i;
347                                 in += 3;
348                         }
349                         break;
350                 case SPRHL_ALPHATEST:
351                         for (i = 0;i < 256;i++)
352                         {
353                                 palette[i][2] = in[i*3+0];
354                                 palette[i][1] = in[i*3+1];
355                                 palette[i][0] = in[i*3+2];
356                                 palette[i][3] = 255;
357                         }
358                         palette[255][0] = palette[255][1] = palette[255][2] = palette[255][3] = 0;
359                         // should this use alpha test or alpha blend?  (currently blend)
360                         break;
361                 default:
362                         Host_Error("Mod_IDSP_Load: unknown texFormat (%i, should be 0, 1, 2, or 3)", i);
363                         return;
364                 }
365
366                 Mod_Sprite_SharedSetup(datapointer, LittleLong (pinhlsprite->version), (unsigned int *)(&palette[0][0]), rendermode == SPRHL_ADDITIVE);
367         }
368         else
369                 Host_Error("Mod_IDSP_Load: %s has wrong version number (%i). Only %i (quake), %i (HalfLife), and %i (sprite32) supported",
370                                         loadmodel->name, version, SPRITE_VERSION, SPRITEHL_VERSION, SPRITE32_VERSION);
371
372         // TODO: Note that isanimated only means whether vertices change due to
373         // the animation. This may happen due to sprframe parameters changing.
374         // Mere texture chanegs OTOH shouldn't require isanimated to be 1.
375         loadmodel->surfmesh.isanimated = loadmodel->numframes > 1 || (loadmodel->animscenes && loadmodel->animscenes[0].framecount > 1);
376 }
377
378
379 void Mod_IDS2_Load(model_t *mod, void *buffer, void *bufferend)
380 {
381         int i, version;
382         qbool fullbright;
383         const dsprite2_t *pinqsprite;
384         skinframe_t *skinframe;
385         float modelradius;
386         int texflags = (r_mipsprites.integer ? TEXF_MIPMAP : 0) | TEXF_ISSPRITE | TEXF_PICMIP | TEXF_COMPRESS | TEXF_ALPHA | TEXF_CLAMP;
387
388         loadmodel->modeldatatypestring = "SPR2";
389
390         loadmodel->type = mod_sprite;
391
392         loadmodel->DrawSky = NULL;
393         loadmodel->Draw = R_Model_Sprite_Draw;
394         loadmodel->DrawDepth = NULL;
395         loadmodel->DrawLight = NULL;
396         loadmodel->DrawAddWaterPlanes = NULL;
397
398         pinqsprite = (dsprite2_t *)buffer;
399
400         version = LittleLong(pinqsprite->version);
401         if (version != SPRITE2_VERSION)
402                 Host_Error("Mod_IDS2_Load: %s has wrong version number (%i should be 2 (quake 2)", loadmodel->name, version);
403
404         loadmodel->numframes = LittleLong (pinqsprite->numframes);
405         if (loadmodel->numframes < 1)
406                 Host_Error ("Mod_IDS2_Load: Invalid # of frames: %d", loadmodel->numframes);
407         loadmodel->sprite.sprnum_type = SPR_VP_PARALLEL;
408         loadmodel->synctype = ST_SYNC;
409
410         // LadyHavoc: hack to allow sprites to be non-fullbright
411         fullbright = true;
412         for (i = 0;i < MAX_QPATH && loadmodel->name[i];i++)
413                 if (loadmodel->name[i] == '!')
414                         fullbright = false;
415
416         loadmodel->animscenes = (animscene_t *)Mem_Alloc(loadmodel->mempool, sizeof(animscene_t) * loadmodel->numframes);
417         loadmodel->sprite.sprdata_frames = (mspriteframe_t *)Mem_Alloc(loadmodel->mempool, sizeof(mspriteframe_t) * loadmodel->numframes);
418         loadmodel->num_textures = loadmodel->numframes;
419         loadmodel->num_texturesperskin = 1;
420         loadmodel->data_textures = (texture_t *)Mem_Alloc(loadmodel->mempool, sizeof(texture_t) * loadmodel->num_textures);
421
422         modelradius = 0;
423         for (i = 0;i < loadmodel->numframes;i++)
424         {
425                 int origin[2], x, y, width, height;
426                 const dsprite2frame_t *pinframe;
427                 mspriteframe_t *sprframe;
428
429                 dpsnprintf(loadmodel->animscenes[i].name, sizeof(loadmodel->animscenes[i].name), "frame %i", i);
430                 loadmodel->animscenes[i].firstframe = i;
431                 loadmodel->animscenes[i].framecount = 1;
432                 loadmodel->animscenes[i].framerate = 10;
433                 loadmodel->animscenes[i].loop = true;
434
435                 pinframe = &pinqsprite->frames[i];
436
437                 origin[0] = LittleLong (pinframe->origin_x);
438                 origin[1] = LittleLong (pinframe->origin_y);
439                 width = LittleLong (pinframe->width);
440                 height = LittleLong (pinframe->height);
441
442                 sprframe = &loadmodel->sprite.sprdata_frames[i];
443
444                 // note that sp2 origin[0] is positive, where as it is negative in
445                 // spr/spr32/hlspr
446                 sprframe->left = -origin[0];
447                 sprframe->right = -origin[0] + width;
448                 sprframe->up = origin[1];
449                 sprframe->down = origin[1] - height;
450
451                 x = (int)max(sprframe->left * sprframe->left, sprframe->right * sprframe->right);
452                 y = (int)max(sprframe->up * sprframe->up, sprframe->down * sprframe->down);
453                 if (modelradius < x + y)
454                         modelradius = x + y;
455         }
456
457         if (cls.state != ca_dedicated)
458         {
459                 for (i = 0;i < loadmodel->numframes;i++)
460                 {
461                         const dsprite2frame_t *pinframe;
462                         pinframe = &pinqsprite->frames[i];
463                         if (!(skinframe = R_SkinFrame_LoadExternal(pinframe->name, texflags, false, false)))
464                         {
465                                 Con_Printf(CON_ERROR "Mod_IDS2_Load: failed to load %s", pinframe->name);
466                                 skinframe = R_SkinFrame_LoadMissing();
467                         }
468                         Mod_SpriteSetupTexture(&loadmodel->data_textures[i], skinframe, fullbright, false);
469                 }
470         }
471
472         modelradius = sqrt(modelradius);
473         for (i = 0;i < 3;i++)
474         {
475                 loadmodel->normalmins[i] = loadmodel->yawmins[i] = loadmodel->rotatedmins[i] = -modelradius;
476                 loadmodel->normalmaxs[i] = loadmodel->yawmaxs[i] = loadmodel->rotatedmaxs[i] = modelradius;
477         }
478         loadmodel->radius = modelradius;
479         loadmodel->radius2 = modelradius * modelradius;
480
481         // TODO: Note that isanimated only means whether vertices change due to
482         // the animation. This may happen due to sprframe parameters changing.
483         // Mere texture chanegs OTOH shouldn't require isanimated to be 1.
484         loadmodel->surfmesh.isanimated = loadmodel->numframes > 1 || (loadmodel->animscenes && loadmodel->animscenes[0].framecount > 1);
485 }