1
0
forked from 0ad/0ad
0ad/source/dcdt/se/sr_cfg_manager.cpp
janwas 5bf9bca9ef fix/disable warnings.
there are too many W4 and "potentially uninitialized", so those are
disabled by 0ad_warning_disable.h.

the silly "int x = strlen" and very dangerous "int x = (void*)p" (and
vice versa) problems are fixed.

This was SVN commit r5526.
2007-12-23 12:18:57 +00:00

36 lines
1.1 KiB
C++

#include "precompiled.h"
#include "0ad_warning_disable.h"
# include "sr_cfg_manager.h"
//=========================== SrCfgManagerBase ========================================
// ps: could try each "level check" in a new thread
bool SrCfgManagerBase::visible ( const srcfg* ct0, const srcfg* ct1, srcfg* ct, float prec )
{
float segs, dseg, dt, t;
float len = dist ( ct0, ct1 );
int k = 1; // k is the current level being tested
while ( true )
{ // test the 2^(k-1) tests of level k:
segs = (float) sr_pow ( 2, k );
dseg = 1.0f / segs;
dt = dseg*2.0f;
//sr_out<<"level="<<k<<srnl;
//sr_out<<"segs="<<segs<<srnl;
for ( t=dseg; t<1.0f; t+=dt )
{ interp ( ct0, ct1, t, ct );
//sr_out<<"t="<<t<<srnl;
if ( !valid(ct) ) return false;
}
//sr_out<<"len/segs="<<(len/segs)<<" prec="<<prec<<srnl;
if ( len/segs<=prec ) return true; // safe edge up to prec
k++; // increment level
}
}
//============================= End of File ===========================================