]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
changed entity networking prioritization code to use the center of the model rather...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 3 Mar 2007 22:06:57 +0000 (22:06 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 3 Mar 2007 22:06:57 +0000 (22:06 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6940 d7cf8633-e32d-0410-b094-e92efae38249

protocol.c
protocol.h
sv_main.c

index 6e62bddb0c28f5117816ee4c392df07e83098a96..92c3e853c155f18624fbf6ca295771faa9c19803 100644 (file)
@@ -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);
 }
index 8897e92fb24a77344dc8a8638f32b961a67c75f1..c7bbf20503b1ec2b5bf4ec20dc0290f84dcad7b8 100644 (file)
@@ -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;
 
index 2de9b8a39c69993d522ccd3ae8a43a18fd2e21a7..f79d15aef32d96fc46e5dd3190a913a1ed93d7ca 100644 (file)
--- 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)
                {