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

LODs are a bit of a mess #2357

Open
Trass3r opened this issue Feb 2, 2025 · 0 comments
Open

LODs are a bit of a mess #2357

Trass3r opened this issue Feb 2, 2025 · 0 comments
Labels
Documentation Issues that affect the Wiki, Javadoc or any other form of documentation

Comments

@Trass3r
Copy link
Contributor

Trass3r commented Feb 2, 2025

The documentation is not clear about what LOD 0 is, sometimes it's even contradictory:

* @return The number of LOD levels set on this mesh, including the main
* index buffer, returns zero if there are no lod levels.
*/
public int getNumLodLevels() {
return lodLevels != null ? lodLevels.length : 0;
}
/**
* Returns the lod level at the given index.
*
* @param lod The lod level index, this does not include
* the main index buffer.
* @return The LOD index buffer at the index
*
* @throws IndexOutOfBoundsException If the index is outside of the
* range [0, {@link #getNumLodLevels()}].
*
* @see #setLodLevels(com.jme3.scene.VertexBuffer[])
*/
public VertexBuffer getLodLevel(int lod) {
return lodLevels[lod];

One has to dig deep into the code to find out that it just ignores the main index buffer when LODs are set:

if (mesh.getNumLodLevels() > 0) {
indices = mesh.getLodLevel(lod);
} else {
indices = mesh.getBuffer(Type.Index);

Also setting an LOD level to null seems to be valid:

if (indices != null) {
drawTriangleList(indices, mesh, count);
} else {
drawTriangleArray(mesh.getMode(), count, mesh.getVertexCount());

But one runs into crashes since it's not consistently handled like that:

return computeNumElements(lodLevels[lod].getData().limit());

@stephengold stephengold added the Documentation Issues that affect the Wiki, Javadoc or any other form of documentation label Feb 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Issues that affect the Wiki, Javadoc or any other form of documentation
Projects
None yet
Development

No branches or pull requests

2 participants