www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: AGP on January 10, 2018, 03:16:28 pm

Title: rotateMesh Bug
Post 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().

Code: [Select]
if (ship instanceof Blah) {
     ship.body.rotateY((float)Math.PI*.5f);
     ship.body.rotateMesh();
     ship.body.clearRotation();
}
Title: Re: rotateMesh Bug
Post by: EgonOlsen on January 10, 2018, 03:36:34 pm
Most likely because you've stripped the object it's being called on.
Title: Re: rotateMesh Bug
Post by: AGP on January 10, 2018, 04:20:12 pm
So is there no way for me to rotate and clear the object's matrix at that point?
Title: Re: rotateMesh Bug
Post by: EgonOlsen on January 10, 2018, 06:05:26 pm
Just don't call strip() on the object and it should work.
Title: Re: rotateMesh Bug
Post by: AGP on January 10, 2018, 06:12:16 pm
But then it's going to cost me performance, right?
Title: Re: rotateMesh Bug
Post by: EgonOlsen on January 11, 2018, 08:28:22 am
No, just some memory.
Title: Re: rotateMesh Bug
Post by: AGP on January 11, 2018, 04:30:28 pm
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?
Title: Re: rotateMesh Bug
Post by: EgonOlsen on January 11, 2018, 09:58:02 pm
Well...I can't. strip() strips away stuff that is needed to do it, so...
Title: Re: rotateMesh Bug
Post by: AGP on January 12, 2018, 03:45:29 am
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.