Пример #1
0
 void Node_SetLeaf(Node_t node, bool leaf)
 {
     if (leaf)
         node.m_fFlags |= 0x1;
     else
         node.m_fFlags &= ~0x1;
 }
Пример #2
0
 bool Node_IsLeaf(Node_t node)
 {
     return (node.m_fFlags & 0x1) == 0x1;
 }
Пример #3
0
        void Node_Init(Node_t node)
        {
            node.m_BBox[0] = new Vector3(99999.0f, 99999.0f, 99999.0f);
            node.m_BBox[1] = new Vector3(-99999.0f, -99999.0f, -99999.0f);

            node.m_iTris[0] = -1;
            node.m_iTris[1] = -1;

            node.m_fFlags = 0;
        }
Пример #4
0
        void Nodes_CalcLeafBounds(Node_t pNode, int ndxNode)
        {
            // Find the minimum and maximum component values for all triangles in
            // the leaf node (including caps tris)
            for (int iTri = 0; iTri < 2; iTri++)
            {
                for (int iVert = 0; iVert < 3; iVert++)
                {
                    // Minimum checks
                    Tri_t pTri = m_pTris[pNode.m_iTris[iTri]];
                    Vector3 vecTemp = m_pVerts[pTri.m_uiVerts[iVert]];

                    pNode.m_BBox[0] = Vector3.Minimize(pNode.m_BBox[0], vecTemp);
                    pNode.m_BBox[1] = Vector3.Maximize(pNode.m_BBox[1], vecTemp);
                }
            }
        }
Пример #5
0
        void Nodes_CalcBounds(Node_t pNode, int ndxNode)
        {
            //
            // leaf nodes have special cases (caps, etc.)
            //
            if (Node_IsLeaf(pNode))
            {
                Nodes_CalcLeafBounds(pNode, ndxNode);
                return;
            }

            //
            // get the maximum and minimum bounds of all leaf nodes -- that is the
            // bounding box for this node
            //
            pNode.m_BBox[0] = new Vector3(99999.0f, 99999.0f, 99999.0f);
            pNode.m_BBox[1] = new Vector3(-99999.0f, -99999.0f, -99999.0f);

            for (int ndxChildren = 0; ndxChildren < 4; ndxChildren++)
            {
                //
                // get the current child node
                //
                int ndxChildNode = Nodes_GetChild(ndxNode, ndxChildren);
                Node_t childNode = m_pNodes[ndxChildNode];

                // update the bounds
                pNode.m_BBox[0] = Vector3.Minimize(pNode.m_BBox[0], childNode.m_BBox[0]);
                pNode.m_BBox[1] = Vector3.Maximize(pNode.m_BBox[1], childNode.m_BBox[1]);

            }
        }
Пример #6
0
        bool Nodes_Alloc()
        {
            m_NodeCount = (short)Nodes_CalcCount(Power);
            if (m_NodeCount == 0)
                return false;

            m_pNodes = new Node_t[m_NodeCount];
            if (m_pNodes.Length == 0)
            {
                m_NodeCount = 0;
                return false;
            }

            //
            // initialize the nodes
            //
            for (int i = 0; i < m_NodeCount; i++)
            {
                m_pNodes[i] = new Node_t();
                Node_Init(m_pNodes[i]);
            }

            // tree successfully allocated!
            return true;
        }