www.jpct.net
jPCT - a 3d engine for Java => Support => Topic started by: AGP on January 10, 2018, 03:16:28 pm
-
The following code doesn't crash with Object3D.rotateY(...) but crashes with a NullPointerException on Object3D.rotateMesh().
if (ship instanceof Blah) {
ship.body.rotateY((float)Math.PI*.5f);
ship.body.rotateMesh();
ship.body.clearRotation();
}
-
Most likely because you've stripped the object it's being called on.
-
So is there no way for me to rotate and clear the object's matrix at that point?
-
Just don't call strip() on the object and it should work.
-
But then it's going to cost me performance, right?
-
No, just some memory.
-
Still... I made a hack, just compiling (then decompiling before rotation) for that one specific ship. Wouldn't it be better to just make rotateMesh() work in some form or another, though?
-
Well...I can't. strip() strips away stuff that is needed to do it, so...
-
What about some logic to hide the fact that the matrix has not been cleared? Is that too convoluted? Even just a better message when throwing the exception would help. But in this particular example, you select your ship from inside a hangar. The whole thing is already short of 400k triangles, so I need all the optimization I can get inside the hangar. The game itself, naturally, has a different orientation to the hangar (since the ships have to be positioned aesthetically relative to the player). Thus my little hack.