Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

11991 Posts in 1587 Topics- by 3509 Members - Latest Member: lioneltenel

26. May 2012, 10:11:38 pm
Xith3D CommunityGeneral CategorySupport (Moderator: Marvin Fröhlich)ArrayIndexOutOfBoundsException in calculateFaceNormals()
Pages: [1]
Print
Author Topic: ArrayIndexOutOfBoundsException in calculateFaceNormals()  (Read 891 times)
Hervé
Just dropped in

Offline Offline

Posts: 13


View Profile
« on: 07. May 2007, 04:44:32 pm »

The GeomIndexedContainer.calculateFaceNormals() crashes with an ArrayIndexOutOfBoundsException if called on an IndexedTriangleStripArray with multiple strips (well maybe with a single strip too, I didn't check).
 
The face loop index overflows because in case of an IndexedTriangleStripArray, the face count is not equal to
Code:
int numFaces = validIndexCount / faceSize;
but it should be something like:
Code:
int numFaces=0;
for( int stripCount : super.stripCounts )
{
    numFaces += stripCount - 2;
}
as for a single strip of n points, you define n-2 faces.

Anyway, for that kind of geometries, maybe should we not rely on an automatic normals generation.


Hervé
Logged

A designer knows he has achieved perfection not when there is nothing left to add, but when there is nothing left to take away.
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #1 on: 07. May 2007, 06:35:48 pm »

Could you please test, it it works? Then I will happily commit your fix.

Marvin
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic