Skip to content

Commit

Permalink
Releasing old TLAS. Fixed a bug where some vertices in ShapeNet are m…
Browse files Browse the repository at this point in the history
…issing texcoords, and were indexing out of bounds
  • Loading branch information
natevm committed Jul 22, 2020
1 parent f8ce615 commit ecfec15
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
28 changes: 19 additions & 9 deletions src/visii/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,18 +588,28 @@ void Mesh::loadObj(std::string objPath)
}
if (attrib.normals.size() != 0)
{
vertex.normal = {
attrib.normals[3 * index.normal_index + 0],
attrib.normals[3 * index.normal_index + 1],
attrib.normals[3 * index.normal_index + 2],
0.0f};
has_normals = true;
if (index.normal_index == -1) {
vertex.normal = {0.f, 0.f, 0.f, 0.f};
}
else {
vertex.normal = {
attrib.normals[3 * index.normal_index + 0],
attrib.normals[3 * index.normal_index + 1],
attrib.normals[3 * index.normal_index + 2],
0.0f};
has_normals = true;
}
}
if (attrib.texcoords.size() != 0)
{
vertex.texcoord = {
attrib.texcoords[2 * index.texcoord_index + 0],
attrib.texcoords[2 * index.texcoord_index + 1]};
if (index.texcoord_index == -1) {
vertex.texcoord = {0.f, 0.f};
}
else {
vertex.texcoord = {
attrib.texcoords[2 * index.texcoord_index + 0],
attrib.texcoords[2 * index.texcoord_index + 1]};
}
}
vertices.push_back(vertex);
}
Expand Down
6 changes: 4 additions & 2 deletions src/visii/visii.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static struct OptixData {
OWLMissProg missProg;
OWLGeomType trianglesGeomType;
MeshData meshes[MAX_MESHES];
OWLGroup tlas;
OWLGroup tlas = nullptr;

std::vector<uint32_t> lightEntities;

Expand Down Expand Up @@ -815,7 +815,7 @@ void updateComponents()

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

if (oldTLAS) {owlGroupRelease(oldTLAS);}

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

0 comments on commit ecfec15

Please sign in to comment.