/* shadowcaching.c: shadow caching routines */ #include "shadowcaching.h" #include "patch.h" #include "grid.h" #include "scene.h" /* for statistics */ int ShadowRays=0, ShadowCacheHits=0; #define MAXCACHE 5 /* cache at most 5 blocking patches */ static PATCH *cache[MAXCACHE]; static int cachedpatches, ncached; /* initialize/empty the shadow cache */ void InitShadowCache(void) { int i; ncached = cachedpatches = 0; for (i=0; ipatch); } return hit; } /* like ShadowTestDiscretisation, except that a list of PATCHes is tested * for intersection. */ HITREC *ShadowTestPatchlist(RAY *ray, PATCHLIST *ShadowList, float dist, HITREC *hitstore) { HITREC *hit=NULL; ShadowRays++; if ((hit = CacheHit(ray, &dist, hitstore))) ShadowCacheHits++; else if ((hit = PatchListIntersect(ShadowList, ray, EPSILON*dist, &dist, HIT_FRONT|HIT_ANY, hitstore))) AddToShadowCache(hit->patch); return hit; }