Merge branch 'master' of https://github.com/DigitalPulseSoftware/NazaraEngine
This commit is contained in:
commit
8a1d61c3ea
|
|
@ -86,6 +86,11 @@ Nazara Engine:
|
|||
- Fixed Billboard bounding volume
|
||||
- Fixed Directory::GetResultSize and Directory::IsResultDirectory on Posix systems
|
||||
- Fixed Quaternion::Inverse which was not correctly normalizing quaternions
|
||||
- Graphics module now register "White2D" and "WhiteCubemap" textures to the TextureLibrary (respectively a 1x1 texture 2D and a 1x1 texture cubemap)
|
||||
- Added AbstractTextDrawer::GetLineGlyphCount, which returns the number of glyph part of the line
|
||||
- Fixed Font handling of whitespace glyphs (which were triggering an error)
|
||||
- ⚠️ Translucent2D pipeline no longer has depth sorting
|
||||
- Fixed SimpleTextDrawer line bounds
|
||||
|
||||
Nazara Development Kit:
|
||||
- Added ImageWidget (#139)
|
||||
|
|
@ -129,6 +134,9 @@ Nazara Development Kit:
|
|||
- Fix GraphicsComponent bounding volume not taking local matrix in account
|
||||
- ⚠️ Rewrote all render queue system, which should be more efficient, take scissor box into account
|
||||
- ⚠️ All widgets are now bound to a scissor box when rendering
|
||||
- Add DebugComponent (a component able to show aabb/obb/collision mesh)
|
||||
- ⚠️ TextAreaWidget now support text selection (WIP)
|
||||
- ⚠️ TextAreaWidget::GetHoveredGlyph now returns a two-dimensional position instead of a single glyph position
|
||||
|
||||
# 0.4:
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
#include <NDK/Components/CameraComponent.hpp>
|
||||
#include <NDK/Components/CollisionComponent2D.hpp>
|
||||
#include <NDK/Components/CollisionComponent3D.hpp>
|
||||
#include <NDK/Components/ConstraintComponent2D.hpp>
|
||||
#include <NDK/Components/DebugComponent.hpp>
|
||||
#include <NDK/Components/GraphicsComponent.hpp>
|
||||
#include <NDK/Components/LightComponent.hpp>
|
||||
#include <NDK/Components/ListenerComponent.hpp>
|
||||
|
|
@ -17,6 +19,5 @@
|
|||
#include <NDK/Components/PhysicsComponent2D.hpp>
|
||||
#include <NDK/Components/PhysicsComponent3D.hpp>
|
||||
#include <NDK/Components/VelocityComponent.hpp>
|
||||
#include <NDK/Components/ConstraintComponent2D.hpp>
|
||||
|
||||
#endif // NDK_COMPONENTS_GLOBAL_HPP
|
||||
|
|
|
|||
|
|
@ -0,0 +1,80 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
#ifndef NDK_COMPONENTS_DEBUGCOMPONENT_HPP
|
||||
#define NDK_COMPONENTS_DEBUGCOMPONENT_HPP
|
||||
|
||||
#include <Nazara/Core/Flags.hpp>
|
||||
#include <Nazara/Graphics/InstancedRenderable.hpp>
|
||||
#include <NDK/Component.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
enum class DebugDraw
|
||||
{
|
||||
//TODO: Collider2D
|
||||
Collider3D,
|
||||
GraphicsAABB,
|
||||
GraphicsOBB,
|
||||
|
||||
Max = GraphicsOBB
|
||||
};
|
||||
}
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
template<>
|
||||
struct EnumAsFlags<Ndk::DebugDraw>
|
||||
{
|
||||
static constexpr Ndk::DebugDraw max = Ndk::DebugDraw::GraphicsOBB;
|
||||
};
|
||||
}
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
using DebugDrawFlags = Nz::Flags<DebugDraw>;
|
||||
|
||||
constexpr DebugDrawFlags DebugDraw_None = 0;
|
||||
|
||||
class NDK_API DebugComponent : public Component<DebugComponent>
|
||||
{
|
||||
friend class DebugSystem;
|
||||
|
||||
public:
|
||||
inline DebugComponent(DebugDrawFlags flags = DebugDraw_None);
|
||||
inline DebugComponent(const DebugComponent& debug);
|
||||
~DebugComponent() = default;
|
||||
|
||||
inline void Disable(DebugDrawFlags flags);
|
||||
inline void Enable(DebugDrawFlags flags);
|
||||
|
||||
inline DebugDrawFlags GetFlags() const;
|
||||
|
||||
inline bool IsEnabled(DebugDrawFlags flags) const;
|
||||
|
||||
inline DebugComponent& operator=(const DebugComponent& debug);
|
||||
|
||||
static ComponentIndex componentIndex;
|
||||
|
||||
private:
|
||||
inline const Nz::InstancedRenderableRef& GetDebugRenderable(DebugDraw option) const;
|
||||
inline DebugDrawFlags GetEnabledFlags() const;
|
||||
inline void UpdateDebugRenderable(DebugDraw option, Nz::InstancedRenderableRef renderable);
|
||||
inline void UpdateEnabledFlags(DebugDrawFlags flags);
|
||||
|
||||
static constexpr std::size_t DebugModeCount = static_cast<std::size_t>(DebugDraw::Max) + 1;
|
||||
|
||||
std::array<Nz::InstancedRenderableRef, DebugModeCount> m_debugRenderables;
|
||||
DebugDrawFlags m_enabledFlags;
|
||||
DebugDrawFlags m_flags;
|
||||
};
|
||||
}
|
||||
|
||||
#include <NDK/Components/DebugComponent.inl>
|
||||
|
||||
#endif // NDK_COMPONENTS_DEBUGCOMPONENT_HPP
|
||||
#endif // NDK_SERVER
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
#include <NDK/Components/DebugComponent.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
inline DebugComponent::DebugComponent(DebugDrawFlags flags) :
|
||||
m_flags(flags)
|
||||
{
|
||||
}
|
||||
|
||||
inline DebugComponent::DebugComponent(const DebugComponent& debug) :
|
||||
m_flags(debug.m_flags)
|
||||
{
|
||||
}
|
||||
|
||||
inline void DebugComponent::Disable(DebugDrawFlags flags)
|
||||
{
|
||||
m_flags &= ~flags;
|
||||
|
||||
if (m_entity)
|
||||
m_entity->Invalidate();
|
||||
}
|
||||
|
||||
inline void DebugComponent::Enable(DebugDrawFlags flags)
|
||||
{
|
||||
m_flags |= flags;
|
||||
|
||||
if (m_entity)
|
||||
m_entity->Invalidate();
|
||||
}
|
||||
|
||||
inline DebugDrawFlags DebugComponent::GetFlags() const
|
||||
{
|
||||
return m_flags;
|
||||
}
|
||||
|
||||
inline bool DebugComponent::IsEnabled(DebugDrawFlags flags) const
|
||||
{
|
||||
return (m_flags & flags) == flags;
|
||||
}
|
||||
|
||||
inline DebugComponent& DebugComponent::operator=(const DebugComponent& debug)
|
||||
{
|
||||
m_flags = debug.m_flags;
|
||||
|
||||
if (m_entity)
|
||||
m_entity->Invalidate();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Nz::InstancedRenderableRef& DebugComponent::GetDebugRenderable(DebugDraw option) const
|
||||
{
|
||||
return m_debugRenderables[static_cast<std::size_t>(option)];
|
||||
}
|
||||
|
||||
inline DebugDrawFlags DebugComponent::GetEnabledFlags() const
|
||||
{
|
||||
return m_enabledFlags;
|
||||
}
|
||||
|
||||
inline void DebugComponent::UpdateDebugRenderable(DebugDraw option, Nz::InstancedRenderableRef renderable)
|
||||
{
|
||||
m_debugRenderables[static_cast<std::size_t>(option)] = std::move(renderable);
|
||||
}
|
||||
|
||||
inline void DebugComponent::UpdateEnabledFlags(DebugDrawFlags flags)
|
||||
{
|
||||
m_enabledFlags = flags;
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@
|
|||
#ifndef NDK_SYSTEMS_GLOBAL_HPP
|
||||
#define NDK_SYSTEMS_GLOBAL_HPP
|
||||
|
||||
#include <NDK/Systems/DebugSystem.hpp>
|
||||
#include <NDK/Systems/ListenerSystem.hpp>
|
||||
#include <NDK/Systems/ParticleSystem.hpp>
|
||||
#include <NDK/Systems/PhysicsSystem2D.hpp>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
#ifndef NDK_SYSTEMS_DEBUGSYSTEM_HPP
|
||||
#define NDK_SYSTEMS_DEBUGSYSTEM_HPP
|
||||
|
||||
#include <Nazara/Graphics/InstancedRenderable.hpp>
|
||||
#include <Nazara/Utility/IndexBuffer.hpp>
|
||||
#include <Nazara/Utility/Mesh.hpp>
|
||||
#include <Nazara/Utility/VertexBuffer.hpp>
|
||||
#include <NDK/System.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API DebugSystem : public System<DebugSystem>
|
||||
{
|
||||
public:
|
||||
DebugSystem();
|
||||
~DebugSystem() = default;
|
||||
|
||||
static SystemIndex systemIndex;
|
||||
|
||||
private:
|
||||
Nz::InstancedRenderableRef GenerateBox(Nz::Boxf box);
|
||||
Nz::InstancedRenderableRef GenerateCollision3DMesh(Entity* entity);
|
||||
|
||||
Nz::MaterialRef GetAABBMaterial();
|
||||
Nz::MaterialRef GetCollisionMaterial();
|
||||
Nz::MaterialRef GetOBBMaterial();
|
||||
std::pair<Nz::IndexBufferRef, Nz::VertexBufferRef> GetBoxMesh();
|
||||
|
||||
void OnEntityValidation(Entity* entity, bool justAdded) override;
|
||||
|
||||
void OnUpdate(float elapsedTime) override;
|
||||
|
||||
Nz::MaterialRef m_aabbMaterial;
|
||||
Nz::MaterialRef m_collisionMaterial;
|
||||
Nz::MaterialRef m_obbMaterial;
|
||||
Nz::IndexBufferRef m_boxMeshIndexBuffer;
|
||||
Nz::VertexBufferRef m_boxMeshVertexBuffer;
|
||||
};
|
||||
}
|
||||
|
||||
#include <NDK/Systems/DebugSystem.inl>
|
||||
|
||||
#endif // NDK_SYSTEMS_DEBUGSYSTEM_HPP
|
||||
#endif // NDK_SERVER
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
#include <NDK/Systems/DebugSystem.hpp>
|
||||
|
||||
|
|
@ -11,6 +11,7 @@
|
|||
#include <Nazara/Utility/SimpleTextDrawer.hpp>
|
||||
#include <NDK/BaseWidget.hpp>
|
||||
#include <NDK/Widgets/Enums.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
|
|
@ -30,15 +31,20 @@ namespace Ndk
|
|||
|
||||
inline void EnableMultiline(bool enable = true);
|
||||
|
||||
void EraseSelection();
|
||||
|
||||
inline unsigned int GetCharacterSize() const;
|
||||
inline const Nz::Vector2ui& GetCursorPosition() const;
|
||||
inline Nz::Vector2ui GetCursorPosition(std::size_t glyphIndex) const;
|
||||
inline const Nz::String& GetDisplayText() const;
|
||||
inline EchoMode GetEchoMode() const;
|
||||
inline std::size_t GetGlyphIndex(const Nz::Vector2ui& cursorPosition);
|
||||
inline const Nz::String& GetText() const;
|
||||
inline const Nz::Color& GetTextColor() const;
|
||||
|
||||
std::size_t GetHoveredGlyph(float x, float y) const;
|
||||
Nz::Vector2ui GetHoveredGlyph(float x, float y) const;
|
||||
|
||||
inline bool HasSelection() const;
|
||||
|
||||
inline bool IsMultilineEnabled() const;
|
||||
inline bool IsReadOnly() const;
|
||||
|
|
@ -53,6 +59,7 @@ namespace Ndk
|
|||
inline void SetCursorPosition(Nz::Vector2ui cursorPosition);
|
||||
inline void SetEchoMode(EchoMode echoMode);
|
||||
inline void SetReadOnly(bool readOnly = true);
|
||||
inline void SetSelection(Nz::Vector2ui fromPosition, Nz::Vector2ui toPosition);
|
||||
inline void SetText(const Nz::String& text);
|
||||
inline void SetTextColor(const Nz::Color& text);
|
||||
|
||||
|
|
@ -64,6 +71,8 @@ namespace Ndk
|
|||
NazaraSignal(OnTextAreaCursorMove, const TextAreaWidget* /*textArea*/, std::size_t* /*newCursorPosition*/);
|
||||
NazaraSignal(OnTextAreaKeyBackspace, const TextAreaWidget* /*textArea*/, bool* /*ignoreDefaultAction*/);
|
||||
NazaraSignal(OnTextAreaKeyDown, const TextAreaWidget* /*textArea*/, bool* /*ignoreDefaultAction*/);
|
||||
NazaraSignal(OnTextAreaKeyEnd, const TextAreaWidget* /*textArea*/, bool* /*ignoreDefaultAction*/);
|
||||
NazaraSignal(OnTextAreaKeyHome, const TextAreaWidget* /*textArea*/, bool* /*ignoreDefaultAction*/);
|
||||
NazaraSignal(OnTextAreaKeyLeft, const TextAreaWidget* /*textArea*/, bool* /*ignoreDefaultAction*/);
|
||||
NazaraSignal(OnTextAreaKeyReturn, const TextAreaWidget* /*textArea*/, bool* /*ignoreDefaultAction*/);
|
||||
NazaraSignal(OnTextAreaKeyRight, const TextAreaWidget* /*textArea*/, bool* /*ignoreDefaultAction*/);
|
||||
|
|
@ -79,6 +88,9 @@ namespace Ndk
|
|||
bool OnKeyPressed(const Nz::WindowEvent::KeyEvent& key) override;
|
||||
void OnKeyReleased(const Nz::WindowEvent::KeyEvent& key) override;
|
||||
void OnMouseButtonPress(int /*x*/, int /*y*/, Nz::Mouse::Button button) override;
|
||||
void OnMouseButtonRelease(int /*x*/, int /*y*/, Nz::Mouse::Button button) override;
|
||||
void OnMouseEnter() override;
|
||||
void OnMouseMoved(int x, int y, int deltaX, int deltaY) override;
|
||||
void OnTextEntered(char32_t character, bool repeated) override;
|
||||
|
||||
void RefreshCursor();
|
||||
|
|
@ -88,10 +100,13 @@ namespace Ndk
|
|||
EntityHandle m_cursorEntity;
|
||||
EntityHandle m_textEntity;
|
||||
Nz::SimpleTextDrawer m_drawer;
|
||||
Nz::SpriteRef m_cursorSprite;
|
||||
Nz::String m_text;
|
||||
Nz::TextSpriteRef m_textSprite;
|
||||
Nz::Vector2ui m_cursorPosition;
|
||||
Nz::Vector2ui m_cursorPositionBegin;
|
||||
Nz::Vector2ui m_cursorPositionEnd;
|
||||
Nz::Vector2ui m_selectionCursor;
|
||||
std::vector<Nz::SpriteRef> m_cursorSprites;
|
||||
bool m_isMouseButtonDown;
|
||||
bool m_multiLineEnabled;
|
||||
bool m_readOnly;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ namespace Ndk
|
|||
{
|
||||
inline void TextAreaWidget::Clear()
|
||||
{
|
||||
m_cursorPosition.MakeZero();
|
||||
m_cursorPositionBegin.MakeZero();
|
||||
m_cursorPositionEnd.MakeZero();
|
||||
m_drawer.Clear();
|
||||
m_text.Clear();
|
||||
m_textSprite->Update(m_drawer);
|
||||
|
|
@ -29,7 +30,30 @@ namespace Ndk
|
|||
|
||||
inline const Nz::Vector2ui& TextAreaWidget::GetCursorPosition() const
|
||||
{
|
||||
return m_cursorPosition;
|
||||
return m_cursorPositionBegin;
|
||||
}
|
||||
|
||||
Nz::Vector2ui TextAreaWidget::GetCursorPosition(std::size_t glyphIndex) const
|
||||
{
|
||||
glyphIndex = std::min(glyphIndex, m_drawer.GetGlyphCount());
|
||||
|
||||
std::size_t lineCount = m_drawer.GetLineCount();
|
||||
std::size_t line = 0U;
|
||||
for (std::size_t i = line + 1; i < lineCount; ++i)
|
||||
{
|
||||
if (m_drawer.GetLine(i).glyphIndex > glyphIndex)
|
||||
break;
|
||||
|
||||
line = i;
|
||||
}
|
||||
|
||||
const auto& lineInfo = m_drawer.GetLine(line);
|
||||
|
||||
Nz::Vector2ui cursorPos;
|
||||
cursorPos.y = static_cast<unsigned int>(line);
|
||||
cursorPos.x = static_cast<unsigned int>(glyphIndex - lineInfo.glyphIndex);
|
||||
|
||||
return cursorPos;
|
||||
}
|
||||
|
||||
inline const Nz::String& TextAreaWidget::GetDisplayText() const
|
||||
|
|
@ -63,7 +87,12 @@ namespace Ndk
|
|||
return m_drawer.GetColor();
|
||||
}
|
||||
|
||||
inline bool Ndk::TextAreaWidget::IsMultilineEnabled() const
|
||||
inline bool TextAreaWidget::HasSelection() const
|
||||
{
|
||||
return m_cursorPositionBegin != m_cursorPositionEnd;
|
||||
}
|
||||
|
||||
inline bool TextAreaWidget::IsMultilineEnabled() const
|
||||
{
|
||||
return m_multiLineEnabled;
|
||||
}
|
||||
|
|
@ -75,7 +104,7 @@ namespace Ndk
|
|||
|
||||
inline void TextAreaWidget::MoveCursor(int offset)
|
||||
{
|
||||
std::size_t cursorGlyph = GetGlyphIndex(m_cursorPosition);
|
||||
std::size_t cursorGlyph = GetGlyphIndex(m_cursorPositionBegin);
|
||||
if (offset >= 0)
|
||||
SetCursorPosition(cursorGlyph + static_cast<std::size_t>(offset));
|
||||
else
|
||||
|
|
@ -104,7 +133,7 @@ namespace Ndk
|
|||
}
|
||||
};
|
||||
|
||||
Nz::Vector2ui cursorPosition = m_cursorPosition;
|
||||
Nz::Vector2ui cursorPosition = m_cursorPositionBegin;
|
||||
cursorPosition.x = ClampOffset(static_cast<unsigned int>(cursorPosition.x), offset.x);
|
||||
cursorPosition.y = ClampOffset(static_cast<unsigned int>(cursorPosition.y), offset.y);
|
||||
|
||||
|
|
@ -120,22 +149,8 @@ namespace Ndk
|
|||
{
|
||||
OnTextAreaCursorMove(this, &glyphIndex);
|
||||
|
||||
glyphIndex = std::min(glyphIndex, m_drawer.GetGlyphCount());
|
||||
|
||||
std::size_t lineCount = m_drawer.GetLineCount();
|
||||
std::size_t line = 0U;
|
||||
for (std::size_t i = line + 1; i < lineCount; ++i)
|
||||
{
|
||||
if (m_drawer.GetLine(i).glyphIndex > glyphIndex)
|
||||
break;
|
||||
|
||||
line = i;
|
||||
}
|
||||
|
||||
const auto& lineInfo = m_drawer.GetLine(line);
|
||||
|
||||
m_cursorPosition.y = static_cast<unsigned int>(line);
|
||||
m_cursorPosition.x = static_cast<unsigned int>(glyphIndex - lineInfo.glyphIndex);
|
||||
m_cursorPositionBegin = GetCursorPosition(glyphIndex);
|
||||
m_cursorPositionEnd = m_cursorPositionBegin;
|
||||
|
||||
RefreshCursor();
|
||||
}
|
||||
|
|
@ -146,7 +161,7 @@ namespace Ndk
|
|||
if (cursorPosition.y >= lineCount)
|
||||
cursorPosition.y = static_cast<unsigned int>(lineCount - 1);
|
||||
|
||||
m_cursorPosition = cursorPosition;
|
||||
m_cursorPositionBegin = cursorPosition;
|
||||
|
||||
const auto& lineInfo = m_drawer.GetLine(cursorPosition.y);
|
||||
if (cursorPosition.y + 1 < lineCount)
|
||||
|
|
@ -155,6 +170,8 @@ namespace Ndk
|
|||
cursorPosition.x = std::min(cursorPosition.x, static_cast<unsigned int>(nextLineInfo.glyphIndex - lineInfo.glyphIndex - 1));
|
||||
}
|
||||
|
||||
m_cursorPositionEnd = m_cursorPositionBegin;
|
||||
|
||||
std::size_t glyphIndex = lineInfo.glyphIndex + cursorPosition.x;
|
||||
|
||||
OnTextAreaCursorMove(this, &glyphIndex);
|
||||
|
|
@ -175,6 +192,23 @@ namespace Ndk
|
|||
m_cursorEntity->Enable(!m_readOnly && HasFocus());
|
||||
}
|
||||
|
||||
inline void TextAreaWidget::SetSelection(Nz::Vector2ui fromPosition, Nz::Vector2ui toPosition)
|
||||
{
|
||||
///TODO: Check if position are valid
|
||||
|
||||
// Ensure begin is before end
|
||||
if (toPosition.y < fromPosition.y || (toPosition.y == fromPosition.y && toPosition.x < fromPosition.x))
|
||||
std::swap(fromPosition, toPosition);
|
||||
|
||||
if (m_cursorPositionBegin != fromPosition || m_cursorPositionEnd != toPosition)
|
||||
{
|
||||
m_cursorPositionBegin = fromPosition;
|
||||
m_cursorPositionEnd = toPosition;
|
||||
|
||||
RefreshCursor();
|
||||
}
|
||||
}
|
||||
|
||||
inline void TextAreaWidget::SetText(const Nz::String& text)
|
||||
{
|
||||
m_text = text;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
#include <NDK/Components/DebugComponent.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
ComponentIndex DebugComponent::componentIndex;
|
||||
}
|
||||
|
|
@ -277,7 +277,8 @@ namespace Ndk
|
|||
{
|
||||
Nz::Boxf localBox = boundingVolume.obb.localBox;
|
||||
Nz::Vector3f newPos = r.data.localMatrix * localBox.GetPosition();
|
||||
Nz::Vector3f newLengths = r.data.localMatrix * localBox.GetLengths();
|
||||
Nz::Vector3f newCorner = r.data.localMatrix * (localBox.GetPosition() + localBox.GetLengths());
|
||||
Nz::Vector3f newLengths = newCorner - newPos;
|
||||
|
||||
boundingVolume.Set(Nz::Boxf(newPos.x, newPos.y, newPos.z, newLengths.x, newLengths.y, newLengths.z));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,11 +28,13 @@
|
|||
|
||||
#ifndef NDK_SERVER
|
||||
#include <NDK/Components/CameraComponent.hpp>
|
||||
#include <NDK/Components/DebugComponent.hpp>
|
||||
#include <NDK/Components/LightComponent.hpp>
|
||||
#include <NDK/Components/ListenerComponent.hpp>
|
||||
#include <NDK/Components/GraphicsComponent.hpp>
|
||||
#include <NDK/Components/ParticleEmitterComponent.hpp>
|
||||
#include <NDK/Components/ParticleGroupComponent.hpp>
|
||||
#include <NDK/Systems/DebugSystem.hpp>
|
||||
#include <NDK/Systems/ParticleSystem.hpp>
|
||||
#include <NDK/Systems/ListenerSystem.hpp>
|
||||
#include <NDK/Systems/RenderSystem.hpp>
|
||||
|
|
@ -95,6 +97,7 @@ namespace Ndk
|
|||
#ifndef NDK_SERVER
|
||||
// Client components
|
||||
InitializeComponent<CameraComponent>("NdkCam");
|
||||
InitializeComponent<DebugComponent>("NdkDebug");
|
||||
InitializeComponent<LightComponent>("NdkLight");
|
||||
InitializeComponent<ListenerComponent>("NdkList");
|
||||
InitializeComponent<GraphicsComponent>("NdkGfx");
|
||||
|
|
@ -113,6 +116,7 @@ namespace Ndk
|
|||
|
||||
#ifndef NDK_SERVER
|
||||
// Client systems
|
||||
InitializeSystem<DebugSystem>();
|
||||
InitializeSystem<ListenerSystem>();
|
||||
InitializeSystem<ParticleSystem>();
|
||||
InitializeSystem<RenderSystem>();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,363 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
#include <NDK/Systems/DebugSystem.hpp>
|
||||
#include <Nazara/Core/Primitive.hpp>
|
||||
#include <Nazara/Graphics/Model.hpp>
|
||||
#include <Nazara/Utility/IndexIterator.hpp>
|
||||
#include <Nazara/Utility/Mesh.hpp>
|
||||
#include <Nazara/Utility/StaticMesh.hpp>
|
||||
#include <NDK/Components/CollisionComponent3D.hpp>
|
||||
#include <NDK/Components/DebugComponent.hpp>
|
||||
#include <NDK/Components/GraphicsComponent.hpp>
|
||||
#include <NDK/Components/NodeComponent.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
namespace
|
||||
{
|
||||
class DebugRenderable : public Nz::InstancedRenderable
|
||||
{
|
||||
public:
|
||||
DebugRenderable(Ndk::Entity* owner, Nz::MaterialRef mat, Nz::IndexBufferRef indexBuffer, Nz::VertexBufferRef vertexBuffer) :
|
||||
m_entityOwner(owner),
|
||||
m_material(std::move(mat)),
|
||||
m_indexBuffer(std::move(indexBuffer)),
|
||||
m_vertexBuffer(std::move(vertexBuffer))
|
||||
{
|
||||
ResetMaterials(1);
|
||||
|
||||
m_meshData.indexBuffer = m_indexBuffer;
|
||||
m_meshData.primitiveMode = Nz::PrimitiveMode_LineList;
|
||||
m_meshData.vertexBuffer = m_vertexBuffer;
|
||||
}
|
||||
|
||||
void UpdateBoundingVolume(InstanceData* instanceData) const override
|
||||
{
|
||||
}
|
||||
|
||||
void MakeBoundingVolume() const override
|
||||
{
|
||||
m_boundingVolume.MakeNull();
|
||||
}
|
||||
|
||||
protected:
|
||||
Ndk::EntityHandle m_entityOwner;
|
||||
Nz::IndexBufferRef m_indexBuffer;
|
||||
Nz::MaterialRef m_material;
|
||||
Nz::MeshData m_meshData;
|
||||
Nz::VertexBufferRef m_vertexBuffer;
|
||||
};
|
||||
|
||||
class AABBDebugRenderable : public DebugRenderable
|
||||
{
|
||||
public:
|
||||
using DebugRenderable::DebugRenderable;
|
||||
|
||||
void AddToRenderQueue(Nz::AbstractRenderQueue* renderQueue, const InstanceData& instanceData, const Nz::Recti& scissorRect) const override
|
||||
{
|
||||
NazaraAssert(m_entityOwner, "DebugRenderable has no owner");
|
||||
|
||||
const DebugComponent& entityDebug = m_entityOwner->GetComponent<DebugComponent>();
|
||||
const GraphicsComponent& entityGfx = m_entityOwner->GetComponent<GraphicsComponent>();
|
||||
|
||||
Nz::Matrix4f transformMatrix = Nz::Matrix4f::Identity();
|
||||
transformMatrix.SetScale(entityGfx.GetBoundingVolume().aabb.GetLengths());
|
||||
transformMatrix.SetTranslation(entityGfx.GetBoundingVolume().aabb.GetCenter());
|
||||
|
||||
renderQueue->AddMesh(0, m_material, m_meshData, Nz::Boxf::Zero(), transformMatrix, scissorRect);
|
||||
}
|
||||
};
|
||||
|
||||
class OBBDebugRenderable : public DebugRenderable
|
||||
{
|
||||
public:
|
||||
using DebugRenderable::DebugRenderable;
|
||||
|
||||
void AddToRenderQueue(Nz::AbstractRenderQueue* renderQueue, const InstanceData& instanceData, const Nz::Recti& scissorRect) const override
|
||||
{
|
||||
NazaraAssert(m_entityOwner, "DebugRenderable has no owner");
|
||||
|
||||
const DebugComponent& entityDebug = m_entityOwner->GetComponent<DebugComponent>();
|
||||
const GraphicsComponent& entityGfx = m_entityOwner->GetComponent<GraphicsComponent>();
|
||||
|
||||
Nz::Matrix4f transformMatrix = instanceData.transformMatrix;
|
||||
transformMatrix.ApplyScale(entityGfx.GetBoundingVolume().obb.localBox.GetLengths());
|
||||
|
||||
renderQueue->AddMesh(0, m_material, m_meshData, Nz::Boxf::Zero(), transformMatrix, scissorRect);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/*!
|
||||
* \ingroup NDK
|
||||
* \class Ndk::DebugSystem
|
||||
* \brief NDK class that represents the debug system
|
||||
*
|
||||
* \remark This system is enabled if the entity owns the trait: DebugComponent and GraphicsComponent
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \brief Constructs an DebugSystem object by default
|
||||
*/
|
||||
DebugSystem::DebugSystem()
|
||||
{
|
||||
Requires<DebugComponent, GraphicsComponent>();
|
||||
SetUpdateOrder(1000); //< Update last
|
||||
}
|
||||
|
||||
std::pair<Nz::IndexBufferRef, Nz::VertexBufferRef> DebugSystem::GetBoxMesh()
|
||||
{
|
||||
if (!m_boxMeshIndexBuffer)
|
||||
{
|
||||
std::array<Nz::UInt16, 24> indices = {
|
||||
{
|
||||
0, 1,
|
||||
1, 2,
|
||||
2, 3,
|
||||
3, 0,
|
||||
|
||||
4, 5,
|
||||
5, 6,
|
||||
6, 7,
|
||||
7, 4,
|
||||
|
||||
0, 4,
|
||||
1, 5,
|
||||
2, 6,
|
||||
3, 7
|
||||
}
|
||||
};
|
||||
|
||||
m_boxMeshIndexBuffer = Nz::IndexBuffer::New(false, Nz::UInt32(indices.size()), Nz::DataStorage_Hardware, 0);
|
||||
m_boxMeshIndexBuffer->Fill(indices.data(), 0, Nz::UInt32(indices.size()));
|
||||
}
|
||||
|
||||
if (!m_boxMeshVertexBuffer)
|
||||
{
|
||||
Nz::Boxf box(-0.5f, -0.5f, -0.5f, 1.f, 1.f, 1.f);
|
||||
|
||||
std::array<Nz::Vector3f, 8> positions = {
|
||||
{
|
||||
box.GetCorner(Nz::BoxCorner_FarLeftBottom),
|
||||
box.GetCorner(Nz::BoxCorner_NearLeftBottom),
|
||||
box.GetCorner(Nz::BoxCorner_NearRightBottom),
|
||||
box.GetCorner(Nz::BoxCorner_FarRightBottom),
|
||||
box.GetCorner(Nz::BoxCorner_FarLeftTop),
|
||||
box.GetCorner(Nz::BoxCorner_NearLeftTop),
|
||||
box.GetCorner(Nz::BoxCorner_NearRightTop),
|
||||
box.GetCorner(Nz::BoxCorner_FarRightTop)
|
||||
}
|
||||
};
|
||||
|
||||
m_boxMeshVertexBuffer = Nz::VertexBuffer::New(Nz::VertexDeclaration::Get(Nz::VertexLayout_XYZ), Nz::UInt32(positions.size()), Nz::DataStorage_Hardware, 0);
|
||||
m_boxMeshVertexBuffer->Fill(positions.data(), 0, Nz::UInt32(positions.size()));
|
||||
}
|
||||
|
||||
return { m_boxMeshIndexBuffer, m_boxMeshVertexBuffer };
|
||||
}
|
||||
|
||||
void DebugSystem::OnEntityValidation(Entity* entity, bool /*justAdded*/)
|
||||
{
|
||||
static constexpr int DebugDrawOrder = 1'000;
|
||||
|
||||
DebugComponent& entityDebug = entity->GetComponent<DebugComponent>();
|
||||
GraphicsComponent& entityGfx = entity->GetComponent<GraphicsComponent>();
|
||||
|
||||
DebugDrawFlags enabledFlags = entityDebug.GetEnabledFlags();
|
||||
DebugDrawFlags flags = entityDebug.GetFlags();
|
||||
|
||||
DebugDrawFlags flagsToEnable = flags & ~enabledFlags;
|
||||
for (std::size_t i = 0; i <= static_cast<std::size_t>(DebugDraw::Max); ++i)
|
||||
{
|
||||
DebugDraw option = static_cast<DebugDraw>(i);
|
||||
if (flagsToEnable & option)
|
||||
{
|
||||
switch (option)
|
||||
{
|
||||
case DebugDraw::Collider3D:
|
||||
{
|
||||
const Nz::Boxf& obb = entityGfx.GetBoundingVolume().obb.localBox;
|
||||
|
||||
Nz::InstancedRenderableRef renderable = GenerateCollision3DMesh(entity);
|
||||
renderable->SetPersistent(false);
|
||||
|
||||
entityGfx.Attach(renderable, Nz::Matrix4f::Translate(obb.GetCenter()), DebugDrawOrder);
|
||||
|
||||
entityDebug.UpdateDebugRenderable(option, std::move(renderable));
|
||||
break;
|
||||
}
|
||||
|
||||
case DebugDraw::GraphicsAABB:
|
||||
{
|
||||
auto indexVertexBuffers = GetBoxMesh();
|
||||
|
||||
Nz::InstancedRenderableRef renderable = new AABBDebugRenderable(entity, GetAABBMaterial(), indexVertexBuffers.first, indexVertexBuffers.second);
|
||||
renderable->SetPersistent(false);
|
||||
|
||||
entityGfx.Attach(renderable, Nz::Matrix4f::Identity(), DebugDrawOrder);
|
||||
|
||||
entityDebug.UpdateDebugRenderable(option, std::move(renderable));
|
||||
break;
|
||||
}
|
||||
|
||||
case DebugDraw::GraphicsOBB:
|
||||
{
|
||||
auto indexVertexBuffers = GetBoxMesh();
|
||||
|
||||
Nz::InstancedRenderableRef renderable = new OBBDebugRenderable(entity, GetOBBMaterial(), indexVertexBuffers.first, indexVertexBuffers.second);
|
||||
renderable->SetPersistent(false);
|
||||
|
||||
entityGfx.Attach(renderable, Nz::Matrix4f::Identity(), DebugDrawOrder);
|
||||
|
||||
entityDebug.UpdateDebugRenderable(option, std::move(renderable));
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DebugDrawFlags flagsToDisable = enabledFlags & ~flags;
|
||||
for (std::size_t i = 0; i <= static_cast<std::size_t>(DebugDraw::Max); ++i)
|
||||
{
|
||||
DebugDraw option = static_cast<DebugDraw>(i);
|
||||
if (flagsToDisable & option)
|
||||
entityGfx.Detach(entityDebug.GetDebugRenderable(option));
|
||||
}
|
||||
|
||||
entityDebug.UpdateEnabledFlags(flags);
|
||||
}
|
||||
|
||||
void DebugSystem::OnUpdate(float elapsedTime)
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
Nz::InstancedRenderableRef DebugSystem::GenerateBox(Nz::Boxf box)
|
||||
{
|
||||
Nz::MeshRef mesh = Nz::Mesh::New();
|
||||
mesh->CreateStatic();
|
||||
|
||||
mesh->BuildSubMesh(Nz::Primitive::Box(box.GetLengths()));
|
||||
mesh->SetMaterialCount(1);
|
||||
|
||||
Nz::ModelRef model = Nz::Model::New();
|
||||
model->SetMesh(mesh);
|
||||
model->SetMaterial(0, GetOBBMaterial());
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
Nz::InstancedRenderableRef DebugSystem::GenerateCollision3DMesh(Entity* entity)
|
||||
{
|
||||
if (entity->HasComponent<CollisionComponent3D>())
|
||||
{
|
||||
CollisionComponent3D& entityCollision = entity->GetComponent<CollisionComponent3D>();
|
||||
const Nz::Collider3DRef& geom = entityCollision.GetGeom();
|
||||
|
||||
std::vector<Nz::Vector3f> vertices;
|
||||
std::vector<std::size_t> indices;
|
||||
|
||||
geom->ForEachPolygon([&](const float* polygonVertices, std::size_t vertexCount)
|
||||
{
|
||||
std::size_t firstIndex = vertices.size();
|
||||
|
||||
for (std::size_t i = 0; i < vertexCount; ++i)
|
||||
{
|
||||
const float* vertexData = &polygonVertices[i * 3];
|
||||
vertices.emplace_back(vertexData[0], vertexData[1], vertexData[2]);
|
||||
}
|
||||
|
||||
for (std::size_t i = 0; i < vertexCount - 1; ++i)
|
||||
{
|
||||
indices.push_back(firstIndex + i);
|
||||
indices.push_back(firstIndex + i + 1);
|
||||
}
|
||||
|
||||
indices.push_back(firstIndex + vertexCount - 1);
|
||||
indices.push_back(firstIndex);
|
||||
});
|
||||
|
||||
Nz::IndexBufferRef indexBuffer = Nz::IndexBuffer::New(vertices.size() > 0xFFFF, Nz::UInt32(indices.size()), Nz::DataStorage_Hardware, 0);
|
||||
Nz::IndexMapper indexMapper(indexBuffer, Nz::BufferAccess_WriteOnly);
|
||||
|
||||
Nz::IndexIterator indexPtr = indexMapper.begin();
|
||||
for (std::size_t index : indices)
|
||||
*indexPtr++ = static_cast<Nz::UInt32>(index);
|
||||
|
||||
indexMapper.Unmap();
|
||||
|
||||
Nz::VertexBufferRef vertexBuffer = Nz::VertexBuffer::New(Nz::VertexDeclaration::Get(Nz::VertexLayout_XYZ), Nz::UInt32(vertices.size()), Nz::DataStorage_Hardware, 0);
|
||||
vertexBuffer->Fill(vertices.data(), 0, Nz::UInt32(vertices.size()));
|
||||
|
||||
Nz::MeshRef mesh = Nz::Mesh::New();
|
||||
mesh->CreateStatic();
|
||||
|
||||
Nz::StaticMeshRef subMesh = Nz::StaticMesh::New(mesh);
|
||||
subMesh->Create(vertexBuffer);
|
||||
subMesh->SetIndexBuffer(indexBuffer);
|
||||
subMesh->SetPrimitiveMode(Nz::PrimitiveMode_LineList);
|
||||
subMesh->SetMaterialIndex(0);
|
||||
subMesh->GenerateAABB();
|
||||
|
||||
mesh->SetMaterialCount(1);
|
||||
mesh->AddSubMesh(subMesh);
|
||||
|
||||
Nz::ModelRef model = Nz::Model::New();
|
||||
model->SetMesh(mesh);
|
||||
model->SetMaterial(0, GetCollisionMaterial());
|
||||
|
||||
return model;
|
||||
}
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Nz::MaterialRef DebugSystem::GetAABBMaterial()
|
||||
{
|
||||
if (!m_aabbMaterial)
|
||||
{
|
||||
m_aabbMaterial = Nz::Material::New();
|
||||
m_aabbMaterial->EnableFaceCulling(false);
|
||||
m_aabbMaterial->EnableDepthBuffer(true);
|
||||
m_aabbMaterial->SetDiffuseColor(Nz::Color::Red);
|
||||
m_aabbMaterial->SetFaceFilling(Nz::FaceFilling_Line);
|
||||
}
|
||||
|
||||
return m_aabbMaterial;
|
||||
}
|
||||
|
||||
Nz::MaterialRef DebugSystem::GetCollisionMaterial()
|
||||
{
|
||||
if (!m_collisionMaterial)
|
||||
{
|
||||
m_collisionMaterial = Nz::Material::New();
|
||||
m_collisionMaterial->EnableFaceCulling(false);
|
||||
m_collisionMaterial->EnableDepthBuffer(true);
|
||||
m_collisionMaterial->SetDiffuseColor(Nz::Color::Blue);
|
||||
m_collisionMaterial->SetFaceFilling(Nz::FaceFilling_Line);
|
||||
}
|
||||
|
||||
return m_collisionMaterial;
|
||||
}
|
||||
|
||||
Nz::MaterialRef DebugSystem::GetOBBMaterial()
|
||||
{
|
||||
if (!m_obbMaterial)
|
||||
{
|
||||
m_obbMaterial = Nz::Material::New();
|
||||
m_obbMaterial->EnableFaceCulling(false);
|
||||
m_obbMaterial->EnableDepthBuffer(true);
|
||||
m_obbMaterial->SetDiffuseColor(Nz::Color::Green);
|
||||
m_obbMaterial->SetFaceFilling(Nz::FaceFilling_Line);
|
||||
}
|
||||
|
||||
return m_obbMaterial;
|
||||
}
|
||||
|
||||
SystemIndex DebugSystem::systemIndex;
|
||||
}
|
||||
|
|
@ -12,16 +12,14 @@ namespace Ndk
|
|||
TextAreaWidget::TextAreaWidget(BaseWidget* parent) :
|
||||
BaseWidget(parent),
|
||||
m_echoMode(EchoMode_Normal),
|
||||
m_cursorPosition(0U, 0U),
|
||||
m_cursorPositionBegin(0U, 0U),
|
||||
m_cursorPositionEnd(0U, 0U),
|
||||
m_isMouseButtonDown(false),
|
||||
m_multiLineEnabled(false),
|
||||
m_readOnly(false)
|
||||
{
|
||||
m_cursorSprite = Nz::Sprite::New();
|
||||
m_cursorSprite->SetColor(Nz::Color::Black);
|
||||
m_cursorSprite->SetSize(1.f, float(m_drawer.GetFont()->GetSizeInfo(m_drawer.GetCharacterSize()).lineHeight));
|
||||
|
||||
m_cursorEntity = CreateEntity(true);
|
||||
m_cursorEntity->AddComponent<GraphicsComponent>().Attach(m_cursorSprite, 10);
|
||||
m_cursorEntity->AddComponent<GraphicsComponent>();
|
||||
m_cursorEntity->AddComponent<NodeComponent>().SetParent(this);
|
||||
m_cursorEntity->Enable(false);
|
||||
|
||||
|
|
@ -72,7 +70,29 @@ namespace Ndk
|
|||
OnTextChanged(this, m_text);
|
||||
}
|
||||
|
||||
std::size_t TextAreaWidget::GetHoveredGlyph(float x, float y) const
|
||||
void TextAreaWidget::EraseSelection()
|
||||
{
|
||||
if (!HasSelection())
|
||||
return;
|
||||
|
||||
std::size_t cursorGlyphBegin = GetGlyphIndex(m_cursorPositionBegin);
|
||||
std::size_t cursorGlyphEnd = GetGlyphIndex(m_cursorPositionEnd);
|
||||
|
||||
std::size_t textLength = m_text.GetLength();
|
||||
if (cursorGlyphBegin > textLength)
|
||||
return;
|
||||
|
||||
Nz::String newText;
|
||||
if (cursorGlyphBegin > 0)
|
||||
newText.Append(m_text.SubString(0, m_text.GetCharacterPosition(cursorGlyphBegin) - 1));
|
||||
|
||||
if (cursorGlyphEnd < textLength)
|
||||
newText.Append(m_text.SubString(m_text.GetCharacterPosition(cursorGlyphEnd)));
|
||||
|
||||
SetText(newText);
|
||||
}
|
||||
|
||||
Nz::Vector2ui TextAreaWidget::GetHoveredGlyph(float x, float y) const
|
||||
{
|
||||
std::size_t glyphCount = m_drawer.GetGlyphCount();
|
||||
if (glyphCount > 0)
|
||||
|
|
@ -88,7 +108,8 @@ namespace Ndk
|
|||
|
||||
std::size_t upperLimit = (line != lineCount - 1) ? m_drawer.GetLine(line + 1).glyphIndex : glyphCount + 1;
|
||||
|
||||
std::size_t i = m_drawer.GetLine(line).glyphIndex;
|
||||
std::size_t firstLineGlyph = m_drawer.GetLine(line).glyphIndex;
|
||||
std::size_t i = firstLineGlyph;
|
||||
for (; i < upperLimit - 1; ++i)
|
||||
{
|
||||
Nz::Rectf bounds = m_drawer.GetGlyph(i).bounds;
|
||||
|
|
@ -96,10 +117,10 @@ namespace Ndk
|
|||
break;
|
||||
}
|
||||
|
||||
return i;
|
||||
return Nz::Vector2ui(i - firstLineGlyph, line);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return Nz::Vector2ui::Zero();
|
||||
}
|
||||
|
||||
void TextAreaWidget::ResizeToContent()
|
||||
|
|
@ -109,7 +130,7 @@ namespace Ndk
|
|||
|
||||
void TextAreaWidget::Write(const Nz::String& text)
|
||||
{
|
||||
std::size_t cursorGlyph = GetGlyphIndex(m_cursorPosition);
|
||||
std::size_t cursorGlyph = GetGlyphIndex(m_cursorPositionBegin);
|
||||
|
||||
if (cursorGlyph >= m_drawer.GetGlyphCount())
|
||||
{
|
||||
|
|
@ -156,20 +177,27 @@ namespace Ndk
|
|||
{
|
||||
case Nz::Keyboard::Delete:
|
||||
{
|
||||
std::size_t cursorGlyph = GetGlyphIndex(m_cursorPosition);
|
||||
if (HasSelection())
|
||||
EraseSelection();
|
||||
else
|
||||
{
|
||||
std::size_t cursorGlyphBegin = GetGlyphIndex(m_cursorPositionBegin);
|
||||
std::size_t cursorGlyphEnd = GetGlyphIndex(m_cursorPositionEnd);
|
||||
|
||||
std::size_t textLength = m_text.GetLength();
|
||||
if (cursorGlyph > textLength)
|
||||
return true;
|
||||
std::size_t textLength = m_text.GetLength();
|
||||
if (cursorGlyphBegin > textLength)
|
||||
return true;
|
||||
|
||||
Nz::String newText;
|
||||
if (cursorGlyph > 0)
|
||||
newText.Append(m_text.SubString(0, m_text.GetCharacterPosition(cursorGlyph) - 1));
|
||||
Nz::String newText;
|
||||
if (cursorGlyphBegin > 0)
|
||||
newText.Append(m_text.SubString(0, m_text.GetCharacterPosition(cursorGlyphBegin) - 1));
|
||||
|
||||
if (cursorGlyph < textLength)
|
||||
newText.Append(m_text.SubString(m_text.GetCharacterPosition(cursorGlyph + 1)));
|
||||
if (cursorGlyphEnd < textLength)
|
||||
newText.Append(m_text.SubString(m_text.GetCharacterPosition(cursorGlyphEnd + 1)));
|
||||
|
||||
SetText(newText);
|
||||
}
|
||||
|
||||
SetText(newText);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -181,10 +209,38 @@ namespace Ndk
|
|||
if (ignoreDefaultAction)
|
||||
return true;
|
||||
|
||||
if (HasSelection())
|
||||
SetCursorPosition(m_cursorPositionEnd);
|
||||
|
||||
MoveCursor({0, 1});
|
||||
return true;
|
||||
}
|
||||
|
||||
case Nz::Keyboard::End:
|
||||
{
|
||||
bool ignoreDefaultAction = false;
|
||||
OnTextAreaKeyEnd(this, &ignoreDefaultAction);
|
||||
|
||||
if (ignoreDefaultAction)
|
||||
return true;
|
||||
|
||||
const auto& lineInfo = m_drawer.GetLine(m_cursorPositionEnd.y);
|
||||
SetCursorPosition({ static_cast<unsigned int>(m_drawer.GetLineGlyphCount(m_cursorPositionEnd.y)), m_cursorPositionEnd.y });
|
||||
return true;
|
||||
}
|
||||
|
||||
case Nz::Keyboard::Home:
|
||||
{
|
||||
bool ignoreDefaultAction = false;
|
||||
OnTextAreaKeyHome(this, &ignoreDefaultAction);
|
||||
|
||||
if (ignoreDefaultAction)
|
||||
return true;
|
||||
|
||||
SetCursorPosition({ 0U, m_cursorPositionEnd.y });
|
||||
return true;
|
||||
}
|
||||
|
||||
case Nz::Keyboard::Left:
|
||||
{
|
||||
bool ignoreDefaultAction = false;
|
||||
|
|
@ -193,7 +249,11 @@ namespace Ndk
|
|||
if (ignoreDefaultAction)
|
||||
return true;
|
||||
|
||||
MoveCursor(-1);
|
||||
if (HasSelection())
|
||||
SetCursorPosition(m_cursorPositionBegin);
|
||||
else
|
||||
MoveCursor(-1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -205,7 +265,11 @@ namespace Ndk
|
|||
if (ignoreDefaultAction)
|
||||
return true;
|
||||
|
||||
MoveCursor(1);
|
||||
if (HasSelection())
|
||||
SetCursorPosition(m_cursorPositionEnd);
|
||||
else
|
||||
MoveCursor(1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -217,6 +281,9 @@ namespace Ndk
|
|||
if (ignoreDefaultAction)
|
||||
return true;
|
||||
|
||||
if (HasSelection())
|
||||
SetCursorPosition(m_cursorPositionBegin);
|
||||
|
||||
MoveCursor({0, -1});
|
||||
return true;
|
||||
}
|
||||
|
|
@ -237,7 +304,39 @@ namespace Ndk
|
|||
SetFocus();
|
||||
|
||||
const Padding& padding = GetPadding();
|
||||
SetCursorPosition(GetHoveredGlyph(float(x - padding.left), float(y - padding.top)));
|
||||
Nz::Vector2ui hoveredGlyph = GetHoveredGlyph(float(x - padding.left), float(y - padding.top));
|
||||
|
||||
// Shift extends selection
|
||||
if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::LShift) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::RShift))
|
||||
SetSelection(hoveredGlyph, m_selectionCursor);
|
||||
else
|
||||
{
|
||||
SetCursorPosition(hoveredGlyph);
|
||||
m_selectionCursor = m_cursorPositionBegin;
|
||||
}
|
||||
|
||||
m_isMouseButtonDown = true;
|
||||
}
|
||||
}
|
||||
|
||||
void TextAreaWidget::OnMouseButtonRelease(int, int, Nz::Mouse::Button button)
|
||||
{
|
||||
if (button == Nz::Mouse::Left)
|
||||
m_isMouseButtonDown = false;
|
||||
}
|
||||
|
||||
void TextAreaWidget::OnMouseEnter()
|
||||
{
|
||||
if (!Nz::Mouse::IsButtonPressed(Nz::Mouse::Left))
|
||||
m_isMouseButtonDown = false;
|
||||
}
|
||||
|
||||
void TextAreaWidget::OnMouseMoved(int x, int y, int deltaX, int deltaY)
|
||||
{
|
||||
if (m_isMouseButtonDown)
|
||||
{
|
||||
const Padding& padding = GetPadding();
|
||||
SetSelection(m_selectionCursor, GetHoveredGlyph(float(x - padding.left), float(y - padding.top)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -253,20 +352,30 @@ namespace Ndk
|
|||
bool ignoreDefaultAction = false;
|
||||
OnTextAreaKeyBackspace(this, &ignoreDefaultAction);
|
||||
|
||||
std::size_t cursorGlyph = GetGlyphIndex(m_cursorPosition);
|
||||
if (ignoreDefaultAction || cursorGlyph == 0)
|
||||
std::size_t cursorGlyphBegin = GetGlyphIndex(m_cursorPositionBegin);
|
||||
std::size_t cursorGlyphEnd = GetGlyphIndex(m_cursorPositionEnd);
|
||||
|
||||
if (ignoreDefaultAction || cursorGlyphEnd == 0)
|
||||
break;
|
||||
|
||||
Nz::String newText;
|
||||
// When a text is selected, delete key does the same as delete and leave the character behind it
|
||||
if (HasSelection())
|
||||
EraseSelection();
|
||||
else
|
||||
{
|
||||
Nz::String newText;
|
||||
|
||||
if (cursorGlyph > 1)
|
||||
newText.Append(m_text.SubString(0, m_text.GetCharacterPosition(cursorGlyph - 1) - 1));
|
||||
if (cursorGlyphBegin > 1)
|
||||
newText.Append(m_text.SubString(0, m_text.GetCharacterPosition(cursorGlyphBegin - 1) - 1));
|
||||
|
||||
if (cursorGlyph < m_text.GetLength())
|
||||
newText.Append(m_text.SubString(m_text.GetCharacterPosition(cursorGlyph)));
|
||||
if (cursorGlyphEnd < m_text.GetLength())
|
||||
newText.Append(m_text.SubString(m_text.GetCharacterPosition(cursorGlyphEnd)));
|
||||
|
||||
MoveCursor(-1);
|
||||
SetText(newText);
|
||||
// Move cursor before setting text (to prevent SetText to move our cursor)
|
||||
MoveCursor(-1);
|
||||
|
||||
SetText(newText);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -288,6 +397,9 @@ namespace Ndk
|
|||
if (Nz::Unicode::GetCategory(character) == Nz::Unicode::Category_Other_Control)
|
||||
break;
|
||||
|
||||
if (HasSelection())
|
||||
EraseSelection();
|
||||
|
||||
Write(Nz::String::Unicode(character));
|
||||
break;
|
||||
}
|
||||
|
|
@ -299,24 +411,68 @@ namespace Ndk
|
|||
if (m_readOnly)
|
||||
return;
|
||||
|
||||
const auto& lineInfo = m_drawer.GetLine(m_cursorPosition.y);
|
||||
std::size_t cursorGlyph = GetGlyphIndex(m_cursorPosition);
|
||||
m_cursorEntity->GetComponent<NodeComponent>().SetPosition(GetContentOrigin());
|
||||
|
||||
std::size_t glyphCount = m_drawer.GetGlyphCount();
|
||||
float position;
|
||||
if (glyphCount > 0 && lineInfo.glyphIndex < cursorGlyph)
|
||||
std::size_t selectionLineCount = m_cursorPositionEnd.y - m_cursorPositionBegin.y + 1;
|
||||
std::size_t oldSpriteCount = m_cursorSprites.size();
|
||||
if (m_cursorSprites.size() != selectionLineCount)
|
||||
{
|
||||
const auto& glyph = m_drawer.GetGlyph(std::min(cursorGlyph, glyphCount - 1));
|
||||
position = glyph.bounds.x;
|
||||
if (cursorGlyph >= glyphCount)
|
||||
position += glyph.bounds.width;
|
||||
m_cursorSprites.resize(m_cursorPositionEnd.y - m_cursorPositionBegin.y + 1);
|
||||
for (std::size_t i = oldSpriteCount; i < m_cursorSprites.size(); ++i)
|
||||
{
|
||||
m_cursorSprites[i] = Nz::Sprite::New();
|
||||
m_cursorSprites[i]->SetMaterial(Nz::Material::New("Translucent2D"));
|
||||
}
|
||||
}
|
||||
else
|
||||
position = 0.f;
|
||||
|
||||
Nz::Vector2f contentOrigin = GetContentOrigin();
|
||||
float lineHeight = float(m_drawer.GetFont()->GetSizeInfo(m_drawer.GetCharacterSize()).lineHeight);
|
||||
|
||||
m_cursorEntity->GetComponent<NodeComponent>().SetPosition(contentOrigin.x + position, contentOrigin.y + lineInfo.bounds.y);
|
||||
GraphicsComponent& gfxComponent = m_cursorEntity->GetComponent<GraphicsComponent>();
|
||||
gfxComponent.Clear();
|
||||
|
||||
for (unsigned int i = m_cursorPositionBegin.y; i <= m_cursorPositionEnd.y; ++i)
|
||||
{
|
||||
const auto& lineInfo = m_drawer.GetLine(i);
|
||||
|
||||
Nz::SpriteRef& cursorSprite = m_cursorSprites[i - m_cursorPositionBegin.y];
|
||||
if (i == m_cursorPositionBegin.y || i == m_cursorPositionEnd.y)
|
||||
{
|
||||
auto GetGlyphPos = [&](unsigned int localGlyphPos)
|
||||
{
|
||||
std::size_t cursorGlyph = GetGlyphIndex({ localGlyphPos, i });
|
||||
|
||||
std::size_t glyphCount = m_drawer.GetGlyphCount();
|
||||
float position;
|
||||
if (glyphCount > 0 && lineInfo.glyphIndex < cursorGlyph)
|
||||
{
|
||||
const auto& glyph = m_drawer.GetGlyph(std::min(cursorGlyph, glyphCount - 1));
|
||||
position = glyph.bounds.x;
|
||||
if (cursorGlyph >= glyphCount)
|
||||
position += glyph.bounds.width;
|
||||
}
|
||||
else
|
||||
position = 0.f;
|
||||
|
||||
return position;
|
||||
};
|
||||
|
||||
float beginX = (i == m_cursorPositionBegin.y) ? GetGlyphPos(m_cursorPositionBegin.x) : 0.f;
|
||||
float endX = (i == m_cursorPositionEnd.y) ? GetGlyphPos(m_cursorPositionEnd.x) : lineInfo.bounds.width;
|
||||
float spriteSize = std::max(endX - beginX, 1.f);
|
||||
|
||||
cursorSprite->SetColor((m_cursorPositionBegin == m_cursorPositionEnd) ? Nz::Color::Black : Nz::Color(0, 0, 0, 50));
|
||||
cursorSprite->SetSize(spriteSize, float(m_drawer.GetFont()->GetSizeInfo(m_drawer.GetCharacterSize()).lineHeight));
|
||||
|
||||
gfxComponent.Attach(cursorSprite, Nz::Matrix4f::Translate({ beginX, lineInfo.bounds.y, 0.f }));
|
||||
}
|
||||
else
|
||||
{
|
||||
cursorSprite->SetColor(Nz::Color(0, 0, 0, 50));
|
||||
cursorSprite->SetSize(lineInfo.bounds.width, float(m_drawer.GetFont()->GetSizeInfo(m_drawer.GetCharacterSize()).lineHeight));
|
||||
|
||||
gfxComponent.Attach(cursorSprite, Nz::Matrix4f::Translate({ 0.f, lineInfo.bounds.y, 0.f }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TextAreaWidget::UpdateDisplayText()
|
||||
|
|
@ -335,6 +491,6 @@ namespace Ndk
|
|||
|
||||
m_textSprite->Update(m_drawer);
|
||||
|
||||
SetCursorPosition(m_cursorPosition); //< Refresh cursor position (prevent it from being outside of the text)
|
||||
SetCursorPosition(m_cursorPositionBegin); //< Refresh cursor position (prevent it from being outside of the text)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include <NDK/Systems/VelocitySystem.hpp>
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
#include <NDK/Systems/DebugSystem.hpp>
|
||||
#include <NDK/Systems/ListenerSystem.hpp>
|
||||
#include <NDK/Systems/ParticleSystem.hpp>
|
||||
#include <NDK/Systems/RenderSystem.hpp>
|
||||
|
|
@ -47,6 +48,7 @@ namespace Ndk
|
|||
AddSystem<VelocitySystem>();
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
AddSystem<DebugSystem>();
|
||||
AddSystem<ListenerSystem>();
|
||||
AddSystem<ParticleSystem>();
|
||||
AddSystem<RenderSystem>();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,365 @@
|
|||
# GNU Make workspace makefile autogenerated by Premake
|
||||
|
||||
ifndef config
|
||||
config=debugdynamic_x64
|
||||
endif
|
||||
|
||||
ifndef verbose
|
||||
SILENT = @
|
||||
endif
|
||||
|
||||
ifeq ($(config),debugdynamic_x64)
|
||||
chipmunk_config = debugdynamic_x64
|
||||
lua_config = debugdynamic_x64
|
||||
stb_image_config = debugdynamic_x64
|
||||
NazaraAudio_config = debugdynamic_x64
|
||||
NazaraCore_config = debugdynamic_x64
|
||||
NazaraGraphics_config = debugdynamic_x64
|
||||
NazaraLua_config = debugdynamic_x64
|
||||
NazaraNetwork_config = debugdynamic_x64
|
||||
NazaraNoise_config = debugdynamic_x64
|
||||
NazaraPhysics2D_config = debugdynamic_x64
|
||||
NazaraPhysics3D_config = debugdynamic_x64
|
||||
NazaraPlatform_config = debugdynamic_x64
|
||||
NazaraRenderer_config = debugdynamic_x64
|
||||
NazaraUtility_config = debugdynamic_x64
|
||||
PluginAssimp_config = debugdynamic_x64
|
||||
NazaraSDK_config = debugdynamic_x64
|
||||
NazaraSDKServer_config = debugdynamic_x64
|
||||
NazaraUnitTests_config = debugdynamic_x64
|
||||
NazaraUnitTestsServer_config = debugdynamic_x64
|
||||
DemoDopplerEffect_config = debugdynamic_x64
|
||||
DemoFirstScene_config = debugdynamic_x64
|
||||
DemoHardwareInfo_config = debugdynamic_x64
|
||||
DemoMeshInfos_config = debugdynamic_x64
|
||||
DemoParticles_config = debugdynamic_x64
|
||||
DemoTut00_EmptyProject_config = debugdynamic_x64
|
||||
DemoTut01_HelloWorld_config = debugdynamic_x64
|
||||
DemoTut02_Events_config = debugdynamic_x64
|
||||
endif
|
||||
ifeq ($(config),debugdynamic_x86)
|
||||
chipmunk_config = debugdynamic_x86
|
||||
lua_config = debugdynamic_x86
|
||||
stb_image_config = debugdynamic_x86
|
||||
NazaraAudio_config = debugdynamic_x86
|
||||
NazaraCore_config = debugdynamic_x86
|
||||
NazaraGraphics_config = debugdynamic_x86
|
||||
NazaraLua_config = debugdynamic_x86
|
||||
NazaraNetwork_config = debugdynamic_x86
|
||||
NazaraNoise_config = debugdynamic_x86
|
||||
NazaraPhysics2D_config = debugdynamic_x86
|
||||
NazaraPhysics3D_config = debugdynamic_x86
|
||||
NazaraPlatform_config = debugdynamic_x86
|
||||
NazaraRenderer_config = debugdynamic_x86
|
||||
NazaraUtility_config = debugdynamic_x86
|
||||
PluginAssimp_config = debugdynamic_x86
|
||||
NazaraSDK_config = debugdynamic_x86
|
||||
NazaraSDKServer_config = debugdynamic_x86
|
||||
NazaraUnitTests_config = debugdynamic_x86
|
||||
NazaraUnitTestsServer_config = debugdynamic_x86
|
||||
DemoDopplerEffect_config = debugdynamic_x86
|
||||
DemoFirstScene_config = debugdynamic_x86
|
||||
DemoHardwareInfo_config = debugdynamic_x86
|
||||
DemoMeshInfos_config = debugdynamic_x86
|
||||
DemoParticles_config = debugdynamic_x86
|
||||
DemoTut00_EmptyProject_config = debugdynamic_x86
|
||||
DemoTut01_HelloWorld_config = debugdynamic_x86
|
||||
DemoTut02_Events_config = debugdynamic_x86
|
||||
endif
|
||||
ifeq ($(config),releasedynamic_x64)
|
||||
chipmunk_config = releasedynamic_x64
|
||||
lua_config = releasedynamic_x64
|
||||
stb_image_config = releasedynamic_x64
|
||||
NazaraAudio_config = releasedynamic_x64
|
||||
NazaraCore_config = releasedynamic_x64
|
||||
NazaraGraphics_config = releasedynamic_x64
|
||||
NazaraLua_config = releasedynamic_x64
|
||||
NazaraNetwork_config = releasedynamic_x64
|
||||
NazaraNoise_config = releasedynamic_x64
|
||||
NazaraPhysics2D_config = releasedynamic_x64
|
||||
NazaraPhysics3D_config = releasedynamic_x64
|
||||
NazaraPlatform_config = releasedynamic_x64
|
||||
NazaraRenderer_config = releasedynamic_x64
|
||||
NazaraUtility_config = releasedynamic_x64
|
||||
PluginAssimp_config = releasedynamic_x64
|
||||
NazaraSDK_config = releasedynamic_x64
|
||||
NazaraSDKServer_config = releasedynamic_x64
|
||||
NazaraUnitTests_config = releasedynamic_x64
|
||||
NazaraUnitTestsServer_config = releasedynamic_x64
|
||||
DemoDopplerEffect_config = releasedynamic_x64
|
||||
DemoFirstScene_config = releasedynamic_x64
|
||||
DemoHardwareInfo_config = releasedynamic_x64
|
||||
DemoMeshInfos_config = releasedynamic_x64
|
||||
DemoParticles_config = releasedynamic_x64
|
||||
DemoTut00_EmptyProject_config = releasedynamic_x64
|
||||
DemoTut01_HelloWorld_config = releasedynamic_x64
|
||||
DemoTut02_Events_config = releasedynamic_x64
|
||||
endif
|
||||
ifeq ($(config),releasedynamic_x86)
|
||||
chipmunk_config = releasedynamic_x86
|
||||
lua_config = releasedynamic_x86
|
||||
stb_image_config = releasedynamic_x86
|
||||
NazaraAudio_config = releasedynamic_x86
|
||||
NazaraCore_config = releasedynamic_x86
|
||||
NazaraGraphics_config = releasedynamic_x86
|
||||
NazaraLua_config = releasedynamic_x86
|
||||
NazaraNetwork_config = releasedynamic_x86
|
||||
NazaraNoise_config = releasedynamic_x86
|
||||
NazaraPhysics2D_config = releasedynamic_x86
|
||||
NazaraPhysics3D_config = releasedynamic_x86
|
||||
NazaraPlatform_config = releasedynamic_x86
|
||||
NazaraRenderer_config = releasedynamic_x86
|
||||
NazaraUtility_config = releasedynamic_x86
|
||||
PluginAssimp_config = releasedynamic_x86
|
||||
NazaraSDK_config = releasedynamic_x86
|
||||
NazaraSDKServer_config = releasedynamic_x86
|
||||
NazaraUnitTests_config = releasedynamic_x86
|
||||
NazaraUnitTestsServer_config = releasedynamic_x86
|
||||
DemoDopplerEffect_config = releasedynamic_x86
|
||||
DemoFirstScene_config = releasedynamic_x86
|
||||
DemoHardwareInfo_config = releasedynamic_x86
|
||||
DemoMeshInfos_config = releasedynamic_x86
|
||||
DemoParticles_config = releasedynamic_x86
|
||||
DemoTut00_EmptyProject_config = releasedynamic_x86
|
||||
DemoTut01_HelloWorld_config = releasedynamic_x86
|
||||
DemoTut02_Events_config = releasedynamic_x86
|
||||
endif
|
||||
|
||||
PROJECTS := chipmunk lua stb_image NazaraAudio NazaraCore NazaraGraphics NazaraLua NazaraNetwork NazaraNoise NazaraPhysics2D NazaraPhysics3D NazaraPlatform NazaraRenderer NazaraUtility PluginAssimp NazaraSDK NazaraSDKServer NazaraUnitTests NazaraUnitTestsServer DemoDopplerEffect DemoFirstScene DemoHardwareInfo DemoMeshInfos DemoParticles DemoTut00_EmptyProject DemoTut01_HelloWorld DemoTut02_Events
|
||||
|
||||
.PHONY: all clean help $(PROJECTS)
|
||||
|
||||
all: $(PROJECTS)
|
||||
|
||||
chipmunk:
|
||||
ifneq (,$(chipmunk_config))
|
||||
@echo "==== Building chipmunk ($(chipmunk_config)) ===="
|
||||
@${MAKE} --no-print-directory -C thirdparty -f chipmunk.make config=$(chipmunk_config)
|
||||
endif
|
||||
|
||||
lua:
|
||||
ifneq (,$(lua_config))
|
||||
@echo "==== Building lua ($(lua_config)) ===="
|
||||
@${MAKE} --no-print-directory -C thirdparty -f lua.make config=$(lua_config)
|
||||
endif
|
||||
|
||||
stb_image:
|
||||
ifneq (,$(stb_image_config))
|
||||
@echo "==== Building stb_image ($(stb_image_config)) ===="
|
||||
@${MAKE} --no-print-directory -C thirdparty -f stb_image.make config=$(stb_image_config)
|
||||
endif
|
||||
|
||||
NazaraAudio: NazaraCore
|
||||
ifneq (,$(NazaraAudio_config))
|
||||
@echo "==== Building NazaraAudio ($(NazaraAudio_config)) ===="
|
||||
@${MAKE} --no-print-directory -C modules -f NazaraAudio.make config=$(NazaraAudio_config)
|
||||
endif
|
||||
|
||||
NazaraCore:
|
||||
ifneq (,$(NazaraCore_config))
|
||||
@echo "==== Building NazaraCore ($(NazaraCore_config)) ===="
|
||||
@${MAKE} --no-print-directory -C modules -f NazaraCore.make config=$(NazaraCore_config)
|
||||
endif
|
||||
|
||||
NazaraGraphics: NazaraCore NazaraUtility NazaraPlatform NazaraRenderer
|
||||
ifneq (,$(NazaraGraphics_config))
|
||||
@echo "==== Building NazaraGraphics ($(NazaraGraphics_config)) ===="
|
||||
@${MAKE} --no-print-directory -C modules -f NazaraGraphics.make config=$(NazaraGraphics_config)
|
||||
endif
|
||||
|
||||
NazaraLua: lua NazaraCore
|
||||
ifneq (,$(NazaraLua_config))
|
||||
@echo "==== Building NazaraLua ($(NazaraLua_config)) ===="
|
||||
@${MAKE} --no-print-directory -C modules -f NazaraLua.make config=$(NazaraLua_config)
|
||||
endif
|
||||
|
||||
NazaraNetwork: NazaraCore
|
||||
ifneq (,$(NazaraNetwork_config))
|
||||
@echo "==== Building NazaraNetwork ($(NazaraNetwork_config)) ===="
|
||||
@${MAKE} --no-print-directory -C modules -f NazaraNetwork.make config=$(NazaraNetwork_config)
|
||||
endif
|
||||
|
||||
NazaraNoise: NazaraCore
|
||||
ifneq (,$(NazaraNoise_config))
|
||||
@echo "==== Building NazaraNoise ($(NazaraNoise_config)) ===="
|
||||
@${MAKE} --no-print-directory -C modules -f NazaraNoise.make config=$(NazaraNoise_config)
|
||||
endif
|
||||
|
||||
NazaraPhysics2D: chipmunk NazaraCore
|
||||
ifneq (,$(NazaraPhysics2D_config))
|
||||
@echo "==== Building NazaraPhysics2D ($(NazaraPhysics2D_config)) ===="
|
||||
@${MAKE} --no-print-directory -C modules -f NazaraPhysics2D.make config=$(NazaraPhysics2D_config)
|
||||
endif
|
||||
|
||||
NazaraPhysics3D: NazaraCore
|
||||
ifneq (,$(NazaraPhysics3D_config))
|
||||
@echo "==== Building NazaraPhysics3D ($(NazaraPhysics3D_config)) ===="
|
||||
@${MAKE} --no-print-directory -C modules -f NazaraPhysics3D.make config=$(NazaraPhysics3D_config)
|
||||
endif
|
||||
|
||||
NazaraPlatform: NazaraCore NazaraUtility
|
||||
ifneq (,$(NazaraPlatform_config))
|
||||
@echo "==== Building NazaraPlatform ($(NazaraPlatform_config)) ===="
|
||||
@${MAKE} --no-print-directory -C modules -f NazaraPlatform.make config=$(NazaraPlatform_config)
|
||||
endif
|
||||
|
||||
NazaraRenderer: NazaraCore NazaraUtility NazaraPlatform
|
||||
ifneq (,$(NazaraRenderer_config))
|
||||
@echo "==== Building NazaraRenderer ($(NazaraRenderer_config)) ===="
|
||||
@${MAKE} --no-print-directory -C modules -f NazaraRenderer.make config=$(NazaraRenderer_config)
|
||||
endif
|
||||
|
||||
NazaraUtility: stb_image NazaraCore
|
||||
ifneq (,$(NazaraUtility_config))
|
||||
@echo "==== Building NazaraUtility ($(NazaraUtility_config)) ===="
|
||||
@${MAKE} --no-print-directory -C modules -f NazaraUtility.make config=$(NazaraUtility_config)
|
||||
endif
|
||||
|
||||
PluginAssimp: NazaraCore NazaraUtility
|
||||
ifneq (,$(PluginAssimp_config))
|
||||
@echo "==== Building PluginAssimp ($(PluginAssimp_config)) ===="
|
||||
@${MAKE} --no-print-directory -C tools -f PluginAssimp.make config=$(PluginAssimp_config)
|
||||
endif
|
||||
|
||||
NazaraSDK: NazaraAudio NazaraCore NazaraGraphics NazaraLua NazaraNetwork NazaraNoise NazaraPhysics2D NazaraPhysics3D NazaraPlatform NazaraRenderer NazaraUtility
|
||||
ifneq (,$(NazaraSDK_config))
|
||||
@echo "==== Building NazaraSDK ($(NazaraSDK_config)) ===="
|
||||
@${MAKE} --no-print-directory -C tools -f NazaraSDK.make config=$(NazaraSDK_config)
|
||||
endif
|
||||
|
||||
NazaraSDKServer: NazaraCore NazaraLua NazaraNetwork NazaraNoise NazaraPhysics2D NazaraPhysics3D NazaraUtility
|
||||
ifneq (,$(NazaraSDKServer_config))
|
||||
@echo "==== Building NazaraSDKServer ($(NazaraSDKServer_config)) ===="
|
||||
@${MAKE} --no-print-directory -C tools -f NazaraSDKServer.make config=$(NazaraSDKServer_config)
|
||||
endif
|
||||
|
||||
NazaraUnitTests: NazaraSDK NazaraAudio NazaraCore NazaraGraphics NazaraLua NazaraNetwork NazaraNoise NazaraPhysics2D NazaraPhysics3D NazaraPlatform NazaraRenderer NazaraUtility
|
||||
ifneq (,$(NazaraUnitTests_config))
|
||||
@echo "==== Building NazaraUnitTests ($(NazaraUnitTests_config)) ===="
|
||||
@${MAKE} --no-print-directory -C tools -f NazaraUnitTests.make config=$(NazaraUnitTests_config)
|
||||
endif
|
||||
|
||||
NazaraUnitTestsServer: NazaraSDKServer NazaraCore NazaraLua NazaraNetwork NazaraNoise NazaraPhysics2D NazaraPhysics3D NazaraUtility
|
||||
ifneq (,$(NazaraUnitTestsServer_config))
|
||||
@echo "==== Building NazaraUnitTestsServer ($(NazaraUnitTestsServer_config)) ===="
|
||||
@${MAKE} --no-print-directory -C tools -f NazaraUnitTestsServer.make config=$(NazaraUnitTestsServer_config)
|
||||
endif
|
||||
|
||||
DemoDopplerEffect: NazaraAudio NazaraCore NazaraPlatform NazaraUtility
|
||||
ifneq (,$(DemoDopplerEffect_config))
|
||||
@echo "==== Building DemoDopplerEffect ($(DemoDopplerEffect_config)) ===="
|
||||
@${MAKE} --no-print-directory -C examples -f DemoDopplerEffect.make config=$(DemoDopplerEffect_config)
|
||||
endif
|
||||
|
||||
DemoFirstScene: NazaraAudio NazaraCore NazaraGraphics NazaraLua NazaraNetwork NazaraNoise NazaraPhysics2D NazaraPhysics3D NazaraPlatform NazaraRenderer NazaraUtility NazaraSDK
|
||||
ifneq (,$(DemoFirstScene_config))
|
||||
@echo "==== Building DemoFirstScene ($(DemoFirstScene_config)) ===="
|
||||
@${MAKE} --no-print-directory -C examples -f DemoFirstScene.make config=$(DemoFirstScene_config)
|
||||
endif
|
||||
|
||||
DemoHardwareInfo: NazaraCore NazaraPlatform NazaraRenderer NazaraUtility
|
||||
ifneq (,$(DemoHardwareInfo_config))
|
||||
@echo "==== Building DemoHardwareInfo ($(DemoHardwareInfo_config)) ===="
|
||||
@${MAKE} --no-print-directory -C examples -f DemoHardwareInfo.make config=$(DemoHardwareInfo_config)
|
||||
endif
|
||||
|
||||
DemoMeshInfos: NazaraCore NazaraPlatform NazaraUtility
|
||||
ifneq (,$(DemoMeshInfos_config))
|
||||
@echo "==== Building DemoMeshInfos ($(DemoMeshInfos_config)) ===="
|
||||
@${MAKE} --no-print-directory -C examples -f DemoMeshInfos.make config=$(DemoMeshInfos_config)
|
||||
endif
|
||||
|
||||
DemoParticles: NazaraAudio NazaraCore NazaraGraphics NazaraLua NazaraNetwork NazaraNoise NazaraPhysics2D NazaraPhysics3D NazaraPlatform NazaraRenderer NazaraUtility NazaraSDK
|
||||
ifneq (,$(DemoParticles_config))
|
||||
@echo "==== Building DemoParticles ($(DemoParticles_config)) ===="
|
||||
@${MAKE} --no-print-directory -C examples -f DemoParticles.make config=$(DemoParticles_config)
|
||||
endif
|
||||
|
||||
DemoTut00_EmptyProject: NazaraAudio NazaraCore NazaraGraphics NazaraLua NazaraNetwork NazaraNoise NazaraPhysics2D NazaraPhysics3D NazaraPlatform NazaraRenderer NazaraUtility NazaraSDK
|
||||
ifneq (,$(DemoTut00_EmptyProject_config))
|
||||
@echo "==== Building DemoTut00_EmptyProject ($(DemoTut00_EmptyProject_config)) ===="
|
||||
@${MAKE} --no-print-directory -C examples -f DemoTut00_EmptyProject.make config=$(DemoTut00_EmptyProject_config)
|
||||
endif
|
||||
|
||||
DemoTut01_HelloWorld: NazaraAudio NazaraCore NazaraGraphics NazaraLua NazaraNetwork NazaraNoise NazaraPhysics2D NazaraPhysics3D NazaraPlatform NazaraRenderer NazaraUtility NazaraSDK
|
||||
ifneq (,$(DemoTut01_HelloWorld_config))
|
||||
@echo "==== Building DemoTut01_HelloWorld ($(DemoTut01_HelloWorld_config)) ===="
|
||||
@${MAKE} --no-print-directory -C examples -f DemoTut01_HelloWorld.make config=$(DemoTut01_HelloWorld_config)
|
||||
endif
|
||||
|
||||
DemoTut02_Events: NazaraAudio NazaraCore NazaraGraphics NazaraLua NazaraNetwork NazaraNoise NazaraPhysics2D NazaraPhysics3D NazaraPlatform NazaraRenderer NazaraUtility NazaraSDK
|
||||
ifneq (,$(DemoTut02_Events_config))
|
||||
@echo "==== Building DemoTut02_Events ($(DemoTut02_Events_config)) ===="
|
||||
@${MAKE} --no-print-directory -C examples -f DemoTut02_Events.make config=$(DemoTut02_Events_config)
|
||||
endif
|
||||
|
||||
clean:
|
||||
@${MAKE} --no-print-directory -C thirdparty -f chipmunk.make clean
|
||||
@${MAKE} --no-print-directory -C thirdparty -f lua.make clean
|
||||
@${MAKE} --no-print-directory -C thirdparty -f stb_image.make clean
|
||||
@${MAKE} --no-print-directory -C modules -f NazaraAudio.make clean
|
||||
@${MAKE} --no-print-directory -C modules -f NazaraCore.make clean
|
||||
@${MAKE} --no-print-directory -C modules -f NazaraGraphics.make clean
|
||||
@${MAKE} --no-print-directory -C modules -f NazaraLua.make clean
|
||||
@${MAKE} --no-print-directory -C modules -f NazaraNetwork.make clean
|
||||
@${MAKE} --no-print-directory -C modules -f NazaraNoise.make clean
|
||||
@${MAKE} --no-print-directory -C modules -f NazaraPhysics2D.make clean
|
||||
@${MAKE} --no-print-directory -C modules -f NazaraPhysics3D.make clean
|
||||
@${MAKE} --no-print-directory -C modules -f NazaraPlatform.make clean
|
||||
@${MAKE} --no-print-directory -C modules -f NazaraRenderer.make clean
|
||||
@${MAKE} --no-print-directory -C modules -f NazaraUtility.make clean
|
||||
@${MAKE} --no-print-directory -C tools -f PluginAssimp.make clean
|
||||
@${MAKE} --no-print-directory -C tools -f NazaraSDK.make clean
|
||||
@${MAKE} --no-print-directory -C tools -f NazaraSDKServer.make clean
|
||||
@${MAKE} --no-print-directory -C tools -f NazaraUnitTests.make clean
|
||||
@${MAKE} --no-print-directory -C tools -f NazaraUnitTestsServer.make clean
|
||||
@${MAKE} --no-print-directory -C examples -f DemoDopplerEffect.make clean
|
||||
@${MAKE} --no-print-directory -C examples -f DemoFirstScene.make clean
|
||||
@${MAKE} --no-print-directory -C examples -f DemoHardwareInfo.make clean
|
||||
@${MAKE} --no-print-directory -C examples -f DemoMeshInfos.make clean
|
||||
@${MAKE} --no-print-directory -C examples -f DemoParticles.make clean
|
||||
@${MAKE} --no-print-directory -C examples -f DemoTut00_EmptyProject.make clean
|
||||
@${MAKE} --no-print-directory -C examples -f DemoTut01_HelloWorld.make clean
|
||||
@${MAKE} --no-print-directory -C examples -f DemoTut02_Events.make clean
|
||||
|
||||
help:
|
||||
@echo "Usage: make [config=name] [target]"
|
||||
@echo ""
|
||||
@echo "CONFIGURATIONS:"
|
||||
@echo " debugdynamic_x64"
|
||||
@echo " debugdynamic_x86"
|
||||
@echo " releasedynamic_x64"
|
||||
@echo " releasedynamic_x86"
|
||||
@echo ""
|
||||
@echo "TARGETS:"
|
||||
@echo " all (default)"
|
||||
@echo " clean"
|
||||
@echo " chipmunk"
|
||||
@echo " lua"
|
||||
@echo " stb_image"
|
||||
@echo " NazaraAudio"
|
||||
@echo " NazaraCore"
|
||||
@echo " NazaraGraphics"
|
||||
@echo " NazaraLua"
|
||||
@echo " NazaraNetwork"
|
||||
@echo " NazaraNoise"
|
||||
@echo " NazaraPhysics2D"
|
||||
@echo " NazaraPhysics3D"
|
||||
@echo " NazaraPlatform"
|
||||
@echo " NazaraRenderer"
|
||||
@echo " NazaraUtility"
|
||||
@echo " PluginAssimp"
|
||||
@echo " NazaraSDK"
|
||||
@echo " NazaraSDKServer"
|
||||
@echo " NazaraUnitTests"
|
||||
@echo " NazaraUnitTestsServer"
|
||||
@echo " DemoDopplerEffect"
|
||||
@echo " DemoFirstScene"
|
||||
@echo " DemoHardwareInfo"
|
||||
@echo " DemoMeshInfos"
|
||||
@echo " DemoParticles"
|
||||
@echo " DemoTut00_EmptyProject"
|
||||
@echo " DemoTut01_HelloWorld"
|
||||
@echo " DemoTut02_Events"
|
||||
@echo ""
|
||||
@echo "For more information, see http://industriousone.com/premake/quick-start"
|
||||
|
|
@ -27,6 +27,8 @@ TOOL.FilesExcluded = {
|
|||
"../SDK/**/CameraComponent.*",
|
||||
"../SDK/**/Canvas.*",
|
||||
"../SDK/**/Console.*",
|
||||
"../SDK/**/DebugComponent.*",
|
||||
"../SDK/**/DebugSystem.*",
|
||||
"../SDK/**/GraphicsComponent.*",
|
||||
"../SDK/**/LightComponent.*",
|
||||
"../SDK/**/ListenerComponent.*",
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@
|
|||
#include <Nazara/Core/StringStream.hpp>
|
||||
#include <Nazara/Core/TaskScheduler.hpp>
|
||||
#include <Nazara/Core/Thread.hpp>
|
||||
#include <Nazara/Core/TypeTag.hpp>
|
||||
#include <Nazara/Core/Unicode.hpp>
|
||||
#include <Nazara/Core/Updatable.hpp>
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ namespace Nz
|
|||
Buffer m_vertexBuffer;
|
||||
RenderStates m_clearStates;
|
||||
ShaderRef m_clearShader;
|
||||
Texture m_whiteTexture;
|
||||
TextureRef m_whiteTexture;
|
||||
VertexBuffer m_billboardPointBuffer;
|
||||
VertexBuffer m_spriteBuffer;
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ namespace Nz
|
|||
Buffer m_vertexBuffer;
|
||||
RenderStates m_clearStates;
|
||||
ShaderRef m_clearShader;
|
||||
Texture m_whiteTexture;
|
||||
TextureRef m_whiteTexture;
|
||||
VertexBuffer m_billboardPointBuffer;
|
||||
VertexBuffer m_spriteBuffer;
|
||||
mutable DepthRenderQueue m_renderQueue;
|
||||
|
|
|
|||
|
|
@ -88,13 +88,13 @@ namespace Nz
|
|||
mutable std::vector<std::pair<const VertexStruct_XYZ_Color_UV*, std::size_t>> m_spriteChains;
|
||||
Buffer m_vertexBuffer;
|
||||
mutable BasicRenderQueue m_renderQueue;
|
||||
Texture m_whiteTexture;
|
||||
TextureRef m_whiteCubemap;
|
||||
TextureRef m_whiteTexture;
|
||||
VertexBuffer m_billboardPointBuffer;
|
||||
VertexBuffer m_spriteBuffer;
|
||||
unsigned int m_maxLightPassPerObject;
|
||||
|
||||
static IndexBuffer s_quadIndexBuffer;
|
||||
static Texture s_dummyReflection;
|
||||
static TextureSampler s_reflectionSampler;
|
||||
static TextureSampler s_shadowSampler;
|
||||
static VertexBuffer s_quadVertexBuffer;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ namespace Nz
|
|||
virtual std::size_t GetGlyphCount() const = 0;
|
||||
virtual const Line& GetLine(std::size_t index) const = 0;
|
||||
virtual std::size_t GetLineCount() const = 0;
|
||||
inline std::size_t GetLineGlyphCount(std::size_t index) const;
|
||||
|
||||
struct Glyph
|
||||
{
|
||||
|
|
@ -53,4 +54,6 @@ namespace Nz
|
|||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/AbstractTextDrawer.inl>
|
||||
|
||||
#endif // NAZARA_ABSTRACTTEXTDRAWER_HPP
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Utility/AbstractTextDrawer.hpp>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline std::size_t AbstractTextDrawer::GetLineGlyphCount(std::size_t index) const
|
||||
{
|
||||
std::size_t lineCount = GetLineCount();
|
||||
const auto& lineInfo = GetLine(index);
|
||||
if (index == lineCount - 1)
|
||||
return GetGlyphCount() - lineInfo.glyphIndex;
|
||||
|
||||
const auto& nextLineInfo = GetLine(index + 1);
|
||||
|
||||
return nextLineInfo.glyphIndex - lineInfo.glyphIndex;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/DebugOff.hpp>
|
||||
|
|
@ -48,9 +48,7 @@ namespace Nz
|
|||
{
|
||||
ErrorFlags flags(ErrorFlag_ThrowException, true);
|
||||
|
||||
std::array<UInt8, 4> whitePixel = { { 255, 255, 255, 255 } };
|
||||
m_whiteTexture.Create(ImageType_2D, PixelFormatType_RGBA8, 1, 1);
|
||||
m_whiteTexture.Update(whitePixel.data());
|
||||
m_whiteTexture = Nz::TextureLibrary::Get("White2D");
|
||||
|
||||
m_vertexBuffer.Create(s_vertexBufferSize, DataStorage_Hardware, BufferUsage_Dynamic);
|
||||
|
||||
|
|
@ -87,6 +85,7 @@ namespace Nz
|
|||
|
||||
m_GBufferRTT->SetColorTargets({0, 1, 2}); // G-Buffer
|
||||
Renderer::SetTarget(m_GBufferRTT);
|
||||
Renderer::SetScissorRect(Recti(0, 0, m_dimensions.x, m_dimensions.y));
|
||||
Renderer::SetViewport(Recti(0, 0, m_dimensions.x, m_dimensions.y));
|
||||
|
||||
Renderer::SetRenderStates(m_clearStates);
|
||||
|
|
@ -576,7 +575,7 @@ namespace Nz
|
|||
lastMaterial = basicSprites.material;
|
||||
}
|
||||
|
||||
const Nz::Texture* overlayTexture = (basicSprites.overlay) ? basicSprites.overlay.Get() : &m_whiteTexture;
|
||||
const Nz::Texture* overlayTexture = (basicSprites.overlay) ? basicSprites.overlay.Get() : m_whiteTexture.Get();
|
||||
if (overlayTexture != lastOverlay)
|
||||
{
|
||||
Renderer::SetTexture(overlayTextureUnit, overlayTexture);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include <Nazara/Graphics/DepthRenderTechnique.hpp>
|
||||
#include <Nazara/Core/ErrorFlags.hpp>
|
||||
#include <Nazara/Core/OffsetOf.hpp>
|
||||
#include <Nazara/Graphics/AbstractBackground.hpp>
|
||||
#include <Nazara/Graphics/AbstractViewer.hpp>
|
||||
#include <Nazara/Graphics/Drawable.hpp>
|
||||
#include <Nazara/Graphics/Material.hpp>
|
||||
|
|
@ -49,9 +50,7 @@ namespace Nz
|
|||
{
|
||||
ErrorFlags flags(ErrorFlag_ThrowException, true);
|
||||
|
||||
std::array<UInt8, 4> whitePixel = { {255, 255, 255, 255} };
|
||||
m_whiteTexture.Create(ImageType_2D, PixelFormatType_RGBA8, 1, 1);
|
||||
m_whiteTexture.Update(whitePixel.data());
|
||||
m_whiteTexture = Nz::TextureLibrary::Get("White2D");
|
||||
|
||||
m_vertexBuffer.Create(s_vertexBufferSize, DataStorage_Hardware, BufferUsage_Dynamic);
|
||||
|
||||
|
|
@ -65,15 +64,20 @@ namespace Nz
|
|||
* \param sceneData Data of the scene
|
||||
*/
|
||||
|
||||
void DepthRenderTechnique::Clear(const SceneData& /*sceneData*/) const
|
||||
void DepthRenderTechnique::Clear(const SceneData& sceneData) const
|
||||
{
|
||||
const RenderTarget* renderTarget = sceneData.viewer->GetTarget();
|
||||
Recti fullscreenScissorRect = Recti(Vector2i(renderTarget->GetSize()));
|
||||
|
||||
Renderer::SetScissorRect(fullscreenScissorRect);
|
||||
|
||||
Renderer::Enable(RendererParameter_DepthBuffer, true);
|
||||
Renderer::Enable(RendererParameter_DepthWrite, true);
|
||||
Renderer::Clear(RendererBuffer_Depth);
|
||||
|
||||
// Just in case the background does render depth
|
||||
//if (sceneData.background)
|
||||
// sceneData.background->Draw(sceneData.viewer);
|
||||
if (sceneData.background)
|
||||
sceneData.background->Draw(sceneData.viewer);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -587,7 +591,7 @@ namespace Nz
|
|||
lastMaterial = basicSprites.material;
|
||||
}
|
||||
|
||||
const Nz::Texture* overlayTexture = (basicSprites.overlay) ? basicSprites.overlay.Get() : &m_whiteTexture;
|
||||
const Nz::Texture* overlayTexture = (basicSprites.overlay) ? basicSprites.overlay.Get() : m_whiteTexture.Get();
|
||||
if (overlayTexture != lastOverlay)
|
||||
{
|
||||
Renderer::SetTexture(overlayTextureUnit, overlayTexture);
|
||||
|
|
|
|||
|
|
@ -52,9 +52,8 @@ namespace Nz
|
|||
{
|
||||
ErrorFlags flags(ErrorFlag_ThrowException, true);
|
||||
|
||||
std::array<UInt8, 4> whitePixel = { {255, 255, 255, 255} };
|
||||
m_whiteTexture.Create(ImageType_2D, PixelFormatType_RGBA8, 1, 1);
|
||||
m_whiteTexture.Update(whitePixel.data());
|
||||
m_whiteCubemap = Nz::TextureLibrary::Get("WhiteCubemap");
|
||||
m_whiteTexture = Nz::TextureLibrary::Get("White2D");
|
||||
|
||||
m_vertexBuffer.Create(s_vertexBufferSize, DataStorage_Hardware, BufferUsage_Dynamic);
|
||||
|
||||
|
|
@ -70,6 +69,11 @@ namespace Nz
|
|||
|
||||
void ForwardRenderTechnique::Clear(const SceneData& sceneData) const
|
||||
{
|
||||
const RenderTarget* renderTarget = sceneData.viewer->GetTarget();
|
||||
Recti fullscreenScissorRect = Recti(Vector2i(renderTarget->GetSize()));
|
||||
|
||||
Renderer::SetScissorRect(fullscreenScissorRect);
|
||||
|
||||
Renderer::Enable(RendererParameter_DepthBuffer, true);
|
||||
Renderer::Enable(RendererParameter_DepthWrite, true);
|
||||
Renderer::Clear(RendererBuffer_Depth);
|
||||
|
|
@ -219,10 +223,6 @@ namespace Nz
|
|||
|
||||
s_shadowSampler.SetFilterMode(SamplerFilter_Bilinear);
|
||||
s_shadowSampler.SetWrapMode(SamplerWrap_Clamp);
|
||||
|
||||
std::array<UInt8, 6> whitePixels = { { 255, 255, 255, 255, 255, 255 } };
|
||||
s_dummyReflection.Create(ImageType_Cubemap, PixelFormatType_L8, 1, 1);
|
||||
s_dummyReflection.Update(whitePixels.data());
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
|
|
@ -239,7 +239,6 @@ namespace Nz
|
|||
|
||||
void ForwardRenderTechnique::Uninitialize()
|
||||
{
|
||||
s_dummyReflection.Destroy();
|
||||
s_quadIndexBuffer.Reset();
|
||||
s_quadVertexBuffer.Reset();
|
||||
}
|
||||
|
|
@ -247,7 +246,7 @@ namespace Nz
|
|||
/*!
|
||||
* \brief Chooses the nearest lights for one object
|
||||
*
|
||||
* \param object Sphere symbolising the object
|
||||
* \param object Sphere symbolizing the object
|
||||
* \param includeDirectionalLights Should directional lights be included in the computation
|
||||
*/
|
||||
|
||||
|
|
@ -726,7 +725,7 @@ namespace Nz
|
|||
lastMaterial = basicSprites.material;
|
||||
}
|
||||
|
||||
const Nz::Texture* overlayTexture = (basicSprites.overlay) ? basicSprites.overlay.Get() : &m_whiteTexture;
|
||||
const Nz::Texture* overlayTexture = (basicSprites.overlay) ? basicSprites.overlay.Get() : m_whiteTexture.Get();
|
||||
if (overlayTexture != lastOverlay)
|
||||
{
|
||||
Renderer::SetTexture(overlayTextureUnit, overlayTexture);
|
||||
|
|
@ -897,7 +896,6 @@ namespace Nz
|
|||
}
|
||||
|
||||
IndexBuffer ForwardRenderTechnique::s_quadIndexBuffer;
|
||||
Texture ForwardRenderTechnique::s_dummyReflection;
|
||||
TextureSampler ForwardRenderTechnique::s_reflectionSampler;
|
||||
TextureSampler ForwardRenderTechnique::s_shadowSampler;
|
||||
VertexBuffer ForwardRenderTechnique::s_quadVertexBuffer;
|
||||
|
|
|
|||
|
|
@ -156,6 +156,21 @@ namespace Nz
|
|||
|
||||
Font::SetDefaultAtlas(std::make_shared<GuillotineTextureAtlas>());
|
||||
|
||||
// Textures
|
||||
std::array<UInt8, 6> whitePixels = { { 255, 255, 255, 255, 255, 255 } };
|
||||
|
||||
Nz::TextureRef whiteTexture = Nz::Texture::New();
|
||||
whiteTexture->Create(ImageType_2D, PixelFormatType_L8, 1, 1);
|
||||
whiteTexture->Update(whitePixels.data());
|
||||
|
||||
TextureLibrary::Register("White2D", std::move(whiteTexture));
|
||||
|
||||
Nz::TextureRef whiteCubemap = Nz::Texture::New();
|
||||
whiteCubemap->Create(ImageType_Cubemap, PixelFormatType_L8, 1, 1);
|
||||
whiteCubemap->Update(whitePixels.data());
|
||||
|
||||
TextureLibrary::Register("WhiteCubemap", std::move(whiteCubemap));
|
||||
|
||||
onExit.Reset();
|
||||
|
||||
NazaraNotice("Initialized: Graphics module");
|
||||
|
|
@ -217,6 +232,10 @@ namespace Nz
|
|||
|
||||
defaultAtlas.reset();
|
||||
|
||||
// Textures
|
||||
TextureLibrary::Unregister("White2D");
|
||||
TextureLibrary::Unregister("WhiteCubemap");
|
||||
|
||||
// Loaders
|
||||
Loaders::UnregisterMesh();
|
||||
Loaders::UnregisterTexture();
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ namespace Nz
|
|||
pipelineInfo.blending = true;
|
||||
pipelineInfo.depthWrite = false;
|
||||
pipelineInfo.faceCulling = false;
|
||||
pipelineInfo.depthSorting = true;
|
||||
pipelineInfo.depthSorting = false;
|
||||
pipelineInfo.scissorTest = true;
|
||||
pipelineInfo.dstBlend = BlendFunc_InvSrcAlpha;
|
||||
pipelineInfo.srcBlend = BlendFunc_SrcAlpha;
|
||||
|
|
|
|||
|
|
@ -514,8 +514,16 @@ namespace Nz
|
|||
FontGlyph fontGlyph;
|
||||
if (ExtractGlyph(characterSize, character, style, &fontGlyph))
|
||||
{
|
||||
glyph.atlasRect.width = fontGlyph.image.GetWidth();
|
||||
glyph.atlasRect.height = fontGlyph.image.GetHeight();
|
||||
if (fontGlyph.image.IsValid())
|
||||
{
|
||||
glyph.atlasRect.width = fontGlyph.image.GetWidth();
|
||||
glyph.atlasRect.height = fontGlyph.image.GetHeight();
|
||||
}
|
||||
else
|
||||
{
|
||||
glyph.atlasRect.width = 0;
|
||||
glyph.atlasRect.height = 0;
|
||||
}
|
||||
|
||||
// Insertion du rectangle dans l'un des atlas
|
||||
if (glyph.atlasRect.width > 0 && glyph.atlasRect.height > 0) // Si l'image contient quelque chose
|
||||
|
|
|
|||
|
|
@ -354,42 +354,38 @@ namespace Nz
|
|||
{
|
||||
glyph.atlas = nullptr;
|
||||
|
||||
glyph.bounds.Set(float(m_drawPos.x), float(0.f), float(advance), float(sizeInfo.lineHeight));
|
||||
glyph.bounds.Set(float(m_drawPos.x), m_lines.back().bounds.y, float(advance), float(sizeInfo.lineHeight));
|
||||
|
||||
glyph.corners[0].Set(glyph.bounds.GetCorner(RectCorner_LeftTop));
|
||||
glyph.corners[1].Set(glyph.bounds.GetCorner(RectCorner_RightTop));
|
||||
glyph.corners[2].Set(glyph.bounds.GetCorner(RectCorner_LeftBottom));
|
||||
glyph.corners[3].Set(glyph.bounds.GetCorner(RectCorner_RightBottom));
|
||||
|
||||
switch (character)
|
||||
{
|
||||
case '\n':
|
||||
{
|
||||
// Extend the line bounding rect to the last glyph it contains, thus extending upon all glyphs of the line
|
||||
if (!m_glyphs.empty())
|
||||
{
|
||||
Glyph& lastGlyph = m_glyphs.back();
|
||||
m_lines.back().bounds.ExtendTo(lastGlyph.bounds);
|
||||
}
|
||||
|
||||
// Reset cursor
|
||||
advance = 0;
|
||||
m_drawPos.x = 0;
|
||||
m_drawPos.y += sizeInfo.lineHeight;
|
||||
|
||||
m_workingBounds.ExtendTo(m_lines.back().bounds);
|
||||
m_lines.emplace_back(Line{Rectf(0.f, float(sizeInfo.lineHeight * m_lines.size()), 0.f, float(sizeInfo.lineHeight)), m_glyphs.size() + 1});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_lines.back().bounds.ExtendTo(glyph.bounds);
|
||||
|
||||
switch (character)
|
||||
{
|
||||
case '\n':
|
||||
{
|
||||
// Reset cursor
|
||||
advance = 0;
|
||||
m_drawPos.x = 0;
|
||||
m_drawPos.y += sizeInfo.lineHeight;
|
||||
|
||||
m_workingBounds.ExtendTo(m_lines.back().bounds);
|
||||
m_lines.emplace_back(Line{Rectf(0.f, float(sizeInfo.lineHeight * m_lines.size()), 0.f, float(sizeInfo.lineHeight)), m_glyphs.size() + 1});
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
m_drawPos.x += advance;
|
||||
break;
|
||||
}
|
||||
|
||||
m_drawPos.x += advance;
|
||||
m_glyphs.push_back(glyph);
|
||||
}
|
||||
m_lines.back().bounds.ExtendTo(m_glyphs.back().bounds);
|
||||
|
||||
m_workingBounds.ExtendTo(m_lines.back().bounds);
|
||||
|
||||
m_bounds.Set(Rectf(std::floor(m_workingBounds.x), std::floor(m_workingBounds.y), std::ceil(m_workingBounds.width), std::ceil(m_workingBounds.height)));
|
||||
|
|
|
|||
Loading…
Reference in New Issue