Bug in FloatBufferData?

A forum for discussing development work on the Ardor3D core systems. Basically, anything that is in the ardor3d-core, math or savable modules.
Forum rules
Developer discussions only. Newbie questions belong in the HELP! forum. This is a forum for discussing development work on the Ardor3D core systems. Basically, anything that is in the ardor3d-core, math or savable modules.

Bug in FloatBufferData?

Postby fuchs » Tue Aug 17, 2010 11:25 am

Ok, after having tried to update texture coordinates of a box to go along with a tiled texture for half an hour trying to figure out what I was doing wrong this time, I decided to switch tactics and blame it on Ardor3d rather than me ;) Joking aside, I think there is a bug in FloatBufferData that affects both scaleData() and translateData().

The problem is the termination criterion of the loop:

Code: Select all
for (int i = 0; i < _buffer.remaining();) {
       _buffer.put(_buffer.get(i) * scales[i % scales.length]);
        i++;
}


Because i is incremented while remaining() decreases with every put(), you'll end up updating only the first half of the stored values, as at this point i == remaining(). The loop therefore rather must be

Code: Select all
for (int i = 0; i < _buffer.limit();) { ...}


At least this makes the texture coordinates behave as I expect after applying scaleData(). Attached a patch in case I should be right.
Attachments
FloatBufferData-patch.txt
(815 Bytes) Downloaded 90 times
Artificial Intelligence is no match for Natural StupidityTM.
User avatar
fuchs
newcomer
 
Posts: 48
Joined: Tue Apr 21, 2009 2:45 am
Location: Sankt Augustin, Germany

Re: Bug in FloatBufferData?

Postby renanse » Tue Aug 17, 2010 11:32 am

doh. :( Thanks. Up in svn
Gratitude is a mark of a noble soul and a refined character.
User avatar
renanse
Site Admin
 
Posts: 2955
Joined: Tue Oct 28, 2008 6:49 pm
Location: Austin, TX


Return to Core Development Discussions

Who is online

Users browsing this forum: No registered users and 1 guest

cron