GameApi 28
Library used by GameApi Builder tool
Loading...
Searching...
No Matches
mesh_edgebreaker_shared.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_MESH_EDGEBREAKER_SHARED_H_
16#define DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_SHARED_H_
17
18#include <stdint.h>
19
20namespace draco {
21
22// Shared declarations used by both edgebreaker encoder and decoder.
23
24// A variable length encoding for storing all possible topology configurations
25// during traversal of mesh's surface. The configurations are based on visited
26// state of neighboring triangles around a currently processed face corner.
27// Note that about half of the encountered configurations is expected to be of
28// type TOPOLOGY_C. It's guaranteed that the encoding will use at most 2 bits
29// per triangle for meshes with no holes and up to 6 bits per triangle for
30// general meshes. In addition, the encoding will take up to 4 bits per triangle
31// for each non-position attribute attached to the mesh.
32//
33// *-------* *-------* *-------*
34// / \ / \ / \ / \ / \ / \
35// / \ / \ / \ / \ / \ / \
36// / \ / \ / \ / \ / \ / \
37// *-------v-------* *-------v-------* *-------v-------*
38// \ /x\ / /x\ / \ /x\
39// \ / \ / / \ / \ / \
40// \ / C \ / / L \ / \ / R \
41// *-------* *-------* *-------*
42//
43// * *
44// / \ / \
45// / \ / \
46// / \ / \
47// *-------v-------* v
48// \ /x\ / /x\
49// \ / \ / / \
50// \ / S \ / / E \
51// *-------* *-------*
52//
54 TOPOLOGY_C = 0x0, // 0
55 TOPOLOGY_S = 0x1, // 1 0 0
56 TOPOLOGY_L = 0x3, // 1 1 0
57 TOPOLOGY_R = 0x5, // 1 0 1
58 TOPOLOGY_E = 0x7, // 1 1 1
59 // A special symbol that's not actually encoded, but it can be used to mark
60 // the initial face that triggers the mesh encoding of a single connected
61 // component.
63 // A special value used to indicate an invalid symbol.
65};
66
75
76// Bit-length of symbols in the EdgebreakerTopologyBitPattern stored as a
77// lookup table for faster indexing.
78constexpr int32_t edge_breaker_topology_bit_pattern_length[] = {1, 3, 0, 3,
79 0, 3, 0, 3};
80
81// Zero-indexed symbol id for each of topology pattern.
87
88// Reverse mapping between symbol id and topology pattern symbol.
91
92// Types of edges used during mesh traversal relative to the tip vertex of a
93// visited triangle.
94enum EdgeFaceName : uint8_t { LEFT_FACE_EDGE = 0, RIGHT_FACE_EDGE = 1 };
95
96// Struct used for storing data about a source face that connects to an
97// already traversed face that was either the initial face or a face encoded
98// with either topology S (split) symbol. Such connection can be only caused by
99// topology changes on the traversed surface (if its genus != 0, i.e. when the
100// surface has topological handles or holes).
101// For each occurrence of such event we always encode the split symbol id,
102// source symbol id and source edge id (left, or right). There will be always
103// exactly two occurrences of this event for every topological handle on the
104// traversed mesh and one occurrence for a hole.
108 // We need to use uint32_t instead of EdgeFaceName because the most recent
109 // version of gcc does not allow that when optimizations are turned on.
110 uint32_t source_edge : 1;
111};
112
113// Hole event is used to store info about the first symbol that reached a
114// vertex of so far unvisited hole. This can happen only on either the initial
115// face or during a regular traversal when TOPOLOGY_S is encountered.
117 int32_t symbol_id;
119 explicit HoleEventData(int32_t sym_id) : symbol_id(sym_id) {}
120};
121
122// List of supported modes for valence based edgebreaker coding.
124 EDGEBREAKER_VALENCE_MODE_2_7 = 0, // Use contexts for valences in range 2-7.
125};
126
127} // namespace draco
128
129#endif // DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_SHARED_H_
Definition attribute_octahedron_transform.cc:21
constexpr int32_t edge_breaker_topology_bit_pattern_length[]
Definition mesh_edgebreaker_shared.h:78
EdgebreakerValenceCodingMode
Definition mesh_edgebreaker_shared.h:123
@ EDGEBREAKER_VALENCE_MODE_2_7
Definition mesh_edgebreaker_shared.h:124
EdgebreakerSymbol
Definition mesh_edgebreaker_shared.h:67
@ EDGEBREAKER_SYMBOL_E
Definition mesh_edgebreaker_shared.h:72
@ EDGEBREAKER_SYMBOL_R
Definition mesh_edgebreaker_shared.h:71
@ EDGEBREAKER_SYMBOL_S
Definition mesh_edgebreaker_shared.h:69
@ EDGEBREAKER_SYMBOL_INVALID
Definition mesh_edgebreaker_shared.h:73
@ EDGEBREAKER_SYMBOL_L
Definition mesh_edgebreaker_shared.h:70
@ EDGEBREAKER_SYMBOL_C
Definition mesh_edgebreaker_shared.h:68
constexpr EdgebreakerTopologyBitPattern edge_breaker_symbol_to_topology_id[]
Definition mesh_edgebreaker_shared.h:89
EdgeFaceName
Definition mesh_edgebreaker_shared.h:94
@ RIGHT_FACE_EDGE
Definition mesh_edgebreaker_shared.h:94
@ LEFT_FACE_EDGE
Definition mesh_edgebreaker_shared.h:94
EdgebreakerTopologyBitPattern
Definition mesh_edgebreaker_shared.h:53
@ TOPOLOGY_INVALID
Definition mesh_edgebreaker_shared.h:64
@ TOPOLOGY_R
Definition mesh_edgebreaker_shared.h:57
@ TOPOLOGY_S
Definition mesh_edgebreaker_shared.h:55
@ TOPOLOGY_INIT_FACE
Definition mesh_edgebreaker_shared.h:62
@ TOPOLOGY_L
Definition mesh_edgebreaker_shared.h:56
@ TOPOLOGY_E
Definition mesh_edgebreaker_shared.h:58
@ TOPOLOGY_C
Definition mesh_edgebreaker_shared.h:54
constexpr EdgebreakerSymbol edge_breaker_topology_to_symbol_id[]
Definition mesh_edgebreaker_shared.h:82
HoleEventData()
Definition mesh_edgebreaker_shared.h:118
HoleEventData(int32_t sym_id)
Definition mesh_edgebreaker_shared.h:119
int32_t symbol_id
Definition mesh_edgebreaker_shared.h:117
Definition mesh_edgebreaker_shared.h:105
uint32_t source_edge
Definition mesh_edgebreaker_shared.h:110
uint32_t split_symbol_id
Definition mesh_edgebreaker_shared.h:106
uint32_t source_symbol_id
Definition mesh_edgebreaker_shared.h:107