So doing something completely unrelated to billboard controls appears to have crashed the app as seen here:
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NullPointerException
at com.jme3.scene.control.BillboardControl.rotateScreenAligned(BillboardControl.java:197)
at com.jme3.scene.control.BillboardControl.rotateBillboard(BillboardControl.java:133)
at com.jme3.scene.control.BillboardControl.controlRender(BillboardControl.java:103)
at com.jme3.scene.control.AbstractControl.render(AbstractControl.java:119)
at com.jme3.scene.Spatial.runControlRender(Spatial.java:590)
at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:655)
at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:665)
at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:665)
at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:665)
at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:665)
at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:665)
at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:665)
at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:665)
at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:640)
at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:974)
at com.jme3.renderer.RenderManager.render(RenderManager.java:1029)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:252)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
at java.lang.Thread.run(Unknown Source)
I’ve looked into BillboardControl,java and it seems to break on this conditional:
This one doesn’t make any sense since it’s a null check and that can’t possibly give a null pointer exception since that’s the whole point of it, right?
Here:
private void rotateBillboard(Camera cam) {
switch (alignment) {
case AxialY:
rotateAxial(cam, Vector3f.UNIT_Y);
break;
case AxialZ:
rotateAxial(cam, Vector3f.UNIT_Z);
break;
case Screen:
rotateScreenAligned(cam); //line 133
break;
case Camera:
rotateCameraAligned(cam);
break;
}
}
I’d say you have a Version Mismatch (e.g. running 3.0 but looking into alpha-2 code).
However good that you came up with it since the Billboard needs some love anyway.
Here’s what I found back then.
I’ll search for what I finally had back then however since I couldn’t build up a decent Test Case I could never ensure it fully works.
So either getWorldRotation(), or inverse() return null.
Could you possibly print out the worldRotation Matrix?
If it isn’t null (possibly due to you modifiying it or not updating the geometric state), then it could be we have an error in inverting Matrices.
Anyway, sound’s like fun to fix I’ve heard @nehon absolutely loves doing Math
PS: I don’t get what you mean with “modify 3.0”? Are you running 3.0? (In that case my code snippet could be wrong again ).
And with Test Case I mean the BBControl in General as it didn’t rotate correctly I think, however my test case: A rotating quad and a fixed camera wasn’t enough it seems.
Well it happens 100% of the time so I’m sure it’s not a multithreading thing, and the matrices cannot possibly be wrong as that would have shown up ages ago by everything breaking everywhere, no?
Math. Not even once.
I’m on 3.0, but I checked the sources that come with the distribution and the snippet is correct. This makes it even more bizzare.
You can’t tell that without simply checking it.
What means 100% of the time? As in you can’t launch your game anymore? So what triggered that issue?
Anyway such an error is always possible: If the rotation would be a bit off nobody would see it however you could have an edge case such as division by zero or w/e went wrong there.
So just show us the WorldRotation, I guess it’s null, but if not, it’ll be fun to see the inverse
Well since it’s only one line difference it could always be some misinterpreted newline or whatever happened there but it’s definately the second line then.
It happens every time a ship’s number of modules becomes zero, which is sort of irrelevant info as the billboards shouldn’t be affected at all, since they don’t have anything do do with it and aren’t attached to it. This appears to only trigger the real cause which I have no idea what it could be.
I’m sure that that doesn’t break anything on my end otherwise, because I just tesed by removing every use of billboards.
It’s not null, just some value it happens to be and the inverse seems good too.
but the the spatial with the control attached that is causing the problem is detached from the scene graph at the moment of the crash. Why does the control even run then?
If this is the case, you’re in big trouble then. A Multitasking Issue isn’t that unrealistic then, it seems Good Luck anyway!
Another idea: Since you’ve already copied the code of the Billboard control:
Check every place where we’re setting rotations. Maybe you find the error there.
I’m pretty sure there’s a larger problem since I’ve noticed all other ships dissapear when yours looses all modules. Most likely physics spazzing out because of reverse movement to keep player at origin when suddently player’s mass is 0.
Physics tend to set invalid rotations, yes!
Especially when their Velocitys are being set invalidly.
Note: Setting mass to 0 sounds also wrong. It’s not possible in the real world.
And when you want to make it solid ensure you create a new RigidBodyControl (or w/e) for this purpose
Okay, it doesn’t work in the physics engine world
For example: applyForce -> 180N a = F / m => a = Float.NaN or a = Float.INFINITY
I don’t know which would acctually happen on a DIV BY ZERO
Doesn’t your ship have a default mass? As in the ECU’s weight being 10kg or something. It could even be 1 / 10^121238 but > 0
Weird… because 0 mass will definitely cause the exact sort of problems you are seeing. Physics rarely deals with math and deals with 1/mass instead. So mass = 0 in a physics engine will NaN everything that’s ‘integrated’ (the math term) as part of the physics loop.
Otherwise the physics engine will try to run physics for it and NaN everything.
I’ve never used bullet before so I could be wrong. But every physics engine I’ve ever used, (plus the one I wrote) will do bad things if you set mass = 0 to an object managed by physics then bad things will happen. Many physics engines supply a setter for inverse mass instead to avoid this issue. (inverseMass = 0 = static object)
But whatever… some setting is wrong somewhere if rotation ends up NaN. Setting mass to 0 is one of the things that will do that.