View Full Version : What I would need to do to implement a new entity type or something?

08-13-2010, 05:30 PM
I am noticing HUUUUUGEEEEE slow-downs on my game when creating entities, I then realized:

The MovingEntities themselves have bazillions of data and methods, there are even some cool AI stuff there (I mean, the stuff that help pathfinders), this is already bad for when I want to create several entities.

Then, all MovingEntities that have collision box, have physics, meaning that all the bizarre amount of Box2D data is added, and meaning also that it fiddles with Box2D binary search tree (even in the lastest version of Box2D, any time you add or remove something from it, it activates a binary search algorithm to add or prune it from its binary tree... kinda stupid if you ask me, or even other Box2D users, but that code work perfectly for Erin Catto games, better than other methods would, and he reject any patches to it without even reading them...)

So I need a way (even if some C++ coding is needed) to create a "simple entity" that has only its picture, script attached, position, rotation, color, bounding box... No physics, no AI states, no brain manager (well... with brain manager I can add brain fade and that one is really cool... but I dunno about the overhead that the brain manager add, or not...), etc...

So, there are a way to do it using stuff that already exist, or if I need to code my own class, what I have to edit (beside obviously creating a edited copy of MovingEntity.h/.cpp)

08-18-2010, 05:10 AM
Well, the pathfinding, brain system, and physics don't actually get initialized unless they are specifically used. (should check this though.. just in case there is a bug, or you're calling something you don't need)

But you're right, despite this, entities are still a bit "heavy".

Depending on what your doing, it might make sense to create a Brain that itself is just a hook into your own custom entity system, providing you don't need to communicate with them in the same way as normal entities.

For example, the example brain that creates the "game of life" can great thousands of its own little 'life' cells, which would be crazy to try to make entities out of each one.