Skip to content

Commit

Permalink
change init
Browse files Browse the repository at this point in the history
  • Loading branch information
OVOAOVO committed Sep 15, 2023
1 parent 613b047 commit 08da43d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
4 changes: 4 additions & 0 deletions Engine/Source/Editor/UILayers/EntityList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ void EntityList::AddEntity(engine::SceneWorld* pSceneWorld)
engine::Entity entity = AddNamedEntity("ParticleEmitter");
auto& particleEmitterComponent = pWorld->CreateComponent<engine::ParticleEmitterComponent>(entity);
// TODO : Some initialization here.

engine::ParticleSystem particles;
particles.Init();
particleEmitterComponent.SetParticleSystem(particles);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Engine/Source/Runtime/ECWorld/ParticleEmitterComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ParticleEmitterComponent final
ParticleEmitterComponent& operator=(ParticleEmitterComponent&&) = default;
~ParticleEmitterComponent() = default;

engine::ParticleSystem GetParticleSystem() { return m_particleSystem; }
engine::ParticleSystem &GetParticleSystem() { return m_particleSystem; }
void SetParticleSystem(engine::ParticleSystem& system) { m_particleSystem = system; }

uint16_t& GetParticleVBH(){ return m_particleVBH; }
Expand Down
2 changes: 1 addition & 1 deletion Engine/Source/Runtime/ParticleSystem/ParticleSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void engine::ParticleSystem::AllocateParticleIndex()
void engine::ParticleSystem::Reset(int index)
{
m_pos[index] = cd::Vec3f(0.0f, 0.0f, 0.0f);
m_velocity[index] = cd::Vec3f(rand() % 41, 0.0f, 0.0f);
m_velocity[index] = cd::Vec3f(rand() % 41, rand() % 7, rand() % 50);
m_acceleration[index] = cd::Vec3f(0.0f, 0.0f, 0.0f);

m_color[index] = cd::Vec3f{rand() %30, rand() %45,0.0f};
Expand Down
9 changes: 2 additions & 7 deletions Engine/Source/Runtime/Rendering/ParticleRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,10 @@ void ParticleRenderer::Render(float deltaTime)
for (Entity entity : m_pCurrentSceneWorld->GetParticleEmitterEntities())
{
engine::ParticleEmitterComponent* pEmitterComponent = m_pCurrentSceneWorld->GetParticleEmitterComponent(entity);
pEmitterComponent->GetParticleSystem().AllocateParticleIndex();
pEmitterComponent->GetParticleSystem().UpdateActive(1 / deltaTime);

engine::ParticleSystem particles;
particles.Init();
particles.AllocateParticleIndex();
particles.UpdateActive(1/deltaTime);

pEmitterComponent->SetParticleSystem(particles);
pEmitterComponent->Build();

bgfx::setVertexBuffer(0, bgfx::VertexBufferHandle{ pEmitterComponent->GetParticleVBH() });
bgfx::setIndexBuffer(bgfx::IndexBufferHandle{ pEmitterComponent->GetParticleIBH() });

Expand Down

0 comments on commit 08da43d

Please sign in to comment.