Disabled automass on rigid bodies

This commit is contained in:
Diren D Bharwani 2022-11-17 12:27:00 +08:00
parent 18218443ec
commit 360c55fa2b
3 changed files with 22 additions and 23 deletions

View File

@ -113,11 +113,11 @@ namespace SHADE
return flags & (1U << FLAG_POS);
}
bool SHRigidBodyComponent::GetAutoMass() const noexcept
{
static constexpr int FLAG_POS = 9;
return flags & (1U << FLAG_POS);
}
//bool SHRigidBodyComponent::GetAutoMass() const noexcept
//{
// static constexpr int FLAG_POS = 9;
// return flags & (1U << FLAG_POS);
//}
float SHRigidBodyComponent::GetMass() const noexcept
{
@ -314,14 +314,13 @@ namespace SHADE
allowInterpolation ? flags |= 1U << FLAG_POS : flags &= ~(1U << FLAG_POS);
}
void SHRigidBodyComponent::SetAutoMass(bool autoMass) noexcept
{
static constexpr int FLAG_POS = 9;
autoMass ? flags |= 1U << FLAG_POS : flags &= ~(1U << FLAG_POS);
dirtyFlags |= 1U << FLAG_POS;
}
//void SHRigidBodyComponent::SetAutoMass(bool autoMass) noexcept
//{
// static constexpr int FLAG_POS = 9;
// autoMass ? flags |= 1U << FLAG_POS : flags &= ~(1U << FLAG_POS);
// dirtyFlags |= 1U << FLAG_POS;
//}
void SHRigidBodyComponent::SetMass(float newMass) noexcept
{
@ -496,7 +495,7 @@ RTTR_REGISTRATION
.property("Use Gravity" , &SHRigidBodyComponent::IsGravityEnabled , &SHRigidBodyComponent::SetGravityEnabled )
.property("Interpolate" , &SHRigidBodyComponent::IsInterpolating , &SHRigidBodyComponent::SetInterpolate )
.property("Sleeping Enabled" , &SHRigidBodyComponent::IsAllowedToSleep , &SHRigidBodyComponent::SetIsAllowedToSleep)
.property("Auto Mass" , &SHRigidBodyComponent::GetAutoMass , &SHRigidBodyComponent::SetAutoMass )
//.property("Auto Mass" , &SHRigidBodyComponent::GetAutoMass , &SHRigidBodyComponent::SetAutoMass )
.property("Freeze Position X" , &SHRigidBodyComponent::GetFreezePositionX , &SHRigidBodyComponent::SetFreezePositionX )
.property("Freeze Position Y" , &SHRigidBodyComponent::GetFreezePositionY , &SHRigidBodyComponent::SetFreezePositionY )
.property("Freeze Position Z" , &SHRigidBodyComponent::GetFreezePositionZ , &SHRigidBodyComponent::SetFreezePositionZ )

View File

@ -82,7 +82,7 @@ namespace SHADE
[[nodiscard]] bool GetFreezeRotationY () const noexcept;
[[nodiscard]] bool GetFreezeRotationZ () const noexcept;
[[nodiscard]] bool GetAutoMass () const noexcept;
//[[nodiscard]] bool GetAutoMass () const noexcept;
[[nodiscard]] float GetMass () const noexcept;
[[nodiscard]] float GetDrag () const noexcept;
@ -112,7 +112,7 @@ namespace SHADE
void SetFreezeRotationY (bool freezeRotationY) noexcept;
void SetFreezeRotationZ (bool freezeRotationZ) noexcept;
void SetInterpolate (bool allowInterpolation) noexcept;
void SetAutoMass (bool autoMass) noexcept;
//void SetAutoMass (bool autoMass) noexcept;
void SetMass (float newMass) noexcept;
void SetDrag (float newDrag) noexcept;

View File

@ -254,17 +254,17 @@ namespace SHADE
}
case 9: // Mass
{
if (component.GetAutoMass())
{
rp3dBody->updateMassPropertiesFromColliders();
component.mass = rp3dBody->getMass();
}
else
{
//if (component.GetAutoMass())
//{
// rp3dBody->updateMassPropertiesFromColliders();
// component.mass = rp3dBody->getMass();
//}
//else
//{
rp3dBody->setMass(component.mass);
rp3dBody->updateLocalCenterOfMassFromColliders();
rp3dBody->updateLocalInertiaTensorFromColliders();
}
//}
break;
}