/** * 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); }
/** * FindNearestIsect * * @param octree * @param ray * @param originID * @param level * @param isectnode * @return boolean */ public bool FindNearestIsect(OctNode octree, Ray ray, int originID, int level, OctNode isectnode) { Point testpt = new Point(ray.GetOrigin()); OctNode current; ObjNode currentnode; CacheIntersectPt isectptr; IntersectPt test = new IntersectPt(); if(level == 0) { testpt.Combine(ray.GetOrigin(), ray.GetDirection(), 1.0f, Threshold); } current = octree.FindTreeNode(testpt); IntersectObj = null; while(current != null) { currentnode = current.GetList(); while(currentnode != null) { bool found = false; if(currentnode.GetObj().GetCachePt().GetID() == ray.GetID()) { isectptr = currentnode.GetObj().GetCachePt(); if(current == current.FindTreeNode(isectptr.GetIntersection())) { if(IntersectObj == null) { SetIsectPt(isectptr); isectnode.Copy(current); } else { if(isectptr.GetT() < t) { SetIsectPt(isectptr); isectnode.Copy(current); } } found = true; } } if(!found) { test.SetOrigID(originID); if(currentnode.GetObj().Intersect(ray, test)) { if(current == current.FindTreeNode(test.GetIntersection())) { if(IntersectObj == null) { SetIsectPt(test); isectnode.Copy(current); } else { if(test.GetT() < t) { SetIsectPt(test); isectnode.Copy(current); } } } } } currentnode = currentnode.Next(); } if(IntersectObj == null) { OctNode adjacent = current.Intersect(ray, testpt, Threshold); if(adjacent == null) { current = null; } else { current = adjacent.FindTreeNode(testpt); } } else { current = null; } } if(IntersectObj == null) { return (false); } else { return (true); } }
/** * FindNearestIsect * * @param octree * @param ray * @param originID * @param level * @param isectnode * @return boolean */ public bool FindNearestIsect(OctNode octree, Ray ray, int originID, int level, OctNode isectnode) { Point testpt = new Point(ray.GetOrigin()); OctNode current; ObjNode currentnode; CacheIntersectPt isectptr; IntersectPt test = new IntersectPt(); if (level == 0) { testpt.Combine(ray.GetOrigin(), ray.GetDirection(), 1.0f, Threshold); } current = octree.FindTreeNode(testpt); IntersectObj = null; while (current != null) { currentnode = current.GetList(); while (currentnode != null) { bool found = false; if (currentnode.GetObj().GetCachePt().GetID() == ray.GetID()) { isectptr = currentnode.GetObj().GetCachePt(); if (current == current.FindTreeNode(isectptr.GetIntersection())) { if (IntersectObj == null) { SetIsectPt(isectptr); isectnode.Copy(current); } else { if (isectptr.GetT() < t) { SetIsectPt(isectptr); isectnode.Copy(current); } } found = true; } } if (!found) { test.SetOrigID(originID); if (currentnode.GetObj().Intersect(ray, test)) { if (current == current.FindTreeNode(test.GetIntersection())) { if (IntersectObj == null) { SetIsectPt(test); isectnode.Copy(current); } else { if (test.GetT() < t) { SetIsectPt(test); isectnode.Copy(current); } } } } } currentnode = currentnode.Next(); } if (IntersectObj == null) { OctNode adjacent = current.Intersect(ray, testpt, Threshold); if (adjacent == null) { current = null; } else { current = adjacent.FindTreeNode(testpt); } } else { current = null; } } if (IntersectObj == null) { return(false); } else { return(true); } }
/** * 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); }