]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
CL_TraceLine can now return what entity was hit (this isn't actually used, and accoun...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 27 Sep 2002 12:02:23 +0000 (12:02 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 27 Sep 2002 12:02:23 +0000 (12:02 +0000)
r_shadows returns, currently only supported on alias models (they are the only ones with a DrawFakeShadow function)
added Matrix4x4_Transform3x3

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2453 d7cf8633-e32d-0410-b094-e92efae38249

18 files changed:
cgamevm.c
chase.c
cl_collision.c
cl_collision.h
cl_main.c
cl_particles.c
gl_models.c
gl_rmain.c
matrixlib.c
matrixlib.h
model_alias.c
model_brush.c
model_shared.h
model_sprite.c
r_crosshairs.c
r_explosion.c
r_light.c
render.h

index d921b7520184a4dce648b7b5461d4225168abe49..dfa6c9ec5bef55bc5f2d5c6082a13244a624da9b 100644 (file)
--- a/cgamevm.c
+++ b/cgamevm.c
@@ -196,7 +196,7 @@ float CGVM_TracePhysics(const float *start, const float *end, const float *world
        middle[2] = (worldmins[2] + worldmaxs[2]) * 0.5f;
        VectorAdd(start, middle, start2);
        VectorAdd(end, middle, end2);
        middle[2] = (worldmins[2] + worldmaxs[2]) * 0.5f;
        VectorAdd(start, middle, start2);
        VectorAdd(end, middle, end2);
-       frac = CL_TraceLine((float *)start2, (float *)end2, impactpos, impactnormal, 0, true);
+       frac = CL_TraceLine((float *)start2, (float *)end2, impactpos, impactnormal, 0, true, NULL);
        VectorSubtract(impactpos, middle, impactpos);
        *impactentnum = -1;
        return frac;
        VectorSubtract(impactpos, middle, impactpos);
        *impactentnum = -1;
        return frac;
diff --git a/chase.c b/chase.c
index fa0f0a03f1fbc064049f709354d7a3ce77df3aa8..be915bcf84057d905944fbc8f5a6ae8069338d70 100644 (file)
--- a/chase.c
+++ b/chase.c
@@ -54,7 +54,7 @@ void Chase_Update (void)
        chase_dest[1] = r_refdef.vieworg[1] + forward[1] * dist;
        chase_dest[2] = r_refdef.vieworg[2] + forward[2] * dist + chase_up.value;
 
        chase_dest[1] = r_refdef.vieworg[1] + forward[1] * dist;
        chase_dest[2] = r_refdef.vieworg[2] + forward[2] * dist + chase_up.value;
 
-       CL_TraceLine (r_refdef.vieworg, chase_dest, stop, normal, 0, true);
+       CL_TraceLine (r_refdef.vieworg, chase_dest, stop, normal, 0, true, NULL);
        chase_dest[0] = stop[0] + forward[0] * 8 + normal[0] * 4;
        chase_dest[1] = stop[1] + forward[1] * 8 + normal[1] * 4;
        chase_dest[2] = stop[2] + forward[2] * 8 + normal[2] * 4;
        chase_dest[0] = stop[0] + forward[0] * 8 + normal[0] * 4;
        chase_dest[1] = stop[1] + forward[1] * 8 + normal[1] * 4;
        chase_dest[2] = stop[2] + forward[2] * 8 + normal[2] * 4;
index 1bc60f72a26ae88411683ccd7e507654d87179dd..0af6d38bd7b52de1ac8ac9a990994d5702250e83 100644 (file)
@@ -30,11 +30,13 @@ physentity_t;
 
 int cl_traceline_endcontents;
 
 
 int cl_traceline_endcontents;
 
-float CL_TraceLine (const vec3_t start, const vec3_t end, vec3_t impact, vec3_t normal, int contents, int hitbmodels)
+float CL_TraceLine (const vec3_t start, const vec3_t end, vec3_t impact, vec3_t normal, int contents, int hitbmodels, entity_render_t **hitent)
 {
        double maxfrac;
        trace_t trace;
 
 {
        double maxfrac;
        trace_t trace;
 
+       if (hitent)
+               *hitent = NULL;
        Mod_CheckLoaded(cl.worldmodel);
        Collision_ClipTrace(&trace, NULL, cl.worldmodel, vec3_origin, vec3_origin, vec3_origin, vec3_origin, start, vec3_origin, vec3_origin, end);
 
        Mod_CheckLoaded(cl.worldmodel);
        Collision_ClipTrace(&trace, NULL, cl.worldmodel, vec3_origin, vec3_origin, vec3_origin, vec3_origin, start, vec3_origin, vec3_origin, end);
 
@@ -44,6 +46,8 @@ float CL_TraceLine (const vec3_t start, const vec3_t end, vec3_t impact, vec3_t
                VectorCopy (trace.plane.normal, normal);
        cl_traceline_endcontents = trace.endcontents;
        maxfrac = trace.fraction;
                VectorCopy (trace.plane.normal, normal);
        cl_traceline_endcontents = trace.endcontents;
        maxfrac = trace.fraction;
+       if (hitent && trace.fraction < 1)
+               *hitent = &cl_entities[0].render;
 
        if (hitbmodels && cl_num_brushmodel_entities)
        {
 
        if (hitbmodels && cl_num_brushmodel_entities)
        {
@@ -76,6 +80,8 @@ float CL_TraceLine (const vec3_t start, const vec3_t end, vec3_t impact, vec3_t
                                if (normal)
                                        VectorCopy(trace.plane.normal, normal);
                                cl_traceline_endcontents = trace.endcontents;
                                if (normal)
                                        VectorCopy(trace.plane.normal, normal);
                                cl_traceline_endcontents = trace.endcontents;
+                               if (hitent)
+                                       *hitent = ent;
                        }
                }
        }
                        }
                }
        }
index 15c1e06afa7dea345f674ce3fe54f3ca452e9564..9e4cda564864aed802df96660f7fa193489b4d85 100644 (file)
@@ -6,6 +6,6 @@
 // (leafs matching contents are considered empty, others are solid)
 extern int cl_traceline_endcontents; // set by TraceLine
 
 // (leafs matching contents are considered empty, others are solid)
 extern int cl_traceline_endcontents; // set by TraceLine
 
-float CL_TraceLine (const vec3_t start, const vec3_t end, vec3_t impact, vec3_t normal, int contents, int hitbmodels);
+float CL_TraceLine (const vec3_t start, const vec3_t end, vec3_t impact, vec3_t normal, int contents, int hitbmodels, entity_render_t **hitent);
 
 #endif
 
 #endif
index f0259e3717c44b3a5231c1033ac4783b8962cfb5..bf38fce51724559602cca8931f37749a597de255 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -644,7 +644,7 @@ static void CL_RelinkNetworkEntities()
                        v2[0] = v[0] * 18 + neworg[0];
                        v2[1] = v[1] * 18 + neworg[1];
                        v2[2] = v[2] * 18 + neworg[2] + 16;
                        v2[0] = v[0] * 18 + neworg[0];
                        v2[1] = v[1] * 18 + neworg[1];
                        v2[2] = v[2] * 18 + neworg[2] + 16;
-                       CL_TraceLine(neworg, v2, v, NULL, 0, true);
+                       CL_TraceLine(neworg, v2, v, NULL, 0, true, NULL);
 
                        CL_AllocDlight (NULL, v, ent->persistent.muzzleflash, 1, 1, 1, 0, 0);
                        ent->persistent.muzzleflash -= cl.frametime * 1000;
 
                        CL_AllocDlight (NULL, v, ent->persistent.muzzleflash, 1, 1, 1, 0, 0);
                        ent->persistent.muzzleflash -= cl.frametime * 1000;
index 1107913bd1635aad743407410a0d98f32efc3d1e..304eb93756150d473e46e7d89cb810d27e803647 100644 (file)
@@ -858,7 +858,7 @@ void CL_MoveParticles (void)
                VectorCopy(p->org, org);
                if (p->bounce)
                {
                VectorCopy(p->org, org);
                if (p->bounce)
                {
-                       if (CL_TraceLine(p->oldorg, p->org, v, normal, 0, true) < 1)
+                       if (CL_TraceLine(p->oldorg, p->org, v, normal, 0, true, NULL) < 1)
                        {
                                VectorCopy(v, p->org);
                                if (p->bounce < 0)
                        {
                                VectorCopy(v, p->org);
                                if (p->bounce < 0)
index ca149f51a97bb6bf625dda1770d6c5f22d8a5c5c..5667f1e9a65aeadcca23f3fd39bcd5202262179a 100644 (file)
@@ -1,5 +1,6 @@
 
 #include "quakedef.h"
 
 #include "quakedef.h"
+#include "cl_collision.h"
 
 cvar_t r_quickmodels = {0, "r_quickmodels", "1"};
 
 
 cvar_t r_quickmodels = {0, "r_quickmodels", "1"};
 
@@ -72,7 +73,7 @@ void R_AliasTransformVerts(int vertcount)
 }
 */
 
 }
 */
 
-void R_AliasLerpVerts(int vertcount,
+void R_AliasLerpVerts(int vertcount, float *vertices, float *normals,
                float lerp1, const trivertx_t *verts1, const vec3_t fscale1, const vec3_t translate1,
                float lerp2, const trivertx_t *verts2, const vec3_t fscale2, const vec3_t translate2,
                float lerp3, const trivertx_t *verts3, const vec3_t fscale3, const vec3_t translate3,
                float lerp1, const trivertx_t *verts1, const vec3_t fscale1, const vec3_t translate1,
                float lerp2, const trivertx_t *verts2, const vec3_t fscale2, const vec3_t translate2,
                float lerp3, const trivertx_t *verts3, const vec3_t fscale3, const vec3_t translate3,
@@ -82,8 +83,8 @@ void R_AliasLerpVerts(int vertcount,
        vec3_t scale1, scale2, scale3, scale4, translate;
        const float *n1, *n2, *n3, *n4;
        float *av, *avn;
        vec3_t scale1, scale2, scale3, scale4, translate;
        const float *n1, *n2, *n3, *n4;
        float *av, *avn;
-       av = aliasvert;
-       avn = aliasvertnorm;
+       av = vertices;
+       avn = normals;
        VectorScale(fscale1, lerp1, scale1);
        if (lerp2)
        {
        VectorScale(fscale1, lerp1, scale1);
        if (lerp2)
        {
@@ -212,7 +213,7 @@ skinframe_t *R_FetchSkinFrame(const entity_render_t *ent)
                return &model->skinframes[model->skinscenes[s].firstframe];
 }
 
                return &model->skinframes[model->skinscenes[s].firstframe];
 }
 
-void R_SetupMDLMD2Frames(const entity_render_t *ent, float colorr, float colorg, float colorb)
+void R_LerpMDLMD2Vertices(const entity_render_t *ent, float *vertices, float *normals)
 {
        const md2frame_t *frame1, *frame2, *frame3, *frame4;
        const trivertx_t *frame1verts, *frame2verts, *frame3verts, *frame4verts;
 {
        const md2frame_t *frame1, *frame2, *frame3, *frame4;
        const trivertx_t *frame1verts, *frame2verts, *frame3verts, *frame4verts;
@@ -226,15 +227,11 @@ void R_SetupMDLMD2Frames(const entity_render_t *ent, float colorr, float colorg,
        frame2verts = &model->mdlmd2data_pose[ent->frameblend[1].frame * model->numverts];
        frame3verts = &model->mdlmd2data_pose[ent->frameblend[2].frame * model->numverts];
        frame4verts = &model->mdlmd2data_pose[ent->frameblend[3].frame * model->numverts];
        frame2verts = &model->mdlmd2data_pose[ent->frameblend[1].frame * model->numverts];
        frame3verts = &model->mdlmd2data_pose[ent->frameblend[2].frame * model->numverts];
        frame4verts = &model->mdlmd2data_pose[ent->frameblend[3].frame * model->numverts];
-       R_AliasLerpVerts(model->numverts,
+       R_AliasLerpVerts(model->numverts, vertices, normals,
                ent->frameblend[0].lerp, frame1verts, frame1->scale, frame1->translate,
                ent->frameblend[1].lerp, frame2verts, frame2->scale, frame2->translate,
                ent->frameblend[2].lerp, frame3verts, frame3->scale, frame3->translate,
                ent->frameblend[3].lerp, frame4verts, frame4->scale, frame4->translate);
                ent->frameblend[0].lerp, frame1verts, frame1->scale, frame1->translate,
                ent->frameblend[1].lerp, frame2verts, frame2->scale, frame2->translate,
                ent->frameblend[2].lerp, frame3verts, frame3->scale, frame3->translate,
                ent->frameblend[3].lerp, frame4verts, frame4->scale, frame4->translate);
-
-       R_LightModel(ent, model->numverts, colorr, colorg, colorb, false);
-
-       //R_AliasTransformVerts(model->numverts);
 }
 
 void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
 }
 
 void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
@@ -311,7 +308,8 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
                        varray_texcoord[0][i] = model->mdlmd2data_texcoords[i] * 8.0f;
                aliasvert = varray_vertex;
                aliasvertcolor = varray_color;
                        varray_texcoord[0][i] = model->mdlmd2data_texcoords[i] * 8.0f;
                aliasvert = varray_vertex;
                aliasvertcolor = varray_color;
-               R_SetupMDLMD2Frames(ent, colorscale, colorscale, colorscale);
+               R_LerpMDLMD2Vertices(ent, aliasvert, aliasvertnorm);
+               R_LightModel(ent, model->numverts, colorscale, colorscale, colorscale, false);
                aliasvert = aliasvertbuf;
                aliasvertcolor = aliasvertcolorbuf;
                R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
                aliasvert = aliasvertbuf;
                aliasvertcolor = aliasvertcolorbuf;
                R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
@@ -335,14 +333,16 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
                memcpy(varray_texcoord[0], model->mdlmd2data_texcoords, model->numverts * sizeof(float[2]));
                aliasvert = varray_vertex;
                aliasvertcolor = varray_color;
                memcpy(varray_texcoord[0], model->mdlmd2data_texcoords, model->numverts * sizeof(float[2]));
                aliasvert = varray_vertex;
                aliasvertcolor = varray_color;
-               R_SetupMDLMD2Frames(ent, colorscale, colorscale, colorscale);
+               R_LerpMDLMD2Vertices(ent, aliasvert, aliasvertnorm);
+               R_LightModel(ent, model->numverts, colorscale, colorscale, colorscale, false);
                aliasvert = aliasvertbuf;
                aliasvertcolor = aliasvertcolorbuf;
                R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
                return;
        }
 
                aliasvert = aliasvertbuf;
                aliasvertcolor = aliasvertcolorbuf;
                R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
                return;
        }
 
-       R_SetupMDLMD2Frames(ent, 1 - fog, 1 - fog, 1 - fog);
+       R_LerpMDLMD2Vertices(ent, aliasvert, aliasvertnorm);
+       R_LightModel(ent, model->numverts, colorscale * (1 - fog), colorscale * (1 - fog), colorscale * (1 - fog), false);
 
        if (colormapped)
        {
 
        if (colormapped)
        {
@@ -471,6 +471,77 @@ void R_DrawQ1Q2AliasModelCallback (const void *calldata1, int calldata2)
        }
 }
 
        }
 }
 
+void R_DrawQ1Q2AliasModelFakeShadow (entity_render_t *ent)
+{
+       int i;
+       rmeshstate_t m;
+       model_t *model;
+       float *v, lightdirection[3], surfnormal[3], planenormal[3], planedist, floororigin[3], v2[3], offset[3], dist1, dist2, frac;
+
+       VectorCopy(ent->origin, v2);
+       v2[2] -= 65536.0f;
+       if (CL_TraceLine(ent->origin, v2, floororigin, surfnormal, 0, false, NULL) == 1)
+               return;
+
+       R_Mesh_Matrix(&ent->matrix);
+
+       model = ent->model;
+       R_Mesh_ResizeCheck(model->numverts);
+
+       memset(&m, 0, sizeof(m));
+       m.blendfunc1 = GL_SRC_ALPHA;
+       m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
+       R_Mesh_State(&m);
+
+       c_alias_polys += model->numtris;
+       R_LerpMDLMD2Vertices(ent, varray_vertex, aliasvertnorm);
+       R_FillColors(varray_color, model->numverts, 0, 0, 0, 0.5);
+
+       // put a light direction in the entity's coordinate space
+       lightdirection[0] = 0.3;
+       lightdirection[1] = 0.1;
+       lightdirection[2] = -1;
+       Matrix4x4_Transform3x3(&ent->inversematrix, lightdirection, offset);
+       VectorNormalizeFast(offset);
+       VectorScale(offset, 65536.0f, offset);
+
+       // put the plane's normal in the entity's coordinate space
+       Matrix4x4_Transform3x3(&ent->inversematrix, surfnormal, planenormal);
+       VectorNormalizeFast(planenormal);
+
+       // put the plane's distance in the entity's coordinate space
+       VectorSubtract(floororigin, ent->origin, floororigin);
+       planedist = DotProduct(floororigin, surfnormal) + 1;
+
+       //Con_Printf("sn: %f %f %f pn: %f %f %f pd: %f\n", surfnormal[0], surfnormal[1], surfnormal[2], planenormal[0], planenormal[1], planenormal[2], planedist);
+       {
+       //int count1 = 0, count2 = 0, count3 = 0;
+       for (i = 0, v = varray_vertex;i < model->numverts;i++, v += 4)
+       {
+               v2[0] = v[0] + offset[0];
+               v2[1] = v[1] + offset[1];
+               v2[2] = v[2] + offset[2];
+               dist1 = DotProduct(v, planenormal) - planedist;
+               dist2 = DotProduct(v2, planenormal) - planedist;
+               //if (dist1 > 0)
+               //      count1++;
+               //if (dist2 > 0)
+               //      count2++;
+               //if (dist1 > 0 != dist2 > 0)
+               //      count3++;
+               if (dist1 > 0 && dist2 < 0)
+               //if (i & 1)
+               {
+                       // clipped
+                       frac = dist1 / (dist1 - dist2);
+                       VectorMA(v, frac, offset, v);
+               }
+       }
+       //Con_Printf("counts %d %d %d\n", count1, count2, count3);
+       }
+       R_Mesh_Draw(model->numverts, model->numtris, model->mdlmd2data_indices);
+}
+
 int ZymoticLerpBones(int count, const zymbonematrix *bonebase, const frameblend_t *blend, const zymbone_t *bone)
 {
        int i;
 int ZymoticLerpBones(int count, const zymbonematrix *bonebase, const frameblend_t *blend, const zymbone_t *bone)
 {
        int i;
@@ -877,4 +948,3 @@ void R_DrawQ1Q2AliasModel(entity_render_t *ent)
        else
                R_DrawQ1Q2AliasModelCallback(ent, 0);
 }
        else
                R_DrawQ1Q2AliasModelCallback(ent, 0);
 }
-
index e17054dd774580a7dc0d6831d6d4efc308bc5ec5..b989580bc93c1592e6a20976bf1ecdcd4660a152 100644 (file)
@@ -51,6 +51,7 @@ unsigned short d_lightstylevalue[256];
 
 cvar_t r_drawentities = {0, "r_drawentities","1"};
 cvar_t r_drawviewmodel = {0, "r_drawviewmodel","1"};
 
 cvar_t r_drawentities = {0, "r_drawentities","1"};
 cvar_t r_drawviewmodel = {0, "r_drawviewmodel","1"};
+cvar_t r_shadows = {CVAR_SAVE, "r_shadows", "1"};
 cvar_t r_speeds = {0, "r_speeds","0"};
 cvar_t r_fullbright = {0, "r_fullbright","0"};
 cvar_t r_wateralpha = {CVAR_SAVE, "r_wateralpha","1"};
 cvar_t r_speeds = {0, "r_speeds","0"};
 cvar_t r_fullbright = {0, "r_fullbright","0"};
 cvar_t r_wateralpha = {CVAR_SAVE, "r_wateralpha","1"};
@@ -218,6 +219,7 @@ void GL_Main_Init(void)
        Cmd_AddCommand ("timerefresh", R_TimeRefresh_f);
        Cvar_RegisterVariable (&r_drawentities);
        Cvar_RegisterVariable (&r_drawviewmodel);
        Cmd_AddCommand ("timerefresh", R_TimeRefresh_f);
        Cvar_RegisterVariable (&r_drawentities);
        Cvar_RegisterVariable (&r_drawviewmodel);
+       Cvar_RegisterVariable (&r_shadows);
        Cvar_RegisterVariable (&r_speeds);
        Cvar_RegisterVariable (&r_fullbrights);
        Cvar_RegisterVariable (&r_wateralpha);
        Cvar_RegisterVariable (&r_speeds);
        Cvar_RegisterVariable (&r_fullbrights);
        Cvar_RegisterVariable (&r_wateralpha);
@@ -459,9 +461,6 @@ static void R_MarkEntities (void)
                        VectorAdd(ent->angles, r_refdef.viewangles, ent->angles);
                }
 
                        VectorAdd(ent->angles, r_refdef.viewangles, ent->angles);
                }
 
-               if (R_CullBox(ent->mins, ent->maxs))
-                       continue;
-
                ent->visframe = r_framecount;
                VectorCopy(ent->angles, v);
                if (!ent->model || ent->model->type != mod_brush)
                ent->visframe = r_framecount;
                VectorCopy(ent->angles, v);
                if (!ent->model || ent->model->type != mod_brush)
@@ -470,6 +469,8 @@ static void R_MarkEntities (void)
                Matrix4x4_Invert_Simple(&ent->inversematrix, &ent->matrix);
                R_LerpAnimation(ent);
                R_UpdateEntLights(ent);
                Matrix4x4_Invert_Simple(&ent->inversematrix, &ent->matrix);
                R_LerpAnimation(ent);
                R_UpdateEntLights(ent);
+               if (R_CullBox(ent->mins, ent->maxs))
+                       continue;
                R_FarClip_Box(ent->mins, ent->maxs);
        }
 }
                R_FarClip_Box(ent->mins, ent->maxs);
        }
 }
@@ -544,6 +545,22 @@ void R_DrawModels (void)
        }
 }
 
        }
 }
 
+void R_DrawModelFakeShadows (void)
+{
+       int i;
+       entity_render_t *ent;
+
+       if (!r_drawentities.integer)
+               return;
+
+       for (i = 0;i < r_refdef.numentities;i++)
+       {
+               ent = r_refdef.entities[i];
+               if (ent->model && ent->model->DrawFakeShadow)
+                       ent->model->DrawFakeShadow(ent);
+       }
+}
+
 static void R_SetFrustum (void)
 {
        int i;
 static void R_SetFrustum (void)
 {
        int i;
@@ -679,6 +696,12 @@ void R_RenderView (void)
        if (!intimerefresh && !r_speeds.integer)
                S_ExtraUpdate ();
 
        if (!intimerefresh && !r_speeds.integer)
                S_ExtraUpdate ();
 
+       if (r_shadows.integer)
+       {
+               R_DrawModelFakeShadows();
+               R_TimeReport("fakeshadows");
+       }
+
        R_DrawModels();
        R_TimeReport("models");
 
        R_DrawModels();
        R_TimeReport("models");
 
index af5ec5ee5697ab7ff25e5cb668bc4769ff1a3e8d..8b7f22bbe5a86c8d729ec79b7ecf992b2a53e9b8 100644 (file)
@@ -364,6 +364,13 @@ void Matrix4x4_Transform4 (const matrix4x4_t *in, const float v[4], float out[4]
        out[3] = v[0] * in->m[3][0] + v[1] * in->m[3][1] + v[2] * in->m[3][2] + v[3] * in->m[3][3];
 }
 
        out[3] = v[0] * in->m[3][0] + v[1] * in->m[3][1] + v[2] * in->m[3][2] + v[3] * in->m[3][3];
 }
 
+void Matrix4x4_Transform3x3 (const matrix4x4_t *in, const float v[3], float out[3])
+{
+       out[0] = v[0] * in->m[0][0] + v[1] * in->m[0][1] + v[2] * in->m[0][2];
+       out[1] = v[0] * in->m[1][0] + v[1] * in->m[1][1] + v[2] * in->m[1][2];
+       out[2] = v[0] * in->m[2][0] + v[1] * in->m[2][1] + v[2] * in->m[2][2];
+}
+
 /*
 void Matrix4x4_SimpleUntransform (const matrix4x4_t *in, const float v[3], float out[3])
 {
 /*
 void Matrix4x4_SimpleUntransform (const matrix4x4_t *in, const float v[3], float out[3])
 {
@@ -707,6 +714,7 @@ void Matrix3x4_Transform (const matrix3x4_t *in, const float v[3], float out[3])
        out[2] = v[0] * in->m[2][0] + v[1] * in->m[2][1] + v[2] * in->m[2][2] + in->m[2][3];
 }
 
        out[2] = v[0] * in->m[2][0] + v[1] * in->m[2][1] + v[2] * in->m[2][2] + in->m[2][3];
 }
 
+/*
 void Matrix3x4_SimpleUntransform (const matrix3x4_t *in, const float v[3], float out[3])
 {
        float t[3];
 void Matrix3x4_SimpleUntransform (const matrix3x4_t *in, const float v[3], float out[3])
 {
        float t[3];
@@ -717,6 +725,15 @@ void Matrix3x4_SimpleUntransform (const matrix3x4_t *in, const float v[3], float
        out[1] = t[0] * in->m[0][1] + t[1] * in->m[1][1] + t[2] * in->m[2][1];
        out[2] = t[0] * in->m[0][2] + t[1] * in->m[1][2] + t[2] * in->m[2][2];
 }
        out[1] = t[0] * in->m[0][1] + t[1] * in->m[1][1] + t[2] * in->m[2][1];
        out[2] = t[0] * in->m[0][2] + t[1] * in->m[1][2] + t[2] * in->m[2][2];
 }
+*/
+
+void Matrix3x4_Transform3x3 (const matrix3x4_t *in, const float v[3], float out[3])
+{
+       out[0] = v[0] * in->m[0][0] + v[1] * in->m[0][1] + v[2] * in->m[0][2] + in->m[0][3];
+       out[1] = v[0] * in->m[1][0] + v[1] * in->m[1][1] + v[2] * in->m[1][2] + in->m[1][3];
+       out[2] = v[0] * in->m[2][0] + v[1] * in->m[2][1] + v[2] * in->m[2][2] + in->m[2][3];
+}
+
 
 // FIXME: optimize
 void Matrix3x4_ConcatTranslate (matrix3x4_t *out, float x, float y, float z)
 
 // FIXME: optimize
 void Matrix3x4_ConcatTranslate (matrix3x4_t *out, float x, float y, float z)
index 81364c68e2de344284f21b478a19c2ea5bc67af6..d8d14752d4a9463d12ddc9a35cd3034696a6f362 100644 (file)
@@ -73,6 +73,8 @@ void Matrix4x4_Transform4 (const matrix4x4_t *in, const float v[4], float out[4]
 // cases (rotation and translation *ONLY*), this attempts to undo the results
 // of Transform
 //void Matrix4x4_SimpleUntransform (const matrix4x4_t *in, const float v[3], float out[3]);
 // cases (rotation and translation *ONLY*), this attempts to undo the results
 // of Transform
 //void Matrix4x4_SimpleUntransform (const matrix4x4_t *in, const float v[3], float out[3]);
+// transforms a direction vector through the rotation part of a matrix
+void Matrix4x4_Transform3x3 (const matrix4x4_t *in, const float v[3], float out[3]);
 
 // ease of use functions
 // immediately applies a Translate to the matrix
 
 // ease of use functions
 // immediately applies a Translate to the matrix
@@ -139,7 +141,9 @@ void Matrix3x4_Transform (const matrix3x4_t *in, const float v[3], float out[3])
 // reverse transforms a 3D vector through a matrix3x4, at least for *simple*
 // cases (rotation and translation *ONLY*), this attempts to undo the results
 // of Transform
 // reverse transforms a 3D vector through a matrix3x4, at least for *simple*
 // cases (rotation and translation *ONLY*), this attempts to undo the results
 // of Transform
-void Matrix3x4_SimpleUntransform (const matrix3x4_t *in, const float v[3], float out[3]);
+//void Matrix3x4_SimpleUntransform (const matrix3x4_t *in, const float v[3], float out[3]);
+// transforms a direction vector through the rotation part of a matrix
+void Matrix3x4_Transform3x3 (const matrix3x4_t *in, const float v[3], float out[3]);
 
 // ease of use functions
 // immediately applies a Translate to the matrix
 
 // ease of use functions
 // immediately applies a Translate to the matrix
index 8e4545de5ca65e014b067b367074e32af24481c6..5540ed20e0dae8c124e88e4a159079e6f75c3081 100644 (file)
@@ -527,7 +527,7 @@ void Mod_LoadAliasModel (model_t *mod, void *buffer)
 
        loadmodel->Draw = R_DrawQ1Q2AliasModel;
        loadmodel->DrawSky = NULL;
 
        loadmodel->Draw = R_DrawQ1Q2AliasModel;
        loadmodel->DrawSky = NULL;
-       loadmodel->DrawShadow = NULL;
+       loadmodel->DrawFakeShadow = R_DrawQ1Q2AliasModelFakeShadow;
 
        loadmodel->mdlmd2data_triangleneighbors = Mem_Alloc(loadmodel->mempool, loadmodel->numtris * sizeof(int[3]));
        Mod_BuildTriangleNeighbors(loadmodel->mdlmd2data_triangleneighbors, loadmodel->mdlmd2data_indices, loadmodel->numtris);
 
        loadmodel->mdlmd2data_triangleneighbors = Mem_Alloc(loadmodel->mempool, loadmodel->numtris * sizeof(int[3]));
        Mod_BuildTriangleNeighbors(loadmodel->mdlmd2data_triangleneighbors, loadmodel->mdlmd2data_indices, loadmodel->numtris);
@@ -604,7 +604,7 @@ void Mod_LoadQ2AliasModel (model_t *mod, void *buffer)
        loadmodel->aliastype = ALIASTYPE_MDLMD2;
        loadmodel->Draw = R_DrawQ1Q2AliasModel;
        loadmodel->DrawSky = NULL;
        loadmodel->aliastype = ALIASTYPE_MDLMD2;
        loadmodel->Draw = R_DrawQ1Q2AliasModel;
        loadmodel->DrawSky = NULL;
-       loadmodel->DrawShadow = NULL;
+       loadmodel->DrawFakeShadow = NULL;
 
        if (LittleLong(pinmodel->num_tris < 1) || LittleLong(pinmodel->num_tris) > MD2MAX_TRIANGLES)
                Host_Error ("%s has invalid number of triangles: %i", loadmodel->name, LittleLong(pinmodel->num_tris));
 
        if (LittleLong(pinmodel->num_tris < 1) || LittleLong(pinmodel->num_tris) > MD2MAX_TRIANGLES)
                Host_Error ("%s has invalid number of triangles: %i", loadmodel->name, LittleLong(pinmodel->num_tris));
@@ -993,5 +993,5 @@ void Mod_LoadZymoticModel(model_t *mod, void *buffer)
 
        loadmodel->Draw = R_DrawZymoticModel;
        loadmodel->DrawSky = NULL;
 
        loadmodel->Draw = R_DrawZymoticModel;
        loadmodel->DrawSky = NULL;
-       loadmodel->DrawShadow = NULL;
+       loadmodel->DrawFakeShadow = NULL;
 }
 }
index 9c0cf4e8328752cb6d43b27a51e2a3aac80cc065..7382001b684239ce9e55e9761e47b04973163797 100644 (file)
@@ -2475,7 +2475,7 @@ void Mod_LoadBrushModel (model_t *mod, void *buffer)
                mod->numleafs = bm->visleafs;
 
                mod->Draw = R_DrawBrushModelNormal;
                mod->numleafs = bm->visleafs;
 
                mod->Draw = R_DrawBrushModelNormal;
-               mod->DrawShadow = NULL;
+               mod->DrawFakeShadow = NULL;
 
                // LordHavoc: only register submodels if it is the world
                // (prevents bsp models from replacing world submodels)
 
                // LordHavoc: only register submodels if it is the world
                // (prevents bsp models from replacing world submodels)
index 9d4c30478a17fb4358f340a1beab6668eb5bdf01..011d53ff540d5a22807482e85ff9b04ab3a9311a 100644 (file)
@@ -198,8 +198,8 @@ typedef struct model_s
        void(*Draw)(struct entity_render_s *ent);
        // draw the model's sky polygons (only used by brush models)
        void(*DrawSky)(struct entity_render_s *ent);
        void(*Draw)(struct entity_render_s *ent);
        // draw the model's sky polygons (only used by brush models)
        void(*DrawSky)(struct entity_render_s *ent);
-       // draw the model's shadows
-       void(*DrawShadow)(struct entity_render_s *ent);
+       // draw a fake shadow for the model
+       void(*DrawFakeShadow)(struct entity_render_s *ent);
 
        // memory pool for allocations
        mempool_t               *mempool;
 
        // memory pool for allocations
        mempool_t               *mempool;
index 3c01af141da58c9c03da162e0efda02cc63186c5..1908afb4a218640ca0198f07764ec28dfda9e3a1 100644 (file)
@@ -244,7 +244,7 @@ void Mod_LoadSpriteModel (model_t *mod, void *buffer)
 
        loadmodel->Draw = R_DrawSpriteModel;
        loadmodel->DrawSky = NULL;
 
        loadmodel->Draw = R_DrawSpriteModel;
        loadmodel->DrawSky = NULL;
-       loadmodel->DrawShadow = NULL;
+       loadmodel->DrawFakeShadow = NULL;
 
        version = LittleLong(((dsprite_t *)buffer)->version);
        if (version == SPRITE_VERSION || SPRITE32_VERSION)
 
        version = LittleLong(((dsprite_t *)buffer)->version);
        if (version == SPRITE_VERSION || SPRITE32_VERSION)
index 438d8549856ac3dbaa0570cbd40c96c900d972a4..ccd49feea8506f487e749ec37eeb1ffbccbfaad9 100644 (file)
@@ -128,7 +128,7 @@ void R_DrawWorldCrosshair(void)
        AngleVectors(cl.viewangles, v2, NULL, NULL);
        //VectorCopy(r_origin, v1);
        VectorMA(v1, 8192, v2, v2);
        AngleVectors(cl.viewangles, v2, NULL, NULL);
        //VectorCopy(r_origin, v1);
        VectorMA(v1, 8192, v2, v2);
-       spritescale = CL_TraceLine(v1, v2, spriteorigin, NULL, 0, true) * (8192.0f / 40.0f) * crosshair_size.value;
+       spritescale = CL_TraceLine(v1, v2, spriteorigin, NULL, 0, true, NULL) * (8192.0f / 40.0f) * crosshair_size.value;
 
        // draw the sprite
        R_DrawCrosshairSprite(pic->tex, spriteorigin, spritescale, color[0], color[1], color[2], color[3]);
 
        // draw the sprite
        R_DrawCrosshairSprite(pic->tex, spriteorigin, spritescale, color[0], color[1], color[2], color[3]);
index 0d5fdf46728ef607e2371bffc335a50d00489c1b..50c3d66f38e04b2d508d6d91e04ca9f915e2e0aa 100644 (file)
@@ -267,7 +267,7 @@ void R_MoveExplosion(explosion_t *e)
                        VectorMA(e->vert[i], frametime, e->vertvel[i], end);
                        if (r_explosionclip.integer)
                        {
                        VectorMA(e->vert[i], frametime, e->vertvel[i], end);
                        if (r_explosionclip.integer)
                        {
-                               if (CL_TraceLine(e->vert[i], end, impact, normal, 0, true) < 1)
+                               if (CL_TraceLine(e->vert[i], end, impact, normal, 0, true, NULL) < 1)
                                {
                                        // clip velocity against the wall
                                        dot = DotProduct(e->vertvel[i], normal) * -1.125f;
                                {
                                        // clip velocity against the wall
                                        dot = DotProduct(e->vertvel[i], normal) * -1.125f;
index 74334c502d53f18b7a1d3a941693d39254becc1f..d2ae578d4c516ee09f7e69e477c321610a025f4c 100644 (file)
--- a/r_light.c
+++ b/r_light.c
@@ -157,7 +157,7 @@ void R_DrawCoronas(void)
        {
                rd = r_dlight + i;
                dist = (DotProduct(rd->origin, vpn) - viewdist);
        {
                rd = r_dlight + i;
                dist = (DotProduct(rd->origin, vpn) - viewdist);
-               if (dist >= 24.0f && CL_TraceLine(rd->origin, r_origin, NULL, NULL, 0, true) == 1)
+               if (dist >= 24.0f && CL_TraceLine(rd->origin, r_origin, NULL, NULL, 0, true, NULL) == 1)
                {
                        scale = r_colorscale * (1.0f / 131072.0f);
                        if (gl_flashblend.integer)
                {
                        scale = r_colorscale * (1.0f / 131072.0f);
                        if (gl_flashblend.integer)
@@ -628,7 +628,7 @@ void R_CompleteLightPoint (vec3_t color, const vec3_t p, int dynamic, const mlea
                        {
                                VectorSubtract (p, sl->origin, v);
                                f = ((1.0f / (DotProduct(v, v) * sl->falloff + sl->distbias)) - sl->subtract);
                        {
                                VectorSubtract (p, sl->origin, v);
                                f = ((1.0f / (DotProduct(v, v) * sl->falloff + sl->distbias)) - sl->subtract);
-                               if (f > 0 && CL_TraceLine(p, sl->origin, NULL, NULL, 0, false) == 1)
+                               if (f > 0 && CL_TraceLine(p, sl->origin, NULL, NULL, 0, false, NULL) == 1)
                                {
                                        f *= d_lightstylevalue[sl->style] * (1.0f / 65536.0f);
                                        VectorMA(color, f, sl->light, color);
                                {
                                        f *= d_lightstylevalue[sl->style] * (1.0f / 65536.0f);
                                        VectorMA(color, f, sl->light, color);
@@ -646,7 +646,7 @@ void R_CompleteLightPoint (vec3_t color, const vec3_t p, int dynamic, const mlea
                        rd = r_dlight + i;
                        VectorSubtract (p, rd->origin, v);
                        f = DotProduct(v, v);
                        rd = r_dlight + i;
                        VectorSubtract (p, rd->origin, v);
                        f = DotProduct(v, v);
-                       if (f < rd->cullradius2 && CL_TraceLine(p, rd->origin, NULL, NULL, 0, false) == 1)
+                       if (f < rd->cullradius2 && CL_TraceLine(p, rd->origin, NULL, NULL, 0, false, NULL) == 1)
                        {
                                f = (1.0f / (f + LIGHTOFFSET)) - rd->subtract;
                                VectorMA(color, f, rd->light, color);
                        {
                                f = (1.0f / (f + LIGHTOFFSET)) - rd->subtract;
                                VectorMA(color, f, rd->light, color);
@@ -759,7 +759,7 @@ void R_LightModel(const entity_render_t *ent, int numverts, float colorr, float
                        VectorSubtract (v, rd->origin, v);
                        if (DotProduct(v, v) < rd->cullradius2)
                        {
                        VectorSubtract (v, rd->origin, v);
                        if (DotProduct(v, v) < rd->cullradius2)
                        {
-                               if (CL_TraceLine(ent->origin, rd->origin, NULL, NULL, 0, false) != 1)
+                               if (CL_TraceLine(ent->origin, rd->origin, NULL, NULL, 0, false, NULL) != 1)
                                        continue;
                                VectorSubtract (ent->origin, rd->origin, v);
                                f = ((1.0f / (DotProduct(v, v) + LIGHTOFFSET)) - rd->subtract);
                                        continue;
                                VectorSubtract (ent->origin, rd->origin, v);
                                f = ((1.0f / (DotProduct(v, v) + LIGHTOFFSET)) - rd->subtract);
@@ -901,7 +901,7 @@ void R_UpdateEntLights(entity_render_t *ent)
                ent->numentlights = 0;
                if (cl.worldmodel)
                        for (i = 0, sl = cl.worldmodel->lights;i < cl.worldmodel->numlights && ent->numentlights < MAXENTLIGHTS;i++, sl++)
                ent->numentlights = 0;
                if (cl.worldmodel)
                        for (i = 0, sl = cl.worldmodel->lights;i < cl.worldmodel->numlights && ent->numentlights < MAXENTLIGHTS;i++, sl++)
-                               if (CL_TraceLine(ent->origin, sl->origin, NULL, NULL, 0, false) == 1)
+                               if (CL_TraceLine(ent->origin, sl->origin, NULL, NULL, 0, false, NULL) == 1)
                                        ent->entlights[ent->numentlights++] = i;
        }
        ent->entlightsframe = r_framecount;
                                        ent->entlights[ent->numentlights++] = i;
        }
        ent->entlightsframe = r_framecount;
index 09dbcd44b05c0ee4495efed0342479afd71dfcaf..21499f90a982dcaa6296e082271906dd15fb5c60 100644 (file)
--- a/render.h
+++ b/render.h
@@ -111,11 +111,12 @@ void R_NewMap (void);
 void R_DrawWorld(entity_render_t *ent);
 void R_DrawParticles(void);
 void R_DrawExplosions(void);
 void R_DrawWorld(entity_render_t *ent);
 void R_DrawParticles(void);
 void R_DrawExplosions(void);
-void R_DrawBrushModelSky (entity_render_t *ent);
-void R_DrawBrushModelNormal (entity_render_t *ent);
-void R_DrawZymoticModel (entity_render_t *ent);
+void R_DrawBrushModelSky(entity_render_t *ent);
+void R_DrawBrushModelNormal(entity_render_t *ent);
+void R_DrawZymoticModel(entity_render_t *ent);
 void R_DrawQ1Q2AliasModel(entity_render_t *ent);
 void R_DrawQ1Q2AliasModel(entity_render_t *ent);
-void R_DrawSpriteModel (entity_render_t *ent);
+void R_DrawQ1Q2AliasModelFakeShadow(entity_render_t *ent);
+void R_DrawSpriteModel(entity_render_t *ent);
 
 // LordHavoc: vertex transform
 #include "transform.h"
 
 // LordHavoc: vertex transform
 #include "transform.h"