Changeset 499


Ignore:
Timestamp:
01/04/06 20:03:54 (18 years ago)
Author:
bittner
Message:

updated vsspreprocessor castray to match rssprep - makes sure that only valid line segments are taken, although it is a bit slower now

Location:
trunk/VUT/GtpVisibilityPreprocessor/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/src/Makefile

    r496 r499  
    11############################################################################# 
    22# Makefile for building: preprocessor 
    3 # Generated by qmake (2.00a) (Qt 4.1.0) on: st 4. I 15:01:55 2006 
     3# Generated by qmake (2.00a) (Qt 4.1.0) on: st 4. I 19:53:26 2006 
    44# Project:  preprocessor.pro 
    55# Template: app 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp

    r492 r499  
    5656                                                 ) 
    5757{ 
    58   int hits = 0; 
     58 
     59    int hits = 0; 
    5960  static Ray ray; 
    6061  AxisAlignedBox3 box = mKdTree->GetBox(); 
     
    6465  if (!sbox.IsInside(viewPoint)) 
    6566        return 0; 
    66  
     67         
    6768  SetupRay(ray, viewPoint, direction); 
    6869  // cast ray to KD tree to find intersection with other objects 
     
    7071  Vector3 pointA, pointB; 
    7172  float bsize = Magnitude(box.Size()); 
     73 
     74   
    7275  if (mKdTree->CastRay(ray)) { 
    7376        objectA = ray.intersections[0].mObject; 
     
    7780        // compute intersection with the scene bounding box 
    7881        float tmin, tmax; 
    79         box.ComputeMinMaxT(ray, &tmin, &tmax); 
    80         if (tmax > bsize) { 
    81           //                    cerr<<"Warning: tmax > box size tmax="<<tmax<<" tmin="<<tmin<<" size="<<bsize<<endl; 
    82           //                    cerr<<"ray"<<ray<<endl; 
    83         } 
    84         pointA = ray.Extrap(tmax); 
    85  
     82        if (box.ComputeMinMaxT(ray, &tmin, &tmax) && tmin < tmax) 
     83          pointA = ray.Extrap(tmax); 
     84        else 
     85          return 0; 
    8686  } 
    8787 
    8888  bool detectEmptyViewSpace = true; 
    89  
     89         
    9090  if (detectEmptyViewSpace) { 
    9191        SetupRay(ray, pointA, -direction); 
    9292  } else 
    9393        SetupRay(ray, viewPoint, -direction); 
    94  
     94         
     95         
    9596  if (mKdTree->CastRay(ray)) { 
    96  
    9797        objectB = ray.intersections[0].mObject; 
    9898        pointB = ray.Extrap(ray.intersections[0].mT); 
    99  
    10099  } else { 
    101100        objectB = NULL; 
    102101        float tmin, tmax; 
    103         box.ComputeMinMaxT(ray, &tmin, &tmax); 
    104         if (tmax > bsize) { 
    105           //                    cerr<<"Warning: tmax > box size tmax="<<tmax<<" tmin="<<tmin<<" size="<<bsize<<endl; 
    106           //                    cerr<<"ray"<<ray<<endl; 
    107         } 
    108  
    109         pointB = ray.Extrap(tmax); 
    110   } 
    111  
     102        if (box.ComputeMinMaxT(ray, &tmin, &tmax) && tmin < tmax) 
     103          pointB = ray.Extrap(tmax); 
     104        else 
     105          return 0; 
     106  } 
     107 
     108  //  if (objectA == NULL && objectB != NULL) { 
     109  if (1) { 
     110        // cast again to ensure that there is no objectA 
     111        SetupRay(ray, pointB, direction); 
     112        if (mKdTree->CastRay(ray)) { 
     113          objectA = ray.intersections[0].mObject; 
     114          pointA = ray.Extrap(ray.intersections[0].mT); 
     115        } 
     116  } 
     117   
     118   
    112119  VssRay *vssRay  = NULL; 
    113120 
    114   bool validSample = true; 
    115   if (detectEmptyViewSpace) { 
     121  bool validSample = (objectA != objectB); 
     122  if (0 && detectEmptyViewSpace) {   // consider all samples valid 
     123        // check if the viewpoint lies on the line segment AB 
    116124        if (Distance(pointA, pointB) < 
    117125                Distance(viewPoint, pointA) + Distance(viewPoint, pointB) - Limits::Small) { 
     
    119127        } 
    120128  } 
    121  
     129         
    122130  if (validSample) { 
    123131        if (objectA) { 
     
    125133                                                  pointA, 
    126134                                                  objectB, 
    127                                                   objectA); 
     135                                                  objectA, 
     136                                                  mPass 
     137                                                  ); 
    128138          vssRays.push_back(vssRay); 
    129139          hits ++; 
    130140        } 
    131  
     141         
    132142        if (objectB) { 
    133143          vssRay = new VssRay(pointA, 
    134144                                                  pointB, 
    135145                                                  objectA, 
    136                                                   objectB); 
     146                                                  objectB, 
     147                                                  mPass 
     148                                                  ); 
    137149          vssRays.push_back(vssRay); 
    138150          hits ++; 
    139151        } 
    140152  } 
    141  
     153         
    142154  return hits; 
    143155} 
Note: See TracChangeset for help on using the changeset viewer.