what's wrong with the following?
From: Paul Holverda (_paulholverda__at_hotmail.com)
Date: 12/31/03
- Next message: David Alex Lamb: "comp.lang.java.{help,programmer} - what they're for (mini-FAQ 2002-12-28)"
- Previous message: Andrew Thompson: "Re: SSCCE 1st draft.."
- Next in thread: VisionSet: "Re: what's wrong with the following?"
- Reply: VisionSet: "Re: what's wrong with the following?"
- Reply: Andrew Thompson: "Re: what's wrong with the following?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 31 Dec 2003 10:41:22 +0100
Hey all I got a problem with the following code, somehow i got in an
endless Loop when i enter the "polyList2.addPoly( newPolygon )" area
so basically the error is in the Poly class I believe?
But why is polyList1.addPoly( newPolygon ) working correctly??! I did some
debuggin and the endless loop is in the addPoly method, to be more
specific in while(!isLast() ) part of it.
//SNIPPET OF CSG CLASS
for ( int i = 0; i < WorldLoader.compiledBrushList.length; i++ )
{
// Clear the clip flag for each new brush to be clipped.
clip = false;
brush1 = WorldLoader.compiledBrushList[i];
// Copy the polygons from brush1 to polylist1
for ( int loop = 0; loop < brush1.polys.length; loop++ )
{
Poly newPolygon = new Poly();
newPolygon = brush1.polys[loop];
if ( polyList1 != null )
{
polyList1.addPoly( newPolygon );
}
else
polyList1 = newPolygon;
}
for ( int j = 0; j < WorldLoader.compiledBrushList.length;
i++ )
{
brush2 = WorldLoader.compiledBrushList[j];
// If brush1 is the same as brush2 then we are halfway
through
// clipping the brushes against each other so we set the
clip
// flag for further operations and continue.
if ( brush1.equals( brush2 ) )
{
clip = true;
continue;
}
for ( int loop = 0; loop < brush2.polys.length; loop++ )
{
Poly newPolygon = new Poly();
newPolygon = brush2.polys[loop];
if ( polyList2 != null )
{
polyList2.addPoly( newPolygon );
}
else
polyList2 = newPolygon;
}
And for completeness here is a snippet of the POLY class:
/**
* This method will add a polygon to a linked list
* @param p Poly
*/
public void addPoly( Poly p )
{
if ( p != null )
{
if ( isLast() )
{
next = p;
return;
}
Poly pPoly = next;
while ( !pPoly.isLast() )
{
pPoly = pPoly.getNext();
}
pPoly.next = p;
}
}
public Poly getNext()
{
return next;
}
public boolean isLast()
{
if ( next == null )
{
return true;
}
return false;
}
thanks in advance,
Paul
- Next message: David Alex Lamb: "comp.lang.java.{help,programmer} - what they're for (mini-FAQ 2002-12-28)"
- Previous message: Andrew Thompson: "Re: SSCCE 1st draft.."
- Next in thread: VisionSet: "Re: what's wrong with the following?"
- Reply: VisionSet: "Re: what's wrong with the following?"
- Reply: Andrew Thompson: "Re: what's wrong with the following?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]