Game Development Community

Orphaned polygon warning in map2dif is a bug

by Tom Spilman · in Torque Game Engine · 05/17/2005 (12:34 am) · 3 replies

Ok... i think that i've found that the orphaned polygon warning in map2dif is totally bogus in most cases. EditGeometry::createBrushSurfaces() is the culprit here as it's the one that increments the mNumOrphanPolys count. When it loops for 'j' the code does this:

rSurface.flags  = (brush.mBrushType == DetailBrush)      ? Interior::SurfaceDetail    : 0;
  rSurface.flags |= (brush.mIsAmbiguous == true)           ? Interior::SurfaceAmbiguous : 0;
  rSurface.flags |= (planeFinalWindings[j].numNodes == 0)  ? Interior::SurfaceOrphan    : 0;

  // We know that either all of a surfaces zones are outside zones, or they're
  //  all inside zones.  Therefore, we can just look at the first...
  if (rSurface.winding.numZoneIds > 0)
     rSurface.flags |= (mZones[rSurface.winding.zoneIds[0]]->ambientLit) ? Interior::SurfaceOutsideVisible : 0;

   if (planeFinalWindings[i].numNodes == 0)
      mNumOrphanPolys++;

Notice that Interior::SurfaceOrphan flag is set by checking planeFinalWindings with 'j' yet below planeFinalWindings is checked with 'i' (the outer loop) to increment the mNumOrphanPolys count.

I don't know for a fact that this is a bug in map2dif as i don't totally understand what the code is doing, but i have some strong evidence:

1. Using the index for an outer loop in an inner loop is a common bug.
2. The Interior::SurfaceOrphan flag may never be set on a surface (you can check this by using setInteriorRenderMode), yet it will report orphaned polys on export.
3. Only 5 orphaned polys are reported for a simple DIF cube and not 6.
4. There is no special performance hit that i can find for DIF cube that has no interior surfaces... so what is this orphaned polygons warning telling me in this case?
5. Set a breakpoint in EditBSPNode::breakWindingS() where the numNodes is incremented and you'll see is that every surface of the DIF cube is added to a node... this is what orphaned polygon check seems to be failing to test for.

I'm fairly certain that this is strictly a bug and planeFinalWindings should be indexed with 'j' and not 'i' to increment the mNumOrphanPolys count. Maybe Matt can back me up on this as he's the interior expert around these parts now.

About the author

Tom is a programmer and co-owner of Sickhead Games, LLC.


#1
05/17/2005 (7:38 am)
Thanks Tom for looking into this, that orphaned polys message is quite meaningless at the moment.
#2
05/17/2005 (10:29 am)
Good find Tom! Matt, is he right? :)
#3
06/02/2005 (7:17 pm)
To follow up. Matt told me he just removed the warning in map2dif+ ... so in a way he agrees with me. This fix along with other fixes and new features will be in the Pipeline 1.1 beta release which will be out soon.