Changeset View
Changeset View
Standalone View
Standalone View
extern/draco/draco/src/draco/animation/keyframe_animation.cc
- This file was moved from extern/draco/dracoenc/src/draco/animation/keyframe_animation.cc.
| Show All 23 Lines | bool KeyframeAnimation::SetTimestamps( | ||||
| const int32_t num_frames = timestamp.size(); | const int32_t num_frames = timestamp.size(); | ||||
| if (num_attributes() > 0) { | if (num_attributes() > 0) { | ||||
| // Timestamp attribute could be added only once. | // Timestamp attribute could be added only once. | ||||
| if (timestamps()->size()) { | if (timestamps()->size()) { | ||||
| return false; | return false; | ||||
| } else { | } else { | ||||
| // Check if the number of frames is consistent with | // Check if the number of frames is consistent with | ||||
| // the existing keyframes. | // the existing keyframes. | ||||
| if (num_frames != num_points()) | if (num_frames != num_points()) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | |||||
| } else { | } else { | ||||
| // This is the first attribute. | // This is the first attribute. | ||||
| set_num_frames(num_frames); | set_num_frames(num_frames); | ||||
| } | } | ||||
| // Add attribute for time stamp data. | // Add attribute for time stamp data. | ||||
| std::unique_ptr<PointAttribute> timestamp_att = | std::unique_ptr<PointAttribute> timestamp_att = | ||||
| std::unique_ptr<PointAttribute>(new PointAttribute()); | std::unique_ptr<PointAttribute>(new PointAttribute()); | ||||
| timestamp_att->Init(GeometryAttribute::GENERIC, nullptr, 1, DT_FLOAT32, false, | timestamp_att->Init(GeometryAttribute::GENERIC, 1, DT_FLOAT32, false, | ||||
| sizeof(float), 0); | num_frames); | ||||
| timestamp_att->SetIdentityMapping(); | |||||
| timestamp_att->Reset(num_frames); | |||||
| for (PointIndex i(0); i < num_frames; ++i) { | for (PointIndex i(0); i < num_frames; ++i) { | ||||
| timestamp_att->SetAttributeValue(timestamp_att->mapped_index(i), | timestamp_att->SetAttributeValue(timestamp_att->mapped_index(i), | ||||
| ×tamp[i.value()]); | ×tamp[i.value()]); | ||||
| } | } | ||||
| this->SetAttribute(kTimestampId, std::move(timestamp_att)); | this->SetAttribute(kTimestampId, std::move(timestamp_att)); | ||||
| return true; | return true; | ||||
| } | } | ||||
| } // namespace draco | } // namespace draco | ||||