Skip to content

Instantly share code, notes, and snippets.

@PcChip
Created March 12, 2020 02:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PcChip/ee494c8ec2bd998bb4d2fa36d2ab04be to your computer and use it in GitHub Desktop.
Save PcChip/ee494c8ec2bd998bb4d2fa36d2ab04be to your computer and use it in GitHub Desktop.
submitMesh
void te2GraphicsModule::submitMesh(glm::mat4 orientation, meshBase* whichMesh, teShader* whichShader)
{
ZoneScoped;
//std::cerr << "submitMesh(glm::mat4, meshBase*, teShader*)\n";
auto it = shadersAndMeshesToRender.find(whichShader);
if (it != shadersAndMeshesToRender.end()) //found the shader we need
{
//std::cout << "shader found, searching for mesh...\n";
//search through the MeshMap and try to find the mesh we want
auto it2 = it.value().find(whichMesh);
if (it2 != it.value().end()) //mesh was already there, just add mat4
{
it2.value().emplace_back(orientation);
//std::cout << "mesh " << whichMesh << " found, added mat4. New size of mat4's is " << it2.value().size() << "\n";
}
else //mesh was not there, add the mesh and a vector of a single mat4
{
std::vector<glm::mat4> tempMat44Vec;
tempMat44Vec.emplace_back(orientation);
it.value().insert({ whichMesh, tempMat44Vec });
//std::cout << "mesh not found, added mesh and mat4\n";
}
}
else //insert the shader, along with the second robin map (mesh, mat44) inside of it
{
//std::cerr << "shader not found, inserting new map into map\n";
std::vector<glm::mat4> tempMat44Vec;
tempMat44Vec.emplace_back(orientation);
tsl::robin_map<meshBase*, std::vector<glm::mat4>> emptyMap;
shadersAndMeshesToRender.insert({ whichShader, emptyMap });
shadersAndMeshesToRender[whichShader].insert({ whichMesh, tempMat44Vec });
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment