Author Topic: rotateMesh Bug  (Read 4125 times)

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
rotateMesh Bug
« 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();
}

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: rotateMesh Bug
« Reply #1 on: January 10, 2018, 03:36:34 pm »
Most likely because you've stripped the object it's being called on.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: rotateMesh Bug
« Reply #2 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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: rotateMesh Bug
« Reply #3 on: January 10, 2018, 06:05:26 pm »
Just don't call strip() on the object and it should work.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: rotateMesh Bug
« Reply #4 on: January 10, 2018, 06:12:16 pm »
But then it's going to cost me performance, right?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: rotateMesh Bug
« Reply #5 on: January 11, 2018, 08:28:22 am »
No, just some memory.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: rotateMesh Bug
« Reply #6 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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: rotateMesh Bug
« Reply #7 on: January 11, 2018, 09:58:02 pm »
Well...I can't. strip() strips away stuff that is needed to do it, so...

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: rotateMesh Bug
« Reply #8 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.