Subversion Repositories gelsvn

Rev

Rev 364 | Rev 429 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 364 Rev 428
Line 321... Line 321...
321
    tri_objects.push_back(tri_accel);
321
        tri_objects.push_back(tri_accel);
322
      }
322
      }
323
      subdivide_node(*root, bbox, 0, objects, tri_objects);
323
      subdivide_node(*root, bbox, 0, objects, tri_objects);
324
      b_is_build = true;
324
      b_is_build = true;
325
    }
325
    }
326
    isecttris.clear();
-
 
327
    all_objects.clear();
-
 
328
    make_fast_tree(root);
326
    make_fast_tree(root);
329
  }
327
  }
330
 
328
 
331
  bool BSPTree::is_build() 
329
  bool BSPTree::is_build() 
332
  {
330
  {
Line 441... Line 439...
441
      else
439
      else
442
    t = (node.plane - ray.origin[node.axis_leaf])/ray.direction[node.axis_leaf];// intersect node plane;
440
        t = (node.plane - ray.origin[node.axis_leaf])/ray.direction[node.axis_leaf];// intersect node plane;
443
      
441
      
444
      if (t>t_max) 
442
      if (t>t_max) 
445
        return intersect_node(ray, *near_node, t_min, t_max);
443
        return intersect_node(ray, *near_node, t_min, t_max);      
446
      
-
 
447
      else if (t<t_min) 
444
      else if (t<t_min) 
448
    return intersect_node(ray, *far_node, t_min, t_max);
445
        return intersect_node(ray, *far_node, t_min, t_max);
449
      else 
446
      else 
450
      {
447
      {
451
    if (intersect_node(ray, *near_node, t_min, t))
448
        if (intersect_node(ray, *near_node, t_min, t))
Line 472... Line 469...
472
//    intersect_fast_node(ray, &fast_tree[0], t_min, t_max);
469
//    intersect_fast_node(ray, &fast_tree[0], t_min, t_max);
473
    //  if (!ray.has_hit)
470
    //  if (!ray.has_hit)
474
    //return false;
471
    //return false;
475
    else 
472
    else 
476
    {
473
    {
477
 
-
 
478
        //printf("HIT\n");
474
      //printf("HIT\n");
479
 
475
 
480
 
-
 
481
      // Calculate the normal at the intersection
476
      // Calculate the normal at the intersection
482
        ray.id = reinterpret_cast<int>(ray.hit_object);
477
      ray.id = reinterpret_cast<int>(ray.hit_object);
483
        ray.hit_object = trimesh[ray.id];
478
      ray.hit_object = trimesh[ray.id];
484
        
479
      
485
        Vec3i face = ray.hit_object->normals.face(ray.hit_face_id);
480
      Vec3i face = ray.hit_object->normals.face(ray.hit_face_id);
Line 500... Line 495...
500
      ray.hit_normal = normalize(normal0*(1 - ray.u - ray.v)
495
      ray.hit_normal = normalize(normal0*(1 - ray.u - ray.v)
501
                 +normal1*ray.u
496
                 +normal1*ray.u
502
                 +normal2*ray.v);
497
                 +normal2*ray.v);
503
      ray.hit_pos = ray.origin + ray.direction*ray.dist;
498
      ray.hit_pos = ray.origin + ray.direction*ray.dist;
504
*/
499
*/
505
 
-
 
506
      return true;
500
      return true;
507
    }
501
    }
508
  }
502
  }
509
 
503
 
510
  const int MAX_DEPTH=25;
504
  const int MAX_DEPTH=25;