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
|
||||
{
|
||||
public:
|
||||
enum FreeRectChoiceHeuristic
|
||||
{
|
||||
RectBestAreaFit,
|
||||
RectBestLongSideFit,
|
||||
RectBestShortSideFit,
|
||||
RectWorstAreaFit,
|
||||
RectWorstLongSideFit,
|
||||
RectWorstShortSideFit
|
||||
};
|
||||
|
||||
enum GuillotineSplitHeuristic
|
||||
{
|
||||
SplitLongerAxis,
|
||||
SplitLongerLeftoverAxis,
|
||||
SplitMaximizeArea,
|
||||
SplitMinimizeArea,
|
||||
SplitShorterAxis,
|
||||
SplitShorterLeftoverAxis
|
||||
};
|
||||
enum FreeRectChoiceHeuristic : int;
|
||||
enum GuillotineSplitHeuristic : int;
|
||||
|
||||
NzGuillotineBinPack();
|
||||
NzGuillotineBinPack(unsigned int width, unsigned int height);
|
||||
|
|
@ -70,6 +53,26 @@ class NAZARA_API NzGuillotineBinPack
|
|||
NzGuillotineBinPack& operator=(const 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:
|
||||
void SplitFreeRectAlongAxis(const NzRectui& freeRect, const NzRectui& placedRect, bool splitHorizontal);
|
||||
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 GetZNear() const;
|
||||
|
||||
NzVector2i MapWorldToPixel(const NzVector2f& coords);
|
||||
NzVector2f MapPixelToWorld(const NzVector2i& pixel);
|
||||
NzVector2i MapWorldToPixel(const NzVector2f& coords);
|
||||
|
||||
void SetSize(const NzVector2f& size);
|
||||
void SetSize(float width, float height);
|
||||
|
|
|
|||
|
|
@ -19,8 +19,15 @@ enum nzLuaComparison
|
|||
enum nzLuaOperation
|
||||
{
|
||||
nzLuaOperation_Addition,
|
||||
nzLuaOperation_BitwiseAnd,
|
||||
nzLuaOperation_BitwiseLeftShift,
|
||||
nzLuaOperation_BitwiseNot,
|
||||
nzLuaOperation_BitwiseOr,
|
||||
nzLuaOperation_BitwideRightShift,
|
||||
nzLuaOperation_BitwiseXOr,
|
||||
nzLuaOperation_Division,
|
||||
nzLuaOperation_Exponentiation,
|
||||
nzLuaOperation_FloorDivision,
|
||||
nzLuaOperation_Modulo,
|
||||
nzLuaOperation_Multiplication,
|
||||
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 NzString& error);
|
||||
|
||||
bool Call(unsigned int argCount);
|
||||
bool Call(unsigned int argCount, unsigned int resultCount);
|
||||
|
||||
void CheckAny(int index) const;
|
||||
bool CheckBoolean(int index) const;
|
||||
bool CheckBoolean(int index, bool defValue) const;
|
||||
|
|
@ -146,7 +149,7 @@ class NAZARA_API NzLuaInstance : NzNonCopyable
|
|||
static NzLuaInstance* GetInstance(lua_State* state);
|
||||
|
||||
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 int ProxyFunc(lua_State* state);
|
||||
|
|
|
|||
|
|
@ -748,7 +748,6 @@ NzMatrix4<T>& NzMatrix4<T>::Set(const T matrix[16])
|
|||
template<typename T>
|
||||
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));
|
||||
|
||||
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"
|
||||
// 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"
|
||||
// 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
|
||||
#undef delete
|
||||
#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"
|
||||
// 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:
|
||||
bool OnObjectDestroy(const NzRefCounted* object, int index) override;
|
||||
void UpdateDrawBuffers() const;
|
||||
void UpdateSize() const;
|
||||
void UpdateTargets() const;
|
||||
|
||||
NzRenderTextureImpl* m_impl = nullptr;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,12 @@ class NAZARA_API NzSimpleTextDrawer : public NzAbstractTextDrawer, NzObjectListe
|
|||
unsigned int GetCharacterSize() const;
|
||||
const NzColor& GetColor() 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;
|
||||
const NzString& GetText() const;
|
||||
|
||||
void SetCharacterSize(unsigned int characterSize);
|
||||
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);
|
||||
|
||||
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;
|
||||
void OnObjectReleased(const NzRefCounted* object, int index) override;
|
||||
void UpdateGlyphs() const;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#elif defined(NAZARA_PLATFORM_POSIX)
|
||||
#include <Nazara/Core/Posix/ConditionVariableImpl.hpp>
|
||||
#else
|
||||
#error Thread condition has no implementation
|
||||
#error Condition variable has no implementation
|
||||
#endif
|
||||
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ namespace
|
|||
bool s_initialized = false;
|
||||
const unsigned int s_magic = 0xDEADB33FUL;
|
||||
const char* s_logFileName = "NazaraMemory.log";
|
||||
const char* s_nextFreeFile = "(Internal error)";
|
||||
unsigned int s_nextFreeLine = 0;
|
||||
thread_local const char* s_nextFreeFile = "(Internal error)";
|
||||
thread_local unsigned int s_nextFreeLine = 0;
|
||||
|
||||
Block s_list =
|
||||
{
|
||||
|
|
@ -235,6 +235,7 @@ void NzMemoryManager::Initialize()
|
|||
|
||||
#ifdef NAZARA_PLATFORM_WINDOWS
|
||||
InitializeCriticalSection(&s_mutex);
|
||||
//#elif defined(NAZARA_PLATFORM_POSIX) is already done in the namespace
|
||||
#endif
|
||||
|
||||
s_initialized = true;
|
||||
|
|
@ -250,6 +251,8 @@ void NzMemoryManager::Uninitialize()
|
|||
{
|
||||
#ifdef NAZARA_PLATFORM_WINDOWS
|
||||
DeleteCriticalSection(&s_mutex);
|
||||
#elif defined(NAZARA_PLATFORM_POSIX)
|
||||
pthread_mutex_destroy(&s_mutex);
|
||||
#endif
|
||||
|
||||
FILE* log = std::fopen(s_logFileName, "a");
|
||||
|
|
|
|||
|
|
@ -266,8 +266,8 @@ bool NzParameterList::GetUserdataParameter(const NzString& name, void** value) c
|
|||
}
|
||||
else
|
||||
{
|
||||
NazaraError("Parameter value is not an userdata");
|
||||
return nullptr;
|
||||
NazaraError("Parameter value is not a userdata");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ bool NzConditionVariableImpl::Wait(NzMutexImpl* mutex, nzUInt32 timeout)
|
|||
{
|
||||
// get the current time
|
||||
timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
gettimeofday(&tv, nullptr);
|
||||
|
||||
// construct the time limit (current time + time to wait)
|
||||
timespec ti;
|
||||
|
|
|
|||
|
|
@ -82,14 +82,15 @@ bool NzDirectoryImpl::Exists(const NzString& dirPath)
|
|||
NzString NzDirectoryImpl::GetCurrent()
|
||||
{
|
||||
NzString currentPath;
|
||||
char* path = new char[_PC_PATH_MAX];
|
||||
char* path = getcwd(nullptr, 0);
|
||||
|
||||
if (getcwd(path, _PC_PATH_MAX))
|
||||
if (path)
|
||||
{
|
||||
currentPath = path;
|
||||
free(path);
|
||||
}
|
||||
else
|
||||
NazaraError("Unable to get current directory: " + NzError::GetLastSystemError());
|
||||
|
||||
delete[] path;
|
||||
NazaraError("Unable to get current directory: " + NzError::GetLastSystemError()); // Bug: initialisation -> if no path for log !
|
||||
|
||||
return currentPath;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,11 @@
|
|||
|
||||
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()
|
||||
|
|
|
|||
|
|
@ -57,9 +57,9 @@ void NzThreadImpl::Sleep(nzUInt32 time)
|
|||
|
||||
// create a mutex and thread condition
|
||||
pthread_mutex_t mutex;
|
||||
pthread_mutex_init(&mutex, 0);
|
||||
pthread_mutex_init(&mutex, nullptr);
|
||||
pthread_cond_t condition;
|
||||
pthread_cond_init(&condition, 0);
|
||||
pthread_cond_init(&condition, nullptr);
|
||||
|
||||
// wait...
|
||||
pthread_mutex_lock(&mutex);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
bool NzTaskSchedulerImpl::Initialize(unsigned int workerCount)
|
||||
{
|
||||
if (s_workerCount > 0)
|
||||
if (IsInitialized())
|
||||
return true; // Déjà initialisé
|
||||
|
||||
#if NAZARA_CORE_SAFE
|
||||
|
|
|
|||
|
|
@ -171,6 +171,10 @@ void NzCamera::SetTarget(const NzRenderTarget* renderTarget)
|
|||
m_target = renderTarget;
|
||||
if (m_target)
|
||||
m_target->AddListener(this);
|
||||
|
||||
m_frustumUpdated = false;
|
||||
m_projectionMatrixUpdated = false;
|
||||
m_viewportUpdated = false;
|
||||
}
|
||||
|
||||
void NzCamera::SetTarget(const NzRenderTarget& renderTarget)
|
||||
|
|
|
|||
|
|
@ -127,8 +127,8 @@ bool NzDeferredPhongLightingPass::Process(const NzScene* scene, unsigned int fir
|
|||
NzRenderer::SetRenderStates(lightStates);
|
||||
|
||||
NzRenderer::SetShader(m_pointSpotLightShader);
|
||||
m_pointSpotLightShader->SendColor(m_pointSpotLightShaderEyePositionLocation, scene->GetAmbientColor());
|
||||
m_pointSpotLightShader->SendVector(m_pointSpotLightShaderSceneAmbientLocation, scene->GetViewer()->GetEyePosition());
|
||||
m_pointSpotLightShader->SendColor(m_pointSpotLightShaderSceneAmbientLocation, scene->GetAmbientColor());
|
||||
m_pointSpotLightShader->SendVector(m_pointSpotLightShaderEyePositionLocation, scene->GetViewer()->GetEyePosition());
|
||||
|
||||
NzMatrix4f lightMatrix;
|
||||
lightMatrix.MakeIdentity();
|
||||
|
|
|
|||
|
|
@ -658,9 +658,12 @@ void NzForwardRenderTechnique::DrawTransparentModels(const NzScene* scene) const
|
|||
shader->SendVector(shaderUniforms->eyePosition, viewer->GetEyePosition());
|
||||
|
||||
// On envoie les lumières directionnelles s'il y a (Les mêmes pour tous)
|
||||
lightCount = std::min(m_directionalLights.GetLightCount(), NazaraSuffixMacro(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS, U));
|
||||
for (unsigned int i = 0; i < lightCount; ++i)
|
||||
m_directionalLights.GetLight(i)->Enable(shader, shaderUniforms->lightUniforms, shaderUniforms->lightOffset*i);
|
||||
if (shaderUniforms->hasLightUniforms)
|
||||
{
|
||||
lightCount = std::min(m_directionalLights.GetLightCount(), NazaraSuffixMacro(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS, U));
|
||||
for (unsigned int i = 0; i < lightCount; ++i)
|
||||
m_directionalLights.GetLight(i)->Enable(shader, shaderUniforms->lightUniforms, shaderUniforms->lightOffset*i);
|
||||
}
|
||||
|
||||
lastShader = shader;
|
||||
}
|
||||
|
|
@ -690,21 +693,24 @@ void NzForwardRenderTechnique::DrawTransparentModels(const NzScene* scene) const
|
|||
NzRenderer::SetIndexBuffer(indexBuffer);
|
||||
NzRenderer::SetVertexBuffer(vertexBuffer);
|
||||
|
||||
// Calcul des lumières les plus proches
|
||||
if (lightCount < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS && !m_lights.IsEmpty())
|
||||
if (shaderUniforms->hasLightUniforms)
|
||||
{
|
||||
NzVector3f position = matrix.GetTranslation() + modelData.squaredBoundingSphere.GetPosition();
|
||||
float radius = modelData.squaredBoundingSphere.radius;
|
||||
unsigned int closestLightCount = m_lights.ComputeClosestLights(position, radius, NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS);
|
||||
// Calcul des lumières les plus proches
|
||||
if (lightCount < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS && !m_lights.IsEmpty())
|
||||
{
|
||||
NzVector3f position = matrix.GetTranslation() + modelData.squaredBoundingSphere.GetPosition();
|
||||
float radius = modelData.squaredBoundingSphere.radius;
|
||||
unsigned int closestLightCount = m_lights.ComputeClosestLights(position, radius, NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS);
|
||||
|
||||
unsigned int count = std::min(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS - lightCount, closestLightCount);
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
m_lights.GetResult(i)->Enable(shader, shaderUniforms->lightUniforms, shaderUniforms->lightOffset*(lightCount++));
|
||||
unsigned int count = std::min(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS - lightCount, closestLightCount);
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
m_lights.GetResult(i)->Enable(shader, shaderUniforms->lightUniforms, shaderUniforms->lightOffset*(lightCount++));
|
||||
}
|
||||
|
||||
for (unsigned int i = lightCount; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i)
|
||||
NzLight::Disable(shader, shaderUniforms->lightUniforms, shaderUniforms->lightOffset*i);
|
||||
}
|
||||
|
||||
for (unsigned int i = lightCount; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i)
|
||||
NzLight::Disable(shader, shaderUniforms->lightUniforms, shaderUniforms->lightOffset*i);
|
||||
|
||||
NzRenderer::SetMatrix(nzMatrixType_World, matrix);
|
||||
drawFunc(meshData.primitiveMode, 0, indexCount);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,6 +170,24 @@ float NzView::GetZNear() const
|
|||
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)
|
||||
{
|
||||
if (!m_viewProjMatrixUpdated)
|
||||
|
|
@ -190,24 +208,6 @@ NzVector2i NzView::MapWorldToPixel(const NzVector2f& coords)
|
|||
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)
|
||||
{
|
||||
SetSize(size.x, size.y);
|
||||
|
|
|
|||
|
|
@ -95,13 +95,20 @@ namespace
|
|||
static_assert(sizeof(s_comparisons)/sizeof(int) == nzLuaComparison_Max+1, "Lua comparison array is incomplete");
|
||||
|
||||
int s_operations[] = {
|
||||
LUA_OPADD, // nzLuaOperation_Addition
|
||||
LUA_OPDIV, // nzLuaOperation_Division
|
||||
LUA_OPPOW, // nzLuaOperation_Exponentiation
|
||||
LUA_OPMOD, // nzLuaOperation_Modulo
|
||||
LUA_OPMUL, // nzLuaOperation_Multiplication
|
||||
LUA_OPUNM, // nzLuaOperation_Negation
|
||||
LUA_OPSUB // nzLuaOperation_Substraction
|
||||
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_OPPOW, // nzLuaOperation_Exponentiation
|
||||
LUA_OPIDIV, // nzLuaOperation_FloorDivision
|
||||
LUA_OPMUL, // nzLuaOperation_Multiplication
|
||||
LUA_OPMOD, // nzLuaOperation_Modulo
|
||||
LUA_OPUNM, // nzLuaOperation_Negation
|
||||
LUA_OPSUB // nzLuaOperation_Substraction
|
||||
};
|
||||
|
||||
static_assert(sizeof(s_operations)/sizeof(int) == nzLuaOperation_Max+1, "Lua operation array is incomplete");
|
||||
|
|
@ -159,6 +166,16 @@ int NzLuaInstance::ArgError(unsigned int argNum, const NzString& error)
|
|||
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
|
||||
{
|
||||
luaL_checkany(m_state, index);
|
||||
|
|
@ -370,7 +387,7 @@ bool NzLuaInstance::Execute(const NzString& code)
|
|||
return false;
|
||||
}
|
||||
|
||||
return Run();
|
||||
return Run(0, 0);
|
||||
}
|
||||
|
||||
bool NzLuaInstance::ExecuteFromFile(const NzString& filePath)
|
||||
|
|
@ -416,7 +433,7 @@ bool NzLuaInstance::ExecuteFromStream(NzInputStream& stream)
|
|||
return false;
|
||||
}
|
||||
|
||||
return Run();
|
||||
return Run(0, 0);
|
||||
}
|
||||
|
||||
int NzLuaInstance::GetAbsIndex(int index) const
|
||||
|
|
@ -813,12 +830,12 @@ NzLuaInstance* NzLuaInstance::GetInstance(lua_State* state)
|
|||
return instance;
|
||||
}
|
||||
|
||||
bool NzLuaInstance::Run()
|
||||
bool NzLuaInstance::Run(int argCount, int resultCount)
|
||||
{
|
||||
if (m_level++ == 0)
|
||||
m_clock.Restart();
|
||||
|
||||
int status = lua_pcall(m_state, 0, 0, 0);
|
||||
int status = lua_pcall(m_state, argCount, resultCount, 0);
|
||||
|
||||
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"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
#if NAZARA_PHYSICS_MANAGE_MEMORY
|
||||
|
||||
#include <Nazara/Core/MemoryManager.hpp>
|
||||
#include <new> // Nécessaire ?
|
||||
#include <new> // Nécessaire ?
|
||||
|
||||
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"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ struct NzRenderTextureImpl
|
|||
bool complete = false;
|
||||
bool userDefinedTargets = false;
|
||||
mutable bool drawBuffersUpdated = true;
|
||||
mutable bool sizeUpdated = false;
|
||||
mutable bool targetsUpdated = true;
|
||||
unsigned int height;
|
||||
unsigned int width;
|
||||
|
|
@ -171,6 +172,7 @@ bool NzRenderTexture::AttachBuffer(nzAttachmentPoint attachmentPoint, nzUInt8 in
|
|||
attachment.width = buffer->GetWidth();
|
||||
|
||||
m_impl->checked = false;
|
||||
m_impl->sizeUpdated = false;
|
||||
|
||||
if (attachmentPoint == nzAttachmentPoint_Color && !m_impl->userDefinedTargets)
|
||||
{
|
||||
|
|
@ -316,6 +318,7 @@ bool NzRenderTexture::AttachTexture(nzAttachmentPoint attachmentPoint, nzUInt8 i
|
|||
attachment.width = texture->GetWidth();
|
||||
|
||||
m_impl->checked = false;
|
||||
m_impl->sizeUpdated = false;
|
||||
|
||||
if (attachmentPoint == nzAttachmentPoint_Color && !m_impl->userDefinedTargets)
|
||||
{
|
||||
|
|
@ -469,8 +472,8 @@ unsigned int NzRenderTexture::GetHeight() const
|
|||
}
|
||||
#endif
|
||||
|
||||
if (!m_impl->targetsUpdated)
|
||||
UpdateTargets();
|
||||
if (!m_impl->sizeUpdated)
|
||||
UpdateSize();
|
||||
|
||||
return m_impl->height;
|
||||
}
|
||||
|
|
@ -499,8 +502,8 @@ NzVector2ui NzRenderTexture::GetSize() const
|
|||
}
|
||||
#endif
|
||||
|
||||
if (!m_impl->targetsUpdated)
|
||||
UpdateTargets();
|
||||
if (!m_impl->sizeUpdated)
|
||||
UpdateSize();
|
||||
|
||||
return NzVector2ui(m_impl->width, m_impl->height);
|
||||
}
|
||||
|
|
@ -515,8 +518,8 @@ unsigned int NzRenderTexture::GetWidth() const
|
|||
}
|
||||
#endif
|
||||
|
||||
if (!m_impl->targetsUpdated)
|
||||
UpdateTargets();
|
||||
if (!m_impl->sizeUpdated)
|
||||
UpdateSize();
|
||||
|
||||
return m_impl->width;
|
||||
}
|
||||
|
|
@ -915,11 +918,21 @@ void NzRenderTexture::UpdateDrawBuffers() const
|
|||
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
|
||||
{
|
||||
m_impl->width = std::numeric_limits<unsigned int>::max();
|
||||
m_impl->height = std::numeric_limits<unsigned int>::max();
|
||||
|
||||
if (m_impl->colorTargets.empty())
|
||||
{
|
||||
m_impl->drawBuffers.resize(1);
|
||||
|
|
@ -930,13 +943,7 @@ void NzRenderTexture::UpdateTargets() const
|
|||
m_impl->drawBuffers.resize(m_impl->colorTargets.size());
|
||||
GLenum* ptr = &m_impl->drawBuffers[0];
|
||||
for (nzUInt8 index : m_impl->colorTargets)
|
||||
{
|
||||
*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;
|
||||
|
|
|
|||
|
|
@ -37,11 +37,50 @@ NzFont* NzSimpleTextDrawer::GetFont() const
|
|||
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
|
||||
{
|
||||
return m_style;
|
||||
}
|
||||
|
||||
const NzString& NzSimpleTextDrawer::GetText() const
|
||||
{
|
||||
return m_text;
|
||||
}
|
||||
|
||||
void NzSimpleTextDrawer::SetCharacterSize(unsigned int characterSize)
|
||||
{
|
||||
m_characterSize = characterSize;
|
||||
|
|
@ -101,40 +140,6 @@ NzSimpleTextDrawer NzSimpleTextDrawer::Draw(NzFont* font, const NzString& str, u
|
|||
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)
|
||||
{
|
||||
NazaraUnused(object);
|
||||
|
|
|
|||
Loading…
Reference in New Issue