rotateMesh Bug

Started by AGP, January 10, 2018, 03:16:28 PM

Previous topic - Next topic

AGP

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();
}

EgonOlsen

Most likely because you've stripped the object it's being called on.

AGP

So is there no way for me to rotate and clear the object's matrix at that point?

EgonOlsen

Just don't call strip() on the object and it should work.

AGP

But then it's going to cost me performance, right?

EgonOlsen


AGP

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?

EgonOlsen

Well...I can't. strip() strips away stuff that is needed to do it, so...

AGP

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.