summaryrefslogtreecommitdiff
path: root/Extras
diff options
context:
space:
mode:
authorChuyuan Fu <fuchuyuan.kelly@gmail.com>2020-01-30 19:58:21 -0800
committerChuyuan Fu <fuchuyuan.kelly@gmail.com>2020-01-30 19:58:21 -0800
commit1efe8209ac3bae98a349c3469dd1f6871ed6303e (patch)
tree35e42836cc587cebaf7a53629d9eaaf9c15a2131 /Extras
parente76ebe86d9aedc0919d9dfacc4ce9cab876b55b9 (diff)
downloadbullet3-1efe8209ac3bae98a349c3469dd1f6871ed6303e.tar.gz
fix obj2sdf mergeMaterial
Diffstat (limited to 'Extras')
-rw-r--r--Extras/obj2sdf/obj2sdf.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/Extras/obj2sdf/obj2sdf.cpp b/Extras/obj2sdf/obj2sdf.cpp
index 720bcf18e..2237c53f1 100644
--- a/Extras/obj2sdf/obj2sdf.cpp
+++ b/Extras/obj2sdf/obj2sdf.cpp
@@ -16,6 +16,8 @@
#include "Bullet3Common/b3HashMap.h"
#include "../Utils/b3BulletDefaultFileIO.h"
+using tinyobj::index_t;
+
struct ShapeContainer
{
std::string m_matName;
@@ -24,8 +26,7 @@ struct ShapeContainer
std::vector<float> positions;
std::vector<float> normals;
std::vector<float> texcoords;
- std::vector<unsigned int> indices;
-
+ std::vector<index_t> indices;
b3AlignedObjectArray<int> m_shapeIndices;
};
@@ -141,9 +142,14 @@ int main(int argc, char* argv[])
continue;
}
- shapeC->indices.push_back(shape.mesh.indices[face].vertex_index + curPositions);
- shapeC->indices.push_back(shape.mesh.indices[face + 1].vertex_index + curPositions);
- shapeC->indices.push_back(shape.mesh.indices[face + 2].vertex_index + curPositions);
+ index_t index;
+ for (int ii = 0; ii < 3; ii++)
+ {
+ index.vertex_index = shape.mesh.indices[face + ii].vertex_index + curPositions;
+ index.normal_index = shape.mesh.indices[face + ii].normal_index + curNormals;
+ index.texcoord_index = shape.mesh.indices[face + ii].texcoord_index + curTexcoords;
+ shapeC->indices.push_back(index);
+ }
}
}
}
@@ -237,9 +243,9 @@ int main(int argc, char* argv[])
continue;
}
fprintf(f, "f %d/%d/%d %d/%d/%d %d/%d/%d\n",
- shapeCon->indices[face] + 1, shapeCon->indices[face] + 1, shapeCon->indices[face] + 1,
- shapeCon->indices[face + 1] + 1, shapeCon->indices[face + 1] + 1, shapeCon->indices[face + 1] + 1,
- shapeCon->indices[face + 2] + 1, shapeCon->indices[face + 2] + 1, shapeCon->indices[face + 2] + 1);
+ shapeCon->indices[face].vertex_index + 1, shapeCon->indices[face].texcoord_index + 1, shapeCon->indices[face].normal_index + 1,
+ shapeCon->indices[face + 1].vertex_index + 1, shapeCon->indices[face + 1].texcoord_index + 1, shapeCon->indices[face + 1].normal_index + 1,
+ shapeCon->indices[face + 2].vertex_index + 1, shapeCon->indices[face + 2].texcoord_index + 1, shapeCon->indices[face + 2].normal_index + 1);
}
fclose(f);