Exemplo n.º 1
0
//---------------------------------------------------------------------------------
int BoxTestf(float x, float y, float z, float width, float height, float depth)
//---------------------------------------------------------------------------------
{
  return BoxTest(floattov16(x), floattov16(y), floattov16(z),
                 floattov16(width), floattov16(height), floattov16(depth));
}
Exemplo n.º 2
0
void	quadsquare::UpdateAux(const quadcornerdata& cd, const float ViewerLocation[3], float CenterError, clip_result_t vis )
// Does the actual work of updating enabled states and tree growing/shrinking.
{
    BlockUpdateCount++;	//xxxxx

    check_assertion( vis != NotVisible, "Invalid visibility value" );
    if ( vis != NoClip ) {
	vis = ClipSquare( cd );

	if ( vis == NotVisible ) {
	    return;
	}
    }
	
    // Make sure error values are current.
    if (Dirty) {
	RecomputeError(cd);
    }

    int	half = 1 << cd.Level;
    int	whole = half << 1;

    // See about enabling child verts.

    // East vert.
    if ( (EnabledFlags & 1) == 0 && 
	 VertexTest(cd.xorg + whole, Vertex[1].Y, cd.zorg + half, 
		    Error[0], ViewerLocation, cd.Level, East) == true ) 
    {
	EnableEdgeVertex(0, false, cd);	
    }

    // South vert.
    if ( (EnabledFlags & 8) == 0 && 
	 VertexTest(cd.xorg + half, Vertex[4].Y, cd.zorg + whole, 
		    Error[1], ViewerLocation, cd.Level, South) == true ) 
    {
	EnableEdgeVertex(3, false, cd);	
    }

    if (cd.Level > 0) {
	if ((EnabledFlags & 32) == 0) {
	    if (BoxTest(cd.xorg, cd.zorg, half, MinY, MaxY, Error[3], ViewerLocation) == true) EnableChild(1, cd);	// nw child.er
	}
	if ((EnabledFlags & 16) == 0) {
	    if (BoxTest(cd.xorg + half, cd.zorg, half, MinY, MaxY, Error[2], ViewerLocation) == true) EnableChild(0, cd);	// ne child.
	}
	if ((EnabledFlags & 64) == 0) {
	    if (BoxTest(cd.xorg, cd.zorg + half, half, MinY, MaxY, Error[4], ViewerLocation) == true) EnableChild(2, cd);	// sw child.
	}
	if ((EnabledFlags & 128) == 0) {
	    if (BoxTest(cd.xorg + half, cd.zorg + half, half, MinY, MaxY, Error[5], ViewerLocation) == true) EnableChild(3, cd);	// se child.
	}
		
	// Recurse into child quadrants as necessary.
	quadcornerdata	q;
		
	if (EnabledFlags & 32) {
	    SetupCornerData(&q, cd, 1);
	    Child[1]->UpdateAux(q, ViewerLocation, Error[3], vis);
	}
	if (EnabledFlags & 16) {
	    SetupCornerData(&q, cd, 0);
	    Child[0]->UpdateAux(q, ViewerLocation, Error[2], vis);
	}
	if (EnabledFlags & 64) {
	    SetupCornerData(&q, cd, 2);
	    Child[2]->UpdateAux(q, ViewerLocation, Error[4], vis);
	}
	if (EnabledFlags & 128) {
	    SetupCornerData(&q, cd, 3);
	    Child[3]->UpdateAux(q, ViewerLocation, Error[5], vis);
	}
    }
	
    // Test for disabling.  East, South, and center.
    if ( (EnabledFlags & 1) && 
	 SubEnabledCount[0] == 0 && 
	 VertexTest(cd.xorg + whole, Vertex[1].Y, cd.zorg + half, 
		    Error[0], ViewerLocation, cd.Level, East) == false) 
    {
	EnabledFlags &= ~1;
	quadsquare*	s = GetNeighbor(0, cd);
	if (s) s->EnabledFlags &= ~4;
    }

    if ( (EnabledFlags & 8) && 
	 SubEnabledCount[1] == 0 && 
	 VertexTest(cd.xorg + half, Vertex[4].Y, cd.zorg + whole, 
		    Error[1], ViewerLocation, cd.Level, South) == false) 
    {
	EnabledFlags &= ~8;
	quadsquare*	s = GetNeighbor(3, cd);
	if (s) s->EnabledFlags &= ~2;
    }

    if (EnabledFlags == 0 &&
	cd.Parent != NULL &&
	BoxTest(cd.xorg, cd.zorg, whole, MinY, MaxY, CenterError, 
		ViewerLocation) == false)
    {
	// Disable ourself.
	cd.Parent->Square->NotifyChildDisable(*cd.Parent, cd.ChildIndex);	// nb: possibly deletes 'this'.
    }
}