Fixed picking pass... again...
This commit is contained in:
@@ -48,26 +48,31 @@ void PickingPass::Draw(RenderQueueCollection& rq)
|
|||||||
m_PickingColorsToEntity.clear();
|
m_PickingColorsToEntity.clear();
|
||||||
PickingPassState* state = new PickingPassState(m_PickingBuffer.GetHandle());
|
PickingPassState* state = new PickingPassState(m_PickingBuffer.GetHandle());
|
||||||
|
|
||||||
int r = 1;
|
int r = 0;
|
||||||
int g = 0;
|
int g = 0;
|
||||||
//TODO: Render: Add code for more jobs than modeljobs.
|
//TODO: Render: Add code for more jobs than modeljobs.
|
||||||
|
|
||||||
GLuint ShaderHandle = m_PickingProgram->GetHandle();
|
GLuint ShaderHandle = m_PickingProgram->GetHandle();
|
||||||
m_PickingProgram->Bind();
|
m_PickingProgram->Bind();
|
||||||
|
|
||||||
|
std::map<EntityID, glm::vec2> entityColors;
|
||||||
|
|
||||||
for (auto &job : rq.Forward) {
|
for (auto &job : rq.Forward) {
|
||||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||||
|
|
||||||
if (modelJob) {
|
if (modelJob) {
|
||||||
//---------------
|
|
||||||
//TODO: Renderer: IMPORTANT: Fixa detta så det inte loopar igenom listan varje frame.
|
|
||||||
//---------------
|
|
||||||
int pickColor[2] = { r, g };
|
int pickColor[2] = { r, g };
|
||||||
for (auto i : m_PickingColorsToEntity) {
|
auto color = entityColors.find(modelJob->Entity);
|
||||||
if (modelJob->Entity == i.second) {
|
if (color != entityColors.end()) {
|
||||||
pickColor[0] = i.first.x;
|
pickColor[0] = color->second[0];
|
||||||
pickColor[1] = i.first.y;
|
pickColor[1] = color->second[1];
|
||||||
r -= 1;
|
} else {
|
||||||
|
entityColors[modelJob->Entity] = glm::vec2(pickColor[0], pickColor[1]);
|
||||||
|
if (r + 10 > 255) {
|
||||||
|
r = 0;
|
||||||
|
g += 1;
|
||||||
|
} else {
|
||||||
|
r += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_PickingColorsToEntity[glm::vec2(pickColor[0], pickColor[1])] = modelJob->Entity;
|
m_PickingColorsToEntity[glm::vec2(pickColor[0], pickColor[1])] = modelJob->Entity;
|
||||||
@@ -82,11 +87,6 @@ void PickingPass::Draw(RenderQueueCollection& rq)
|
|||||||
glBindVertexArray(modelJob->Model->VAO);
|
glBindVertexArray(modelJob->Model->VAO);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||||
glDrawElementsBaseVertex(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, nullptr, modelJob->StartIndex);
|
glDrawElementsBaseVertex(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, nullptr, modelJob->StartIndex);
|
||||||
r += 1;
|
|
||||||
if (r > 255) {
|
|
||||||
r = 0;
|
|
||||||
g += 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_PickingBuffer.Unbind();
|
m_PickingBuffer.Unbind();
|
||||||
@@ -105,6 +105,8 @@ void PickingPass::Draw(RenderQueueCollection& rq)
|
|||||||
&m_PickingColorsToEntity);
|
&m_PickingColorsToEntity);
|
||||||
|
|
||||||
m_EventBroker->Publish(pickEvent);
|
m_EventBroker->Publish(pickEvent);
|
||||||
|
|
||||||
|
delete state;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PickingPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const
|
void PickingPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const
|
||||||
|
|||||||
Reference in New Issue
Block a user