Graphics/InstancedRenderable: Make SetMaterial methods public

This commit is contained in:
Lynix 2018-06-06 19:32:28 +02:00
parent f5645833df
commit 2f0c62df20
3 changed files with 48 additions and 48 deletions

View File

@ -108,6 +108,7 @@ Nazara Engine:
- Added AbstractViewer::ProjectDepth method
- Fixed SocketPoller not be able to recover from some errors (like invalid sockets and such)
- ⚠️ Replaced currentBitPos and currentByte fields by [read|write][BitPos][Byte] to handle properly bit reading/writing.
- InstancedRenderable::SetMaterial methods are now public.
Nazara Development Kit:
- Added ImageWidget (#139)

View File

@ -53,6 +53,8 @@ namespace Nz
virtual void InvalidateData(InstanceData* instanceData, UInt32 flags) const;
inline void SetMaterial(std::size_t matIndex, MaterialRef material);
inline void SetMaterial(std::size_t skinIndex, std::size_t matIndex, MaterialRef material);
inline void SetSkin(std::size_t skinIndex);
inline void SetSkinCount(std::size_t skinCount);
@ -108,9 +110,6 @@ namespace Nz
inline void ResetMaterials(std::size_t matCount, std::size_t skinCount = 1);
inline void SetMaterial(std::size_t matIndex, MaterialRef material);
inline void SetMaterial(std::size_t skinIndex, std::size_t matIndex, MaterialRef material);
mutable BoundingVolumef m_boundingVolume;
private:

View File

@ -110,6 +110,51 @@ namespace Nz
return m_skinCount;
}
/*!
* \brief Changes the material used at the specified index by another one
*
* This function changes the active material at the specified index, depending on the current active skin, to the one passed as parameter.
*
* \param matIndex Material index
* \param material New material, cannot be null
*
* \remark If you wish to reset the material to the default one, use the default material (see Material::GetDefault)
*
* \see SetMaterial
*/
inline void InstancedRenderable::SetMaterial(std::size_t matIndex, MaterialRef material)
{
SetMaterial(m_skin, matIndex, std::move(material));
}
/*!
* \brief Changes the material used at the specified index by another one, independently from the active skin.
*
* This function changes the active material at the specified index and for the specified skin index, to the one passed as parameter.
*
* \param skinIndex Skin index
* \param matIndex Material index
* \param material New material, cannot be null
*
* \remark If you wish to reset the material to the default one, use the default material (see Material::GetDefault)
*
* \see SetMaterial
*/
inline void InstancedRenderable::SetMaterial(std::size_t skinIndex, std::size_t matIndex, MaterialRef material)
{
NazaraAssert(skinIndex < m_skinCount, "Skin index out of bounds");
NazaraAssert(matIndex < m_materials.size(), "Material index out of bounds");
NazaraAssert(material.IsValid(), "Material must be valid");
MaterialRef& matEntry = m_materials[m_matCount * skinIndex + matIndex];
if (matEntry != material)
{
OnInstancedRenderableInvalidateMaterial(this, skinIndex, matIndex, material);
matEntry = std::move(material);
}
}
/*!
* \brief Changes the active skin
*
@ -201,51 +246,6 @@ namespace Nz
m_skin = 0;
}
/*!
* \brief Changes the material used at the specified index by another one
*
* This function changes the active material at the specified index, depending on the current active skin, to the one passed as parameter.
*
* \param matIndex Material index
* \param material New material, cannot be null
*
* \remark If you wish to reset the material to the default one, use the default material (see Material::GetDefault)
*
* \see SetMaterial
*/
inline void InstancedRenderable::SetMaterial(std::size_t matIndex, MaterialRef material)
{
SetMaterial(m_skin, matIndex, std::move(material));
}
/*!
* \brief Changes the material used at the specified index by another one, independently from the active skin.
*
* This function changes the active material at the specified index and for the specified skin index, to the one passed as parameter.
*
* \param skinIndex Skin index
* \param matIndex Material index
* \param material New material, cannot be null
*
* \remark If you wish to reset the material to the default one, use the default material (see Material::GetDefault)
*
* \see SetMaterial
*/
inline void InstancedRenderable::SetMaterial(std::size_t skinIndex, std::size_t matIndex, MaterialRef material)
{
NazaraAssert(skinIndex < m_skinCount, "Skin index out of bounds");
NazaraAssert(matIndex < m_materials.size(), "Material index out of bounds");
NazaraAssert(material.IsValid(), "Material must be valid");
MaterialRef& matEntry = m_materials[m_matCount * skinIndex + matIndex];
if (matEntry != material)
{
OnInstancedRenderableInvalidateMaterial(this, skinIndex, matIndex, material);
matEntry = std::move(material);
}
}
/*!
* \brief Sets the current instanced renderable with the content of the other one
* \return A reference to this