15#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_ENCODER_H_
16#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_ENCODER_H_
29template <
typename DataTypeT,
class TransformT,
class MeshDataT>
44 int num_components,
const PointIndex *entry_to_point_id_map)
override;
53 if (!predictor_.IsInitialized()) {
77 predictor_.SetPositionAttribute(*att);
82 void SetQuantizationBits(
int q) {
87 MeshPredictionSchemeGeometricNormalPredictorArea<DataTypeT, TransformT,
91 OctahedronToolBox octahedron_tool_box_;
92 RAnsBitEncoder flip_normal_bit_encoder_;
95template <
typename DataTypeT,
class TransformT,
class MeshDataT>
98 ComputeCorrectionValues(
const DataTypeT *in_data,
CorrType *out_corr,
99 int size,
int num_components,
101 this->SetQuantizationBits(this->
transform().quantization_bits());
102 predictor_.SetEntryToPointIdMap(entry_to_point_id_map);
107 flip_normal_bit_encoder_.StartEncoding();
109 const int corner_map_size =
110 static_cast<int>(this->
mesh_data().data_to_corner_map()->size());
117 for (
int data_id = 0; data_id < corner_map_size; ++data_id) {
119 this->
mesh_data().data_to_corner_map()->at(data_id);
120 predictor_.ComputePredictedValue(corner_id, pred_normal_3d.
data());
123 octahedron_tool_box_.CanonicalizeIntegerVector(pred_normal_3d.
data());
125 octahedron_tool_box_.center_value());
128 octahedron_tool_box_.IntegerVectorToQuantizedOctahedralCoords(
129 pred_normal_3d.
data(), pos_pred_normal_oct.
data(),
130 pos_pred_normal_oct.
data() + 1);
131 pred_normal_3d = -pred_normal_3d;
132 octahedron_tool_box_.IntegerVectorToQuantizedOctahedralCoords(
133 pred_normal_3d.
data(), neg_pred_normal_oct.
data(),
134 neg_pred_normal_oct.
data() + 1);
137 const int data_offset = data_id * 2;
138 this->
transform().ComputeCorrection(in_data + data_offset,
139 pos_pred_normal_oct.
data(),
140 pos_correction.
data());
141 this->
transform().ComputeCorrection(in_data + data_offset,
142 neg_pred_normal_oct.
data(),
143 neg_correction.
data());
144 pos_correction[0] = octahedron_tool_box_.ModMax(pos_correction[0]);
145 pos_correction[1] = octahedron_tool_box_.ModMax(pos_correction[1]);
146 neg_correction[0] = octahedron_tool_box_.ModMax(neg_correction[0]);
147 neg_correction[1] = octahedron_tool_box_.ModMax(neg_correction[1]);
148 if (pos_correction.
AbsSum() < neg_correction.
AbsSum()) {
149 flip_normal_bit_encoder_.EncodeBit(
false);
150 (out_corr + data_offset)[0] =
151 octahedron_tool_box_.MakePositive(pos_correction[0]);
152 (out_corr + data_offset)[1] =
153 octahedron_tool_box_.MakePositive(pos_correction[1]);
155 flip_normal_bit_encoder_.EncodeBit(
true);
156 (out_corr + data_offset)[0] =
157 octahedron_tool_box_.MakePositive(neg_correction[0]);
158 (out_corr + data_offset)[1] =
159 octahedron_tool_box_.MakePositive(neg_correction[1]);
165template <
typename DataTypeT,
class TransformT,
class MeshDataT>
169 if (!this->
transform().EncodeTransformData(buffer)) {
174 flip_normal_bit_encoder_.EndEncoding(buffer);
Definition encoder_buffer.h:29
uint8_t num_components() const
Definition geometry_attribute.h:263
Type attribute_type() const
Definition geometry_attribute.h:256
Type
Definition geometry_attribute.h:46
@ POSITION
Definition geometry_attribute.h:52
MeshPredictionSchemeEncoder(const PointAttribute *attribute, const TransformT &transform, const MeshDataT &mesh_data)
Definition mesh_prediction_scheme_encoder.h:31
const MeshData & mesh_data() const
Definition mesh_prediction_scheme_encoder.h:38
Definition mesh_prediction_scheme_geometric_normal_encoder.h:31
bool SetParentAttribute(const PointAttribute *att) override
Definition mesh_prediction_scheme_geometric_normal_encoder.h:70
MeshPredictionSchemeGeometricNormalEncoder(const PointAttribute *attribute, const TransformT &transform, const MeshDataT &mesh_data)
Definition mesh_prediction_scheme_geometric_normal_encoder.h:35
bool IsInitialized() const override
Definition mesh_prediction_scheme_geometric_normal_encoder.h:52
int GetNumParentAttributes() const override
Definition mesh_prediction_scheme_geometric_normal_encoder.h:62
PredictionSchemeMethod GetPredictionMethod() const override
Definition mesh_prediction_scheme_geometric_normal_encoder.h:48
bool ComputeCorrectionValues(const DataTypeT *in_data, CorrType *out_corr, int size, int num_components, const PointIndex *entry_to_point_id_map) override
Definition mesh_prediction_scheme_geometric_normal_encoder.h:98
GeometryAttribute::Type GetParentAttributeType(int i) const override
Definition mesh_prediction_scheme_geometric_normal_encoder.h:64
typename MeshPredictionSchemeEncoder< DataTypeT, TransformT, MeshDataT >::CorrType CorrType
Definition mesh_prediction_scheme_geometric_normal_encoder.h:33
bool EncodePredictionData(EncoderBuffer *buffer) override
Definition mesh_prediction_scheme_geometric_normal_encoder.h:167
Definition point_attribute.h:33
const PointAttribute * attribute() const
Definition prediction_scheme_encoder.h:79
const Transform & transform() const
Definition prediction_scheme_encoder.h:80
Scalar AbsSum() const
Definition vector_d.h:237
Scalar * data()
Definition vector_d.h:282
#define DRACO_DCHECK_EQ(a, b)
Definition macros.h:81
#define DRACO_DCHECK(x)
Definition macros.h:80
#define DRACO_DCHECK_LE(a, b)
Definition macros.h:85
#define DRACO_DCHECK_GE(a, b)
Definition macros.h:83
n< br > font size
Definition meshpage.php:3536
Definition attribute_octahedron_transform.cc:21
CornerIndex CornerIndex
Definition mesh_edgebreaker_encoder_impl.cc:35
PredictionSchemeMethod
Definition compression_shared.h:80
@ MESH_PREDICTION_GEOMETRIC_NORMAL
Definition compression_shared.h:91
Definition GameApi_pl.cc:29382