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

Function InitInstance

engine/gameobject/src/gameobject/gameobject.cpp:1815–1845  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1813 }
1814
1815 static bool InitInstance(Collection* collection, HInstance instance)
1816 {
1817 if (instance)
1818 {
1819 if (instance->m_Initialized)
1820 {
1821 dmLogWarning("Instance '%s' is initialized twice, this may lead to undefined behaviour.", dmHashReverseSafe64(instance->m_Identifier));
1822 }
1823 else
1824 {
1825 instance->m_Initialized = 1;
1826 }
1827
1828 assert(collection->m_Instances[instance->m_Index] == instance);
1829
1830 // Update world transforms since some components might need them in their init-callback
1831 Matrix4* trans = &collection->m_WorldTransforms[instance->m_Index];
1832 if (instance->m_Parent == INVALID_INSTANCE_INDEX)
1833 {
1834 *trans = dmTransform::ToMatrix4(instance->m_Transform);
1835 }
1836 else
1837 {
1838 const Matrix4* parent_trans = &collection->m_WorldTransforms[instance->m_Parent];
1839 *trans = (*parent_trans) * dmTransform::ToMatrix4(instance->m_Transform);
1840 }
1841 return InitComponents(collection, instance);
1842 }
1843
1844 return true;
1845 }
1846
1847 static bool DispatchMessages(Collection* collection, dmMessage::HSocket* sockets, uint32_t socket_count);
1848

Callers 3

SpawnFunction · 0.85
InitCollectionFunction · 0.85

Calls 4

dmHashReverseSafe64Function · 0.85
InitComponentsFunction · 0.85
assertFunction · 0.50
ToMatrix4Function · 0.50

Tested by

no test coverage detected