Skip to content

Commit

Permalink
Debugging crashes
Browse files Browse the repository at this point in the history
Signed-off-by: Louise Poubel <louise@openrobotics.org>
  • Loading branch information
chapulina committed Apr 27, 2021
1 parent d88af6f commit 5186393
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
4 changes: 4 additions & 0 deletions graphics/src/Animation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -417,11 +417,15 @@ TrajectoryInfo::TrajectoryInfo(TrajectoryInfo &&_trajInfo) noexcept
TrajectoryInfo::~TrajectoryInfo()
{
delete this->dataPtr;
this->dataPtr = nullptr;
}

//////////////////////////////////////////////////
void TrajectoryInfo::CopyFrom(const TrajectoryInfo &_trajInfo)
{
if (nullptr == _trajInfo.dataPtr)
return;

this->dataPtr->id = _trajInfo.dataPtr->id;
this->dataPtr->animIndex = _trajInfo.dataPtr->animIndex;
this->dataPtr->startTime = _trajInfo.dataPtr->startTime;
Expand Down
8 changes: 8 additions & 0 deletions graphics/src/Skeleton.cc
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,14 @@ SkeletonAnimation *Skeleton::Animation(const unsigned int _i) const
//////////////////////////////////////////////////
void Skeleton::AddAnimation(SkeletonAnimation *_anim)
{
if (std::find(this->data->anims.begin(), this->data->anims.end(), _anim)
!= this->data->anims.end())
{
ignerr << "Trying to add the same animation to a skeleton twice."
<< std::endl;
return;
}

this->data->mapAnimSkin.push_back(std::map<std::string, std::string>());
this->data->alignTranslate.push_back(std::map<std::string, math::Matrix4d>());
this->data->alignRotate.push_back(std::map<std::string, math::Matrix4d>());
Expand Down
17 changes: 16 additions & 1 deletion graphics/src/SkeletonAnimation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,28 @@ math::Matrix4d SkeletonAnimation::NodePoseAt(const std::string &_node,
std::map<std::string, math::Matrix4d> SkeletonAnimation::PoseAt(
const double _time, const bool _loop) const
{
std::map<std::string, math::Matrix4d> pose;

if (this->data->animations.empty())
{
return pose;
}

if (this->data->animations.size() > this->data->animations.max_size())
{
ignerr << "The animations map size is [" << this->data->animations.size()
<< "], which is larger than the maximum size ["
<< this->data->animations.max_size() << "], how did this happen?!"
<< std::endl;
return pose;
}

/// TODO need to make sure that all nodes have keyframes at the same
/// points in time and create the missing keyframes. if the animation
/// comes from bvh this is guaranteed, but if it's comming from collada
/// it's not guaranteed. fixing this will help not having to find the
/// prev and next keyframe for each node at each time step, but rather
/// doing it only once per time step.
std::map<std::string, math::Matrix4d> pose;
for (auto iter = this->data->animations.begin();
iter != this->data->animations.end(); ++iter)
{
Expand Down

0 comments on commit 5186393

Please sign in to comment.