]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
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 5540ed20e0dae8c124e88e4a159079e6f75c3081..b848772a8a84ec46e458a9217b7ae98da5442a39 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 7382001b684239ce9e55e9761e47b04973163797..51538971121534d932ea03e58090d99f046d8903 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 011d53ff540d5a22807482e85ff9b04ab3a9311a..c58b238366107190284b47069823af4f2e58e0f8 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 1908afb4a218640ca0198f07764ec28dfda9e3a1..102607514824df60d893b4173aa8a33b126aa439 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;
 }
 
 /*