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
20
#include "
draco/attributes/attribute_transform_type.h
"
21
#include "
draco/core/data_buffer.h
"
22
23
namespace
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).
30
class
AttributeTransformData
{
31
public
:
32
AttributeTransformData
() : transform_type_(
ATTRIBUTE_INVALID_TRANSFORM
) {}
33
AttributeTransformData
(
const
AttributeTransformData
&
data
) =
default
;
34
35
// Returns the type of the attribute transform that is described by the class.
36
AttributeTransformType
transform_type
()
const
{
return
transform_type_; }
37
void
set_transform_type
(
AttributeTransformType
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_
attribute_transform_type.h
draco::AttributeTransformData::transform_type
AttributeTransformType transform_type() const
Definition
attribute_transform_data.h:36
draco::AttributeTransformData::AttributeTransformData
AttributeTransformData(const AttributeTransformData &data)=default
draco::AttributeTransformData::AttributeTransformData
AttributeTransformData()
Definition
attribute_transform_data.h:32
draco::AttributeTransformData::AppendParameterValue
void AppendParameterValue(const DataTypeT &in_data)
Definition
attribute_transform_data.h:60
draco::AttributeTransformData::SetParameterValue
void SetParameterValue(int byte_offset, const DataTypeT &in_data)
Definition
attribute_transform_data.h:51
draco::AttributeTransformData::set_transform_type
void set_transform_type(AttributeTransformType type)
Definition
attribute_transform_data.h:37
draco::AttributeTransformData::GetParameterValue
DataTypeT GetParameterValue(int byte_offset) const
Definition
attribute_transform_data.h:43
draco::DataBuffer
Definition
data_buffer.h:36
data_buffer.h
data
lazy data
Definition
meshpage.php:1583
draco
Definition
attribute_octahedron_transform.cc:21
draco::AttributeTransformType
AttributeTransformType
Definition
attribute_transform_type.h:21
draco::ATTRIBUTE_INVALID_TRANSFORM
@ ATTRIBUTE_INVALID_TRANSFORM
Definition
attribute_transform_type.h:22
draco
attributes
attribute_transform_data.h
Generated by
1.15.0