change default snd_soundradius back to 1000, matching Quake
[divverent/darkplaces.git] / model_sprite.c
index 9fa62fd..7c80ef4 100644 (file)
@@ -26,7 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "image.h"
 
 cvar_t r_mipsprites = {CVAR_SAVE, "r_mipsprites", "1", "mipmaps sprites so they render faster in the distance and do not display noise artifacts"};
-cvar_t r_picmipsprites = {CVAR_SAVE, "r_picmipsprites", "1", "make gl_picmip affect sprites too (saves some graphics memory in sprite heavy games)"};
 cvar_t r_labelsprites_scale = {CVAR_SAVE, "r_labelsprites_scale", "1", "global scale to apply to label sprites before conversion to HUD coordinates"};
 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"};
 
@@ -38,7 +37,6 @@ Mod_SpriteInit
 void Mod_SpriteInit (void)
 {
        Cvar_RegisterVariable(&r_mipsprites);
-       Cvar_RegisterVariable(&r_picmipsprites);
        Cvar_RegisterVariable(&r_labelsprites_scale);
        Cvar_RegisterVariable(&r_labelsprites_roundtopixels);
 }
@@ -47,21 +45,30 @@ static void Mod_SpriteSetupTexture(texture_t *texture, skinframe_t *skinframe, q
 {
        if (!skinframe)
                skinframe = R_SkinFrame_LoadMissing();
+       texture->offsetmapping = OFFSETMAPPING_OFF;
+       texture->offsetscale = 1;
+       texture->specularscalemod = 1;
+       texture->specularpowermod = 1;
        texture->basematerialflags = MATERIALFLAG_WALL;
        if (fullbright)
                texture->basematerialflags |= MATERIALFLAG_FULLBRIGHT;
        if (additive)
                texture->basematerialflags |= MATERIALFLAG_ADD | MATERIALFLAG_BLENDED | MATERIALFLAG_NOSHADOW;
-       else if (skinframe->fog)
+       else if (skinframe->hasalpha)
                texture->basematerialflags |= MATERIALFLAG_ALPHA | MATERIALFLAG_BLENDED | MATERIALFLAG_NOSHADOW;
        texture->currentmaterialflags = texture->basematerialflags;
        texture->numskinframes = 1;
        texture->currentskinframe = texture->skinframes[0] = skinframe;
+       texture->surfaceflags = 0;
+       texture->supercontents = SUPERCONTENTS_SOLID;
+       if (!(texture->basematerialflags & MATERIALFLAG_BLENDED))
+               texture->supercontents |= SUPERCONTENTS_OPAQUE;
 }
 
 static void Mod_Sprite_SharedSetup(const unsigned char *datapointer, int version, const unsigned int *palette, qboolean additive)
 {
-       int                                     i, j, groupframes, realframes, x, y, origin[2], width, height, fullbright;
+       int                                     i, j, groupframes, realframes, x, y, origin[2], width, height;
+       qboolean                        fullbright;
        dspriteframetype_t      *pinframetype;
        dspriteframe_t          *pinframe;
        dspritegroup_t          *pingroup;
@@ -70,7 +77,7 @@ static void Mod_Sprite_SharedSetup(const unsigned char *datapointer, int version
        float                           modelradius, interval;
        char                            name[MAX_QPATH], fogname[MAX_QPATH];
        const void                      *startframes;
-       int                 texflags = (r_mipsprites.integer ? TEXF_MIPMAP : 0) | (r_picmipsprites.integer ? TEXF_PICMIP : 0) | TEXF_ALPHA | TEXF_CLAMP | TEXF_PRECACHE;
+       int                 texflags = (r_mipsprites.integer ? TEXF_MIPMAP : 0) | TEXF_ISSPRITE | TEXF_PICMIP | TEXF_ALPHA | TEXF_CLAMP;
        modelradius = 0;
 
        if (loadmodel->numframes < 1)
@@ -148,7 +155,7 @@ static void Mod_Sprite_SharedSetup(const unsigned char *datapointer, int version
                                Host_Error("Mod_Sprite_SharedSetup: invalid interval");
                }
 
-               sprintf(loadmodel->animscenes[i].name, "frame %i", i);
+               dpsnprintf(loadmodel->animscenes[i].name, sizeof(loadmodel->animscenes[i].name), "frame %i", i);
                loadmodel->animscenes[i].firstframe = realframes;
                loadmodel->animscenes[i].framecount = groupframes;
                loadmodel->animscenes[i].framerate = 1.0f / interval;
@@ -182,17 +189,17 @@ static void Mod_Sprite_SharedSetup(const unsigned char *datapointer, int version
                                {
                                        if (groupframes > 1)
                                        {
-                                               sprintf (name, "%s_%i_%i", loadmodel->name, i, j);
-                                               sprintf (fogname, "%s_%i_%ifog", loadmodel->name, i, j);
+                                               dpsnprintf (name, sizeof(name), "%s_%i_%i", loadmodel->name, i, j);
+                                               dpsnprintf (fogname, sizeof(fogname), "%s_%i_%ifog", loadmodel->name, i, j);
                                        }
                                        else
                                        {
-                                               sprintf (name, "%s_%i", loadmodel->name, i);
-                                               sprintf (fogname, "%s_%ifog", loadmodel->name, i);
+                                               dpsnprintf (name, sizeof(name), "%s_%i", loadmodel->name, i);
+                                               dpsnprintf (fogname, sizeof(fogname), "%s_%ifog", loadmodel->name, i);
                                        }
                                        if (!(skinframe = R_SkinFrame_LoadExternal(name, texflags | TEXF_COMPRESS, false)))
                                        {
-                                               unsigned char *pixels = Mem_Alloc(loadmodel->mempool, width*height*4);
+                                               unsigned char *pixels = (unsigned char *) Mem_Alloc(loadmodel->mempool, width*height*4);
                                                if (version == SPRITE32_VERSION)
                                                {
                                                        for (x = 0;x < width*height;x++)
@@ -340,16 +347,19 @@ void Mod_IDSP_Load(dp_model_t *mod, void *buffer, void *bufferend)
        else
                Host_Error("Mod_IDSP_Load: %s has wrong version number (%i). Only %i (quake), %i (HalfLife), and %i (sprite32) supported",
                                        loadmodel->name, version, SPRITE_VERSION, SPRITEHL_VERSION, SPRITE32_VERSION);
+
+       loadmodel->surfmesh.isanimated = loadmodel->numframes > 1 || loadmodel->animscenes[0].framecount > 1;
 }
 
 
 void Mod_IDS2_Load(dp_model_t *mod, void *buffer, void *bufferend)
 {
-       int i, version, fullbright;
+       int i, version;
+       qboolean fullbright;
        const dsprite2_t *pinqsprite;
        skinframe_t *skinframe;
        float modelradius;
-       int texflags = (r_mipsprites.integer ? TEXF_MIPMAP : 0) | (r_picmipsprites.integer ? TEXF_PICMIP : 0) | TEXF_COMPRESS | TEXF_ALPHA | TEXF_CLAMP | TEXF_PRECACHE;
+       int texflags = (r_mipsprites.integer ? TEXF_MIPMAP : 0) | TEXF_ISSPRITE | TEXF_PICMIP | TEXF_COMPRESS | TEXF_ALPHA | TEXF_CLAMP;
 
        loadmodel->modeldatatypestring = "SPR2";
 
@@ -445,4 +455,6 @@ void Mod_IDS2_Load(dp_model_t *mod, void *buffer, void *bufferend)
        }
        loadmodel->radius = modelradius;
        loadmodel->radius2 = modelradius * modelradius;
+
+       loadmodel->surfmesh.isanimated = loadmodel->numframes > 1 || loadmodel->animscenes[0].framecount > 1;
 }