Possible 'ArrayIndexOutOfBoundsException' with WeightVector()
BitsAtPlayDev opened this issue · 2 comments
The property count
and values.length
can have different values leading to ArrayIndexOutOfBoundsException
because when looping through values
, count
is often used instead of values.length
The difference can occur when creating a new instance of WeightVector
, and only nbWeights
is specified, causing max
to default to 8. This leads to count
getting set to whatever nbWeights
is, while values.length
== 8
Places where only nbWeights
is specified:
AnimationLoader
, MeshLoader
& CubicWeightVector
classes.
Places where count
is used to loop through values
:
WeightVector
& GTLFTypes
classes
The exception below occurred when attempting to load a model where an nbWeights
> 8 was encountered.
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 8 out of bounds for length 8 at net.mgsx.gltf.loaders.shared.GLTFTypes.map(GLTFTypes.java:105) at net.mgsx.gltf.loaders.shared.animation.AnimationLoader.load(AnimationLoader.java:164) at net.mgsx.gltf.loaders.shared.animation.AnimationLoader.load(AnimationLoader.java:37) at net.mgsx.gltf.loaders.shared.GLTFLoaderBase.load(GLTFLoaderBase.java:129) at net.mgsx.gltf.loaders.glb.GLBLoader.load(GLBLoader.java:16) at net.mgsx.gltf.loaders.glb.GLBAssetLoader.loadSync(GLBAssetLoader.java:32) at net.mgsx.gltf.loaders.glb.GLBAssetLoader.loadSync(GLBAssetLoader.java:14) [...]
We have this issue on some models. Therefore we're also investigating on that as it's a show stopper in many cases.