diff --git a/bsp.h b/bsp.h index d75b54e..32014ed 100644 --- a/bsp.h +++ b/bsp.h @@ -151,9 +151,9 @@ typedef struct { long plane_id; // The plane that splits the node // must be in [0,numplanes[ - unsigned short front; // If bit15==0, index of Front child node + short front; // If bit15==0, index of Front child node // If bit15==1, ~front = index of child leaf - unsigned short back; // If bit15==0, id of Back child node + short back; // If bit15==0, id of Back child node // If bit15==1, ~back = id of child leaf bboxshort_t box; // Bounding box of node and all childs unsigned short face_id; // Index of first Polygons in the node diff --git a/main.cpp b/main.cpp index b6300f4..4f7db64 100644 --- a/main.cpp +++ b/main.cpp @@ -408,6 +408,9 @@ int process_faces(const world_t* world) outNode.front = node->front; outNode.back = node->back; + outNode.firstFace = node->face_id; + outNode.numFaces = node->face_num; + outNodes.push_back(outNode); } @@ -427,6 +430,7 @@ int process_faces(const world_t* world) } std::vector outLeafFaces(world->faceList, world->faceList + world->faceListLength); + std::vector outVisData(world->visList, world->visList + world->visListLength); // Write collected data to file and update header info writeMapData(outVertices, outHeader.vertices, fbsp); @@ -436,6 +440,7 @@ int process_faces(const world_t* world) writeMapData(outNodes, outHeader.nodes, fbsp); writeMapData(outLeaves, outHeader.leaves, fbsp); writeMapData(outLeafFaces, outHeader.leafFaces, fbsp); + writeMapData(outVisData, outHeader.visData, fbsp); // Write final header fseek(fbsp, 0, SEEK_SET); diff --git a/ps1bsp.h b/ps1bsp.h index fce5011..7629566 100644 --- a/ps1bsp.h +++ b/ps1bsp.h @@ -35,6 +35,7 @@ typedef struct ps1bsp_dentry_t nodes; ps1bsp_dentry_t leaves; ps1bsp_dentry_t leafFaces; + ps1bsp_dentry_t visData; } ps1bsp_header_t; typedef struct @@ -85,10 +86,13 @@ typedef struct typedef struct { int planeId; - u_short front; - u_short back; + short front; + short back; + // TODO: add bounding box for frustum culling - // TODO: not sure if face list is needed here + + u_short firstFace; + u_short numFaces; } ps1bsp_node_t; typedef struct