MCPcopy Create free account
hub / github.com/DanielChappuis/reactphysics3d / createEntity

Method createEntity

src/engine/EntityManager.cpp:39–63  ·  view source on GitHub ↗

Create a new entity

Source from the content-addressed store, hash-verified

37
38// Create a new entity
39Entity EntityManager::createEntity() {
40
41 uint32 index;
42
43 // If there are already enough free indices to start using them
44 if (mFreeIndices.size() > Entity::MINIMUM_FREE_INDICES) {
45
46 // Recycle an index from the free indices
47 index = mFreeIndices.getFront();
48 mFreeIndices.popFront();
49 }
50 else {
51
52 // We start at generation 0
53 mGenerations.add(0);
54
55 // Create a new indice
56 index = static_cast<uint32>(mGenerations.size()) - 1;
57
58 assert(index < (uint32(1) << Entity::ENTITY_INDEX_BITS));
59 }
60
61 // Return a new entity
62 return Entity(index, mGenerations[index]);
63}
64
65// Destroy an entity
66void EntityManager::destroyEntity(Entity entity) {

Callers 4

createRigidBodyMethod · 0.80
createJointMethod · 0.80
addColliderMethod · 0.80
addColliderMethod · 0.80

Calls 4

popFrontMethod · 0.80
EntityClass · 0.50
sizeMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected