| 2545 | } |
| 2546 | |
| 2547 | dmGameObject::UpdateResult CompModelUpdate(const dmGameObject::ComponentsUpdateParams& params, dmGameObject::ComponentsUpdateResult& update_result) |
| 2548 | { |
| 2549 | ModelWorld* world = (ModelWorld*)params.m_World; |
| 2550 | ModelContext* context = (ModelContext*)params.m_Context; |
| 2551 | dmGraphics::HContext graphics_context = dmRender::GetGraphicsContext(context->m_RenderContext); |
| 2552 | dmRig::ResetPoseMatrixCache(world->m_RigContext); |
| 2553 | |
| 2554 | const dmArray<ModelComponent*>& components = world->m_Components.GetRawObjects(); |
| 2555 | const uint32_t count = components.Size(); |
| 2556 | |
| 2557 | for (uint32_t i = 0; i < count; ++i) |
| 2558 | { |
| 2559 | ModelComponent& component = *components[i]; |
| 2560 | component.m_DoRender = 0; |
| 2561 | |
| 2562 | if (!component.m_Enabled || !component.m_AddedToUpdate) |
| 2563 | continue; |
| 2564 | |
| 2565 | if (component.m_ReHash || (component.m_RenderConstants && dmGameSystem::AreRenderConstantsUpdated(component.m_RenderConstants))) |
| 2566 | { |
| 2567 | ReHash(world, &component); |
| 2568 | } |
| 2569 | |
| 2570 | if (component.m_RequiresBindPoseCaching) |
| 2571 | { |
| 2572 | if (dmRig::AcquirePoseMatrixCacheEntry(world->m_RigContext, component.m_RigInstance) == dmRig::INVALID_POSE_MATRIX_CACHE_ENTRY) |
| 2573 | { |
| 2574 | dmLogWarning("Model requires bind pose cache, but was not able to acquire a cache index. Consider increasing the cache size (model.max_bone_matrix_texture_width and model.max_bone_matrix_texture_height)."); |
| 2575 | } |
| 2576 | } |
| 2577 | |
| 2578 | // Purge old mesh attribute data |
| 2579 | const uint8_t current_tick = world->m_CurrentFrameTick; |
| 2580 | const uint32_t num_render_datas = component.m_MeshAttributeRenderDatas.Size(); |
| 2581 | for (uint32_t j = 0; j < num_render_datas; ++j) |
| 2582 | { |
| 2583 | MeshAttributeRenderData& rd = component.m_MeshAttributeRenderDatas[j]; |
| 2584 | if (!rd.m_Initialized) |
| 2585 | { |
| 2586 | continue; |
| 2587 | } |
| 2588 | if ((current_tick - rd.m_LastUsedFrame) > ATTRIBUTE_RENDER_DATA_MAX_FRAME_TICKS) |
| 2589 | { |
| 2590 | ReleaseMeshAttributeRenderData(&rd); |
| 2591 | } |
| 2592 | } |
| 2593 | |
| 2594 | component.m_DoRender = 1; |
| 2595 | |
| 2596 | DM_PROPERTY_ADD_U32(rmtp_Model, 1); |
| 2597 | } |
| 2598 | |
| 2599 | dmRig::Result rig_res = dmRig::Update(world->m_RigContext, params.m_UpdateContext->m_DT); |
| 2600 | |
| 2601 | WritePoseMatricesToTexture(graphics_context, world); |
| 2602 | |
| 2603 | assert(world->m_MaxBatchIndex < VERTEX_BUFFER_MAX_BATCHES); |
| 2604 | for (int i = 0; i <= world->m_MaxBatchIndex; ++i) |
nothing calls this directly
no test coverage detected