public void absorbPhoton(Photon p) { if (p.affectsLightMap) { inLightMap = true; incidentLight += p.colour; // (p.position - position).LengthSquared; } if (p.affectsShadowMap) { inShadowMap = true; incidentShadow += p.shadowColour; // (p.position - position).LengthSquared; } }
private void build(List <Photon> points, int depth) { if (points.Count == 1) { p = points[0]; left = null; right = null; } else { points.OrderBy(x => KDTree.getComponentFromDepth(x.position, depth)); int medianIndex = points.Count / 2; p = points[medianIndex]; List <Photon> leftList = points.GetRange(0, medianIndex); List <Photon> rightList = points.GetRange(medianIndex + 1, points.Count - medianIndex - 1); left = new KDTree(leftList, depth + 1); //This should never be null as the case with 1 point is // taken care of above right = rightList.Count > 0 ? new KDTree(rightList, depth + 1) : null; //This will be null if only 2 points } }
private void build(List<Photon> points, int depth) { if (points.Count == 1) { p = points[0]; left = null; right = null; } else { points.OrderBy(x => KDTree.getComponentFromDepth(x.position, depth)); int medianIndex = points.Count / 2; p = points[medianIndex]; List<Photon> leftList = points.GetRange(0, medianIndex); List<Photon> rightList = points.GetRange(medianIndex + 1, points.Count - medianIndex - 1); left = new KDTree(leftList, depth + 1); //This should never be null as the case with 1 point is // taken care of above right = rightList.Count > 0 ? new KDTree(rightList, depth + 1) : null; //This will be null if only 2 points } }