Hey,
So, I'm assuming this section of code doesn't get tested too often, because triangle arrays suck. However, the non-Triangle array based Cylinder creation methods seem to be broken now, and I only have one object I want to use it for, so I have one or two geometries in my scene in that use them.
Anyway, if you try to clone a Geometry that is a triangle array, you get a crash in the JNI when you try to display the geometry. I haven't dug too far into the exact problem, but I was able to fix it by commenting out two checks:
SimpleGeometryDataContainer.java:623 - Commenting out the else.
if ( o.isInterleaved )
{
this.interleavedData = o.interleavedData.duplicateGeomData( true );
}
// else
// {
if ( o.coords != null )
{
this.coords = o.coords.duplicateGeomData( true );
}
// }
GeometryDataContainer.java:2002 - commenting out the if (!o.isInterleaved()))
// if ( !o.isInterleaved() )
// {
if ( o.hasNormals() )
{
this.normals = o.normals.duplicateGeomData( true );
}
if ( o.hasColors() )
{
this.colors = o.colors.duplicateGeomData( true );
}
if ( o.hasTextureCoordinates() )
{
this.texCoords = new GeomNioFloatData[ o.texCoords.length ];
for ( int i = 0; i < texCoords.length; i++ )
{
if ( o.texCoords[ i ] != null )
{
this.texCoords[ i ] = o.texCoords[ i ].duplicateGeomData( true );
}
}
}
if ( o.vertexAttribs != null )
{
this.vertexAttribs = new GeomNioFloatData[ o.vertexAttribs.length ];
for ( int i = 0; i < vertexAttribs.length; i++ )
{
if ( o.vertexAttribs[ i ] != null )
{
this.vertexAttribs[ i ] = o.vertexAttribs[ i ].duplicateGeomData( true );
}
}
}
// }
It seems that something in the drawing code is still depending on the separate buffers to exist when it is drawing Triangle Arrays that are interleaved. I'm still not acquainted with the drawing code well enough to find that yet. There is no problem when you instead copy Indexed Triangle Arrays (this worked fine with all of the collada models I've been using).
So, for my purposes, just dropping those two lines has solved my problems, but it seems that there might be a bug somewhere else that this is hiding. If you have interleaved data, it *shouldn't* matter whether your texture coordinates and normals have been copied as separate buffers. But apparently it does. either that or geometry is getting set as interleaved that is not.