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

Function ResourceReloadedCallback

engine/gameobject/src/gameobject/gameobject.cpp:4258–4305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4256 }
4257
4258 static void ResourceReloadedCallback(const ResourceReloadedParams* params)
4259 {
4260 Collection* collection = (Collection*) params->m_UserData;
4261 for (uint32_t level_i = 0; level_i < MAX_HIERARCHICAL_DEPTH; ++level_i)
4262 {
4263 dmArray<uint16_t>& level = collection->m_LevelIndices[level_i];
4264 uint32_t instance_count = level.Size();
4265 for (uint32_t i = 0; i < instance_count; ++i)
4266 {
4267 uint16_t index = level[i];
4268 Instance* instance = collection->m_Instances[index];
4269 Prototype* prototype = (Prototype*)ResourceDescriptorGetResource(params->m_Resource);
4270 if (instance->m_Prototype == prototype) {
4271 Prototype* prev_prototype = (Prototype*)ResourceDescriptorGetPrevResource(params->m_Resource);
4272 RecreateInstance(collection, index, prev_prototype, prototype, params->m_Filename);
4273 } else {
4274 uint32_t next_component_instance_data = 0;
4275 for (uint32_t j = 0; j < instance->m_Prototype->m_ComponentCount; ++j)
4276 {
4277 Prototype::Component& component = instance->m_Prototype->m_Components[j];
4278 ComponentType* type = component.m_Type;
4279 if (component.m_ResourceId == ResourceDescriptorGetNameHash(params->m_Resource))
4280 {
4281 if (type->m_OnReloadFunction)
4282 {
4283 uintptr_t* user_data = 0;
4284 if (type->m_InstanceHasUserData)
4285 {
4286 user_data = &instance->m_ComponentInstanceUserData[next_component_instance_data];
4287 }
4288 ComponentOnReloadParams on_reload_params;
4289 on_reload_params.m_Instance = instance;
4290 on_reload_params.m_Resource = prototype;
4291 on_reload_params.m_World = collection->m_ComponentWorlds[component.m_TypeIndex];
4292 on_reload_params.m_Context = type->m_Context;
4293 on_reload_params.m_UserData = user_data;
4294 type->m_OnReloadFunction(on_reload_params);
4295 }
4296 }
4297 if (type->m_InstanceHasUserData)
4298 {
4299 next_component_instance_data++;
4300 }
4301 }
4302 }
4303 }
4304 }
4305 }
4306
4307 // Unit test functions
4308 uint32_t GetAddToUpdateCount(HCollection hcollection)

Callers

nothing calls this directly

Calls 5

RecreateInstanceFunction · 0.85
SizeMethod · 0.45

Tested by

no test coverage detected