add basic ah physicsworld
This commit is contained in:
@@ -0,0 +1 @@
|
||||
#include <destrum/Components/Physics/BoxCollider.h>
|
||||
@@ -0,0 +1,45 @@
|
||||
#include <destrum/Components/Physics/Rigidbody.h>
|
||||
|
||||
#include <destrum/Physics/PhysicsWorld.h>
|
||||
|
||||
void Rigidbody::AttachPhysicsBody(PhysicsWorld* world, PhysicsBodyHandle body) {
|
||||
m_World = world;
|
||||
m_Body = body;
|
||||
}
|
||||
|
||||
void Rigidbody::DetachPhysicsBody() {
|
||||
m_World = nullptr;
|
||||
m_Body.Reset();
|
||||
}
|
||||
|
||||
void Rigidbody::AddForce(const glm::vec3& force) {
|
||||
if (!HasPhysicsBody()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_World->AddForce(m_Body, force);
|
||||
}
|
||||
|
||||
void Rigidbody::AddImpulse(const glm::vec3& impulse) {
|
||||
if (!HasPhysicsBody()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_World->AddImpulse(m_Body, impulse);
|
||||
}
|
||||
|
||||
void Rigidbody::SetLinearVelocity(const glm::vec3& velocity) {
|
||||
if (!HasPhysicsBody()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_World->SetLinearVelocity(m_Body, velocity);
|
||||
}
|
||||
|
||||
glm::vec3 Rigidbody::GetLinearVelocity() const {
|
||||
if (!HasPhysicsBody()) {
|
||||
return glm::vec3{0.0f};
|
||||
}
|
||||
|
||||
return m_World->GetLinearVelocity(m_Body);
|
||||
}
|
||||
Reference in New Issue
Block a user