Changeset View
Changeset View
Standalone View
Standalone View
extern/draco/draco/src/draco/mesh/mesh_misc_functions.cc
- This file was moved from extern/draco/dracoenc/src/draco/mesh/mesh_misc_functions.cc.
| Show All 12 Lines | |||||
| // limitations under the License. | // limitations under the License. | ||||
| // | // | ||||
| #include "draco/mesh/mesh_misc_functions.h" | #include "draco/mesh/mesh_misc_functions.h" | ||||
| namespace draco { | namespace draco { | ||||
| std::unique_ptr<CornerTable> CreateCornerTableFromPositionAttribute( | std::unique_ptr<CornerTable> CreateCornerTableFromPositionAttribute( | ||||
| const Mesh *mesh) { | const Mesh *mesh) { | ||||
| return CreateCornerTableFromAttribute(mesh, GeometryAttribute::POSITION); | |||||
| } | |||||
| std::unique_ptr<CornerTable> CreateCornerTableFromAttribute( | |||||
| const Mesh *mesh, GeometryAttribute::Type type) { | |||||
| typedef CornerTable::FaceType FaceType; | typedef CornerTable::FaceType FaceType; | ||||
| const PointAttribute *const att = | const PointAttribute *const att = mesh->GetNamedAttribute(type); | ||||
| mesh->GetNamedAttribute(GeometryAttribute::POSITION); | if (att == nullptr) { | ||||
| if (att == nullptr) | |||||
| return nullptr; | return nullptr; | ||||
| } | |||||
| IndexTypeVector<FaceIndex, FaceType> faces(mesh->num_faces()); | IndexTypeVector<FaceIndex, FaceType> faces(mesh->num_faces()); | ||||
| FaceType new_face; | FaceType new_face; | ||||
| for (FaceIndex i(0); i < mesh->num_faces(); ++i) { | for (FaceIndex i(0); i < mesh->num_faces(); ++i) { | ||||
| const Mesh::Face &face = mesh->face(i); | const Mesh::Face &face = mesh->face(i); | ||||
| for (int j = 0; j < 3; ++j) { | for (int j = 0; j < 3; ++j) { | ||||
| // Map general vertex indices to position indices. | // Map general vertex indices to attribute indices. | ||||
| new_face[j] = att->mapped_index(face[j]).value(); | new_face[j] = att->mapped_index(face[j]).value(); | ||||
| } | } | ||||
| faces[FaceIndex(i)] = new_face; | faces[FaceIndex(i)] = new_face; | ||||
| } | } | ||||
| // Build the corner table. | // Build the corner table. | ||||
| return CornerTable::Create(faces); | return CornerTable::Create(faces); | ||||
| } | } | ||||
| Show All 18 Lines | |||||