Lifebuoy working
This commit is contained in:
@@ -12,7 +12,6 @@ void dd::Systems::PhysicsSystem::ContactListener::BeginContact(b2Contact* contac
|
||||
e.Entity2 = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureB()->GetBody()];
|
||||
e.Normal = glm::normalize(glm::vec2(contact->GetManifold()->localNormal.x, contact->GetManifold()->localNormal.y));
|
||||
e.SignificantNormal = glm::normalize((glm::abs(e.Normal.x) > glm::abs(e.Normal.y)) ? glm::vec2(e.Normal.x, 0) : glm::vec2(0, e.Normal.y));
|
||||
|
||||
m_PhysicsSystem->EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
@@ -29,10 +28,17 @@ void dd::Systems::PhysicsSystem::ContactListener::PreSolve(b2Contact* contact, c
|
||||
auto physicsComponentA = m_PhysicsSystem->m_World->GetComponent<Components::Physics>(entityA);
|
||||
auto physicsComponentB = m_PhysicsSystem->m_World->GetComponent<Components::Physics>(entityB);
|
||||
|
||||
|
||||
std::string propertyA = m_PhysicsSystem->m_World->GetProperty<std::string>(entityA, "Name");
|
||||
std::string propertyB = m_PhysicsSystem->m_World->GetProperty<std::string>(entityB, "Name");
|
||||
|
||||
if (physicsComponentA != nullptr && physicsComponentB != nullptr) {
|
||||
if (physicsComponentA->Calculate || physicsComponentB->Calculate) {
|
||||
// Turn of collisions
|
||||
contact->SetEnabled(false);
|
||||
if ((propertyA != "Lifebuoy" && propertyB != "Pad") || (propertyA != "Pad" && propertyB != "Lifebuoy")) {
|
||||
contact->SetEnabled(false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,10 +34,9 @@ void dd::Systems::PhysicsSystem::InitializeWater()
|
||||
b2ParticleSystemDef m_ParticleSystemDef;
|
||||
m_ParticleSystemDef.radius = radius;
|
||||
m_ParticleSystemDef.gravityScale = gravityScale;
|
||||
m_ParticleSystemDef.density = 4.f;
|
||||
|
||||
m_WaterParticleSystem = m_PhysicsWorld->CreateParticleSystem(&m_ParticleSystemDef);
|
||||
|
||||
|
||||
}
|
||||
|
||||
bool dd::Systems::PhysicsSystem::SetImpulse(const Events::SetImpulse &event)
|
||||
|
||||
Reference in New Issue
Block a user