Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scenegraph.io Problem with OrderedGroup #3

Open
psymagic opened this issue Jan 11, 2016 · 0 comments
Open

scenegraph.io Problem with OrderedGroup #3

psymagic opened this issue Jan 11, 2016 · 0 comments

Comments

@psymagic
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant