]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - model_sprite.c
Configure all of the CL_MeshEntities* meshes the same, the material flags decide...
[xonotic/darkplaces.git] / model_sprite.c
index 7b683988951dad01320b62957677e96e1c95a679..2dd746957207d11f89d58cc0f028bce9cac2b8c1 100644 (file)
@@ -63,9 +63,11 @@ static void Mod_SpriteSetupTexture(texture_t *texture, skinframe_t *skinframe, q
                skinframe = R_SkinFrame_LoadMissing();
        texture->offsetmapping = OFFSETMAPPING_OFF;
        texture->offsetscale = 1;
+       texture->offsetbias = 0;
        texture->specularscalemod = 1;
        texture->specularpowermod = 1;
        texture->basematerialflags = MATERIALFLAG_WALL;
+       texture->basealpha = 1.0f;
        if (fullbright)
                texture->basematerialflags |= MATERIALFLAG_FULLBRIGHT;
        if (additive)
@@ -73,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(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;
@@ -95,7 +100,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) | (gl_texturecompression_sprites.integer ? TEXF_COMPRESS : 0) | TEXF_ISSPRITE | TEXF_PICMIP | TEXF_ALPHA | TEXF_CLAMP;
+       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;
        modelradius = 0;
 
        if (loadmodel->numframes < 1)
@@ -258,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;
@@ -367,7 +371,10 @@ 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);
 
-       loadmodel->surfmesh.isanimated = loadmodel->numframes > 1 || loadmodel->animscenes[0].framecount > 1;
+       // 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);
 }
 
 
@@ -475,5 +482,8 @@ 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;
+       // 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);
 }