parent
e40346513c
commit
d59f4e88c2
|
@ -12,6 +12,7 @@
|
||||||
Type: Dynamic
|
Type: Dynamic
|
||||||
Drag: 0.00999999978
|
Drag: 0.00999999978
|
||||||
Angular Drag: 0.100000001
|
Angular Drag: 0.100000001
|
||||||
|
Gravity Scale: 0.100000001
|
||||||
Use Gravity: true
|
Use Gravity: true
|
||||||
Interpolate: false
|
Interpolate: false
|
||||||
Sleeping Enabled: true
|
Sleeping Enabled: true
|
||||||
|
@ -75,10 +76,10 @@
|
||||||
Yaw: 0
|
Yaw: 0
|
||||||
Roll: 0
|
Roll: 0
|
||||||
Width: 1920
|
Width: 1920
|
||||||
Height: 1080
|
|
||||||
Near: 0.00999999978
|
Near: 0.00999999978
|
||||||
Far: 10000
|
Far: 10000
|
||||||
Perspective: true
|
Perspective: true
|
||||||
|
FOV: 90
|
||||||
IsActive: true
|
IsActive: true
|
||||||
Scripts: ~
|
Scripts: ~
|
||||||
- EID: 65539
|
- EID: 65539
|
||||||
|
@ -187,6 +188,7 @@
|
||||||
Type: Dynamic
|
Type: Dynamic
|
||||||
Drag: 0.00999999978
|
Drag: 0.00999999978
|
||||||
Angular Drag: 0.100000001
|
Angular Drag: 0.100000001
|
||||||
|
Gravity Scale: 1
|
||||||
Use Gravity: true
|
Use Gravity: true
|
||||||
Interpolate: true
|
Interpolate: true
|
||||||
Sleeping Enabled: true
|
Sleeping Enabled: true
|
||||||
|
|
|
@ -263,6 +263,10 @@ namespace SHADE
|
||||||
if(rbType == SHRigidBodyComponent::Type::DYNAMIC) //Dynamic only fields
|
if(rbType == SHRigidBodyComponent::Type::DYNAMIC) //Dynamic only fields
|
||||||
{
|
{
|
||||||
SHEditorWidgets::CheckBox("Use Gravity", [component]{return component->IsGravityEnabled();}, [component](bool const& value){component->SetGravityEnabled(value);}, "Gravity");
|
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");
|
//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
|
if (rbType == SHRigidBodyComponent::Type::DYNAMIC || rbType == SHRigidBodyComponent::Type::KINEMATIC) //Dynamic or Kinematic only fields
|
||||||
|
|
|
@ -297,6 +297,7 @@ namespace SHADE
|
||||||
rigidBodyComponent->SetInterpolate (rigidBodyComponent->IsInterpolating());
|
rigidBodyComponent->SetInterpolate (rigidBodyComponent->IsInterpolating());
|
||||||
rigidBodyComponent->SetDrag (rigidBodyComponent->GetDrag());
|
rigidBodyComponent->SetDrag (rigidBodyComponent->GetDrag());
|
||||||
rigidBodyComponent->SetAngularDrag (rigidBodyComponent->GetAngularDrag());
|
rigidBodyComponent->SetAngularDrag (rigidBodyComponent->GetAngularDrag());
|
||||||
|
rigidBodyComponent->SetGravityScale (rigidBodyComponent->GetGravityScale());
|
||||||
|
|
||||||
rigidBodyQueue.pop();
|
rigidBodyQueue.pop();
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,6 +114,11 @@ namespace SHADE
|
||||||
return angularDrag;
|
return angularDrag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float SHRigidBodyComponent::GetGravityScale() const noexcept
|
||||||
|
{
|
||||||
|
return gravityScale;
|
||||||
|
}
|
||||||
|
|
||||||
SHVec3 SHRigidBodyComponent::GetForce() const noexcept
|
SHVec3 SHRigidBodyComponent::GetForce() const noexcept
|
||||||
{
|
{
|
||||||
return rigidBody ? SHVec3{ rigidBody->getForce() } : SHVec3::Zero;
|
return rigidBody ? SHVec3{ rigidBody->getForce() } : SHVec3::Zero;
|
||||||
|
@ -297,6 +302,15 @@ namespace SHADE
|
||||||
rigidBody->setAngularDamping(newAngularDrag);
|
rigidBody->setAngularDamping(newAngularDrag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SHRigidBodyComponent::SetGravityScale(float newGravityScale) noexcept
|
||||||
|
{
|
||||||
|
gravityScale = newGravityScale;
|
||||||
|
|
||||||
|
if (rigidBody)
|
||||||
|
rigidBody->setGravityScale(newGravityScale);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SHRigidBodyComponent::SetLinearVelocity(const SHVec3& newLinearVelocity) noexcept
|
void SHRigidBodyComponent::SetLinearVelocity(const SHVec3& newLinearVelocity) noexcept
|
||||||
{
|
{
|
||||||
if (type == Type::STATIC)
|
if (type == Type::STATIC)
|
||||||
|
@ -408,6 +422,7 @@ RTTR_REGISTRATION
|
||||||
.property("Type" , &SHRigidBodyComponent::GetType , &SHRigidBodyComponent::SetType )
|
.property("Type" , &SHRigidBodyComponent::GetType , &SHRigidBodyComponent::SetType )
|
||||||
.property("Drag" , &SHRigidBodyComponent::GetDrag , &SHRigidBodyComponent::SetDrag )
|
.property("Drag" , &SHRigidBodyComponent::GetDrag , &SHRigidBodyComponent::SetDrag )
|
||||||
.property("Angular Drag" , &SHRigidBodyComponent::GetAngularDrag , &SHRigidBodyComponent::SetAngularDrag )
|
.property("Angular Drag" , &SHRigidBodyComponent::GetAngularDrag , &SHRigidBodyComponent::SetAngularDrag )
|
||||||
|
.property("Gravity Scale" , &SHRigidBodyComponent::GetGravityScale , &SHRigidBodyComponent::SetGravityScale )
|
||||||
.property("Use Gravity" , &SHRigidBodyComponent::IsGravityEnabled , &SHRigidBodyComponent::SetGravityEnabled )
|
.property("Use Gravity" , &SHRigidBodyComponent::IsGravityEnabled , &SHRigidBodyComponent::SetGravityEnabled )
|
||||||
.property("Interpolate" , &SHRigidBodyComponent::IsInterpolating , &SHRigidBodyComponent::SetInterpolate )
|
.property("Interpolate" , &SHRigidBodyComponent::IsInterpolating , &SHRigidBodyComponent::SetInterpolate )
|
||||||
.property("Sleeping Enabled" , &SHRigidBodyComponent::IsAllowedToSleep , &SHRigidBodyComponent::SetIsAllowedToSleep)
|
.property("Sleeping Enabled" , &SHRigidBodyComponent::IsAllowedToSleep , &SHRigidBodyComponent::SetIsAllowedToSleep)
|
||||||
|
|
|
@ -93,6 +93,7 @@ namespace SHADE
|
||||||
[[nodiscard]] float GetMass () const noexcept;
|
[[nodiscard]] float GetMass () const noexcept;
|
||||||
[[nodiscard]] float GetDrag () const noexcept;
|
[[nodiscard]] float GetDrag () const noexcept;
|
||||||
[[nodiscard]] float GetAngularDrag () const noexcept;
|
[[nodiscard]] float GetAngularDrag () const noexcept;
|
||||||
|
[[nodiscard]] float GetGravityScale () const noexcept;
|
||||||
|
|
||||||
[[nodiscard]] SHVec3 GetForce () const noexcept;
|
[[nodiscard]] SHVec3 GetForce () const noexcept;
|
||||||
[[nodiscard]] SHVec3 GetTorque () const noexcept;
|
[[nodiscard]] SHVec3 GetTorque () const noexcept;
|
||||||
|
@ -123,6 +124,7 @@ namespace SHADE
|
||||||
|
|
||||||
void SetDrag (float newDrag) noexcept;
|
void SetDrag (float newDrag) noexcept;
|
||||||
void SetAngularDrag (float newAngularDrag) noexcept;
|
void SetAngularDrag (float newAngularDrag) noexcept;
|
||||||
|
void SetGravityScale (float newGravityScale) noexcept;
|
||||||
|
|
||||||
void SetLinearVelocity (const SHVec3& newLinearVelocity) noexcept;
|
void SetLinearVelocity (const SHVec3& newLinearVelocity) noexcept;
|
||||||
void SetAngularVelocity (const SHVec3& newAngularVelocity) noexcept;
|
void SetAngularVelocity (const SHVec3& newAngularVelocity) noexcept;
|
||||||
|
@ -173,6 +175,7 @@ namespace SHADE
|
||||||
|
|
||||||
// Used for storing serialised data
|
// Used for storing serialised data
|
||||||
uint8_t flags; // aZ aY aX lZ lY lX sleepEnabled gravity
|
uint8_t flags; // aZ aY aX lZ lY lX sleepEnabled gravity
|
||||||
|
float gravityScale;
|
||||||
float drag;
|
float drag;
|
||||||
float angularDrag;
|
float angularDrag;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue