Add renderstat to get some info about rendering.
This commit is contained in:
@@ -11,13 +11,21 @@
|
||||
#include <intersect.h>
|
||||
|
||||
#include <float.h>
|
||||
#include <renderstat.h>
|
||||
|
||||
#define MIN_ALLOC (2)
|
||||
|
||||
/* TODO: Memory allocation, even if using standard calloc/realloc have a huge impact on performances. need to find a way
|
||||
* to reuse the intersect object without reallocating from scratch all the time. We use a lot of Intersect objects as
|
||||
* there is at least 2 per ray (one for Ray intersect object, one object per light)
|
||||
*/
|
||||
|
||||
Intersect::Intersect()
|
||||
{
|
||||
this->allocated = MIN_ALLOC;
|
||||
this->list = (Intersection **)calloc(sizeof(Intersection *), MIN_ALLOC);
|
||||
stats.addMalloc();
|
||||
stats.addIntersect();
|
||||
this->num = 0;
|
||||
}
|
||||
|
||||
@@ -35,10 +43,13 @@ void Intersect::add(Intersection i)
|
||||
if ((this->num + 1) > this->allocated)
|
||||
{
|
||||
this->allocated *= 2;
|
||||
stats.addRealloc();
|
||||
this->list = (Intersection **)realloc(this->list, sizeof(Intersection *) * this->allocated);
|
||||
}
|
||||
this->list[this->num++] = new Intersection(i.t, i.object);
|
||||
|
||||
stats.setMaxIntersect(this->num);
|
||||
|
||||
/* Now sort.. */
|
||||
for(j = 1; j < (this->num); j++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user