sdk icon indicating copy to clipboard operation
sdk copied to clipboard

j3o caching in scenecomposer

Open neph1 opened this issue 3 years ago • 7 comments

User (kevinba99) report:

I asked this question before and I didn’t get any real help. But I’m noticing that the SDK and J30 scene editor is caching the file and editing the cached file and not the actual file inside the SDK (netbeans). I can’t figure out how to get rid of caching and done some searches and nothing has helped.

file snake.glb → conver to j3o. I open it and rename a node to “snake”, “body”, “eyes”. Save it.

Go back into blender, make a change, changed color to black on the snake. Go back into SDK, it asks if I want to update it. I say yes. then open the scene editor and the snake still brown. I view it in a object viewer outside of the SDK and it is black.

I delete the j3o file. Go back into SDK and convert model to j3o again and reopen it. It is till brown. and the nodes are still renamed even though the glb file has obj1 obj2 obj3 for names.

I then delete the j3o again. Then in file manager rename the snake.glb to snake1.glb and go back into SDK and conver snake1.glb to j3o. Open snak1.j3o in scene editor and now the snake is black, and the nodes are obj1, obj2 and obj3.

Then go to file manager and rename snake1.* (blg, j3o and j3odata) back to snake.*. Go back into SDK and open snake.j3o in scene editor and the snake is brown again and node name are still renamed, even though in the j3o file they are not.

https://hub.jmonkeyengine.org/t/j3o-scene-and-sdk/45421

neph1 avatar Mar 23 '22 14:03 neph1

This isn't actually a bug, merely an unexpected outcome. The message says it will update the mesh data, and it does, even if the object is open in the SceneComposer. It even has options for animations. It doesn't however update anytyhing else, like materials or names of the objects.

neph1 avatar Mar 23 '22 15:03 neph1

I propose to expand this to include more data, including materials.

neph1 avatar Mar 23 '22 15:03 neph1

So, there are a number of things at play here;

  1. Changing names of the meshes produces an NPE in the auto converter. The root cause is that it uses the names to find the spatials in the scenegraph (if I read it correctly).
  2. It uses AnimControl when wanting to replace animations.

I've produced a PR with two changes:

  1. It replaces the material of the old spatial with the new. Just a naive setMaterial(). Don't know if it needs anything more than that.
  2. I've added a null check if it doesn't find a spatial due to name change. It's mostly a work around to avoid throwing an error.

I'll look into the AnimControl too, but I'll do it in a separate PR

neph1 avatar Mar 23 '22 17:03 neph1

Just one note here, that there may indeed be a cache, but we're talking stock jme there: AssetManager has a weak-key cache on assets, so even if you were to re-load the whole asset by string (and we don't have any other caching in place, that is), you'd end up with a cached version.

MeFisto94 avatar Mar 23 '22 21:03 MeFisto94

I looked at the caching, and it seems to be used and closed. Updating the spatial really works fine, it's just that it doesn't do more than update the mesh. In my case I think I've been misled by that and the fact that it didn't use AnimComposer.

neph1 avatar Mar 24 '22 08:03 neph1

Noticed that it doesn't update spatial positions if you move them, either. Would be a pretty good nice-to-have as well.

neph1 avatar Mar 24 '22 17:03 neph1

Should be solved by https://github.com/jMonkeyEngine/sdk/pull/316

neph1 avatar May 11 '22 07:05 neph1