Big skeletal animation update

Added MeshInfos demo
Added MD5Mesh/MD5Anim loader support
Added Node class
Fixed ResourceParams not being exported
Added support for skeletal animation
(Animation/Mesh/Joint/SkeletalMesh/Skeleton)
Meshes are now only stored with VertexStruct_XYZ_Normal_UV_Tangent type
Moved Sequence declaration to Sequence.hpp

-Animation:
Renamed Create to Create[Keyframe|Skeletal]

-AxisAlignedBox:
Added Contains method
Added GetCorner method
Added GetCube method
Added Transform method

-Cube/Rect:
Added GetPosition method
Added GetSize method
(Almost) Fixed ExtendTo method
Fixed GetCenter method

-File:
Added GetDirectory static function
Added GetPath method
Renamed GetDirectoryPath method to GetDirectory

-Math module:
Fixed constructor/methods taking a non-const array
GetNormal/Normalize methods now takes an optionnal integer pointer
(returning length)
Made all classes default constructor trivial
Inverse, MakeIdentity, MakeZero, Normalize, Set methods now returns
reference to object

-Matrix4:
Modified methods to avoid copies
Removed COW (Too much overhead)
Removed Concatenate[Affine] static function

-Mesh:
Renamed Create to Create[Keyframe|Skeletal|Static]
Renamed Skin to Material

-MeshParams:
No longer takes declaration argument
Renamed loadAnimations to animated
Storage default to BufferStorage_Hardware if supported and
BufferStorage_Software otherwise

-OpenGL:
Added glGetBooleanv function
Added glIsEnabled function

-Quaternion:
Added ComputeW method
Added Conjugate method

-Renderer:
Added IsEnabled static function
Fixed GetLineWidth function not being static
Removed SetVertexDeclaration

-RenderWindow:
Made CopyTo[Image|Texture] method constant

-Resource
Fixed RemoveResourceListener crash

-ResourceLoader:
Loaders are now used in a LIFO context

-Stream:
Renamed GetLine method to ReadLine

-String:
Fixed Simplified

-Utility module
Added configuration define for strict resource parsing

-VertexBuffer
Now takes a VertexDeclaration pointer

-VertexDeclaration
No longer throw an error when getting a non-existing element


Former-commit-id: f7358c1231d6af48b799d2f24f077a001e16785b
This commit is contained in:
Lynix
2012-11-21 17:23:50 +01:00
parent 84f73f2b6a
commit 70ef422950
99 changed files with 6270 additions and 1983 deletions

View File

@@ -9,6 +9,7 @@
#include <Nazara/Core/Log.hpp>
#include <Nazara/Renderer/Config.hpp>
#include <Nazara/Renderer/Context.hpp>
#include <Nazara/Renderer/DebugDrawer.hpp>
#include <Nazara/Renderer/HardwareBuffer.hpp>
#include <Nazara/Renderer/RenderTarget.hpp>
#include <Nazara/Renderer/Shader.hpp>
@@ -102,6 +103,12 @@ void NzRenderer::DrawIndexedPrimitives(nzPrimitiveType primitive, unsigned int f
NazaraError("No active context");
return;
}
if (primitive > nzPrimitiveType_Max)
{
NazaraError("Primitive type out of enum");
return;
}
#endif
#if NAZARA_RENDERER_SAFE
@@ -156,6 +163,12 @@ void NzRenderer::DrawPrimitives(nzPrimitiveType primitive, unsigned int firstVer
NazaraError("No active context");
return;
}
if (primitive > nzPrimitiveType_Max)
{
NazaraError("Primitive type out of enum");
return;
}
#endif
if (!EnsureStateUpdate())
@@ -175,6 +188,12 @@ void NzRenderer::Enable(nzRendererParameter parameter, bool enable)
NazaraError("No active context");
return;
}
if (parameter > nzRendererParameter_Max)
{
NazaraError("Renderer parameter out of enum");
return;
}
#endif
switch (parameter)
@@ -199,6 +218,14 @@ void NzRenderer::Enable(nzRendererParameter parameter, bool enable)
float NzRenderer::GetLineWidth()
{
#ifdef NAZARA_DEBUG
if (NzContext::GetCurrent() == nullptr)
{
NazaraError("No active context");
return 0.f;
}
#endif
float lineWidth;
glGetFloatv(GL_LINE_WIDTH, &lineWidth);
@@ -240,6 +267,14 @@ NzMatrix4f NzRenderer::GetMatrix(nzMatrixCombination combination)
*/
NzMatrix4f NzRenderer::GetMatrix(nzMatrixType type)
{
#ifdef NAZARA_DEBUG
if (type > nzMatrixType_Max)
{
NazaraError("Matrix type out of enum");
return NzMatrix4f();
}
#endif
return s_matrix[type];
}
@@ -260,6 +295,14 @@ unsigned int NzRenderer::GetMaxTextureUnits()
float NzRenderer::GetPointSize()
{
#ifdef NAZARA_DEBUG
if (NzContext::GetCurrent() == nullptr)
{
NazaraError("No active context");
return 0.f;
}
#endif
float pointSize;
glGetFloatv(GL_POINT_SIZE, &pointSize);
@@ -294,6 +337,14 @@ NzRectui NzRenderer::GetViewport()
bool NzRenderer::HasCapability(nzRendererCap capability)
{
#ifdef NAZARA_DEBUG
if (capability > nzRendererCap_Max)
{
NazaraError("Renderer capability out of enum");
return false;
}
#endif
return s_capabilities[capability];
}
@@ -393,11 +444,55 @@ bool NzRenderer::Initialize()
NzBuffer::SetBufferFunction(nzBufferStorage_Hardware, HardwareBufferFunction);
#ifdef NAZARA_DEBUG
if (!NzDebugDrawer::Initialize())
NazaraWarning("Failed to initialize debug drawer");
#endif
NazaraNotice("Initialized: Renderer module");
return true;
}
bool NzRenderer::IsEnabled(nzRendererParameter parameter)
{
#ifdef NAZARA_DEBUG
if (NzContext::GetCurrent() == nullptr)
{
NazaraError("No active context");
return false;
}
if (parameter > nzRendererParameter_Max)
{
NazaraError("Renderer parameter out of enum");
return false;
}
#endif
switch (parameter)
{
case nzRendererParameter_ColorWrite:
{
GLboolean enabled;
glGetBooleanv(GL_COLOR_WRITEMASK, &enabled);
return enabled;
}
case nzRendererParameter_DepthWrite:
{
GLboolean enabled;
glGetBooleanv(GL_DEPTH_WRITEMASK, &enabled);
return enabled;
}
default:
return glIsEnabled(NzOpenGL::RendererParameter[parameter]);
}
}
bool NzRenderer::IsInitialized()
{
return s_moduleReferenceCouter != 0;
@@ -515,6 +610,14 @@ bool NzRenderer::SetIndexBuffer(const NzIndexBuffer* indexBuffer)
void NzRenderer::SetLineWidth(float width)
{
#ifdef NAZARA_DEBUG
if (NzContext::GetCurrent() == nullptr)
{
NazaraError("No active context");
return;
}
#endif
#if NAZARA_RENDERER_SAFE
if (width <= 0.f)
{
@@ -528,6 +631,14 @@ void NzRenderer::SetLineWidth(float width)
void NzRenderer::SetMatrix(nzMatrixType type, const NzMatrix4f& matrix)
{
#ifdef NAZARA_DEBUG
if (type > nzMatrixType_Max)
{
NazaraError("Matrix type out of enum");
return;
}
#endif
s_matrix[type] = matrix;
// Invalidation des combinaisons
@@ -545,6 +656,14 @@ void NzRenderer::SetMatrix(nzMatrixType type, const NzMatrix4f& matrix)
void NzRenderer::SetPointSize(float size)
{
#ifdef NAZARA_DEBUG
if (NzContext::GetCurrent() == nullptr)
{
NazaraError("No active context");
return;
}
#endif
#if NAZARA_RENDERER_SAFE
if (size <= 0.f)
{
@@ -593,7 +712,7 @@ bool NzRenderer::SetShader(NzShader* shader)
s_matrixLocation[nzMatrixCombination_WorldView] = shader->GetUniformLocation("WorldViewMatrix");
s_matrixLocation[nzMatrixCombination_WorldViewProj] = shader->GetUniformLocation("WorldViewProjMatrix");
///FIXME: Peut VRAIMENT être optimisé
///FIXME: Peut être optimisé
for (unsigned int i = 0; i < totalMatrixCount; ++i)
s_matrixUpdated[i] = false;
}
@@ -605,6 +724,14 @@ bool NzRenderer::SetShader(NzShader* shader)
void NzRenderer::SetStencilCompareFunction(nzRendererComparison compareFunc)
{
#ifdef NAZARA_DEBUG
if (compareFunc > nzRendererComparison_Max)
{
NazaraError("Renderer comparison out of enum");
return;
}
#endif
if (compareFunc != s_stencilCompare)
{
s_stencilCompare = compareFunc;
@@ -614,6 +741,14 @@ void NzRenderer::SetStencilCompareFunction(nzRendererComparison compareFunc)
void NzRenderer::SetStencilFailOperation(nzStencilOperation failOperation)
{
#ifdef NAZARA_DEBUG
if (failOperation > nzStencilOperation_Max)
{
NazaraError("Stencil fail operation out of enum");
return;
}
#endif
if (failOperation != s_stencilFail)
{
s_stencilFail = failOperation;
@@ -632,6 +767,14 @@ void NzRenderer::SetStencilMask(nzUInt32 mask)
void NzRenderer::SetStencilPassOperation(nzStencilOperation passOperation)
{
#ifdef NAZARA_DEBUG
if (passOperation > nzStencilOperation_Max)
{
NazaraError("Stencil pass operation out of enum");
return;
}
#endif
if (passOperation != s_stencilPass)
{
s_stencilPass = passOperation;
@@ -650,6 +793,14 @@ void NzRenderer::SetStencilReferenceValue(unsigned int refValue)
void NzRenderer::SetStencilZFailOperation(nzStencilOperation zfailOperation)
{
#ifdef NAZARA_DEBUG
if (zfailOperation > nzStencilOperation_Max)
{
NazaraError("Stencil zfail operation out of enum");
return;
}
#endif
if (zfailOperation != s_stencilZFail)
{
s_stencilZFail = zfailOperation;
@@ -705,17 +856,11 @@ bool NzRenderer::SetVertexBuffer(const NzVertexBuffer* vertexBuffer)
if (s_vertexBuffer != vertexBuffer)
{
s_vertexBuffer = vertexBuffer;
s_vaoUpdated = false;
}
return true;
}
const NzVertexDeclaration* vertexDeclaration = s_vertexBuffer->GetVertexDeclaration();
if (s_vertexDeclaration != vertexDeclaration)
s_vertexDeclaration = vertexDeclaration;
bool NzRenderer::SetVertexDeclaration(const NzVertexDeclaration* vertexDeclaration)
{
if (s_vertexDeclaration != vertexDeclaration)
{
s_vertexDeclaration = vertexDeclaration;
s_vaoUpdated = false;
}
@@ -758,6 +903,10 @@ void NzRenderer::Uninitialize()
if (--s_moduleReferenceCouter != 0)
return; // Encore utilisé
#ifdef NAZARA_DEBUG
NzDebugDrawer::Uninitialize();
#endif
// Libération du module
NzContext::EnsureContext();
@@ -812,7 +961,8 @@ bool NzRenderer::EnsureStateUpdate()
// Cas spéciaux car il faut recalculer la matrice
if (!s_matrixUpdated[nzMatrixCombination_ViewProj])
{
s_matrix[nzMatrixCombination_ViewProj] = s_matrix[nzMatrixType_View] * s_matrix[nzMatrixType_Projection];
s_matrix[nzMatrixCombination_ViewProj] = s_matrix[nzMatrixType_View];
s_matrix[nzMatrixCombination_ViewProj].Concatenate(s_matrix[nzMatrixType_Projection]);
shaderImpl->SendMatrix(s_matrixLocation[nzMatrixCombination_ViewProj], s_matrix[nzMatrixCombination_ViewProj]);
s_matrixUpdated[nzMatrixCombination_ViewProj] = true;
@@ -820,7 +970,8 @@ bool NzRenderer::EnsureStateUpdate()
if (!s_matrixUpdated[nzMatrixCombination_WorldView])
{
s_matrix[nzMatrixCombination_WorldView] = NzMatrix4f::ConcatenateAffine(s_matrix[nzMatrixType_World], s_matrix[nzMatrixType_View]);
s_matrix[nzMatrixCombination_WorldView] = s_matrix[nzMatrixType_World];
s_matrix[nzMatrixCombination_WorldView].ConcatenateAffine(s_matrix[nzMatrixType_View]);
shaderImpl->SendMatrix(s_matrixLocation[nzMatrixCombination_WorldView], s_matrix[nzMatrixCombination_WorldView]);
s_matrixUpdated[nzMatrixCombination_WorldView] = true;
@@ -828,7 +979,8 @@ bool NzRenderer::EnsureStateUpdate()
if (!s_matrixUpdated[nzMatrixCombination_WorldViewProj])
{
s_matrix[nzMatrixCombination_WorldViewProj] = s_matrix[nzMatrixCombination_WorldView] * s_matrix[nzMatrixType_Projection];
s_matrix[nzMatrixCombination_WorldViewProj] = s_matrix[nzMatrixCombination_WorldView];
s_matrix[nzMatrixCombination_WorldViewProj].Concatenate(s_matrix[nzMatrixType_Projection]);
shaderImpl->SendMatrix(s_matrixLocation[nzMatrixCombination_WorldViewProj], s_matrix[nzMatrixCombination_WorldViewProj]);
s_matrixUpdated[nzMatrixCombination_WorldViewProj] = true;