Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

11855 Posts in 1569 Topics- by 3045 Members - Latest Member: lensreslai

10. February 2012, 05:39:09 AM
Xith3D CommunityXith3D InternalsDeveloper discussion (Moderators: Marvin Fröhlich, 'n ddrylliog)jagatoo GeometryDataContainer copyFrom issue with Triangle Arrays
Pages: [1]
Print
Author Topic: jagatoo GeometryDataContainer copyFrom issue with Triangle Arrays  (Read 563 times)
ford.304
Enjoying the stay
*
Offline Offline

Posts: 30


View Profile Email
« on: 16. October 2009, 02:30:59 PM »

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.
Code:
        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()))
Code:
//        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.
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic