예제 #1
0
            public void ThreadProc()
            {
                Vector3D surfaceDirection = new Vector3D();

                for (int i = start; i <= stop; i++)
                {
                    Photon p = mainInstance.getPhoton(i);

                    p.accumPower = new RGBColor();
                    p.surfaceToCartesian(surfaceDirection);

                    mainInstance.radianceEstimate(p.accumPower, p.position, surfaceDirection, maxDist, noPhotons);

                    p.precomputedIrradiance = true;
                }

                // signal!
                lock (this)
                {
                    done = true;
                }
            }
예제 #2
0
        public virtual void  locatePhotonsPrecomputed(Vector3D normal, NearestPhotons np, int index)
        {
            double dist1, dist2;
            Photon p = getPhoton(index);

            if (index < halfStoredPhotons)
            {
                dist1 = np.position.get(p.plane) - p.position.get(p.plane);

                if (dist1 > 0.0)
                {
                    // if dist1 is positive search right plane
                    locatePhotonsPrecomputed(normal, np, (2 * index) + 1);

                    if (dist1 * dist1 < np.dist2[0])
                    {
                        locatePhotonsPrecomputed(normal, np, (2 * index));
                    }
                }
                else
                {
                    // dist1 is negative search left first
                    locatePhotonsPrecomputed(normal, np, (2 * index));

                    if (dist1 * dist1 < np.dist2[0])
                    {
                        locatePhotonsPrecomputed(normal, np, (2 * index) + 1);
                    }
                }
            }

            // compute squared distance between current photon and np.position
            dist2 = p.position.distanceSqr(np.position);

            //assert(p.precomputedIrradiance);
            //assert(np.max == 1);

            Vector3D surfaceDirection = new Vector3D();

            p.surfaceToCartesian(surfaceDirection);

            //System.out.println(normal.dot(surfaceDirection));

            if (dist2 < np.dist2[0] && normal.dot(surfaceDirection) > 0.0)
            {
                // we found a photon :) Insert it in the candidate list

                if (np.found < 1)
                {
                    // heap is not full; use array
                    np.found++;
                    np.dist2[np.found]   = dist2;
                    np.indices[np.found] = index;
                }
                else
                {
                    // exchange element if necessary

                    if (np.dist2[0] > dist2)
                    {
                        np.dist2[1]   = dist2;
                        np.indices[1] = index;

                        np.dist2[0] = dist2;
                    }
                }
            }
        }