Differential D9642 Diff 31337 extern/draco/draco/src/draco/attributes/attribute_octahedron_transform.cc
Changeset View
Changeset View
Standalone View
Standalone View
extern/draco/draco/src/draco/attributes/attribute_octahedron_transform.cc
- This file was moved from extern/draco/dracoenc/src/draco/attributes/attribute_octahedron_transform.cc.
| Show All 19 Lines | |||||
| namespace draco { | namespace draco { | ||||
| bool AttributeOctahedronTransform::InitFromAttribute( | bool AttributeOctahedronTransform::InitFromAttribute( | ||||
| const PointAttribute &attribute) { | const PointAttribute &attribute) { | ||||
| const AttributeTransformData *const transform_data = | const AttributeTransformData *const transform_data = | ||||
| attribute.GetAttributeTransformData(); | attribute.GetAttributeTransformData(); | ||||
| if (!transform_data || | if (!transform_data || | ||||
| transform_data->transform_type() != ATTRIBUTE_OCTAHEDRON_TRANSFORM) | transform_data->transform_type() != ATTRIBUTE_OCTAHEDRON_TRANSFORM) { | ||||
| return false; // Wrong transform type. | return false; // Wrong transform type. | ||||
| } | |||||
| quantization_bits_ = transform_data->GetParameterValue<int32_t>(0); | quantization_bits_ = transform_data->GetParameterValue<int32_t>(0); | ||||
| return true; | return true; | ||||
| } | } | ||||
| void AttributeOctahedronTransform::CopyToAttributeTransformData( | void AttributeOctahedronTransform::CopyToAttributeTransformData( | ||||
| AttributeTransformData *out_data) const { | AttributeTransformData *out_data) const { | ||||
| out_data->set_transform_type(ATTRIBUTE_OCTAHEDRON_TRANSFORM); | out_data->set_transform_type(ATTRIBUTE_OCTAHEDRON_TRANSFORM); | ||||
| out_data->AppendParameterValue(quantization_bits_); | out_data->AppendParameterValue(quantization_bits_); | ||||
| Show All 25 Lines | AttributeOctahedronTransform::GeneratePortableAttribute( | ||||
| // Quantize all values in the order given by point_ids into portable | // Quantize all values in the order given by point_ids into portable | ||||
| // attribute. | // attribute. | ||||
| int32_t *const portable_attribute_data = reinterpret_cast<int32_t *>( | int32_t *const portable_attribute_data = reinterpret_cast<int32_t *>( | ||||
| portable_attribute->GetAddress(AttributeValueIndex(0))); | portable_attribute->GetAddress(AttributeValueIndex(0))); | ||||
| float att_val[3]; | float att_val[3]; | ||||
| int32_t dst_index = 0; | int32_t dst_index = 0; | ||||
| OctahedronToolBox converter; | OctahedronToolBox converter; | ||||
| if (!converter.SetQuantizationBits(quantization_bits_)) | if (!converter.SetQuantizationBits(quantization_bits_)) { | ||||
| return nullptr; | return nullptr; | ||||
| } | |||||
| for (uint32_t i = 0; i < point_ids.size(); ++i) { | for (uint32_t i = 0; i < point_ids.size(); ++i) { | ||||
| const AttributeValueIndex att_val_id = attribute.mapped_index(point_ids[i]); | const AttributeValueIndex att_val_id = attribute.mapped_index(point_ids[i]); | ||||
| attribute.GetValue(att_val_id, att_val); | attribute.GetValue(att_val_id, att_val); | ||||
| // Encode the vector into a s and t octahedral coordinates. | // Encode the vector into a s and t octahedral coordinates. | ||||
| int32_t s, t; | int32_t s, t; | ||||
| converter.FloatVectorToQuantizedOctahedralCoords(att_val, &s, &t); | converter.FloatVectorToQuantizedOctahedralCoords(att_val, &s, &t); | ||||
| portable_attribute_data[dst_index++] = s; | portable_attribute_data[dst_index++] = s; | ||||
| portable_attribute_data[dst_index++] = t; | portable_attribute_data[dst_index++] = t; | ||||
| } | } | ||||
| return portable_attribute; | return portable_attribute; | ||||
| } | } | ||||
| } // namespace draco | } // namespace draco | ||||