Add support for naming groups

This commit is contained in:
Godzil
2020-03-09 15:58:32 +00:00
parent 8437ab8753
commit 314da11005
2 changed files with 12 additions and 0 deletions

View File

@@ -11,6 +11,7 @@
#include <group.h>
#include <math_helper.h>
#include <renderstat.h>
#include <string.h>
#define MIN_ALLOC (2)
@@ -25,6 +26,14 @@ Group::Group(const char *name) : Shape(Shape::GROUP)
this->unboxableObjectList = (Shape **)calloc(sizeof(Shape **), MIN_ALLOC);
this->unboxableObjectCount = 0;
if (name != nullptr)
{
strncpy(this->name, name, 32);
}
else
{
strncpy(this->name, "untitled", 32);
}
}
Intersect Group::intersect(Ray r)
@@ -204,6 +213,7 @@ void Group::dumpMe(FILE *fp)
{
int i;
fprintf(fp, "\"Type\": \"Group\",\n");
fprintf(fp, "\"Name\": \"%s\",\n", this->name);
if (this->objectCount > 0)
{
fprintf(fp, "\"Objects\": {\n");