diff --git a/ChangeLog.md b/ChangeLog.md index 2e2c30d59..c85fe2fc5 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -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) diff --git a/include/Nazara/Graphics/InstancedRenderable.hpp b/include/Nazara/Graphics/InstancedRenderable.hpp index 25f6064a8..9bd74bfea 100644 --- a/include/Nazara/Graphics/InstancedRenderable.hpp +++ b/include/Nazara/Graphics/InstancedRenderable.hpp @@ -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: diff --git a/include/Nazara/Graphics/InstancedRenderable.inl b/include/Nazara/Graphics/InstancedRenderable.inl index c2a8f1b70..f54f9cebe 100644 --- a/include/Nazara/Graphics/InstancedRenderable.inl +++ b/include/Nazara/Graphics/InstancedRenderable.inl @@ -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