Merge branch 'water'
This commit is contained in:
@@ -33,8 +33,10 @@ namespace Components
|
|||||||
|
|
||||||
struct Particle : public Component
|
struct Particle : public Component
|
||||||
{
|
{
|
||||||
float Radius = 0.5f;
|
EntityID ParticleSystem;
|
||||||
float LifeTime = 5.0f;
|
glm::vec3 Scale = glm::vec3(1.f);
|
||||||
|
double TimeLived = 0;
|
||||||
|
double LifeTime = 5;
|
||||||
|
|
||||||
ParticleFlags::Type Flags = static_cast<ParticleFlags::Type>(
|
ParticleFlags::Type Flags = static_cast<ParticleFlags::Type>(
|
||||||
ParticleFlags::Water
|
ParticleFlags::Water
|
||||||
|
|||||||
@@ -21,6 +21,11 @@ struct ParticleEmitter : public Component
|
|||||||
float Spread = 0.f;
|
float Spread = 0.f;
|
||||||
float Speed = 2.f;
|
float Speed = 2.f;
|
||||||
double LifeTime = 100;
|
double LifeTime = 100;
|
||||||
|
float RadiusDistribution = 0;
|
||||||
|
|
||||||
|
//values to interpolate between.
|
||||||
|
std::vector<glm::vec3> ScaleValues;
|
||||||
|
std::vector<float> AlphaValues;
|
||||||
|
|
||||||
//System variables
|
//System variables
|
||||||
float GravityScale = 1.0f;
|
float GravityScale = 1.0f;
|
||||||
|
|||||||
@@ -22,14 +22,18 @@ struct CreateParticleSequence : public Event
|
|||||||
float Spread = 1.f;
|
float Spread = 1.f;
|
||||||
float EmittingAngle = 0.f;
|
float EmittingAngle = 0.f;
|
||||||
float MaxCount = 0;
|
float MaxCount = 0;
|
||||||
|
float RadiusDistribution = 0;
|
||||||
glm::vec4 Color = glm::vec4(0);
|
glm::vec4 Color = glm::vec4(0);
|
||||||
EntityID parent = 0;
|
EntityID parent = 0;
|
||||||
|
// values to interpolate between.
|
||||||
|
std::vector<glm::vec3> ScaleValues;
|
||||||
|
std::vector<float> AlphaValues;
|
||||||
|
|
||||||
//Particle
|
//Particle
|
||||||
std::string SpriteFile = "";
|
std::string SpriteFile = "";
|
||||||
double ParticleLifeTime = 3.f;
|
double ParticleLifeTime = 3.f;
|
||||||
ParticleFlags::Type Flags = static_cast<ParticleFlags::Type>(ParticleFlags::Powder | ParticleFlags::ParticleContactFilter | ParticleFlags::FixtureContactFilter);
|
ParticleFlags::Type Flags = static_cast<ParticleFlags::Type>(ParticleFlags::Powder | ParticleFlags::ParticleContactFilter | ParticleFlags::FixtureContactFilter);
|
||||||
float Radius = 1.f;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace dd
|
|||||||
class PhysicsSystem : public System
|
class PhysicsSystem : public System
|
||||||
{
|
{
|
||||||
friend class ContractListener;
|
friend class ContractListener;
|
||||||
friend class DestructionListener;
|
//friend class DestructionListener;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PhysicsSystem(World* world, std::shared_ptr<dd::EventBroker> eventBroker)
|
PhysicsSystem(World* world, std::shared_ptr<dd::EventBroker> eventBroker)
|
||||||
@@ -106,6 +106,9 @@ namespace dd
|
|||||||
b2ParticleSystem* CreateParticleSystem(float radius, float gravityScale, int maxCount);
|
b2ParticleSystem* CreateParticleSystem(float radius, float gravityScale, int maxCount);
|
||||||
void CreateParticleEmitter(EntityID entity);
|
void CreateParticleEmitter(EntityID entity);
|
||||||
void UpdateParticleEmitters(double dt); //TODO: Remove them and particles if needed.
|
void UpdateParticleEmitters(double dt); //TODO: Remove them and particles if needed.
|
||||||
|
float ScalarInterpolation(float timeProgress, std::vector<float> spectrum);
|
||||||
|
glm::vec3 VectorInterpolation(float timeProgress, std::vector<glm::vec3> spectrum);
|
||||||
|
|
||||||
|
|
||||||
EventRelay<PhysicsSystem, Events::SetImpulse> m_SetImpulse;
|
EventRelay<PhysicsSystem, Events::SetImpulse> m_SetImpulse;
|
||||||
bool SetImpulse(const Events::SetImpulse &event);
|
bool SetImpulse(const Events::SetImpulse &event);
|
||||||
@@ -128,36 +131,36 @@ namespace dd
|
|||||||
std::list<Impulse> m_Impulses;
|
std::list<Impulse> m_Impulses;
|
||||||
|
|
||||||
|
|
||||||
class DestructionListener : public b2DestructionListener
|
// class DestructionListener : public b2DestructionListener
|
||||||
{
|
// {
|
||||||
public:
|
// public:
|
||||||
DestructionListener(PhysicsSystem* physicsSystem)
|
// DestructionListener(PhysicsSystem* physicsSystem)
|
||||||
: m_PhysicsSystem(physicsSystem) { }
|
// : m_PhysicsSystem(physicsSystem) { }
|
||||||
|
//
|
||||||
void SayGoodbye(b2Joint*) {LOG_INFO("joint körs");};
|
// void SayGoodbye(b2Joint*) {LOG_INFO("joint körs");};
|
||||||
void SayGoodbye(b2Fixture*) {/*LOG_INFO("Fixture körs");*/};
|
// void SayGoodbye(b2Fixture*) {/*LOG_INFO("Fixture körs");*/};
|
||||||
|
//
|
||||||
void SayGoodbye(b2ParticleSystem* particleSystem, int32 index) override
|
// void SayGoodbye(b2ParticleSystem* particleSystem, int32 index) override
|
||||||
{
|
// {
|
||||||
LOG_INFO("Particle ded");
|
// // LOG_INFO("Particle ded");
|
||||||
|
// //
|
||||||
|
// //
|
||||||
const b2ParticleHandle* handle = particleSystem->GetParticleHandleFromIndex(index);
|
// // const b2ParticleHandle* handle = particleSystem->GetParticleHandleFromIndex(index);
|
||||||
for (int i = 0; i < m_PhysicsSystem->m_ParticleEmitters.ParticleSystem.size(); i++) {
|
// // for (int i = 0; i < m_PhysicsSystem->m_ParticleEmitters.ParticleSystem.size(); i++) {
|
||||||
if(m_PhysicsSystem->m_ParticleEmitters.ParticleSystem[i] == particleSystem) {
|
// // if(m_PhysicsSystem->m_ParticleEmitters.ParticleSystem[i] == particleSystem) {
|
||||||
std::unordered_map<const b2ParticleHandle*, EntityID>::iterator it = m_PhysicsSystem->m_ParticleHandleToEntities[i].find(handle);
|
// // std::unordered_map<const b2ParticleHandle*, EntityID>::iterator it = m_PhysicsSystem->m_ParticleHandleToEntities[i].find(handle);
|
||||||
if(it != m_PhysicsSystem->m_ParticleHandleToEntities[i].end()) {
|
// // if(it != m_PhysicsSystem->m_ParticleHandleToEntities[i].end()) {
|
||||||
EntityID id = it->second;
|
// // EntityID id = it->second;
|
||||||
m_PhysicsSystem->m_World->RemoveEntity(id);
|
// // m_PhysicsSystem->m_World->RemoveEntity(id);
|
||||||
m_PhysicsSystem->m_ParticleHandleToEntities[i].erase(it);
|
// // m_PhysicsSystem->m_ParticleHandleToEntities[i].erase(it);
|
||||||
LOG_INFO("Removing from list");
|
// // LOG_INFO("Removing from list");
|
||||||
}
|
// // }
|
||||||
}
|
// // }
|
||||||
}
|
// // }
|
||||||
}
|
// }
|
||||||
private:
|
// private:
|
||||||
PhysicsSystem* m_PhysicsSystem;
|
// PhysicsSystem* m_PhysicsSystem;
|
||||||
};
|
// };
|
||||||
|
|
||||||
class ParticleContactDisabler : public b2ContactFilter
|
class ParticleContactDisabler : public b2ContactFilter
|
||||||
{
|
{
|
||||||
@@ -195,7 +198,7 @@ namespace dd
|
|||||||
PhysicsSystem* m_PhysicsSystem;
|
PhysicsSystem* m_PhysicsSystem;
|
||||||
};
|
};
|
||||||
|
|
||||||
DestructionListener* m_DestructionListener;
|
//DestructionListener* m_DestructionListener;
|
||||||
ParticleContactDisabler* m_ParticleContactDisabler;
|
ParticleContactDisabler* m_ParticleContactDisabler;
|
||||||
ContactListener* m_ContactListener;
|
ContactListener* m_ContactListener;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event)
|
|||||||
} else if (ballTransform->Position.x <= -2.7f) {
|
} else if (ballTransform->Position.x <= -2.7f) {
|
||||||
particleEvent.Position = glm::vec3(-2.7f, -3.f, -3.f);
|
particleEvent.Position = glm::vec3(-2.7f, -3.f, -3.f);
|
||||||
}
|
}
|
||||||
particleEvent.Radius = 1.f;
|
particleEvent.ScaleValues.push_back(glm::vec3(1.f));
|
||||||
particleEvent.Color = glm::vec4(1.f);
|
particleEvent.Color = glm::vec4(1.f);
|
||||||
particleEvent.Speed = 0;
|
particleEvent.Speed = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -286,6 +286,7 @@ bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
|
|||||||
brick->Removed = true;
|
brick->Removed = true;
|
||||||
m_World->RemoveEntity(entityShot);
|
m_World->RemoveEntity(entityShot);
|
||||||
BrickHit(entityShot, entityBrick, 1);
|
BrickHit(entityShot, entityBrick, 1);
|
||||||
|
//ep.Radius = 0.05;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -393,6 +394,45 @@ void dd::Systems::LevelSystem::BrickHit(EntityID entityHitter, EntityID entityBr
|
|||||||
m_World->RemoveComponent<Components::Template>(b);
|
m_World->RemoveComponent<Components::Template>(b);
|
||||||
m_World->SetEntityParent(b, 0);
|
m_World->SetEntityParent(b, 0);
|
||||||
m_World->CommitEntity(b);
|
m_World->CommitEntity(b);
|
||||||
|
|
||||||
|
//Particle trail
|
||||||
|
Events::CreateParticleSequence trail;
|
||||||
|
trail.parent = b;
|
||||||
|
trail.AlphaValues.push_back(1.f);
|
||||||
|
trail.AlphaValues.push_back(0.f);
|
||||||
|
trail.ScaleValues.push_back(glm::vec3(0.08f));
|
||||||
|
trail.ScaleValues.push_back(glm::vec3(0.f));
|
||||||
|
trail.RadiusDistribution = 1;
|
||||||
|
trail.EmitterLifeTime = 2.f;
|
||||||
|
trail.ParticleLifeTime = 1.f;
|
||||||
|
trail.ParticlesPerTick = 1;
|
||||||
|
trail.SpawnRate = 0.1f;
|
||||||
|
trail.Speed = 10.f;
|
||||||
|
trail.EmittingAngle = glm::half_pi<float>();
|
||||||
|
trail.SpriteFile = "Textures/Particles/FadeBall.png";
|
||||||
|
trail.Color = brickModel->Color;
|
||||||
|
//p.Spread = ...
|
||||||
|
EventBroker->Publish(trail);
|
||||||
|
|
||||||
|
//ParticlePoof
|
||||||
|
Events::CreateParticleSequence poof;
|
||||||
|
poof.EmitterLifeTime = 4;
|
||||||
|
poof.EmittingAngle = glm::half_pi<float>();
|
||||||
|
poof.Spread = 0.5f;
|
||||||
|
poof.NumberOfTicks = 1;
|
||||||
|
poof.ParticleLifeTime = 1.5f;
|
||||||
|
poof.ParticlesPerTick = 1;
|
||||||
|
poof.Position = cTransform->Position;
|
||||||
|
poof.ScaleValues.clear();
|
||||||
|
poof.ScaleValues.push_back(glm::vec3(0.5f));
|
||||||
|
poof.ScaleValues.push_back(glm::vec3(2.f, 2.f, 0.2f));
|
||||||
|
poof.SpriteFile = "Textures/Particles/Cloud_Particle.png";
|
||||||
|
poof.Color = brickModel->Color;
|
||||||
|
poof.AlphaValues.clear();
|
||||||
|
poof.AlphaValues.push_back(1.f);
|
||||||
|
poof.AlphaValues.push_back(0.f);
|
||||||
|
poof.Speed = 10;
|
||||||
|
EventBroker->Publish(poof);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+894
-812
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user