GameApi 28
Library used by GameApi Builder tool
Loading...
Searching...
No Matches
mesh_attribute_indices_encoding_observer.h
Go to the documentation of this file.
1// Copyright 2016 The Draco Authors.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15#ifndef DRACO_COMPRESSION_MESH_TRAVERSER_MESH_ATTRIBUTE_INDICES_ENCODING_OBSERVER_H_
16#define DRACO_COMPRESSION_MESH_TRAVERSER_MESH_ATTRIBUTE_INDICES_ENCODING_OBSERVER_H_
17
20#include "draco/mesh/mesh.h"
21
22namespace draco {
23
24// Class that can be used to generate encoding (and decoding) order of attribute
25// values based on the traversal of the encoded mesh. The class should be used
26// as the TraversalObserverT member of a Traverser class such as the
27// DepthFirstTraverser (depth_first_traverser.h).
28// TODO(b/199760123): Rename to AttributeIndicesCodingTraverserObserver.
29template <class CornerTableT>
31 public:
33 : att_connectivity_(nullptr),
34 encoding_data_(nullptr),
35 mesh_(nullptr),
36 sequencer_(nullptr) {}
38 const CornerTableT *connectivity, const Mesh *mesh,
39 PointsSequencer *sequencer,
41 : att_connectivity_(connectivity),
42 encoding_data_(encoding_data),
43 mesh_(mesh),
44 sequencer_(sequencer) {}
45
46 // Interface for TraversalObserverT
47
48 void OnNewFaceVisited(FaceIndex /* face */) {}
49
50 inline void OnNewVertexVisited(VertexIndex vertex, CornerIndex corner) {
51 const PointIndex point_id =
52 mesh_->face(FaceIndex(corner.value() / 3))[corner.value() % 3];
53 // Append the visited attribute to the encoding order.
54 sequencer_->AddPointId(point_id);
55
56 // Keep track of visited corners.
57 encoding_data_->encoded_attribute_value_index_to_corner_map.push_back(
58 corner);
59
60 encoding_data_
61 ->vertex_to_encoded_attribute_value_index_map[vertex.value()] =
62 encoding_data_->num_values;
63
64 encoding_data_->num_values++;
65 }
66
67 private:
68 const CornerTableT *att_connectivity_;
70 const Mesh *mesh_;
71 PointsSequencer *sequencer_;
72};
73
74} // namespace draco
75
76#endif // DRACO_COMPRESSION_MESH_TRAVERSER_MESH_ATTRIBUTE_INDICES_ENCODING_OBSERVER_H_
MeshAttributeIndicesEncodingObserver(const CornerTableT *connectivity, const Mesh *mesh, PointsSequencer *sequencer, MeshAttributeIndicesEncodingData *encoding_data)
Definition mesh_attribute_indices_encoding_observer.h:37
MeshAttributeIndicesEncodingObserver()
Definition mesh_attribute_indices_encoding_observer.h:32
void OnNewFaceVisited(FaceIndex)
Definition mesh_attribute_indices_encoding_observer.h:48
void OnNewVertexVisited(VertexIndex vertex, CornerIndex corner)
Definition mesh_attribute_indices_encoding_observer.h:50
Definition mesh.h:52
Definition points_sequencer.h:27
Definition attribute_octahedron_transform.cc:21
VertexIndex VertexIndex
Definition mesh_edgebreaker_encoder_impl.cc:37
CornerIndex CornerIndex
Definition mesh_edgebreaker_encoder_impl.cc:35
FaceIndex FaceIndex
Definition mesh_edgebreaker_encoder_impl.cc:36
Definition GameApi_pl.cc:29382
int face
Definition GameApi_pl.cc:29383
Definition mesh_attribute_indices_encoding_data.h:27