fix list index out of range for color_per_vertex #2
No reviewers
Labels
No Label
bug
confirmed
duplicate
enhancement
help wanted
High
known issue
Low
Normal
not a task
question
task
v2.4
wontfix
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: extensions/io_scene_x3d#2
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "Bujus_Krachus/io_scene_x3d:fix-list-index-out-of-range-vertex-color"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
fixes blender/blender-addons#101604 by using the index position instead of the actual vertex value to access the rgb list, because in the provided file the required filed colorIndex was missing (zero length).
Now the file from mentioned issue can get imported, however in rendered view the colors are still missing. But that should probably be another issue, as it seems unrelated (this is caused by the missing ColorAttribute node in the material setup and gets fixed/added in #6).
Now the code is able to:
Have you tested your patch with a correctly formed VRML file, i.e. with face vertex color index ending with '-1' like other per vertex nodes does ?
http://graphcomp.com/info/specs/sgi/vrml/spec/part1/nodesRef.html#IndexedFaceSet
Hi @Hombre57 could you be so kind and provide a "valid" file to test, which would apply in that case? Currently don't have the time to look one up/create one.
In my local copy it works with several files, however i'm not too experienced with the mentioned tech standard, so those files may not even trigger that case. But i don't see why they wouldn't work now, i just fixed a tiny logic error in the code. Anyways i'd be glad to test with your files.
@Bujus_Krachus Here are some files. The screenshots are taken after importing the "corrected" version.
@Hombre57 thank you for taking the time. Indeed, my proposed "fix" is not a fix at all as it seems.
Do you have an idea/quick fix on how to handle such "broken" files? Because programs like FreeWRL are able to display them all correctly...
fix list index out of range for color_per_vertexto WIP: fix list index out of range for color_per_vertex@Bujus_Krachus
In short :
@Hombre57 thanks for the suggestion, will add that soon. Currently i've added a simple length check because the broken file did not have an colorIndex field (in such cases we don't have to rebuild the colorIndex field in my opinion, which saves a bit of performance).
WIP: fix list index out of range for color_per_vertexto fix list index out of range for color_per_vertex@Hombre57 i've included your change requests. Now all cases should work fine.
@Bujus_Krachus That's clean ! 😃 Thanks for the update.
Who's reviewing and accepting the PR ? (yes, I'm new here)
Tbh idk. Since the addon moved to the extensions platform it doesn't have a maintainer anymore and the official blender team isn't really responsible either.
@Bujus_Krachus
Don't you mean
index
instead ofcolor_index
here ?Hi @Hombre57, you are partially correct.
Comparison
However, when using
coordIndex
(orindex
) it will have Ambient Occlusion Pre-baked into the material as it seems. I don’t think this is intended behavior for the importer (yet).Compared to using
color_index
:Btw the missing colorAttribute node and smooth shading will probably be fixed by a merge with your PR (#6).
Compared to freeWRL:
Explanation:
processPerVertexIndex(color_index)
will default to returningfaces
(basically coordIndex, just more abstracted into faces already) if the parameterind
is empty (like it’s the case here for mentioned case) unlike when usingindex
, then it (coordIndex
) will get unfolded; so in the new commit I will simplify the code, to save some few function calls to hopefully improve performance for that case a tiny bit.If you are other opinion or have some tech knowledge i don't have, please elaborate and ideally attach a file where the current solution breaks things. Thank you for bringing it up.
We could however leverage the observed behavior of pre-baked AO (if that’s even correct and not just a coincidence for the file of the original issue) by creating a new option in the importer; still the implementation for the other cases and material types is missing, so that would have to be a todo.
@Bujus_Krachus
Yes, I manually merged this branch in PR #6 and it loaded with normals and colors. Here is what I get.
No problem ! I was just surprised to see
normal_index
here and overlooked that special case inprocessPerVertexIndex
😅. Great if you can optimize your code even more.Now we just need a maintainer to merge your PR first, I'll resolve conflicts there after.
@Hombre57
Great, looks exactly how it should (with smooth shading and colors applied).
Yeah, haha. You indeed let me question what i was thinking back then, took a while to find that part again lol
In #7 Nika (volunteer as admin for the extension platform) asked, if i wanted to become the future maintainer, unfortunately since then no more activity occured. If you want, you can comment and tag her as well, if you're interested. Else either her oder someone from the blender team is responsible (another PR got merged by Campbell Barton, but no activity since then either). I'll wait another week for a response and will then request some reviews in hope someone will respond.