-
Notifications
You must be signed in to change notification settings - Fork 181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ECS: re-implement mesh rendering in database entries #2140
ECS: re-implement mesh rendering in database entries #2140
Conversation
- Total duplication of the code there. Will extract soon, if appropriate
The same projection is happening already a few lines above
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.
My reflexes were for optional arguments, but an overload seems more correct.
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.
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
When copying behavior from viewport3D we adopted some behavior from it that doesn't seem necessary for this view
src/mesh.cpp
Outdated
} | ||
|
||
|
||
float sum_x = 0.f; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe it would be possible to use glm::vec3
instead? Not sure if you can initialize a glm::vec3
from a float[3]
.
But then it would look something like:
glm::vec3 sum{};
for(auto vertex : vertices) sum += glm::vec3(vertex.position);
auto average = sum / float(vertices.size());
for(auto vertex : vertices) {
float distance = glm::length(glm::vec3(vertex.position) - average);
...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(changing the Mesh float[3] into a glm::vec3 in theory should be possible, but right now feels quite risky and too large of a change)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that idea! That's where I started before changing it to try to match the style of the code above it, but I think it would be cleaner with glm
structures/functions.
In the first few commits, this was close to a copy/paste from
MeshRenderSystem::render3D
toGuiRotatingModelView::onDraw
. If duplicating the rendering pipeline in these two places is sufficient, I'm happy to simplify this PR back down to that.That said, the rest of the work is an attempt at re-using some of the code between
render3D
andonDraw
without compromising the clarity of the render system to serve the one-off needs ofonDraw
. I will admit that the likelihood of render code changing often is pretty low, so maybe this kind of re-use isn't that critical here.Aside: Again, I'm pretty new to C++, so I'm open to thoughtful feedback on language features I'm misusing, or weaknesses I might be inadvertently introducing, or patterns that make more sense than what I've put in.
I've opted to save the debug work for a separate PR to keep this one a bit smaller, but I did leave one piece from my exploration there in this series of commits 2d0405c. I think it'll be useful to have an entity in order to enumerate and render emitters.