Skip to content
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

Wrong indexes fix #20

Open
wants to merge 4 commits into
base: numba
Choose a base branch
from
Open

Wrong indexes fix #20

wants to merge 4 commits into from

Conversation

Juksten
Copy link

@Juksten Juksten commented Feb 1, 2020

Fixes #18
This bug was caused because in some lines like:

tensionmap/tensionmap.py

Lines 186 to 189 in c63fc1b

def read_vertex_color_data(mesh):
vertex_colors = np.zeros(len(mesh.polygons)*16, dtype='float32')
mesh.vertex_colors['tm_tension'].data.foreach_get('color',vertex_colors)
return (vertex_colors.reshape(len(mesh.polygons)*4,4))

code was creating arrays that would fit only if model is build from quads. This pull request adds new menu under tm_panel called 'Mesh type'. It allows user to select 'Quads only' in case model is build from quad polygons, 'Triangles only' for meshes build from triangles, and 'Mixed' for all other cases. If 'Mixed' is selected script will use part of code from original addon to handle changing vertex colors, and due to that gives worse performance.

@VincentKueszter
Copy link

If I use the numba_crash.blend file I sent you it still crashes for me. No matter which combination of settings (dual/quad) I choose.

Windows fatal exception: access violation
Current thread 0x00000964 (most recent call first):
  File "...\Blender\2.81\scripts\addons\tensionmap_numba.py", line 209 in tm_update
  File "...\Blender\2.81\scripts\addons\tensionmap_numba.py", line 286 in tm_update_handler

Does this happen for you, too, or did I make some mistake?

@Juksten
Copy link
Author

Juksten commented Feb 2, 2020

Blender 2.81.16
Numba 0.48.0
Numpy 1.18.1
Windows 10
In scene select cylinder, check 'Quads mode'(cylinder is made from quad polygons), then select plane(made from tris) and in its tm_panel uncheck 'Quads mode'. If your object contains different types of polygons in its tm_panel check 'Dual mode'.

@VincentKueszter
Copy link

I have an object that is quads only, but it also crashes in dual mode.
https://www.dropbox.com/s/buqnbp5yyi6nvix/crash.zip?dl=1

@Juksten
Copy link
Author

Juksten commented Feb 2, 2020

This scene works on my computer, are numba and numpy version the same as mine?
Also are you sure you unchecked 'Quads mode' for hidden plane in your scene?

@VincentKueszter
Copy link

Oh, I knew I did something wrong! I forgot there was a hidden plane in my scene.
Yes, everything works now, sorry for the confusion on my part! :)
A suggestion: Instead of the two tickboxes, I think a dropdown menu with "Triangles only" "Quads only" and "Mixed" would be better.

I wonder if this could be detected automatically without impacting performance too much...

@VincentKueszter
Copy link

Tried it out, works for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants