Differential D9642 Diff 31337 extern/draco/draco/src/draco/compression/mesh/traverser/max_prediction_degree_traverser.h
Changeset View
Changeset View
Standalone View
Standalone View
extern/draco/draco/src/draco/compression/mesh/traverser/max_prediction_degree_traverser.h
- This file was moved from extern/draco/dracoenc/src/draco/compression/mesh/traverser/max_prediction_degree_traverser.h.
| Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | public: | ||||
| void OnTraversalStart() { | void OnTraversalStart() { | ||||
| prediction_degree_.resize(this->corner_table()->num_vertices(), 0); | prediction_degree_.resize(this->corner_table()->num_vertices(), 0); | ||||
| } | } | ||||
| // Called when all the traversing is done. | // Called when all the traversing is done. | ||||
| void OnTraversalEnd() {} | void OnTraversalEnd() {} | ||||
| bool TraverseFromCorner(CornerIndex corner_id) { | bool TraverseFromCorner(CornerIndex corner_id) { | ||||
| if (prediction_degree_.size() == 0) | if (prediction_degree_.size() == 0) { | ||||
| return true; | return true; | ||||
| } | |||||
| // Traversal starts from the |corner_id|. It's going to follow either the | // Traversal starts from the |corner_id|. It's going to follow either the | ||||
| // right or the left neighboring faces to |corner_id| based on their | // right or the left neighboring faces to |corner_id| based on their | ||||
| // prediction degree. | // prediction degree. | ||||
| traversal_stacks_[0].push_back(corner_id); | traversal_stacks_[0].push_back(corner_id); | ||||
| best_priority_ = 0; | best_priority_ = 0; | ||||
| // For the first face, check the remaining corners as they may not be | // For the first face, check the remaining corners as they may not be | ||||
| // processed yet. | // processed yet. | ||||
| ▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | for (int i = best_priority_; i < kMaxPriority; ++i) { | ||||
| } | } | ||||
| } | } | ||||
| return kInvalidCornerIndex; | return kInvalidCornerIndex; | ||||
| } | } | ||||
| inline void AddCornerToTraversalStack(CornerIndex ci, int priority) { | inline void AddCornerToTraversalStack(CornerIndex ci, int priority) { | ||||
| traversal_stacks_[priority].push_back(ci); | traversal_stacks_[priority].push_back(ci); | ||||
| // Make sure that the best available priority is up to date. | // Make sure that the best available priority is up to date. | ||||
| if (priority < best_priority_) | if (priority < best_priority_) { | ||||
| best_priority_ = priority; | best_priority_ = priority; | ||||
| } | } | ||||
| } | |||||
| // Returns the priority of traversing edge leading to |corner_id|. | // Returns the priority of traversing edge leading to |corner_id|. | ||||
| inline int ComputePriority(CornerIndex corner_id) { | inline int ComputePriority(CornerIndex corner_id) { | ||||
| const VertexIndex v_tip = this->corner_table()->Vertex(corner_id); | const VertexIndex v_tip = this->corner_table()->Vertex(corner_id); | ||||
| // Priority 0 when traversing to already visited vertices. | // Priority 0 when traversing to already visited vertices. | ||||
| int priority = 0; | int priority = 0; | ||||
| if (!this->IsVertexVisited(v_tip)) { | if (!this->IsVertexVisited(v_tip)) { | ||||
| const int degree = ++prediction_degree_[v_tip]; | const int degree = ++prediction_degree_[v_tip]; | ||||
| // Priority 1 when prediction degree > 1, otherwise 2. | // Priority 1 when prediction degree > 1, otherwise 2. | ||||
| priority = (degree > 1 ? 1 : 2); | priority = (degree > 1 ? 1 : 2); | ||||
| } | } | ||||
| // Clamp the priority to the maximum number of buckets. | // Clamp the priority to the maximum number of buckets. | ||||
| if (priority >= kMaxPriority) | if (priority >= kMaxPriority) { | ||||
| priority = kMaxPriority - 1; | priority = kMaxPriority - 1; | ||||
| } | |||||
| return priority; | return priority; | ||||
| } | } | ||||
| // For efficiency reasons, the priority traversal is implemented using buckets | // For efficiency reasons, the priority traversal is implemented using buckets | ||||
| // where each buckets represent a stack of available corners for a given | // where each buckets represent a stack of available corners for a given | ||||
| // priority. Corners with the highest priority are always processed first. | // priority. Corners with the highest priority are always processed first. | ||||
| static constexpr int kMaxPriority = 3; | static constexpr int kMaxPriority = 3; | ||||
| std::vector<CornerIndex> traversal_stacks_[kMaxPriority]; | std::vector<CornerIndex> traversal_stacks_[kMaxPriority]; | ||||
| Show All 12 Lines | |||||