for (String key: new ArrayList(spatial.getUserDataKeys()))
spatial.setUserData(key, null);
simple as that
for (String key: new ArrayList(spatial.getUserDataKeys()))
spatial.setUserData(key, null);
simple as that
I totaly agree, but one should have the possibility to assign user data to scenegraph elements
groovy
this one even better :
for (String key: new ArrayList<String>(spatial.getUserDataKeys()))
spatial.setUserData(key, null);
yes maybe I should add a custom prefix for the blender object custom properties
so I dont whipe internal JME stuffs
thanks
in the case one dont use setUserData, what in the case you got thousands of objects, you only need to check what real-non-jme-programmer-internal data is associated with a particular spacial ???
I donāt even know why you would need to do this.
Is it really a use case that code randomly is adding stuff to your spatials and you donāt know about? Do you have like a team of 50 guys just setting someSpatial.setUserData(āSomeCrapWeDonātReallyNeedā, 1)?
Itās a bit mind boggling that itās possible to be so completely unaware of what one part of your app is doing that you need to whack it all with a nuke every now and then.
āJME shouldnāt be setting stuff to user dataā¦ but itās totally cool if the blender loader does itā¦ā uhhhā¦
??? what if you click one a spatial, could be anything, any king of object, your game logic has to figure what kind of object
and you dont use getName cos defining behaviour from an object name is dodgy, what if the name changes
personaly I dont like that approachā¦
first I used Control class for my AI/Game logic, then I realized I should implement my own Controller classes to do that instead (you pointed that to me actually in another thread)
so I obviously need to have some link between some spatials in the scenegraph and some of my Controller instances
cos Spatial and Control classes are not supposed to hold game items/characters data/stats
thatās allā¦
and I never said anything like āJME shouldnāt be setting stuff to user dataā¦ but itās totally cool if the blender loader does itā¦āā¦ I asked why the Blender importer did thatā¦cos they are user (not JME) defined propertiesā¦nothing internal
so following your logic, it shouldānt do that
The point he makes is that your code should know what it sets so it should also know what it has to remove. If we followed your logic then there also shouldnāt be anything like AnimControls or stuff like that because āControls are for usersā and āusers should be able to remove all Controls from a Spatial without having to fear that they remove a Control added by jMEāā¦
ok then Iāll use setUserData with my own prefix, and that solves it
jME3 uses UserData internally for certain fields which are uncommon or which make sense in only specific scenarios. All jME3 UserData fields are prefixed with the string "Jme"
. To avoid collisions, you should not start your fields with the string "Jme"
.
tadaaaaa, finaly
thanks mate
Thats only the case for two of the UserData entries that the engine uses.
ā¦this part I donāt understand. My contention all along is that JME might put stuff in there. Of course you can also put stuff in thereā¦ I never said otherwise.
Just that itās bad practice to want to clear everythingā¦ because itās incredibly reckless and a sign that your code is hopelessly seat-of-the-pants.
sorry I just got you worng
I agree clearing blindly that list is really not a good idea if jme stores stuff in there