Skip to content

Commit

Permalink
[#4] Fix issue when instance bounding box was calculated incorrectly.
Browse files Browse the repository at this point in the history
  • Loading branch information
Morozov-5F committed Nov 28, 2021
1 parent 203f0b5 commit cae29a6
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions hittables/rt_instance.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ static bool rt_instance_bb(const rt_hittable_t *hittable, double time0, double t
return false;
}

hittable_bb = rt_aabb(vec3_sum(hittable_bb.min, instance->offset), vec3_sum(hittable_bb.max, instance->offset));

vec3_t min = hittable_bb.min, max = hittable_bb.max;
for (int i = 0; i < 2; i++)
{
Expand All @@ -119,7 +117,6 @@ static bool rt_instance_bb(const rt_hittable_t *hittable, double time0, double t
k * hittable_bb.max.z + (1 - k) * hittable_bb.min.z);

vec3_t tester = rt_mat3_mul_vec3(&instance->transform_matrix_bb, &point);

for (int c = 0; c < 3; c++)
{
min.components[c] = fmin(min.components[c], tester.components[c]);
Expand All @@ -128,8 +125,7 @@ static bool rt_instance_bb(const rt_hittable_t *hittable, double time0, double t
}
}
}

*out_bb = rt_aabb(min, max);
*out_bb = rt_aabb(vec3_sum(min, instance->offset), vec3_sum(max, instance->offset));

return true;
}
Expand Down

0 comments on commit cae29a6

Please sign in to comment.