fix mapmodel occlusion when using pitch and roll

may need a bit more work, though
This commit is contained in:
ac-stef
2015-06-05 16:00:03 +02:00
parent fc0c6347f9
commit 3d1f7d9b95
5 changed files with 20 additions and 13 deletions
+1 -1
View File
@@ -272,7 +272,7 @@ struct md2 : vertmodel
per_idents = true;
loadingmd2 = 0;
loopv(parts) parts[i]->scaleverts(scale/16.0f, vec(translate.x, -translate.y, translate.z));
radius = calcradius();
radius = calcradius(zradius);
if(shadowdist) calcneighbors();
calcbbs();
return loaded = true;
+1 -1
View File
@@ -248,7 +248,7 @@ struct md3 : vertmodel
if(skin==notexture) conoutf("could not load model skin for %s", name1);
}
loopv(parts) parts[i]->scaleverts(scale/16.0f, vec(translate.x, -translate.y, translate.z));
radius = calcradius();
radius = calcradius(zradius);
if(shadowdist) calcneighbors();
calcbbs();
return loaded = true;
+2 -2
View File
@@ -42,12 +42,12 @@ class dynent;
struct model
{
bool cullface, vertexlight, alphablend; //ALX Alpha channel models
float alphatest, translucency, scale, radius, shadowdist;
float alphatest, translucency, scale, radius, zradius, shadowdist;
vec translate;
int cachelimit, batch;
//model() : cullface(true), vertexlight(false), alphatest(0.9f), translucency(0.25f), scale(1), radius(0), shadowdist(0), translate(0, 0, 0), cachelimit(8), batch(-1) {}
model() : cullface(true), vertexlight(false), alphablend(false), alphatest(0.9f), translucency(0.25f), scale(1), radius(0), shadowdist(0), translate(0, 0, 0), cachelimit(8), batch(-1) {}
model() : cullface(true), vertexlight(false), alphablend(false), alphatest(0.9f), translucency(0.25f), scale(1), radius(0), zradius(0), shadowdist(0), translate(0, 0, 0), cachelimit(8), batch(-1) {}
virtual ~model() {}
virtual bool load() = 0;
+6 -1
View File
@@ -612,7 +612,12 @@ void rendermodel(const char *mdl, int anim, int tex, float rad, const vec &o, fl
if(rad >= 0)
{
if(!rad) rad = m->radius * scale;
if(!rad)
{
rad = m->radius;
if(roll != 0 || pitch != 0) rad = max(m->radius, m->zradius); // FIXME: this assumes worst-case even for small angles and should be eased up (especially for lamp posts)
rad *= scale;
}
if(isoccluded(camera1->o.x, camera1->o.y, o.x-rad, o.y-rad, rad*2)) return;
}
+10 -8
View File
@@ -566,10 +566,11 @@ __attribute__((optimize(2)))
return vert;
}
float calcradius()
float calcradius(float &zradius)
{
float rad = 0;
loopi(numverts) rad = max(rad, verts[i].magnitudexy());
float rad = 0, zrad = 0;
loopi(numverts) rad = max(rad, verts[i].magnitudexy()), zrad = max(zrad, fabsf(verts[i].z));
zradius = zrad;
return rad;
}
@@ -1195,10 +1196,10 @@ __attribute__((optimize(2)))
return s;
}
float calcradius()
float calcradius(float &zradius)
{
float rad = 0;
loopv(meshes) rad = max(rad, meshes[i]->calcradius());
float rad = 0, zrad = 0;
loopv(meshes) rad = max(rad, meshes[i]->calcradius(zrad)), zradius = max(zradius, zrad);
return rad;
}
@@ -1260,9 +1261,10 @@ __attribute__((optimize(2)))
return parts.length()==1 && parts[0]->shadows;
}
float calcradius()
float calcradius(float &zradius)
{
return parts.empty() ? 0.0f : parts[0]->calcradius();
zradius = 0;
return parts.empty() ? 0.0f : parts[0]->calcradius(zradius);
}
void calcneighbors()