OBJFile now use group instead of it own list.
Change the group function to find group by name, and now name group when needed, and change tests to use group name instead of number. Also now the default group is the base group, not a separate group. Bonus: Add a destructor to cleanup memory Added a function to get base group. OBJFile will still behave as a valid shape, but now we can skip it in the generated world by adding the base group instead. Code is now cleaner.
This commit is contained in:
@@ -18,9 +18,9 @@
|
||||
class OBJFile : public Shape
|
||||
{
|
||||
private:
|
||||
uint32_t allocatedFaceGroupCount;
|
||||
Group* *faceGroupList;
|
||||
uint32_t faceGroupCount;
|
||||
Group *baseGroup;
|
||||
|
||||
Group *currentGroup;
|
||||
|
||||
uint32_t allocatedVertexCount;
|
||||
Point* *vertexList;
|
||||
@@ -51,16 +51,20 @@ public:
|
||||
OBJFile();
|
||||
OBJFile(const char *filepath);
|
||||
|
||||
~OBJFile();
|
||||
|
||||
int parseOBJFile(const char *content);
|
||||
|
||||
/* OBJ file expect the first vertice to be 1 and not 0 */
|
||||
Point vertices(uint32_t i) { return *this->vertexList[i - 1]; };
|
||||
Vector verticesNormal(uint32_t i) { return *this->vertexNormalList[i - 1]; };
|
||||
Group *groups(uint32_t i) { return this->faceGroupList[i]; };
|
||||
Group *groups(const char *groupName);
|
||||
Intersect intersect(Ray r);
|
||||
BoundingBox getLocalBounds();
|
||||
BoundingBox getBounds();
|
||||
|
||||
Shape *getBaseGroup() { return this->baseGroup; };
|
||||
|
||||
bool includes(Shape *b);
|
||||
|
||||
void updateBoundingBox();
|
||||
@@ -69,4 +73,6 @@ public:
|
||||
void dumpMe(FILE * fp);
|
||||
};
|
||||
|
||||
#define OBJ_DEFAULT_GROUP "_DefaultObjGroup_"
|
||||
|
||||
#endif /* DORAYME_OBJFILE_H */
|
||||
|
||||
Reference in New Issue
Block a user