MCPcopy Create free account
hub / github.com/defold/defold / NewInstance

Function NewInstance

engine/gameobject/src/gameobject/gameobject.cpp:819–838  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

817 }
818
819 HInstance NewInstance(Collection* collection, Prototype* proto, const char* prototype_name) {
820 if (collection->m_InstanceIndices.Remaining() == 0)
821 {
822 dmLogError("The game object instance could not be created since the buffer is full (%d). Increase the capacity with collection.max_instances", collection->m_InstanceIndices.Capacity());
823 return 0;
824 }
825 HInstance instance = AllocInstance(proto, prototype_name);
826 instance->m_Collection = collection;
827 uint16_t instance_index = collection->m_InstanceIndices.Pop();
828 instance->m_Index = instance_index;
829 dmMutex::Lock(collection->m_Mutex);
830 instance->m_Generation = dmMath::Max(1U, collection->m_GenInstanceCounter++);
831 dmMutex::Unlock(collection->m_Mutex);
832 assert(collection->m_Instances[instance_index] == 0);
833 collection->m_Instances[instance_index] = instance;
834
835 InsertInstanceInLevelIndex(collection, instance);
836
837 return instance;
838 }
839
840 HInstance NewInstance(HCollection hcollection, Prototype* proto, const char* prototype_name){
841 return NewInstance(hcollection->m_Collection, proto, prototype_name);

Callers 4

NewFunction · 0.85
SpawnFunction · 0.85
AcquireResourcesFunction · 0.85

Calls 9

AllocInstanceFunction · 0.85
LockFunction · 0.50
MaxFunction · 0.50
UnlockFunction · 0.50
assertFunction · 0.50
RemainingMethod · 0.45
CapacityMethod · 0.45
PopMethod · 0.45

Tested by

no test coverage detected