GameApi 28
Library used by GameApi Builder tool
Loading...
Searching...
No Matches
attribute_transform_data.h
Go to the documentation of this file.
1// Copyright 2017 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_ATTRIBUTES_ATTRIBUTE_TRANSFORM_DATA_H_
16#define DRACO_ATTRIBUTES_ATTRIBUTE_TRANSFORM_DATA_H_
17
18#include <memory>
19
22
23namespace draco {
24
25// Class for holding parameter values for an attribute transform of a
26// PointAttribute. This can be for example quantization data for an attribute
27// that holds quantized values. This class provides only a basic storage for
28// attribute transform parameters and it should be accessed only through wrapper
29// classes for a specific transform (e.g. AttributeQuantizationTransform).
31 public:
34
35 // Returns the type of the attribute transform that is described by the class.
36 AttributeTransformType transform_type() const { return transform_type_; }
38 transform_type_ = type;
39 }
40
41 // Returns a parameter value on a given |byte_offset|.
42 template <typename DataTypeT>
43 DataTypeT GetParameterValue(int byte_offset) const {
44 DataTypeT out_data;
45 buffer_.Read(byte_offset, &out_data, sizeof(DataTypeT));
46 return out_data;
47 }
48
49 // Sets a parameter value on a given |byte_offset|.
50 template <typename DataTypeT>
51 void SetParameterValue(int byte_offset, const DataTypeT &in_data) {
52 if (byte_offset + sizeof(DataTypeT) > buffer_.data_size()) {
53 buffer_.Resize(byte_offset + sizeof(DataTypeT));
54 }
55 buffer_.Write(byte_offset, &in_data, sizeof(DataTypeT));
56 }
57
58 // Sets a parameter value at the end of the |buffer_|.
59 template <typename DataTypeT>
60 void AppendParameterValue(const DataTypeT &in_data) {
61 SetParameterValue(static_cast<int>(buffer_.data_size()), in_data);
62 }
63
64 private:
65 AttributeTransformType transform_type_;
66 DataBuffer buffer_;
67};
68
69} // namespace draco
70
71#endif // DRACO_ATTRIBUTES_ATTRIBUTE_TRANSFORM_DATA_H_
AttributeTransformType transform_type() const
Definition attribute_transform_data.h:36
AttributeTransformData(const AttributeTransformData &data)=default
AttributeTransformData()
Definition attribute_transform_data.h:32
void AppendParameterValue(const DataTypeT &in_data)
Definition attribute_transform_data.h:60
void SetParameterValue(int byte_offset, const DataTypeT &in_data)
Definition attribute_transform_data.h:51
void set_transform_type(AttributeTransformType type)
Definition attribute_transform_data.h:37
DataTypeT GetParameterValue(int byte_offset) const
Definition attribute_transform_data.h:43
Definition data_buffer.h:36
lazy data
Definition meshpage.php:1583
Definition attribute_octahedron_transform.cc:21
AttributeTransformType
Definition attribute_transform_type.h:21
@ ATTRIBUTE_INVALID_TRANSFORM
Definition attribute_transform_type.h:22