Ok, what I'm asking could not be so mainstream. I'm writing an addon for blender that will add a better particle system, and I am in the process of reating an operator that spawns particles and animates them during time. Untill now I've used this procedure to create a particle object:

  • I created a plane,
  • Merged it at the center
  • removed doubles

So That I would have only a vertex. And then to add datas like particle age, the frame it was born, etc, I used object Custom Properties.

the problem is that Blender struggles to keep upp with thousands of different objects to the point where it doesn't even play the animation at all or just crashes.

But I noticed that it could hold more than 20000 particles at a time without any problem. I want to state that I know python but not so much C++ or C, so excuse me if the following argument is wrong, but I think that blender cannot hold so many object cause they have much more to them than a single particle, for example an objects has Material Slot, Particle Systems, Location, And Much More and It's also treated in a completely different way than a particle which on the other side only has few properties.

given the Argument is true (Escuse me if it isn't) could I create a simple class in a c++ file like this:

class better_particle{
    int age;
    vector Location;

And create instead of a normal object a better_particle object to represent each particle, and also important draw that better_particle Class into the viewport using for example a Rectagle (Like For Example blender's Default Particle)?

I think this is possible modifying the Blender source code to fit my needs, but I want to keep it a Blender addon and not just a custom Build.

So is this possible?

EDIT: I Cannot use Animation Nodes as it hasn't the flexibility of an addon, and The Tree as long as I know it's executed each frame, so particle will not be able to spawn or move in subframes and this would lead to lagging streaks of particles. The same problem that there's in blender by default.


I've Written this simple Python Code:

class particle:

created_particles = []
for f in range(0,40): #For each of 40 Frames
    for i in range(0, 30): # Create 30 Particle
        pp = particle() ##Create New Particle Object
        pp.location = (0,0,0) #Add location variable
        pp.spawn_frame = f

As you can see it just creates some particle object ad assign them some variables. Now I need to Create the particle class in c++ with something like the lines up above and then in Python do something like:

p = bpy.ops.add_particle()  
p.location = (0,0,0)

and the Last Thing I need to do it's to create a drawing function in c++ do display these particle objects.

  • $\begingroup$ Are you by any chance using operators to create plane, merge vertices and remove doubles? $\endgroup$
    – batFINGER
    Commented May 12, 2018 at 17:13
  • $\begingroup$ I'm using a function that does the creating, merging and removing doubles. And that function is inserted into a modal operator run every frame. $\endgroup$
    – Fabrizio
    Commented May 12, 2018 at 17:16
  • 1
    $\begingroup$ I mean, if all is inside a blender object, finally, you need only one blender object. So, your code can associate (create) verts/polys you want inside of it and follow the particles age/location. In other words, your code can maintain a link between each particle and corresponding verts/polys. $\endgroup$
    – lemon
    Commented May 14, 2018 at 12:38
  • 1
    $\begingroup$ you could save the size color etc in vertexgroups and vertexcolors. It would be comparably easy to implement. If you later decide to replace the vertices with cube you can do so with the duplication feature I think as long as you dont want rotating particles (could make trouble in subframes I didn't try) $\endgroup$
    – HenrikD
    Commented May 14, 2018 at 19:49
  • 2
    $\begingroup$ AFAIK you can't use C# at all without custom build unless you hook into external executable somehow. Not trying to be smart but how is this a better particle? What are you trying to achieve that you can't do by python scripting the existing particle system? You definitely don't want to create an object per particle. Make a single mesh and store particles as vertices. You can store surprisingly lot of data per vertex natively and what you can't (like velocity) you could store as custom data array built in vertex order. But it won't perform better than native C# particles, probably worse. $\endgroup$
    – kheetor
    Commented May 15, 2018 at 10:28

1 Answer 1


I suggest writing your code in Python first to keep it simple and get results quickly (especially when you have little experience with where are the bottlenecks).

Then you need to benchmark it and find where the bottlenecks are.

  • if they are on Blender's side, porting your code to c/c++ will have little to no effect. Building your own Blender is the solution.

  • if they are on your code's side consider using Numpy module rather than writing custom C/C++ code first. If you want speedup on arrays or math, it is often enough. Threading can also help.

    For most use cases when you need to wrap C/C++ classes the ctypes module is all you need.

    You can also use Cython to expose parts of C/C++ library to Python.

    For another solution for Python binding to C/C++ code look into Boost.Python:

    The Boost Python Library is a framework for interfacing Python and C++. It allows you to quickly and seamlessly expose C++ classes, functions and objects to Python, and vice-versa, using no special tools

Last thing to consider is that Blender 2.8 version is behind corner and a lot of things will change including the particle system. Some coding time on an addon this big might be wasted when it will release and you will have to re-work it or it becomes redundant by the new native system.

  • $\begingroup$ Hi Jaroslav, are you able to help with wrapping C++ calls in blender? $\endgroup$
    – Denis
    Commented Sep 24, 2018 at 18:29
  • $\begingroup$ @Denis Yes, when you write your question just link it here or ping me in chat, I'll take a look. $\endgroup$ Commented Sep 24, 2018 at 20:52
  • $\begingroup$ I added some info here chat.stackexchange.com/rooms/83603/… $\endgroup$
    – Denis
    Commented Sep 24, 2018 at 21:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .