// (c) Tuomas J. Lukka #include #include namespace Vob { namespace LOD { DBGVAR(dbg, "Lod.TexPoly"); TexAccum::TexAccum() { clear(); } void TexAccum::add(ZPt &p1, ZPt &p2, ZPt &p3, Pt &t1, Pt &t2, Pt &t3) { Vec vp1 = Vec(p2) - Vec(p1); Vec vp2 = Vec(p3) - Vec(p1); Vec vt1 = t2 - t1; Vec vt2 = t3 - t2; double parea = fabs(vp1.cross(vp2)) / 2; double tarea = fabs(vt1.cross(vt2)) / 2; if(parea < 1) return; int exponent; frexp(parea / tarea, &exponent); int mip = exponent / 2; if(mip < 0) return; if(mip >= NLEVELS) mip = NLEVELS-1; this->pixels[mip] += parea; } void TexAccum::clear() { for(int i=0; i