Free intersection t values array after use.
This commit is contained in:
parent
99055ff5f4
commit
8b828e45a8
1 changed files with 7 additions and 4 deletions
|
@ -157,12 +157,15 @@ scene_trace_ray(Scene *scene, const Ray ray, const int depth)
|
||||||
ObjectList *ptr = scene->objects;
|
ObjectList *ptr = scene->objects;
|
||||||
while (ptr != NULL) {
|
while (ptr != NULL) {
|
||||||
nints = object_does_intersect(ptr->object, ray, &t);
|
nints = object_does_intersect(ptr->object, ray, &t);
|
||||||
|
if (nints > 0) {
|
||||||
for (int i = 0; i < nints; i++) {
|
for (int i = 0; i < nints; i++) {
|
||||||
if (t[i] < nearest_t) {
|
if (t[i] < nearest_t) {
|
||||||
intersected_obj = ptr->object;
|
intersected_obj = ptr->object;
|
||||||
nearest_t = t[i];
|
nearest_t = t[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
free(t);
|
||||||
|
}
|
||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue