#include "vector.h"#include "vertex.h"#include "polygon.h"#include "plane.h"Go to the source code of this file.
Compounds | |
| class | PORTAL |
Functions | |
| PORTAL * | CopyPortal (PORTAL *portal) |
| void | CreateLargePortal (POLYGON splittingPolygon, PORTAL *largePortal) |
| int | SplitPortal (PORTAL *portalToSplit, PLANE plane, VECTOR pointOnPlane, PORTAL *front, PORTAL *back) |
| int | SplitPortal (PORTAL *portalToSplit, POLYGON planePolygon, PORTAL *front, PORTAL *back) |
| void | MakePortalList () |
| int | ClassifyPortal (PORTAL *portal, POLYGON planePolygon) |
| int | ClassifyInvertedPortal (PORTAL *portal, POLYGON planePolygon) |
| void | InvertPortal (PORTAL *portal) |
| void | InvertPortals (BSP_node *node) |
| void | AddPortal (PORTAL *thisportal, BSP_node *node) |
| void | AddPortalsToLeaves (BSP_node *root) |
| int | ClipPortalToFrontLeaf (PORTAL *portal) |
| int | ClipPortalToBackLeaf (PORTAL *portal) |
| void | CheckForSinglePortals (BSP_node *node, BSP_node *originalnode, PORTAL *portal, int *flag) |
| int | RemoveExtraPortals (PORTAL *portal) |
| void | FindTruePortals (BSP_node *node) |
|
||||||||||||
|
Definition at line 811 of file portal.cpp. References Back, BSP_node::backnode, ClassifyPortal(), CopyPortal(), Front, BSP_node::frontnode, LinkedList< PORTAL >::Insert(), BSP_node::leaf, PORTAL::linkPosition, BSP_node::numportals, OnPartition, BSP_node::partition, and BSP_node::portallist. Referenced by AddPortalsToLeaves().
00812 {
00813 if (node->leaf == true)
00814 {
00815 node->numportals++;
00816 thisportal->linkPosition = node->numportals;
00817 node->portallist.Insert(thisportal);
00818 return;
00819 }
00820
00821 int side = ClassifyPortal(thisportal, node->partition);
00822 if (side == Front)
00823 {
00824 AddPortal(thisportal, node->frontnode);
00825 }
00826 if (side == Back)
00827 {
00828 AddPortal(thisportal, node->backnode);
00829 }
00830 if (side == OnPartition)
00831 {
00832 AddPortal(thisportal, node->frontnode);
00833 PORTAL* tempportal = CopyPortal(thisportal);
00834 AddPortal(tempportal, node->backnode);
00835 }
00836 return;
00837 }
|
|
|
Definition at line 839 of file portal.cpp. References AddPortal(), CopyPortal(), LinkedList< T >::Get(), and numportals. Referenced by InitGL().
00840 {
00841 for (int loop = 1; loop <= numportals; loop++)
00842 {
00843 PORTAL* tempportal = CopyPortal(PortalList.Get(loop));
00844 AddPortal(tempportal, root);
00845 }
00846 }
|
|
||||||||||||||||||||
|
Definition at line 909 of file portal.cpp. References PORTAL::backleaf, BSP_node::backnode, PORTAL::frontleaf, BSP_node::frontnode, LinkedList< PORTAL >::Get(), BSP_node::leaf, BSP_node::nodeid, BSP_node::numportals, PORTAL::PortalId, and BSP_node::portallist. Referenced by FindTruePortals().
00910 {
00911 PORTAL* tempportal;
00912 if (node->leaf == true)
00913 {
00914 if (node->nodeid != originalnode->nodeid)
00915 {
00916 for (int portalnum = node->numportals; portalnum > 0; portalnum--)
00917 {
00918 tempportal = node->portallist.Get(portalnum);
00919 if (tempportal->PortalId == portal->PortalId)
00920 {
00921 portal->frontleaf = originalnode;
00922 portal->backleaf = node;
00923 *flag += 1;
00924 }
00925 }
00926 }
00927 return;
00928 }
00929 else
00930 {
00931 CheckForSinglePortals(node->frontnode, originalnode, portal, flag);
00932 CheckForSinglePortals(node->backnode, originalnode, portal, flag);
00933 return;
00934 }
00935 }
|
|
||||||||||||
|
Definition at line 668 of file portal.cpp. References Back, ClassifyPoint(), CrossVector(), Front, PORTAL::numVertices, PORTAL::Vertex, POLYGON::Vertex, VERTEX::x, VECTOR::x, VERTEX::y, VECTOR::y, VERTEX::z, and VECTOR::z. Referenced by RemoveExtraPortals().
00669 {
00670 int numVerts = portal->numVertices;
00671 int count = 0;
00672 VECTOR planeNormal, polysNormal, pointOnPlane, edge1, edge2, temp;
00673
00674 // get a point on the plane
00675 pointOnPlane.x = planePolygon.Vertex[0].x;
00676 pointOnPlane.y = planePolygon.Vertex[0].y;
00677 pointOnPlane.z = planePolygon.Vertex[0].z;
00678
00679 // get the planes normal
00680 edge1.x = planePolygon.Vertex[1].x - planePolygon.Vertex[0].x;
00681 edge1.y = planePolygon.Vertex[1].y - planePolygon.Vertex[0].y;
00682 edge1.z = planePolygon.Vertex[1].z - planePolygon.Vertex[0].z;
00683 edge2.x = planePolygon.Vertex[2].x - planePolygon.Vertex[0].x;
00684 edge2.y = planePolygon.Vertex[2].y - planePolygon.Vertex[0].y;
00685 edge2.z = planePolygon.Vertex[2].z - planePolygon.Vertex[0].z;
00686 planeNormal = CrossVector(edge1, edge2);
00687
00688 // get the normal of the portal
00689 edge1.x = portal->Vertex[1].x - portal->Vertex[0].x;
00690 edge1.y = portal->Vertex[1].y - portal->Vertex[0].y;
00691 edge1.z = portal->Vertex[1].z - portal->Vertex[0].z;
00692 edge2.x = portal->Vertex[2].x - portal->Vertex[0].x;
00693 edge2.y = portal->Vertex[2].y - portal->Vertex[0].y;
00694 edge2.z = portal->Vertex[2].z - portal->Vertex[0].z;
00695 polysNormal = CrossVector(edge1, edge2);
00696 polysNormal.x *= -1;
00697 polysNormal.y *= -1;
00698 polysNormal.z *= -1;
00699
00700 // check if the portal lies on the plane
00701 for (int loop = 0; loop < numVerts; loop++)
00702 {
00703 temp.x = portal->Vertex[loop].x;
00704 temp.y = portal->Vertex[loop].y;
00705 temp.z = portal->Vertex[loop].z;
00706 if (ClassifyPoint(temp, pointOnPlane, planeNormal) == 0)
00707 count++;
00708 else
00709 break;
00710 }
00711 if (count == numVerts)
00712 {
00713 if (ClassifyPoint(polysNormal, pointOnPlane, planeNormal) == 1)
00714 return Front;
00715 if (ClassifyPoint(polysNormal, pointOnPlane, planeNormal) == -1)
00716 return Back;
00717 }
00718
00719 // find if all of the points are infront of or behind the plane
00720 int result, frontcount = 0, backcount = 0;
00721 for (int loop = 0; loop < numVerts; loop++)
00722 {
00723 temp.x = portal->Vertex[loop].x;
00724 temp.y = portal->Vertex[loop].y;
00725 temp.z = portal->Vertex[loop].z;
00726 result = ClassifyPoint(temp, pointOnPlane, planeNormal);
00727 if (result == 0)
00728 {
00729 frontcount++;
00730 backcount++;
00731 }
00732 else
00733 if (result == 1)
00734 frontcount++;
00735 else
00736 if (result == -1)
00737 backcount++;
00738 }
00739 if (frontcount == numVerts)
00740 return Front;
00741 if (backcount == numVerts)
00742 return Back;
00743
00744 return 0;
00745 }
|
|
||||||||||||
|
Definition at line 597 of file portal.cpp. References Back, ClassifyPoint(), CrossVector(), Front, PORTAL::numVertices, OnPartition, PORTAL::Vertex, POLYGON::Vertex, VERTEX::x, VECTOR::x, VERTEX::y, VECTOR::y, VERTEX::z, and VECTOR::z. Referenced by AddPortal().
00598 {
00599 int numVerts = portal->numVertices;
00600 int count = 0;
00601 VECTOR planeNormal, polysNormal, pointOnPlane, edge1, edge2, temp;
00602
00603 // get a point on the plane
00604 pointOnPlane.x = planePolygon.Vertex[0].x;
00605 pointOnPlane.y = planePolygon.Vertex[0].y;
00606 pointOnPlane.z = planePolygon.Vertex[0].z;
00607
00608 // get the planes normal
00609 edge1.x = planePolygon.Vertex[1].x - planePolygon.Vertex[0].x;
00610 edge1.y = planePolygon.Vertex[1].y - planePolygon.Vertex[0].y;
00611 edge1.z = planePolygon.Vertex[1].z - planePolygon.Vertex[0].z;
00612 edge2.x = planePolygon.Vertex[2].x - planePolygon.Vertex[0].x;
00613 edge2.y = planePolygon.Vertex[2].y - planePolygon.Vertex[0].y;
00614 edge2.z = planePolygon.Vertex[2].z - planePolygon.Vertex[0].z;
00615 planeNormal = CrossVector(edge1, edge2);
00616
00617 // get the normal of the portal
00618 edge1.x = portal->Vertex[1].x - portal->Vertex[0].x;
00619 edge1.y = portal->Vertex[1].y - portal->Vertex[0].y;
00620 edge1.z = portal->Vertex[1].z - portal->Vertex[0].z;
00621 edge2.x = portal->Vertex[2].x - portal->Vertex[0].x;
00622 edge2.y = portal->Vertex[2].y - portal->Vertex[0].y;
00623 edge2.z = portal->Vertex[2].z - portal->Vertex[0].z;
00624 polysNormal = CrossVector(edge1, edge2);
00625
00626 // check if the portal lies on the plane
00627 for (int loop = 0; loop < numVerts; loop++)
00628 {
00629 temp.x = portal->Vertex[loop].x;
00630 temp.y = portal->Vertex[loop].y;
00631 temp.z = portal->Vertex[loop].z;
00632 if (ClassifyPoint(temp, pointOnPlane, planeNormal) == 0)
00633 count++;
00634 else
00635 break;
00636 }
00637 if (count == numVerts)
00638 return OnPartition;
00639
00640 // find if all of the points are infront of or behind the plane
00641 int result, frontcount = 0, backcount = 0;
00642 for (int loop = 0; loop < numVerts; loop++)
00643 {
00644 temp.x = portal->Vertex[loop].x;
00645 temp.y = portal->Vertex[loop].y;
00646 temp.z = portal->Vertex[loop].z;
00647 result = ClassifyPoint(temp, pointOnPlane, planeNormal);
00648 if (result == 0)
00649 {
00650 frontcount++;
00651 backcount++;
00652 }
00653 else
00654 if (result == 1)
00655 frontcount++;
00656 else
00657 if (result == -1)
00658 backcount++;
00659 }
00660 if (frontcount == numVerts)
00661 return Front;
00662 if (backcount == numVerts)
00663 return Back;
00664
00665 return 0;
00666 }
|
|
|
Definition at line 879 of file portal.cpp. References PORTAL::backleaf, BSP_node::nodepolylist, BSP_node::numpolys, PORTAL::numVertices, polygon, PortalWasSplit, SplitPortal(), and PORTAL::Vertex. Referenced by FindTruePortals().
00880 {
00881 int result, returnvalue = 0;
00882 for (int polygon = 0; polygon < portal->backleaf->numpolys; polygon++)
00883 {
00884 PORTAL* front = new PORTAL;
00885 PORTAL* back = new PORTAL;
00886 result = SplitPortal(portal, portal->backleaf->nodepolylist[polygon], front, back);
00887
00888 if (result == PortalWasSplit)
00889 {
00890 returnvalue = PortalWasSplit;
00891 delete[] back->Vertex;
00892 back->Vertex = 0;
00893 delete back;
00894 delete[] portal->Vertex;
00895 portal->Vertex = 0;
00896 portal->numVertices = front->numVertices;
00897 portal->Vertex = front->Vertex;
00898 delete front;
00899 }
00900 else
00901 {
00902 delete back;
00903 delete front;
00904 }
00905 }
00906 return returnvalue;
00907 }
|
|
|
Definition at line 848 of file portal.cpp. References PORTAL::frontleaf, BSP_node::nodepolylist, BSP_node::numpolys, PORTAL::numVertices, polygon, PortalWasSplit, SplitPortal(), and PORTAL::Vertex. Referenced by FindTruePortals().
00849 {
00850 int result, returnvalue = 0;
00851 for (int polygon = 0; polygon < portal->frontleaf->numpolys; polygon++)
00852 {
00853 PORTAL* front = new PORTAL;
00854 PORTAL* back = new PORTAL;
00855 result = SplitPortal(portal, portal->frontleaf->nodepolylist[polygon], front, back);
00856
00857 if (result == PortalWasSplit)
00858 {
00859 returnvalue = PortalWasSplit;
00860 delete[] back->Vertex;
00861 back->Vertex = 0;
00862 delete back;
00863 delete[] portal->Vertex;
00864 portal->Vertex = 0;
00865 portal->numVertices = front->numVertices;
00866 portal->Vertex = front->Vertex;
00867 delete front;
00868 }
00869
00870 else
00871 {
00872 delete back;
00873 delete front;
00874 }
00875 }
00876 return returnvalue;
00877 }
|
|
|
Definition at line 86 of file portal.cpp. References PORTAL::numVertices, and PORTAL::Vertex. Referenced by AddPortal(), AddPortalsToLeaves(), and InvertPortal().
00087 {
00088 PORTAL* tempportal = new PORTAL;
00089 *tempportal = *portal;
00090 tempportal->Vertex = new VERTEX[portal->numVertices];
00091 for (int loop = 0; loop < portal->numVertices; loop++)
00092 tempportal->Vertex[loop] = portal->Vertex[loop];
00093 return tempportal;
00094 }
|
|
||||||||||||
|
Definition at line 96 of file portal.cpp. References POLYGON::GetNormal(), Max_X, Max_Y, Max_Z, Min_X, Min_Y, Min_Z, VECTOR::Normalize(), PORTAL::numVertices, PORTAL::SetNormal(), POLYGON::Vertex, PORTAL::Vertex, VERTEX::x, VECTOR::x, VERTEX::y, VECTOR::y, VERTEX::z, and VECTOR::z. Referenced by MakePortalList().
00097 {
00098 // Make large portal using planar mapping
00099 largePortal->numVertices = 4;
00100 largePortal->Vertex = new VERTEX[4];
00101 // find the primary axis plane
00102 int flag = 0;
00103 VECTOR poly_normal = splittingPolygon.GetNormal();
00104 poly_normal.Normalize();
00105
00106 if (fabs(poly_normal.x) > fabs(poly_normal.y) && fabs(poly_normal.x) > fabs(poly_normal.z))
00107 {
00108 flag = 1;
00109 largePortal->Vertex[0].y = Min_Y;
00110 largePortal->Vertex[0].z = Max_Z;
00111 largePortal->Vertex[1].y = Min_Y;
00112 largePortal->Vertex[1].z = Min_Z;
00113 largePortal->Vertex[2].y = Max_Y;
00114 largePortal->Vertex[2].z = Min_Z;
00115 largePortal->Vertex[3].y = Max_Y;
00116 largePortal->Vertex[3].z = Max_Z;
00117 }
00118 else if (fabs(poly_normal.y) > fabs(poly_normal.x) && fabs(poly_normal.y) > fabs(poly_normal.z))
00119 {
00120 flag = 2;
00121 largePortal->Vertex[0].x = Min_X;
00122 largePortal->Vertex[0].z = Max_Z;
00123 largePortal->Vertex[1].x = Max_X;
00124 largePortal->Vertex[1].z = Max_Z;
00125 largePortal->Vertex[2].x = Max_X;
00126 largePortal->Vertex[2].z = Min_Z;
00127 largePortal->Vertex[3].x = Min_X;
00128 largePortal->Vertex[3].z = Min_Z;
00129 }
00130 else
00131 {
00132 flag = 3;
00133 largePortal->Vertex[0].x = Min_X;
00134 largePortal->Vertex[0].y = Min_Y;
00135 largePortal->Vertex[1].x = Max_X;
00136 largePortal->Vertex[1].y = Min_Y;
00137 largePortal->Vertex[2].x = Max_X;
00138 largePortal->Vertex[2].y = Max_Y;
00139 largePortal->Vertex[3].x = Min_X;
00140 largePortal->Vertex[3].y = Max_Y;
00141 }
00142
00143 float X, Y, Z;
00144 float Distance = - (poly_normal.x * splittingPolygon.Vertex[0].x + poly_normal.y * splittingPolygon.Vertex[0].y + poly_normal.z * splittingPolygon.Vertex[0].z);
00145 switch (flag)
00146 {
00147 case 1: //YZ Plane
00148 X = - ( poly_normal.y * Min_Y + poly_normal.z * Max_Z + Distance ) / poly_normal.x;
00149 largePortal->Vertex[0].x = X;
00150 X = - ( poly_normal.y * Min_Y + poly_normal.z * Min_Z + Distance ) / poly_normal.x;
00151 largePortal->Vertex[1].x = X;
00152 X = - ( poly_normal.y * Max_Y + poly_normal.z * Min_Z + Distance ) / poly_normal.x;
00153 largePortal->Vertex[2].x = X;
00154 X = - ( poly_normal.y * Max_Y + poly_normal.z * Max_Z + Distance ) / poly_normal.x;
00155 largePortal->Vertex[3].x = X;
00156 break;
00157 case 2: //XZ Plane
00158 Y = - ( poly_normal.x * Min_X + poly_normal.z * Max_Z + Distance ) / poly_normal.y;
00159 largePortal->Vertex[0].y = Y;
00160 Y = - ( poly_normal.x * Max_X + poly_normal.z * Max_Z + Distance ) / poly_normal.y;
00161 largePortal->Vertex[1].y = Y;
00162 Y = - ( poly_normal.x * Max_X + poly_normal.z * Min_Z + Distance ) / poly_normal.y;
00163 largePortal->Vertex[2].y = Y;
00164 Y = - ( poly_normal.x * Min_X + poly_normal.z * Min_Z + Distance ) / poly_normal.y;
00165 largePortal->Vertex[3].y = Y;
00166 break;
00167 case 3: //XY Plane
00168 Z = - ( poly_normal.x * Min_X + poly_normal.y * Min_Y + Distance ) / poly_normal.z;
00169 largePortal->Vertex[0].z = Z;
00170 Z = - ( poly_normal.x * Max_X + poly_normal.y * Min_Y + Distance ) / poly_normal.z;
00171 largePortal->Vertex[1].z = Z;
00172 Z = - ( poly_normal.x * Max_X + poly_normal.y * Max_Y + Distance ) / poly_normal.z;
00173 largePortal->Vertex[2].z = Z;
00174 Z = - ( poly_normal.x * Min_X + poly_normal.y * Max_Y + Distance ) / poly_normal.z;
00175 largePortal->Vertex[3].z = Z;
00176 break;
00177 }
00178 largePortal->SetNormal();
00179 }
|
|
|
Definition at line 955 of file portal.cpp. References BSP_node::backnode, CheckForSinglePortals(), ClipPortalToBackLeaf(), ClipPortalToFrontLeaf(), LinkedList< PORTAL >::Delete(), BSP_node::frontnode, LinkedList< PORTAL >::Get(), InvertPortals(), BSP_node::leaf, BSP_node::numportals, BSP_node::portallist, RemoveExtraPortals(), and PORTAL::Vertex. Referenced by InitGL().
00956 {
00957 int flag;
00958 if (node->leaf == true)
00959 {
00960 for (int portalnumber = node->numportals; portalnumber > 0; portalnumber--)
00961 {
00962 flag = 0;
00963 PORTAL* tempportal = node->portallist.Get(portalnumber);
00964 CheckForSinglePortals(root, node, tempportal, &flag);
00965 if (flag == 0)
00966 {
00967 delete[] tempportal->Vertex;
00968 tempportal->Vertex = 0;
00969 node->portallist.Delete(portalnumber);
00970 delete tempportal;
00971 node->numportals--;
00972 }
00973 else
00974 {
00975 ClipPortalToFrontLeaf(tempportal);
00976 ClipPortalToBackLeaf(tempportal);
00977 }
00978 }
00979
00980 InvertPortals(node); // also inverts the front and back leaf pointers if necessary
00981
00982 for (int portalnumber = node->numportals; portalnumber > 0; portalnumber--)
00983 {
00984 PORTAL* tempportal = node->portallist.Get(portalnumber);
00985 flag = RemoveExtraPortals(tempportal);
00986 if (flag == true)
00987 {
00988 delete[] tempportal->Vertex;
00989 tempportal->Vertex = 0;
00990 node->portallist.Delete(portalnumber);
00991 delete tempportal;
00992 node->numportals--;
00993 }
00994 }
00995 return;
00996 }
00997 else
00998 {
00999 FindTruePortals(node->frontnode);
01000 FindTruePortals(node->backnode);
01001 return;
01002 }
01003 }
|
|
|
Definition at line 747 of file portal.cpp. References CopyPortal(), PORTAL::numVertices, and PORTAL::Vertex. Referenced by InvertPortals().
00748 {
00749 PORTAL* tempportal = CopyPortal(portal);
00750 int numverts = portal->numVertices;
00751 for (int loop = 0; loop < numverts; loop++)
00752 portal->Vertex[loop] = tempportal->Vertex[(numverts - 1) - loop];
00753 delete[] tempportal->Vertex;
00754 tempportal->Vertex = 0;
00755 delete tempportal;
00756 return;
00757 }
|
|
|
Definition at line 759 of file portal.cpp. References PORTAL::backleaf, ClassifyPoint(), CrossVector(), PORTAL::frontleaf, LinkedList< PORTAL >::Get(), InvertPortal(), BSP_node::nodeid, BSP_node::nodepolylist, BSP_node::numpolys, BSP_node::numportals, polygon, BSP_node::portallist, POLYGON::Vertex, PORTAL::Vertex, VERTEX::x, VECTOR::x, VERTEX::y, VECTOR::y, VERTEX::z, and VECTOR::z. Referenced by FindTruePortals().
00760 {
00761 VECTOR planeNormal, polysNormal, pointOnPlane, edge1, edge2, temp;
00762 int flag;
00763 for (int loop = 1; loop <= node->numportals; loop++)
00764 {
00765 PORTAL* tempportal = node->portallist.Get(loop);
00766 // get a point on the plane
00767 pointOnPlane.x = tempportal->Vertex[0].x;
00768 pointOnPlane.y = tempportal->Vertex[0].y;
00769 pointOnPlane.z = tempportal->Vertex[0].z;
00770
00771 // get the normal of the portals plane
00772 edge1.x = tempportal->Vertex[1].x - tempportal->Vertex[0].x;
00773 edge1.y = tempportal->Vertex[1].y - tempportal->Vertex[0].y;
00774 edge1.z = tempportal->Vertex[1].z - tempportal->Vertex[0].z;
00775 edge2.x = tempportal->Vertex[2].x - tempportal->Vertex[0].x;
00776 edge2.y = tempportal->Vertex[2].y - tempportal->Vertex[0].y;
00777 edge2.z = tempportal->Vertex[2].z - tempportal->Vertex[0].z;
00778 planeNormal = CrossVector(edge1, edge2);
00779
00780 flag = 0;
00781 for (int polygon = 0; polygon < node->numpolys; polygon++)
00782 {
00783 for (int vert = 0; vert < 3; vert++)
00784 {
00785 temp.x = node->nodepolylist[polygon].Vertex[vert].x;
00786 temp.y = node->nodepolylist[polygon].Vertex[vert].y;
00787 temp.z = node->nodepolylist[polygon].Vertex[vert].z;
00788
00789 flag = ClassifyPoint(temp, pointOnPlane, planeNormal);
00790 if (flag == -1)
00791 {
00792 InvertPortal(tempportal);
00793 }
00794 if (flag == 1 || flag == -1)
00795 {
00796 if (tempportal->frontleaf->nodeid != node->nodeid)
00797 {
00798 BSP_node* tempnode = tempportal->backleaf;
00799 tempportal->backleaf = tempportal->frontleaf;
00800 tempportal->frontleaf = tempnode;
00801 }
00802 break;
00803 }
00804 }
00805 if (flag == 1 || flag == -1)
00806 break;
00807 }
00808 }
00809 }
|
|
|
Definition at line 533 of file portal.cpp. References CreateLargePortal(), LinkedList< T >::Delete(), LinkedList< T >::Get(), LinkedList< T >::Insert(), PORTAL::linkPosition, ListNode::node, numpartitions, numportals, BSP_node::partition, PORTAL::PartitionNodeId, PORTAL::PortalId, PortalWasSplit, SplitPortal(), and PORTAL::Vertex. Referenced by InitGL().
00534 {
00535 // Create the large portals
00536 for (int loop = 1; loop <= numpartitions; loop++)
00537 {
00538 listnode = PartitionList.Get(loop);
00539 portal = new PORTAL;
00540 portal->Vertex = 0;
00541 portal->linkPosition = loop;
00542 portal->PartitionNodeId = loop;
00543 CreateLargePortal(listnode->node->partition, portal);
00544 PortalList.Insert(portal);
00545 }
00546
00547 // Split the large portals into potential portals
00548 numportals = numpartitions;
00549 int result, portalToSplit;
00550 PORTAL* frontportal;
00551 PORTAL* backportal;
00552 for (int partition = 1; partition <= numpartitions; partition++)
00553 {
00554 listnode = PartitionList.Get(partition);
00555 portalToSplit = numportals;
00556 while (portalToSplit > 0)
00557 {
00558 frontportal = new PORTAL;
00559 backportal = new PORTAL;
00560
00561 portal = PortalList.Get(portalToSplit);
00562 result = SplitPortal(portal, listnode->node->partition, frontportal, backportal);
00563
00564 if (result == PortalWasSplit)
00565 {
00566 frontportal->PartitionNodeId = portal->PartitionNodeId;
00567 backportal->PartitionNodeId = portal->PartitionNodeId;
00568
00569 delete[] portal->Vertex;
00570 portal->Vertex = 0;
00571 PortalList.Delete(portalToSplit);
00572 delete portal;
00573 numportals--;
00574
00575 frontportal->linkPosition = ++numportals;
00576 PortalList.Insert(frontportal);
00577 backportal->linkPosition = ++numportals;
00578 PortalList.Insert(backportal);
00579 }
00580 else
00581 {
00582 delete frontportal;
00583 delete backportal;
00584 }
00585 portalToSplit--;
00586 }
00587 }
00588
00589 // Loop through the portals and assign a unique id
00590 for (int loop = 1; loop <= numportals; loop++)
00591 {
00592 portal = PortalList.Get(loop);
00593 portal->PortalId = loop;
00594 }
00595 }
|
|
|
Definition at line 937 of file portal.cpp. References PORTAL::backleaf, ClassifyInvertedPortal(), Front, BSP_node::nodepolylist, and BSP_node::numpolys. Referenced by FindTruePortals().
00938 {
00939 int result, count = 0;
00940 POLYGON temppoly;
00941 BSP_node* tempnode = portal->backleaf;
00942 for (int loop = 0; loop < tempnode->numpolys; loop++)
00943 {
00944 temppoly = tempnode->nodepolylist[loop];
00945 result = ClassifyInvertedPortal(portal, temppoly);
00946 if (result == Front)
00947 count++;
00948 }
00949 if (count != portal->backleaf->numpolys)
00950 return true;
00951 else
00952 return false;
00953 }
|
|
||||||||||||||||||||
|
Referenced by CalculatePVS(), ClipPortalToBackLeaf(), ClipPortalToFrontLeaf(), FindVisibleLeaves(), and MakePortalList(). |
|
||||||||||||||||||||||||
|
|
1.2.15