Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

11991 Posts in 1587 Topics- by 3508 Members - Latest Member: NevilleKemp

26. May 2012, 02:02:40 pm
Xith3D CommunityGeneral CategorySupport (Moderator: Marvin Fröhlich)QuadArray getTriangle method seems wrong
Pages: [1]
Print
Author Topic: QuadArray getTriangle method seems wrong  (Read 284 times)
rwb1977
Enjoying the stay
*
Offline Offline

Posts: 45


View Profile
« on: 25. May 2010, 10:46:18 pm »

QuadArray has a "getTriangle" method.  However, I think it may be wrong.

If i is 0, the indices of the vertices for the triangle are computed as 0, 1, 2.

If i is 1, the indices of the vertices for the triangle are computed as 1, 2, 3.  It should be something like 0, 2, 3 or 2, 3, 0 shouldn't it?  As a result, picking quad arrays results in an unpickable area.

Logged
horati
Global Moderator
Getting respectable
*****
Offline Offline

Posts: 393


View Profile
« Reply #1 on: 26. May 2010, 11:56:07 am »

Seems like a bug to me.  Marvin wrote the picking library so he'll know more.
Logged

Kevin
"It may not seem like a big deal, but ignorance of character encoding issues leads to insidious code rot akin to y2k."
http://stackoverflow.com/users/3474/sylvarking
rwb1977
Enjoying the stay
*
Offline Offline

Posts: 45


View Profile
« Reply #2 on: 26. May 2010, 02:07:09 pm »

This seems to be the fix for QuadArray.java:
Code:
/**
     * {@inheritDoc}
     */
    public boolean setTriangle( int i, Triangle triangle )
    {
        final int idx0;
       
        idx0 = ( ( i / 2 ) * 4 ) + 0;
       
        if (i % 2 == 0)
        return ( setTriangle( idx0 + 0, idx0 + 1, idx0 + 2, triangle ) );
        else
        return ( setTriangle( idx0 + 2, idx0 + 3, idx0 + 0, triangle ) );
    }
   
    /**
     * {@inheritDoc}
     */
    public boolean getTriangle( int i, Triangle triangle )
    {
        final int idx0;
       
        idx0 = ( ( i / 2 ) * 4 ) + 0;

        if (i % 2 == 0)
        return ( getTriangle( idx0 + 0, idx0 + 1, idx0 + 2, triangle ) );
        else
        return ( getTriangle( idx0 + 2, idx0 + 3, idx0 + 0, triangle ) );
    }
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #3 on: 27. May 2010, 01:21:54 am »

Good work. I have committed your fix.

Marvin
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic