diff options
Diffstat (limited to 'src/renderergl2/tr_light.c')
-rw-r--r-- | src/renderergl2/tr_light.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/renderergl2/tr_light.c b/src/renderergl2/tr_light.c index 82e088e8..ba493198 100644 --- a/src/renderergl2/tr_light.c +++ b/src/renderergl2/tr_light.c @@ -450,3 +450,32 @@ int R_LightDirForPoint( vec3_t point, vec3_t lightDir, vec3_t normal, world_t *w return qtrue; } + + +int R_CubemapForPoint( vec3_t point ) +{ + int cubemapIndex = -1; + + if (r_cubeMapping->integer && tr.numCubemaps) + { + int i; + vec_t shortest = (float)WORLD_SIZE * (float)WORLD_SIZE; + + for (i = 0; i < tr.numCubemaps; i++) + { + vec3_t diff; + vec_t length; + + VectorSubtract(point, tr.cubemapOrigins[i], diff); + length = DotProduct(diff, diff); + + if (shortest > length) + { + shortest = length; + cubemapIndex = i; + } + } + } + + return cubemapIndex + 1; +} |