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); return flags & (1U << FLAG_POS);
} }
bool SHRigidBodyComponent::GetAutoMass() const noexcept //bool SHRigidBodyComponent::GetAutoMass() const noexcept
{ //{
static constexpr int FLAG_POS = 9; // static constexpr int FLAG_POS = 9;
return flags & (1U << FLAG_POS); // return flags & (1U << FLAG_POS);
} //}
float SHRigidBodyComponent::GetMass() const noexcept float SHRigidBodyComponent::GetMass() const noexcept
{ {
@ -314,14 +314,13 @@ namespace SHADE
allowInterpolation ? flags |= 1U << FLAG_POS : flags &= ~(1U << FLAG_POS); allowInterpolation ? flags |= 1U << FLAG_POS : flags &= ~(1U << FLAG_POS);
} }
void SHRigidBodyComponent::SetAutoMass(bool autoMass) noexcept //void SHRigidBodyComponent::SetAutoMass(bool autoMass) noexcept
{ //{
static constexpr int FLAG_POS = 9; // static constexpr int FLAG_POS = 9;
autoMass ? flags |= 1U << FLAG_POS : flags &= ~(1U << FLAG_POS); // autoMass ? flags |= 1U << FLAG_POS : flags &= ~(1U << FLAG_POS);
dirtyFlags |= 1U << FLAG_POS;
}
// dirtyFlags |= 1U << FLAG_POS;
//}
void SHRigidBodyComponent::SetMass(float newMass) noexcept void SHRigidBodyComponent::SetMass(float newMass) noexcept
{ {
@ -496,7 +495,7 @@ RTTR_REGISTRATION
.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)
.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 X" , &SHRigidBodyComponent::GetFreezePositionX , &SHRigidBodyComponent::SetFreezePositionX )
.property("Freeze Position Y" , &SHRigidBodyComponent::GetFreezePositionY , &SHRigidBodyComponent::SetFreezePositionY ) .property("Freeze Position Y" , &SHRigidBodyComponent::GetFreezePositionY , &SHRigidBodyComponent::SetFreezePositionY )
.property("Freeze Position Z" , &SHRigidBodyComponent::GetFreezePositionZ , &SHRigidBodyComponent::SetFreezePositionZ ) .property("Freeze Position Z" , &SHRigidBodyComponent::GetFreezePositionZ , &SHRigidBodyComponent::SetFreezePositionZ )

View File

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

View File

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