Merge remote-tracking branch 'origin/master' into Resource-Update

Conflicts:
	include/Nazara/Audio/Music.hpp
	include/Nazara/Audio/SoundBuffer.hpp
	include/Nazara/Core/Resource.hpp
	include/Nazara/Core/ResourceListener.hpp
	include/Nazara/Graphics/Material.hpp
	include/Nazara/Renderer/Context.hpp
	include/Nazara/Renderer/RenderBuffer.hpp
	include/Nazara/Renderer/Shader.hpp
	include/Nazara/Renderer/Texture.hpp
	include/Nazara/Renderer/UberShader.hpp
	include/Nazara/Utility/Animation.hpp
	include/Nazara/Utility/Buffer.hpp
	include/Nazara/Utility/Image.hpp
	include/Nazara/Utility/IndexBuffer.hpp
	include/Nazara/Utility/Mesh.hpp
	include/Nazara/Utility/SkeletalMesh.hpp
	include/Nazara/Utility/Skeleton.hpp
	include/Nazara/Utility/StaticMesh.hpp
	include/Nazara/Utility/SubMesh.hpp
	include/Nazara/Utility/VertexBuffer.hpp
	include/Nazara/Utility/VertexDeclaration.hpp
	src/Nazara/Core/Resource.cpp
	src/Nazara/Core/ResourceListener.cpp
	src/Nazara/Graphics/DeferredRenderQueue.cpp
	src/Nazara/Graphics/ForwardRenderQueue.cpp
	src/Nazara/Graphics/SkinningManager.cpp
	src/Nazara/Renderer/RenderTexture.cpp
	src/Nazara/Renderer/Renderer.cpp
	src/Nazara/Utility/Mesh.cpp

Former-commit-id: 99b5ad26a19fe9c9f8118da7b5920bffe89f60f8
This commit is contained in:
Lynix
2015-01-25 19:29:55 +01:00
579 changed files with 11958 additions and 3706 deletions

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
@@ -19,6 +19,7 @@ class NzCallOnExit : NzNonCopyable
NzCallOnExit(Func func = nullptr);
~NzCallOnExit();
void CallAndReset(Func func = nullptr);
void Reset(Func func = nullptr);
private:

View File

@@ -1,7 +1,8 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Core/Error.hpp>
#include <Nazara/Core/Debug.hpp>
inline NzCallOnExit::NzCallOnExit(Func func) :
@@ -15,6 +16,14 @@ inline NzCallOnExit::~NzCallOnExit()
m_func();
}
inline void NzCallOnExit::CallAndReset(Func func)
{
if (m_func)
m_func();
Reset(func);
}
inline void NzCallOnExit::Reset(Func func)
{
m_func = func;

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
@@ -19,6 +19,7 @@ class NAZARA_API NzClock
{
public:
NzClock(nzUInt64 startingValue = 0, bool paused = false);
NzClock(const NzClock& clock) = default;
float GetSeconds() const;
nzUInt64 GetMicroseconds() const;
@@ -30,6 +31,8 @@ class NAZARA_API NzClock
void Restart();
void Unpause();
NzClock& operator=(const NzClock& clock) = default;
private:
NazaraMutexAttrib(m_mutex, mutable)

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,8 +1,9 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Core/StringStream.hpp>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stdexcept>
@@ -235,7 +236,7 @@ inline void NzColor::ToCMYK(const NzColor& color, float* cyan, float* magenta, f
float c, m, y;
ToCMY(color, &c, &m, &y);
float k = std::min(std::min(std::min(1.f, c), m), y);
float k = std::min({1.f, c, m, y});
if (NzNumberEquals(k, 1.f))
{
@@ -260,8 +261,8 @@ inline void NzColor::ToHSL(const NzColor& color, nzUInt8* hue, nzUInt8* saturati
float g = color.g / 255.f;
float b = color.b / 255.f;
float min = std::min(std::min(r, g), b); // Min. value of RGB
float max = std::max(std::max(r, g), b); // Max. value of RGB
float min = std::min({r, g, b}); // Min. value of RGB
float max = std::max({r, g, b}); // Max. value of RGB
float deltaMax = max - min; //Delta RGB value

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,7 +1,7 @@
/*
Nazara Engine - Core module
Copyright (C) 2014 Jérôme "Lynix" Leclercq (Lynix680@gmail.com)
Copyright (C) 2015 Jérôme "Lynix" Leclercq (Lynix680@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
@@ -8,6 +8,7 @@
#define NAZARA_DIRECTORY_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/NonCopyable.hpp>
#include <Nazara/Core/String.hpp>
#if defined(NAZARA_PLATFORM_WINDOWS)
@@ -27,7 +28,7 @@
class NzDirectoryImpl;
class NAZARA_API NzDirectory
class NAZARA_API NzDirectory : NzNonCopyable
{
public:
NzDirectory();

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -0,0 +1,85 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
// Implémentation originale de Jukka Jylänki (Merci de sa contribution au domaine public)
// http://clb.demon.fi/projects/even-more-rectangle-bin-packing
#pragma once
#ifndef NAZARA_GUILLOTINEBINPACK_HPP
#define NAZARA_GUILLOTINEBINPACK_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/SparsePtr.hpp>
#include <Nazara/Math/Rect.hpp>
#include <vector>
class NAZARA_API NzGuillotineBinPack
{
public:
enum FreeRectChoiceHeuristic
{
RectBestAreaFit,
RectBestLongSideFit,
RectBestShortSideFit,
RectWorstAreaFit,
RectWorstLongSideFit,
RectWorstShortSideFit
};
enum GuillotineSplitHeuristic
{
SplitLongerAxis,
SplitLongerLeftoverAxis,
SplitMaximizeArea,
SplitMinimizeArea,
SplitShorterAxis,
SplitShorterLeftoverAxis
};
NzGuillotineBinPack();
NzGuillotineBinPack(unsigned int width, unsigned int height);
NzGuillotineBinPack(const NzVector2ui& size);
NzGuillotineBinPack(const NzGuillotineBinPack&) = default;
NzGuillotineBinPack(NzGuillotineBinPack&&) = default;
~NzGuillotineBinPack() = default;
void Clear();
void Expand(unsigned int newWidth, unsigned newHeight);
void Expand(const NzVector2ui& newSize);
void FreeRectangle(const NzRectui& rect);
unsigned int GetHeight() const;
float GetOccupancy() const;
NzVector2ui GetSize() const;
unsigned int GetWidth() const;
bool Insert(NzRectui* rects, unsigned int count, bool merge, FreeRectChoiceHeuristic rectChoice, GuillotineSplitHeuristic splitMethod);
bool Insert(NzRectui* rects, bool* flipped, unsigned int count, bool merge, FreeRectChoiceHeuristic rectChoice, GuillotineSplitHeuristic splitMethod);
bool Insert(NzRectui* rects, bool* flipped, bool* inserted, unsigned int count, bool merge, FreeRectChoiceHeuristic rectChoice, GuillotineSplitHeuristic splitMethod);
bool MergeFreeRectangles();
void Reset();
void Reset(unsigned int width, unsigned int height);
void Reset(const NzVector2ui& size);
NzGuillotineBinPack& operator=(const NzGuillotineBinPack&) = default;
NzGuillotineBinPack& operator=(NzGuillotineBinPack&&) = default;
private:
void SplitFreeRectAlongAxis(const NzRectui& freeRect, const NzRectui& placedRect, bool splitHorizontal);
void SplitFreeRectByHeuristic(const NzRectui& freeRect, const NzRectui& placedRect, GuillotineSplitHeuristic method);
static int ScoreByHeuristic(int width, int height, const NzRectui& freeRect, FreeRectChoiceHeuristic rectChoice);
std::vector<NzRectui> m_freeRectangles;
unsigned int m_height;
unsigned int m_usedArea;
unsigned int m_width;
};
#endif // NAZARA_GUILLOTINEBINPACK_HPP

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
@@ -11,7 +11,7 @@
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/String.hpp>
#include <ostream>
#include <iosfwd>
class NAZARA_API NzHashDigest
{

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -0,0 +1,20 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_MEMORYHELPER_HPP
#define NAZARA_MEMORYHELPER_HPP
#include <cstddef>
void NzOperatorDelete(void* ptr);
void* NzOperatorNew(std::size_t size);
template<typename T, typename... Args>
T* NzPlacementNew(void* ptr, Args... args);
#include <Nazara/Core/MemoryHelper.inl>
#endif // NAZARA_MEMORYHELPER_HPP

View File

@@ -0,0 +1,45 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
// Je ne suis pas fier des cinq lignes qui suivent mais difficile de faire autrement pour le moment...
#ifdef NAZARA_DEBUG_NEWREDEFINITION_DISABLE_REDEFINITION
#define NAZARA_DEBUG_NEWREDEFINITION_DISABLE_REDEFINITION_DEFINED
#else
#define NAZARA_DEBUG_NEWREDEFINITION_DISABLE_REDEFINITION
#endif
#include <Nazara/Core/MemoryManager.hpp>
#include <new>
#include <Nazara/Core/Debug.hpp>
inline void NzOperatorDelete(void* ptr)
{
#if NAZARA_CORE_MANAGE_MEMORY
NzMemoryManager::Free(ptr);
#else
operator delete(ptr);
#endif
}
inline void* NzOperatorNew(std::size_t size)
{
#if NAZARA_CORE_MANAGE_MEMORY
return NzMemoryManager::Allocate(size);
#else
return operator new(size);
#endif
}
template<typename T, typename... Args>
T* NzPlacementNew(void* ptr, Args... args)
{
return new (ptr) T(std::forward<Args>(args)...);
}
#include <Nazara/Core/DebugOff.hpp>
// Si c'est nous qui avons défini la constante, alors il nous faut l'enlever (Pour éviter que le moteur entier n'en souffre)
#ifndef NAZARA_DEBUG_NEWREDEFINITION_DISABLE_REDEFINITION_DEFINED
#undef NAZARA_DEBUG_NEWREDEFINITION_DISABLE_REDEFINITION
#endif

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,15 +1,8 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
// Je ne suis pas fier des cinq lignes qui suivent mais difficile de faire autrement pour le moment...
#ifdef NAZARA_DEBUG_NEWREDEFINITION_DISABLE_REDEFINITION
#define NAZARA_DEBUG_NEWREDEFINITION_DISABLE_REDEFINITION_DEFINED
#else
#define NAZARA_DEBUG_NEWREDEFINITION_DISABLE_REDEFINITION
#endif
#include <new>
#include <Nazara/Core/MemoryHelper.hpp>
#include <Nazara/Core/Debug.hpp>
template<unsigned int blockSize, bool canGrow>
@@ -58,7 +51,7 @@ void* NzMemoryPool<blockSize, canGrow>::Allocate(unsigned int size)
}
}
return operator new(size);
return NzOperatorNew(size);
}
template<unsigned int blockSize, bool canGrow>
@@ -93,7 +86,7 @@ void NzMemoryPool<blockSize, canGrow>::Free(void* ptr)
if (m_next)
m_next->Free(ptr);
else
operator delete(ptr);
NzOperatorDelete(ptr);
}
}
}
@@ -111,8 +104,3 @@ unsigned int NzMemoryPool<blockSize, canGrow>::GetSize() const
}
#include <Nazara/Core/DebugOff.hpp>
// Si c'est nous qui avons défini la constante, alors il nous faut l'enlever (Pour éviter que le moteur entier n'en souffre)
#ifndef NAZARA_DEBUG_NEWREDEFINITION_DISABLE_REDEFINITION_DEFINED
#undef NAZARA_DEBUG_NEWREDEFINITION_DISABLE_REDEFINITION
#endif

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -0,0 +1,45 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_OBJECTLISTENERWRAPPER_HPP
#define NAZARA_OBJECTLISTENERWRAPPER_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ObjectListener.hpp>
#include <Nazara/Core/RefCounted.hpp>
#include <type_traits>
template<typename T>
class NzObjectListenerWrapper
{
static_assert(std::is_base_of<NzRefCounted, T>::value, "ObjListenerWrapper should only be used with RefCounted-derived type");
public:
NzObjectListenerWrapper(NzObjectListener* listener, int index = 0, T* object = nullptr);
NzObjectListenerWrapper(const NzObjectListenerWrapper& listener);
NzObjectListenerWrapper(NzObjectListenerWrapper&& listener);
~NzObjectListenerWrapper();
bool IsValid() const;
void Reset(T* object = nullptr);
operator bool() const;
operator T*() const;
T* operator->() const;
NzObjectListenerWrapper& operator=(T* object);
NzObjectListenerWrapper& operator=(const NzObjectListenerWrapper& listener);
NzObjectListenerWrapper& operator=(NzObjectListenerWrapper&& listener);
private:
T* m_object;
NzObjectListener* m_listener;
int m_index;
};
#include <Nazara/Core/ObjectListenerWrapper.inl>
#endif // NAZARA_OBJECTLISTENERWRAPPER_HPP

View File

@@ -0,0 +1,108 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Core/Debug.hpp>
template<typename T>
NzObjectListenerWrapper<T>::NzObjectListenerWrapper(NzObjectListener* listener, int index, T* object) :
m_object(nullptr),
m_listener(listener),
m_index(index)
{
Reset(object);
}
template<typename T>
NzObjectListenerWrapper<T>::NzObjectListenerWrapper(const NzObjectListenerWrapper& listener) :
m_object(nullptr),
m_listener(listener.m_listener),
m_index(listener.m_index)
{
Reset(listener.m_object);
}
template<typename T>
NzObjectListenerWrapper<T>::NzObjectListenerWrapper(NzObjectListenerWrapper&& listener) :
m_object(listener.m_object),
m_listener(listener.m_listener),
m_index(listener.m_index)
{
listener.m_object = nullptr;
}
template<typename T>
NzObjectListenerWrapper<T>::~NzObjectListenerWrapper()
{
Reset(nullptr);
}
template<typename T>
bool NzObjectListenerWrapper<T>::IsValid() const
{
return m_object != nullptr;
}
template<typename T>
void NzObjectListenerWrapper<T>::Reset(T* object)
{
if (object)
object->AddObjectListener(m_listener, m_index);
if (m_object)
m_object->RemoveObjectListener(m_listener);
m_object = object;
}
template<typename T>
NzObjectListenerWrapper<T>::operator bool() const
{
return IsValid();
}
template<typename T>
NzObjectListenerWrapper<T>::operator T*() const
{
return m_object;
}
template<typename T>
T* NzObjectListenerWrapper<T>::operator->() const
{
return m_object;
}
template<typename T>
NzObjectListenerWrapper<T>& NzObjectListenerWrapper<T>::operator=(T* object)
{
Reset(object);
return *this;
}
template<typename T>
NzObjectListenerWrapper<T>& NzObjectListenerWrapper<T>::operator=(const NzObjectListenerWrapper& listener)
{
m_index = listener.m_index;
m_listener = listener.m_listener;
Reset(listener.m_object);
return *this;
}
template<typename T>
NzObjectListenerWrapper<T>& NzObjectListenerWrapper<T>::operator=(NzObjectListenerWrapper&& listener)
{
Reset();
m_index = listener.m_index;
m_listener = listener.m_listener;
m_object = listener.m_object;
listener.m_object = nullptr;
return *this;
}
#include <Nazara/Core/DebugOff.hpp>

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
@@ -18,26 +18,26 @@ class NzObjectRef
public:
NzObjectRef();
NzObjectRef(T* resource);
NzObjectRef(T* object);
NzObjectRef(const NzObjectRef& ref);
NzObjectRef(NzObjectRef&& ref) noexcept;
~NzObjectRef();
bool IsValid() const;
T* Release();
bool Reset(T* resource = nullptr);
bool Reset(T* object = nullptr);
NzObjectRef& Swap(NzObjectRef& ref);
operator bool() const;
operator T*() const;
T* operator->() const;
NzObjectRef& operator=(T* resource);
NzObjectRef& operator=(T* object);
NzObjectRef& operator=(const NzObjectRef& ref);
NzObjectRef& operator=(NzObjectRef&& ref) noexcept;
private:
T* m_resource;
T* m_object;
};
#include <Nazara/Core/ObjectRef.inl>

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
@@ -7,70 +7,70 @@
template<typename T>
NzObjectRef<T>::NzObjectRef() :
m_resource(nullptr)
m_object(nullptr)
{
}
template<typename T>
NzObjectRef<T>::NzObjectRef(T* resource) :
m_resource(resource)
NzObjectRef<T>::NzObjectRef(T* object) :
m_object(object)
{
if (m_resource)
m_resource->AddReference();
if (m_object)
m_object->AddReference();
}
template<typename T>
NzObjectRef<T>::NzObjectRef(const NzObjectRef& ref) :
m_resource(ref.m_resource)
m_object(ref.m_object)
{
if (m_resource)
m_resource->AddReference();
if (m_object)
m_object->AddReference();
}
template<typename T>
NzObjectRef<T>::NzObjectRef(NzObjectRef&& ref) noexcept :
m_resource(ref.m_resource)
m_object(ref.m_object)
{
ref.m_resource = nullptr; // On vole la référence
ref.m_object = nullptr; // On vole la référence
}
template<typename T>
NzObjectRef<T>::~NzObjectRef()
{
if (m_resource)
m_resource->RemoveReference();
if (m_object)
m_object->RemoveReference();
}
template<typename T>
bool NzObjectRef<T>::IsValid() const
{
return m_resource != nullptr;
return m_object != nullptr;
}
template<typename T>
T* NzObjectRef<T>::Release()
{
T* resource = m_resource;
m_resource = nullptr;
T* object = m_object;
m_object = nullptr;
return resource;
return object;
}
template<typename T>
bool NzObjectRef<T>::Reset(T* resource)
bool NzObjectRef<T>::Reset(T* object)
{
bool destroyed = false;
if (m_resource != resource)
if (m_object != object)
{
if (m_resource)
if (m_object)
{
destroyed = m_resource->RemoveReference();
m_resource = nullptr;
destroyed = m_object->RemoveReference();
m_object = nullptr;
}
m_resource = resource;
if (m_resource)
m_resource->AddReference();
m_object = object;
if (m_object)
m_object->AddReference();
}
return destroyed;
@@ -79,7 +79,7 @@ bool NzObjectRef<T>::Reset(T* resource)
template<typename T>
NzObjectRef<T>& NzObjectRef<T>::Swap(NzObjectRef& ref)
{
std::swap(m_resource, ref.m_resource);
std::swap(m_object, ref.m_object);
return *this;
}
@@ -93,19 +93,19 @@ NzObjectRef<T>::operator bool() const
template<typename T>
NzObjectRef<T>::operator T*() const
{
return m_resource;
return m_object;
}
template<typename T>
T* NzObjectRef<T>::operator->() const
{
return m_resource;
return m_object;
}
template<typename T>
NzObjectRef<T>& NzObjectRef<T>::operator=(T* resource)
NzObjectRef<T>& NzObjectRef<T>::operator=(T* object)
{
Reset(resource);
Reset(object);
return *this;
}
@@ -113,7 +113,7 @@ NzObjectRef<T>& NzObjectRef<T>::operator=(T* resource)
template<typename T>
NzObjectRef<T>& NzObjectRef<T>::operator=(const NzObjectRef& ref)
{
Reset(ref.m_resource);
Reset(ref.m_object);
return *this;
}
@@ -123,7 +123,7 @@ NzObjectRef<T>& NzObjectRef<T>::operator=(NzObjectRef&& ref) noexcept
{
Reset();
std::swap(m_resource, ref.m_resource);
std::swap(m_object, ref.m_object);
return *this;
}

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
@@ -16,7 +16,7 @@ template <typename T, typename M> M NzImplGetMemberType(M T::*);
template <typename T, typename R, R T::*M>
constexpr std::size_t NzImplOffsetOf()
{
return reinterpret_cast<std::size_t>(&(((T*)0)->*M));
return reinterpret_cast<std::size_t>(&((static_cast<T*>(0))->*M));
}
#define NzOffsetOf(type, member) NzImplOffsetOf<decltype(NzImplGetClassType(&type::member)), decltype(NzImplGetMemberType(&type::member)), &type::member>()

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -23,6 +23,8 @@ class NAZARA_API NzRefCounted
{
public:
NzRefCounted(bool persistent = true);
NzRefCounted(const NzRefCounted&) = delete;
NzRefCounted(NzRefCounted&&) = delete;
virtual ~NzRefCounted();
void AddObjectListener(NzObjectListener* listener, int index = 0) const;
@@ -37,6 +39,9 @@ class NAZARA_API NzRefCounted
bool SetPersistent(bool persistent = true, bool checkReferenceCount = false);
NzRefCounted& operator=(const NzRefCounted&) = delete;
NzRefCounted& operator=(NzRefCounted&&) = delete;
protected:
void NotifyCreated();
void NotifyDestroy();

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
@@ -14,12 +14,17 @@ class NAZARA_API NzResource
{
public:
NzResource() = default;
NzResource(const NzResource&) = default;
NzResource(NzResource&&) = default;
virtual ~NzResource();
NzString GetFilePath() const;
const NzString& GetFilePath() const;
void SetFilePath(const NzString& filePath);
NzResource& operator=(const NzResource&) = default;
NzResource& operator=(NzResource&&) = default;
private:
NzString m_filePath;
};

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
@@ -22,6 +22,7 @@ class NzResourceLoader
public:
using ExtensionGetter = bool (*)(const NzString& extension);
using FileLoader = bool (*)(Type* resource, const NzString& filePath, const Parameters& parameters);
using MemoryLoader = bool (*)(Type* resource, const void* data, std::size_t size, const Parameters& parameters);
using StreamChecker = nzTernary (*)(NzInputStream& stream, const Parameters& parameters);
using StreamLoader = bool (*)(Type* resource, NzInputStream& stream, const Parameters& parameters);
@@ -31,10 +32,10 @@ class NzResourceLoader
static bool LoadFromMemory(Type* resource, const void* data, unsigned int size, const Parameters& parameters = Parameters());
static bool LoadFromStream(Type* resource, NzInputStream& stream, const Parameters& parameters = Parameters());
static void RegisterLoader(ExtensionGetter extensionGetter, StreamChecker checkFunc, StreamLoader streamLoader, FileLoader fileLoader = nullptr);
static void UnregisterLoader(ExtensionGetter extensionGetter, StreamChecker checkFunc, StreamLoader streamLoader, FileLoader fileLoader = nullptr);
static void RegisterLoader(ExtensionGetter extensionGetter, StreamChecker checkFunc, StreamLoader streamLoader, FileLoader fileLoader = nullptr, MemoryLoader memoryLoader = nullptr);
static void UnregisterLoader(ExtensionGetter extensionGetter, StreamChecker checkFunc, StreamLoader streamLoader, FileLoader fileLoader = nullptr, MemoryLoader memoryLoader = nullptr);
using Loader = std::tuple<ExtensionGetter, StreamChecker, StreamLoader, FileLoader>;
using Loader = std::tuple<ExtensionGetter, StreamChecker, StreamLoader, FileLoader, MemoryLoader>;
using LoaderList = std::list<Loader>;
};

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
@@ -123,9 +123,77 @@ bool NzResourceLoader<Type, Parameters>::LoadFromFile(Type* resource, const NzSt
template<typename Type, typename Parameters>
bool NzResourceLoader<Type, Parameters>::LoadFromMemory(Type* resource, const void* data, unsigned int size, const Parameters& parameters)
{
#if NAZARA_CORE_SAFE
if (!parameters.IsValid())
{
NazaraError("Invalid parameters");
return false;
}
if (size == 0)
{
NazaraError("No data to load");
return false;
}
#endif
NzMemoryStream stream(data, size);
return LoadFromStream(resource, stream, parameters);
bool found = false;
for (Loader& loader : Type::s_loaders)
{
StreamChecker checkFunc = std::get<1>(loader);
StreamLoader streamLoader = std::get<2>(loader);
MemoryLoader memoryLoader = std::get<4>(loader);
nzTernary recognized = nzTernary_Unknown;
if (memoryLoader)
{
if (checkFunc)
{
stream.SetCursorPos(0);
recognized = checkFunc(stream, parameters);
if (recognized == nzTernary_False)
continue;
else
found = true;
}
else
{
recognized = nzTernary_Unknown;
found = true;
}
if (memoryLoader(resource, data, size, parameters))
return true;
}
else
{
stream.SetCursorPos(0);
recognized = checkFunc(stream, parameters);
if (recognized == nzTernary_False)
continue;
else if (recognized == nzTernary_True)
found = true;
stream.SetCursorPos(0);
if (streamLoader(resource, stream, parameters))
return true;
}
if (recognized == nzTernary_True)
NazaraWarning("Loader failed");
}
if (found)
NazaraError("Failed to load file: all loaders failed");
else
NazaraError("Failed to load file: no loader found");
return false;
}
template<typename Type, typename Parameters>
@@ -181,7 +249,7 @@ bool NzResourceLoader<Type, Parameters>::LoadFromStream(Type* resource, NzInputS
}
template<typename Type, typename Parameters>
void NzResourceLoader<Type, Parameters>::RegisterLoader(ExtensionGetter extensionGetter, StreamChecker checkFunc, StreamLoader streamLoader, FileLoader fileLoader)
void NzResourceLoader<Type, Parameters>::RegisterLoader(ExtensionGetter extensionGetter, StreamChecker checkFunc, StreamLoader streamLoader, FileLoader fileLoader, MemoryLoader memoryLoader)
{
#if NAZARA_CORE_SAFE
if (streamLoader)
@@ -192,20 +260,20 @@ void NzResourceLoader<Type, Parameters>::RegisterLoader(ExtensionGetter extensio
return;
}
}
else if (!fileLoader)
else if (!fileLoader && !memoryLoader)
{
NazaraError("Neither FileLoader nor StreamLoader were present");
NazaraError("Neither FileLoader nor MemoryLoader nor StreamLoader were present");
return;
}
#endif
Type::s_loaders.push_front(std::make_tuple(extensionGetter, checkFunc, streamLoader, fileLoader));
Type::s_loaders.push_front(std::make_tuple(extensionGetter, checkFunc, streamLoader, fileLoader, memoryLoader));
}
template<typename Type, typename Parameters>
void NzResourceLoader<Type, Parameters>::UnregisterLoader(ExtensionGetter extensionGetter, StreamChecker checkFunc, StreamLoader streamLoader, FileLoader fileLoader)
void NzResourceLoader<Type, Parameters>::UnregisterLoader(ExtensionGetter extensionGetter, StreamChecker checkFunc, StreamLoader streamLoader, FileLoader fileLoader, MemoryLoader memoryLoader)
{
Type::s_loaders.remove(std::make_tuple(extensionGetter, checkFunc, streamLoader, fileLoader));
Type::s_loaders.remove(std::make_tuple(extensionGetter, checkFunc, streamLoader, fileLoader, memoryLoader));
}
#include <Nazara/Core/DebugOff.hpp>

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
@@ -10,30 +10,49 @@
///FIXME: Est-ce que SparsePtr est vraiment le meilleur nom pour cette classe ?
#include <Nazara/Prerequesites.hpp>
#include <cstddef>
#include <type_traits>
template<typename T>
class NzSparsePtr
{
public:
using BytePtr = typename std::conditional<std::is_const<T>::value, const nzUInt8*, nzUInt8*>::type;
using VoidPtr = typename std::conditional<std::is_const<T>::value, const void*, void*>::type;
NzSparsePtr();
NzSparsePtr(void* ptr, unsigned int stride);
NzSparsePtr(T* ptr);
NzSparsePtr(VoidPtr ptr, int stride);
template<typename U> NzSparsePtr(const NzSparsePtr<U>& ptr);
NzSparsePtr(const NzSparsePtr& ptr) = default;
~NzSparsePtr() = default;
void* Get() const;
unsigned int GetStride() const;
void Set(void* ptr);
void SetStride(unsigned int stride);
VoidPtr GetPtr() const;
int GetStride() const;
void Reset();
void Reset(T* ptr);
void Reset(VoidPtr ptr, int stride);
void Reset(const NzSparsePtr& ptr);
template<typename U> void Reset(const NzSparsePtr<U>& ptr);
void SetPtr(VoidPtr ptr);
void SetStride(int stride);
operator bool() const;
operator T*() const;
T& operator*() const;
T& operator->() const;
T& operator[](unsigned int index) const;
T& operator[](int index) const;
NzSparsePtr operator+(int count) const;
NzSparsePtr operator+(unsigned int count) const;
NzSparsePtr operator-(int count) const;
NzSparsePtr operator-(unsigned int count) const;
std::ptrdiff_t operator-(const NzSparsePtr& ptr) const;
NzSparsePtr& operator+=(unsigned int count);
NzSparsePtr& operator-=(unsigned int count);
NzSparsePtr& operator+=(int count);
NzSparsePtr& operator-=(int count);
NzSparsePtr& operator++();
NzSparsePtr operator++(int);
@@ -51,8 +70,8 @@ class NzSparsePtr
NzSparsePtr& operator=(const NzSparsePtr& ptr) = default;
private:
nzUInt8* m_ptr;
unsigned int m_stride;
BytePtr m_ptr;
int m_stride;
};
#include <Nazara/Core/SparsePtr.inl>

View File

@@ -1,47 +1,108 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Core/Debug.hpp>
template<typename T>
NzSparsePtr<T>::NzSparsePtr() :
m_ptr(nullptr),
m_stride(0)
NzSparsePtr<T>::NzSparsePtr()
{
Reset();
}
template<typename T>
NzSparsePtr<T>::NzSparsePtr(void* ptr, unsigned int stride)
NzSparsePtr<T>::NzSparsePtr(T* ptr)
{
Set(ptr);
SetStride(stride);
Reset(ptr);
}
template<typename T>
void* NzSparsePtr<T>::Get() const
NzSparsePtr<T>::NzSparsePtr(VoidPtr ptr, int stride)
{
Reset(ptr, stride);
}
template<typename T>
template<typename U>
NzSparsePtr<T>::NzSparsePtr(const NzSparsePtr<U>& ptr)
{
Reset(ptr);
}
template<typename T>
typename NzSparsePtr<T>::VoidPtr NzSparsePtr<T>::GetPtr() const
{
return m_ptr;
}
template<typename T>
unsigned int NzSparsePtr<T>::GetStride() const
int NzSparsePtr<T>::GetStride() const
{
return m_stride;
}
template<typename T>
void NzSparsePtr<T>::Set(void* ptr)
void NzSparsePtr<T>::Reset()
{
m_ptr = reinterpret_cast<nzUInt8*>(ptr);
SetPtr(nullptr);
SetStride(0);
}
template<typename T>
void NzSparsePtr<T>::SetStride(unsigned int stride)
void NzSparsePtr<T>::Reset(T* ptr)
{
SetPtr(ptr);
SetStride(sizeof(T));
}
template<typename T>
void NzSparsePtr<T>::Reset(VoidPtr ptr, int stride)
{
SetPtr(ptr);
SetStride(stride);
}
template<typename T>
void NzSparsePtr<T>::Reset(const NzSparsePtr& ptr)
{
SetPtr(ptr.GetPtr());
SetStride(ptr.GetStride());
}
template<typename T>
template<typename U>
void NzSparsePtr<T>::Reset(const NzSparsePtr<U>& ptr)
{
static_assert(std::is_convertible<U*, T*>::value, "Source type pointer cannot be implicitely converted to target type pointer");
SetPtr(static_cast<T*>(ptr.GetPtr()));
SetStride(ptr.GetStride());
}
template<typename T>
void NzSparsePtr<T>::SetPtr(VoidPtr ptr)
{
m_ptr = reinterpret_cast<BytePtr>(ptr);
}
template<typename T>
void NzSparsePtr<T>::SetStride(int stride)
{
m_stride = stride;
}
template<typename T>
NzSparsePtr<T>::operator bool() const
{
return m_ptr != nullptr;
}
template<typename T>
NzSparsePtr<T>::operator T*() const
{
return reinterpret_cast<T*>(m_ptr);
}
template<typename T>
T& NzSparsePtr<T>::operator*() const
{
@@ -55,17 +116,29 @@ T& NzSparsePtr<T>::operator->() const
}
template<typename T>
T& NzSparsePtr<T>::operator[](unsigned int index) const
T& NzSparsePtr<T>::operator[](int index) const
{
return *reinterpret_cast<T*>(m_ptr + index*m_stride);
}
template<typename T>
NzSparsePtr<T> NzSparsePtr<T>::operator+(int count) const
{
return NzSparsePtr(m_ptr + count*m_stride, m_stride);
}
template<typename T>
NzSparsePtr<T> NzSparsePtr<T>::operator+(unsigned int count) const
{
return NzSparsePtr(m_ptr + count*m_stride, m_stride);
}
template<typename T>
NzSparsePtr<T> NzSparsePtr<T>::operator-(int count) const
{
return NzSparsePtr(m_ptr - count*m_stride, m_stride);
}
template<typename T>
NzSparsePtr<T> NzSparsePtr<T>::operator-(unsigned int count) const
{
@@ -73,16 +146,24 @@ NzSparsePtr<T> NzSparsePtr<T>::operator-(unsigned int count) const
}
template<typename T>
NzSparsePtr<T>& NzSparsePtr<T>::operator+=(unsigned int count)
std::ptrdiff_t NzSparsePtr<T>::operator-(const NzSparsePtr& ptr) const
{
return (m_ptr - ptr.m_ptr)/m_stride;
}
template<typename T>
NzSparsePtr<T>& NzSparsePtr<T>::operator+=(int count)
{
m_ptr += count*m_stride;
return *this;
}
template<typename T>
NzSparsePtr<T>& NzSparsePtr<T>::operator-=(unsigned int count)
NzSparsePtr<T>& NzSparsePtr<T>::operator-=(int count)
{
m_ptr -= count*m_stride;
return *this;
}
@@ -90,6 +171,7 @@ template<typename T>
NzSparsePtr<T>& NzSparsePtr<T>::operator++()
{
m_ptr += m_stride;
return *this;
}

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Jérôme Leclercq
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core Module"
// For conditions of distribution and use, see copyright notice in Config.hpp
@@ -9,9 +9,12 @@
#include <Nazara/Prerequesites.hpp>
class NzUpdatable
class NAZARA_API NzUpdatable
{
public:
NzUpdatable() = default;
virtual ~NzUpdatable();
virtual void Update() = 0;
};