kapa76 / jmonkeyengine

Automatically exported from code.google.com/p/jmonkeyengine
0 stars 0 forks source link

BufferUtils Bugs #572

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Multiple issues in BufferUtils in nightly and earlier.
The file needs to be gone over, as an example:

'''
    public static FloatBuffer createFloatBuffer(Quaternion... data) {
        if (data == null) {
            return null;
        }
        FloatBuffer buff = createFloatBuffer(4 * data.length);
        for (Quaternion element : data) {
            if (element != null) {
                buff.put(element.getX()).put(element.getY()).put(element.getZ()).put(element.getW());
            } else {
                buff.put(0).put(0).put(0);
            }
        }
        buff.flip();
        return buff;
    }
'''
And this is just one bug of many similar ones in a host of functions in this 
file.
The quarternion has 4 values, but in the case that the quaternion is null it 
puts in *3* zero's instead of 4.  This issue also exists in many other helper 
methods in this file.

Original issue reported on code.google.com by Overmind...@gmail.com on 13 Jan 2013 at 12:26

GoogleCodeExporter commented 9 years ago
hmm...wow.. how this hasn't been noticed before.
I guess the engine seldom use those methods and use the one with the float 
array as a parameter.

Thanks for reporting

Original comment by remy.bou...@gmail.com on 27 Feb 2013 at 10:28

GoogleCodeExporter commented 9 years ago
The put(0) problem is present exactly twice, here's the (trivial) patch:

Index: src/core/com/jme3/util/BufferUtils.java
===================================================================
— src/core/com/jme3/util/BufferUtils.java (Revision 10490)
+++ src/core/com/jme3/util/BufferUtils.java (Arbeitskopie)
@@ -195,7 +195,7 @@
if (element != null) {
buff.put(element.getX()).put(element.getY()).put(element.getZ()).put(element.get
W());
} else {
- buff.put(0).put(0).put(0);
+ buff.put(0).put(0).put(0).put(0);
}
}
buff.flip();
@@ -217,7 +217,7 @@
if (data[x] != null) {
buff.put(data[x].getX()).put(data[x].getY()).put(data[x].getZ()).put(data[x].get
W());
} else {
- buff.put(0).put(0).put(0);
+ buff.put(0).put(0).put(0).put(0);
}
}
buff.flip();

Original comment by toolfor...@gmail.com on 16 Mar 2013 at 11:28

GoogleCodeExporter commented 9 years ago

Original comment by remy.bou...@gmail.com on 16 Mar 2013 at 12:04

GoogleCodeExporter commented 9 years ago
Issue 579 has been merged into this issue.

Original comment by ShadowIs...@gmail.com on 16 Apr 2013 at 3:19