MeshDrawer know when node is render

I always had the being/end interface in MeshDrawer because it just seem most natural to me (coming from openGL and they way i wanted to use this)

Basically what i do on begin: i open GeomReWriters and compute some stuff and when i do end I close them and clear the remaining triangles to 0. Now i want to do this only when frame is about to be rendered.

1 How would I get “this node is about to get renders” event to clear then end of the geom and close it?

2 Then “we are done rendering this geom” open the GeomReWriters again?

3 Or is it possible to do this at the same time?


Override cull_callback(). This method is called when the node is visited during the cull traversal (which is to say, when Panda is collecting geometry for rendering).

You’ll also need to call set_cull_callback() in your constructor to indicate that you have a customized cull_callback() method; this is a minor performance optimization.

There are lots of examples of nodes that override cull_callback(), like TextNode, CollisionNode, and PGItem.


Thanks, but when do I know that the Geometry rendering is done? I will look into how those classes do it when i get home.

What do you mean by “done”–do you mean that all the processing of the child nodes is complete? You can upcall to the base class’s cull_callback(), and when that returns, then all of the child nodes have been processed.

By “processed” I just mean that the Geoms have been extracted from the nodes and added to a list for rendering. The actual draw calls are issued later, of course.


It looks like the only way i get to cull_callback()/set_cull_callback() is if my class is actually a PandaNode(). There is no other way? Redesign!

I’m not sure what you’re asking for, then, if your node isn’t a PandaNode. You want to get notified when the global draw operation begins and ends? You would probably be best off doing that from the high level, for instance with a task.

The reason it doesn’t make sense at the low level is that, technically, there’s no such thing as a “global” draw operation. Panda is capable of having multiple draw operations going on in parallel, with different scenes, different graphics cards, maybe even different GraphicsEngines. In practice, an application will typically create just one GraphicsEngine and do all the rendering in one thread (especially because parallel rendering support isn’t complete yet), so it is possible for an application to know when the global draw is beginning and ending; but it isn’t possible for the low-level code to know this.