-
Notifications
You must be signed in to change notification settings - Fork 616
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
Refactor MeshVisual indexing for easier and more flexible filter creation #1462
Conversation
The scene
@campagnola @kmuehlbauer @larsoner @davidh-ssec Any feedback on this? |
@asnt I finally have a little time to look at all of our recent PRs (even if this is a month old, sorry). However, I'm not really familiar with the MeshVisual code. I do have some questions from what I can see.
|
Thank you for following up @djhoese. Here are the answers to the questions based on what I can recall:
I think we should profit from the occasion to extend MeshVisual with a Material API as discussed in campagnola#10 (comment) |
Looks like this PR is a blocker for some potentially nice progress! I tried it out on an example I had, it didn't work, so I trimmed the example down:
On On this PR it changes and looks incorrect: Do you have time to look into it? |
945d105
to
feda893
Compare
@larsoner After some thought, I propose another (simpler) strategy in this updated PR: Always send the element arrays (i.e. no index arrays) to the graphics card.
|
As long as internally everything works and externally users can work in indexed mode like they could before I'm fine with it |
feda893
to
9ac2e31
Compare
9ac2e31
to
9ba13af
Compare
1b8b2d6
to
c1de876
Compare
@asnt Do you foresee any performance issues by sending the full faces instead of index arrays? I'm guessing even if there are that the benefits of filters working/being easier make it worth it? |
I was going to comment and say that I'm worried this is doing a lot of extra work if someone provides their data in a draw-able way, but now realize that these computations were being done already (getting faces if we were only getting vertices, etc). I'm ok merging this if @asnt can comment/fix the things I pointed out about unnecessary code. Any issues that this uncovers with users' use cases or if this limits functionality in any way can be dealt with in the future. The number of features that @asnt has been requesting/adding and that need this fix/clarification is more of a driving reason to merge this than keep the old functionality to support some obscure previous use case (not saying backwards compatibility isn't important). It becomes more of an argument to take this code that is cleaner and easier to understand and make it work with any broken use cases, if any, than to support the current implementation. All this is to say, I'm not 100% sure all this is perfect, but it doesn't seem less perfect than the code that is there already. |
I just tried this out, it works fine for me all my use cases - including after dropping the lines @djhoese flagged as not needed (which should be done before this gets merged). I did notice a problem with vispy/vispy/geometry/meshdata.py Line 339 in 9e0822d
vispy/vispy/geometry/meshdata.py Line 307 in 9e0822d
but that is really independent of this PR and would have been broken before hand. When the time is right I can make a short follow-up PR to make sure the those lines do something reasonable when given 2D meshes if a shading mode is enabled |
@djhoese I think the indexed vertices are advantageous for larger meshes or for collections of meshes sharing the same geometry. I might be missing some other aspects, though. However, sticking to faces internally makes indeed the implementation simpler while still general as far as I can tell. |
62b0c8b
to
c1de876
Compare
To simplify the logic in the mesh visual
c1de876
to
3c6d157
Compare
1bbb2de
to
09c9341
Compare
@asnt There was a failing test. I assumed it was random and restarted it. We'll see how that goes. Could you remind me what the situation with this PR is versus the other ones that you've created? #1444 is ready to merge and works as-is, but could benefit from this PR to simplify some of its logic, right? #1463 relies on this and won't be able to work without it, right? So we could merge #1444 now, double check this and merge this PR, then update/remerge #1463 and merge that in to master, and then make another PR to simplify the TextureFilter to use the new indexing/features added in this PR. Does that sound good? Any other PR I'm forgetting about (looking through my open browser tabs now)? |
@djhoese The dependency order of the PR's you suggested seems right:
I've got merge conflicts with this branch at the moment. I'll have a closer look later if still open. |
# Conflicts: # vispy/visuals/mesh.py
I was going to ask everyone if it is OK to merge this but now realize (after looking at the "Files changed") that this includes the important changes from #1444. So 🤦♂️ on my part, but merging this now and will continue on in working on the related PRs. |
@djhoese Indeed, point 4 seems done already. I thought the indexing in the TextureFilter would need updating but, looking at it again, it seems I already did it (as mentioned in this edit). |
MeshVisual currently seems to always reindex the vertex array as face-indexed vertices. This should rather be the decision of the caller for practical and perfomance reasons (e.g., glDrawEelements vs glDrawArrays).
This PR changes the behavior of MeshVisual to use whatever indexing was provided by the caller.
This allows the implementation of texture filters (#1444) and coming-up shading filters without workarounds.