Simple test for asyncio.library.
[AROS-Contrib.git] / gfx / povray / ray.c
blob0ba646feb3c12b00a712501b007c4dfe0f731679
1 /****************************************************************************
2 * ray.c
4 * This module implements the code pertaining to rays.
6 * from Persistence of Vision(tm) Ray Tracer
7 * Copyright 1996,1999 Persistence of Vision Team
8 *---------------------------------------------------------------------------
9 * NOTICE: This source code file is provided so that users may experiment
10 * with enhancements to POV-Ray and to port the software to platforms other
11 * than those supported by the POV-Ray Team. There are strict rules under
12 * which you are permitted to use this file. The rules are in the file
13 * named POVLEGAL.DOC which should be distributed with this file.
14 * If POVLEGAL.DOC is not available or for more info please contact the POV-Ray
15 * Team Coordinator by email to team-coord@povray.org or visit us on the web at
16 * http://www.povray.org. The latest version of POV-Ray may be found at this site.
18 * This program is based on the popular DKB raytracer version 2.12.
19 * DKBTrace was originally written by David K. Buck.
20 * DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
22 *****************************************************************************/
24 #include "frame.h"
25 #include "vector.h"
26 #include "povproto.h"
27 #include "povray.h"
28 #include "interior.h"
29 #include "ray.h"
30 #include "texture.h"
34 /*****************************************************************************
35 * Local preprocessor defines
36 ******************************************************************************/
40 /*****************************************************************************
41 * Local typedefs
42 ******************************************************************************/
46 /*****************************************************************************
47 * Local variables
48 ******************************************************************************/
52 /*****************************************************************************
53 * Static functions
54 ******************************************************************************/
58 /*****************************************************************************
60 * FUNCTION
62 * Initialize_Ray_Containers
64 * INPUT
66 * OUTPUT
68 * RETURNS
70 * AUTHOR
72 * POV-Ray Team
74 * DESCRIPTION
76 * -
78 * CHANGES
80 * -
82 ******************************************************************************/
84 void Initialize_Ray_Containers(RAY *Ray)
86 Ray->Index = - 1;
91 /*****************************************************************************
93 * FUNCTION
95 * Copy_Ray_Containers
97 * INPUT
99 * OUTPUT
101 * RETURNS
103 * AUTHOR
105 * POV-Ray Team
107 * DESCRIPTION
111 * CHANGES
115 ******************************************************************************/
117 void Copy_Ray_Containers(RAY *Dest_Ray, RAY *Source_Ray)
119 register int i;
121 if ((Dest_Ray->Index = Source_Ray->Index) >= MAX_CONTAINING_OBJECTS)
123 Error("ERROR - Containing Index too high.\n");
126 for (i = 0 ; i <= Source_Ray->Index; i++)
128 Dest_Ray->Interiors[i] = Source_Ray->Interiors[i];
134 /*****************************************************************************
136 * FUNCTION
138 * Ray_Enter
140 * INPUT
142 * OUTPUT
144 * RETURNS
146 * AUTHOR
148 * POV-Ray Team
150 * DESCRIPTION
154 * CHANGES
156 * Oct 1995 : Fixed bug with IOR assignment (only valid for plain textures) [DB]
158 ******************************************************************************/
160 void Ray_Enter(RAY *Ray, INTERIOR *interior)
162 int index;
164 if ((index = ++(Ray->Index)) >= MAX_CONTAINING_OBJECTS)
166 Error("Too many nested refracting objects.");
169 Ray->Interiors[index] = interior;
174 /*****************************************************************************
176 * FUNCTION
178 * Ray_Exit
180 * INPUT
182 * OUTPUT
184 * RETURNS
186 * AUTHOR
188 * POV-Ray Team
190 * DESCRIPTION
192 * Remove given entry from given ray's container.
194 * CHANGES
198 ******************************************************************************/
200 void Ray_Exit(RAY *Ray, int nr)
202 int i;
204 for (i = nr; i < Ray->Index; i++)
206 Ray->Interiors[i] = Ray->Interiors[i+1];
209 if (--(Ray->Index) < - 1)
211 Error("Too many exits from refractions.");
217 /*****************************************************************************
219 * FUNCTION
221 * Interior_In_Ray_Container
223 * INPUT
225 * OUTPUT
227 * RETURNS
229 * AUTHOR
231 * Dieter Bayer
233 * DESCRIPTION
235 * Test if a given interior is in the container of a given ray.
237 * CHANGES
239 * Mar 1996 : Creation.
241 ******************************************************************************/
243 int Interior_In_Ray_Container(RAY *ray, INTERIOR *interior)
245 int i, found = -1;
247 if (ray->Index > -1)
249 for (i = 0; i <= ray->Index; i++)
251 if (interior == ray->Interiors[i])
253 found = i;
255 break;
260 return(found);