Readded collision tags and moved collision filtering to an earlier stage

This commit is contained in:
Diren D Bharwani 2023-01-02 22:49:12 +08:00
parent 58a44997b2
commit 1f2a9820d1
4 changed files with 11 additions and 9 deletions

View File

@ -66,7 +66,7 @@
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -1.45715916, y: 7, z: 0.64831841}
Translate: {x: -1.45715916, y: 7, z: 0.0329093337}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
@ -136,7 +136,7 @@
DrawColliders: false
Colliders:
- Is Trigger: false
Collision Tag: 1
Collision Tag: 2
Type: Box
Half Extents: {x: 1, y: 1, z: 1}
Friction: 0.400000006

View File

@ -376,6 +376,7 @@ namespace SHADE
{
SHEditorWidgets::CheckBox("Is Trigger", [shape] { return shape->IsTrigger(); }, [shape](bool value) { shape->SetIsTrigger(value); });
SHEditorWidgets::ComboBox("Tag", collisionTagNames, [shape]{return SHCollisionTagMatrix::GetTagIndex(shape->GetCollisionTag().GetName());}, [shape](int const& value){shape->SetCollisionTag(SHCollisionTagMatrix::GetTag(value));});
if(ImGui::CollapsingHeader("Physics Material"))
{

View File

@ -65,13 +65,6 @@ namespace SHADE
if (!collisionTable[TYPE_A][TYPE_B])
return false;
// Filter through tags
const uint16_t TAG_A = A.GetCollisionTag().GetMask();
const uint16_t TAG_B = B.GetCollisionTag().GetMask();
const uint16_t MATCH = TAG_A & TAG_B;
return MATCH > 0;
}
bool SHCollisionDispatcher::Collide(SHManifold& manifold, const SHCollisionShape& A, const SHCollisionShape& B) noexcept

View File

@ -143,6 +143,14 @@ namespace SHADE
// This applies both ways: A -> B and B -> A.
for (auto& [key, narrowphasePair] : narrowphaseBatch)
{
// Filter through tags before attempting narrow-phase
const uint16_t TAG_A = narrowphasePair.A->GetCollisionTag().GetMask();
const uint16_t TAG_B = narrowphasePair.B->GetCollisionTag().GetMask();
const bool MATCH_TAG = TAG_A & TAG_B;
if (!MATCH_TAG)
continue;
const bool IS_A_TRIGGER = narrowphasePair.A->IsTrigger();
const bool IS_B_TRIGGER = narrowphasePair.B->IsTrigger();