| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264 |
- /****************************************************************************
- * ray.c
- *
- * This module implements the code pertaining to rays.
- *
- * from Persistence of Vision(tm) Ray Tracer
- * Copyright 1996,1999 Persistence of Vision Team
- *---------------------------------------------------------------------------
- * NOTICE: This source code file is provided so that users may experiment
- * with enhancements to POV-Ray and to port the software to platforms other
- * than those supported by the POV-Ray Team. There are strict rules under
- * which you are permitted to use this file. The rules are in the file
- * named POVLEGAL.DOC which should be distributed with this file.
- * If POVLEGAL.DOC is not available or for more info please contact the POV-Ray
- * Team Coordinator by email to team-coord@povray.org or visit us on the web at
- * http://www.povray.org. The latest version of POV-Ray may be found at this site.
- *
- * This program is based on the popular DKB raytracer version 2.12.
- * DKBTrace was originally written by David K. Buck.
- * DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
- *
- *****************************************************************************/
- #include "frame.h"
- #include "vector.h"
- #include "povproto.h"
- #include "povray.h"
- #include "interior.h"
- #include "ray.h"
- #include "texture.h"
- /*****************************************************************************
- * Local preprocessor defines
- ******************************************************************************/
- /*****************************************************************************
- * Local typedefs
- ******************************************************************************/
- /*****************************************************************************
- * Local variables
- ******************************************************************************/
- /*****************************************************************************
- * Static functions
- ******************************************************************************/
- /*****************************************************************************
- *
- * FUNCTION
- *
- * Initialize_Ray_Containers
- *
- * INPUT
- *
- * OUTPUT
- *
- * RETURNS
- *
- * AUTHOR
- *
- * POV-Ray Team
- *
- * DESCRIPTION
- *
- * -
- *
- * CHANGES
- *
- * -
- *
- ******************************************************************************/
- void Initialize_Ray_Containers(RAY *Ray)
- {
- Ray->Index = - 1;
- }
- /*****************************************************************************
- *
- * FUNCTION
- *
- * Copy_Ray_Containers
- *
- * INPUT
- *
- * OUTPUT
- *
- * RETURNS
- *
- * AUTHOR
- *
- * POV-Ray Team
- *
- * DESCRIPTION
- *
- * -
- *
- * CHANGES
- *
- * -
- *
- ******************************************************************************/
- void Copy_Ray_Containers(RAY *Dest_Ray, RAY *Source_Ray)
- {
- register int i;
- if ((Dest_Ray->Index = Source_Ray->Index) >= MAX_CONTAINING_OBJECTS)
- {
- Error("ERROR - Containing Index too high.\n");
- }
- for (i = 0 ; i <= Source_Ray->Index; i++)
- {
- Dest_Ray->Interiors[i] = Source_Ray->Interiors[i];
- }
- }
- /*****************************************************************************
- *
- * FUNCTION
- *
- * Ray_Enter
- *
- * INPUT
- *
- * OUTPUT
- *
- * RETURNS
- *
- * AUTHOR
- *
- * POV-Ray Team
- *
- * DESCRIPTION
- *
- * -
- *
- * CHANGES
- *
- * Oct 1995 : Fixed bug with IOR assignment (only valid for plain textures) [DB]
- *
- ******************************************************************************/
- void Ray_Enter(RAY *Ray, INTERIOR *interior)
- {
- int index;
- if ((index = ++(Ray->Index)) >= MAX_CONTAINING_OBJECTS)
- {
- Error("Too many nested refracting objects.");
- }
- Ray->Interiors[index] = interior;
- }
- /*****************************************************************************
- *
- * FUNCTION
- *
- * Ray_Exit
- *
- * INPUT
- *
- * OUTPUT
- *
- * RETURNS
- *
- * AUTHOR
- *
- * POV-Ray Team
- *
- * DESCRIPTION
- *
- * Remove given entry from given ray's container.
- *
- * CHANGES
- *
- * -
- *
- ******************************************************************************/
- void Ray_Exit(RAY *Ray, int nr)
- {
- int i;
- for (i = nr; i < Ray->Index; i++)
- {
- Ray->Interiors[i] = Ray->Interiors[i+1];
- }
- if (--(Ray->Index) < - 1)
- {
- Error("Too many exits from refractions.");
- }
- }
- /*****************************************************************************
- *
- * FUNCTION
- *
- * Interior_In_Ray_Container
- *
- * INPUT
- *
- * OUTPUT
- *
- * RETURNS
- *
- * AUTHOR
- *
- * Dieter Bayer
- *
- * DESCRIPTION
- *
- * Test if a given interior is in the container of a given ray.
- *
- * CHANGES
- *
- * Mar 1996 : Creation.
- *
- ******************************************************************************/
- int Interior_In_Ray_Container(RAY *ray, INTERIOR *interior)
- {
- int i, found = -1;
- if (ray->Index > -1)
- {
- for (i = 0; i <= ray->Index; i++)
- {
- if (interior == ray->Interiors[i])
- {
- found = i;
- break;
- }
- }
- }
- return(found);
- }
|