Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 709 vs 710 for /trunk/Source Code/Geometry/Material/Material.cpp

Diff revisions: vs.
  @@ -94,13 +94,12 @@
94 94 return true;
95 95 }
96 96
97 - std::shared_ptr<Material> Material::clone(const stringImpl& nameSuffix) {
97 + Material_ptr Material::clone(const stringImpl& nameSuffix) {
98 98 DIVIDE_ASSERT(!nameSuffix.empty(),
99 99 "Material error: clone called without a valid name suffix!");
100 100
101 101 const Material& base = *this;
102 - std::shared_ptr<Material> cloneMat =
103 - CreateResource<Material>(ResourceDescriptor(getName() + nameSuffix));
102 + Material_ptr cloneMat = CreateResource<Material>(ResourceDescriptor(getName() + nameSuffix));
104 103
105 104 cloneMat->_shadingMode = base._shadingMode;
106 105 cloneMat->_translucencyCheck = base._translucencyCheck;
  @@ -132,13 +131,13 @@
132 131 for (U8 i = 0; i < to_ubyte(base._textures.size()); ++i) {
133 132 ShaderProgram::TextureUsage usage = static_cast<ShaderProgram::TextureUsage>(i);
134 133 if (!isExternalTexture(usage)) {
135 - std::shared_ptr<Texture> tex = base._textures[i];
134 + Texture_ptr tex = base._textures[i];
136 135 if (tex) {
137 136 cloneMat->setTexture(usage, tex);
138 137 }
139 138 }
140 139 }
141 - for (const std::pair<std::shared_ptr<Texture>, U8>& tex : base._customTextures) {
140 + for (const std::pair<Texture_ptr, U8>& tex : base._customTextures) {
142 141 if (tex.first) {
143 142 cloneMat->addCustomTexture(tex.first, tex.second);
144 143 }
  @@ -187,7 +186,7 @@
187 186 // second = second texture used for multitexturing
188 187 // bump = bump map
189 188 bool Material::setTexture(ShaderProgram::TextureUsage textureUsageSlot,
190 - const std::shared_ptr<Texture>& texture,
189 + const Texture_ptr& texture,
191 190 const TextureOperation& op) {
192 191 bool computeShaders = false;
193 192 U32 slot = to_uint(textureUsageSlot);
  @@ -197,7 +196,7 @@
197 196 }
198 197
199 198 if (texture && textureUsageSlot == ShaderProgram::TextureUsage::OPACITY) {
200 - std::shared_ptr<Texture>& diffuseMap = _textures[to_const_uint(ShaderProgram::TextureUsage::UNIT0)];
199 + Texture_ptr& diffuseMap = _textures[to_const_uint(ShaderProgram::TextureUsage::UNIT0)];
201 200 if (diffuseMap && texture->getGUID() == diffuseMap->getGUID()) {
202 201 return false;
203 202 }
  @@ -318,7 +317,7 @@
318 317 assert(reflectionTarget._buffer != nullptr);
319 318 setTexture(ShaderProgram::TextureUsage::REFLECTION, reflectionTarget._buffer->getAttachment());
320 319 } else {
321 - setTexture(ShaderProgram::TextureUsage::REFLECTION, std::shared_ptr<Texture>());
320 + setTexture(ShaderProgram::TextureUsage::REFLECTION, Texture_ptr());
322 321 }
323 322 }
324 323
  @@ -329,7 +328,7 @@
329 328 assert(refractionTarget._buffer != nullptr);
330 329 setTexture(ShaderProgram::TextureUsage::REFRACTION, refractionTarget._buffer->getAttachment());
331 330 } else {
332 - setTexture(ShaderProgram::TextureUsage::REFRACTION, std::shared_ptr<Texture>());
331 + setTexture(ShaderProgram::TextureUsage::REFRACTION, Texture_ptr());
333 332 }
334 333 }
335 334
  @@ -520,16 +519,16 @@
520 519
521 520 /// Add a texture <-> bind slot pair to be bound with the default textures
522 521 /// on each "bindTexture" call
523 - void Material::addCustomTexture(const std::shared_ptr<Texture>& texture, U8 offset) {
522 + void Material::addCustomTexture(const Texture_ptr& texture, U8 offset) {
524 523 // custom textures are not material dependencies!
525 524 _customTextures.push_back(std::make_pair(texture, offset));
526 525 }
527 526
528 527 /// Remove the custom texture assigned to the specified offset
529 528 bool Material::removeCustomTexture(U8 index) {
530 - vectorImpl<std::pair<std::shared_ptr<Texture>, U8>>::iterator it =
529 + vectorImpl<std::pair<Texture_ptr, U8>>::iterator it =
531 530 std::find_if(std::begin(_customTextures), std::end(_customTextures),
532 - [&index](const std::pair<std::shared_ptr<Texture>, U8>& tex)
531 + [&index](const std::pair<Texture_ptr, U8>& tex)
533 532 -> bool { return tex.second == index; });
534 533 if (it == std::end(_customTextures)) {
535 534 return false;
  @@ -543,7 +542,7 @@
543 542 void Material::getTextureData(ShaderProgram::TextureUsage slot,
544 543 TextureDataContainer& container) {
545 544 U32 slotValue = to_uint(slot);
546 - std::shared_ptr<Texture>& crtTexture = _textures[slotValue];
545 + Texture_ptr& crtTexture = _textures[slotValue];
547 546 if (crtTexture && crtTexture->flushTextureState()) {
548 547 TextureData& data = crtTexture->getData();
549 548 data.setHandleLow(slotValue);
  @@ -564,7 +563,7 @@
564 563 getTextureData(ShaderProgram::TextureUsage::REFLECTION, textureData);
565 564 getTextureData(ShaderProgram::TextureUsage::REFRACTION, textureData);
566 565
567 - for (std::pair<std::shared_ptr<Texture>, U8>& tex : _customTextures) {
566 + for (std::pair<Texture_ptr, U8>& tex : _customTextures) {
568 567 if (tex.first->flushTextureState()) {
569 568 textureData.push_back(tex.first->getData());
570 569 textureData.back().setHandleLow(to_uint(tex.second));
  @@ -584,7 +583,7 @@
584 583 }
585 584 }
586 585
587 - const std::shared_ptr<ShaderProgram>& Material::ShaderInfo::getProgram() const {
586 + const ShaderProgram_ptr& Material::ShaderInfo::getProgram() const {
588 587 return _shaderRef == nullptr
589 588 ? ShaderProgram::defaultShader()
590 589 : _shaderRef;