Description
When working with Collada models (with lighting enabled), the ColladaMeshShape.createNormals()
method throws an IllegalArgumentException
intermittently. I looked at the code, and the offending line appears to be line 896:
this.normalBuffer.position(this.normalBuffer.position() + thisSize);
It looks like the position specified by this.normalBuffer.position()+thisSize
is not a valid position in some cases. I think this issue can be resolved by simply introducing a check to ensure the position is valid:
if(this.normalBuffer.limit() >= this.normalBuffer.position() + thisSize)
{
this.normalBuffer.position(this.normalBuffer.position() + thisSize);
}
It may also be a good idea to provide a similar check in the ColladaMeshShape.createTexCoords()
method.