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

Function DoAddToUpdate

engine/gameobject/src/gameobject/gameobject.cpp:1117–1158  ·  view source on GitHub ↗

Actually add instance to update

Source from the content-addressed store, hash-verified

1115
1116 // Actually add instance to update
1117 static bool DoAddToUpdate(Collection* collection, HInstance instance) {
1118 bool add_to_update_result = true;
1119 if (instance)
1120 {
1121 instance->m_ToBeAdded = 0;
1122 if (instance->m_ToBeDeleted == 0) {
1123 assert(collection->m_Instances[instance->m_Index] == instance);
1124
1125 uint32_t next_component_instance_data = 0;
1126 Prototype* prototype = instance->m_Prototype;
1127 for (uint32_t i = 0; i < prototype->m_ComponentCount; ++i)
1128 {
1129 Prototype::Component* component = &prototype->m_Components[i];
1130 ComponentType* component_type = component->m_Type;
1131
1132 uintptr_t* component_instance_data = 0;
1133 if (component_type->m_InstanceHasUserData)
1134 {
1135 component_instance_data = &instance->m_ComponentInstanceUserData[next_component_instance_data++];
1136 }
1137 assert(next_component_instance_data <= instance->m_ComponentInstanceUserDataCount);
1138
1139 if (component_type->m_AddToUpdateFunction)
1140 {
1141 ComponentAddToUpdateParams params;
1142 params.m_Collection = collection->m_HCollection;
1143 params.m_Instance = instance;
1144 params.m_World = collection->m_ComponentWorlds[component->m_TypeIndex];
1145 params.m_Context = component_type->m_Context;
1146 params.m_UserData = component_instance_data;
1147 CreateResult result = component_type->m_AddToUpdateFunction(params);
1148 if (result != CREATE_RESULT_OK)
1149 {
1150 add_to_update_result = false;
1151 }
1152 }
1153 }
1154 }
1155 }
1156
1157 return add_to_update_result;
1158 }
1159
1160 // Actually add all scheduled instances to the update
1161 static bool DoAddToUpdate(Collection* collection) {

Callers 3

InitCollectionFunction · 0.85
UpdateFunction · 0.85
RecreateInstanceFunction · 0.85

Calls 1

assertFunction · 0.50

Tested by

no test coverage detected