Minor cleanup in LOD system
This commit is contained in:
parent
c1c62a9b94
commit
be9f178780
@ -35,12 +35,12 @@ public:
|
|||||||
renderObjects.emplace_back(RenderObject(transform->matrix, 0, mesh.get()));
|
renderObjects.emplace_back(RenderObject(transform->matrix, 0, mesh.get()));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
glm::vec3 cameraPos = cameraTransform->getPosition();
|
||||||
|
|
||||||
// TODO: Is it possible to do get ObjMeshes in the Mesh loop above implicitly via polymorphism?
|
// TODO: Is it possible to do get ObjMeshes in the Mesh loop above implicitly via polymorphism?
|
||||||
pWorld->each<ObjMesh, Transform>([&](Entity *ent, ComponentHandle<ObjMesh> mesh, ComponentHandle<Transform> transform) {
|
pWorld->each<ObjMesh, Transform>([&](Entity *ent, ComponentHandle<ObjMesh> mesh, ComponentHandle<Transform> transform) {
|
||||||
// Add the object to the renderObjects to draw if the distance is within the min and max distance of the mesh
|
// Add the object to the renderObjects to draw if the distance is within the min and max distance of the mesh
|
||||||
glm::vec3 cameraPos = cameraTransform->getPosition();
|
float distance = glm::distance(cameraPos, transform->getPosition());
|
||||||
glm::vec3 objPos = transform->getPosition();
|
|
||||||
float distance = glm::distance(cameraPos, objPos);
|
|
||||||
|
|
||||||
if (distance > mesh->minDistance && distance < mesh->maxDistance) {
|
if (distance > mesh->minDistance && distance < mesh->maxDistance) {
|
||||||
renderObjects.emplace_back(RenderObject(transform->matrix, 0, mesh.get()));
|
renderObjects.emplace_back(RenderObject(transform->matrix, 0, mesh.get()));
|
||||||
@ -50,19 +50,16 @@ public:
|
|||||||
// ObjMesh with textures
|
// ObjMesh with textures
|
||||||
pWorld->each<ObjMesh, Transform, Texture>([&](Entity *ent, ComponentHandle<ObjMesh> mesh, ComponentHandle<Transform> transform, ComponentHandle<Texture> texture) {
|
pWorld->each<ObjMesh, Transform, Texture>([&](Entity *ent, ComponentHandle<ObjMesh> mesh, ComponentHandle<Transform> transform, ComponentHandle<Texture> texture) {
|
||||||
// Add the object to the renderObjects to draw if the distance is within the min and max distance of the mesh
|
// Add the object to the renderObjects to draw if the distance is within the min and max distance of the mesh
|
||||||
glm::vec3 cameraPos = cameraTransform->getPosition();
|
float distance = glm::distance(cameraPos, transform->getPosition());
|
||||||
glm::vec3 objPos = transform->getPosition();
|
|
||||||
float distance = glm::distance(cameraPos, objPos);
|
|
||||||
|
|
||||||
if (distance > mesh->minDistance && distance < mesh->maxDistance) {
|
if (distance > mesh->minDistance && distance < mesh->maxDistance) {
|
||||||
renderObjects.emplace_back(RenderObject(transform->matrix, texture->id, mesh.get()));
|
renderObjects.emplace_back(RenderObject(transform->matrix, texture->id, mesh.get()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// LODObjMesh with Texture
|
||||||
pWorld->each<LODObjMesh, Transform, Texture>([&](Entity *ent, ComponentHandle<LODObjMesh> lodMesh, ComponentHandle<Transform> transform, ComponentHandle<Texture> texture) {
|
pWorld->each<LODObjMesh, Transform, Texture>([&](Entity *ent, ComponentHandle<LODObjMesh> lodMesh, ComponentHandle<Transform> transform, ComponentHandle<Texture> texture) {
|
||||||
glm::vec3 cameraPos = cameraTransform->getPosition();
|
float distance = glm::distance(cameraPos, transform->getPosition());
|
||||||
glm::vec3 objPos = transform->getPosition();
|
|
||||||
float distance = glm::distance(cameraPos, objPos);
|
|
||||||
|
|
||||||
for (const auto &mesh : lodMesh->meshes) {
|
for (const auto &mesh : lodMesh->meshes) {
|
||||||
if (distance > mesh.minDistance && distance < mesh.maxDistance) {
|
if (distance > mesh.minDistance && distance < mesh.maxDistance) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user