Github C++ MotionStreak batch node

Github C++ MotionStreak batch node
0

After I solved the issues of wanting to batch MotionStreak nodes with the same texture into 1 draw call, I went ahead and abstracted the code for a public GitHub repo.

It is pretty straightforward to use, almost an exact analogy of Sprite -> SpriteBatchNode.

One thing to keep in mind, is to make the Batch work, you need to replace your instances of MotionStreak with this BatchableMotionStreak… it just allows read access to a few private attributes that were necessary for the batch to work. I wanted to subclass MotionStreak here for version compatibility etc instead of changing the cocos lib file.

There are tons of areas for improvement I have in mind (ie use true frame and index buffers, not using memcpy on the data and populating from MotionStreak class itself), but, it works as intended for me, so I am leaving it as is for now. I thought it might also serve as a good example for others on how to batch other misc / custom nodes with their own CustomCommand or other render commands etc to OpenGL with one draw call.

5 Likes