Minor improvements

This commit is contained in:
Lynix
2024-01-29 18:34:46 +01:00
parent 0191256493
commit 2b88f50c21
19 changed files with 34 additions and 41 deletions

View File

@@ -36,7 +36,7 @@ namespace Nz
virtual void BuildElement(ElementRendererRegistry& registry, const ElementData& elementData, std::size_t passIndex, std::vector<RenderElementOwner>& elements) const = 0;
inline const Boxf& GetAABB() const;
virtual const std::shared_ptr<MaterialInstance>& GetMaterial(std::size_t i) const = 0;
virtual const std::shared_ptr<MaterialInstance>& GetMaterial(std::size_t materialIndex) const = 0;
virtual std::size_t GetMaterialCount() const = 0;
inline int GetRenderLayer() const;

View File

@@ -35,7 +35,7 @@ namespace Nz
inline void Clear();
inline const Color& GetColor() const;
const std::shared_ptr<MaterialInstance>& GetMaterial(std::size_t i = 0) const override;
const std::shared_ptr<MaterialInstance>& GetMaterial(std::size_t materialIndex = 0) const override;
std::size_t GetMaterialCount() const override;
inline Orientation GetOrientation() const;
inline const Vector2f& GetOrigin() const;

View File

@@ -43,7 +43,7 @@ namespace Nz
inline auto LinearSlicedSprite::GetSection(std::size_t sectionIndex) const -> const Section&
{
NazaraAssert(sectionIndex < m_sectionCount, "out of range section");
NazaraAssertFmt(sectionIndex < m_sectionCount, "section index ouf of range ({0} >= {1})", sectionIndex, m_sectionCount);
return m_sections[sectionIndex];
}
@@ -71,7 +71,7 @@ namespace Nz
inline void LinearSlicedSprite::RemoveSection(std::size_t sectionIndex)
{
NazaraAssert(sectionIndex < m_sectionCount, "out of range section");
NazaraAssertFmt(sectionIndex < m_sectionCount, "section index ouf of range ({0} >= {1})", sectionIndex, m_sectionCount);
if (m_sectionCount >= sectionIndex + 1)
std::move(m_sections.begin() + sectionIndex + 1, m_sections.begin() + m_sectionCount, m_sections.begin() + sectionIndex);
@@ -102,7 +102,7 @@ namespace Nz
inline void LinearSlicedSprite::SetSection(std::size_t sectionIndex, float size, float textureCoord)
{
NazaraAssert(sectionIndex < m_sectionCount, "out of range section");
NazaraAssertFmt(sectionIndex < m_sectionCount, "section index ouf of range ({0} >= {1})", sectionIndex, m_sectionCount);
auto& section = m_sections[sectionIndex];
section.size = size;
@@ -113,7 +113,7 @@ namespace Nz
inline void LinearSlicedSprite::SetSectionSize(std::size_t sectionIndex, float size)
{
NazaraAssert(sectionIndex < m_sectionCount, "out of range section");
NazaraAssertFmt(sectionIndex < m_sectionCount, "section index ouf of range ({0} >= {1})", sectionIndex, m_sectionCount);
auto& section = m_sections[sectionIndex];
section.size = size;
@@ -123,7 +123,7 @@ namespace Nz
inline void LinearSlicedSprite::SetSectionTextureCoord(std::size_t sectionIndex, float textureCoord)
{
NazaraAssert(sectionIndex < m_sectionCount, "out of range section");
NazaraAssertFmt(sectionIndex < m_sectionCount, "section index ouf of range ({0} >= {1})", sectionIndex, m_sectionCount);
auto& section = m_sections[sectionIndex];
section.textureCoord = textureCoord;
@@ -133,7 +133,7 @@ namespace Nz
inline void LinearSlicedSprite::SetSize(float size)
{
NazaraAssert(size >= 0.f, "size must be positive");
NazaraAssertFmt(size >= 0.f, "size must be positive (got {0})", size);
m_size = size;

View File

@@ -2,7 +2,7 @@
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <cassert>
#include <Nazara/Core/Error.hpp>
#include <Nazara/Graphics/Debug.hpp>
namespace Nz
@@ -14,8 +14,8 @@ namespace Nz
inline void Model::SetMaterial(std::size_t subMeshIndex, std::shared_ptr<MaterialInstance> material)
{
assert(subMeshIndex < m_submeshes.size());
assert(material);
NazaraAssertFmt(subMeshIndex < m_submeshes.size(), "submesh index out of range ({0} >= {1})", subMeshIndex, m_submeshes.size());
NazaraAssert(material, "invalid material");
if (m_submeshes[subMeshIndex].material != material)
{

View File

@@ -31,7 +31,7 @@ namespace Nz
inline const Color& GetColor() const;
inline const Corner& GetBottomRightCorner() const;
const std::shared_ptr<MaterialInstance>& GetMaterial(std::size_t i = 0) const override;
const std::shared_ptr<MaterialInstance>& GetMaterial(std::size_t materialIndex = 0) const override;
std::size_t GetMaterialCount() const override;
inline const Vector2f& GetOrigin() const;
inline const Vector2f& GetSize() const;

View File

@@ -2,7 +2,7 @@
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <cassert>
#include <Nazara/Core/Error.hpp>
#include <Nazara/Graphics/Debug.hpp>
namespace Nz
@@ -70,7 +70,7 @@ namespace Nz
inline void SlicedSprite::SetMaterial(std::shared_ptr<MaterialInstance> material)
{
assert(material);
NazaraAssert(material, "invalid material");
if (m_material != material)
{

View File

@@ -120,7 +120,7 @@ namespace Nz
inline void Tilemap::EnableTile(const Vector2ui& tilePos, const Rectf& coords, const Color& color, std::size_t materialIndex)
{
NazaraAssert(tilePos.x < m_mapSize.x&& tilePos.y < m_mapSize.y, "Tile position is out of bounds");
NazaraAssert(materialIndex < m_layers.size(), "Material out of bounds");
NazaraAssertFmt(materialIndex < m_layers.size(), "material index out of bounds ({0} >= {1})", materialIndex, m_layers.size());
std::size_t tileIndex = tilePos.y * m_mapSize.x + tilePos.x;
Tile& tile = m_tiles[tilePos.y * m_mapSize.x + tilePos.x];
@@ -168,7 +168,7 @@ namespace Nz
*/
inline void Tilemap::EnableTile(const Vector2ui& tilePos, const Rectui& rect, const Color& color, std::size_t materialIndex)
{
NazaraAssert(materialIndex < m_layers.size(), "Material out of bounds");
NazaraAssertFmt(materialIndex < m_layers.size(), "material index out of bounds ({0} >= {1})", materialIndex, m_layers.size());
Vector2ui textureSize(GetTextureSize(materialIndex));
float invWidth = 1.f / textureSize.x;
@@ -194,7 +194,7 @@ namespace Nz
*/
inline void Tilemap::EnableTiles(const Rectf& coords, const Color& color, std::size_t materialIndex)
{
NazaraAssert(materialIndex < m_layers.size(), "Material out of bounds");
NazaraAssertFmt(materialIndex < m_layers.size(), "material index out of bounds ({0} >= {1})", materialIndex, m_layers.size());
for (Layer& layer : m_layers)
layer.enabledTiles.Reset();
@@ -231,7 +231,7 @@ namespace Nz
*/
inline void Tilemap::EnableTiles(const Rectui& rect, const Color& color, std::size_t materialIndex)
{
NazaraAssert(materialIndex < m_layers.size(), "Material out of bounds");
NazaraAssertFmt(materialIndex < m_layers.size(), "material index out of bounds ({0} >= {1})", materialIndex, m_layers.size());
Vector2ui textureSize(GetTextureSize(materialIndex));
float invWidth = 1.f / textureSize.x;
@@ -257,7 +257,7 @@ namespace Nz
inline void Tilemap::EnableTiles(const Vector2ui* tilesPos, std::size_t tileCount, const Rectf& coords, const Color& color, std::size_t materialIndex)
{
NazaraAssert(tilesPos || tileCount == 0, "Invalid tile position array with a non-zero tileCount");
NazaraAssert(materialIndex < m_layers.size(), "Material out of bounds");
NazaraAssertFmt(materialIndex < m_layers.size(), "material index out of bounds ({0} >= {1})", materialIndex, m_layers.size());
for (std::size_t i = 0; i < tileCount; ++i)
{
@@ -316,7 +316,7 @@ namespace Nz
*/
inline void Tilemap::EnableTiles(const Vector2ui* tilesPos, std::size_t tileCount, const Rectui& rect, const Color& color, std::size_t materialIndex)
{
NazaraAssert(materialIndex < m_layers.size(), "Material out of bounds");
NazaraAssertFmt(materialIndex < m_layers.size(), "material index out of bounds ({0} >= {1})", materialIndex, m_layers.size());
Vector2ui textureSize(GetTextureSize(materialIndex));
float invWidth = 1.f / textureSize.x;