-
Notifications
You must be signed in to change notification settings - Fork 58
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
apply_to_vector to lists of vectors raises ValueError("Vector size unsupported") #106
Comments
Some changes were applied in #108, can you test if the latest changes fix this for you? |
Thanks @adamlwgriffiths , unfortunately it's going to take me some time to get back to this, although I assume that change would fix it. If you are curious about performance I gathered a bunch of comparisons for my epycc project. |
No rush. |
Thanks and likewise! I used pyrr heavily in some weird STL / editor / 3D graphics playground I'm writing, it made things a lot easier than straight numpy's learning curve. The slowness of Python smoothing normals even with numpy-optimized algorithms is what made me create epycc. With numpy you are SOL if your algorithm doesn't fit it, and numba is cool but the little I've used it I've found it to be a lot of guesswork and trial and error to appease it (also the codegen sucks donkey balls as you can see in epycc's performance study). Hopefully one day I'll get my lazy ass around to push my playground to github too. |
With numpy you really need to vectorise your data so you can do mass transforms.
Although I'm sure you already figured these out. |
Right, so STL is actually pretty friendly, it's just a vertexbuffer and a normalbuffer of independent tris, no indices so no shared vertices across faces. This means there's a lot of vertex duplication (~12x in my stats) and normals are per face, not per vertex, so it looks very faceted. I wrote several numpy vectorized algos to do normal sharing/smoothing across faces with angle thresholding, so only normals that are "close enough" are smoothened out and then shared across faces, which not only makes the model look better, but also reduces the vertex count since now you can share vertices (and normals) across most faces: The fastest numpy vectorized algo I wrote was an xyz vertex sort to put the repeated vertices together, and then do predicate masking to sum all the "close enough" normals depending on the angle between normals, and that way get the shared normal value. Still, that takes around 3-5s for that simple model of 200K vertices on my laptop. |
The documentation states that apply_to_vector can be used to transform a list of vectors (instead of calling apply_to_vector on each one in a Python loop)
Pyrr/pyrr/matrix44.py
Line 196 in 34802ba
Unfortunately the vec.size check in both matrix33 and matrix44 implementations above prevents that and raises a ValueError("Vector size unsupported")
calling apply_to_vector in a loop is 12x slower than using numpy natively
´´´
Numpy
1000000 vectors in 0.53 seconds, 1893938.98 vectors/second
Pyrr no conversion
1000000 vectors in 6.20 seconds, 161238.31 vectors/second
´´´
The text was updated successfully, but these errors were encountered: