Jump to content

Optimizing ObjectMeshSkinned loading


photo

Recommended Posts

Hello,

 

I try to optimize the creation/loading of our "avatar" at runtime.

As I am working on a online game it can happen that the game need to create more than one "avatar" at the same time.

So I made some "performance" test and for example creating 100 avatars took approximately 5 seconds.

Instead of loading the node (which contains the ObjectMeshSkinned) and loading the skinner script each time I try to preload/clone them.

But at the end it still too long.

 

Here is my code

        Avatar(ObjectMeshSkinned preloadedMesh, Unigine::Skinner::Skinner precreatedSkinner, Unigine::Schemer::SchemerScript preloadedScript)
        {
            Node clonedNode = preloadedMesh.clone();
            _mesh = class_cast("ObjectMeshSkinned", clonedNode);
            class_append(_mesh);

            _skinnerMesh = new Unigine::Skinner::SkinnerMesh(precreatedSkinner, _mesh);

            _skinnerMesh.setScript(preloadedScript);

            initialize();
        }

After commenting lines to find which line took all the time if found that it is

            _skinnerMesh.setScript(preloadedScript);

I take a look at the code of skinner_mesh.h and I see that the script is compiled.

Is there a way to preload and precompile a script and then to clone it ? So I have not to compile the script each time I create an avatar ?

 

Thanks.

Link to comment

ok,

so the only solution I have if a want to optimize the create of many skinner mesh at the same time is to have a "pool" of object precreated and then take object from the pool instead of creating new one ?

Link to comment
×
×
  • Create New...