/** * FindLightBlock * * @param tree * @param ray * @param maxt * @return boolean */ private bool FindLightBlock(OctNode tree, Ray ray, double maxt) { OctNode current = tree.FindTreeNode(ray.GetOrigin()); IntersectPt test = new IntersectPt(); Point testpt = new Point(); while (current != null) { ObjNode currentnode = current.GetList(); while (currentnode != null) { bool found = false; if (currentnode.GetObj().GetCachePt().GetID() == ray.GetID()) { found = true; } if (!found) { test.SetOrigID(0); if (currentnode.GetObj().Intersect(ray, test)) { if (test.GetT() < maxt) { return(true); } } } currentnode = currentnode.Next(); } OctNode adjacent = current.Intersect(ray, testpt, test.GetThreshold()); if (adjacent == null) { current = null; } else { current = adjacent.FindTreeNode(testpt); } } return(false); }
/** * CreateTree * * @param objects * @param numObjects */ private void CreateTree(ObjNode objects, int numObjects) { if (objects != null) { if (numObjects > MaxObj) { CreateChildren(objects, 1); } else { ObjNode currentObj = objects; while (currentObj != null) { ObjNode newnode = new ObjNode(currentObj.GetObj(), ObjList); ObjList = newnode; currentObj = currentObj.Next(); } NumObj = numObjects; } } }