Add initial support for skeletal entities / components
This commit is contained in:
@@ -30,6 +30,9 @@
|
||||
#define NAZARA_UTILITY_COMPONENTS_HPP
|
||||
|
||||
#include <Nazara/Utility/Components/NodeComponent.hpp>
|
||||
#include <Nazara/Utility/Components/SharedSkeletonComponent.hpp>
|
||||
#include <Nazara/Utility/Components/SkeletonComponent.hpp>
|
||||
#include <Nazara/Utility/Components/SkeletonComponentBase.hpp>
|
||||
#include <Nazara/Utility/Components/VelocityComponent.hpp>
|
||||
|
||||
#endif // NAZARA_UTILITY_COMPONENTS_HPP
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_UTILITY_COMPONENTS_SHAREDSKELETONCOMPONENT_HPP
|
||||
#define NAZARA_UTILITY_COMPONENTS_SHAREDSKELETONCOMPONENT_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Utility/Skeleton.hpp>
|
||||
#include <Nazara/Utility/Components/SkeletonComponentBase.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_UTILITY_API SharedSkeletonComponent final : public SkeletonComponentBase
|
||||
{
|
||||
friend class SkeletonSystem;
|
||||
|
||||
public:
|
||||
SharedSkeletonComponent(std::shared_ptr<Skeleton> skeleton);
|
||||
SharedSkeletonComponent(const SharedSkeletonComponent& sharedSkeletalComponent);
|
||||
SharedSkeletonComponent(SharedSkeletonComponent&& sharedSkeletalComponent) noexcept;
|
||||
~SharedSkeletonComponent() = default;
|
||||
|
||||
const Joint& GetAttachedJoint(std::size_t jointIndex) const override;
|
||||
|
||||
SharedSkeletonComponent& operator=(const SharedSkeletonComponent& sharedSkeletalComponent);
|
||||
SharedSkeletonComponent& operator=(SharedSkeletonComponent&& sharedSkeletalComponent) noexcept;
|
||||
|
||||
private:
|
||||
inline bool IsAttachedSkeletonOutdated() const;
|
||||
void OnReferenceJointsInvalidated(const Skeleton* skeleton);
|
||||
void SetSkeletonParent(Node* parent);
|
||||
void SetupSkeleton();
|
||||
void UpdateAttachedSkeletonJoints();
|
||||
|
||||
NazaraSlot(Skeleton, OnSkeletonJointsInvalidated, m_onSkeletonJointsInvalidated);
|
||||
|
||||
Skeleton m_attachedSkeleton;
|
||||
bool m_skeletonJointInvalidated;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/Components/SharedSkeletonComponent.inl>
|
||||
|
||||
#endif // NAZARA_UTILITY_COMPONENTS_SHAREDSKELETONCOMPONENT_HPP
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Utility/Components/SharedSkeletonComponent.hpp>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline bool SharedSkeletonComponent::IsAttachedSkeletonOutdated() const
|
||||
{
|
||||
return m_skeletonJointInvalidated;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/DebugOff.hpp>
|
||||
36
include/Nazara/Utility/Components/SkeletonComponent.hpp
Normal file
36
include/Nazara/Utility/Components/SkeletonComponent.hpp
Normal file
@@ -0,0 +1,36 @@
|
||||
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_UTILITY_COMPONENTS_SKELETONCOMPONENT_HPP
|
||||
#define NAZARA_UTILITY_COMPONENTS_SKELETONCOMPONENT_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Utility/Skeleton.hpp>
|
||||
#include <Nazara/Utility/Components/SkeletonComponentBase.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class Node;
|
||||
|
||||
class NAZARA_UTILITY_API SkeletonComponent final : public SkeletonComponentBase
|
||||
{
|
||||
public:
|
||||
SkeletonComponent(std::shared_ptr<Skeleton> skeleton);
|
||||
SkeletonComponent(const SkeletonComponent&) = delete;
|
||||
SkeletonComponent(SkeletonComponent&& skeletalComponent) noexcept = default;
|
||||
~SkeletonComponent() = default;
|
||||
|
||||
const Joint& GetAttachedJoint(std::size_t jointIndex) const override;
|
||||
Node* GetRootNode();
|
||||
|
||||
SkeletonComponent& operator=(const SkeletonComponent&) = delete;
|
||||
SkeletonComponent& operator=(SkeletonComponent&& skeletalComponent) noexcept = default;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/Components/SkeletonComponent.inl>
|
||||
|
||||
#endif // NAZARA_UTILITY_COMPONENTS_SKELETONCOMPONENT_HPP
|
||||
12
include/Nazara/Utility/Components/SkeletonComponent.inl
Normal file
12
include/Nazara/Utility/Components/SkeletonComponent.inl
Normal file
@@ -0,0 +1,12 @@
|
||||
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Utility/Components/SkeletonComponent.hpp>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/DebugOff.hpp>
|
||||
38
include/Nazara/Utility/Components/SkeletonComponentBase.hpp
Normal file
38
include/Nazara/Utility/Components/SkeletonComponentBase.hpp
Normal file
@@ -0,0 +1,38 @@
|
||||
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_UTILITY_COMPONENTS_SKELETONCOMPONENTBASE_HPP
|
||||
#define NAZARA_UTILITY_COMPONENTS_SKELETONCOMPONENTBASE_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Utility/Joint.hpp>
|
||||
#include <Nazara/Utility/Skeleton.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_UTILITY_API SkeletonComponentBase
|
||||
{
|
||||
public:
|
||||
SkeletonComponentBase(const SkeletonComponentBase&) = default;
|
||||
SkeletonComponentBase(SkeletonComponentBase&&) noexcept = default;
|
||||
~SkeletonComponentBase() = default;
|
||||
|
||||
virtual const Joint& GetAttachedJoint(std::size_t jointIndex) const = 0;
|
||||
inline const std::shared_ptr<Skeleton>& GetSkeleton() const;
|
||||
|
||||
SkeletonComponentBase& operator=(const SkeletonComponentBase&) = default;
|
||||
SkeletonComponentBase& operator=(SkeletonComponentBase&&) noexcept = default;
|
||||
|
||||
protected:
|
||||
SkeletonComponentBase(std::shared_ptr<Skeleton> skeleton);
|
||||
|
||||
std::shared_ptr<Skeleton> m_referenceSkeleton;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/Components/SkeletonComponentBase.inl>
|
||||
|
||||
#endif // NAZARA_UTILITY_COMPONENTS_SKELETONCOMPONENTBASE_HPP
|
||||
21
include/Nazara/Utility/Components/SkeletonComponentBase.inl
Normal file
21
include/Nazara/Utility/Components/SkeletonComponentBase.inl
Normal file
@@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Utility/Components/SkeletonComponentBase.hpp>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline SkeletonComponentBase::SkeletonComponentBase(std::shared_ptr<Skeleton> skeleton) :
|
||||
m_referenceSkeleton(std::move(skeleton))
|
||||
{
|
||||
}
|
||||
|
||||
inline const std::shared_ptr<Skeleton>& SkeletonComponentBase::GetSkeleton() const
|
||||
{
|
||||
return m_referenceSkeleton;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/DebugOff.hpp>
|
||||
@@ -29,6 +29,7 @@
|
||||
#ifndef NAZARA_UTILITY_SYSTEMS_HPP
|
||||
#define NAZARA_UTILITY_SYSTEMS_HPP
|
||||
|
||||
#include <Nazara/Utility/Systems/SkeletonSystem.hpp>
|
||||
#include <Nazara/Utility/Systems/VelocitySystem.hpp>
|
||||
|
||||
#endif // NAZARA_UTILITY_SYSTEMS_HPP
|
||||
|
||||
41
include/Nazara/Utility/Systems/SkeletonSystem.hpp
Normal file
41
include/Nazara/Utility/Systems/SkeletonSystem.hpp
Normal file
@@ -0,0 +1,41 @@
|
||||
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_UTILITY_SYSTEMS_SKELETONSYSTEM_HPP
|
||||
#define NAZARA_UTILITY_SYSTEMS_SKELETONSYSTEM_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
#include <entt/entt.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_UTILITY_API SkeletonSystem
|
||||
{
|
||||
public:
|
||||
static constexpr bool AllowConcurrent = false;
|
||||
static constexpr Int64 ExecutionOrder = -1'000;
|
||||
|
||||
SkeletonSystem(entt::registry& registry);
|
||||
SkeletonSystem(const SkeletonSystem&) = delete;
|
||||
SkeletonSystem(SkeletonSystem&&) = delete;
|
||||
~SkeletonSystem();
|
||||
|
||||
void Update(float elapsedTime);
|
||||
|
||||
SkeletonSystem& operator=(const SkeletonSystem&) = delete;
|
||||
SkeletonSystem& operator=(SkeletonSystem&&) = delete;
|
||||
|
||||
private:
|
||||
entt::registry& m_registry;
|
||||
entt::observer m_sharedSkeletonConstructObserver;
|
||||
entt::observer m_skeletonConstructObserver;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/Systems/SkeletonSystem.inl>
|
||||
|
||||
#endif // NAZARA_UTILITY_SYSTEMS_SKELETONSYSTEM_HPP
|
||||
12
include/Nazara/Utility/Systems/SkeletonSystem.inl
Normal file
12
include/Nazara/Utility/Systems/SkeletonSystem.inl
Normal file
@@ -0,0 +1,12 @@
|
||||
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Utility/Systems/SkeletonSystem.hpp>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/DebugOff.hpp>
|
||||
Reference in New Issue
Block a user