Skip to content

Commit

Permalink
precision quadrilateral
Browse files Browse the repository at this point in the history
  • Loading branch information
OVOAOVO committed Sep 21, 2023
1 parent 8517b7a commit 05d8e99
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 69 deletions.
34 changes: 17 additions & 17 deletions Engine/Source/Runtime/ParticleSystem/ParticleSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ void engine::ParticleSystem::Reset(int index)
{

m_pos[index] = cd::Vec3f(0.0f, 0.0f, 0.0f);
m_velocity[index] = cd::Vec3f(1.0f, 1.0f, 1.0f);
m_acceleration[index] = cd::Vec3f(1.0f, 0.0f, 0.0f);
m_velocity[index] = cd::Vec3f(rand()%3, rand()%3, 0.0f);
m_acceleration[index] = cd::Vec3f(0.0f, 0.0f, 0.0f);

m_color[index] = cd::Vec3f{0.0f, 0.0f,1.0f};
m_color[index] = cd::Vec3f{1.0f, 1.0f,1.0f};

m_isActive[index] = false;
m_currentTime[index] = 0.0f;
Expand All @@ -61,29 +61,29 @@ void engine::ParticleSystem::Update(float deltaTime, int index)
{
m_pos[index].x() = m_pos[index].x() + m_velocity[index].x() * 0.15f + 0.5f * m_acceleration[index].x() * 0.15f * 0.15f;
m_pos[index].y() = m_pos[index].y() + m_velocity[index].y() * 0.15f + 0.5f * m_acceleration[index].y() * 0.15f * 0.15f;
m_texture_u[index] = 0.0f;
m_texture_v[index] = 0.0f;
m_texture_u[index] = 1.0f;
m_texture_v[index] = 1.0f;
}
else if (index % 4 == 1)
{
m_pos[index].x() = m_pos[index-1].x()+ 1 + m_velocity[index].x() * 0.15f + 0.5f * m_acceleration[index].x() * 0.15f * 0.15f;
m_pos[index].y() = m_pos[index-1].y() + m_velocity[index].y() * 0.15f + 0.5f * m_acceleration[index].y() * 0.15f * 0.15f;
m_texture_u[index] = 1.0f;
m_texture_v[index] = 0.0f;
m_pos[index].x() = m_pos[index-1].x()+ 1 ;
m_pos[index].y() = m_pos[index-1].y() ;
m_texture_u[index] = 0.0f;
m_texture_v[index] = 1.0f;
}
else if (index % 4 == 2)
{
m_pos[index].x() = m_pos[index-2].x() + 1+ m_velocity[index].x() * 0.15f + 0.5f * m_acceleration[index].x() * 0.15f * 0.15f;
m_pos[index].y() = m_pos[index-2].y() + 1 + m_velocity[index].y() * 0.15f + 0.5f * m_acceleration[index].y() * 0.15f * 0.15f;
m_texture_u[index] = 1.0f;
m_texture_v[index] = 1.0f;
m_pos[index].x() = m_pos[index-2].x() + 1;
m_pos[index].y() = m_pos[index-2].y() + 1;
m_texture_u[index] = 0.0f;
m_texture_v[index] = 0.0f;
}
else if (index % 4 == 3)
{
m_pos[index].x() = m_pos[index-3].x() + m_velocity[index].x() * 0.15f + 0.5f * m_acceleration[index].x() * 0.15f * 0.15f;
m_pos[index].y() = m_pos[index-3].y() + 1 + m_velocity[index].y() * 0.15f + 0.5f * m_acceleration[index].y() * 0.15f * 0.15f;
m_texture_u[index] = 0.0f;
m_texture_v[index] = 1.0f;
m_pos[index].x() = m_pos[index-3].x();
m_pos[index].y() = m_pos[index-3].y() + 1 ;
m_texture_u[index] = 1.0f;
m_texture_v[index] = 0.0f;
}

for (int i = index; i < m_particleMaxCount; ++i)
Expand Down
52 changes: 0 additions & 52 deletions Engine/Source/Runtime/Rendering/ParticleRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,58 +49,6 @@ void ParticleRenderer::Render(float deltaTime)
constexpr StringCrc ParticleProgram("ParticleProgram");
bgfx::submit(GetViewID(), GetRenderContext()->GetProgram(ParticleProgram));
}
// engine::ParticleEmitterComponent* pEmitterComponent = m_pCurrentSceneWorld->GetParticleEmitterComponent(entity);
// const cd::Transform& transform = m_pCurrentSceneWorld->GetTransformComponent(entity)->GetTransform();
// pEmitterComponent->init();
// int particleindex = pEmitterComponent->allocateParticleIndex();
// ParticleComponent& particle = pEmitterComponent->getParticle(particleindex);
// if (pEmitterComponent->allocateParticleIndex() != -1)
// {
// particle.setPos(transform.GetTranslation());
// particle.setVelocity(cd::Vec3f(-0.02f + rand() % 4100, 0.0f, 0.0f));
// particle.setAcceleration(cd::Vec3f(0.0f, 0.0f, 0.0f));
// particle.setColor(cd::Vec3f(1.0f, 0.0f, 0.0f));
// particle.setLifeTime(1.0f + rand() % 7);
// }

// pEmitterComponent->update(1.0f / deltaTime);

// cd::VertexFormat vertexFormat;
// vertexFormat.AddAttributeLayout(cd::VertexAttributeType::Position, cd::AttributeValueType::Float, 3);
// vertexFormat.AddAttributeLayout(cd::VertexAttributeType::Color, cd::AttributeValueType::Float, 3);

// bgfx::VertexLayout vertexLayout;
// VertexLayoutUtility::CreateVertexLayout(vertexLayout, vertexFormat.GetVertexLayout());

// //vertex
// pEmitterComponent->GetVertexBuffer().resize(2*sizeof(cd::Vec3f));


// std::memcpy(pEmitterComponent->GetVertexBuffer().data(), &particle.getPos(), sizeof(cd::Vec3f));
// std::memcpy(pEmitterComponent->GetVertexBuffer().data()+sizeof(cd::Vec3f), &particle.getColor(), sizeof(cd::Vec3f));


// //index
///* std::vector<uint16_t> indices = { 0, 1 };
// emitter->GetIndexBuffer().resize(2*sizeof(uint16_t));
// std::memcpy(emitter->GetIndexBuffer().data(), indices.data(), sizeof(indices));*/


// pEmitterComponent->setParticleVBH(bgfx::createVertexBuffer(bgfx::makeRef(pEmitterComponent->GetVertexBuffer().data(), static_cast<uint32_t>(pEmitterComponent->GetVertexBuffer().size())), vertexLayout).idx);
// //emitter->setParticleIBH( bgfx::createIndexBuffer(bgfx::makeRef(emitter->GetIndexBuffer().data(), static_cast<uint32_t>(emitter->GetIndexBuffer().size())),0U).idx);

// bgfx::setVertexBuffer(0, bgfx::VertexBufferHandle{ pEmitterComponent->getParticleVBH() });
//// bgfx::setIndexBuffer(bgfx::IndexBufferHandle{ emitter->getParticleIBH() });

// constexpr uint64_t state = BGFX_STATE_WRITE_MASK | BGFX_STATE_MSAA | BGFX_STATE_DEPTH_TEST_LESS |
// BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_SRC_ALPHA, BGFX_STATE_BLEND_INV_SRC_ALPHA) | BGFX_STATE_PT_POINTS;

// bgfx::setState(state);

// constexpr StringCrc ParticleProgram("ParticleProgram");
// bgfx::submit(GetViewID(), GetRenderContext()->GetProgram(ParticleProgram));
//
//const cd::Transform& cameraTransform = m_pCurrentSceneWorld->GetTransformComponent(m_pCurrentSceneWorld->GetMainCameraEntity())->GetTransform();
}

}

0 comments on commit 05d8e99

Please sign in to comment.