From: havoc Date: Fri, 25 Nov 2005 01:12:00 +0000 (+0000) Subject: fixed up various bugs with cl_beams_relative, and reenabled smooth sweeping on other... X-Git-Tag: xonotic-v0.1.0preview~4461 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=914f149fccaef4d32f841b865614f6f99551c88d;p=xonotic%2Fdarkplaces.git fixed up various bugs with cl_beams_relative, and reenabled smooth sweeping on other players/enemies git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5823 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cl_main.c b/cl_main.c index 3bb141b4..020fea7d 100644 --- 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) diff --git a/cl_parse.c b/cl_parse.c index 7223ce10..f9f8cd47 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -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)