some culling bug.

This commit is contained in:
Federico Ponchio 2005-02-21 20:49:35 +00:00
parent c2df026728
commit 487f113015
2 changed files with 10 additions and 5 deletions

View File

@ -24,6 +24,9 @@
History
$Log: not supported by cvs2svn $
Revision 1.7 2005/02/20 19:49:44 ponchio
cleaning (a bit more).
Revision 1.6 2005/02/20 18:07:01 ponchio
cleaning.
@ -79,13 +82,15 @@ namespace nxs {
if(culling) {
float remote = frustum.Remoteness(sph.Center(), sph.Radius());
if(remote > 0) {
//TODO remoteness is bugged when the sphere is really close
//FIX it!
// TODO FIXME remoteness is bugged... (not much only bit
//if we are close to the surface, the projection of
//the bounding sphere in screen space comes out too small
//just using resolution and radius. Im too lazy to fix it.
if(frustum.IsOutside(sph.Center(), sph.Radius()))
visible = false;
error /= remote;
} else if(entry.cone.Backface(sph, frustum.ViewPoint())) {
visible = false;
//visible = false;
}
}
return error;

View File

@ -155,7 +155,7 @@ void NCone3s::Import(const ANCone3f &c) {
bool NCone3s::Backface(const vcg::Sphere3f &sphere,
const vcg::Point3f &view) const {
vcg::Point3f norm(n[0]/32766.0f, n[1]/32766.0f, n[2]/32766.0f);
vcg::Point3f d = (sphere.Center() + norm * sphere.Radius()) - view;
vcg::Point3f d = (sphere.Center() - norm * sphere.Radius()) - view;
norm *= n[3]/3276.0f;
float f = d * norm;
@ -167,7 +167,7 @@ bool NCone3s::Backface(const vcg::Sphere3f &sphere,
bool NCone3s::Frontface(const vcg::Sphere3f &sphere,
const vcg::Point3f &view) const {
vcg::Point3f norm(n[0]/32766.0f, n[1]/32766.0f, n[2]/32766.0f);
vcg::Point3f d = (sphere.Center() - norm * sphere.Radius()) - view;
vcg::Point3f d = (sphere.Center() + norm * sphere.Radius()) - view;
norm *= n[3]/3276.0f;
float f = -d * norm;