From 4c357d1b72ef15a540af76b1e62a9ed7952a9563 Mon Sep 17 00:00:00 2001 From: havoc Date: Sat, 3 Mar 2007 22:06:57 +0000 Subject: [PATCH] changed entity networking prioritization code to use the center of the model rather than the origin, this fixes prioritization of doors and lifts which typically have their origin near '0 0 0' rather than inside the entity box git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6940 d7cf8633-e32d-0410-b094-e92efae38249 --- protocol.c | 5 +++-- protocol.h | 5 +++-- sv_main.c | 7 +++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/protocol.c b/protocol.c index 6e62bddb..92c3e853 100644 --- a/protocol.c +++ b/protocol.c @@ -8,6 +8,7 @@ entity_state_t defaultstate = { // ! means this is not sent to client 0,//double time; // ! time this state was built (used on client for interpolation) + {0,0,0},//float netcenter[3]; // ! for network prioritization, this is the center of the bounding box (which may differ from the origin) {0,0,0},//float origin[3]; {0,0,0},//float angles[3]; 0,//int number; // entity number this state is for @@ -35,7 +36,7 @@ entity_state_t defaultstate = 0,//unsigned char tagindex; {32, 32, 32},//unsigned char colormod[3]; // padding to a multiple of 8 bytes (to align the double time) - {0,0,0,0,0,0}//unsigned char unused[6]; // ! + {0,0}//unsigned char unused[2]; // ! }; // LordHavoc: I own protocol ranges 96, 97, 3500-3599 @@ -1681,7 +1682,7 @@ int EntityState5_Priority(entityframe5_database_t *d, int stateindex) Con_DPrintf("Protocol: Runaway loop recursing tagentity links on entity %i\n", stateindex); // now that we have the parent entity we can make some decisions based on // distance from the player - if (VectorDistance(d->states[d->viewentnum].origin, s->origin) < 1024.0f) + if (VectorDistance(d->states[d->viewentnum].netcenter, s->netcenter) < 1024.0f) priority++; return bound(1, priority, E5_PROTOCOL_PRIORITYLEVELS - 1); } diff --git a/protocol.h b/protocol.h index 8897e92f..c7bbf205 100644 --- a/protocol.h +++ b/protocol.h @@ -320,11 +320,12 @@ void Protocol_Names(char *buffer, size_t buffersize); #define RENDER_SHADOW 65536 // cast shadow #define RENDER_LIGHT 131072 // receive light -// this is 88 bytes +// this is 96 bytes typedef struct entity_state_s { // ! means this is not sent to client double time; // ! time this state was built (used on client for interpolation) + float netcenter[3]; // ! for network prioritization, this is the center of the bounding box (which may differ from the origin) float origin[3]; float angles[3]; int number; // entity number this state is for @@ -352,7 +353,7 @@ typedef struct entity_state_s unsigned char tagindex; unsigned char colormod[3]; // padding to a multiple of 8 bytes (to align the double time) - unsigned char unused[6]; + unsigned char unused[2]; } entity_state_t; diff --git a/sv_main.c b/sv_main.c index 2de9b8a3..f79d15ae 100644 --- a/sv_main.c +++ b/sv_main.c @@ -779,10 +779,17 @@ qboolean SV_PrepareEntityForSending (prvm_edict_t *ent, entity_state_t *cs, int cullmaxs[1] = max(cullmaxs[1], cs->origin[1] + specialvisibilityradius); cullmaxs[2] = max(cullmaxs[2], cs->origin[2] + specialvisibilityradius); } + // calculate center of bbox for network prioritization purposes + VectorMAM(0.5f, cullmins, 0.5f, cullmaxs, cs->netcenter); + // if culling box has moved, update pvs cluster links if (!VectorCompare(cullmins, ent->priv.server->cullmins) || !VectorCompare(cullmaxs, ent->priv.server->cullmaxs)) { VectorCopy(cullmins, ent->priv.server->cullmins); VectorCopy(cullmaxs, ent->priv.server->cullmaxs); + // a value of -1 for pvs_numclusters indicates that the links are not + // cached, and should be re-tested each time, this is the case if the + // culling box touches too many pvs clusters to store, or if the world + // model does not support FindBoxClusters ent->priv.server->pvs_numclusters = -1; if (sv.worldmodel && sv.worldmodel->brush.FindBoxClusters) { -- 2.39.2