Skip to content

Commit

Permalink
feat: add default property values for animated component bones
Browse files Browse the repository at this point in the history
  • Loading branch information
Silverlan committed May 10, 2024
1 parent 96bc92e commit f1841b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ void BaseAnimatedComponent::OnModelChanged(const std::shared_ptr<Model> &mdl)
if(!mdl)
return;
auto &skeleton = mdl->GetSkeleton();
auto relRef = Frame::Create(mdl->GetReference());
relRef->Localize(skeleton);
auto &bones = skeleton.GetBones();
ReserveMembers(bones.size() * 3);
std::function<void(const pragma::animation::Bone &, const std::string &)> fAddBone = nullptr;
Expand All @@ -244,6 +246,9 @@ void BaseAnimatedComponent::OnModelChanged(const std::shared_ptr<Model> &mdl)
parentMetaData->parentProperty = parentPathName;
}

umath::ScaledTransform defaultPose;
relRef->GetBonePose(bone.ID, defaultPose);

auto posePathName = "bone/" + lname + "/pose";
auto posPathName = "bone/" + lname + "/position";
auto rotPathName = "bone/" + lname + "/rotation";
Expand Down Expand Up @@ -284,6 +289,7 @@ void BaseAnimatedComponent::OnModelChanged(const std::shared_ptr<Model> &mdl)
memberInfoPos.SetName("bone/" + lname + "/position");
memberInfoPos.type = ents::EntityMemberType::Vector3;
memberInfoPos.userIndex = bone.ID;
memberInfoPos.SetDefault<Vector3>(defaultPose.GetOrigin());
memberInfoPos.AddTypeMetaData(coordMetaData);
memberInfoPos.AddTypeMetaData(poseComponentMetaData);
if(parentMetaData)
Expand All @@ -301,6 +307,7 @@ void BaseAnimatedComponent::OnModelChanged(const std::shared_ptr<Model> &mdl)
memberInfoRot.SetName("bone/" + lname + "/rotation");
memberInfoRot.type = ents::EntityMemberType::Quaternion;
memberInfoRot.userIndex = bone.ID;
memberInfoRot.SetDefault<Quat>(defaultPose.GetRotation());
memberInfoRot.AddTypeMetaData(coordMetaData);
memberInfoRot.AddTypeMetaData(poseComponentMetaData);
if(parentMetaData)
Expand All @@ -317,6 +324,7 @@ void BaseAnimatedComponent::OnModelChanged(const std::shared_ptr<Model> &mdl)
auto memberInfoScale = memberInfoPos;
memberInfoScale.SetName("bone/" + lname + "/scale");
memberInfoScale.userIndex = bone.ID;
memberInfoScale.SetDefault<Vector3>(defaultPose.GetScale());
memberInfoScale.AddTypeMetaData(coordMetaData);
memberInfoScale.AddTypeMetaData(poseMetaData);
if(parentMetaData)
Expand Down
3 changes: 2 additions & 1 deletion core/shared/src/entities/components/panima_component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ void PanimaComponent::DebugPrint()
Con::cout << "Animation info: \n" << ss.str() << Con::endl;
}

void PanimaComponent::UpdateAnimationChannelSubmitters() {
void PanimaComponent::UpdateAnimationChannelSubmitters()
{
#ifdef PRAGMA_ENABLE_VTUNE_PROFILING
::debug::get_domain().BeginTask("panima_update_channel_values");
#endif
Expand Down

0 comments on commit f1841b7

Please sign in to comment.