Skip to content

Commit ecfec15

Browse files
committed
Releasing old TLAS. Fixed a bug where some vertices in ShapeNet are missing texcoords, and were indexing out of bounds
1 parent f8ce615 commit ecfec15

2 files changed

Lines changed: 23 additions & 11 deletions

File tree

src/visii/mesh.cpp

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -588,18 +588,28 @@ void Mesh::loadObj(std::string objPath)
588588
}
589589
if (attrib.normals.size() != 0)
590590
{
591-
vertex.normal = {
592-
attrib.normals[3 * index.normal_index + 0],
593-
attrib.normals[3 * index.normal_index + 1],
594-
attrib.normals[3 * index.normal_index + 2],
595-
0.0f};
596-
has_normals = true;
591+
if (index.normal_index == -1) {
592+
vertex.normal = {0.f, 0.f, 0.f, 0.f};
593+
}
594+
else {
595+
vertex.normal = {
596+
attrib.normals[3 * index.normal_index + 0],
597+
attrib.normals[3 * index.normal_index + 1],
598+
attrib.normals[3 * index.normal_index + 2],
599+
0.0f};
600+
has_normals = true;
601+
}
597602
}
598603
if (attrib.texcoords.size() != 0)
599604
{
600-
vertex.texcoord = {
601-
attrib.texcoords[2 * index.texcoord_index + 0],
602-
attrib.texcoords[2 * index.texcoord_index + 1]};
605+
if (index.texcoord_index == -1) {
606+
vertex.texcoord = {0.f, 0.f};
607+
}
608+
else {
609+
vertex.texcoord = {
610+
attrib.texcoords[2 * index.texcoord_index + 0],
611+
attrib.texcoords[2 * index.texcoord_index + 1]};
612+
}
603613
}
604614
vertices.push_back(vertex);
605615
}

src/visii/visii.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static struct OptixData {
9595
OWLMissProg missProg;
9696
OWLGeomType trianglesGeomType;
9797
MeshData meshes[MAX_MESHES];
98-
OWLGroup tlas;
98+
OWLGroup tlas = nullptr;
9999

100100
std::vector<uint32_t> lightEntities;
101101

@@ -815,7 +815,7 @@ void updateComponents()
815815

816816
std::vector<owl4x3f> t0Transforms;
817817
std::vector<owl4x3f> t1Transforms;
818-
if (OD.tlas) {owlGroupRelease(OD.tlas); OD.tlas = nullptr;}
818+
auto oldTLAS = OD.tlas;
819819
// not sure why, but if I release this TLAS, I get the following error
820820
// python3d: /home/runner/work/ViSII/ViSII/externals/owl/owl/ObjectRegistry.cpp:83:
821821
// owl::RegisteredObject* owl::ObjectRegistry::getPtr(int): Assertion `objects[ID]' failed.
@@ -848,6 +848,8 @@ void updateComponents()
848848
groupBuildAccel(OD.tlas);
849849
launchParamsSetGroup(OD.launchParams, "world", OD.tlas);
850850
buildSBT(OD.context);
851+
852+
if (oldTLAS) {owlGroupRelease(oldTLAS);}
851853

852854
OD.lightEntities.resize(0);
853855
for (uint32_t eid = 0; eid < Entity::getCount(); ++eid) {

0 commit comments

Comments
 (0)