Added Capsule Collider, AABB Query & SimulateBody for Trajectory path prediction #402

Merged
direnbharwani merged 13 commits from SP3-2-Physics into main 2023-03-07 20:11:22 +08:00
5 changed files with 26 additions and 1 deletions
Showing only changes of commit d59f4e88c2 - Show all commits

View File

@ -12,6 +12,7 @@
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.100000001
Gravity Scale: 0.100000001
Use Gravity: true
Interpolate: false
Sleeping Enabled: true
@ -75,10 +76,10 @@
Yaw: 0
Roll: 0
Width: 1920
Height: 1080
Near: 0.00999999978
Far: 10000
Perspective: true
FOV: 90
IsActive: true
Scripts: ~
- EID: 65539
@ -187,6 +188,7 @@
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.100000001
Gravity Scale: 1
Use Gravity: true
Interpolate: true
Sleeping Enabled: true

View File

@ -263,6 +263,10 @@ namespace SHADE
if(rbType == SHRigidBodyComponent::Type::DYNAMIC) //Dynamic only fields
{
SHEditorWidgets::CheckBox("Use Gravity", [component]{return component->IsGravityEnabled();}, [component](bool const& value){component->SetGravityEnabled(value);}, "Gravity");
if (component->IsGravityEnabled())
SHEditorWidgets::DragFloat("Gravity Scale", [component] {return component->GetGravityScale(); }, [component](float const& value) {component->SetGravityScale(value); }, "Gravity Scale");
//SHEditorWidgets::DragFloat("Mass", [component] {return component->GetMass(); }, [component](float const& value) {component->SetMass(value); }, "Mass");
}
if (rbType == SHRigidBodyComponent::Type::DYNAMIC || rbType == SHRigidBodyComponent::Type::KINEMATIC) //Dynamic or Kinematic only fields

View File

@ -297,6 +297,7 @@ namespace SHADE
rigidBodyComponent->SetInterpolate (rigidBodyComponent->IsInterpolating());
rigidBodyComponent->SetDrag (rigidBodyComponent->GetDrag());
rigidBodyComponent->SetAngularDrag (rigidBodyComponent->GetAngularDrag());
rigidBodyComponent->SetGravityScale (rigidBodyComponent->GetGravityScale());
rigidBodyQueue.pop();
}

View File

@ -114,6 +114,11 @@ namespace SHADE
return angularDrag;
}
float SHRigidBodyComponent::GetGravityScale() const noexcept
{
return gravityScale;
}
SHVec3 SHRigidBodyComponent::GetForce() const noexcept
{
return rigidBody ? SHVec3{ rigidBody->getForce() } : SHVec3::Zero;
@ -297,6 +302,15 @@ namespace SHADE
rigidBody->setAngularDamping(newAngularDrag);
}
void SHRigidBodyComponent::SetGravityScale(float newGravityScale) noexcept
{
gravityScale = newGravityScale;
if (rigidBody)
rigidBody->setGravityScale(newGravityScale);
}
void SHRigidBodyComponent::SetLinearVelocity(const SHVec3& newLinearVelocity) noexcept
{
if (type == Type::STATIC)
@ -408,6 +422,7 @@ RTTR_REGISTRATION
.property("Type" , &SHRigidBodyComponent::GetType , &SHRigidBodyComponent::SetType )
.property("Drag" , &SHRigidBodyComponent::GetDrag , &SHRigidBodyComponent::SetDrag )
.property("Angular Drag" , &SHRigidBodyComponent::GetAngularDrag , &SHRigidBodyComponent::SetAngularDrag )
.property("Gravity Scale" , &SHRigidBodyComponent::GetGravityScale , &SHRigidBodyComponent::SetGravityScale )
.property("Use Gravity" , &SHRigidBodyComponent::IsGravityEnabled , &SHRigidBodyComponent::SetGravityEnabled )
.property("Interpolate" , &SHRigidBodyComponent::IsInterpolating , &SHRigidBodyComponent::SetInterpolate )
.property("Sleeping Enabled" , &SHRigidBodyComponent::IsAllowedToSleep , &SHRigidBodyComponent::SetIsAllowedToSleep)

View File

@ -93,6 +93,7 @@ namespace SHADE
[[nodiscard]] float GetMass () const noexcept;
[[nodiscard]] float GetDrag () const noexcept;
[[nodiscard]] float GetAngularDrag () const noexcept;
[[nodiscard]] float GetGravityScale () const noexcept;
[[nodiscard]] SHVec3 GetForce () const noexcept;
[[nodiscard]] SHVec3 GetTorque () const noexcept;
@ -123,6 +124,7 @@ namespace SHADE
void SetDrag (float newDrag) noexcept;
void SetAngularDrag (float newAngularDrag) noexcept;
void SetGravityScale (float newGravityScale) noexcept;
void SetLinearVelocity (const SHVec3& newLinearVelocity) noexcept;
void SetAngularVelocity (const SHVec3& newAngularVelocity) noexcept;
@ -173,6 +175,7 @@ namespace SHADE
// Used for storing serialised data
uint8_t flags; // aZ aY aX lZ lY lX sleepEnabled gravity
float gravityScale;
float drag;
float angularDrag;