Esempio n. 1
0
 final void updateScene(Scene scene) {
   if (rebuildInstanceList) {
     UI.printInfo(Module.API, "Building scene instance list for rendering ...");
     int numInfinite = 0, numInstance = 0;
     for (Map.Entry<String, RenderObjectHandle> e : renderObjects.entrySet()) {
       Instance i = e.getValue().getInstance();
       if (i != null) {
         i.updateBounds();
         if (i.getBounds() == null) numInfinite++;
         else numInstance++;
       }
     }
     Instance[] infinite = new Instance[numInfinite];
     Instance[] instance = new Instance[numInstance];
     numInfinite = numInstance = 0;
     for (Map.Entry<String, RenderObjectHandle> e : renderObjects.entrySet()) {
       Instance i = e.getValue().getInstance();
       if (i != null) {
         if (i.getBounds() == null) {
           infinite[numInfinite] = i;
           numInfinite++;
         } else {
           instance[numInstance] = i;
           numInstance++;
         }
       }
     }
     scene.setInstanceLists(instance, infinite);
     rebuildInstanceList = false;
   }
   if (rebuildLightList) {
     UI.printInfo(Module.API, "Building scene light list for rendering ...");
     ArrayList<LightSource> lightList = new ArrayList<LightSource>();
     for (Map.Entry<String, RenderObjectHandle> e : renderObjects.entrySet()) {
       LightSource light = e.getValue().getLight();
       if (light != null) lightList.add(light);
     }
     scene.setLightList(lightList.toArray(new LightSource[lightList.size()]));
     rebuildLightList = false;
   }
 }
Esempio n. 2
0
 static {
   UI.printInfo(Module.QMC, "Initializing Faure scrambling tables ...");
   // build table of first primes
   PRIMES[0] = 2;
   for (int i = 1; i < PRIMES.length; i++) PRIMES[i] = nextPrime(PRIMES[i - 1]);
   int[][] table = new int[PRIMES[PRIMES.length - 1] + 1][];
   table[2] = new int[2];
   table[2][0] = 0;
   table[2][1] = 1;
   for (int i = 3; i <= PRIMES[PRIMES.length - 1]; i++) {
     table[i] = new int[i];
     if ((i & 1) == 0) {
       int[] prev = table[i >> 1];
       for (int j = 0; j < prev.length; j++) table[i][j] = 2 * prev[j];
       for (int j = 0; j < prev.length; j++) table[i][prev.length + j] = 2 * prev[j] + 1;
     } else {
       int[] prev = table[i - 1];
       int med = (i - 1) >> 1;
       for (int j = 0; j < med; j++) table[i][j] = prev[j] + ((prev[j] >= med) ? 1 : 0);
       table[i][med] = med;
       for (int j = 0; j < med; j++)
         table[i][med + j + 1] = prev[j + med] + ((prev[j + med] >= med) ? 1 : 0);
     }
   }
   for (int i = 0; i < PRIMES.length; i++) {
     int p = PRIMES[i];
     SIGMA[i] = new int[p];
     System.arraycopy(table[p], 0, SIGMA[i], 0, p);
   }
   UI.printInfo(Module.QMC, "Initializing lattice tables ...");
   FIBONACCI[0] = 0;
   FIBONACCI[1] = 1;
   for (int i = 2; i < FIBONACCI.length; i++) {
     FIBONACCI[i] = FIBONACCI[i - 1] + FIBONACCI[i - 2];
     FIBONACCI_INV[i] = 1.0 / FIBONACCI[i];
   }
   KOROBOV[0] = 1;
   for (int i = 1; i < KOROBOV.length; i++) KOROBOV[i] = 203 * KOROBOV[i - 1];
 }