Map2Dif - Removal of intersecting surfaces, where?
by Stefan Lundmark · in Torque Game Engine · 09/22/2007 (9:28 am) · 2 replies
Does anyone know where the intersection detection happens in Map2Dif? The kind of detection that is used to determine if a surface should be deleted or not.
I searched for intersecting and intersection, and found a few hits but none made any sense and if I made them always return true or false, no logical results were given in the export.. it looked like random faces were dropped.
I know any of the constructor guys probably knows, but I figured I'd save sending them an email and ask here instead.
I searched for intersecting and intersection, and found a few hits but none made any sense and if I made them always return true or false, no logical results were given in the export.. it looked like random faces were dropped.
I know any of the constructor guys probably knows, but I figured I'd save sending them an email and ask here instead.
About the author
#2
Edit: For anyone trying this, it won't work as simply as removing any of the codeblocks as the lightmapper will choke on that.
09/26/2007 (9:03 am)
Wow, thanks Matt!Edit: For anyone trying this, it won't work as simply as removing any of the codeblocks as the lightmapper will choke on that.
Associate Matt Fairfax
PopCap
You want to start in EditBSPNode::breakWindingS() in bspNode.cc.
The actual place where it removes the hidden face is right at the top in this code block:
// Toss if we're in someone else's zone... if (sourceBrush->brushId != definingSolid->brushId) return;Getting to that point is a little complicated though.
First, there is the creation of the bsp tree itself (which starts over in EditGeometry::buildBSP() but procedes quickly to EditBSPNode::createBSP(). The meat of the bsp generation happens in splitBrush() and clipWindingToPlaneFront().
Once you have the bsp tree, the brush polygons are pushed into that tree via the mBSPRoot->breakWinding() call in EditGeometry::createBrushSurfaces() which leads us to our EditBSPNode::breakWindingS() above.
In EditBSPNode::breakWindingS() the main three pieces of code to look at is the surface removal I pasted above, the calls to clipWindingToPlaneFront() (this is where it attempts it "intersect" the polygon with the bsp node plane), and the call to collapseWindings() near the end of the function.
Most of the geometry problems/error messages from map2dif come from the imperfect nature of floating point comparisons in clipWindingToPlaneFront() and PlaneEQ::whichSide() (same thing essentially), the colinearity and convexity checks in collapseWindings(), or from the failure to create the correct initial geometry in CSGBrush::selfClip() and createBaseWinding().
If you are looking to remove all intersection tests/surface splitting/hidden surface removal then I *believe* (I haven't tested this) all you have to do is go into EditGeometry::createBrushSurfaces() and replace:
mBSPRoot->breakWinding(tempWindings, rPlane.planeEQIndex, &brush, planeFinalWindings);with
If you wish to preserve the intersections/splits but don't want it to actually remove the hidden surfaces (leads to a lot of z-fighting) then you should just comment out the codeblock from EditBSPNode::breakWindingS() at the top of this post.
Beyond that....good luck! =P