Shadowrun: Awakened 29 September 2011 - Build 871
Functions
intersect.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void add_intersection (flt, object *, ray *)
void add_object (object *)
int closest_intersection (flt *, object **, intersectstruct *)
void free_objects (object *)
void intersect_objects (ray *)
unsigned int max_objectid (void)
unsigned int new_objectid (void)
int next_intersection (object **, object *, intersectstruct *)
void reset_intersection (intersectstruct *)
void reset_object (void)
int shadow_intersection (intersectstruct *intstruct, flt maxdist)

Function Documentation

void add_intersection ( flt  ,
object ,
ray  
)

Definition at line 133 of file intersect.cpp.

References EPSILON, ray::flags, ray::intstruct, intersectstruct::list, ray::maxdist, intersectstruct::num, mission1::obj, intersection::obj, RT_RAY_FINISHED, RT_RAY_SHADOW, and intersection::t.

Referenced by box_intersect(), cylinder_intersect(), fcylinder_intersect(), light_intersect(), plane_intersect(), quadric_intersect(), ring_intersect(), sphere_intersect(), and tri_intersect().

                                                     {
  intersectstruct * intstruct = ry->intstruct;

  if (t > EPSILON) {

    /* if we hit something before maxdist update maxdist */
    if (t < ry->maxdist) {
      ry->maxdist = t;

      /* if we hit *anything* before maxdist, and we're firing a */
      /* shadow ray, then we are finished ray tracing the shadow */
      if (ry->flags & RT_RAY_SHADOW)
        ry->flags |= RT_RAY_FINISHED;
    }

    intstruct->num++;
    intstruct->list[intstruct->num].obj = obj;
    intstruct->list[intstruct->num].t = t;
  }
}
void add_object ( object )

Definition at line 79 of file intersect.cpp.

References object::id, new_objectid(), object::nextobj, mission1::obj, and rootobj.

Referenced by rt_box(), rt_cylinder(), rt_extvol(), rt_fcylinder(), rt_light(), rt_plane(), rt_quadsphere(), rt_ring(), rt_scalarvol(), rt_sphere(), rt_stri(), and rt_tri().

                              {
  object * objtemp;

  if (obj == NULL)
    return;

  obj->id = new_objectid();

  objtemp = rootobj;
  rootobj = obj;
  obj->nextobj = objtemp;
}
int closest_intersection ( flt ,
object **  ,
intersectstruct  
)

Definition at line 155 of file intersect.cpp.

References FHUGE, intersectstruct::list, intersectstruct::num, intersection::obj, and intersection::t.

Referenced by shader().

                                                                              {
  int i;
  *t=FHUGE;

  for (i=1; i<=intstruct->num; i++) {
    if (intstruct->list[i].t < *t) {
        *t=intstruct->list[i].t;
      *obj=intstruct->list[i].obj;
    }
  } 

  return intstruct->num;
}
void free_objects ( object )

Definition at line 92 of file intersect.cpp.

References object_methods::free, object::methods, and object::nextobj.

Referenced by free_bndbox(), grid_free(), and reset_object().

                                  {
  object * cur;
  object * cur2;

  cur=start; 
  while (cur->nextobj != NULL) { 
    cur2=(object *)cur->nextobj;
    cur->methods->free(cur);
    cur=cur2;
  }
  free(cur);

}
void intersect_objects ( ray )

Definition at line 114 of file intersect.cpp.

References object_methods::intersect, object::methods, object::nextobj, and rootobj.

Referenced by shader(), and trace().

                                     {
  object * cur;
  object temp;

  temp.nextobj = rootobj; /* setup the initial object pointers.. */
  cur = &temp;            /* ready, set                          */

  while ((cur=(object *)cur->nextobj) != NULL)          
    cur->methods->intersect(cur, intray); 
}
unsigned int max_objectid ( void  )

Definition at line 75 of file intersect.cpp.

References numobjects.

Referenced by parallel_thread().

                                {
  return numobjects;
}
unsigned int new_objectid ( void  )

Definition at line 71 of file intersect.cpp.

References numobjects.

Referenced by add_object(), and newgrid().

                                {
  return numobjects++; /* global used to generate unique object ID's */
}
int next_intersection ( object **  ,
object ,
intersectstruct  
)
void reset_intersection ( intersectstruct )

Definition at line 125 of file intersect.cpp.

References FHUGE, intersectstruct::list, intersectstruct::num, intersection::obj, and intersection::t.

Referenced by shader(), and trace().

                                                     {
  intstruct->num = 0;
  intstruct->list[0].t = FHUGE;
  intstruct->list[0].obj = NULL;
  intstruct->list[1].t = FHUGE;
  intstruct->list[1].obj = NULL;
}
void reset_object ( void  )

Definition at line 106 of file intersect.cpp.

References free_objects(), numobjects, and rootobj.

Referenced by rt_initialize().

                        {
  if (rootobj != NULL)
    free_objects(rootobj);

  rootobj = NULL;
  numobjects = 0; /* set number of objects back to 0 */
}
int shadow_intersection ( intersectstruct intstruct,
flt  maxdist 
)

Definition at line 169 of file intersect.cpp.

References intersectstruct::list, intersectstruct::num, intersection::obj, texture::shadowcast, intersection::t, and object::tex.

Referenced by shader().

                                                                  {
  int i;
  
  if (intstruct->num > 0) {
    for (i=1; i<=intstruct->num; i++) {
      if ((intstruct->list[i].t < maxdist) && 
          (intstruct->list[i].obj->tex->shadowcast == 1)) {
        return 1;
      }
    }
  }
  
  return 0;
}

Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.

GNU Lesser General Public License 3 Sourceforge.net