mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-09 20:08:57 +03:00
Crude optimizations
From testing with model of around 50 bones, I could get 64+ animated models on the screen with 150fps+
This commit is contained in:
@@ -13,5 +13,6 @@ namespace Nuake
|
||||
std::vector<SkeletonNode> Children;
|
||||
Matrix4 FinalTransform = Matrix4(1.0f);
|
||||
int32_t Id = -1;
|
||||
int32_t EntityHandle = 0;
|
||||
};
|
||||
}
|
||||
@@ -24,7 +24,11 @@ namespace Nuake
|
||||
{
|
||||
BEGIN_SERIALIZE();
|
||||
SERIALIZE_VAL(ModelPath);
|
||||
SERIALIZE_OBJECT(ModelResource);
|
||||
|
||||
if (ModelResource)
|
||||
{
|
||||
SERIALIZE_OBJECT(ModelResource);
|
||||
}
|
||||
END_SERIALIZE();
|
||||
}
|
||||
|
||||
|
||||
@@ -484,9 +484,11 @@ namespace Nuake
|
||||
auto& skeletonRoot = component.ModelResource->GetSkeletonRootNode();
|
||||
|
||||
Entity skeletonRootEntity = CreateEntity(skeletonRoot.Name);
|
||||
skeletonRootEntity.AddComponent<BoneComponent>();
|
||||
skeletonRootEntity.AddComponent<BoneComponent>().Name = skeletonRoot.Name;
|
||||
skeletonRoot.EntityHandle = skeletonRootEntity.GetHandle();
|
||||
entity.AddChild(skeletonRootEntity);
|
||||
|
||||
|
||||
Vector3 bonePosition;
|
||||
Quat boneRotation;
|
||||
Vector3 boneScale;
|
||||
@@ -509,6 +511,8 @@ namespace Nuake
|
||||
boneEntity.AddComponent<BoneComponent>();
|
||||
entity.AddChild(boneEntity);
|
||||
|
||||
c.EntityHandle = boneEntity.GetHandle();
|
||||
|
||||
Vector3 bonePosition;
|
||||
Quat boneRotation;
|
||||
Vector3 boneScale;
|
||||
|
||||
@@ -50,12 +50,14 @@ namespace Nuake
|
||||
auto& animationTrack = animation->GetTrack(boneName);
|
||||
|
||||
Entity& boneEntity = m_Scene->GetEntity(boneName);
|
||||
if (boneEntity.GetHandle() != -1)
|
||||
Entity& boneEnt = Entity{ (entt::entity)bone.EntityHandle, m_Scene };
|
||||
///assert(boneEnt.GetHandle() == boneEntity.GetHandle());
|
||||
if (boneEnt.GetHandle() != 0)
|
||||
{
|
||||
auto& transformComponent = boneEntity.GetComponent<TransformComponent>();
|
||||
auto& transformComponent = boneEnt.GetComponent<TransformComponent>();
|
||||
bone.FinalTransform = transformComponent.GetGlobalTransform() * bone.Offset;
|
||||
|
||||
if (!animationTrack.IsEmpty())
|
||||
//if (!animationTrack.IsEmpty())
|
||||
{
|
||||
// Get Update transform
|
||||
animationTrack.Update(time);
|
||||
@@ -74,6 +76,7 @@ namespace Nuake
|
||||
transformComponent.Dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& childBone : bone.Children)
|
||||
{
|
||||
UpdateBonePositionTraversal(childBone, animation, time);
|
||||
|
||||
Reference in New Issue
Block a user