Fix setinfo.
[xonotic/darkplaces.git] / model_sprite.c
index 1515092..215d681 100644 (file)
@@ -67,6 +67,7 @@ static void Mod_SpriteSetupTexture(texture_t *texture, skinframe_t *skinframe, q
        texture->specularscalemod = 1;
        texture->specularpowermod = 1;
        texture->basematerialflags = MATERIALFLAG_WALL;
+       texture->basealpha = 1.0f;
        if (fullbright)
                texture->basematerialflags |= MATERIALFLAG_FULLBRIGHT;
        if (additive)
@@ -74,12 +75,15 @@ static void Mod_SpriteSetupTexture(texture_t *texture, skinframe_t *skinframe, q
        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->materialshaderpass = texture->shaderpasses[0] = Mod_CreateShaderPass(loadmodel->mempool, skinframe);
+       texture->currentskinframe = skinframe;
        texture->surfaceflags = 0;
        texture->supercontents = SUPERCONTENTS_SOLID;
        if (!(texture->basematerialflags & MATERIALFLAG_BLENDED))
                texture->supercontents |= SUPERCONTENTS_OPAQUE;
+       texture->transparentsort = TRANSPARENTSORT_DISTANCE;
+       // WHEN ADDING DEFAULTS HERE, REMEMBER TO PUT DEFAULTS IN ALL LOADERS
+       // JUST GREP FOR "specularscalemod = 1".
 }
 
 extern cvar_t gl_texturecompression_sprites;
@@ -216,7 +220,7 @@ static void Mod_Sprite_SharedSetup(const unsigned char *datapointer, int version
                                                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)))
+                                       if (!(skinframe = R_SkinFrame_LoadExternal(name, texflags | TEXF_COMPRESS, false, false)))
                                        {
                                                unsigned char *pixels = (unsigned char *) Mem_Alloc(loadmodel->mempool, width*height*4);
                                                if (version == SPRITE32_VERSION)
@@ -231,7 +235,7 @@ static void Mod_Sprite_SharedSetup(const unsigned char *datapointer, int version
                                                }
                                                else //if (version == SPRITEHL_VERSION || version == SPRITE_VERSION)
                                                        Image_Copy8bitBGRA(datapointer, pixels, width*height, palette ? palette : palette_bgra_transparent);
-                                               skinframe = R_SkinFrame_LoadInternalBGRA(name, texflags, pixels, width, height, false);
+                                               skinframe = R_SkinFrame_LoadInternalBGRA(name, texflags, pixels, width, height, 0, 0, 0, false);
                                                // texflags |= TEXF_COMPRESS;
                                                Mem_Free(pixels);
                                        }
@@ -259,7 +263,6 @@ static void Mod_Sprite_SharedSetup(const unsigned char *datapointer, int version
        loadmodel->radius2 = modelradius * modelradius;
 }
 
-extern void R_Model_Sprite_Draw(entity_render_t *ent);
 void Mod_IDSP_Load(dp_model_t *mod, void *buffer, void *bufferend)
 {
        int version;
@@ -274,8 +277,6 @@ void Mod_IDSP_Load(dp_model_t *mod, void *buffer, void *bufferend)
        loadmodel->DrawSky = NULL;
        loadmodel->Draw = R_Model_Sprite_Draw;
        loadmodel->DrawDepth = NULL;
-       loadmodel->CompileShadowVolume = NULL;
-       loadmodel->DrawShadowVolume = NULL;
        loadmodel->DrawLight = NULL;
        loadmodel->DrawAddWaterPlanes = NULL;
 
@@ -368,6 +369,9 @@ void Mod_IDSP_Load(dp_model_t *mod, void *buffer, void *bufferend)
                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);
 
+       // TODO: Note that isanimated only means whether vertices change due to
+       // the animation. This may happen due to sprframe parameters changing.
+       // Mere texture chanegs OTOH shouldn't require isanimated to be 1.
        loadmodel->surfmesh.isanimated = loadmodel->numframes > 1 || (loadmodel->animscenes && loadmodel->animscenes[0].framecount > 1);
 }
 
@@ -388,8 +392,6 @@ void Mod_IDS2_Load(dp_model_t *mod, void *buffer, void *bufferend)
        loadmodel->DrawSky = NULL;
        loadmodel->Draw = R_Model_Sprite_Draw;
        loadmodel->DrawDepth = NULL;
-       loadmodel->CompileShadowVolume = NULL;
-       loadmodel->DrawShadowVolume = NULL;
        loadmodel->DrawLight = NULL;
        loadmodel->DrawAddWaterPlanes = NULL;
 
@@ -458,7 +460,7 @@ void Mod_IDS2_Load(dp_model_t *mod, void *buffer, void *bufferend)
                {
                        const dsprite2frame_t *pinframe;
                        pinframe = &pinqsprite->frames[i];
-                       if (!(skinframe = R_SkinFrame_LoadExternal(pinframe->name, texflags, false)))
+                       if (!(skinframe = R_SkinFrame_LoadExternal(pinframe->name, texflags, false, false)))
                        {
                                Con_Printf("Mod_IDS2_Load: failed to load %s", pinframe->name);
                                skinframe = R_SkinFrame_LoadMissing();
@@ -476,5 +478,8 @@ void Mod_IDS2_Load(dp_model_t *mod, void *buffer, void *bufferend)
        loadmodel->radius = modelradius;
        loadmodel->radius2 = modelradius * modelradius;
 
+       // TODO: Note that isanimated only means whether vertices change due to
+       // the animation. This may happen due to sprframe parameters changing.
+       // Mere texture chanegs OTOH shouldn't require isanimated to be 1.
        loadmodel->surfmesh.isanimated = loadmodel->numframes > 1 || (loadmodel->animscenes && loadmodel->animscenes[0].framecount > 1);
 }