Przeglądaj źródła

resource: access the correct index

Fixes: #305
Daniele Bartolini 11 miesięcy temu
rodzic
commit
cf6a1875a9
2 zmienionych plików z 2 dodań i 1 usunięć
  1. 1 0
      docs/changelog.rst
  2. 1 1
      src/world/material_manager.cpp

+ 1 - 0
docs/changelog.rst

@@ -22,6 +22,7 @@ Changelog
 * Fixed a crash when moving many objects simultaneusly.
 * Fixed a crash when reloading unloaded or unsupported resources.
 * Fixed setting kinematic actor's position and rotation.
+* Fixed an issue that caused all samplers in a material to be set to the same texture.
 * Data Compiler: 'includes' key in shaders can now be specified as an array to include code from multiple locations.
 * Data Compiler: shader #defines are now correctly exposed in vs_input_output and fs_input_output.
 * Data Compiler: fixed shader compiler ignoring errors when parsing included files.

+ 1 - 1
src/world/material_manager.cpp

@@ -56,7 +56,7 @@ void MaterialManager::online(StringId64 id, ResourceManager &rm)
 	const TextureData *td = texture_data_array(mr);
 	for (u32 i = 0; i < mr->num_textures; ++i) {
 		TextureHandle *th   = texture_handle(td, i, material->_data);
-		TextureResource *tr = (TextureResource *)rm.get(RESOURCE_TYPE_TEXTURE, td->id);
+		TextureResource *tr = (TextureResource *)rm.get(RESOURCE_TYPE_TEXTURE, td[i].id);
 		th->sampler_handle = bgfx::createUniform(texture_name(mr, td, i), bgfx::UniformType::Sampler).idx;
 		th->texture_handle = tr->handle.idx;
 #if CROWN_CAN_RELOAD