mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-15 20:08:54 +03:00
Can now add rigidbodies at runtime
This commit is contained in:
@@ -13,18 +13,18 @@ namespace Nuake {
|
||||
|
||||
Ref<Physics::RigidBody> RigidBodyComponent::GetRigidBody() const
|
||||
{
|
||||
return m_Rigidbody;
|
||||
return Rigidbody;
|
||||
}
|
||||
|
||||
void RigidBodyComponent::SyncTransformComponent(TransformComponent* tc)
|
||||
{
|
||||
if (!m_Rigidbody)
|
||||
if (!GetRigidBody())
|
||||
return;
|
||||
}
|
||||
|
||||
void RigidBodyComponent::SyncWithTransform(TransformComponent* tc)
|
||||
{
|
||||
if (!m_Rigidbody)
|
||||
if (!GetRigidBody())
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Nuake {
|
||||
{
|
||||
public:
|
||||
float Mass;
|
||||
Ref<Physics::RigidBody> m_Rigidbody;
|
||||
Ref<Physics::RigidBody> Rigidbody;
|
||||
|
||||
RigidBodyComponent();
|
||||
Ref<Physics::RigidBody> GetRigidBody() const;
|
||||
|
||||
@@ -120,6 +120,8 @@ namespace Nuake
|
||||
if (!Engine::IsPlayMode())
|
||||
return;
|
||||
|
||||
InitializeRigidbodies();
|
||||
|
||||
PhysicsManager::Get().Step(ts);
|
||||
}
|
||||
|
||||
@@ -227,6 +229,11 @@ namespace Nuake
|
||||
Entity ent = Entity({ e, m_Scene });
|
||||
Ref<Physics::RigidBody> rigidBody;
|
||||
|
||||
if (rigidBodyComponent.GetRigidBody())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ent.HasComponent<BoxColliderComponent>())
|
||||
{
|
||||
float mass = rigidBodyComponent.Mass;
|
||||
@@ -276,6 +283,7 @@ namespace Nuake
|
||||
{
|
||||
Logger::Log("Cannot use mesh collider without model component", WARNING);
|
||||
}
|
||||
|
||||
const auto& modelComponent = ent.GetComponent<ModelComponent>();
|
||||
const auto& component = ent.GetComponent<MeshColliderComponent>();
|
||||
|
||||
@@ -293,6 +301,8 @@ namespace Nuake
|
||||
PhysicsManager::Get().RegisterBody(rigidBody);
|
||||
}
|
||||
}
|
||||
|
||||
rigidBodyComponent.Rigidbody = rigidBody;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ namespace Nuake
|
||||
void Exit() override;
|
||||
|
||||
private:
|
||||
|
||||
void InitializeShapes();
|
||||
void InitializeQuakeMap();
|
||||
void InitializeRigidbodies();
|
||||
|
||||
Reference in New Issue
Block a user