private QTNode GetSameLevelBorder(int dir) { List <QTNode> nodeList = QTManager.Instance.activeTerrain.allNodeListArray[lodLevel]; Vector3 target = Vector3.zero; switch (dir) { case 0: target = center + new Vector3(0f, 0f, length); break; case 1: target = center + new Vector3(length, 0f, 0f); break; case 2: target = center + new Vector3(0f, 0f, -length); break; case 3: target = center + new Vector3(-length, 0f, 0f); break; } for (int i = 0; i < nodeList.Count; i++) { if (MathExtra.ApproEquals(nodeList [i].center.x, target.x) && MathExtra.ApproEquals(nodeList [i].center.z, target.z)) { return(nodeList [i]); } } return(null); }
public QTNode FindBorder(QTNode node, int dir) { nodeList = null; tNode = null; for (int i = node.lodLevel + 2; i < activeTerrain.maxLodLevel; i++) { nodeList = activeTerrain.activeNodeListArray [i]; for (int m = 0; m < nodeList.Count; m++) { tNode = nodeList[m]; switch (dir) { case 0: if (MathExtra.ApproEquals(node.center.z + node.length * 0.5f, tNode.center.z - tNode.length * 0.5f) && (node.center.x > tNode.center.x - tNode.length * 0.5f) && (node.center.x < tNode.center.x + tNode.length * 0.5f)) { return(tNode); } break; case 1: if (MathExtra.ApproEquals(node.center.x + node.length * 0.5f, tNode.center.x - tNode.length * 0.5f) && (node.center.z > tNode.center.z - tNode.length * 0.5f) && (node.center.z < tNode.center.z + tNode.length * 0.5f)) { return(tNode); } break; case 2: if (MathExtra.ApproEquals(node.center.z - node.length * 0.5f, tNode.center.z + tNode.length * 0.5f) && (node.center.x > tNode.center.x - tNode.length * 0.5f) && (node.center.x < tNode.center.x + tNode.length * 0.5f)) { return(tNode); } break; case 3: if (MathExtra.ApproEquals(node.center.x - node.length * 0.5f, tNode.center.x + tNode.length * 0.5f) && (node.center.z > tNode.center.z - tNode.length * 0.5f) && (node.center.z < tNode.center.z + tNode.length * 0.5f)) { return(tNode); } break; } } } return(null); }
private bool GetBorderStatus(int dir) { if (lodLevel == QTManager.Instance.activeTerrain.maxLodLevel) { return(false); } if (dir == 0 && ((borderStatus & BorderStatus.UpBorder) == BorderStatus.UpBorder)) { return(false); } if (dir == 1 && ((borderStatus & BorderStatus.RightBorder) == BorderStatus.RightBorder)) { return(false); } if (dir == 2 && ((borderStatus & BorderStatus.DownBorder) == BorderStatus.DownBorder)) { return(false); } if (dir == 3 && ((borderStatus & BorderStatus.LeftBorder) == BorderStatus.LeftBorder)) { return(false); } float halfLength = length * 0.5f; float targetA = (dir == 0 || dir == 2)?(center.x - halfLength):(center.z - halfLength); float targetB = (dir == 0 || dir == 2)?(center.x + halfLength):(center.z + halfLength); List <QTNode> checkList = QTManager.Instance.activeTerrain.activeNodeListArray [lodLevel + 1]; switch (dir) { case 0: for (int i = 0; i < checkList.Count; i++) { if (MathExtra.ApproEquals(checkList [i].center.x, targetA) || MathExtra.ApproEquals(checkList [i].center.x, targetB)) { if (MathExtra.ApproEquals(checkList [i].center.z - length, center.z + halfLength)) { return(true); } } } break; case 1: for (int i = 0; i < checkList.Count; i++) { if (MathExtra.ApproEquals(checkList [i].center.z, targetA) || MathExtra.ApproEquals(checkList [i].center.z, targetB)) { if (MathExtra.ApproEquals(checkList [i].center.x - length, center.x + halfLength)) { return(true); } } } break; case 2: for (int i = 0; i < checkList.Count; i++) { if (MathExtra.ApproEquals(checkList [i].center.x, targetA) || MathExtra.ApproEquals(checkList [i].center.x, targetB)) { if (MathExtra.ApproEquals(checkList [i].center.z + length, center.z - halfLength)) { return(true); } } } break; case 3: for (int i = 0; i < checkList.Count; i++) { if (MathExtra.ApproEquals(checkList [i].center.z, targetA) || MathExtra.ApproEquals(checkList [i].center.z, targetB)) { if (MathExtra.ApproEquals(checkList [i].center.x + length, center.x - halfLength)) { return(true); } } } break; } return(false); }