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

Function FillTextures

engine/gamesys/src/gamesys/components/comp_model.cpp:520–544  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

518 }
519
520 static int32_t FillTextures(dmRender::RenderObject* ro, const ModelComponent* component, uint32_t material_index)
521 {
522 MaterialResource* material = GetMaterialResource(component, component->m_Resource, material_index);
523
524 int32_t first_free_index = -1;
525 bool first_free_index_set = false;
526
527 for(uint32_t i = 0; i < dmRender::RenderObject::MAX_TEXTURE_COUNT; ++i)
528 {
529 TextureResource* texture_res = component->m_Textures[i];
530 if (!texture_res)
531 {
532 texture_res = GetTextureFromSamplerNameHash(&component->m_Resource->m_Materials[material_index], material, i, material->m_SamplerNames[i]);
533 }
534
535 ro->m_Textures[i] = texture_res ? texture_res->m_Texture : 0;
536
537 if (ro->m_Textures[i] == 0 && !first_free_index_set)
538 {
539 first_free_index_set = true;
540 first_free_index = i;
541 }
542 }
543 return first_free_index;
544 }
545
546 static void HashMaterial(HashState32* state, const dmGameSystem::MaterialResource* material)
547 {

Callers 3

RenderBatchWorldVSFunction · 0.85

Calls 2

GetMaterialResourceFunction · 0.70

Tested by

no test coverage detected