Added Collision Tags #233
|
@ -174,6 +174,7 @@ namespace Sandbox
|
|||
SHSystemManager::RunRoutines(editor->editorState != SHEditor::State::PLAY, 0.016f);
|
||||
editor->PollPicking();
|
||||
|
||||
// TODO: Move into an Editor menu
|
||||
static bool drawColliders = false;
|
||||
if (SHInputManager::GetKeyDown(SHInputManager::SH_KEYCODE::F10))
|
||||
{
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace SHADE
|
|||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
SHCollisionTag::SHCollisionTag() noexcept
|
||||
: mask { SHUtilities::ConvertEnum(eTag::ALL_TAGS) }
|
||||
: mask { SHUtilities::ConvertEnum(eTag::TAG_1) }
|
||||
{}
|
||||
|
||||
SHCollisionTag::SHCollisionTag(uint16_t tagValue) noexcept
|
||||
|
|
|
@ -251,12 +251,6 @@ namespace SHADE
|
|||
collisionTags = newCollisionTag;
|
||||
}
|
||||
|
||||
void SHCollisionShape::SetCollisionTags(SHCollisionTag::eTag newCollisionTag) noexcept
|
||||
{
|
||||
dirty = true;
|
||||
collisionTags = SHCollisionTag{ newCollisionTag };
|
||||
}
|
||||
|
||||
void SHCollisionShape::SetFriction(float friction) noexcept
|
||||
{
|
||||
dirty = true;
|
||||
|
|
|
@ -96,7 +96,6 @@ namespace SHADE
|
|||
|
||||
void SetIsTrigger (bool isTrigger) noexcept;
|
||||
void SetCollisionTags (const SHCollisionTag& newCollisionTag) noexcept;
|
||||
void SetCollisionTags (SHCollisionTag::eTag newCollisionTag) noexcept;
|
||||
void SetFriction (float friction) noexcept;
|
||||
void SetBounciness (float bounciness) noexcept;
|
||||
void SetDensity (float density) noexcept;
|
||||
|
|
|
@ -254,6 +254,10 @@ namespace SHADE
|
|||
}
|
||||
case 9: // Mass
|
||||
{
|
||||
rp3dBody->setMass(component.mass);
|
||||
rp3dBody->updateLocalCenterOfMassFromColliders();
|
||||
rp3dBody->updateLocalInertiaTensorFromColliders();
|
||||
|
||||
//if (component.GetAutoMass())
|
||||
//{
|
||||
// rp3dBody->updateMassPropertiesFromColliders();
|
||||
|
@ -261,9 +265,9 @@ namespace SHADE
|
|||
//}
|
||||
//else
|
||||
//{
|
||||
rp3dBody->setMass(component.mass);
|
||||
rp3dBody->updateLocalCenterOfMassFromColliders();
|
||||
rp3dBody->updateLocalInertiaTensorFromColliders();
|
||||
// rp3dBody->setMass(component.mass);
|
||||
// rp3dBody->updateLocalCenterOfMassFromColliders();
|
||||
// rp3dBody->updateLocalInertiaTensorFromColliders();
|
||||
//}
|
||||
|
||||
break;
|
||||
|
@ -309,10 +313,18 @@ namespace SHADE
|
|||
default: break;
|
||||
}
|
||||
|
||||
syncMaterial(i, collisionShape);
|
||||
// Sync material
|
||||
auto* rp3dCollider = rp3dBody->getCollider(i);
|
||||
auto& rp3dMaterial = rp3dCollider->getMaterial();
|
||||
|
||||
rp3dMaterial.setFrictionCoefficient(collisionShape.GetFriction());
|
||||
rp3dMaterial.setBounciness(collisionShape.GetBounciness());
|
||||
rp3dMaterial.setMassDensity(collisionShape.GetDensity());
|
||||
|
||||
// Sync tags
|
||||
|
||||
const unsigned short MASK_BITS = collisionShape.GetCollisionTags();
|
||||
rp3dCollider->setCollisionCategoryBits(MASK_BITS);
|
||||
rp3dCollider->setCollideWithMaskBits(MASK_BITS);
|
||||
|
||||
collisionShape.dirty = false;
|
||||
}
|
||||
|
@ -322,19 +334,6 @@ namespace SHADE
|
|||
/* Private Function Member Definitions */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void SHPhysicsObject::syncMaterial(int colliderIndex, SHCollisionShape& collisionShape) const noexcept
|
||||
{
|
||||
auto& rp3dMaterial = rp3dBody->getCollider(colliderIndex)->getMaterial();
|
||||
rp3dMaterial.setFrictionCoefficient(collisionShape.GetFriction());
|
||||
rp3dMaterial.setBounciness(collisionShape.GetBounciness());
|
||||
rp3dMaterial.setMassDensity(collisionShape.GetDensity());
|
||||
}
|
||||
|
||||
void SHPhysicsObject::syncTags(int colliderIndex, SHCollisionShape& collisionShape) const noexcept
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SHPhysicsObject::addBoxShape(SHCollisionShape& boxShape) const noexcept
|
||||
{
|
||||
const rp3d::Transform OFFSETS
|
||||
|
|
|
@ -96,9 +96,6 @@ namespace SHADE
|
|||
/* Function Members */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
|
||||
void syncMaterial (int colliderIndex, SHCollisionShape& collisionShape) const noexcept;
|
||||
void syncTags (int colliderIndex, SHCollisionShape& collisionShape) const noexcept;
|
||||
|
||||
// Box Shapes
|
||||
|
||||
void addBoxShape (SHCollisionShape& boxShape) const noexcept;
|
||||
|
|
Loading…
Reference in New Issue