You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When writing an OrderedGroup that has its index array set to null, j3d throws:
java.lang.NullPointerException
at
com.sun.j3d.utils.scenegraph.io.state.javax.media.j3d.OrderedGroupState.writeObject(OrderedGroupState.java:63)
Not sure if this is a bug, as one can always set the array, but considering Null is a legit value regarding the official OrderedGroupState docs, it would be nice if OrderedGroupState could handle an empty index array.
psymagic commented 21 hours ago
After investigating a little further, it really seems like someone forgot to implement io for the case of OrderedGroup.getChildIndexOrder() == null.
Just did a working fix with these lines in com.sun.j3d.utils.scenegraph.io.state.javax.media.j3d.OrderedGroupState:
@OverRide
public void writeObject(DataOutput out) throws IOException {
super.writeObject(out);
int[] childIndexOrder = ((OrderedGroup) node).getChildIndexOrder();
if (childIndexOrder == null) {
out.writeInt(0);
} else {
out.writeInt(childIndexOrder.length);
for (int i = 0; i < childIndexOrder.length; i++) {
out.writeInt(childIndexOrder[i]);
}
}
}
@OverRide
public void readObject(DataInput in) throws IOException {
super.readObject(in);
int length = in.readInt();
int[] childIndexOrder;
if (length == 0) {
childIndexOrder = null;
} else {
childIndexOrder = new int[length];
for (int i = 0; i < childIndexOrder.length; i++) {
childIndexOrder[i] = in.readInt();
}
}
((OrderedGroup) node).setChildIndexOrder(childIndexOrder);
}
It might not be perfect thou.
The text was updated successfully, but these errors were encountered:
When writing an OrderedGroup that has its index array set to null, j3d throws:
java.lang.NullPointerException
at
com.sun.j3d.utils.scenegraph.io.state.javax.media.j3d.OrderedGroupState.writeObject(OrderedGroupState.java:63)
Not sure if this is a bug, as one can always set the array, but considering Null is a legit value regarding the official OrderedGroupState docs, it would be nice if OrderedGroupState could handle an empty index array.
psymagic commented 21 hours ago
After investigating a little further, it really seems like someone forgot to implement io for the case of OrderedGroup.getChildIndexOrder() == null.
Just did a working fix with these lines in com.sun.j3d.utils.scenegraph.io.state.javax.media.j3d.OrderedGroupState:
@OverRide
public void writeObject(DataOutput out) throws IOException {
super.writeObject(out);
}
@OverRide
public void readObject(DataInput in) throws IOException {
super.readObject(in);
}
It might not be perfect thou.
The text was updated successfully, but these errors were encountered: