Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[Manta] r2358 - trunk/Model/Materials


Chronological Thread 
  • From:
  • To:
  • Subject: [Manta] r2358 - trunk/Model/Materials
  • Date: Thu, 18 Dec 2008 14:44:16 -0700 (MST)

Author: brownlee
Date: Thu Dec 18 14:44:14 2008
New Revision: 2358

Modified:
   trunk/Model/Materials/Volume.cc
Log:
fixing squishing operation for range culling

Modified: trunk/Model/Materials/Volume.cc
==============================================================================
--- trunk/Model/Materials/Volume.cc     (original)
+++ trunk/Model/Materials/Volume.cc     Thu Dec 18 14:44:14 2008
@@ -169,29 +169,28 @@
 
   RGBAColor RGBAColorMap::GetColor(float v)  // get the interpolated color 
at value v (0-1)
   {
-    v = v*squish_scale + squish_min;
     if (_slices.size() == 0)
       return RGBAColor(Color(RGB(0,0,0)), 1.0f);
     int start = 0;
     int end = _slices.size()-1;
         
-    if (v < _slices[0].value)
+    if (v < _slices[0].value*squish_scale + squish_min)
       return _slices[0].color;
-    if (v > _slices[end].value)
+    if (v > _slices[end].value*squish_scale + squish_min)
       return _slices[end].color;
     //binary search over values
     int middle;
     while(end > start+1)
       {
         middle = (start+end)/2;
-        if (v < _slices[middle].value)
+        if (v < _slices[middle].value*squish_scale + squish_min)
           end = middle;
-        else if (v > _slices[middle].value)
+        else if (v > _slices[middle].value*squish_scale + squish_min)
           start = middle;
         else
           return _slices[middle].color;
       }
-    float interp = (v - _slices[start].value) / (_slices[end].value - 
_slices[start].value);
+    float interp = (v - (_slices[start].value*squish_scale + squish_min)) / 
((_slices[end].value - _slices[start].value)*squish_scale);
     return RGBAColor( Color(_slices[start].color.color*(1.0f-interp) + 
_slices[end].color.color*interp), 
                       _slices[start].color.a*(1.0f-interp) + 
_slices[end].color.a*interp);
         
@@ -239,20 +238,19 @@
       if (val != 0 || next_val != 0) {
         int start, end;
         start = (int)((_slices[a_index].value * squish_scale + 
squish_min)*nindex);
-        end = (int)ceilf(_slices[a_index+1].value * nindex);
+        end = (int)ceilf((_slices[a_index+1].value * squish_scale 
+squish_min)*nindex);
         for (int i = start; i <= end; i++)
           // Turn on the bits.
           new_course_hash |= 1ULL << i;
       }
     }
-
     course_hash = new_course_hash;
     //size_t num_bits = sizeof(course_hash)*8;
-    //  for(size_t i = 0; i < num_bits; i++)
-    // if (course_hash & ( 1ULL << i ))
-    //  cout << 1;
-    // else
-    //  cout << 0;
+    //for(size_t i = 0; i < num_bits; i++)
+        //if (course_hash & ( 1ULL << i ))
+       //cout << 1;
+      //else
+       // cout << 0;
 
   }
 


  • [Manta] r2358 - trunk/Model/Materials, brownlee, 12/18/2008

Archive powered by MHonArc 2.6.16.

Top of page