-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ECS: re-implement mesh rendering in database entries (#2140)
* Use MeshRenderSystem::render3D as a starting point - Total duplication of the code there. Will extract soon, if appropriate * Store greatest vertex distance from mesh center * Scale models to fit within database render view * Extract a few common behaviors as a test * Remove logging and commented code * Add reminder comments for inverted matrix * Remove unused commented code The same projection is happening already a few lines above * Group remaining behavior into functions These functions are somewhat arbitrary, but might be a good starting point for a final form. Providing these functions from rendering.h is still only temporary. * Use overload instead of attempted 'optional' My reflexes were for optional arguments, but an overload seems more correct. * Adjust where we scale and translate This seems to give a better result for a large variety of different original model scales. E.g. average vertex from 'center' of Atlantis is 30-40 whereas an MP52 is 1ish. * Offset model distance by near-z clip boundary * Clean up duplicate commented code * Pass entity instead of mesh to render view This isn't necessary to render the mesh, but it will be useful when trying to look up beam emitter and engine emitters to render in debug mode * Don't flip the matrix twice * drop out of `onDraw` if we can't load the mesh * Ensure no change to GL settings from previous When copying behavior from viewport3D we adopted some behavior from it that doesn't seem necessary for this view * Rename 'mesh' to 'mrc' * Replace ensureLoaded with 'getters' * Clarify comment * Return to original conditional style * Fix spacing * Simplify logic with glm:vec3
- Loading branch information
Showing
10 changed files
with
262 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "mesh.h" | ||
#include "textureManager.h" | ||
#include "rendering.h" | ||
|
||
Mesh* MeshRenderComponent::getMesh() | ||
{ | ||
if (!mesh.ptr && !mesh.name.empty()) | ||
mesh.ptr = Mesh::getMesh(mesh.name); | ||
return mesh.ptr; | ||
} | ||
|
||
sp::Texture* MeshRenderComponent::getTexture() | ||
{ | ||
if (!texture.ptr && !texture.name.empty()) | ||
texture.ptr = textureManager.getTexture(texture.name); | ||
return texture.ptr; | ||
} | ||
|
||
sp::Texture* MeshRenderComponent::getSpecularTexture() | ||
{ | ||
if (!specular_texture.ptr && !specular_texture.name.empty()) | ||
specular_texture.ptr = textureManager.getTexture(specular_texture.name); | ||
return specular_texture.ptr; | ||
} | ||
|
||
sp::Texture* MeshRenderComponent::getIlluminationTexture() | ||
{ | ||
if (!illumination_texture.ptr && !illumination_texture.name.empty()) | ||
illumination_texture.ptr = textureManager.getTexture(illumination_texture.name); | ||
return illumination_texture.ptr; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.