Ignore:
Timestamp:
11/24/06 00:24:41 (18 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r1757 r1786  
    5555 
    5656        if (hittriangle != -1 ) { 
    57                 if (hittriangle >= mPreprocessor.mFaceParents.size()) 
    58                         cerr<<"Warning: triangle index out of range! "<<hittriangle<<endl; 
    59                 else { 
    60                         hitA.mObject = mPreprocessor.mFaceParents[hittriangle].mObject; 
     57                Intersectable *intersect = mPreprocessor.GetParentObject(hittriangle); 
     58                 
     59                if (intersect) 
     60                { 
     61                        hitA.mObject = intersect; 
    6162                        hitA.mNormal = Vector3(normal[0], normal[1], normal[2]); 
    6263                        // Get the normal of that face 
     
    7778                        dist); 
    7879 
    79                 if (hittriangle != -1 ) { 
    80                         if (hittriangle >= mPreprocessor.mFaceParents.size()) 
    81                                 cerr<<"Warning: triangle index out of range! "<<hittriangle<<endl; 
    82                         else  
    83                         { 
    84                                 hitB.mObject = mPreprocessor.mFaceParents[hittriangle].mObject; 
    85                                 hitB.mNormal = Vector3(normal[0], normal[1], normal[2]); 
    86                                 // Get the normal of that face 
    87                                 //              Mesh *mesh = ((MeshInstance *)objectB)->GetMesh(); 
    88                                 //              normalA = mesh->GetFacePlane(mFaceParents[forward_hit_triangles[i]].mFaceIndex).mNormal; 
    89                                 //-rays[index+i].mDirection; // $$ temporary 
    90                                 hitB.mPoint = simpleRay.Extrap(dist); 
    91                         } 
     80                Intersectable *intersect = mPreprocessor.GetParentObject(hittriangle); 
     81                 
     82                if (intersect) 
     83                { 
     84                        hitB.mObject = intersect; 
     85                        hitB.mNormal = Vector3(normal[0], normal[1], normal[2]); 
     86                        // Get the normal of that face 
     87                        //              Mesh *mesh = ((MeshInstance *)objectB)->GetMesh(); 
     88                        //              normalA = mesh->GetFacePlane(mFaceParents[forward_hit_triangles[i]].mFaceIndex).mNormal; 
     89                        //-rays[index+i].mDirection; // $$ temporary 
     90                        hitB.mPoint = simpleRay.Extrap(dist); 
    9291                } 
    9392        } 
     
    170169 
    171170        for (i=0; i < num; i++)  
    172           { 
     171        { 
    173172                Intersection hitA(rays[i].mOrigin), hitB(rays[i].mOrigin); 
    174173 
    175174#if DEBUG_RAYCAST 
    176           Debug<<"FH\n"<<flush; 
    177 #endif 
    178                  
    179                 if (forward_hit_triangles[i] != -1 ) { 
    180                   if (forward_hit_triangles[i] >= mPreprocessor.mFaceParents.size()) 
    181                         cerr<<"Warning: triangle index out of range! "<<forward_hit_triangles[i]<<endl; 
    182                   else {  
    183                         hitA.mObject = mPreprocessor.mFaceParents[forward_hit_triangles[i]].mObject; 
     175                Debug<<"FH\n"<<flush; 
     176#endif 
     177                Intersectable *intersect = mPreprocessor.GetParentObject(forward_hit_triangles[i]); 
     178 
     179                if (intersect) 
     180                { 
     181                        hitA.mObject = intersect; 
    184182                        // Get the normal of that face 
    185                         hitA.mNormal = hitA.mObject->GetNormal(mPreprocessor.mFaceParents[forward_hit_triangles[i]].mFaceIndex); 
     183                        hitA.mNormal = mPreprocessor.GetParentNormal(forward_hit_triangles[i]); 
     184 
    186185                        //-rays[index+i].mDirection; // $$ temporary 
    187186                        hitA.mPoint = rays[index+i].Extrap(forward_dist[i]); 
     187                } 
     188         
     189#if DEBUG_RAYCAST 
     190                Debug<<"BH\n"<<flush; 
     191#endif 
     192 
     193                if (castDoubleRay)  
     194                { 
     195                        Intersectable *intersect = mPreprocessor.GetParentObject(backward_hit_triangles[i]); 
     196 
     197                        if (intersect) 
     198                        {  
     199                                hitB.mObject = intersect; 
     200                                hitB.mNormal = mPreprocessor.GetParentNormal(backward_hit_triangles[i]); 
     201 
     202                                // normalB = rays[index+i].mDirection; // $$ temporary 
     203                                hitB.mPoint = rays[index+i].Extrap(-backward_dist[i]); 
    188204                        } 
    189           } 
    190 #if DEBUG_RAYCAST 
    191           Debug<<"BH\n"<<flush; 
    192 #endif 
    193            
    194           if (castDoubleRay && (backward_hit_triangles[i] != -1)) { 
    195                 if (backward_hit_triangles[i] >= mPreprocessor.mFaceParents.size()) 
    196                   cerr<<"Warning: triangle  index out of range! "<<backward_hit_triangles[i]<<endl; 
    197                 else {  
    198                   hitB.mObject = mPreprocessor.mFaceParents[backward_hit_triangles[i]].mObject; 
    199                   hitB.mNormal = hitB.mObject->GetNormal(mPreprocessor.mFaceParents[backward_hit_triangles[i]].mFaceIndex); 
    200                    
    201                   // normalB = rays[index+i].mDirection; // $$ temporary 
    202                   hitB.mPoint = rays[index+i].Extrap(-backward_dist[i]); 
    203                 } 
    204           } 
    205            
    206 #if DEBUG_RAYCAST 
    207           Debug<<"PR\n"<<flush; 
    208 #endif 
    209            
    210           ProcessRay( 
    211                                  rays[index + i], 
    212                                  hitA, 
    213                                  hitB, 
    214                                  vssRays, 
    215                                  sbox, 
    216                                  castDoubleRay, 
    217                                  pruneInvalidRays 
    218                                  ); 
    219         } 
    220          
     205                } 
     206 
     207#if DEBUG_RAYCAST 
     208                Debug<<"PR\n"<<flush; 
     209#endif 
     210 
     211                ProcessRay(rays[index + i], 
     212                                   hitA, 
     213                                   hitB, 
     214                                   vssRays, 
     215                                   sbox, 
     216                                   castDoubleRay, 
     217                                   pruneInvalidRays 
     218                                   ); 
     219        } 
     220 
    221221#if DEBUG_RAYCAST 
    222222        Debug<<"C16F\n"<<flush; 
Note: See TracChangeset for help on using the changeset viewer.