Highlight faces?

Hello all!
What would be the best way to change the color/highlight a bunch of faces properly in Blender 2.8?
A modal operator, using a draw handler, seems to work with the new gpu API:
https://docs.blender.org/api/blender2.8/gpu.html

But i’m stumbling on performances issues, evaluating the vertices coordinates of animated meshes with more than 10K vertices is quite slow. For meshes deformed by an armature, the “object.to_mesh()” method seems to be the only way to return the deformed vertices coordinates, as of now, which creates a new mesh data block, it’s probably not the best approach.
Aren’t there any lower level access, such as modifying the vertex/faces color as drawn directly by Eevee/viewport?

I guess up to 10k vertices is about the limit of what python can process in “realtime”, I think if you could implement this highlighting in a draw handler, there’s not much that you could to to massivelly speed up the mesh computation besides using lower resolution meshes or smartly skipping mesh elements you dont care.

Luckily Philipp Oeser fixed the bmesh.from_object() method which was broken in 2.8, thanks to this it’s currently the faster way to evaluate the final deformed vertices position. Will look for other ways to optimize as well.

Another 2 questions for you. Is this face highlight different than just making a real face selection? What is your criteria for the face highlight; is it something blender can do from one of it’s built in selection operators or something entirely custom?

What I need is highlighting a group of faces in object mode, not edit mode. With a custom color and transparency applied to it.
So my current implementation is the following: the face vertices are collected in a list, then from this list the vertices coordinates and indices lists are generated to build the shader (which is basically a virtual mesh made of faces) and finally the shader is drawn in the viewport.

Ah, ok. So it’s probably not the initial face selection/search that is the problem? It’s probably the middle step of extracting out all the vertex coords into your own lists in Python you think? You can verify that by printing some timings in your code to be sure but it’s probably that. If that’s the case I’m not sure what could be done either, sorry :-/

Yes, as said earlier:

But i’m stumbling on performances issues, evaluating the vertices coordinates of animated meshes with more than 10K vertices is quite slow. For meshes deformed by an armature, the “object.to_mesh()” method seems to be the only way to return the deformed vertices coordinates, as of now, which creates a new mesh data block, it’s probably not the best approach.

But the bmesh method is faster, i’ve added timers here and there and it’s about two times faster (which seems logicial since the to_mesh() method involves to create a new mesh data block in the file, and must be deleted at the end of the process no to go out of memory: for each frame a new data block is added and stored. While the bmesh method returns the mesh data on the fly, and can skip the vertex normal calculation by the way).
But the ultimate way would be lower level access, passing an argument to change the face color as drawn in eevee. Something similar can be done in 3dsMax.