Batching with moving objects

what is the strategy/ methodology used when implementing batching with continuously changing scene? how do we handle if the view matrix is changing / number of objects in the scene are changing, do we generate the batch every frame? what about the objects which are not the scene but exists in the same batch where other objects are from that batch are in the scene, do we delete those meshes from the batch?

how do we handle the cases where mesh of the object is replaced or model matrix is modified?

“Batching” is not a single, specific technique. It is a general goal: to minimize the number of draw calls in your program. How to batch any particular system efficiently depends very much on the details of what that system is. There are numerous tools and techniques for decreasing the count of draw calls.

As such, it’s hard to answer any of your questions without knowing anything about what your scene is as well as how you’re presently batching stuff. All you’ve said is that you sometimes render certain meshes, and some meshes move around. That explains nothing about how you’re batching your scene already.

Portions of the geometry can be enabled and disabled without needing to rebuild the index array by using the multi-draw functions, e.g. glMultiDrawElements().

Parameters with finer granularity than uniform variables but coarser granularity than vertex attributes can be implemented using a vertex attribute which holds a mesh id; this can then be used to index into a uniform array of parameters, one per mesh.

That covers two of the most basic reasons why you might otherwise need to split a batch across multiple draw calls.

But as Alfonse says, there isn’t any single methodology for batching. You have to consider the kinds of variation which exist within the data and choose an appropriate strategy based upon the specific details.

i personally do create the model matrix array every frame and as far as i can tell, there is no recognizable performance drop, wheather i render 10 or 1000 objects, fps is steadily 60 (and without vsync, about > 500)
the view matrix of the camera is also rebuild every frame, regardless of wheather it has moved or not

in my app, an “object” is just an instance of a movable orientation with some infos but without a mesh / texture / model, it only has an integer (model index) or pointer to a model
of course there are some restrictions with my approach (the model of an object obviously cant change without affecting all other objects using this model), thats why i divide models up in parts, which optionally can be removed / changed for specific objects (like a missile fired from a helicopter)
i use instanced rendering as described here (tutorial 33): http://www.ogldev.org/