]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
fixed up various bugs with cl_beams_relative, and reenabled smooth sweeping on other...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 25 Nov 2005 01:12:00 +0000 (01:12 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 25 Nov 2005 01:12:00 +0000 (01:12 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5823 d7cf8633-e32d-0410-b094-e92efae38249

cl_main.c
cl_parse.c

index 3bb141b4386146ec07a3cc1d057999eb0c7fbe49..020fea7d65dd8e5547059e795ff463aa008fb691 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -1220,41 +1220,13 @@ void CL_RelinkBeams(void)
                // if coming from the player, update the start position
                //if (b->entity == cl.viewentity)
                //      Matrix4x4_OriginFromMatrix(&cl_entities[cl.viewentity].render.matrix, b->start);
-               if (cl_beams_relative.integer && b->entity == cl.viewentity && b->entity && cl_entities[b->entity].state_current.active && b->relativestartvalid)
+               if (cl_beams_relative.integer && b->entity && cl_entities[b->entity].state_current.active && b->relativestartvalid)
                {
-                       entity_state_t *p = &cl_entities[b->entity].state_previous;
-                       //entity_state_t *c = &cl_entities[b->entity].state_current;
                        entity_render_t *r = &cl_entities[b->entity].render;
-                       matrix4x4_t matrix, imatrix;
-                       if (b->relativestartvalid == 2)
-                       {
-                               // not really valid yet, we need to get the orientation now
-                               // (ParseBeam flagged this because it is received before
-                               //  entities are received, by now they have been received)
-                               // note: because players create lightning in their think
-                               // function (which occurs before movement), they actually
-                               // have some lag in it's location, so compare to the
-                               // previous player state, not the latest
-                               if (b->entity == cl.viewentity)
-                                       Matrix4x4_CreateFromQuakeEntity(&matrix, p->origin[0], p->origin[1], p->origin[2] + 16, cl.viewangles[0], cl.viewangles[1], cl.viewangles[2], 1);
-                               else
-                                       Matrix4x4_CreateFromQuakeEntity(&matrix, p->origin[0], p->origin[1], p->origin[2] + 16, p->angles[0], p->angles[1], p->angles[2], 1);
-                               Matrix4x4_Invert_Simple(&imatrix, &matrix);
-                               Matrix4x4_Transform(&imatrix, b->start, b->relativestart);
-                               Matrix4x4_Transform(&imatrix, b->end, b->relativeend);
-                               b->relativestartvalid = 1;
-                       }
-                       else
-                       {
-                               vec3_t origin;
-                               Matrix4x4_OriginFromMatrix(&r->matrix, origin);
-                               if (b->entity == cl.viewentity)
-                                       Matrix4x4_CreateFromQuakeEntity(&matrix, origin[0], origin[1], origin[2] + 16, cl.viewangles[0], cl.viewangles[1], cl.viewangles[2], 1);
-                               else
-                                       Matrix4x4_CreateFromQuakeEntity(&matrix, origin[0], origin[1], origin[2] + 16, r->angles[0], r->angles[1], r->angles[2], 1);
-                               Matrix4x4_Transform(&matrix, b->relativestart, b->start);
-                               Matrix4x4_Transform(&matrix, b->relativeend, b->end);
-                       }
+                       //Matrix4x4_OriginFromMatrix(&r->matrix, origin);
+                       //Matrix4x4_CreateFromQuakeEntity(&matrix, r->origin[0], r->origin[1], r->origin[2] + 16, r->angles[0], r->angles[1], r->angles[2], 1);
+                       Matrix4x4_Transform(&r->matrix, b->relativestart, b->start);
+                       Matrix4x4_Transform(&r->matrix, b->relativeend, b->end);
                }
 
                if (b->lightning)
index 7223ce10e753ac4b58a64fcc257526210ee0faf4..f9f8cd474c762e1a7e8274b80eb6e68a01657df3 100644 (file)
@@ -860,37 +860,49 @@ void CL_ParseBeam (model_t *m, int lightning)
                CL_ExpandEntities(ent);
 
        // override any beam with the same entity
-       for (i = 0, b = cl_beams;i < cl_max_beams;i++, b++)
+       i = cl_max_beams;
+       if (ent)
+               for (i = 0, b = cl_beams;i < cl_max_beams;i++, b++)
+                       if (b->entity == ent)
+                               break;
+       // if the entity was not found then just replace an unused beam
+       if (i == cl_max_beams)
+               for (i = 0, b = cl_beams;i < cl_max_beams;i++, b++)
+                       if (!b->model || b->endtime < cl.time)
+                               break;
+       if (i < cl_max_beams)
        {
-               if (b->entity == ent && ent)
+               b->entity = ent;
+               b->lightning = lightning;
+               b->model = m;
+               b->endtime = cl.time + 0.2;
+               VectorCopy (start, b->start);
+               VectorCopy (end, b->end);
+               b->relativestartvalid = 0;
+               if (ent && cl_entities[ent].state_current.active)
                {
-                       //b->entity = ent;
-                       b->lightning = lightning;
-                       b->relativestartvalid = (ent && cl_entities[ent].state_current.active) ? 2 : 0;
-                       b->model = m;
-                       b->endtime = cl.time + 0.2;
-                       VectorCopy (start, b->start);
-                       VectorCopy (end, b->end);
-                       return;
-               }
-       }
-
-       // find a free beam
-       for (i = 0, b = cl_beams;i < cl_max_beams;i++, b++)
-       {
-               if (!b->model || b->endtime < cl.time)
-               {
-                       b->entity = ent;
-                       b->lightning = lightning;
-                       b->relativestartvalid = (ent && cl_entities[ent].state_current.active) ? 2 : 0;
-                       b->model = m;
-                       b->endtime = cl.time + 0.2;
-                       VectorCopy (start, b->start);
-                       VectorCopy (end, b->end);
-                       return;
+                       entity_state_t *p;
+                       matrix4x4_t matrix, imatrix;
+                       if (ent == cl.viewentity && cl.movement)
+                               p = &cl_entities[b->entity].state_previous;
+                       else
+                               p = &cl_entities[b->entity].state_current;
+                       // not really valid yet, we need to get the orientation now
+                       // (ParseBeam flagged this because it is received before
+                       //  entities are received, by now they have been received)
+                       // note: because players create lightning in their think
+                       // function (which occurs before movement), they actually
+                       // have some lag in it's location, so compare to the
+                       // previous player state, not the latest
+                       Matrix4x4_CreateFromQuakeEntity(&matrix, p->origin[0], p->origin[1], p->origin[2], -p->angles[0], p->angles[1], p->angles[2], 1);
+                       Matrix4x4_Invert_Simple(&imatrix, &matrix);
+                       Matrix4x4_Transform(&imatrix, b->start, b->relativestart);
+                       Matrix4x4_Transform(&imatrix, b->end, b->relativeend);
+                       b->relativestartvalid = 1;
                }
        }
-       Con_Print("beam list overflow!\n");
+       else
+               Con_Print("beam list overflow!\n");
 }
 
 void CL_ParseTempEntity(void)