]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - r_sprites.c
fix crash when loading .dpm models
[xonotic/darkplaces.git] / r_sprites.c
index bd7d0213c4eb326b0c14583f239f0887758b51c2..0c1b922f910e0eeea7d9ebc634be64c3d24a7518 100644 (file)
@@ -1,10 +1,11 @@
 
 #include "quakedef.h"
+#include "r_shadow.h"
 
-void R_DrawSpriteModelCallback(const void *calldata1, int calldata2)
+void R_Model_Sprite_Draw_TransparentCallback(const entity_render_t *ent, int surfacenumber, const rtlight_t *rtlight)
 {
-       const entity_render_t *ent = (entity_render_t *)calldata1;
        int i;
+       model_t *model = ent->model;
        vec3_t left, up, org, color, diffusecolor, diffusenormal;
        mspriteframe_t *frame;
        float scale;
@@ -13,7 +14,7 @@ void R_DrawSpriteModelCallback(const void *calldata1, int calldata2)
        org[0] = ent->matrix.m[0][3] - r_viewforward[0];
        org[1] = ent->matrix.m[1][3] - r_viewforward[1];
        org[2] = ent->matrix.m[2][3] - r_viewforward[2];
-       switch(ent->model->sprite.sprnum_type)
+       switch(model->sprite.sprnum_type)
        {
        case SPR_VP_PARALLEL_UPRIGHT:
                // flames and such
@@ -38,7 +39,7 @@ void R_DrawSpriteModelCallback(const void *calldata1, int calldata2)
                up[2] = ent->scale;
                break;
        default:
-               Con_Printf("R_SpriteSetup: unknown sprite type %i\n", ent->model->sprite.sprnum_type);
+               Con_Printf("R_SpriteSetup: unknown sprite type %i\n", model->sprite.sprnum_type);
                // fall through to normal sprite
        case SPR_VP_PARALLEL:
                // normal sprite
@@ -73,7 +74,7 @@ void R_DrawSpriteModelCallback(const void *calldata1, int calldata2)
                break;
        }
 
-       R_Mesh_Matrix(&r_identitymatrix);
+       R_Mesh_Matrix(&identitymatrix);
 
        if (!(ent->flags & RENDER_LIGHT))
                color[0] = color[1] = color[2] = 1;
@@ -91,7 +92,7 @@ void R_DrawSpriteModelCallback(const void *calldata1, int calldata2)
        {
                if (ent->frameblend[i].lerp >= 0.01f)
                {
-                       frame = ent->model->sprite.sprdata_frames + ent->frameblend[i].frame;
+                       frame = model->sprite.sprdata_frames + ent->frameblend[i].frame;
                        // FIXME: negate left and right in loader
                        R_DrawSprite(GL_SRC_ALPHA, (ent->effects & EF_ADDITIVE) ? GL_ONE : GL_ONE_MINUS_SRC_ALPHA, frame->skin.base, frame->skin.fog, (ent->effects & EF_NODEPTHTEST), org, left, up, frame->left, frame->right, frame->down, frame->up, color[0], color[1], color[2], ent->alpha * ent->frameblend[i].lerp);
                }
@@ -103,6 +104,6 @@ void R_Model_Sprite_Draw(entity_render_t *ent)
        if (ent->frameblend[0].frame < 0)
                return;
 
-       R_MeshQueue_AddTransparent(ent->effects & EF_NODEPTHTEST ? r_vieworigin : ent->origin, R_DrawSpriteModelCallback, ent, 0);
+       R_MeshQueue_AddTransparent(ent->effects & EF_NODEPTHTEST ? r_vieworigin : ent->origin, R_Model_Sprite_Draw_TransparentCallback, ent, 0, r_shadow_rtlight);
 }