Skip to content
Snippets Groups Projects
Commit 512dd40d authored by JonShard's avatar JonShard
Browse files

Fixed Scene::getEntityByTag(), it is now used in main to get camera.

parent 76c3cb63
No related branches found
No related tags found
No related merge requests found
......@@ -65,20 +65,20 @@ namespace overkill
return m_entities[ID];
}
// Entity* Scene::getEntityByTag(const C::Tag tag)
// {
// auto comp = [tag](Entity* entity) // Lambda to compare two entities by tag.
// {
// return (entity-> getTag() == tag);
// };
// auto entityToGet = std::find(m_entities.begin(), m_entities.end(), comp);
// // if (entityToGet == m_entities.end())
// // {
// // LOG_ERROR("Attempt to find entity that does not exist.");
// // }
// return *entityToGet;
// }
Entity* Scene::getEntityByTag(const C::Tag tag)
{
auto comp = [tag](Entity* entity) // Lambda to compare two entities by tag.
{
return (entity-> getTag() == tag);
};
auto entityToGet = std::find_if(m_entities.begin(), m_entities.end(), comp);
if (entityToGet == m_entities.end())
{
LOG_ERROR("Attempt to find entity that does not exist.");
}
return *entityToGet;
}
void Scene::update(float dt)
{
......
......@@ -127,10 +127,9 @@ int main()
// // UPDATE CAMERA DATA
projection = glm::perspective(Input::m_fovy, C::AspectRatio, 0.1f, -100.0f);
view = ((EntityCamera*)Scene::getEntity(0))-> m_viewMatrix;
view = ((EntityCamera*)Scene::getEntityByTag("camera"))-> m_viewMatrix;
glm::inverse(view);
// view = ((EntityCamera*)Scene::getEntityByTag("camera"))-> m_viewMatrix;
// UPDATE LIGHT DATA
lightData[0].position = glm::vec4(10 * sin(3 * t), (sin(0.666f*t) + 2.0f), 10 * cos(3 * t), 0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment