diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-07-15 15:18:30 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-07-15 15:23:35 +0300 |
commit | e8f8c13d4b76ba587ef7cf33370b286d4fbd36bc (patch) | |
tree | 371472ae220ad8740b310aaa8f4c5746448302c5 /extern/mantaflow/preprocessed/fileio/iomeshes.cpp | |
parent | 0c062a9e082130212447c2b67e8e16b8a2e622d1 (diff) | |
parent | 44bb73e765a6f79bc14a46449368f83e572d8bad (diff) |
PointCloud: Initial rendering support for Workbenchtmp-pointcloud-render
Also includes outline overlays. Removes the temp overlay drawing
We make the geometry follow camera like billboards this uses less
geometry. Currently we use half octahedron for now. Goal would be
to use icospheres.
This patch also optimize the case when pointcloud has uniform radius.
However we should premultiply the radius prop by the default radius
beforehand to avoid a multiplication on CPU.
Differential Revision: https://developer.blender.org/D8301
Diffstat (limited to 'extern/mantaflow/preprocessed/fileio/iomeshes.cpp')
-rw-r--r-- | extern/mantaflow/preprocessed/fileio/iomeshes.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/extern/mantaflow/preprocessed/fileio/iomeshes.cpp b/extern/mantaflow/preprocessed/fileio/iomeshes.cpp index 1c50376de77..b5e51625077 100644 --- a/extern/mantaflow/preprocessed/fileio/iomeshes.cpp +++ b/extern/mantaflow/preprocessed/fileio/iomeshes.cpp @@ -315,10 +315,14 @@ int readObjFile(const std::string &name, Mesh *mesh, bool append) return 0; } + const Real dx = mesh->getParent()->getDx(); + const Vec3 gs = toVec3(mesh->getParent()->getGridSize()); + if (!append) mesh->clear(); int nodebase = mesh->numNodes(); - int cnt = nodebase; + int cntNodes = nodebase, cntNormals = nodebase; + while (ifs.good() && !ifs.eof()) { string id; ifs >> id; @@ -333,19 +337,23 @@ int readObjFile(const std::string &name, Mesh *mesh, bool append) } else if (id == "vn") { // normals - if (!mesh->numNodes()) { + if (mesh->numNodes() != cntNodes) { errMsg("invalid amount of nodes"); return 0; } - Node n = mesh->nodes(cnt); - ifs >> n.normal.x >> n.normal.y >> n.normal.z; - cnt++; + Node *n = &mesh->nodes(cntNormals); + ifs >> n->normal.x >> n->normal.y >> n->normal.z; + cntNormals++; } else if (id == "v") { // vertex Node n; ifs >> n.pos.x >> n.pos.y >> n.pos.z; + // convert to grid space + n.pos /= dx; + n.pos += gs * 0.5; mesh->addNode(n); + cntNodes++; } else if (id == "g") { // group @@ -408,7 +416,6 @@ int writeObjFile(const string &name, Mesh *mesh) // write normals for (int i = 0; i < numVerts; i++) { Vector3D<float> n = toVec3f(mesh->nodes(i).normal); - // normalize to unit cube around 0 ofs << "vn " << n.value[0] << " " << n.value[1] << " " << n.value[2] << " " << "\n"; } |