Changeset View
Changeset View
Standalone View
Standalone View
extern/draco/draco/src/draco/mesh/mesh_cleanup.cc
- This file was moved from extern/draco/dracoenc/src/draco/mesh/mesh_cleanup.cc.
| Show All 11 Lines | |||||
| // See the License for the specific language governing permissions and | // See the License for the specific language governing permissions and | ||||
| // limitations under the License. | // limitations under the License. | ||||
| // | // | ||||
| #include "draco/mesh/mesh_cleanup.h" | #include "draco/mesh/mesh_cleanup.h" | ||||
| namespace draco { | namespace draco { | ||||
| bool MeshCleanup::operator()(Mesh *mesh, const MeshCleanupOptions &options) { | bool MeshCleanup::operator()(Mesh *mesh, const MeshCleanupOptions &options) { | ||||
| if (!options.remove_degenerated_faces && !options.remove_unused_attributes) | if (!options.remove_degenerated_faces && !options.remove_unused_attributes) { | ||||
| return true; // Nothing to cleanup. | return true; // Nothing to cleanup. | ||||
| } | |||||
| const PointAttribute *const pos_att = | const PointAttribute *const pos_att = | ||||
| mesh->GetNamedAttribute(GeometryAttribute::POSITION); | mesh->GetNamedAttribute(GeometryAttribute::POSITION); | ||||
| if (pos_att == nullptr) | if (pos_att == nullptr) { | ||||
| return false; | return false; | ||||
| } | |||||
| // Array that is going to store whether a corresponding point is used. | // Array that is going to store whether a corresponding point is used. | ||||
| std::vector<bool> is_point_used; | std::vector<bool> is_point_used; | ||||
| if (options.remove_unused_attributes) { | if (options.remove_unused_attributes) { | ||||
| is_point_used.resize(mesh->num_points(), false); | is_point_used.resize(mesh->num_points(), false); | ||||
| } | } | ||||
| FaceIndex::ValueType num_degenerated_faces = 0; | FaceIndex::ValueType num_degenerated_faces = 0; | ||||
| PointIndex::ValueType num_new_points = 0; | PointIndex::ValueType num_new_points = 0; | ||||
| ▲ Show 20 Lines • Show All 122 Lines • ▼ Show 20 Lines | for (int a = 0; a < mesh->num_attributes(); ++a) { | ||||
| } | } | ||||
| } | } | ||||
| if (!att->is_mapping_identity()) { | if (!att->is_mapping_identity()) { | ||||
| // Explicit mapping between points and local attribute indices. | // Explicit mapping between points and local attribute indices. | ||||
| for (PointIndex i(0); i < num_original_points; ++i) { | for (PointIndex i(0); i < num_original_points; ++i) { | ||||
| // The new point id that maps to the currently processed attribute | // The new point id that maps to the currently processed attribute | ||||
| // entry. | // entry. | ||||
| const PointIndex new_point_id = point_map[i]; | const PointIndex new_point_id = point_map[i]; | ||||
| if (new_point_id == kInvalidPointIndex) | if (new_point_id == kInvalidPointIndex) { | ||||
| continue; | continue; | ||||
| } | |||||
| // Index of the currently processed attribute entry in the original | // Index of the currently processed attribute entry in the original | ||||
| // mesh. | // mesh. | ||||
| const AttributeValueIndex original_entry_index = | const AttributeValueIndex original_entry_index = | ||||
| att->mapped_index(i); | att->mapped_index(i); | ||||
| // New index of the same entry after unused entries were removed. | // New index of the same entry after unused entries were removed. | ||||
| const AttributeValueIndex new_entry_index = | const AttributeValueIndex new_entry_index = | ||||
| att_index_map[original_entry_index]; | att_index_map[original_entry_index]; | ||||
| att->SetPointMapEntry(new_point_id, new_entry_index); | att->SetPointMapEntry(new_point_id, new_entry_index); | ||||
| Show All 12 Lines | |||||