Changeset View
Changeset View
Standalone View
Standalone View
extern/draco/draco/src/draco/animation/keyframe_animation.h
- This file was moved from extern/draco/dracoenc/src/draco/animation/keyframe_animation.h.
| Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | private: | ||||
| static constexpr int32_t kTimestampId = 0; | static constexpr int32_t kTimestampId = 0; | ||||
| }; | }; | ||||
| template <typename T> | template <typename T> | ||||
| int32_t KeyframeAnimation::AddKeyframes(DataType data_type, | int32_t KeyframeAnimation::AddKeyframes(DataType data_type, | ||||
| uint32_t num_components, | uint32_t num_components, | ||||
| const std::vector<T> &data) { | const std::vector<T> &data) { | ||||
| // TODO(draco-eng): Verify T is consistent with |data_type|. | // TODO(draco-eng): Verify T is consistent with |data_type|. | ||||
| if (num_components == 0) | if (num_components == 0) { | ||||
| return -1; | return -1; | ||||
| } | |||||
| // If timestamps is not added yet, then reserve attribute 0 for timestamps. | // If timestamps is not added yet, then reserve attribute 0 for timestamps. | ||||
| if (!num_attributes()) { | if (!num_attributes()) { | ||||
| // Add a temporary attribute with 0 points to fill attribute id 0. | // Add a temporary attribute with 0 points to fill attribute id 0. | ||||
| std::unique_ptr<PointAttribute> temp_att = | std::unique_ptr<PointAttribute> temp_att = | ||||
| std::unique_ptr<PointAttribute>(new PointAttribute()); | std::unique_ptr<PointAttribute>(new PointAttribute()); | ||||
| temp_att->Init(GeometryAttribute::GENERIC, nullptr, num_components, | temp_att->Init(GeometryAttribute::GENERIC, num_components, data_type, false, | ||||
| data_type, false, DataTypeLength(data_type), 0); | 0); | ||||
| temp_att->Reset(0); | |||||
| this->AddAttribute(std::move(temp_att)); | this->AddAttribute(std::move(temp_att)); | ||||
| set_num_frames(data.size() / num_components); | set_num_frames(data.size() / num_components); | ||||
| } | } | ||||
| if (data.size() != num_components * num_frames()) | if (data.size() != num_components * num_frames()) { | ||||
| return -1; | return -1; | ||||
| } | |||||
| std::unique_ptr<PointAttribute> keyframe_att = | std::unique_ptr<PointAttribute> keyframe_att = | ||||
| std::unique_ptr<PointAttribute>(new PointAttribute()); | std::unique_ptr<PointAttribute>(new PointAttribute()); | ||||
| keyframe_att->Init(GeometryAttribute::GENERIC, nullptr, num_components, | keyframe_att->Init(GeometryAttribute::GENERIC, num_components, data_type, | ||||
| data_type, false, DataTypeLength(data_type), 0); | false, num_frames()); | ||||
| keyframe_att->SetIdentityMapping(); | |||||
| keyframe_att->Reset(num_frames()); | |||||
| const size_t stride = num_components; | const size_t stride = num_components; | ||||
| for (PointIndex i(0); i < num_frames(); ++i) { | for (PointIndex i(0); i < num_frames(); ++i) { | ||||
| keyframe_att->SetAttributeValue(keyframe_att->mapped_index(i), | keyframe_att->SetAttributeValue(keyframe_att->mapped_index(i), | ||||
| &data[i.value() * stride]); | &data[i.value() * stride]); | ||||
| } | } | ||||
| return this->AddAttribute(std::move(keyframe_att)); | return this->AddAttribute(std::move(keyframe_att)); | ||||
| } | } | ||||
| } // namespace draco | } // namespace draco | ||||
| #endif // DRACO_ANIMATION_KEYFRAME_ANIMATION_H_ | #endif // DRACO_ANIMATION_KEYFRAME_ANIMATION_H_ | ||||