Fixed various Physics bugs #217

Merged
direnbharwani merged 14 commits from SP3-2-Physics into main 2022-11-17 17:13:02 +08:00
3 changed files with 22 additions and 23 deletions
Showing only changes of commit 360c55fa2b - Show all commits

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;
}