Merge branch 'master' into NDK
Conflicts: src/Nazara/Physics/Geom.cpp Former-commit-id: 8fd71e34dbe105890042acc55e30b64e7c457ed4
This commit is contained in:
commit
446f537e3f
|
|
@ -18,25 +18,8 @@
|
||||||
class NAZARA_API NzGuillotineBinPack
|
class NAZARA_API NzGuillotineBinPack
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum FreeRectChoiceHeuristic
|
enum FreeRectChoiceHeuristic : int;
|
||||||
{
|
enum GuillotineSplitHeuristic : int;
|
||||||
RectBestAreaFit,
|
|
||||||
RectBestLongSideFit,
|
|
||||||
RectBestShortSideFit,
|
|
||||||
RectWorstAreaFit,
|
|
||||||
RectWorstLongSideFit,
|
|
||||||
RectWorstShortSideFit
|
|
||||||
};
|
|
||||||
|
|
||||||
enum GuillotineSplitHeuristic
|
|
||||||
{
|
|
||||||
SplitLongerAxis,
|
|
||||||
SplitLongerLeftoverAxis,
|
|
||||||
SplitMaximizeArea,
|
|
||||||
SplitMinimizeArea,
|
|
||||||
SplitShorterAxis,
|
|
||||||
SplitShorterLeftoverAxis
|
|
||||||
};
|
|
||||||
|
|
||||||
NzGuillotineBinPack();
|
NzGuillotineBinPack();
|
||||||
NzGuillotineBinPack(unsigned int width, unsigned int height);
|
NzGuillotineBinPack(unsigned int width, unsigned int height);
|
||||||
|
|
@ -70,6 +53,26 @@ class NAZARA_API NzGuillotineBinPack
|
||||||
NzGuillotineBinPack& operator=(const NzGuillotineBinPack&) = default;
|
NzGuillotineBinPack& operator=(const NzGuillotineBinPack&) = default;
|
||||||
NzGuillotineBinPack& operator=(NzGuillotineBinPack&&) = default;
|
NzGuillotineBinPack& operator=(NzGuillotineBinPack&&) = default;
|
||||||
|
|
||||||
|
enum FreeRectChoiceHeuristic : int
|
||||||
|
{
|
||||||
|
RectBestAreaFit,
|
||||||
|
RectBestLongSideFit,
|
||||||
|
RectBestShortSideFit,
|
||||||
|
RectWorstAreaFit,
|
||||||
|
RectWorstLongSideFit,
|
||||||
|
RectWorstShortSideFit
|
||||||
|
};
|
||||||
|
|
||||||
|
enum GuillotineSplitHeuristic : int
|
||||||
|
{
|
||||||
|
SplitLongerAxis,
|
||||||
|
SplitLongerLeftoverAxis,
|
||||||
|
SplitMaximizeArea,
|
||||||
|
SplitMinimizeArea,
|
||||||
|
SplitShorterAxis,
|
||||||
|
SplitShorterLeftoverAxis
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SplitFreeRectAlongAxis(const NzRectui& freeRect, const NzRectui& placedRect, bool splitHorizontal);
|
void SplitFreeRectAlongAxis(const NzRectui& freeRect, const NzRectui& placedRect, bool splitHorizontal);
|
||||||
void SplitFreeRectByHeuristic(const NzRectui& freeRect, const NzRectui& placedRect, GuillotineSplitHeuristic method);
|
void SplitFreeRectByHeuristic(const NzRectui& freeRect, const NzRectui& placedRect, GuillotineSplitHeuristic method);
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,8 @@ class NAZARA_API NzView : public NzAbstractViewer, public NzNode, NzRenderTarget
|
||||||
float GetZFar() const;
|
float GetZFar() const;
|
||||||
float GetZNear() const;
|
float GetZNear() const;
|
||||||
|
|
||||||
NzVector2i MapWorldToPixel(const NzVector2f& coords);
|
|
||||||
NzVector2f MapPixelToWorld(const NzVector2i& pixel);
|
NzVector2f MapPixelToWorld(const NzVector2i& pixel);
|
||||||
|
NzVector2i MapWorldToPixel(const NzVector2f& coords);
|
||||||
|
|
||||||
void SetSize(const NzVector2f& size);
|
void SetSize(const NzVector2f& size);
|
||||||
void SetSize(float width, float height);
|
void SetSize(float width, float height);
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,15 @@ enum nzLuaComparison
|
||||||
enum nzLuaOperation
|
enum nzLuaOperation
|
||||||
{
|
{
|
||||||
nzLuaOperation_Addition,
|
nzLuaOperation_Addition,
|
||||||
|
nzLuaOperation_BitwiseAnd,
|
||||||
|
nzLuaOperation_BitwiseLeftShift,
|
||||||
|
nzLuaOperation_BitwiseNot,
|
||||||
|
nzLuaOperation_BitwiseOr,
|
||||||
|
nzLuaOperation_BitwideRightShift,
|
||||||
|
nzLuaOperation_BitwiseXOr,
|
||||||
nzLuaOperation_Division,
|
nzLuaOperation_Division,
|
||||||
nzLuaOperation_Exponentiation,
|
nzLuaOperation_Exponentiation,
|
||||||
|
nzLuaOperation_FloorDivision,
|
||||||
nzLuaOperation_Modulo,
|
nzLuaOperation_Modulo,
|
||||||
nzLuaOperation_Multiplication,
|
nzLuaOperation_Multiplication,
|
||||||
nzLuaOperation_Negation,
|
nzLuaOperation_Negation,
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,9 @@ class NAZARA_API NzLuaInstance : NzNonCopyable
|
||||||
int ArgError(unsigned int argNum, const char* error);
|
int ArgError(unsigned int argNum, const char* error);
|
||||||
int ArgError(unsigned int argNum, const NzString& error);
|
int ArgError(unsigned int argNum, const NzString& error);
|
||||||
|
|
||||||
|
bool Call(unsigned int argCount);
|
||||||
|
bool Call(unsigned int argCount, unsigned int resultCount);
|
||||||
|
|
||||||
void CheckAny(int index) const;
|
void CheckAny(int index) const;
|
||||||
bool CheckBoolean(int index) const;
|
bool CheckBoolean(int index) const;
|
||||||
bool CheckBoolean(int index, bool defValue) const;
|
bool CheckBoolean(int index, bool defValue) const;
|
||||||
|
|
@ -146,7 +149,7 @@ class NAZARA_API NzLuaInstance : NzNonCopyable
|
||||||
static NzLuaInstance* GetInstance(lua_State* state);
|
static NzLuaInstance* GetInstance(lua_State* state);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool Run();
|
bool Run(int argCount, int resultCount);
|
||||||
|
|
||||||
static void* MemoryAllocator(void *ud, void *ptr, std::size_t osize, std::size_t nsize);
|
static void* MemoryAllocator(void *ud, void *ptr, std::size_t osize, std::size_t nsize);
|
||||||
static int ProxyFunc(lua_State* state);
|
static int ProxyFunc(lua_State* state);
|
||||||
|
|
|
||||||
|
|
@ -748,7 +748,6 @@ NzMatrix4<T>& NzMatrix4<T>::Set(const T matrix[16])
|
||||||
template<typename T>
|
template<typename T>
|
||||||
NzMatrix4<T>& NzMatrix4<T>::Set(const NzMatrix4& matrix)
|
NzMatrix4<T>& NzMatrix4<T>::Set(const NzMatrix4& matrix)
|
||||||
{
|
{
|
||||||
// Le membre isIdentity est copié en même temps que les valeurs
|
|
||||||
std::memcpy(this, &matrix, sizeof(NzMatrix4));
|
std::memcpy(this, &matrix, sizeof(NzMatrix4));
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (C) 2015 Jérôme Leclercq
|
// Copyright (C) 2015 Jérôme Leclercq
|
||||||
// This file is part of the "Nazara Engine - Physics module"
|
// This file is part of the "Nazara Engine - Physics module"
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
// Copyright (C) 2015 Jérôme Leclercq
|
// Copyright (C) 2015 Jérôme Leclercq
|
||||||
// This file is part of the "Nazara Engine - Physics module"
|
// This file is part of the "Nazara Engine - Physics module"
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp
|
// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp
|
||||||
#if NAZARA_PHYSICS_MANAGE_MEMORY
|
#if NAZARA_PHYSICS_MANAGE_MEMORY
|
||||||
#undef delete
|
#undef delete
|
||||||
#undef new
|
#undef new
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (C) 2015 Jérôme Leclercq
|
// Copyright (C) 2015 Jérôme Leclercq
|
||||||
// This file is part of the "Nazara Engine - Physics module"
|
// This file is part of the "Nazara Engine - Physics module"
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,7 @@ class NAZARA_API NzRenderTexture : public NzRenderTarget, NzObjectListener, NzNo
|
||||||
private:
|
private:
|
||||||
bool OnObjectDestroy(const NzRefCounted* object, int index) override;
|
bool OnObjectDestroy(const NzRefCounted* object, int index) override;
|
||||||
void UpdateDrawBuffers() const;
|
void UpdateDrawBuffers() const;
|
||||||
|
void UpdateSize() const;
|
||||||
void UpdateTargets() const;
|
void UpdateTargets() const;
|
||||||
|
|
||||||
NzRenderTextureImpl* m_impl = nullptr;
|
NzRenderTextureImpl* m_impl = nullptr;
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,12 @@ class NAZARA_API NzSimpleTextDrawer : public NzAbstractTextDrawer, NzObjectListe
|
||||||
unsigned int GetCharacterSize() const;
|
unsigned int GetCharacterSize() const;
|
||||||
const NzColor& GetColor() const;
|
const NzColor& GetColor() const;
|
||||||
NzFont* GetFont() const;
|
NzFont* GetFont() const;
|
||||||
|
NzFont* GetFont(unsigned int index) const override;
|
||||||
|
unsigned int GetFontCount() const override;
|
||||||
|
const Glyph& GetGlyph(unsigned int index) const override;
|
||||||
|
unsigned int GetGlyphCount() const override;
|
||||||
nzUInt32 GetStyle() const;
|
nzUInt32 GetStyle() const;
|
||||||
|
const NzString& GetText() const;
|
||||||
|
|
||||||
void SetCharacterSize(unsigned int characterSize);
|
void SetCharacterSize(unsigned int characterSize);
|
||||||
void SetColor(const NzColor& color);
|
void SetColor(const NzColor& color);
|
||||||
|
|
@ -37,11 +42,6 @@ class NAZARA_API NzSimpleTextDrawer : public NzAbstractTextDrawer, NzObjectListe
|
||||||
static NzSimpleTextDrawer Draw(NzFont* font, const NzString& str, unsigned int characterSize, nzUInt32 style = nzTextStyle_Regular, const NzColor& color = NzColor::White);
|
static NzSimpleTextDrawer Draw(NzFont* font, const NzString& str, unsigned int characterSize, nzUInt32 style = nzTextStyle_Regular, const NzColor& color = NzColor::White);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NzFont* GetFont(unsigned int index) const override;
|
|
||||||
unsigned int GetFontCount() const override;
|
|
||||||
const Glyph& GetGlyph(unsigned int index) const override;
|
|
||||||
unsigned int GetGlyphCount() const override;
|
|
||||||
|
|
||||||
bool OnObjectModified(const NzRefCounted* object, int index, unsigned int code) override;
|
bool OnObjectModified(const NzRefCounted* object, int index, unsigned int code) override;
|
||||||
void OnObjectReleased(const NzRefCounted* object, int index) override;
|
void OnObjectReleased(const NzRefCounted* object, int index) override;
|
||||||
void UpdateGlyphs() const;
|
void UpdateGlyphs() const;
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
#elif defined(NAZARA_PLATFORM_POSIX)
|
#elif defined(NAZARA_PLATFORM_POSIX)
|
||||||
#include <Nazara/Core/Posix/ConditionVariableImpl.hpp>
|
#include <Nazara/Core/Posix/ConditionVariableImpl.hpp>
|
||||||
#else
|
#else
|
||||||
#error Thread condition has no implementation
|
#error Condition variable has no implementation
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <Nazara/Core/Debug.hpp>
|
#include <Nazara/Core/Debug.hpp>
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,8 @@ namespace
|
||||||
bool s_initialized = false;
|
bool s_initialized = false;
|
||||||
const unsigned int s_magic = 0xDEADB33FUL;
|
const unsigned int s_magic = 0xDEADB33FUL;
|
||||||
const char* s_logFileName = "NazaraMemory.log";
|
const char* s_logFileName = "NazaraMemory.log";
|
||||||
const char* s_nextFreeFile = "(Internal error)";
|
thread_local const char* s_nextFreeFile = "(Internal error)";
|
||||||
unsigned int s_nextFreeLine = 0;
|
thread_local unsigned int s_nextFreeLine = 0;
|
||||||
|
|
||||||
Block s_list =
|
Block s_list =
|
||||||
{
|
{
|
||||||
|
|
@ -235,6 +235,7 @@ void NzMemoryManager::Initialize()
|
||||||
|
|
||||||
#ifdef NAZARA_PLATFORM_WINDOWS
|
#ifdef NAZARA_PLATFORM_WINDOWS
|
||||||
InitializeCriticalSection(&s_mutex);
|
InitializeCriticalSection(&s_mutex);
|
||||||
|
//#elif defined(NAZARA_PLATFORM_POSIX) is already done in the namespace
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
s_initialized = true;
|
s_initialized = true;
|
||||||
|
|
@ -250,6 +251,8 @@ void NzMemoryManager::Uninitialize()
|
||||||
{
|
{
|
||||||
#ifdef NAZARA_PLATFORM_WINDOWS
|
#ifdef NAZARA_PLATFORM_WINDOWS
|
||||||
DeleteCriticalSection(&s_mutex);
|
DeleteCriticalSection(&s_mutex);
|
||||||
|
#elif defined(NAZARA_PLATFORM_POSIX)
|
||||||
|
pthread_mutex_destroy(&s_mutex);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FILE* log = std::fopen(s_logFileName, "a");
|
FILE* log = std::fopen(s_logFileName, "a");
|
||||||
|
|
|
||||||
|
|
@ -266,8 +266,8 @@ bool NzParameterList::GetUserdataParameter(const NzString& name, void** value) c
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NazaraError("Parameter value is not an userdata");
|
NazaraError("Parameter value is not a userdata");
|
||||||
return nullptr;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ bool NzConditionVariableImpl::Wait(NzMutexImpl* mutex, nzUInt32 timeout)
|
||||||
{
|
{
|
||||||
// get the current time
|
// get the current time
|
||||||
timeval tv;
|
timeval tv;
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, nullptr);
|
||||||
|
|
||||||
// construct the time limit (current time + time to wait)
|
// construct the time limit (current time + time to wait)
|
||||||
timespec ti;
|
timespec ti;
|
||||||
|
|
|
||||||
|
|
@ -82,14 +82,15 @@ bool NzDirectoryImpl::Exists(const NzString& dirPath)
|
||||||
NzString NzDirectoryImpl::GetCurrent()
|
NzString NzDirectoryImpl::GetCurrent()
|
||||||
{
|
{
|
||||||
NzString currentPath;
|
NzString currentPath;
|
||||||
char* path = new char[_PC_PATH_MAX];
|
char* path = getcwd(nullptr, 0);
|
||||||
|
|
||||||
if (getcwd(path, _PC_PATH_MAX))
|
if (path)
|
||||||
|
{
|
||||||
currentPath = path;
|
currentPath = path;
|
||||||
|
free(path);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
NazaraError("Unable to get current directory: " + NzError::GetLastSystemError());
|
NazaraError("Unable to get current directory: " + NzError::GetLastSystemError()); // Bug: initialisation -> if no path for log !
|
||||||
|
|
||||||
delete[] path;
|
|
||||||
|
|
||||||
return currentPath;
|
return currentPath;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,11 @@
|
||||||
|
|
||||||
NzMutexImpl::NzMutexImpl()
|
NzMutexImpl::NzMutexImpl()
|
||||||
{
|
{
|
||||||
pthread_mutex_init(&m_handle, NULL);
|
pthread_mutexattr_t attr;
|
||||||
|
pthread_mutexattr_init(&attr);
|
||||||
|
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||||
|
|
||||||
|
pthread_mutex_init(&m_handle, &attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
NzMutexImpl::~NzMutexImpl()
|
NzMutexImpl::~NzMutexImpl()
|
||||||
|
|
|
||||||
|
|
@ -57,9 +57,9 @@ void NzThreadImpl::Sleep(nzUInt32 time)
|
||||||
|
|
||||||
// create a mutex and thread condition
|
// create a mutex and thread condition
|
||||||
pthread_mutex_t mutex;
|
pthread_mutex_t mutex;
|
||||||
pthread_mutex_init(&mutex, 0);
|
pthread_mutex_init(&mutex, nullptr);
|
||||||
pthread_cond_t condition;
|
pthread_cond_t condition;
|
||||||
pthread_cond_init(&condition, 0);
|
pthread_cond_init(&condition, nullptr);
|
||||||
|
|
||||||
// wait...
|
// wait...
|
||||||
pthread_mutex_lock(&mutex);
|
pthread_mutex_lock(&mutex);
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
bool NzTaskSchedulerImpl::Initialize(unsigned int workerCount)
|
bool NzTaskSchedulerImpl::Initialize(unsigned int workerCount)
|
||||||
{
|
{
|
||||||
if (s_workerCount > 0)
|
if (IsInitialized())
|
||||||
return true; // Déjà initialisé
|
return true; // Déjà initialisé
|
||||||
|
|
||||||
#if NAZARA_CORE_SAFE
|
#if NAZARA_CORE_SAFE
|
||||||
|
|
|
||||||
|
|
@ -171,6 +171,10 @@ void NzCamera::SetTarget(const NzRenderTarget* renderTarget)
|
||||||
m_target = renderTarget;
|
m_target = renderTarget;
|
||||||
if (m_target)
|
if (m_target)
|
||||||
m_target->AddListener(this);
|
m_target->AddListener(this);
|
||||||
|
|
||||||
|
m_frustumUpdated = false;
|
||||||
|
m_projectionMatrixUpdated = false;
|
||||||
|
m_viewportUpdated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzCamera::SetTarget(const NzRenderTarget& renderTarget)
|
void NzCamera::SetTarget(const NzRenderTarget& renderTarget)
|
||||||
|
|
|
||||||
|
|
@ -127,8 +127,8 @@ bool NzDeferredPhongLightingPass::Process(const NzScene* scene, unsigned int fir
|
||||||
NzRenderer::SetRenderStates(lightStates);
|
NzRenderer::SetRenderStates(lightStates);
|
||||||
|
|
||||||
NzRenderer::SetShader(m_pointSpotLightShader);
|
NzRenderer::SetShader(m_pointSpotLightShader);
|
||||||
m_pointSpotLightShader->SendColor(m_pointSpotLightShaderEyePositionLocation, scene->GetAmbientColor());
|
m_pointSpotLightShader->SendColor(m_pointSpotLightShaderSceneAmbientLocation, scene->GetAmbientColor());
|
||||||
m_pointSpotLightShader->SendVector(m_pointSpotLightShaderSceneAmbientLocation, scene->GetViewer()->GetEyePosition());
|
m_pointSpotLightShader->SendVector(m_pointSpotLightShaderEyePositionLocation, scene->GetViewer()->GetEyePosition());
|
||||||
|
|
||||||
NzMatrix4f lightMatrix;
|
NzMatrix4f lightMatrix;
|
||||||
lightMatrix.MakeIdentity();
|
lightMatrix.MakeIdentity();
|
||||||
|
|
|
||||||
|
|
@ -658,9 +658,12 @@ void NzForwardRenderTechnique::DrawTransparentModels(const NzScene* scene) const
|
||||||
shader->SendVector(shaderUniforms->eyePosition, viewer->GetEyePosition());
|
shader->SendVector(shaderUniforms->eyePosition, viewer->GetEyePosition());
|
||||||
|
|
||||||
// On envoie les lumières directionnelles s'il y a (Les mêmes pour tous)
|
// On envoie les lumières directionnelles s'il y a (Les mêmes pour tous)
|
||||||
|
if (shaderUniforms->hasLightUniforms)
|
||||||
|
{
|
||||||
lightCount = std::min(m_directionalLights.GetLightCount(), NazaraSuffixMacro(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS, U));
|
lightCount = std::min(m_directionalLights.GetLightCount(), NazaraSuffixMacro(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS, U));
|
||||||
for (unsigned int i = 0; i < lightCount; ++i)
|
for (unsigned int i = 0; i < lightCount; ++i)
|
||||||
m_directionalLights.GetLight(i)->Enable(shader, shaderUniforms->lightUniforms, shaderUniforms->lightOffset*i);
|
m_directionalLights.GetLight(i)->Enable(shader, shaderUniforms->lightUniforms, shaderUniforms->lightOffset*i);
|
||||||
|
}
|
||||||
|
|
||||||
lastShader = shader;
|
lastShader = shader;
|
||||||
}
|
}
|
||||||
|
|
@ -690,6 +693,8 @@ void NzForwardRenderTechnique::DrawTransparentModels(const NzScene* scene) const
|
||||||
NzRenderer::SetIndexBuffer(indexBuffer);
|
NzRenderer::SetIndexBuffer(indexBuffer);
|
||||||
NzRenderer::SetVertexBuffer(vertexBuffer);
|
NzRenderer::SetVertexBuffer(vertexBuffer);
|
||||||
|
|
||||||
|
if (shaderUniforms->hasLightUniforms)
|
||||||
|
{
|
||||||
// Calcul des lumières les plus proches
|
// Calcul des lumières les plus proches
|
||||||
if (lightCount < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS && !m_lights.IsEmpty())
|
if (lightCount < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS && !m_lights.IsEmpty())
|
||||||
{
|
{
|
||||||
|
|
@ -704,6 +709,7 @@ void NzForwardRenderTechnique::DrawTransparentModels(const NzScene* scene) const
|
||||||
|
|
||||||
for (unsigned int i = lightCount; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i)
|
for (unsigned int i = lightCount; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i)
|
||||||
NzLight::Disable(shader, shaderUniforms->lightUniforms, shaderUniforms->lightOffset*i);
|
NzLight::Disable(shader, shaderUniforms->lightUniforms, shaderUniforms->lightOffset*i);
|
||||||
|
}
|
||||||
|
|
||||||
NzRenderer::SetMatrix(nzMatrixType_World, matrix);
|
NzRenderer::SetMatrix(nzMatrixType_World, matrix);
|
||||||
drawFunc(meshData.primitiveMode, 0, indexCount);
|
drawFunc(meshData.primitiveMode, 0, indexCount);
|
||||||
|
|
|
||||||
|
|
@ -170,6 +170,24 @@ float NzView::GetZNear() const
|
||||||
return m_zNear;
|
return m_zNear;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NzVector2f NzView::MapPixelToWorld(const NzVector2i& pixel)
|
||||||
|
{
|
||||||
|
if (!m_invViewProjMatrixUpdated)
|
||||||
|
UpdateInvViewProjMatrix();
|
||||||
|
|
||||||
|
if (!m_viewportUpdated)
|
||||||
|
UpdateViewport();
|
||||||
|
|
||||||
|
// Conversion du viewport en flottant
|
||||||
|
NzRectf viewport(m_viewport);
|
||||||
|
|
||||||
|
NzVector2f normalized;
|
||||||
|
normalized.x = -1.f + 2.f * (pixel.x - viewport.x) / viewport.width;
|
||||||
|
normalized.y = 1.f - 2.f * (pixel.y - viewport.y) / viewport.height;
|
||||||
|
|
||||||
|
return m_invViewProjMatrix.Transform(normalized);
|
||||||
|
}
|
||||||
|
|
||||||
NzVector2i NzView::MapWorldToPixel(const NzVector2f& coords)
|
NzVector2i NzView::MapWorldToPixel(const NzVector2f& coords)
|
||||||
{
|
{
|
||||||
if (!m_viewProjMatrixUpdated)
|
if (!m_viewProjMatrixUpdated)
|
||||||
|
|
@ -190,24 +208,6 @@ NzVector2i NzView::MapWorldToPixel(const NzVector2f& coords)
|
||||||
return pixel;
|
return pixel;
|
||||||
}
|
}
|
||||||
|
|
||||||
NzVector2f NzView::MapPixelToWorld(const NzVector2i& pixel)
|
|
||||||
{
|
|
||||||
if (!m_invViewProjMatrixUpdated)
|
|
||||||
UpdateInvViewProjMatrix();
|
|
||||||
|
|
||||||
if (!m_viewportUpdated)
|
|
||||||
UpdateViewport();
|
|
||||||
|
|
||||||
// Conversion du viewport en flottant
|
|
||||||
NzRectf viewport(m_viewport);
|
|
||||||
|
|
||||||
NzVector2f normalized;
|
|
||||||
normalized.x = -1.f + 2.f * (pixel.x - viewport.x) / viewport.width;
|
|
||||||
normalized.y = 1.f - 2.f * (pixel.y - viewport.y) / viewport.height;
|
|
||||||
|
|
||||||
return m_invViewProjMatrix.Transform(normalized);
|
|
||||||
}
|
|
||||||
|
|
||||||
void NzView::SetSize(const NzVector2f& size)
|
void NzView::SetSize(const NzVector2f& size)
|
||||||
{
|
{
|
||||||
SetSize(size.x, size.y);
|
SetSize(size.x, size.y);
|
||||||
|
|
|
||||||
|
|
@ -96,10 +96,17 @@ namespace
|
||||||
|
|
||||||
int s_operations[] = {
|
int s_operations[] = {
|
||||||
LUA_OPADD, // nzLuaOperation_Addition
|
LUA_OPADD, // nzLuaOperation_Addition
|
||||||
|
LUA_OPBAND, // nzLuaOperation_BitwiseAnd
|
||||||
|
LUA_OPSHL, // nzLuaOperation_BitwiseLeftShift
|
||||||
|
LUA_OPBNOT, // nzLuaOperation_BitwiseNot
|
||||||
|
LUA_OPBOR, // nzLuaOperation_BitwiseOr
|
||||||
|
LUA_OPSHR, // nzLuaOperation_BitwiseRightShift
|
||||||
|
LUA_OPBXOR, // nzLuaOperation_BitwiseXOr
|
||||||
LUA_OPDIV, // nzLuaOperation_Division
|
LUA_OPDIV, // nzLuaOperation_Division
|
||||||
LUA_OPPOW, // nzLuaOperation_Exponentiation
|
LUA_OPPOW, // nzLuaOperation_Exponentiation
|
||||||
LUA_OPMOD, // nzLuaOperation_Modulo
|
LUA_OPIDIV, // nzLuaOperation_FloorDivision
|
||||||
LUA_OPMUL, // nzLuaOperation_Multiplication
|
LUA_OPMUL, // nzLuaOperation_Multiplication
|
||||||
|
LUA_OPMOD, // nzLuaOperation_Modulo
|
||||||
LUA_OPUNM, // nzLuaOperation_Negation
|
LUA_OPUNM, // nzLuaOperation_Negation
|
||||||
LUA_OPSUB // nzLuaOperation_Substraction
|
LUA_OPSUB // nzLuaOperation_Substraction
|
||||||
};
|
};
|
||||||
|
|
@ -159,6 +166,16 @@ int NzLuaInstance::ArgError(unsigned int argNum, const NzString& error)
|
||||||
return luaL_argerror(m_state, argNum, error.GetConstBuffer());
|
return luaL_argerror(m_state, argNum, error.GetConstBuffer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NzLuaInstance::Call(unsigned int argCount)
|
||||||
|
{
|
||||||
|
return Run(argCount, LUA_MULTRET);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NzLuaInstance::Call(unsigned int argCount, unsigned int resultCount)
|
||||||
|
{
|
||||||
|
return Run(argCount, resultCount);
|
||||||
|
}
|
||||||
|
|
||||||
void NzLuaInstance::CheckAny(int index) const
|
void NzLuaInstance::CheckAny(int index) const
|
||||||
{
|
{
|
||||||
luaL_checkany(m_state, index);
|
luaL_checkany(m_state, index);
|
||||||
|
|
@ -370,7 +387,7 @@ bool NzLuaInstance::Execute(const NzString& code)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Run();
|
return Run(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NzLuaInstance::ExecuteFromFile(const NzString& filePath)
|
bool NzLuaInstance::ExecuteFromFile(const NzString& filePath)
|
||||||
|
|
@ -416,7 +433,7 @@ bool NzLuaInstance::ExecuteFromStream(NzInputStream& stream)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Run();
|
return Run(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int NzLuaInstance::GetAbsIndex(int index) const
|
int NzLuaInstance::GetAbsIndex(int index) const
|
||||||
|
|
@ -813,12 +830,12 @@ NzLuaInstance* NzLuaInstance::GetInstance(lua_State* state)
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NzLuaInstance::Run()
|
bool NzLuaInstance::Run(int argCount, int resultCount)
|
||||||
{
|
{
|
||||||
if (m_level++ == 0)
|
if (m_level++ == 0)
|
||||||
m_clock.Restart();
|
m_clock.Restart();
|
||||||
|
|
||||||
int status = lua_pcall(m_state, 0, 0, 0);
|
int status = lua_pcall(m_state, argCount, resultCount, 0);
|
||||||
|
|
||||||
m_level--;
|
m_level--;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (C) 2015 Jérôme Leclercq
|
// Copyright (C) 2015 Jérôme Leclercq
|
||||||
// This file is part of the "Nazara Engine - Physics module"
|
// This file is part of the "Nazara Engine - Physics module"
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
#if NAZARA_PHYSICS_MANAGE_MEMORY
|
#if NAZARA_PHYSICS_MANAGE_MEMORY
|
||||||
|
|
||||||
#include <Nazara/Core/MemoryManager.hpp>
|
#include <Nazara/Core/MemoryManager.hpp>
|
||||||
#include <new> // Nécessaire ?
|
#include <new> // Nécessaire ?
|
||||||
|
|
||||||
void* operator new(std::size_t size)
|
void* operator new(std::size_t size)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (C) 2015 Jérôme Leclercq
|
// Copyright (C) 2015 Jérôme Leclercq
|
||||||
// This file is part of the "Nazara Engine - Physics module"
|
// This file is part of the "Nazara Engine - Physics module"
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@ struct NzRenderTextureImpl
|
||||||
bool complete = false;
|
bool complete = false;
|
||||||
bool userDefinedTargets = false;
|
bool userDefinedTargets = false;
|
||||||
mutable bool drawBuffersUpdated = true;
|
mutable bool drawBuffersUpdated = true;
|
||||||
|
mutable bool sizeUpdated = false;
|
||||||
mutable bool targetsUpdated = true;
|
mutable bool targetsUpdated = true;
|
||||||
unsigned int height;
|
unsigned int height;
|
||||||
unsigned int width;
|
unsigned int width;
|
||||||
|
|
@ -171,6 +172,7 @@ bool NzRenderTexture::AttachBuffer(nzAttachmentPoint attachmentPoint, nzUInt8 in
|
||||||
attachment.width = buffer->GetWidth();
|
attachment.width = buffer->GetWidth();
|
||||||
|
|
||||||
m_impl->checked = false;
|
m_impl->checked = false;
|
||||||
|
m_impl->sizeUpdated = false;
|
||||||
|
|
||||||
if (attachmentPoint == nzAttachmentPoint_Color && !m_impl->userDefinedTargets)
|
if (attachmentPoint == nzAttachmentPoint_Color && !m_impl->userDefinedTargets)
|
||||||
{
|
{
|
||||||
|
|
@ -316,6 +318,7 @@ bool NzRenderTexture::AttachTexture(nzAttachmentPoint attachmentPoint, nzUInt8 i
|
||||||
attachment.width = texture->GetWidth();
|
attachment.width = texture->GetWidth();
|
||||||
|
|
||||||
m_impl->checked = false;
|
m_impl->checked = false;
|
||||||
|
m_impl->sizeUpdated = false;
|
||||||
|
|
||||||
if (attachmentPoint == nzAttachmentPoint_Color && !m_impl->userDefinedTargets)
|
if (attachmentPoint == nzAttachmentPoint_Color && !m_impl->userDefinedTargets)
|
||||||
{
|
{
|
||||||
|
|
@ -469,8 +472,8 @@ unsigned int NzRenderTexture::GetHeight() const
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!m_impl->targetsUpdated)
|
if (!m_impl->sizeUpdated)
|
||||||
UpdateTargets();
|
UpdateSize();
|
||||||
|
|
||||||
return m_impl->height;
|
return m_impl->height;
|
||||||
}
|
}
|
||||||
|
|
@ -499,8 +502,8 @@ NzVector2ui NzRenderTexture::GetSize() const
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!m_impl->targetsUpdated)
|
if (!m_impl->sizeUpdated)
|
||||||
UpdateTargets();
|
UpdateSize();
|
||||||
|
|
||||||
return NzVector2ui(m_impl->width, m_impl->height);
|
return NzVector2ui(m_impl->width, m_impl->height);
|
||||||
}
|
}
|
||||||
|
|
@ -515,8 +518,8 @@ unsigned int NzRenderTexture::GetWidth() const
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!m_impl->targetsUpdated)
|
if (!m_impl->sizeUpdated)
|
||||||
UpdateTargets();
|
UpdateSize();
|
||||||
|
|
||||||
return m_impl->width;
|
return m_impl->width;
|
||||||
}
|
}
|
||||||
|
|
@ -915,11 +918,21 @@ void NzRenderTexture::UpdateDrawBuffers() const
|
||||||
m_impl->drawBuffersUpdated = true;
|
m_impl->drawBuffersUpdated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NzRenderTexture::UpdateSize() const
|
||||||
|
{
|
||||||
|
m_impl->width = 0;
|
||||||
|
m_impl->height = 0;
|
||||||
|
for (Attachment& attachment : m_impl->attachments)
|
||||||
|
{
|
||||||
|
m_impl->height = std::max(m_impl->height, attachment.height);
|
||||||
|
m_impl->width = std::max(m_impl->width, attachment.width);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_impl->sizeUpdated = true;
|
||||||
|
}
|
||||||
|
|
||||||
void NzRenderTexture::UpdateTargets() const
|
void NzRenderTexture::UpdateTargets() const
|
||||||
{
|
{
|
||||||
m_impl->width = std::numeric_limits<unsigned int>::max();
|
|
||||||
m_impl->height = std::numeric_limits<unsigned int>::max();
|
|
||||||
|
|
||||||
if (m_impl->colorTargets.empty())
|
if (m_impl->colorTargets.empty())
|
||||||
{
|
{
|
||||||
m_impl->drawBuffers.resize(1);
|
m_impl->drawBuffers.resize(1);
|
||||||
|
|
@ -930,13 +943,7 @@ void NzRenderTexture::UpdateTargets() const
|
||||||
m_impl->drawBuffers.resize(m_impl->colorTargets.size());
|
m_impl->drawBuffers.resize(m_impl->colorTargets.size());
|
||||||
GLenum* ptr = &m_impl->drawBuffers[0];
|
GLenum* ptr = &m_impl->drawBuffers[0];
|
||||||
for (nzUInt8 index : m_impl->colorTargets)
|
for (nzUInt8 index : m_impl->colorTargets)
|
||||||
{
|
|
||||||
*ptr++ = GL_COLOR_ATTACHMENT0 + index;
|
*ptr++ = GL_COLOR_ATTACHMENT0 + index;
|
||||||
|
|
||||||
Attachment& attachment = m_impl->attachments[attachmentIndex[nzAttachmentPoint_Color] + index];
|
|
||||||
m_impl->height = std::min(m_impl->height, attachment.height);
|
|
||||||
m_impl->width = std::min(m_impl->width, attachment.width);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_impl->targetsUpdated = true;
|
m_impl->targetsUpdated = true;
|
||||||
|
|
|
||||||
|
|
@ -37,11 +37,50 @@ NzFont* NzSimpleTextDrawer::GetFont() const
|
||||||
return m_font;
|
return m_font;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NzFont* NzSimpleTextDrawer::GetFont(unsigned int index) const
|
||||||
|
{
|
||||||
|
#if NAZARA_UTILITY_SAFE
|
||||||
|
if (index > 0)
|
||||||
|
{
|
||||||
|
NazaraError("Font index out of range (" + NzString::Number(index) + " >= 1)");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return m_font;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int NzSimpleTextDrawer::GetFontCount() const
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const NzAbstractTextDrawer::Glyph& NzSimpleTextDrawer::GetGlyph(unsigned int index) const
|
||||||
|
{
|
||||||
|
if (!m_glyphUpdated)
|
||||||
|
UpdateGlyphs();
|
||||||
|
|
||||||
|
return m_glyphs[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int NzSimpleTextDrawer::GetGlyphCount() const
|
||||||
|
{
|
||||||
|
if (!m_glyphUpdated)
|
||||||
|
UpdateGlyphs();
|
||||||
|
|
||||||
|
return m_glyphs.size();
|
||||||
|
}
|
||||||
|
|
||||||
nzUInt32 NzSimpleTextDrawer::GetStyle() const
|
nzUInt32 NzSimpleTextDrawer::GetStyle() const
|
||||||
{
|
{
|
||||||
return m_style;
|
return m_style;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const NzString& NzSimpleTextDrawer::GetText() const
|
||||||
|
{
|
||||||
|
return m_text;
|
||||||
|
}
|
||||||
|
|
||||||
void NzSimpleTextDrawer::SetCharacterSize(unsigned int characterSize)
|
void NzSimpleTextDrawer::SetCharacterSize(unsigned int characterSize)
|
||||||
{
|
{
|
||||||
m_characterSize = characterSize;
|
m_characterSize = characterSize;
|
||||||
|
|
@ -101,40 +140,6 @@ NzSimpleTextDrawer NzSimpleTextDrawer::Draw(NzFont* font, const NzString& str, u
|
||||||
return drawer;
|
return drawer;
|
||||||
}
|
}
|
||||||
|
|
||||||
NzFont* NzSimpleTextDrawer::GetFont(unsigned int index) const
|
|
||||||
{
|
|
||||||
#if NAZARA_UTILITY_SAFE
|
|
||||||
if (index > 0)
|
|
||||||
{
|
|
||||||
NazaraError("Font index out of range (" + NzString::Number(index) + " >= 1)");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return m_font;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int NzSimpleTextDrawer::GetFontCount() const
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const NzAbstractTextDrawer::Glyph& NzSimpleTextDrawer::GetGlyph(unsigned int index) const
|
|
||||||
{
|
|
||||||
if (!m_glyphUpdated)
|
|
||||||
UpdateGlyphs();
|
|
||||||
|
|
||||||
return m_glyphs[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int NzSimpleTextDrawer::GetGlyphCount() const
|
|
||||||
{
|
|
||||||
if (!m_glyphUpdated)
|
|
||||||
UpdateGlyphs();
|
|
||||||
|
|
||||||
return m_glyphs.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NzSimpleTextDrawer::OnObjectModified(const NzRefCounted* object, int index, unsigned int code)
|
bool NzSimpleTextDrawer::OnObjectModified(const NzRefCounted* object, int index, unsigned int code)
|
||||||
{
|
{
|
||||||
NazaraUnused(object);
|
NazaraUnused(object);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue