Ignore:
Timestamp:
01/14/08 15:54:15 (17 years ago)
Author:
bittner
Message:

havran ray caster update

File:
1 edited

Legend:

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

    r2590 r2592  
    9494 
    9595                Intersectable *oldObject = mRays[vssRays[i]->mGeneratorId].mRay->mTerminationObject; 
    96                  
     96                // the ray generated a contribution although it hits the same object 
     97                // mark this using a counter 
    9798                if (oldObject == newObject) 
    9899                  dummyCMutations++; 
     
    106107                mRays.push_back(RayEntry(newRay)); 
    107108          } else { 
    108                 // unref the old ray 
     109                // unref the old ray and add the new ray into the mutation buffer 
    109110                *mRays[mBufferStart].mRay = *vssRays[i]; 
    110111                mRays[mBufferStart].mMutations = 0; 
     
    117118          } 
    118119        } else { 
     120          // the ray did not generate any contribution 
    119121          if (vssRays[i]->mDistribution == MUTATION_BASED_DISTRIBUTION && 
    120122                  vssRays[i]->mGeneratorId != -1 
    121123                  ) { 
    122124                // check whether not to store a new backward mutation candidate 
     125                // this happens if the new ray is occluded significantly closer than 
     126                // the generator ray 
    123127                VssRay *oldRay = mRays[vssRays[i]->mGeneratorId].mRay; 
    124128                VssRay *newRay = vssRays[i]; 
    125129 
    126  
    127130                Intersectable *oldObject = oldRay->mTerminationObject; 
    128                  
    129  
     131 
     132                // only allow one reverse mutation per generator ray 
    130133                if (!mRays[newRay->mGeneratorId].HasReverseMutation()) { 
    131134                  if (DotProd(oldRay->GetDir(), newRay->GetDir()) > 0.0f) { 
     
    149152                Intersectable *newObject = vssRays[i]->mTerminationObject; 
    150153 
    151  
    152154                if (oldObject == newObject) 
    153155                  dummyNcMutations++; 
     
    163165        cout<<"Dummy NC mutations ratio:"<<100.0f*dummyNcMutations/(float)mutationRays<<"%"<<endl; 
    164166        cout<<"Dummy C mutations ratio:"<<100.0f*dummyCMutations/(float)mutationRays<<"%"<<endl; 
    165         cout<<"Reverse candidates:"<<reverseCandidates<<endl; 
     167        cout<<"Reverse candidates:"<<100.0f*reverseCandidates/(float)mutationRays<<endl; 
    166168  } 
    167169   
    168170  float pContributingRays = contributingRays/(float)vssRays.size(); 
    169171   
    170   cout<<"Percentage of contributing rays:"<<pContributingRays<<endl; 
     172  cout<<"Ratio of contributing rays:"<<pContributingRays<<endl; 
    171173   
    172174  if (mUseUnsuccCountImportance) { 
     
    233235                                                                                                 ) 
    234236{ 
    235 #if 0 
    236   Vector3 v; 
    237   if (d.DrivingAxis() == 0) 
    238         v = Vector3(0, r[0]-0.5f, r[1]-0.5f); 
    239   else 
    240         if (d.DrivingAxis() == 1) 
    241           v = Vector3(r[0]-0.5f, 0, r[1]-0.5f); 
    242         else 
    243           v = Vector3(r[0]-0.5f, r[1]-0.5f, 0); 
    244   return v*(2*radius); 
    245 #endif 
    246237#if 0 
    247238  return (U*(r[0] - 0.5f) + V*(r[1] - 0.5f))*(2*radius); 
     
    339330   
    340331  AxisAlignedBox3 box = occluder->GetBox(); 
     332  // consider slightly larger neighborhood of the occluder 
     333  // in search for unocclude reverse ray 
    341334  box.Scale(2.0f); 
    342335   
     
    430423  } 
    431424 
     425  return true; 
    432426#else 
    433427  cerr << "warning: reverse mutation not supported!" << endl; 
    434 #endif 
    435    
    436   return true; 
     428  return false; 
     429#endif 
     430   
    437431   
    438432  // now the origin and termination is swapped compred to the generator ray 
     
    510504 
    511505#else 
    512         cerr << "warning: shiluette mutation not supported" << endl; 
    513         return Vector3(0, 0, 0); 
     506  //cerr << "warning: shiluette mutation not supported" << endl; 
     507  return Vector3(0, 0, 0); 
    514508#endif 
    515509   
     
    523517  if (mRays.size() == 0) { 
    524518        float rr[5]; 
    525         // use direction based distribution 
     519        // use direction based distribution until we have some mutation candidates 
    526520        Vector3 origin, direction; 
    527521 
     
    532526                                                                                                  Vector3(rr[0], rr[1], rr[2])); 
    533527         
    534  
     528         
    535529        direction = UniformRandomVector(rr[3], rr[4]); 
    536530         
     
    538532        sray = SimpleRay(origin, direction, MUTATION_BASED_DISTRIBUTION, pdf); 
    539533        sray.mGeneratorId = -1; 
    540  
     534         
    541535        return true; 
    542   }  
     536  } 
    543537 
    544538  int index; 
     
    552546        if ( 
    553547                mRays[index].GetSamplingFactor() >= mRays[mLastIndex].GetSamplingFactor()) { 
    554           // make another round 
     548          // make another round to equalize the oversampling factor 
    555549 
    556550          //      cout<<"R2"<<endl; 
     
    666660   
    667661  if (mUseSilhouetteSamples && a < mSilhouetteProb) { 
    668          
    669662        termination += ComputeSilhouetteTerminationMutation(*ray, 
    670663                                                                                                                origin, 
     
    692685   
    693686  // shift the origin a little bit 
     687#if 1 
    694688  origin += direction*0.5f; 
     689#else 
     690  // $$JB - 14.1. 2008 increase shift to test HavranRayCaster 
     691  origin = 0.5f*(origin + termination); 
     692#endif 
    695693   
    696694  direction.Normalize(); 
     
    718716    mRays[index].mMutations++; 
    719717        mRays[index].mUnsuccessfulMutations++; 
    720  
    721718        return true; 
    722719  } 
Note: See TracChangeset for help on using the changeset viewer.