I have been trying out the new LodGenerator and found an issue with certain meshes.
The index buffer of the mesh is of type Format.UnsignedShort. So when you retrieve the value in the gatherIndexData() method it can be negative (since Java has no “real” unsigned shorts).
Also on a related topic, currently generating the LOD takes very long for large batched scenes. So I would prefer generating the LOD before batching them together, however the GeometryBatchFactory.makeLods() is completely commented out and the lod levels are discarded in the batching process.
Is there a reason why this code is commented out, is there an issue with it? (maybe I can look into)
<cite>@maximusgrey said:</cite>
I have been trying out the new LodGenerator and found an issue with certain meshes.
The index buffer of the mesh is of type Format.UnsignedShort. So when you retrieve the value in the gatherIndexData() method it can be negative (since Java has no “real” unsigned shorts).
The value of tri.vertexId[i] can thus be negative causing an index out of bounds exception on the vertexLookup list.
I would suggest adjusting the method to convert the UnsignedShort value to the actual value int value before line 337.
Ohhh this could explain some problems part of my models have, I never investigated so far, since I assumed that the models simply had errors might be worth a look if its this issue.
Thanks for the issue report, I’ll take care of it.
About the lods in the geometry batch factory, idk why it’s commented, I remember, @rickard posted it a long time ago, maybe it has since be commented because it was causing issues…
There are however some small issues remaing, (short vs Int and not all models have the same amount of LOD levels generated which is required for the batching). I’ll look into that tomorrow!
The original issue should be fixed.
I tested it with my models and it works, but since I never had the issue before, could you please test it with your problematic model?
I guess you need a model with more than 32767 vertices.
@rickard, i applied the patch in my local copy but there are also issues with int and short buffers, so I’ll fix it and commit later. Thanks for the patch.