added radius and radius2 (squared radius) fields to model structure
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 30 Sep 2002 01:09:13 +0000 (01:09 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 30 Sep 2002 01:09:13 +0000 (01:09 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2476 d7cf8633-e32d-0410-b094-e92efae38249

model_alias.c
model_brush.c
model_shared.h
model_sprite.c

index 5540ed2..b848772 100644 (file)
@@ -524,6 +524,8 @@ void Mod_LoadAliasModel (model_t *mod, void *buffer)
        loadmodel->yawmins[0] = loadmodel->yawmins[1] = -(loadmodel->yawmaxs[0] = loadmodel->yawmaxs[1] = modelyawradius);
        loadmodel->yawmins[2] = loadmodel->normalmins[2];
        loadmodel->yawmaxs[2] = loadmodel->normalmaxs[2];
+       loadmodel->radius = modelradius;
+       loadmodel->radius2 = modelradius * modelradius;
 
        loadmodel->Draw = R_DrawQ1Q2AliasModel;
        loadmodel->DrawSky = NULL;
@@ -784,6 +786,8 @@ void Mod_LoadQ2AliasModel (model_t *mod, void *buffer)
        loadmodel->yawmins[0] = loadmodel->yawmins[1] = -(loadmodel->yawmaxs[0] = loadmodel->yawmaxs[1] = modelyawradius);
        loadmodel->yawmins[2] = loadmodel->normalmins[2];
        loadmodel->yawmaxs[2] = loadmodel->normalmaxs[2];
+       loadmodel->radius = modelradius;
+       loadmodel->radius2 = modelradius * modelradius;
 
        loadmodel->mdlmd2data_triangleneighbors = Mem_Alloc(loadmodel->mempool, loadmodel->numtris * sizeof(int[3]));
        Mod_BuildTriangleNeighbors(loadmodel->mdlmd2data_triangleneighbors, loadmodel->mdlmd2data_indices, loadmodel->numtris);
@@ -990,6 +994,8 @@ void Mod_LoadZymoticModel(model_t *mod, void *buffer)
        loadmodel->yawmins[0] = loadmodel->yawmins[1] = -loadmodel->yawmaxs[0];
        loadmodel->yawmins[2] = loadmodel->normalmins[2];
        loadmodel->yawmaxs[2] = loadmodel->normalmaxs[2];
+       loadmodel->radius = modelradius;
+       loadmodel->radius2 = modelradius * modelradius;
 
        loadmodel->Draw = R_DrawZymoticModel;
        loadmodel->DrawSky = NULL;
index 7382001..5153897 100644 (file)
@@ -2460,6 +2460,8 @@ void Mod_LoadBrushModel (model_t *mod, void *buffer)
                mod->yawmaxs[2] = mod->normalmaxs[2];
                mod->rotatedmins[0] = mod->rotatedmins[1] = mod->rotatedmins[2] = -modelradius;
                mod->rotatedmaxs[0] = mod->rotatedmaxs[1] = mod->rotatedmaxs[2] = modelradius;
+               mod->radius = modelradius;
+               mod->radius2 = modelradius * modelradius;
                // LordHavoc: check for empty submodels (lacrima.bsp has such a glitch)
                if (mod->normalmins[0] > mod->normalmaxs[0] || mod->normalmins[1] > mod->normalmaxs[1] || mod->normalmins[2] > mod->normalmaxs[2])
                {
@@ -2470,6 +2472,8 @@ void Mod_LoadBrushModel (model_t *mod, void *buffer)
                        VectorClear(mod->yawmaxs);
                        VectorClear(mod->rotatedmins);
                        VectorClear(mod->rotatedmaxs);
+                       mod->radius = 0;
+                       mod->radius2 = 0;
                }
 
                mod->numleafs = bm->visleafs;
index 011d53f..c58b238 100644 (file)
@@ -110,8 +110,10 @@ typedef struct model_s
        vec3_t                  yawmins, yawmaxs;
        // bounding box if pitch or roll are used
        vec3_t                  rotatedmins, rotatedmaxs;
-       // usable at any angles
-//     float                   modelradius;
+       // sphere radius, usable at any angles
+       float                   radius;
+       // squared sphere radius for easier comparisons
+       float                   radius2;
 
        // brush model specific
        int                             firstmodelsurface, nummodelsurfaces;
index 1908afb..1026075 100644 (file)
@@ -225,6 +225,8 @@ static void Mod_Sprite_SharedSetup(qbyte *datapointer, int version, int *palette
                loadmodel->normalmins[i] = loadmodel->yawmins[i] = loadmodel->rotatedmins[i] = -modelradius;
                loadmodel->normalmaxs[i] = loadmodel->yawmaxs[i] = loadmodel->rotatedmaxs[i] = modelradius;
        }
+       loadmodel->radius = modelradius;
+       loadmodel->radius2 = modelradius * modelradius;
 }
 
 /*