Explicit updateModelBound()

Hi all,



I updated last week (maybe 2 weeks ago) to the latest build and noticed that some of my picking code stopped working. I have a selectables Node and all the game pieces that can be selected in the game get added to this selectables node. Then, while determining the picking, I leverage the name of the node picked to pass this info further down into the game logic. Anyway, some of my Geometry objects became no longer pickable. However, after all game pieces (Geometry and other Nodes) are fully added to the selectables node, I threw in an explicit call to updateModelBound() and everything is working again.



It’s odd that before I never had to call updateModelBound() but now after updating I do. Was this an introduced bug, or is this by design?

You are using the stable build? That should not be, no. @Momoko_Fan?

i have the same with terrain. When i remove “updateModelBound()” then lod/etc don’t work. (as i good understand it’s/should be automaticly)

Do I have to ask the same question again? -.-

yes i use stable version, no nifty here, no nightly version



edit: plugins → setting is: stable, users contributions and NBAndroid updates. No Nightly

Using jme3 library:

Version: 3.0.0.8509 Source: jMonkeyEngine SDK 3.0beta



Can’t remember exactly when I updated, but it wasn’t that long ago (time flies between work, family and working on my game :stuck_out_tongue: )

@Pandaemonium said:
Version: 3.0.0.8509 Source: jMonkeyEngine SDK 3.0beta

That one came with beta.. Theres been updates in the meantime. Just go to Help->Check for Updates

Ok, I’ll update to latest. I’ll let ya know how it goes.

it needed one update for me but after it one exception:


java.io.FileNotFoundException: C:UsersoxplayAppDataRoaming.jmonkeyplatform3.0betamodulesextnifty-default-controls-1.2.jar (Nie można odnaleźć określonego pliku)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:114)
at java.util.jar.JarFile.(JarFile.java:135)
at java.util.jar.JarFile.(JarFile.java:114)
at org.netbeans.JarClassLoader$JarSource$1.call(JarClassLoader.java:468)
at org.netbeans.JarClassLoader$JarSource$1.call(JarClassLoader.java:461)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at org.netbeans.JarClassLoader$JarSource.getJarFile(JarClassLoader.java:490)
at org.netbeans.JarClassLoader$JarSource.listCoveredPackages(JarClassLoader.java:559)
at org.netbeans.JarClassLoader.getCoveredPackages(JarClassLoader.java:837)
at org.netbeans.JarClassLoader.(JarClassLoader.java:161)
at org.netbeans.StandardModule$OneModuleClassLoader.(StandardModule.java:691)
at org.netbeans.StandardModule.createNewClassLoader(StandardModule.java:632)
at org.netbeans.StandardModule.classLoaderUp(StandardModule.java:621)
at org.netbeans.ModuleManager.enable(ModuleManager.java:908)
at org.netbeans.core.startup.ModuleList.installNew(ModuleList.java:318)
at org.netbeans.core.startup.ModuleList.trigger(ModuleList.java:254)
at org.netbeans.core.startup.ModuleSystem.restore(ModuleSystem.java:294)
at org.netbeans.core.startup.Main.getModuleSystem(Main.java:172)
at org.netbeans.core.startup.Main.start(Main.java:308)
at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:123)
[catch] at java.lang.Thread.run(Thread.java:619)


just an exception, but better to report it :)

Yeah, also for an old nifty file… Gonna check where that is referenced… Should definitely not be lethal.

@oxplay2 said:
i have the same with terrain. When i remove "updateModelBound()" then lod/etc don't work. (as i good understand it's/should be automaticly)


Do you manage your own rootNode by any chance or are you using the rootNode provided by SimpleApplication?

Same issue persists.



Using:

Version: 3.0.0.8725 Source: jMonkeyEngine SDK Stable

'@pspeed: the rootNode provided by SimpleApplication :slight_smile:



edit: dont checked if deleting it will crash after actual update

For me, I use the rootNode provided by SimpleApplication and my selectables node is added to this rootNode. This to seems have always worked for me without having to explicitly call updateModelBound() until I updated to the beta build.

I know it would be a pain… but it might help to know which revision the problem started showing up. Building from SVN isn’t too bad. :stuck_out_tongue:

hmmm it’s hard to say. I remember to always have terrain.updateModelBound(); becouse of having some problems… just diffrent problems…

last week i tried delete it and it was culling GirdQuad it should not cull… and now i delete it again and the same happend.



Since when it started i really can’t help :confused:







EDIT:



sorry now i looked more into it.



i had:



terrain.setModelBound(new BoundingBox());

terrain.updateModelBound();



deleting both seem to work too… dont know from what documentation i get setModelBound for terrain and i dont know if its needed

Simply odd. I compared to HelloPicking and I’m doing the very same thing, though the issue doesn’t seem to exist in HelloPicking.



Here’s what I’m doing:



inside simpleInitApp:

[java]selectables = new Node(“Selectables”);

rootNode.attachChild(selectables);[/java]



[java]combatManager.setNode(selectables); // all pickable Nodes and Spatials are added to selectables

combatManager.startEncounter();

selectables.updateModelBound(); // commenting this out makes picking fail[/java]



Then, in onAction, I do:



[java]

Ray ray = new Ray(origin, direction);

CollisionResults results = new CollisionResults();

selectables.collideWith(ray, results);

System.out.println("


Collisions? " + results.size() + "
");

for (int i = 0; i < results.size(); i++) {
CollisionResult result = results.getCollision(i);
String hitName = result.getGeometry().getName();
Vector3f pt = result.getContactPoint();
System.out.println("hitName= " + hitName);
if (hitName.startsWith("Shape")) {
combatManager.pickedShape(player.getName(), result.getGeometry().getParent().getName());
break;
} else if (hitName.equals("map")) {
combatManager.pickedTile(player.getName(), pt);
break;
}
[/java]

What's interesting here is that even if I comment out the explicit call to updateModelBound(), I can still get collision hits on the map. However, all my "Shape" objects in the game do not ever get hit unless I have the call to updateModelBound(). A Shape in my game is simply a class that extends Node and contains Geometry that is attached to it (the Shape node is added to the selectables node).

Not sure what it is exactly about the relationship here that is causing the Shape nodes to not be pickable unless I call updateModelBound().

Aaah… Yeah, when you set a BoundingBox you have to call updateModelBound… But I think that should be changed too… @Momoko_Fan? Any reason its not directly updated? Do we just need to set the flag? Anyway all shapes have BoundingBoxes by default, so no need to set them.

@Pandaemonium



You might try reducing the issue to a simple test case. At best, it gives others something to run, at worst you find your problem.



Or are you also explicitly setting a bounding box?

and btw i still have problem with shadows mentioned in old posts…



i hope it will be fixed by LWJGL for intel graphic card. many people have laptops with integrated intel GMA graphics