Ignore:
Timestamp:
01/03/08 15:53:44 (17 years ago)
Author:
bittner
Message:

big merge: preparation for havran ray caster, check if everything works

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.cpp

    r2332 r2575  
    11 
    2 // GOLEM library 
    3 #include <assert.h> 
    42#include <iostream> 
    53#include "AxisAlignedBox3.h" 
     
    108#include "Triangle3.h" 
    119#include "VssRay.h" 
     10 
     11 
     12 
     13#include <cassert> 
    1214 
    1315 
     
    210212int 
    211213AxisAlignedBox3::ComputeMinMaxT(const Ray &ray, 
    212                                                                 float *tmin, 
    213                                                                 float *tmax) const 
     214                                float *tmin, 
     215                                float *tmax) const 
    214216{ 
    215217  float minx, maxx, miny, maxy, minz, maxz; 
     
    302304int 
    303305AxisAlignedBox3::ComputeMinMaxT(const Ray &ray, 
    304                                                                 float *tmin, 
    305                                                                 float *tmax) const 
     306                                float *tmin, 
     307                                float *tmax) const 
    306308{ 
    307309  const float dirEps = 1e-8f; 
     
    398400// the bounding box and 0 if it does not. 
    399401int AxisAlignedBox3::ComputeMinMaxT(const Ray &ray, float *tmin, float *tmax, 
    400                                                                         EFaces &entryFace, EFaces &exitFace) const 
     402                                    EFaces &entryFace, EFaces &exitFace) const 
    401403{ 
    402404  float minx, maxx, miny, maxy, minz, maxz; 
     
    18401842int 
    18411843AxisAlignedBox3::ComputeMinMaxT(const Vector3 &origin, 
    1842                                                                 const Vector3 &direction, 
    1843                                                                 float *tmin, 
    1844                                                                 float *tmax) const 
    1845 { 
    1846  
     1844                                const Vector3 &direction, 
     1845                                float *tmin, 
     1846                                float *tmax) const 
     1847{ 
    18471848  register float minx, maxx; 
    18481849 
     
    22352236 
    22362237 
     2238void AxisAlignedBox3::EnlargeToMinSize() 
     2239{ 
     2240  const float epsMin = 1e-7; 
     2241  const float epsAdd = 1e-6; 
     2242  const float epsMul = 1.000005; 
     2243  float dir = mMax.x - mMin.x; 
     2244  assert(dir >= 0.f); 
     2245  if (dir < epsMin) { 
     2246    if (mMax.x > 0) { 
     2247      mMax.x *= epsMul; 
     2248      mMax.x += epsAdd; 
     2249    } 
     2250    else { 
     2251      mMin.x *= epsMul; 
     2252      mMin.x -= epsAdd; 
     2253    } 
     2254    assert(mMin.x < mMax.x); 
     2255  } 
     2256  dir = mMax.y - mMin.y; 
     2257  assert(dir >= 0.f); 
     2258  if (dir < epsMin) { 
     2259    if (mMax.y > 0) { 
     2260      mMax.y *= epsMul; 
     2261      mMax.y += epsAdd; 
     2262    } 
     2263    else { 
     2264      mMin.y *= epsMul; 
     2265      mMin.y -= epsAdd; 
     2266    } 
     2267    assert(mMin.y < mMax.y); 
     2268  } 
     2269  dir = mMax.z - mMin.z; 
     2270  assert(dir >= 0.f); 
     2271  if (dir < epsMin) { 
     2272    if (mMax.z > 0) { 
     2273      mMax.z *= epsMul; 
     2274      mMax.z += epsAdd; 
     2275    } 
     2276    else { 
     2277      mMin.z *= epsMul; 
     2278      mMin.z -= epsAdd; 
     2279    } 
     2280    assert(mMin.z < mMax.z); 
     2281  } 
     2282} 
     2283 
    22372284void AxisAlignedBox3::SetMin(const Vector3 &v)  
    22382285{ 
    2239         mMin = v; 
     2286  mMin = v; 
    22402287} 
    22412288 
     
    22432290void AxisAlignedBox3::SetMax(const Vector3 &v)  
    22442291{ 
    2245         mMax = v; 
     2292  mMax = v; 
    22462293} 
    22472294 
Note: See TracChangeset for help on using the changeset viewer.