Feature Request: spatial.getId() and spatial.setId(long id)

Something I've been relying on in my PhysicsSynchronization code that I would rather not be relying on is the name of the spatial/physics object.  I would much rather have the ability to assign an id to each spatial that will be synchronized and then use that when communicating between servers.  Are there any reasons why we can add this?

I am starting work on jME-Networking and trying to re-analyze how I've done a lot of these things and this is the primary thing I'd like to change.  I'm adding functionality in JGN to make an abstract graphical synchronization system and then jME-Networking will simply be one interface implementation (this way I can create any other implementations just as easily).

This would not interfere with anything since it would simply be a long with a getter and setter that current code would simply not be using, but it would allow a simple way to maintain a handle between multiple environments.  Also, another feature that would go well with this is a node.getChildById(long id) to be able to look a spatial up by its id in a node.  If this is acceptable I'm happy to write and post the relevent code.



It was actually planned to replace strings with ids to save memory. But too many things relied on String names  (like your API too I guess…) and savings were marginal compared to the other saving we made anyway…

I personally think two sytems for identification is a bit overdone… do actually need the id to be inside the Spatial class? Why not just put the relation in a map (eg. IdentityHashMap), for example? At least the String names have another good purpose (debugging).

I can go that route, I was just thinking it would make it a little easier if it was already included in jME.  In reality it's probably better that my system maintains those relationships anyway.



llama said:

At least the String names have another good purpose (debugging).

How exactly would those strings help debugging?

If you are debugging code that handels hundreds of Spirals and crashes on one, you can fined out wtich one.

sorry badmi, i don't understand that.

usually nodes don't crash anything. with a good debugger the node names become obsolete (in respect to debugging at least).

…I've rarely seen applications with Spirals in them…what kind of games are you writing over there Badmi? :-p


Let me explane a little better. When I was developing code for JME and wanted to see how objects change from frame to frame I generated a list of all the objects values each frame. I needed a way to tell one object from another on that list, thats where the name came in.

I was using subclasses of Spirals not Spirals  themselves,

P.S.: The hundreds was an exaggeration, it was more like 3-10.  :wink:

They gives Spatials a name. So when set a breakpoint or something, and you're dealing with a Spatial object you can see which one it is. It also puts the name in the console output, I actually use that every now and then to see why something happened with a quick glance.

Identifiers are clearly the domain of the persistency- or networking-lib they really don't belong into Spatial. Some apps might need more sophisticated ids than just longs. Others might want to save memory and use only bytes…

good point