Esempio n. 1
0
            void TraceTrmThroughNode(TraceWork tw, Node node)
            {
                PolygonRef pref;
                BrushRef   bref;

                // position test
                if (tw.positionTest)
                {
                    // if already stuck in solid
                    if (tw.trace.fraction == 0f)
                    {
                        return;
                    }
                    // test if any of the trm vertices is inside a brush
                    for (bref = node.brushes; bref != null; bref = bref.next)
                    {
                        if (TestTrmVertsInBrush(tw, bref.b))
                        {
                            return;
                        }
                    }
                    // if just testing a point we're done
                    if (tw.pointTrace)
                    {
                        return;
                    }
                    // test if the trm is stuck in any polygons
                    for (pref = node.polygons; pref != null; pref = pref.next)
                    {
                        if (TestTrmInPolygon(tw, pref.p))
                        {
                            return;
                        }
                    }
                }
                // rotate through all polygons in this leaf
                else if (tw.rotation)
                {
                    for (pref = node.polygons; pref != null; pref = pref.next)
                    {
                        if (RotateTrmThroughPolygon(tw, pref.p))
                        {
                            return;
                        }
                    }
                }
                // trace through all polygons in this leaf
                else
                {
                    for (pref = node.polygons; pref != null; pref = pref.next)
                    {
                        if (TranslateTrmThroughPolygon(tw, pref.p))
                        {
                            return;
                        }
                    }
                }
            }
Esempio n. 2
0
            // returns true if any of the trm vertices is inside the brush
            bool TestTrmVertsInBrush(TraceWork tw, Brush b)
            {
                int i, j, numVerts, bestPlane; float d, bestd;

                if (b.checkcount == this.checkCount)
                {
                    return(false);
                }
                b.checkcount = this.checkCount;

                if ((b.contents & tw.contents) == 0)
                {
                    return(false);
                }

                // if the brush bounds don't intersect the trace bounds
                if (!b.bounds.IntersectsBounds(tw.bounds))
                {
                    return(false);
                }

                numVerts = tw.pointTrace ? 1 : tw.numVerts;

                for (j = 0; j < numVerts; j++)
                {
                    ref Vector3 p = ref tw.vertices[j].p;

                    // see if the point is inside the brush
                    bestPlane = 0;
                    bestd     = -MathX.INFINITY;
                    for (i = 0; i < b.numPlanes; i++)
                    {
                        d = b.planes[i].Distance(p);
                        if (d >= 0f)
                        {
                            break;
                        }
                        if (d > bestd)
                        {
                            bestd = d; bestPlane = i;
                        }
                    }
                    if (i >= b.numPlanes)
                    {
                        tw.trace.fraction       = 0f;
                        tw.trace.c.type         = CONTACT.TRMVERTEX;
                        tw.trace.c.normal       = b.planes[bestPlane].Normal;
                        tw.trace.c.dist         = b.planes[bestPlane].Dist;
                        tw.trace.c.contents     = b.contents;
                        tw.trace.c.material     = b.material;
                        tw.trace.c.point        = p;
                        tw.trace.c.modelFeature = 0;
                        tw.trace.c.trmFeature   = j;
                        return(true);
                    }
                }
Esempio n. 3
0
 //#define NO_SPATIAL_SUBDIVISION
 void TraceThroughAxialBSPTree_r(TraceWork tw, Node node, float p1f, float p2f, in Vector3 p1, in Vector3 p2)