From 7a48ecd394f7b3b8f0f6e18606f681ffac3e3a7c Mon Sep 17 00:00:00 2001 From: Julian T Date: Wed, 25 Mar 2020 18:53:37 +0100 Subject: Create new fitting scene to test area lights --- scene.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'scene.c') diff --git a/scene.c b/scene.c index 6221fe8..730d8c8 100644 --- a/scene.c +++ b/scene.c @@ -116,7 +116,7 @@ material_t *add_material(container_t *cont) return m; } -void obj_norm_at(object_t *o, vector_t *dest, vector_t *point) +void obj_norm_at(object_t *o, vector_t *dest, vector_t *point, vector_t *direction) { switch(o->type) { case TYPE_SPHERE: @@ -124,7 +124,8 @@ void obj_norm_at(object_t *o, vector_t *dest, vector_t *point) vector_scale_inv(dest, dest, vector_len(dest)); break; case TYPE_PLANE: - vector_copy(dest, &o->pl.norm); + // Calculate if the point is in front + vector_scale(dest, &o->pl.norm, (vector_dot(direction, &o->pl.norm) > 0) ? -1 : 1); break; } -- cgit v1.2.3