[osg-users] Get Animation current time

Robert Osfield robert.osfield at gmail.com
Fri Jan 4 08:48:00 PST 2019


Hi Diego,

On Fri, 4 Jan 2019 at 16:16, Diego Mancilla <dmancillac at gmail.com> wrote:
> I have another question rather technical. As per now a have a lot of moving objects. I'm using standard AnimationPath instances for each one of them. Also y have a lot a control points for each one (20k+). So filling the AnimationPaths instances is very slow. Then:
>
> 1- Can I using OpenMP or standard Qt threading parallelize the insertion of control points?

Multi-threading adds it's own overhead and complexity, one should
avoid if you can.

> 2- Are osg classes threadsafe? I mean, can I send the generation (filling) of each AnimationPath on a different thread (and then use the addChild method)?

Most low level OSG methods are deliberately not made thread safe as
the overhead and syncronization required would lead to lower
performance.  The types of multi-threading the OSG does support are
high level multi-threading, such as for database paging or viewer
level threading.

> 3- Is there another alternative to improve performance on this matter?

The best solution totally depends on the specifics of the problem you
are trying to solve. From the description it sounds like AnimationPath
and AnimationPathCallback won't scale well to handle what you want
from them.  There were never designed for massive numbers of control
points, let alone cases where control points are being added
dynamically.

However, the OSG is written to be extensible and customizable so if
the off the shelf features don't do exactly what you want or perform
well for your particular usage model then you can roll your own, and
as the OSG is open source you can learn from the exisiing
implementations to see how they hook into the rest of the OSG, so in
your own implementations you can follow this.

So for you, it may well be best to just write your own
AnimationPath+Callback scheme that provides a good public interface
that suits your needs and an internal implementation that performance
well for you usage case.

It may be even that you'd want to start writing really custom schemes
that involve the shaders as well as high level custom interfaces.  For
instance if you have 10's of thousands of objects that are all the
same but all have different positions you can use geometry instancing
and pack the positions into uniform arrays or textures and upack the
positions in the vertex shader and place the objects.  This way you
could just update an array of positions once per frame and all the
objects would update.  If you had an animation path that had regular
intervals then potentially you encode this into one or more 1D
textures and look up the position, rotation and scale from this
texture.

Robert.


More information about the osg-users mailing list