Merge remote-tracking branch 'refs/remotes/origin/master' into vulkan
Former-commit-id: 2d7b8f2258dcb13272482a886aa88e780bffd307 [formerly ffaa87cb5564013addc8749dff6589f732ffe599] [formerly 6792cc9d7a87711eab92875da19bc4200e4463d6 [formerly 0a51ed831d274b1e325cc2efc57016094a7aee83]] Former-commit-id: b16416186770928262bc982969e9dbf10308d121 [formerly 92dc66185439cf46dcd3fb4672061d75d003d508] Former-commit-id: 34072644c9bf88918998070201d9b131ea5b3731
This commit is contained in:
commit
e9f888b550
|
|
@ -1,4 +1,5 @@
|
||||||
# Nazara build
|
# Nazara build
|
||||||
|
build/config.lua
|
||||||
examples/bin/*.exe
|
examples/bin/*.exe
|
||||||
examples/bin/*.pdb
|
examples/bin/*.pdb
|
||||||
examples/bin/*.dll
|
examples/bin/*.dll
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2016 Jérôme Leclercq
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
@ -28,13 +28,11 @@ namespace Ndk
|
||||||
template<typename ComponentType>
|
template<typename ComponentType>
|
||||||
ComponentIndex Component<ComponentType>::RegisterComponent(ComponentId id)
|
ComponentIndex Component<ComponentType>::RegisterComponent(ComponentId id)
|
||||||
{
|
{
|
||||||
// Il faut que notre composant possède un constructeur par défaut (pour la factory)
|
|
||||||
static_assert(std::is_default_constructible<ComponentType>::value, "ComponentType must be default-constructible");
|
|
||||||
|
|
||||||
// On utilise les lambda pour créer une fonction factory
|
// On utilise les lambda pour créer une fonction factory
|
||||||
auto factory = []() -> BaseComponent*
|
auto factory = []() -> BaseComponent*
|
||||||
{
|
{
|
||||||
return new ComponentType;
|
return nullptr; //< Temporary workaround to allow non-default-constructed components, will be updated for serialization
|
||||||
|
//return new ComponentType;
|
||||||
};
|
};
|
||||||
|
|
||||||
return BaseComponent::RegisterComponent(id, factory);
|
return BaseComponent::RegisterComponent(id, factory);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// This file was automatically generated on 01 Jun 2016 at 13:11:09
|
// This file was automatically generated on 30 Jul 2016 at 15:29:16
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
|
@ -11,6 +11,8 @@
|
||||||
#include <NDK/Components/LightComponent.hpp>
|
#include <NDK/Components/LightComponent.hpp>
|
||||||
#include <NDK/Components/ListenerComponent.hpp>
|
#include <NDK/Components/ListenerComponent.hpp>
|
||||||
#include <NDK/Components/NodeComponent.hpp>
|
#include <NDK/Components/NodeComponent.hpp>
|
||||||
|
#include <NDK/Components/ParticleEmitterComponent.hpp>
|
||||||
|
#include <NDK/Components/ParticleGroupComponent.hpp>
|
||||||
#include <NDK/Components/PhysicsComponent.hpp>
|
#include <NDK/Components/PhysicsComponent.hpp>
|
||||||
#include <NDK/Components/VelocityComponent.hpp>
|
#include <NDK/Components/VelocityComponent.hpp>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ namespace Ndk
|
||||||
|
|
||||||
struct Renderable
|
struct Renderable
|
||||||
{
|
{
|
||||||
Renderable(Nz::Matrix4f& transformMatrix) :
|
Renderable(const Nz::Matrix4f& transformMatrix) :
|
||||||
data(transformMatrix),
|
data(transformMatrix),
|
||||||
dataUpdated(false)
|
dataUpdated(false)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,11 @@ namespace Ndk
|
||||||
class NDK_API ListenerComponent : public Component<ListenerComponent>
|
class NDK_API ListenerComponent : public Component<ListenerComponent>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ListenerComponent();
|
inline ListenerComponent();
|
||||||
~ListenerComponent() = default;
|
~ListenerComponent() = default;
|
||||||
|
|
||||||
bool IsActive() const;
|
inline bool IsActive() const;
|
||||||
void SetActive(bool active = true);
|
inline void SetActive(bool active = true);
|
||||||
|
|
||||||
static ComponentIndex componentIndex;
|
static ComponentIndex componentIndex;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
// Copyright (C) 2015 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Development Kit"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef NDK_SERVER
|
||||||
|
#ifndef NDK_COMPONENTS_PARTICLEEMITTERCOMPONENT_HPP
|
||||||
|
#define NDK_COMPONENTS_PARTICLEEMITTERCOMPONENT_HPP
|
||||||
|
|
||||||
|
#include <Nazara/Graphics/ParticleEmitter.hpp>
|
||||||
|
#include <Nazara/Graphics/ParticleGroup.hpp>
|
||||||
|
#include <NDK/Component.hpp>
|
||||||
|
|
||||||
|
namespace Ndk
|
||||||
|
{
|
||||||
|
class NDK_API ParticleEmitterComponent : public Component<ParticleEmitterComponent>, public Nz::ParticleEmitter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using SetupFunc = std::function<void(const EntityHandle& /*entity*/, Nz::ParticleMapper& /*mapper*/, unsigned int /*count*/)>;
|
||||||
|
|
||||||
|
inline ParticleEmitterComponent();
|
||||||
|
ParticleEmitterComponent(const ParticleEmitterComponent& emitter) = default;
|
||||||
|
ParticleEmitterComponent(ParticleEmitterComponent&& emitter) = default;
|
||||||
|
~ParticleEmitterComponent() = default;
|
||||||
|
|
||||||
|
void Enable(bool active = true);
|
||||||
|
|
||||||
|
inline bool IsActive() const;
|
||||||
|
|
||||||
|
inline void SetSetupFunc(SetupFunc func);
|
||||||
|
|
||||||
|
static ComponentIndex componentIndex;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void SetupParticles(Nz::ParticleMapper& mapper, unsigned int count) const override;
|
||||||
|
|
||||||
|
SetupFunc m_setupFunc;
|
||||||
|
bool m_isActive;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <NDK/Components/ParticleEmitterComponent.inl>
|
||||||
|
|
||||||
|
#endif // NDK_COMPONENTS_PARTICLEEMITTERCOMPONENT_HPP
|
||||||
|
#endif // NDK_SERVER
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
// Copyright (C) 2015 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Development Kit"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
||||||
|
#include <NDK/Components/ParticleEmitterComponent.hpp>
|
||||||
|
|
||||||
|
namespace Ndk
|
||||||
|
{
|
||||||
|
inline ParticleEmitterComponent::ParticleEmitterComponent() :
|
||||||
|
m_isActive(true)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Ndk::ParticleEmitterComponent::Enable(bool active)
|
||||||
|
{
|
||||||
|
m_isActive = active;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool ParticleEmitterComponent::IsActive() const
|
||||||
|
{
|
||||||
|
return m_isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Ndk::ParticleEmitterComponent::SetSetupFunc(SetupFunc func)
|
||||||
|
{
|
||||||
|
m_setupFunc = std::move(func);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
// Copyright (C) 2015 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Development Kit"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef NDK_SERVER
|
||||||
|
#ifndef NDK_COMPONENTS_PARTICLEGROUPCOMPONENT_HPP
|
||||||
|
#define NDK_COMPONENTS_PARTICLEGROUPCOMPONENT_HPP
|
||||||
|
|
||||||
|
#include <Nazara/Graphics/ParticleGroup.hpp>
|
||||||
|
#include <NDK/Component.hpp>
|
||||||
|
|
||||||
|
namespace Ndk
|
||||||
|
{
|
||||||
|
class ParticleGroupComponent;
|
||||||
|
|
||||||
|
using ParticleGroupComponentHandle = Nz::ObjectHandle<ParticleGroupComponent>;
|
||||||
|
|
||||||
|
class NDK_API ParticleGroupComponent : public Component<ParticleGroupComponent>, public Nz::ParticleGroup
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
inline ParticleGroupComponent(unsigned int maxParticleCount, Nz::ParticleLayout layout);
|
||||||
|
inline ParticleGroupComponent(unsigned int maxParticleCount, Nz::ParticleDeclarationConstRef declaration);
|
||||||
|
ParticleGroupComponent(const ParticleGroupComponent&) = default;
|
||||||
|
~ParticleGroupComponent() = default;
|
||||||
|
|
||||||
|
static ComponentIndex componentIndex;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <NDK/Components/ParticleGroupComponent.inl>
|
||||||
|
|
||||||
|
#endif // NDK_COMPONENTS_PARTICLEGROUPCOMPONENT_HPP
|
||||||
|
#endif // NDK_SERVER
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
#include "ParticleGroupComponent.hpp"
|
||||||
|
// Copyright (C) 2015 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Development Kit"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
||||||
|
namespace Ndk
|
||||||
|
{
|
||||||
|
inline ParticleGroupComponent::ParticleGroupComponent(unsigned int maxParticleCount, Nz::ParticleLayout layout) :
|
||||||
|
ParticleGroup(maxParticleCount, layout)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ParticleGroupComponent::ParticleGroupComponent(unsigned int maxParticleCount, Nz::ParticleDeclarationConstRef declaration) :
|
||||||
|
ParticleGroup(maxParticleCount, std::move(declaration))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -13,11 +13,11 @@ namespace Ndk
|
||||||
{
|
{
|
||||||
class StateMachine;
|
class StateMachine;
|
||||||
|
|
||||||
class State
|
class NDK_API State
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
State() = default;
|
State() = default;
|
||||||
~State() = default;
|
virtual ~State();
|
||||||
|
|
||||||
virtual void Enter(StateMachine& fsm) = 0;
|
virtual void Enter(StateMachine& fsm) = 0;
|
||||||
virtual void Leave(StateMachine& fsm) = 0;
|
virtual void Leave(StateMachine& fsm) = 0;
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,8 @@ namespace Ndk
|
||||||
|
|
||||||
inline void ChangeState(std::shared_ptr<State> state);
|
inline void ChangeState(std::shared_ptr<State> state);
|
||||||
|
|
||||||
|
inline const std::shared_ptr<State>& GetCurrentState() const;
|
||||||
|
|
||||||
inline bool Update(float elapsedTime);
|
inline bool Update(float elapsedTime);
|
||||||
|
|
||||||
inline StateMachine& operator=(StateMachine&& fsm) = default;
|
inline StateMachine& operator=(StateMachine&& fsm) = default;
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,11 @@ namespace Ndk
|
||||||
m_nextState = std::move(state);
|
m_nextState = std::move(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline const std::shared_ptr<State>& StateMachine::GetCurrentState() const
|
||||||
|
{
|
||||||
|
return m_currentState;
|
||||||
|
}
|
||||||
|
|
||||||
inline bool StateMachine::Update(float elapsedTime)
|
inline bool StateMachine::Update(float elapsedTime)
|
||||||
{
|
{
|
||||||
if (m_nextState)
|
if (m_nextState)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// This file was automatically generated on 01 Jun 2016 at 13:11:09
|
// This file was automatically generated on 30 Jul 2016 at 15:29:16
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#define NDK_SYSTEMS_GLOBAL_HPP
|
#define NDK_SYSTEMS_GLOBAL_HPP
|
||||||
|
|
||||||
#include <NDK/Systems/ListenerSystem.hpp>
|
#include <NDK/Systems/ListenerSystem.hpp>
|
||||||
|
#include <NDK/Systems/ParticleSystem.hpp>
|
||||||
#include <NDK/Systems/PhysicsSystem.hpp>
|
#include <NDK/Systems/PhysicsSystem.hpp>
|
||||||
#include <NDK/Systems/RenderSystem.hpp>
|
#include <NDK/Systems/RenderSystem.hpp>
|
||||||
#include <NDK/Systems/VelocitySystem.hpp>
|
#include <NDK/Systems/VelocitySystem.hpp>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright (C) 2015 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Development Kit"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef NDK_SYSTEMS_PARTICLESYSTEM_HPP
|
||||||
|
#define NDK_SYSTEMS_PARTICLESYSTEM_HPP
|
||||||
|
|
||||||
|
#include <NDK/System.hpp>
|
||||||
|
|
||||||
|
namespace Ndk
|
||||||
|
{
|
||||||
|
class NDK_API ParticleSystem : public System<ParticleSystem>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ParticleSystem();
|
||||||
|
~ParticleSystem() = default;
|
||||||
|
|
||||||
|
static SystemIndex systemIndex;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void OnUpdate(float elapsedTime) override;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <NDK/Systems/ParticleSystem.inl>
|
||||||
|
|
||||||
|
#endif // NDK_SYSTEMS_PARTICLESYSTEM_HPP
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
// Copyright (C) 2015 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Development Kit"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
@ -60,6 +60,7 @@ namespace Ndk
|
||||||
EntityList m_directionalLights;
|
EntityList m_directionalLights;
|
||||||
EntityList m_lights;
|
EntityList m_lights;
|
||||||
EntityList m_pointSpotLights;
|
EntityList m_pointSpotLights;
|
||||||
|
EntityList m_particleGroups;
|
||||||
Nz::BackgroundRef m_background;
|
Nz::BackgroundRef m_background;
|
||||||
Nz::DepthRenderTechnique m_shadowTechnique;
|
Nz::DepthRenderTechnique m_shadowTechnique;
|
||||||
Nz::Matrix4f m_coordinateSystemMatrix;
|
Nz::Matrix4f m_coordinateSystemMatrix;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
// Copyright (C) 2015 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Development Kit"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
||||||
|
#include <NDK/Components/ParticleEmitterComponent.hpp>
|
||||||
|
#include <Nazara/Graphics/ParticleGroup.hpp>
|
||||||
|
|
||||||
|
namespace Ndk
|
||||||
|
{
|
||||||
|
void ParticleEmitterComponent::SetupParticles(Nz::ParticleMapper& mapper, unsigned int count) const
|
||||||
|
{
|
||||||
|
if (m_isActive && m_setupFunc)
|
||||||
|
m_setupFunc(m_entity, mapper, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
ComponentIndex ParticleEmitterComponent::componentIndex;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
// Copyright (C) 2015 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Development Kit"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
||||||
|
#include <NDK/Components/ParticleGroupComponent.hpp>
|
||||||
|
|
||||||
|
namespace Ndk
|
||||||
|
{
|
||||||
|
ComponentIndex ParticleGroupComponent::componentIndex;
|
||||||
|
}
|
||||||
|
|
@ -28,8 +28,8 @@ namespace Ndk
|
||||||
m_characterSize(24)
|
m_characterSize(24)
|
||||||
{
|
{
|
||||||
Nz::MaterialRef backgroundMaterial = Nz::Material::New();
|
Nz::MaterialRef backgroundMaterial = Nz::Material::New();
|
||||||
backgroundMaterial->Enable(Nz::RendererParameter_Blend, true);
|
backgroundMaterial->EnableBlending(true);
|
||||||
backgroundMaterial->Enable(Nz::RendererParameter_DepthBuffer, false);
|
backgroundMaterial->EnableDepthBuffer(false);
|
||||||
backgroundMaterial->SetDstBlend(Nz::BlendFunc_InvSrcAlpha);
|
backgroundMaterial->SetDstBlend(Nz::BlendFunc_InvSrcAlpha);
|
||||||
backgroundMaterial->SetSrcBlend(Nz::BlendFunc_SrcAlpha);
|
backgroundMaterial->SetSrcBlend(Nz::BlendFunc_SrcAlpha);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -205,7 +205,7 @@ namespace Ndk
|
||||||
{
|
{
|
||||||
case Nz::LuaType_Number:
|
case Nz::LuaType_Number:
|
||||||
{
|
{
|
||||||
long long index = lua.CheckInteger(1);
|
auto index = lua.CheckBoundInteger<std::size_t>(1);
|
||||||
if (index < 1 || index > 4)
|
if (index < 1 || index > 4)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -258,7 +258,7 @@ namespace Ndk
|
||||||
{
|
{
|
||||||
case Nz::LuaType_Number:
|
case Nz::LuaType_Number:
|
||||||
{
|
{
|
||||||
long long index = lua.CheckInteger(1);
|
auto index = lua.CheckBoundInteger<std::size_t>(1);
|
||||||
if (index < 1 || index > 4)
|
if (index < 1 || index > 4)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -537,11 +537,12 @@ namespace Ndk
|
||||||
case 0:
|
case 0:
|
||||||
case 3:
|
case 3:
|
||||||
Nz::PlacementNew(vector, lua.CheckNumber(1, 0.0), lua.CheckNumber(2, 0.0), lua.CheckNumber(3, 0.0));
|
Nz::PlacementNew(vector, lua.CheckNumber(1, 0.0), lua.CheckNumber(2, 0.0), lua.CheckNumber(3, 0.0));
|
||||||
|
return true;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
if (lua.IsOfType(1, Nz::LuaType_Number))
|
if (lua.IsOfType(1, Nz::LuaType_Number))
|
||||||
Nz::PlacementNew(vector, lua.CheckNumber(1), *static_cast<Nz::Vector2d*>(lua.ToUserdata(1)));
|
Nz::PlacementNew(vector, lua.CheckNumber(1), *static_cast<Nz::Vector2d*>(lua.CheckUserdata(1, "Vector2")));
|
||||||
else if (lua.IsOfType(1, "Vector2"))
|
else if (lua.IsOfType(1, "Vector2"))
|
||||||
Nz::PlacementNew(vector, *static_cast<Nz::Vector2d*>(lua.ToUserdata(1)));
|
Nz::PlacementNew(vector, *static_cast<Nz::Vector2d*>(lua.ToUserdata(1)));
|
||||||
else if (lua.IsOfType(1, "Vector3"))
|
else if (lua.IsOfType(1, "Vector3"))
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,9 @@
|
||||||
#include <NDK/Components/LightComponent.hpp>
|
#include <NDK/Components/LightComponent.hpp>
|
||||||
#include <NDK/Components/ListenerComponent.hpp>
|
#include <NDK/Components/ListenerComponent.hpp>
|
||||||
#include <NDK/Components/GraphicsComponent.hpp>
|
#include <NDK/Components/GraphicsComponent.hpp>
|
||||||
|
#include <NDK/Components/ParticleEmitterComponent.hpp>
|
||||||
|
#include <NDK/Components/ParticleGroupComponent.hpp>
|
||||||
|
#include <NDK/Systems/ParticleSystem.hpp>
|
||||||
#include <NDK/Systems/ListenerSystem.hpp>
|
#include <NDK/Systems/ListenerSystem.hpp>
|
||||||
#include <NDK/Systems/RenderSystem.hpp>
|
#include <NDK/Systems/RenderSystem.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -71,6 +74,8 @@ namespace Ndk
|
||||||
InitializeComponent<LightComponent>("NdkLight");
|
InitializeComponent<LightComponent>("NdkLight");
|
||||||
InitializeComponent<ListenerComponent>("NdkList");
|
InitializeComponent<ListenerComponent>("NdkList");
|
||||||
InitializeComponent<GraphicsComponent>("NdkGfx");
|
InitializeComponent<GraphicsComponent>("NdkGfx");
|
||||||
|
InitializeComponent<ParticleEmitterComponent>("NdkPaEmi");
|
||||||
|
InitializeComponent<ParticleGroupComponent>("NdkPaGrp");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Systems
|
// Systems
|
||||||
|
|
@ -84,6 +89,7 @@ namespace Ndk
|
||||||
#ifndef NDK_SERVER
|
#ifndef NDK_SERVER
|
||||||
// Client systems
|
// Client systems
|
||||||
InitializeSystem<ListenerSystem>();
|
InitializeSystem<ListenerSystem>();
|
||||||
|
InitializeSystem<ParticleSystem>();
|
||||||
InitializeSystem<RenderSystem>();
|
InitializeSystem<RenderSystem>();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
// Copyright (C) 2016 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Development Kit"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
||||||
|
#include <NDK/State.hpp>
|
||||||
|
|
||||||
|
namespace Ndk
|
||||||
|
{
|
||||||
|
State::~State() = default;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
// Copyright (C) 2015 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Development Kit"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
||||||
|
#include <NDK/Systems/ParticleSystem.hpp>
|
||||||
|
#include <NDK/Components/ParticleGroupComponent.hpp>
|
||||||
|
|
||||||
|
namespace Ndk
|
||||||
|
{
|
||||||
|
ParticleSystem::ParticleSystem()
|
||||||
|
{
|
||||||
|
Requires<ParticleGroupComponent>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ParticleSystem::OnUpdate(float elapsedTime)
|
||||||
|
{
|
||||||
|
for (const Ndk::EntityHandle& entity : GetEntities())
|
||||||
|
{
|
||||||
|
ParticleGroupComponent& group = entity->GetComponent<ParticleGroupComponent>();
|
||||||
|
|
||||||
|
group.Update(elapsedTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SystemIndex ParticleSystem::systemIndex;
|
||||||
|
}
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#include <NDK/Components/GraphicsComponent.hpp>
|
#include <NDK/Components/GraphicsComponent.hpp>
|
||||||
#include <NDK/Components/LightComponent.hpp>
|
#include <NDK/Components/LightComponent.hpp>
|
||||||
#include <NDK/Components/NodeComponent.hpp>
|
#include <NDK/Components/NodeComponent.hpp>
|
||||||
|
#include <NDK/Components/ParticleGroupComponent.hpp>
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
|
|
@ -25,8 +26,11 @@ namespace Ndk
|
||||||
void RenderSystem::OnEntityRemoved(Entity* entity)
|
void RenderSystem::OnEntityRemoved(Entity* entity)
|
||||||
{
|
{
|
||||||
m_cameras.Remove(entity);
|
m_cameras.Remove(entity);
|
||||||
|
m_directionalLights.Remove(entity);
|
||||||
m_drawables.Remove(entity);
|
m_drawables.Remove(entity);
|
||||||
m_lights.Remove(entity);
|
m_lights.Remove(entity);
|
||||||
|
m_particleGroups.Remove(entity);
|
||||||
|
m_pointSpotLights.Remove(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderSystem::OnEntityValidation(Entity* entity, bool justAdded)
|
void RenderSystem::OnEntityValidation(Entity* entity, bool justAdded)
|
||||||
|
|
@ -71,6 +75,11 @@ namespace Ndk
|
||||||
m_lights.Remove(entity);
|
m_lights.Remove(entity);
|
||||||
m_pointSpotLights.Remove(entity);
|
m_pointSpotLights.Remove(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (entity->HasComponent<ParticleGroupComponent>())
|
||||||
|
m_particleGroups.Insert(entity);
|
||||||
|
else
|
||||||
|
m_particleGroups.Remove(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderSystem::OnUpdate(float elapsedTime)
|
void RenderSystem::OnUpdate(float elapsedTime)
|
||||||
|
|
@ -118,6 +127,13 @@ namespace Ndk
|
||||||
lightComponent.AddToRenderQueue(renderQueue, Nz::Matrix4f::ConcatenateAffine(m_coordinateSystemMatrix, lightNode.GetTransformMatrix()));
|
lightComponent.AddToRenderQueue(renderQueue, Nz::Matrix4f::ConcatenateAffine(m_coordinateSystemMatrix, lightNode.GetTransformMatrix()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const Ndk::EntityHandle& particleGroup : m_particleGroups)
|
||||||
|
{
|
||||||
|
ParticleGroupComponent& groupComponent = particleGroup->GetComponent<ParticleGroupComponent>();
|
||||||
|
|
||||||
|
groupComponent.AddToRenderQueue(renderQueue, Nz::Matrix4f::Identity()); //< ParticleGroup doesn't use Matrix4f
|
||||||
|
}
|
||||||
|
|
||||||
camComponent.ApplyView();
|
camComponent.ApplyView();
|
||||||
|
|
||||||
Nz::SceneData sceneData;
|
Nz::SceneData sceneData;
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#ifndef NDK_SERVER
|
#ifndef NDK_SERVER
|
||||||
#include <NDK/Systems/ListenerSystem.hpp>
|
#include <NDK/Systems/ListenerSystem.hpp>
|
||||||
|
#include <NDK/Systems/ParticleSystem.hpp>
|
||||||
#include <NDK/Systems/RenderSystem.hpp>
|
#include <NDK/Systems/RenderSystem.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -27,6 +28,7 @@ namespace Ndk
|
||||||
|
|
||||||
#ifndef NDK_SERVER
|
#ifndef NDK_SERVER
|
||||||
AddSystem<ListenerSystem>();
|
AddSystem<ListenerSystem>();
|
||||||
|
AddSystem<ParticleSystem>();
|
||||||
AddSystem<RenderSystem>();
|
AddSystem<RenderSystem>();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
premake4 --with-extlibs --with-examples codeblocks
|
premake4 codeblocks
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
premake4 --united --with-extlibs --with-examples codeblocks
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
premake5 --with-extlibs --with-examples codelite
|
premake5 codelite
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
premake5 --united --with-extlibs --with-examples codelite
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
premake5 --with-extlibs --with-examples vs2015
|
premake5 vs2015
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
premake5 --united --with-extlibs --with-examples vs2015
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
-- This file contains special configurations values, such as directories to extern libraries (Qt)
|
||||||
|
-- Editing this file is not required to use/compile the engine, as default values should be enough
|
||||||
|
|
||||||
|
-- Builds Nazara extern libraries (such as lua/STB)
|
||||||
|
BuildDependencies = true
|
||||||
|
|
||||||
|
-- Builds Nazara examples
|
||||||
|
BuildExamples = true
|
||||||
|
|
||||||
|
-- Setup additionnals install directories, separated by a semi-colon ; (library binaries will be copied there)
|
||||||
|
--InstallDir = "/usr/local/lib64"
|
||||||
|
|
||||||
|
-- Excludes client-only modules/tools/examples
|
||||||
|
ServerMode = false
|
||||||
|
|
||||||
|
-- Builds modules as one united library (useless on POSIX systems)
|
||||||
|
UniteModules = false
|
||||||
|
|
@ -24,7 +24,7 @@ function NazaraBuild:Execute()
|
||||||
if (self.Actions[_ACTION] == nil) then
|
if (self.Actions[_ACTION] == nil) then
|
||||||
local makeLibDir = os.is("windows") and "mingw" or "gmake"
|
local makeLibDir = os.is("windows") and "mingw" or "gmake"
|
||||||
|
|
||||||
if (_OPTIONS["with-extlibs"]) then
|
if (self.Config["BuildDependencies"]) then
|
||||||
workspace("NazaraExtlibs")
|
workspace("NazaraExtlibs")
|
||||||
platforms(platformData)
|
platforms(platformData)
|
||||||
|
|
||||||
|
|
@ -39,12 +39,6 @@ function NazaraBuild:Execute()
|
||||||
location(_ACTION)
|
location(_ACTION)
|
||||||
kind("StaticLib")
|
kind("StaticLib")
|
||||||
|
|
||||||
configuration("x32")
|
|
||||||
libdirs("../extlibs/lib/common/x86")
|
|
||||||
|
|
||||||
configuration("x64")
|
|
||||||
libdirs("../extlibs/lib/common/x64")
|
|
||||||
|
|
||||||
configuration({"codeblocks or codelite or gmake", "x32"})
|
configuration({"codeblocks or codelite or gmake", "x32"})
|
||||||
libdirs("../extlibs/lib/" .. makeLibDir .. "/x86")
|
libdirs("../extlibs/lib/" .. makeLibDir .. "/x86")
|
||||||
targetdir("../extlibs/lib/" .. makeLibDir .. "/x86")
|
targetdir("../extlibs/lib/" .. makeLibDir .. "/x86")
|
||||||
|
|
@ -111,6 +105,12 @@ function NazaraBuild:Execute()
|
||||||
includedirs(libTable.Includes)
|
includedirs(libTable.Includes)
|
||||||
links(libTable.Libraries)
|
links(libTable.Libraries)
|
||||||
|
|
||||||
|
configuration("x32")
|
||||||
|
libdirs(libTable.LibraryPaths.x86)
|
||||||
|
|
||||||
|
configuration("x64")
|
||||||
|
libdirs(libTable.LibraryPaths.x64)
|
||||||
|
|
||||||
for k,v in pairs(libTable.ConfigurationLibraries) do
|
for k,v in pairs(libTable.ConfigurationLibraries) do
|
||||||
configuration(k)
|
configuration(k)
|
||||||
links(v)
|
links(v)
|
||||||
|
|
@ -188,11 +188,11 @@ function NazaraBuild:Execute()
|
||||||
libdirs("../extlibs/lib/common")
|
libdirs("../extlibs/lib/common")
|
||||||
|
|
||||||
configuration("x32")
|
configuration("x32")
|
||||||
libdirs("../extlibs/lib/common/x86")
|
libdirs(moduleTable.LibraryPaths.x86)
|
||||||
|
|
||||||
configuration("x64")
|
configuration("x64")
|
||||||
defines("NAZARA_PLATFORM_x64")
|
defines("NAZARA_PLATFORM_x64")
|
||||||
libdirs("../extlibs/lib/common/x64")
|
libdirs(moduleTable.LibraryPaths.x64)
|
||||||
|
|
||||||
configuration({"codeblocks or codelite or gmake", "x32"})
|
configuration({"codeblocks or codelite or gmake", "x32"})
|
||||||
libdirs("../extlibs/lib/" .. makeLibDir .. "/x86")
|
libdirs("../extlibs/lib/" .. makeLibDir .. "/x86")
|
||||||
|
|
@ -297,11 +297,11 @@ function NazaraBuild:Execute()
|
||||||
libdirs("../extlibs/lib/common")
|
libdirs("../extlibs/lib/common")
|
||||||
|
|
||||||
configuration("x32")
|
configuration("x32")
|
||||||
libdirs("../extlibs/lib/common/x86")
|
libdirs(toolTable.LibraryPaths.x86)
|
||||||
|
|
||||||
configuration("x64")
|
configuration("x64")
|
||||||
defines("NAZARA_PLATFORM_x64")
|
defines("NAZARA_PLATFORM_x64")
|
||||||
libdirs("../extlibs/lib/common/x64")
|
libdirs(toolTable.LibraryPaths.x64)
|
||||||
|
|
||||||
configuration({"codeblocks or codelite or gmake", "x32"})
|
configuration({"codeblocks or codelite or gmake", "x32"})
|
||||||
libdirs("../extlibs/lib/" .. makeLibDir .. "/x86")
|
libdirs("../extlibs/lib/" .. makeLibDir .. "/x86")
|
||||||
|
|
@ -431,11 +431,11 @@ function NazaraBuild:Execute()
|
||||||
links(exampleTable.Libraries)
|
links(exampleTable.Libraries)
|
||||||
|
|
||||||
configuration("x32")
|
configuration("x32")
|
||||||
libdirs("../extlibs/lib/common/x86")
|
libdirs(exampleTable.LibraryPaths.x86)
|
||||||
|
|
||||||
configuration("x64")
|
configuration("x64")
|
||||||
defines("NAZARA_PLATFORM_x64")
|
defines("NAZARA_PLATFORM_x64")
|
||||||
libdirs("../extlibs/lib/common/x64")
|
libdirs(exampleTable.LibraryPaths.x64)
|
||||||
|
|
||||||
configuration({"codeblocks or codelite or gmake", "x32"})
|
configuration({"codeblocks or codelite or gmake", "x32"})
|
||||||
libdirs("../lib/" .. makeLibDir .. "/x86")
|
libdirs("../lib/" .. makeLibDir .. "/x86")
|
||||||
|
|
@ -465,33 +465,29 @@ function NazaraBuild:Execute()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function NazaraBuild:GetConfig()
|
||||||
|
return self.Config
|
||||||
|
end
|
||||||
|
|
||||||
|
function NazaraBuild:GetDependency(infoTable, name)
|
||||||
|
local projectName = name:match("Nazara(%w+)")
|
||||||
|
if (projectName) then
|
||||||
|
-- tool or module
|
||||||
|
local moduleTable = self.Modules[projectName:lower()]
|
||||||
|
if (moduleTable) then
|
||||||
|
return moduleTable
|
||||||
|
else
|
||||||
|
local toolTable = self.Tools[projectName:lower()]
|
||||||
|
if (toolTable) then
|
||||||
|
return toolTable
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return self.ExtLibs[name:lower()]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function NazaraBuild:Initialize()
|
function NazaraBuild:Initialize()
|
||||||
-- Commençons par les options
|
|
||||||
newoption({
|
|
||||||
trigger = "install-path",
|
|
||||||
description = "Setup additionnals install directories (library binaries will be copied there)"
|
|
||||||
})
|
|
||||||
|
|
||||||
newoption({
|
|
||||||
trigger = "server",
|
|
||||||
description = "Excludes client-only modules/tools/examples"
|
|
||||||
})
|
|
||||||
|
|
||||||
newoption({
|
|
||||||
trigger = "united",
|
|
||||||
description = "Builds all the modules as one united library"
|
|
||||||
})
|
|
||||||
|
|
||||||
newoption({
|
|
||||||
trigger = "with-extlibs",
|
|
||||||
description = "Builds the extern libraries"
|
|
||||||
})
|
|
||||||
|
|
||||||
newoption({
|
|
||||||
trigger = "with-examples",
|
|
||||||
description = "Builds the examples"
|
|
||||||
})
|
|
||||||
|
|
||||||
self.Actions = {}
|
self.Actions = {}
|
||||||
self.Examples = {}
|
self.Examples = {}
|
||||||
self.ExecutableDir = {}
|
self.ExecutableDir = {}
|
||||||
|
|
@ -500,12 +496,8 @@ function NazaraBuild:Initialize()
|
||||||
self.Modules = {}
|
self.Modules = {}
|
||||||
self.Tools = {}
|
self.Tools = {}
|
||||||
|
|
||||||
if (_OPTIONS["install-path"]) then
|
self.Config = {}
|
||||||
local paths = string.explode(_OPTIONS["install-path"], ";")
|
self:LoadConfig()
|
||||||
for k,v in pairs(paths) do
|
|
||||||
self:AddInstallPath(v)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Actions
|
-- Actions
|
||||||
modules = os.matchfiles("scripts/actions/*.lua")
|
modules = os.matchfiles("scripts/actions/*.lua")
|
||||||
|
|
@ -593,7 +585,7 @@ function NazaraBuild:Initialize()
|
||||||
TOOL = nil
|
TOOL = nil
|
||||||
|
|
||||||
-- Examples
|
-- Examples
|
||||||
if (_OPTIONS["with-examples"]) then
|
if (self.Config["BuildExamples"]) then
|
||||||
local examples = os.matchdirs("../examples/*")
|
local examples = os.matchdirs("../examples/*")
|
||||||
for k,v in pairs(examples) do
|
for k,v in pairs(examples) do
|
||||||
local dirName = v:match(".*/(.*)")
|
local dirName = v:match(".*/(.*)")
|
||||||
|
|
@ -643,6 +635,235 @@ function NazaraBuild:Initialize()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function NazaraBuild:LoadConfig()
|
||||||
|
local f = io.open("config.lua", "r")
|
||||||
|
if (f) then
|
||||||
|
local content = f:read("*a")
|
||||||
|
f:close()
|
||||||
|
|
||||||
|
local func, err = loadstring(content)
|
||||||
|
if (func) then
|
||||||
|
setfenv(func, self.Config)
|
||||||
|
|
||||||
|
local status, err = pcall(func)
|
||||||
|
if (not status) then
|
||||||
|
print("Failed to load config.lua: " .. err)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
print("Failed to parse config.lua: " .. err)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
print("Failed to open config.lua")
|
||||||
|
end
|
||||||
|
|
||||||
|
local configTable = self.Config
|
||||||
|
local AddBoolOption = function (option, name, description)
|
||||||
|
newoption({
|
||||||
|
trigger = name,
|
||||||
|
description = description
|
||||||
|
})
|
||||||
|
|
||||||
|
local str = _OPTIONS[name]
|
||||||
|
if (str) then
|
||||||
|
if (#str == 0 or str == "1" or str == "yes" or str == "true") then
|
||||||
|
configTable[option] = true
|
||||||
|
elseif (str == "0" or str == "no" or str == "false") then
|
||||||
|
configTable[option] = false
|
||||||
|
else
|
||||||
|
error("Invalid entry for " .. name .. " option: \"" .. str .. "\"")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
AddBoolOption("BuildDependencies", "with-extlibs", "Builds the extern libraries")
|
||||||
|
AddBoolOption("BuildExamples", "with-examples", "Builds the examples")
|
||||||
|
AddBoolOption("ServerMode", "server", "Excludes client-only modules/tools/examples")
|
||||||
|
AddBoolOption("UniteModules", "united", "Builds all the modules as one united library")
|
||||||
|
|
||||||
|
-- InstallDir
|
||||||
|
newoption({
|
||||||
|
trigger = "install-path",
|
||||||
|
description = "Setup additionnals install directories (library binaries will be copied there)"
|
||||||
|
})
|
||||||
|
|
||||||
|
self.Config["InstallDir"] = self.Config["InstallDir"] or ""
|
||||||
|
if (_OPTIONS["install-path"] ~= nil) then
|
||||||
|
self.Config["InstallDir"] = self.Config["InstallDir"] .. ";" .. _OPTIONS["install-path"]
|
||||||
|
end
|
||||||
|
|
||||||
|
local paths = string.explode(self.Config["InstallDir"], ";")
|
||||||
|
for k,v in pairs(paths) do
|
||||||
|
if (#v > 0) then
|
||||||
|
self:AddInstallPath(v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function NazaraBuild:MakeInstallCommands(infoTable)
|
||||||
|
if (PremakeVersion < 50) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if (os.is("windows")) then
|
||||||
|
configuration({})
|
||||||
|
|
||||||
|
for k,v in pairs(self.InstallDir) do
|
||||||
|
local destPath = path.translate(path.isabsolute(k) and k or "../../" .. k)
|
||||||
|
postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath):sub(1, -5) .. ".dll"}" "]] .. destPath .. [[\" /E /Y]]})
|
||||||
|
end
|
||||||
|
|
||||||
|
for k,fileName in pairs(table.join(infoTable.Libraries, infoTable.DynLib)) do
|
||||||
|
local paths = {}
|
||||||
|
for k,v in pairs(infoTable.BinaryPaths.x86) do
|
||||||
|
table.insert(paths, {"x32", v .. "/" .. fileName .. ".dll"})
|
||||||
|
table.insert(paths, {"x32", v .. "/lib" .. fileName .. ".dll"})
|
||||||
|
end
|
||||||
|
|
||||||
|
for k,v in pairs(infoTable.BinaryPaths.x64) do
|
||||||
|
table.insert(paths, {"x64", v .. "/" .. fileName .. ".dll"})
|
||||||
|
table.insert(paths, {"x64", v .. "/lib" .. fileName .. ".dll"})
|
||||||
|
end
|
||||||
|
|
||||||
|
for k,v in pairs(paths) do
|
||||||
|
local config = v[1]
|
||||||
|
local srcPath = v[2]
|
||||||
|
if (os.isfile(srcPath)) then
|
||||||
|
if (infoTable.Kind == "plugin") then
|
||||||
|
srcPath = "../../" .. srcPath
|
||||||
|
end
|
||||||
|
|
||||||
|
configuration(config)
|
||||||
|
|
||||||
|
for k,v in pairs(self.ExecutableDir) do
|
||||||
|
local srcPath = path.isabsolute(srcPath) and path.translate(srcPath) or [[%{path.translate(cfg.linktarget.relpath:sub(1, -#cfg.linktarget.name - 1) .. "../../]] .. srcPath .. [[")}]]
|
||||||
|
local destPath = path.translate(path.isabsolute(k) and k or "../../" .. k)
|
||||||
|
postbuildcommands({[[xcopy "]] .. srcPath .. [[" "]] .. destPath .. [[\" /E /Y]]})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local PosixOSes = {
|
||||||
|
["bsd"] = true,
|
||||||
|
["linux"] = true,
|
||||||
|
["macosx"] = true,
|
||||||
|
["solaris"] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function NazaraBuild:Process(infoTable)
|
||||||
|
local libraries = {}
|
||||||
|
for k, library in pairs(infoTable.Libraries) do
|
||||||
|
local libraryTable = self:GetDependency(infoTable, library)
|
||||||
|
if (libraryTable) then
|
||||||
|
if (libraryTable.Excluded) then
|
||||||
|
infoTable.Excluded = true
|
||||||
|
infoTable.ExcludeReason = "depends on excluded " .. library .. " " .. libraryTable.Type:lower()
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if (libraryTable.Type == "Module") then
|
||||||
|
if (_OPTIONS["united"]) then
|
||||||
|
library = "NazaraEngine"
|
||||||
|
else
|
||||||
|
library = "Nazara" .. libraryTable.Name
|
||||||
|
end
|
||||||
|
|
||||||
|
if (not self.Config["UniteModules"] or infoTable.Type ~= "Module") then
|
||||||
|
table.insert(infoTable.ConfigurationLibraries.DebugStatic, library .. "-s-d")
|
||||||
|
table.insert(infoTable.ConfigurationLibraries.ReleaseStatic, library .. "-s")
|
||||||
|
table.insert(infoTable.ConfigurationLibraries.DebugDynamic, library .. "-d")
|
||||||
|
table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library)
|
||||||
|
end
|
||||||
|
elseif (libraryTable.Type == "ExternLib") then
|
||||||
|
library = libraryTable.Name
|
||||||
|
|
||||||
|
table.insert(infoTable.ConfigurationLibraries.DebugStatic, library .. "-s-d")
|
||||||
|
table.insert(infoTable.ConfigurationLibraries.ReleaseStatic, library .. "-s")
|
||||||
|
table.insert(infoTable.ConfigurationLibraries.DebugDynamic, library .. "-s-d")
|
||||||
|
table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library .. "-s")
|
||||||
|
elseif (libraryTable.Type == "Tool") then
|
||||||
|
library = "Nazara" .. libraryTable.Name
|
||||||
|
|
||||||
|
-- Import tools includes
|
||||||
|
for k,v in ipairs(libraryTable.Includes) do
|
||||||
|
table.insert(infoTable.Includes, v)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- And libraries
|
||||||
|
for k, v in pairs(libraryTable.Libraries) do
|
||||||
|
table.insert(infoTable.Libraries, v)
|
||||||
|
end
|
||||||
|
|
||||||
|
for config, libs in pairs(libraryTable.ConfigurationLibraries) do
|
||||||
|
for k,v in pairs(libs) do
|
||||||
|
table.insert(infoTable.ConfigurationLibraries[config], v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(infoTable.ConfigurationLibraries.DebugStatic, library .. "-s-d")
|
||||||
|
table.insert(infoTable.ConfigurationLibraries.ReleaseStatic, library .. "-s")
|
||||||
|
table.insert(infoTable.ConfigurationLibraries.DebugDynamic, library .. "-d")
|
||||||
|
table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library)
|
||||||
|
else
|
||||||
|
infoTable.Excluded = true
|
||||||
|
infoTable.ExcludeReason = "dependency " .. library .. " has invalid type \"" .. libraryTable.Type .. "\""
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
else
|
||||||
|
table.insert(libraries, library)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
infoTable.Libraries = libraries
|
||||||
|
|
||||||
|
for k,v in pairs(infoTable) do
|
||||||
|
local target = k:match("Os(%w+)")
|
||||||
|
if (target) then
|
||||||
|
local targetTable = infoTable[target]
|
||||||
|
if (targetTable) then
|
||||||
|
local excludeTargetTable = infoTable[target .. "Excluded"]
|
||||||
|
for platform, defineTable in pairs(v) do
|
||||||
|
platform = string.lower(platform)
|
||||||
|
if (platform == "posix") then
|
||||||
|
local osname = os.get()
|
||||||
|
if (PosixOSes[osname]) then
|
||||||
|
platform = osname
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if (os.is(platform)) then
|
||||||
|
for k,v in ipairs(defineTable) do
|
||||||
|
table.insert(targetTable, v)
|
||||||
|
end
|
||||||
|
elseif (excludeTargetTable) then
|
||||||
|
for k,v in ipairs(defineTable) do
|
||||||
|
table.insert(excludeTargetTable, v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
infoTable[k] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if (infoTable.Kind == "application") then
|
||||||
|
self:AddExecutablePath(infoTable.TargetDirectory)
|
||||||
|
end
|
||||||
|
|
||||||
|
if (infoTable.Validate) then
|
||||||
|
local ret, err = infoTable:Validate()
|
||||||
|
if (not ret) then
|
||||||
|
infoTable.Excluded = true
|
||||||
|
infoTable.ExcludeReason = "validation failed: " .. err
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
function NazaraBuild:RegisterAction(actionTable)
|
function NazaraBuild:RegisterAction(actionTable)
|
||||||
if (actionTable.Name == nil or type(actionTable.Name) ~= "string" or string.len(actionTable.Name) == 0) then
|
if (actionTable.Name == nil or type(actionTable.Name) ~= "string" or string.len(actionTable.Name) == 0) then
|
||||||
return false, "Invalid action name"
|
return false, "Invalid action name"
|
||||||
|
|
@ -750,7 +971,7 @@ function NazaraBuild:RegisterModule(moduleTable)
|
||||||
table.insert(moduleTable.Files, "../src/Nazara/" .. moduleTable.Name .. "/**.inl")
|
table.insert(moduleTable.Files, "../src/Nazara/" .. moduleTable.Name .. "/**.inl")
|
||||||
table.insert(moduleTable.Files, "../src/Nazara/" .. moduleTable.Name .. "/**.cpp")
|
table.insert(moduleTable.Files, "../src/Nazara/" .. moduleTable.Name .. "/**.cpp")
|
||||||
|
|
||||||
if (_OPTIONS["united"] and lowerCaseName ~= "core") then
|
if (self.Config["UniteModules"] and lowerCaseName ~= "core") then
|
||||||
table.insert(moduleTable.FilesExcluded, "../src/Nazara/" .. moduleTable.Name .. "/Debug/NewOverload.cpp")
|
table.insert(moduleTable.FilesExcluded, "../src/Nazara/" .. moduleTable.Name .. "/Debug/NewOverload.cpp")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -789,132 +1010,8 @@ function NazaraBuild:RegisterTool(toolTable)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
local PosixOSes = {
|
|
||||||
["bsd"] = true,
|
|
||||||
["linux"] = true,
|
|
||||||
["macosx"] = true,
|
|
||||||
["solaris"] = true
|
|
||||||
}
|
|
||||||
|
|
||||||
function NazaraBuild:Process(infoTable)
|
|
||||||
local libraries = {}
|
|
||||||
for k, library in pairs(infoTable.Libraries) do
|
|
||||||
local projectName = library:match("Nazara(%w+)")
|
|
||||||
local moduleTable = projectName and self.Modules[projectName:lower()]
|
|
||||||
local toolTable = projectName and self.Tools[projectName:lower()]
|
|
||||||
|
|
||||||
if (moduleTable) then
|
|
||||||
if (moduleTable.Excluded) then
|
|
||||||
infoTable.Excluded = true
|
|
||||||
infoTable.ExcludeReason = "depends on excluded " .. projectName .. " module"
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
if (_OPTIONS["united"]) then
|
|
||||||
library = "NazaraEngine"
|
|
||||||
else
|
|
||||||
library = "Nazara" .. moduleTable.Name
|
|
||||||
end
|
|
||||||
|
|
||||||
if (not _OPTIONS["united"] or infoTable.Type ~= "Module") then
|
|
||||||
table.insert(infoTable.ConfigurationLibraries.DebugStatic, library .. "-s-d")
|
|
||||||
table.insert(infoTable.ConfigurationLibraries.ReleaseStatic, library .. "-s")
|
|
||||||
table.insert(infoTable.ConfigurationLibraries.DebugDynamic, library .. "-d")
|
|
||||||
table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
local extLibTable = self.ExtLibs[library:lower()]
|
|
||||||
if (extLibTable) then
|
|
||||||
if (extLibTable.Excluded) then
|
|
||||||
infoTable.Excluded = true
|
|
||||||
infoTable.ExcludeReason = "depends on excluded " .. extLibTable.Name .. " external library"
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
library = extLibTable.Name
|
|
||||||
|
|
||||||
table.insert(infoTable.ConfigurationLibraries.DebugStatic, library .. "-s-d")
|
|
||||||
table.insert(infoTable.ConfigurationLibraries.ReleaseStatic, library .. "-s")
|
|
||||||
table.insert(infoTable.ConfigurationLibraries.DebugDynamic, library .. "-s-d")
|
|
||||||
table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library .. "-s")
|
|
||||||
else
|
|
||||||
if (toolTable and toolTable.Kind == "library") then
|
|
||||||
if (toolTable.Excluded) then
|
|
||||||
infoTable.Excluded = true
|
|
||||||
infoTable.ExcludeReason = "depends on excluded " .. toolTable.Name .. " tool"
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
library = "Nazara" .. toolTable.Name
|
|
||||||
|
|
||||||
-- Import tools includes
|
|
||||||
for k,v in ipairs(toolTable.Includes) do
|
|
||||||
table.insert(infoTable.Includes, v)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- And libraries
|
|
||||||
for k, v in pairs(toolTable.Libraries) do
|
|
||||||
table.insert(infoTable.Libraries, v)
|
|
||||||
end
|
|
||||||
|
|
||||||
for config, libs in pairs(toolTable.ConfigurationLibraries) do
|
|
||||||
for k,v in pairs(libs) do
|
|
||||||
table.insert(infoTable.ConfigurationLibraries[config], v)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
table.insert(infoTable.ConfigurationLibraries.DebugStatic, library .. "-s-d")
|
|
||||||
table.insert(infoTable.ConfigurationLibraries.ReleaseStatic, library .. "-s")
|
|
||||||
table.insert(infoTable.ConfigurationLibraries.DebugDynamic, library .. "-d")
|
|
||||||
table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library)
|
|
||||||
else
|
|
||||||
table.insert(libraries, library)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
infoTable.Libraries = libraries
|
|
||||||
|
|
||||||
for k,v in pairs(infoTable) do
|
|
||||||
local target = k:match("Os(%w+)")
|
|
||||||
if (target) then
|
|
||||||
local targetTable = infoTable[target]
|
|
||||||
if (targetTable) then
|
|
||||||
local excludeTargetTable = infoTable[target .. "Excluded"]
|
|
||||||
for platform, defineTable in pairs(v) do
|
|
||||||
platform = string.lower(platform)
|
|
||||||
if (platform == "posix") then
|
|
||||||
local osname = os.get()
|
|
||||||
if (PosixOSes[osname]) then
|
|
||||||
platform = osname
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if (os.is(platform)) then
|
|
||||||
for k,v in ipairs(defineTable) do
|
|
||||||
table.insert(targetTable, v)
|
|
||||||
end
|
|
||||||
elseif (excludeTargetTable) then
|
|
||||||
for k,v in ipairs(defineTable) do
|
|
||||||
table.insert(excludeTargetTable, v)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
infoTable[k] = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if (infoTable.Kind == "application") then
|
|
||||||
self:AddExecutablePath(infoTable.TargetDirectory)
|
|
||||||
end
|
|
||||||
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
function NazaraBuild:Resolve(infoTable)
|
function NazaraBuild:Resolve(infoTable)
|
||||||
if (infoTable.ClientOnly and _OPTIONS["server"]) then
|
if (infoTable.ClientOnly and self.Config["ServerMode"]) then
|
||||||
infoTable.Excluded = true
|
infoTable.Excluded = true
|
||||||
infoTable.ExcludeReason = "excluded by command-line options (client-only)"
|
infoTable.ExcludeReason = "excluded by command-line options (client-only)"
|
||||||
end
|
end
|
||||||
|
|
@ -937,53 +1034,19 @@ function NazaraBuild:Resolve(infoTable)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function NazaraBuild:MakeInstallCommands(infoTable)
|
|
||||||
if (PremakeVersion < 50) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if (os.is("windows")) then
|
|
||||||
configuration({})
|
|
||||||
|
|
||||||
for k,v in pairs(self.InstallDir) do
|
|
||||||
local destPath = path.translate(path.isabsolute(k) and k or "../../" .. k)
|
|
||||||
postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath):sub(1, -5) .. ".dll"}" "]] .. destPath .. [[\" /E /Y]]})
|
|
||||||
end
|
|
||||||
|
|
||||||
for k,v in pairs(table.join(infoTable.Libraries, infoTable.DynLib)) do
|
|
||||||
local paths = {}
|
|
||||||
table.insert(paths, {"x32", "../extlibs/lib/common/x86/" .. v .. ".dll"})
|
|
||||||
table.insert(paths, {"x32", "../extlibs/lib/common/x86/lib" .. v .. ".dll"})
|
|
||||||
table.insert(paths, {"x64", "../extlibs/lib/common/x64/" .. v .. ".dll"})
|
|
||||||
table.insert(paths, {"x64", "../extlibs/lib/common/x64/lib" .. v .. ".dll"})
|
|
||||||
|
|
||||||
for k,v in pairs(paths) do
|
|
||||||
local config = v[1]
|
|
||||||
local srcPath = v[2]
|
|
||||||
if (os.isfile(srcPath)) then
|
|
||||||
if (infoTable.Kind == "plugin") then
|
|
||||||
srcPath = "../../" .. srcPath
|
|
||||||
end
|
|
||||||
|
|
||||||
configuration(config)
|
|
||||||
|
|
||||||
for k,v in pairs(self.ExecutableDir) do
|
|
||||||
local destPath = path.translate(path.isabsolute(k) and k or "../../" .. k)
|
|
||||||
postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath:sub(1, -#cfg.linktarget.name - 1) .. "../../]] .. srcPath .. [[")}" "]] .. destPath .. [[\" /E /Y]]})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function NazaraBuild:SetupInfoTable(infoTable)
|
function NazaraBuild:SetupInfoTable(infoTable)
|
||||||
infoTable.Excludable = true
|
infoTable.BinaryPaths = {}
|
||||||
|
infoTable.BinaryPaths.x86 = {}
|
||||||
|
infoTable.BinaryPaths.x64 = {}
|
||||||
infoTable.ConfigurationLibraries = {}
|
infoTable.ConfigurationLibraries = {}
|
||||||
infoTable.ConfigurationLibraries.DebugStatic = {}
|
infoTable.ConfigurationLibraries.DebugStatic = {}
|
||||||
infoTable.ConfigurationLibraries.ReleaseStatic = {}
|
infoTable.ConfigurationLibraries.ReleaseStatic = {}
|
||||||
infoTable.ConfigurationLibraries.DebugDynamic = {}
|
infoTable.ConfigurationLibraries.DebugDynamic = {}
|
||||||
infoTable.ConfigurationLibraries.ReleaseDynamic = {}
|
infoTable.ConfigurationLibraries.ReleaseDynamic = {}
|
||||||
|
infoTable.Excludable = true
|
||||||
|
infoTable.LibraryPaths = {}
|
||||||
|
infoTable.LibraryPaths.x86 = {}
|
||||||
|
infoTable.LibraryPaths.x64 = {}
|
||||||
|
|
||||||
local infos = {"Defines", "DynLib", "Files", "FilesExcluded", "Flags", "Includes", "Libraries"}
|
local infos = {"Defines", "DynLib", "Files", "FilesExcluded", "Flags", "Includes", "Libraries"}
|
||||||
for k,v in ipairs(infos) do
|
for k,v in ipairs(infos) do
|
||||||
|
|
@ -1003,12 +1066,22 @@ function NazaraBuild:SetupExtlibTable(infoTable)
|
||||||
self:SetupInfoTable(infoTable)
|
self:SetupInfoTable(infoTable)
|
||||||
|
|
||||||
infoTable.Kind = "library"
|
infoTable.Kind = "library"
|
||||||
|
|
||||||
|
table.insert(infoTable.BinaryPaths.x86, "../extlibs/lib/common/x86")
|
||||||
|
table.insert(infoTable.BinaryPaths.x64, "../extlibs/lib/common/x64")
|
||||||
|
table.insert(infoTable.LibraryPaths.x86, "../extlibs/lib/common/x86")
|
||||||
|
table.insert(infoTable.LibraryPaths.x64, "../extlibs/lib/common/x64")
|
||||||
end
|
end
|
||||||
|
|
||||||
function NazaraBuild:SetupModuleTable(infoTable)
|
function NazaraBuild:SetupModuleTable(infoTable)
|
||||||
self:SetupInfoTable(infoTable)
|
self:SetupInfoTable(infoTable)
|
||||||
|
|
||||||
infoTable.Kind = "library"
|
infoTable.Kind = "library"
|
||||||
|
|
||||||
|
table.insert(infoTable.BinaryPaths.x86, "../extlibs/lib/common/x86")
|
||||||
|
table.insert(infoTable.BinaryPaths.x64, "../extlibs/lib/common/x64")
|
||||||
|
table.insert(infoTable.LibraryPaths.x86, "../extlibs/lib/common/x86")
|
||||||
|
table.insert(infoTable.LibraryPaths.x64, "../extlibs/lib/common/x64")
|
||||||
end
|
end
|
||||||
|
|
||||||
NazaraBuild.SetupToolTable = NazaraBuild.SetupInfoTable
|
NazaraBuild.SetupToolTable = NazaraBuild.SetupInfoTable
|
||||||
|
|
@ -37,13 +37,11 @@ TOOL.FilesExcluded = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TOOL.Libraries = function()
|
TOOL.Libraries = {
|
||||||
local libraries = {}
|
"NazaraCore",
|
||||||
for k,v in pairs(NazaraBuild.Modules) do
|
"NazaraLua",
|
||||||
if (not v.ClientOnly) then
|
"NazaraNetwork",
|
||||||
table.insert(libraries, "Nazara" .. v.Name)
|
"NazaraNoise",
|
||||||
end
|
"NazaraPhysics",
|
||||||
end
|
"NazaraUtility"
|
||||||
|
}
|
||||||
return libraries
|
|
||||||
end
|
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,10 @@ TOOL.Libraries = {
|
||||||
"NazaraCore",
|
"NazaraCore",
|
||||||
"NazaraAudio",
|
"NazaraAudio",
|
||||||
"NazaraLua",
|
"NazaraLua",
|
||||||
|
"NazaraGraphics",
|
||||||
|
"NazaraRenderer",
|
||||||
|
"NazaraNetwork",
|
||||||
"NazaraNoise",
|
"NazaraNoise",
|
||||||
"NazaraPhysics",
|
"NazaraPhysics",
|
||||||
"NazaraUtility",
|
"NazaraUtility"
|
||||||
"NazaraRenderer",
|
|
||||||
"NazaraGraphics"
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -173,12 +173,7 @@ int main()
|
||||||
|
|
||||||
Nz::String data;
|
Nz::String data;
|
||||||
if (!matData.GetStringParameter(Nz::MaterialData::FilePath, &data))
|
if (!matData.GetStringParameter(Nz::MaterialData::FilePath, &data))
|
||||||
{
|
|
||||||
if (matData.HasParameter(Nz::MaterialData::CustomDefined))
|
|
||||||
data = "<Custom>";
|
data = "<Custom>";
|
||||||
else
|
|
||||||
data = "<No data>";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cout << "\t" << (i+1) << ": " << data << std::endl;
|
std::cout << "\t" << (i+1) << ": " << data << std::endl;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -124,6 +124,7 @@ namespace Nz
|
||||||
template<typename T, std::size_t N>
|
template<typename T, std::size_t N>
|
||||||
constexpr std::size_t CountOf(T(&name)[N]) noexcept
|
constexpr std::size_t CountOf(T(&name)[N]) noexcept
|
||||||
{
|
{
|
||||||
|
NazaraUnused(name);
|
||||||
return N;
|
return N;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,10 @@ namespace Nz
|
||||||
/*!
|
/*!
|
||||||
* \brief Constructs a ByteArray object with a raw memory and a size
|
* \brief Constructs a ByteArray object with a raw memory and a size
|
||||||
*
|
*
|
||||||
* \param ptr Pointer to raw memory
|
* \param buffer Pointer to raw memory
|
||||||
* \param n Size that can be accessed
|
* \param n Size that can be accessed
|
||||||
*
|
*
|
||||||
* \remark If preallocated space of ptr is less than the size, the behaviour is undefined
|
* \remark If preallocated space of buffer is less than the size, the behaviour is undefined
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline ByteArray::ByteArray(const void* buffer, size_type n) :
|
inline ByteArray::ByteArray(const void* buffer, size_type n) :
|
||||||
|
|
@ -62,10 +62,10 @@ namespace Nz
|
||||||
/*!
|
/*!
|
||||||
* \brief Appends the content of raw memory
|
* \brief Appends the content of raw memory
|
||||||
*
|
*
|
||||||
* \param ptr Constant pointer to raw memory
|
* \param buffer Constant pointer to raw memory
|
||||||
* \param n Size that can be read
|
* \param n Size that can be read
|
||||||
*
|
*
|
||||||
* \remark If preallocated space of ptr is less than the size, the behaviour is undefined
|
* \remark If preallocated space of buffer is less than the size, the behaviour is undefined
|
||||||
*
|
*
|
||||||
* \see Insert
|
* \see Insert
|
||||||
*/
|
*/
|
||||||
|
|
@ -298,11 +298,11 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Inserts n times the same value at the iterator position
|
* \brief Inserts n times the same byte at the iterator position
|
||||||
*
|
*
|
||||||
* \param pos Iterator to the position
|
* \param pos Iterator to the position
|
||||||
* \param n Number of repetitions
|
* \param n Number of repetitions
|
||||||
* \param value Value to repeat
|
* \param byte Value to repeat
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline ByteArray::iterator ByteArray::Insert(const_iterator pos, size_type n, value_type byte)
|
inline ByteArray::iterator ByteArray::Insert(const_iterator pos, size_type n, value_type byte)
|
||||||
|
|
@ -359,10 +359,10 @@ namespace Nz
|
||||||
/*!
|
/*!
|
||||||
* \brief Prepends the content of raw memory
|
* \brief Prepends the content of raw memory
|
||||||
*
|
*
|
||||||
* \param ptr Constant pointer to raw memory
|
* \param buffer Constant pointer to raw memory
|
||||||
* \param n Size that can be read
|
* \param n Size that can be read
|
||||||
*
|
*
|
||||||
* \remark If preallocated space of ptr is less than the size, the behaviour is undefined
|
* \remark If preallocated space of buffer is less than the size, the behaviour is undefined
|
||||||
*
|
*
|
||||||
* \see Insert
|
* \see Insert
|
||||||
*/
|
*/
|
||||||
|
|
@ -682,8 +682,7 @@ namespace Nz
|
||||||
* \brief Checks whether the first byte array is equal to the second byte array
|
* \brief Checks whether the first byte array is equal to the second byte array
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ByteArray to compare in left hand side
|
* \param rhs ByteArray to compare with
|
||||||
* \param second ByteArray to compare in right hand side
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline bool ByteArray::operator==(const ByteArray& rhs) const
|
inline bool ByteArray::operator==(const ByteArray& rhs) const
|
||||||
|
|
@ -695,8 +694,7 @@ namespace Nz
|
||||||
* \brief Checks whether the first byte array is equal to the second byte array
|
* \brief Checks whether the first byte array is equal to the second byte array
|
||||||
* \return false if it is the case
|
* \return false if it is the case
|
||||||
*
|
*
|
||||||
* \param first ByteArray to compare in left hand side
|
* \param rhs ByteArray to compare with
|
||||||
* \param second ByteArray to compare in right hand side
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline bool ByteArray::operator!=(const ByteArray& rhs) const
|
inline bool ByteArray::operator!=(const ByteArray& rhs) const
|
||||||
|
|
@ -708,8 +706,7 @@ namespace Nz
|
||||||
* \brief Checks whether the first byte array is less than the second byte array
|
* \brief Checks whether the first byte array is less than the second byte array
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ByteArray to compare in left hand side
|
* \param rhs ByteArray to compare with
|
||||||
* \param second ByteArray to compare in right hand side
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline bool ByteArray::operator<(const ByteArray& rhs) const
|
inline bool ByteArray::operator<(const ByteArray& rhs) const
|
||||||
|
|
@ -721,8 +718,7 @@ namespace Nz
|
||||||
* \brief Checks whether the first byte array is less or equal than the second byte array
|
* \brief Checks whether the first byte array is less or equal than the second byte array
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ByteArray to compare in left hand side
|
* \param rhs ByteArray to compare with
|
||||||
* \param second ByteArray to compare in right hand side
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline bool ByteArray::operator<=(const ByteArray& rhs) const
|
inline bool ByteArray::operator<=(const ByteArray& rhs) const
|
||||||
|
|
@ -731,11 +727,10 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Checks whether the first byte array is greather than the second byte array
|
* \brief Checks whether the first byte array is greater than the second byte array
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ByteArray to compare in left hand side
|
* \param rhs ByteArray to compare with
|
||||||
* \param second ByteArray to compare in right hand side
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline bool ByteArray::operator>(const ByteArray& rhs) const
|
inline bool ByteArray::operator>(const ByteArray& rhs) const
|
||||||
|
|
@ -744,11 +739,10 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Checks whether the first byte array is greather or equal than the second byte array
|
* \brief Checks whether the first byte array is greater or equal than the second byte array
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ByteArray to compare in left hand side
|
* \param rhs ByteArray to compare with
|
||||||
* \param second ByteArray to compare in right hand side
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline bool ByteArray::operator>=(const ByteArray& rhs) const
|
inline bool ByteArray::operator>=(const ByteArray& rhs) const
|
||||||
|
|
|
||||||
|
|
@ -291,15 +291,16 @@ namespace Nz
|
||||||
template<typename T>
|
template<typename T>
|
||||||
std::ostream& operator<<(std::ostream& out, const ObjectHandle<T>& handle)
|
std::ostream& operator<<(std::ostream& out, const ObjectHandle<T>& handle)
|
||||||
{
|
{
|
||||||
return handle.ToString();
|
out << handle.ToString();
|
||||||
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Checks whether the first object handle is equal to the second object handle
|
* \brief Checks whether the first object handle is equal to the second object handle
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectHandle to compare in left hand side
|
* \param lhs ObjectHandle to compare in left hand side
|
||||||
* \param second ObjectHandle to compare in right hand side
|
* \param rhs ObjectHandle to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator==(const ObjectHandle<T>& lhs, const ObjectHandle<T>& rhs)
|
bool operator==(const ObjectHandle<T>& lhs, const ObjectHandle<T>& rhs)
|
||||||
|
|
@ -311,8 +312,8 @@ namespace Nz
|
||||||
* \brief Checks whether the object is equal to the second object handle
|
* \brief Checks whether the object is equal to the second object handle
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first Object to compare in left hand side
|
* \param lhs Object to compare in left hand side
|
||||||
* \param second ObjectHandle to compare in right hand side
|
* \param rhs ObjectHandle to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator==(const T& lhs, const ObjectHandle<T>& rhs)
|
bool operator==(const T& lhs, const ObjectHandle<T>& rhs)
|
||||||
|
|
@ -324,8 +325,8 @@ namespace Nz
|
||||||
* \brief Checks whether the object handle is equal to the second object
|
* \brief Checks whether the object handle is equal to the second object
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectHandle to compare in left hand side
|
* \param lhs ObjectHandle to compare in left hand side
|
||||||
* \param second Object to compare in right hand side
|
* \param rhs Object to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator==(const ObjectHandle<T>& lhs, const T& rhs)
|
bool operator==(const ObjectHandle<T>& lhs, const T& rhs)
|
||||||
|
|
@ -337,8 +338,8 @@ namespace Nz
|
||||||
* \brief Checks whether the first object handle is equal to the second object handle
|
* \brief Checks whether the first object handle is equal to the second object handle
|
||||||
* \return false if it is the case
|
* \return false if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectHandle to compare in left hand side
|
* \param lhs ObjectHandle to compare in left hand side
|
||||||
* \param second ObjectHandle to compare in right hand side
|
* \param rhs ObjectHandle to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator!=(const ObjectHandle<T>& lhs, const ObjectHandle<T>& rhs)
|
bool operator!=(const ObjectHandle<T>& lhs, const ObjectHandle<T>& rhs)
|
||||||
|
|
@ -350,8 +351,8 @@ namespace Nz
|
||||||
* \brief Checks whether the object is equal to the second object handle
|
* \brief Checks whether the object is equal to the second object handle
|
||||||
* \return false if it is the case
|
* \return false if it is the case
|
||||||
*
|
*
|
||||||
* \param first Object to compare in left hand side
|
* \param lhs Object to compare in left hand side
|
||||||
* \param second ObjectHandle to compare in right hand side
|
* \param rhs ObjectHandle to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator!=(const T& lhs, const ObjectHandle<T>& rhs)
|
bool operator!=(const T& lhs, const ObjectHandle<T>& rhs)
|
||||||
|
|
@ -363,8 +364,8 @@ namespace Nz
|
||||||
* \brief Checks whether the object handle is equal to the second object
|
* \brief Checks whether the object handle is equal to the second object
|
||||||
* \return false if it is the case
|
* \return false if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectHandle to compare in left hand side
|
* \param lhs ObjectHandle to compare in left hand side
|
||||||
* \param second Object to compare in right hand side
|
* \param rhs Object to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator!=(const ObjectHandle<T>& lhs, const T& rhs)
|
bool operator!=(const ObjectHandle<T>& lhs, const T& rhs)
|
||||||
|
|
@ -376,8 +377,8 @@ namespace Nz
|
||||||
* \brief Checks whether the first object handle is less than the second object handle
|
* \brief Checks whether the first object handle is less than the second object handle
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectHandle to compare in left hand side
|
* \param lhs ObjectHandle to compare in left hand side
|
||||||
* \param second ObjectHandle to compare in right hand side
|
* \param rhs ObjectHandle to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator<(const ObjectHandle<T>& lhs, const ObjectHandle<T>& rhs)
|
bool operator<(const ObjectHandle<T>& lhs, const ObjectHandle<T>& rhs)
|
||||||
|
|
@ -389,8 +390,8 @@ namespace Nz
|
||||||
* \brief Checks whether the first object handle is less than the second object handle
|
* \brief Checks whether the first object handle is less than the second object handle
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectHandle to compare in left hand side
|
* \param lhs ObjectHandle to compare in left hand side
|
||||||
* \param second ObjectHandle to compare in right hand side
|
* \param rhs ObjectHandle to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator<(const T& lhs, const ObjectHandle<T>& rhs)
|
bool operator<(const T& lhs, const ObjectHandle<T>& rhs)
|
||||||
|
|
@ -402,8 +403,8 @@ namespace Nz
|
||||||
* \brief Checks whether the first object handle is less than the second object handle
|
* \brief Checks whether the first object handle is less than the second object handle
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectHandle to compare in left hand side
|
* \param lhs ObjectHandle to compare in left hand side
|
||||||
* \param second ObjectHandle to compare in right hand side
|
* \param rhs ObjectHandle to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator<(const ObjectHandle<T>& lhs, const T& rhs)
|
bool operator<(const ObjectHandle<T>& lhs, const T& rhs)
|
||||||
|
|
@ -415,8 +416,8 @@ namespace Nz
|
||||||
* \brief Checks whether the first object handle is less or equal than the second object handle
|
* \brief Checks whether the first object handle is less or equal than the second object handle
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectHandle to compare in left hand side
|
* \param lhs ObjectHandle to compare in left hand side
|
||||||
* \param second ObjectHandle to compare in right hand side
|
* \param rhs ObjectHandle to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator<=(const ObjectHandle<T>& lhs, const ObjectHandle<T>& rhs)
|
bool operator<=(const ObjectHandle<T>& lhs, const ObjectHandle<T>& rhs)
|
||||||
|
|
@ -428,8 +429,8 @@ namespace Nz
|
||||||
* \brief Checks whether the first object handle is less or equal than the second object handle
|
* \brief Checks whether the first object handle is less or equal than the second object handle
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectHandle to compare in left hand side
|
* \param lhs ObjectHandle to compare in left hand side
|
||||||
* \param second ObjectHandle to compare in right hand side
|
* \param rhs ObjectHandle to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator<=(const T& lhs, const ObjectHandle<T>& rhs)
|
bool operator<=(const T& lhs, const ObjectHandle<T>& rhs)
|
||||||
|
|
@ -441,8 +442,8 @@ namespace Nz
|
||||||
* \brief Checks whether the first object handle is less or equal than the second object handle
|
* \brief Checks whether the first object handle is less or equal than the second object handle
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectHandle to compare in left hand side
|
* \param lhs ObjectHandle to compare in left hand side
|
||||||
* \param second ObjectHandle to compare in right hand side
|
* \param rhs ObjectHandle to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator<=(const ObjectHandle<T>& lhs, const T& rhs)
|
bool operator<=(const ObjectHandle<T>& lhs, const T& rhs)
|
||||||
|
|
@ -454,8 +455,8 @@ namespace Nz
|
||||||
* \brief Checks whether the first object handle is greather than the second object handle
|
* \brief Checks whether the first object handle is greather than the second object handle
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectHandle to compare in left hand side
|
* \param lhs ObjectHandle to compare in left hand side
|
||||||
* \param second ObjectHandle to compare in right hand side
|
* \param rhs ObjectHandle to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator>(const ObjectHandle<T>& lhs, const ObjectHandle<T>& rhs)
|
bool operator>(const ObjectHandle<T>& lhs, const ObjectHandle<T>& rhs)
|
||||||
|
|
@ -467,8 +468,8 @@ namespace Nz
|
||||||
* \brief Checks whether the first object handle is greather than the second object handle
|
* \brief Checks whether the first object handle is greather than the second object handle
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectHandle to compare in left hand side
|
* \param lhs ObjectHandle to compare in left hand side
|
||||||
* \param second ObjectHandle to compare in right hand side
|
* \param rhs ObjectHandle to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator>(const T& lhs, const ObjectHandle<T>& rhs)
|
bool operator>(const T& lhs, const ObjectHandle<T>& rhs)
|
||||||
|
|
@ -480,8 +481,8 @@ namespace Nz
|
||||||
* \brief Checks whether the first object handle is greather than the second object handle
|
* \brief Checks whether the first object handle is greather than the second object handle
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectHandle to compare in left hand side
|
* \param lhs ObjectHandle to compare in left hand side
|
||||||
* \param second ObjectHandle to compare in right hand side
|
* \param rhs ObjectHandle to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator>(const ObjectHandle<T>& lhs, const T& rhs)
|
bool operator>(const ObjectHandle<T>& lhs, const T& rhs)
|
||||||
|
|
@ -493,8 +494,8 @@ namespace Nz
|
||||||
* \brief Checks whether the first object handle is greather or equal than the second object handle
|
* \brief Checks whether the first object handle is greather or equal than the second object handle
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectHandle to compare in left hand side
|
* \param lhs ObjectHandle to compare in left hand side
|
||||||
* \param second ObjectHandle to compare in right hand side
|
* \param rhs ObjectHandle to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator>=(const ObjectHandle<T>& lhs, const ObjectHandle<T>& rhs)
|
bool operator>=(const ObjectHandle<T>& lhs, const ObjectHandle<T>& rhs)
|
||||||
|
|
@ -506,8 +507,8 @@ namespace Nz
|
||||||
* \brief Checks whether the first object handle is greather or equal than the second object handle
|
* \brief Checks whether the first object handle is greather or equal than the second object handle
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectHandle to compare in left hand side
|
* \param lhs ObjectHandle to compare in left hand side
|
||||||
* \param second ObjectHandle to compare in right hand side
|
* \param rhs ObjectHandle to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator>=(const T& lhs, const ObjectHandle<T>& rhs)
|
bool operator>=(const T& lhs, const ObjectHandle<T>& rhs)
|
||||||
|
|
@ -519,8 +520,8 @@ namespace Nz
|
||||||
* \brief Checks whether the first object handle is greather or equal than the second object handle
|
* \brief Checks whether the first object handle is greather or equal than the second object handle
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectHandle to compare in left hand side
|
* \param lhs ObjectHandle to compare in left hand side
|
||||||
* \param second ObjectHandle to compare in right hand side
|
* \param rhs ObjectHandle to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator>=(const ObjectHandle<T>& lhs, const T& rhs)
|
bool operator>=(const ObjectHandle<T>& lhs, const T& rhs)
|
||||||
|
|
|
||||||
|
|
@ -251,8 +251,8 @@ namespace Nz
|
||||||
* \brief Checks whether the first object handle is equal to the second object handle
|
* \brief Checks whether the first object handle is equal to the second object handle
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectRef to compare in left hand side
|
* \param lhs ObjectRef to compare in left hand side
|
||||||
* \param second ObjectRef to compare in right hand side
|
* \param rhs ObjectRef to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator==(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs)
|
bool operator==(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs)
|
||||||
|
|
@ -264,8 +264,8 @@ namespace Nz
|
||||||
* \brief Checks whether the object is equal to the second object handle
|
* \brief Checks whether the object is equal to the second object handle
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first Object to compare in left hand side
|
* \param lhs Object to compare in left hand side
|
||||||
* \param second ObjectRef to compare in right hand side
|
* \param rhs ObjectRef to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator==(const T& lhs, const ObjectRef<T>& rhs)
|
bool operator==(const T& lhs, const ObjectRef<T>& rhs)
|
||||||
|
|
@ -277,8 +277,8 @@ namespace Nz
|
||||||
* \brief Checks whether the object handle is equal to the second object
|
* \brief Checks whether the object handle is equal to the second object
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectRef to compare in left hand side
|
* \param lhs ObjectRef to compare in left hand side
|
||||||
* \param second Object to compare in right hand side
|
* \param rhs Object to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator==(const ObjectRef<T>& lhs, const T& rhs)
|
bool operator==(const ObjectRef<T>& lhs, const T& rhs)
|
||||||
|
|
@ -290,8 +290,8 @@ namespace Nz
|
||||||
* \brief Checks whether the first object handle is equal to the second object handle
|
* \brief Checks whether the first object handle is equal to the second object handle
|
||||||
* \return false if it is the case
|
* \return false if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectRef to compare in left hand side
|
* \param lhs ObjectRef to compare in left hand side
|
||||||
* \param second ObjectRef to compare in right hand side
|
* \param rhs ObjectRef to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator!=(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs)
|
bool operator!=(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs)
|
||||||
|
|
@ -303,8 +303,8 @@ namespace Nz
|
||||||
* \brief Checks whether the object is equal to the second object handle
|
* \brief Checks whether the object is equal to the second object handle
|
||||||
* \return false if it is the case
|
* \return false if it is the case
|
||||||
*
|
*
|
||||||
* \param first Object to compare in left hand side
|
* \param lhs Object to compare in left hand side
|
||||||
* \param second ObjectRef to compare in right hand side
|
* \param rhs ObjectRef to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator!=(const T& lhs, const ObjectRef<T>& rhs)
|
bool operator!=(const T& lhs, const ObjectRef<T>& rhs)
|
||||||
|
|
@ -316,8 +316,8 @@ namespace Nz
|
||||||
* \brief Checks whether the object handle is equal to the second object
|
* \brief Checks whether the object handle is equal to the second object
|
||||||
* \return false if it is the case
|
* \return false if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectRef to compare in left hand side
|
* \param lhs ObjectRef to compare in left hand side
|
||||||
* \param second Object to compare in right hand side
|
* \param rhs Object to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator!=(const ObjectRef<T>& lhs, const T& rhs)
|
bool operator!=(const ObjectRef<T>& lhs, const T& rhs)
|
||||||
|
|
@ -329,8 +329,8 @@ namespace Nz
|
||||||
* \brief Checks whether the first object handle is less than the second object handle
|
* \brief Checks whether the first object handle is less than the second object handle
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectRef to compare in left hand side
|
* \param lhs ObjectRef to compare in left hand side
|
||||||
* \param second ObjectRef to compare in right hand side
|
* \param rhs ObjectRef to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator<(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs)
|
bool operator<(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs)
|
||||||
|
|
@ -342,8 +342,8 @@ namespace Nz
|
||||||
* \brief Checks whether the first object handle is less than the second object handle
|
* \brief Checks whether the first object handle is less than the second object handle
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectRef to compare in left hand side
|
* \param lhs ObjectRef to compare in left hand side
|
||||||
* \param second ObjectRef to compare in right hand side
|
* \param rhs ObjectRef to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator<(const T& lhs, const ObjectRef<T>& rhs)
|
bool operator<(const T& lhs, const ObjectRef<T>& rhs)
|
||||||
|
|
@ -355,8 +355,8 @@ namespace Nz
|
||||||
* \brief Checks whether the first object handle is less than the second object handle
|
* \brief Checks whether the first object handle is less than the second object handle
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectRef to compare in left hand side
|
* \param lhs ObjectRef to compare in left hand side
|
||||||
* \param second ObjectRef to compare in right hand side
|
* \param rhs ObjectRef to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator<(const ObjectRef<T>& lhs, const T& rhs)
|
bool operator<(const ObjectRef<T>& lhs, const T& rhs)
|
||||||
|
|
@ -368,8 +368,8 @@ namespace Nz
|
||||||
* \brief Checks whether the first object handle is less or equal than the second object handle
|
* \brief Checks whether the first object handle is less or equal than the second object handle
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectRef to compare in left hand side
|
* \param lhs ObjectRef to compare in left hand side
|
||||||
* \param second ObjectRef to compare in right hand side
|
* \param rhs ObjectRef to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator<=(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs)
|
bool operator<=(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs)
|
||||||
|
|
@ -381,8 +381,8 @@ namespace Nz
|
||||||
* \brief Checks whether the first object handle is less or equal than the second object handle
|
* \brief Checks whether the first object handle is less or equal than the second object handle
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectRef to compare in left hand side
|
* \param lhs ObjectRef to compare in left hand side
|
||||||
* \param second ObjectRef to compare in right hand side
|
* \param rhs ObjectRef to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator<=(const T& lhs, const ObjectRef<T>& rhs)
|
bool operator<=(const T& lhs, const ObjectRef<T>& rhs)
|
||||||
|
|
@ -394,8 +394,8 @@ namespace Nz
|
||||||
* \brief Checks whether the first object handle is less or equal than the second object handle
|
* \brief Checks whether the first object handle is less or equal than the second object handle
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectRef to compare in left hand side
|
* \param lhs ObjectRef to compare in left hand side
|
||||||
* \param second ObjectRef to compare in right hand side
|
* \param rhs ObjectRef to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator<=(const ObjectRef<T>& lhs, const T& rhs)
|
bool operator<=(const ObjectRef<T>& lhs, const T& rhs)
|
||||||
|
|
@ -407,8 +407,8 @@ namespace Nz
|
||||||
* \brief Checks whether the first object handle is greather than the second object handle
|
* \brief Checks whether the first object handle is greather than the second object handle
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectRef to compare in left hand side
|
* \param lhs ObjectRef to compare in left hand side
|
||||||
* \param second ObjectRef to compare in right hand side
|
* \param rhs ObjectRef to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator>(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs)
|
bool operator>(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs)
|
||||||
|
|
@ -420,8 +420,8 @@ namespace Nz
|
||||||
* \brief Checks whether the first object handle is greather than the second object handle
|
* \brief Checks whether the first object handle is greather than the second object handle
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectRef to compare in left hand side
|
* \param lhs ObjectRef to compare in left hand side
|
||||||
* \param second ObjectRef to compare in right hand side
|
* \param rhs ObjectRef to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator>(const T& lhs, const ObjectRef<T>& rhs)
|
bool operator>(const T& lhs, const ObjectRef<T>& rhs)
|
||||||
|
|
@ -433,8 +433,8 @@ namespace Nz
|
||||||
* \brief Checks whether the first object handle is greather than the second object handle
|
* \brief Checks whether the first object handle is greather than the second object handle
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectRef to compare in left hand side
|
* \param lhs ObjectRef to compare in left hand side
|
||||||
* \param second ObjectRef to compare in right hand side
|
* \param rhs ObjectRef to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator>(const ObjectRef<T>& lhs, const T& rhs)
|
bool operator>(const ObjectRef<T>& lhs, const T& rhs)
|
||||||
|
|
@ -446,8 +446,8 @@ namespace Nz
|
||||||
* \brief Checks whether the first object handle is greather or equal than the second object handle
|
* \brief Checks whether the first object handle is greather or equal than the second object handle
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectRef to compare in left hand side
|
* \param lhs ObjectRef to compare in left hand side
|
||||||
* \param second ObjectRef to compare in right hand side
|
* \param rhs ObjectRef to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator>=(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs)
|
bool operator>=(const ObjectRef<T>& lhs, const ObjectRef<T>& rhs)
|
||||||
|
|
@ -459,8 +459,8 @@ namespace Nz
|
||||||
* \brief Checks whether the first object handle is greather or equal than the second object handle
|
* \brief Checks whether the first object handle is greather or equal than the second object handle
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectRef to compare in left hand side
|
* \param lhs ObjectRef to compare in left hand side
|
||||||
* \param second ObjectRef to compare in right hand side
|
* \param rhs ObjectRef to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator>=(const T& lhs, const ObjectRef<T>& rhs)
|
bool operator>=(const T& lhs, const ObjectRef<T>& rhs)
|
||||||
|
|
@ -472,8 +472,8 @@ namespace Nz
|
||||||
* \brief Checks whether the first object handle is greather or equal than the second object handle
|
* \brief Checks whether the first object handle is greather or equal than the second object handle
|
||||||
* \return true if it is the case
|
* \return true if it is the case
|
||||||
*
|
*
|
||||||
* \param first ObjectRef to compare in left hand side
|
* \param lhs ObjectRef to compare in left hand side
|
||||||
* \param second ObjectRef to compare in right hand side
|
* \param rhs ObjectRef to compare in right hand side
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator>=(const ObjectRef<T>& lhs, const T& rhs)
|
bool operator>=(const ObjectRef<T>& lhs, const T& rhs)
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ namespace Nz
|
||||||
* \remark The previous file content will be discarded, to prevent this behavior you should use SaveToStream
|
* \remark The previous file content will be discarded, to prevent this behavior you should use SaveToStream
|
||||||
* \remark The file extension will be used as format for the saver ("image.png" => "png", to write a specified format to a user-specified extension you should use SaveToStream
|
* \remark The file extension will be used as format for the saver ("image.png" => "png", to write a specified format to a user-specified extension you should use SaveToStream
|
||||||
*
|
*
|
||||||
* \seealso SaveToStream
|
* \see SaveToStream
|
||||||
*/
|
*/
|
||||||
template<typename Type, typename Parameters>
|
template<typename Type, typename Parameters>
|
||||||
bool ResourceSaver<Type, Parameters>::SaveToFile(const Type& resource, const String& filePath, const Parameters& parameters)
|
bool ResourceSaver<Type, Parameters>::SaveToFile(const Type& resource, const String& filePath, const Parameters& parameters)
|
||||||
|
|
@ -114,7 +114,7 @@ namespace Nz
|
||||||
* \param format Data format to save the resource to
|
* \param format Data format to save the resource to
|
||||||
* \param parameters Parameters for the saving
|
* \param parameters Parameters for the saving
|
||||||
*
|
*
|
||||||
* \seealso SaveToFile
|
* \see SaveToFile
|
||||||
*/
|
*/
|
||||||
template<typename Type, typename Parameters>
|
template<typename Type, typename Parameters>
|
||||||
bool ResourceSaver<Type, Parameters>::SaveToStream(const Type& resource, Stream& stream, const String& format, const Parameters& parameters)
|
bool ResourceSaver<Type, Parameters>::SaveToStream(const Type& resource, Stream& stream, const String& format, const Parameters& parameters)
|
||||||
|
|
|
||||||
|
|
@ -84,16 +84,15 @@ namespace Nz
|
||||||
|
|
||||||
namespace std
|
namespace std
|
||||||
{
|
{
|
||||||
|
template<>
|
||||||
|
struct hash<Nz::String>
|
||||||
|
{
|
||||||
/*!
|
/*!
|
||||||
* \brief Specialisation of std to hash
|
* \brief Specialisation of std to hash
|
||||||
* \return Result of the hash
|
* \return Result of the hash
|
||||||
*
|
*
|
||||||
* \param str String to hash
|
* \param str String to hash
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template<>
|
|
||||||
struct hash<Nz::String>
|
|
||||||
{
|
|
||||||
size_t operator()(const Nz::String& str) const
|
size_t operator()(const Nz::String& str) const
|
||||||
{
|
{
|
||||||
// Algorithme DJB2
|
// Algorithme DJB2
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// This file was automatically generated on 12 Jul 2016 at 17:44:43
|
// This file was automatically generated on 20 Jul 2016 at 13:49:17
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Nazara Engine - Graphics module
|
Nazara Engine - Graphics module
|
||||||
|
|
@ -63,11 +63,12 @@
|
||||||
#include <Nazara/Graphics/ParticleDeclaration.hpp>
|
#include <Nazara/Graphics/ParticleDeclaration.hpp>
|
||||||
#include <Nazara/Graphics/ParticleEmitter.hpp>
|
#include <Nazara/Graphics/ParticleEmitter.hpp>
|
||||||
#include <Nazara/Graphics/ParticleGenerator.hpp>
|
#include <Nazara/Graphics/ParticleGenerator.hpp>
|
||||||
|
#include <Nazara/Graphics/ParticleGroup.hpp>
|
||||||
#include <Nazara/Graphics/ParticleMapper.hpp>
|
#include <Nazara/Graphics/ParticleMapper.hpp>
|
||||||
#include <Nazara/Graphics/ParticleRenderer.hpp>
|
#include <Nazara/Graphics/ParticleRenderer.hpp>
|
||||||
#include <Nazara/Graphics/ParticleStruct.hpp>
|
#include <Nazara/Graphics/ParticleStruct.hpp>
|
||||||
#include <Nazara/Graphics/ParticleSystem.hpp>
|
|
||||||
#include <Nazara/Graphics/Renderable.hpp>
|
#include <Nazara/Graphics/Renderable.hpp>
|
||||||
|
#include <Nazara/Graphics/MaterialPipeline.hpp>
|
||||||
#include <Nazara/Graphics/RenderTechniques.hpp>
|
#include <Nazara/Graphics/RenderTechniques.hpp>
|
||||||
#include <Nazara/Graphics/SceneData.hpp>
|
#include <Nazara/Graphics/SceneData.hpp>
|
||||||
#include <Nazara/Graphics/SkeletalModel.hpp>
|
#include <Nazara/Graphics/SkeletalModel.hpp>
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,6 @@ namespace Nz
|
||||||
|
|
||||||
// Je ne suis vraiment pas fan du nombre de surcharges pour AddBillboards,
|
// Je ne suis vraiment pas fan du nombre de surcharges pour AddBillboards,
|
||||||
// mais je n'ai pas d'autre solution tout aussi performante pour le moment...
|
// mais je n'ai pas d'autre solution tout aussi performante pour le moment...
|
||||||
virtual void AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos = Vector2f(0.f, 1.f), const Color& color = Color::White) = 0;
|
|
||||||
virtual void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr = nullptr, SparsePtr<const Color> colorPtr = nullptr) = 0;
|
virtual void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr = nullptr, SparsePtr<const Color> colorPtr = nullptr) = 0;
|
||||||
virtual void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const float> alphaPtr) = 0;
|
virtual void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const float> alphaPtr) = 0;
|
||||||
virtual void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const Color> colorPtr = nullptr) = 0;
|
virtual void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const Color> colorPtr = nullptr) = 0;
|
||||||
|
|
|
||||||
|
|
@ -121,8 +121,7 @@ namespace Nz
|
||||||
inline void Billboard::SetDefaultMaterial()
|
inline void Billboard::SetDefaultMaterial()
|
||||||
{
|
{
|
||||||
MaterialRef material = Material::New();
|
MaterialRef material = Material::New();
|
||||||
material->Enable(RendererParameter_FaceCulling, true);
|
material->EnableFaceCulling(true);
|
||||||
material->EnableLighting(false);
|
|
||||||
|
|
||||||
SetMaterial(std::move(material));
|
SetMaterial(std::move(material));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#include <Nazara/Prerequesites.hpp>
|
#include <Nazara/Prerequesites.hpp>
|
||||||
#include <Nazara/Core/Color.hpp>
|
#include <Nazara/Core/Color.hpp>
|
||||||
#include <Nazara/Graphics/AbstractRenderQueue.hpp>
|
#include <Nazara/Graphics/ForwardRenderQueue.hpp>
|
||||||
#include <Nazara/Graphics/Material.hpp>
|
#include <Nazara/Graphics/Material.hpp>
|
||||||
#include <Nazara/Math/Box.hpp>
|
#include <Nazara/Math/Box.hpp>
|
||||||
#include <Nazara/Math/Matrix4.hpp>
|
#include <Nazara/Math/Matrix4.hpp>
|
||||||
|
|
@ -21,15 +21,12 @@
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
class ForwardRenderQueue;
|
|
||||||
|
|
||||||
class NAZARA_GRAPHICS_API DeferredRenderQueue : public AbstractRenderQueue
|
class NAZARA_GRAPHICS_API DeferredRenderQueue : public AbstractRenderQueue
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DeferredRenderQueue(ForwardRenderQueue* forwardQueue);
|
DeferredRenderQueue(ForwardRenderQueue* forwardQueue);
|
||||||
~DeferredRenderQueue() = default;
|
~DeferredRenderQueue() = default;
|
||||||
|
|
||||||
void AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos = Vector2f(0.f, 1.f), const Color& color = Color::White) override;
|
|
||||||
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr = nullptr, SparsePtr<const Color> colorPtr = nullptr) override;
|
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr = nullptr, SparsePtr<const Color> colorPtr = nullptr) override;
|
||||||
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const float> alphaPtr) override;
|
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const float> alphaPtr) override;
|
||||||
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const Color> colorPtr = nullptr) override;
|
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const Color> colorPtr = nullptr) override;
|
||||||
|
|
@ -44,11 +41,6 @@ namespace Nz
|
||||||
|
|
||||||
void Clear(bool fully = false) override;
|
void Clear(bool fully = false) override;
|
||||||
|
|
||||||
struct MeshDataComparator
|
|
||||||
{
|
|
||||||
bool operator()(const MeshData& data1, const MeshData& data2) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct MeshInstanceEntry
|
struct MeshInstanceEntry
|
||||||
{
|
{
|
||||||
NazaraSlot(IndexBuffer, OnIndexBufferRelease, indexBufferReleaseSlot);
|
NazaraSlot(IndexBuffer, OnIndexBufferRelease, indexBufferReleaseSlot);
|
||||||
|
|
@ -57,12 +49,7 @@ namespace Nz
|
||||||
std::vector<Matrix4f> instances;
|
std::vector<Matrix4f> instances;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::map<MeshData, MeshInstanceEntry, MeshDataComparator> MeshInstanceContainer;
|
typedef std::map<MeshData, MeshInstanceEntry, ForwardRenderQueue::MeshDataComparator> MeshInstanceContainer;
|
||||||
|
|
||||||
struct BatchedModelMaterialComparator
|
|
||||||
{
|
|
||||||
bool operator()(const Material* mat1, const Material* mat2) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct BatchedModelEntry
|
struct BatchedModelEntry
|
||||||
{
|
{
|
||||||
|
|
@ -70,14 +57,21 @@ namespace Nz
|
||||||
|
|
||||||
MeshInstanceContainer meshMap;
|
MeshInstanceContainer meshMap;
|
||||||
bool enabled = false;
|
bool enabled = false;
|
||||||
bool instancingEnabled = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::map<const Material*, BatchedModelEntry, BatchedModelMaterialComparator> ModelBatches;
|
typedef std::map<const Material*, BatchedModelEntry, ForwardRenderQueue::MaterialComparator> MeshMaterialBatches;
|
||||||
|
|
||||||
|
struct BatchedMaterialEntry
|
||||||
|
{
|
||||||
|
std::size_t maxInstanceCount = 0;
|
||||||
|
MeshMaterialBatches materialMap;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::map<const MaterialPipeline*, BatchedMaterialEntry, ForwardRenderQueue::MaterialPipelineComparator> MeshPipelineBatches;
|
||||||
|
|
||||||
struct Layer
|
struct Layer
|
||||||
{
|
{
|
||||||
ModelBatches opaqueModels;
|
MeshPipelineBatches opaqueModels;
|
||||||
unsigned int clearCount = 0;
|
unsigned int clearCount = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ namespace Nz
|
||||||
DepthRenderQueue();
|
DepthRenderQueue();
|
||||||
~DepthRenderQueue() = default;
|
~DepthRenderQueue() = default;
|
||||||
|
|
||||||
void AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos = Vector2f(0.f, 1.f), const Color& color = Color::White) override;
|
|
||||||
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr = nullptr, SparsePtr<const Color> colorPtr = nullptr) override;
|
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr = nullptr, SparsePtr<const Color> colorPtr = nullptr) override;
|
||||||
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const float> alphaPtr) override;
|
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const float> alphaPtr) override;
|
||||||
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const Color> colorPtr = nullptr) override;
|
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const Color> colorPtr = nullptr) override;
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
NazaraAssert(material, "Invalid material");
|
NazaraAssert(material, "Invalid material");
|
||||||
|
|
||||||
return material->HasDepthMaterial() || (material->IsEnabled(RendererParameter_DepthBuffer) && material->IsEnabled(RendererParameter_DepthWrite) && material->IsShadowCastingEnabled());
|
return material->HasDepthMaterial() || (material->IsDepthBufferEnabled() && material->IsDepthWriteEnabled() && material->IsShadowCastingEnabled());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ namespace Nz
|
||||||
mutable std::unordered_map<const Shader*, ShaderUniforms> m_shaderUniforms;
|
mutable std::unordered_map<const Shader*, ShaderUniforms> m_shaderUniforms;
|
||||||
Buffer m_vertexBuffer;
|
Buffer m_vertexBuffer;
|
||||||
mutable DepthRenderQueue m_renderQueue;
|
mutable DepthRenderQueue m_renderQueue;
|
||||||
|
Texture m_whiteTexture;
|
||||||
VertexBuffer m_billboardPointBuffer;
|
VertexBuffer m_billboardPointBuffer;
|
||||||
VertexBuffer m_spriteBuffer;
|
VertexBuffer m_spriteBuffer;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@ namespace Nz
|
||||||
ForwardRenderQueue() = default;
|
ForwardRenderQueue() = default;
|
||||||
~ForwardRenderQueue() = default;
|
~ForwardRenderQueue() = default;
|
||||||
|
|
||||||
void AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos = Vector2f(0.f, 1.f), const Color& color = Color::White) override;
|
|
||||||
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr = nullptr, SparsePtr<const Color> colorPtr = nullptr) override;
|
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr = nullptr, SparsePtr<const Color> colorPtr = nullptr) override;
|
||||||
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const float> alphaPtr) override;
|
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const float> alphaPtr) override;
|
||||||
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const Color> colorPtr = nullptr) override;
|
void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const Color> colorPtr = nullptr) override;
|
||||||
|
|
@ -48,6 +47,16 @@ namespace Nz
|
||||||
|
|
||||||
void Sort(const AbstractViewer* viewer);
|
void Sort(const AbstractViewer* viewer);
|
||||||
|
|
||||||
|
struct MaterialComparator
|
||||||
|
{
|
||||||
|
bool operator()(const Material* mat1, const Material* mat2) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MaterialPipelineComparator
|
||||||
|
{
|
||||||
|
bool operator()(const MaterialPipeline* pipeline1, const MaterialPipeline* pipeline2) const;
|
||||||
|
};
|
||||||
|
|
||||||
/// Billboards
|
/// Billboards
|
||||||
struct BillboardData
|
struct BillboardData
|
||||||
{
|
{
|
||||||
|
|
@ -57,11 +66,6 @@ namespace Nz
|
||||||
Vector2f sinCos;
|
Vector2f sinCos;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BatchedBillboardComparator
|
|
||||||
{
|
|
||||||
bool operator()(const Material* mat1, const Material* mat2) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct BatchedBillboardEntry
|
struct BatchedBillboardEntry
|
||||||
{
|
{
|
||||||
NazaraSlot(Material, OnMaterialRelease, materialReleaseSlot);
|
NazaraSlot(Material, OnMaterialRelease, materialReleaseSlot);
|
||||||
|
|
@ -69,7 +73,15 @@ namespace Nz
|
||||||
std::vector<BillboardData> billboards;
|
std::vector<BillboardData> billboards;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::map<const Material*, BatchedBillboardEntry, BatchedBillboardComparator> BatchedBillboardContainer;
|
typedef std::map<const Material*, BatchedBillboardEntry, MaterialComparator> BatchedBillboardContainer;
|
||||||
|
|
||||||
|
struct BatchedBillboardPipelineEntry
|
||||||
|
{
|
||||||
|
BatchedBillboardContainer materialMap;
|
||||||
|
bool enabled = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::map<const MaterialPipeline*, BatchedBillboardPipelineEntry, MaterialPipelineComparator> BillboardPipelineBatches;
|
||||||
|
|
||||||
/// Sprites
|
/// Sprites
|
||||||
struct SpriteChain_XYZ_Color_UV
|
struct SpriteChain_XYZ_Color_UV
|
||||||
|
|
@ -85,22 +97,25 @@ namespace Nz
|
||||||
std::vector<SpriteChain_XYZ_Color_UV> spriteChains;
|
std::vector<SpriteChain_XYZ_Color_UV> spriteChains;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BatchedSpriteMaterialComparator
|
typedef std::map<const Texture*, BatchedSpriteEntry> SpriteOverlayBatches;
|
||||||
{
|
|
||||||
bool operator()(const Material* mat1, const Material* mat2);
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef std::map<const Texture*, BatchedSpriteEntry> BasicSpriteOverlayContainer;
|
|
||||||
|
|
||||||
struct BatchedBasicSpriteEntry
|
struct BatchedBasicSpriteEntry
|
||||||
{
|
{
|
||||||
NazaraSlot(Material, OnMaterialRelease, materialReleaseSlot);
|
NazaraSlot(Material, OnMaterialRelease, materialReleaseSlot);
|
||||||
|
|
||||||
BasicSpriteOverlayContainer overlayMap;
|
SpriteOverlayBatches overlayMap;
|
||||||
bool enabled = false;
|
bool enabled = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::map<const Material*, BatchedBasicSpriteEntry> BasicSpriteBatches;
|
typedef std::map<const Material*, BatchedBasicSpriteEntry, MaterialComparator> SpriteMaterialBatches;
|
||||||
|
|
||||||
|
struct BatchedSpritePipelineEntry
|
||||||
|
{
|
||||||
|
SpriteMaterialBatches materialMap;
|
||||||
|
bool enabled = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::map<const MaterialPipeline*, BatchedSpritePipelineEntry, MaterialPipelineComparator> SpritePipelineBatches;
|
||||||
|
|
||||||
/// Meshes
|
/// Meshes
|
||||||
struct MeshDataComparator
|
struct MeshDataComparator
|
||||||
|
|
@ -119,21 +134,23 @@ namespace Nz
|
||||||
|
|
||||||
typedef std::map<MeshData, MeshInstanceEntry, MeshDataComparator> MeshInstanceContainer;
|
typedef std::map<MeshData, MeshInstanceEntry, MeshDataComparator> MeshInstanceContainer;
|
||||||
|
|
||||||
struct BatchedModelMaterialComparator
|
|
||||||
{
|
|
||||||
bool operator()(const Material* mat1, const Material* mat2) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct BatchedModelEntry
|
struct BatchedModelEntry
|
||||||
{
|
{
|
||||||
NazaraSlot(Material, OnMaterialRelease, materialReleaseSlot);
|
NazaraSlot(Material, OnMaterialRelease, materialReleaseSlot);
|
||||||
|
|
||||||
MeshInstanceContainer meshMap;
|
MeshInstanceContainer meshMap;
|
||||||
bool enabled = false;
|
bool enabled = false;
|
||||||
bool instancingEnabled = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::map<const Material*, BatchedModelEntry, BatchedModelMaterialComparator> ModelBatches;
|
typedef std::map<const Material*, BatchedModelEntry, MaterialComparator> MeshMaterialBatches;
|
||||||
|
|
||||||
|
struct BatchedMaterialEntry
|
||||||
|
{
|
||||||
|
std::size_t maxInstanceCount = 0;
|
||||||
|
MeshMaterialBatches materialMap;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::map<const MaterialPipeline*, BatchedMaterialEntry, MaterialPipelineComparator> MeshPipelineBatches;
|
||||||
|
|
||||||
struct TransparentModelData
|
struct TransparentModelData
|
||||||
{
|
{
|
||||||
|
|
@ -147,9 +164,9 @@ namespace Nz
|
||||||
|
|
||||||
struct Layer
|
struct Layer
|
||||||
{
|
{
|
||||||
BatchedBillboardContainer billboards;
|
BillboardPipelineBatches billboards;
|
||||||
BasicSpriteBatches basicSprites;
|
SpritePipelineBatches basicSprites;
|
||||||
ModelBatches opaqueModels;
|
MeshPipelineBatches opaqueModels;
|
||||||
TransparentModelContainer transparentModels;
|
TransparentModelContainer transparentModels;
|
||||||
std::vector<TransparentModelData> transparentModelData;
|
std::vector<TransparentModelData> transparentModelData;
|
||||||
std::vector<const Drawable*> otherDrawables;
|
std::vector<const Drawable*> otherDrawables;
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,7 @@ namespace Nz
|
||||||
mutable std::vector<LightIndex> m_lights;
|
mutable std::vector<LightIndex> m_lights;
|
||||||
Buffer m_vertexBuffer;
|
Buffer m_vertexBuffer;
|
||||||
mutable ForwardRenderQueue m_renderQueue;
|
mutable ForwardRenderQueue m_renderQueue;
|
||||||
|
Texture m_whiteTexture;
|
||||||
VertexBuffer m_billboardPointBuffer;
|
VertexBuffer m_billboardPointBuffer;
|
||||||
VertexBuffer m_spriteBuffer;
|
VertexBuffer m_spriteBuffer;
|
||||||
unsigned int m_maxLightPassPerObject;
|
unsigned int m_maxLightPassPerObject;
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ namespace Nz
|
||||||
|
|
||||||
struct InstanceData
|
struct InstanceData
|
||||||
{
|
{
|
||||||
InstanceData(Matrix4f& referenceMatrix) :
|
InstanceData(const Matrix4f& referenceMatrix) :
|
||||||
transformMatrix(&referenceMatrix),
|
transformMatrix(&referenceMatrix),
|
||||||
flags(0)
|
flags(0)
|
||||||
{
|
{
|
||||||
|
|
@ -75,7 +75,7 @@ namespace Nz
|
||||||
|
|
||||||
std::vector<UInt8> data;
|
std::vector<UInt8> data;
|
||||||
BoundingVolumef volume;
|
BoundingVolumef volume;
|
||||||
Matrix4f* transformMatrix;
|
const Matrix4f* transformMatrix;
|
||||||
UInt32 flags;
|
UInt32 flags;
|
||||||
int renderOrder;
|
int renderOrder;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
#include <Nazara/Core/String.hpp>
|
#include <Nazara/Core/String.hpp>
|
||||||
#include <Nazara/Graphics/Config.hpp>
|
#include <Nazara/Graphics/Config.hpp>
|
||||||
#include <Nazara/Graphics/Enums.hpp>
|
#include <Nazara/Graphics/Enums.hpp>
|
||||||
#include <Nazara/Renderer/RenderStates.hpp>
|
#include <Nazara/Graphics/MaterialPipeline.hpp>
|
||||||
#include <Nazara/Renderer/Texture.hpp>
|
#include <Nazara/Renderer/Texture.hpp>
|
||||||
#include <Nazara/Renderer/TextureSampler.hpp>
|
#include <Nazara/Renderer/TextureSampler.hpp>
|
||||||
#include <Nazara/Renderer/UberShader.hpp>
|
#include <Nazara/Renderer/UberShader.hpp>
|
||||||
|
|
@ -58,20 +58,33 @@ namespace Nz
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline Material();
|
inline Material();
|
||||||
|
inline Material(const MaterialPipeline* pipeline);
|
||||||
|
inline Material(const MaterialPipelineInfo& pipelineInfo);
|
||||||
|
inline Material(const String& pipelineName);
|
||||||
inline Material(const Material& material);
|
inline Material(const Material& material);
|
||||||
inline ~Material();
|
inline ~Material();
|
||||||
|
|
||||||
const Shader* Apply(UInt32 shaderFlags = 0, UInt8 textureUnit = 0, UInt8* lastUsedUnit = nullptr) const;
|
void Apply(const MaterialPipeline::Instance& instance, UInt8 textureUnit = 0, UInt8* lastUsedUnit = nullptr) const;
|
||||||
|
|
||||||
void BuildFromParameters(const ParameterList& matData, const MaterialParams& matParams = MaterialParams());
|
void BuildFromParameters(const ParameterList& matData, const MaterialParams& matParams = MaterialParams());
|
||||||
|
|
||||||
inline void Enable(RendererParameter renderParameter, bool enable);
|
inline void Configure(const MaterialPipeline* pipeline);
|
||||||
|
inline void Configure(const MaterialPipelineInfo& pipelineInfo);
|
||||||
|
inline bool Configure(const String& pipelineName);
|
||||||
|
|
||||||
inline void EnableAlphaTest(bool alphaTest);
|
inline void EnableAlphaTest(bool alphaTest);
|
||||||
|
inline void EnableBlending(bool blending);
|
||||||
|
inline void EnableColorWrite(bool colorWrite);
|
||||||
|
inline void EnableDepthBuffer(bool depthBuffer);
|
||||||
inline void EnableDepthSorting(bool depthSorting);
|
inline void EnableDepthSorting(bool depthSorting);
|
||||||
inline void EnableLighting(bool lighting);
|
inline void EnableDepthWrite(bool depthWrite);
|
||||||
|
inline void EnableFaceCulling(bool faceCulling);
|
||||||
|
inline void EnableScissorTest(bool scissorTest);
|
||||||
inline void EnableShadowCasting(bool castShadows);
|
inline void EnableShadowCasting(bool castShadows);
|
||||||
inline void EnableShadowReceive(bool receiveShadows);
|
inline void EnableShadowReceive(bool receiveShadows);
|
||||||
inline void EnableTransform(bool transform);
|
inline void EnableStencilTest(bool stencilTest);
|
||||||
|
|
||||||
|
inline void EnsurePipelineUpdate() const;
|
||||||
|
|
||||||
inline const TextureRef& GetAlphaMap() const;
|
inline const TextureRef& GetAlphaMap() const;
|
||||||
inline float GetAlphaThreshold() const;
|
inline float GetAlphaThreshold() const;
|
||||||
|
|
@ -87,10 +100,12 @@ namespace Nz
|
||||||
inline FaceSide GetFaceCulling() const;
|
inline FaceSide GetFaceCulling() const;
|
||||||
inline FaceFilling GetFaceFilling() const;
|
inline FaceFilling GetFaceFilling() const;
|
||||||
inline const TextureRef& GetHeightMap() const;
|
inline const TextureRef& GetHeightMap() const;
|
||||||
|
inline float GetLineWidth() const;
|
||||||
inline const TextureRef& GetNormalMap() const;
|
inline const TextureRef& GetNormalMap() const;
|
||||||
inline const RenderStates& GetRenderStates() const;
|
inline const MaterialPipeline* GetPipeline() const;
|
||||||
|
inline const MaterialPipelineInfo& GetPipelineInfo() const;
|
||||||
|
inline float GetPointSize() const;
|
||||||
inline const UberShader* GetShader() const;
|
inline const UberShader* GetShader() const;
|
||||||
inline const UberShaderInstance* GetShaderInstance(UInt32 flags = ShaderFlags_None) const;
|
|
||||||
inline float GetShininess() const;
|
inline float GetShininess() const;
|
||||||
inline Color GetSpecularColor() const;
|
inline Color GetSpecularColor() const;
|
||||||
inline const TextureRef& GetSpecularMap() const;
|
inline const TextureRef& GetSpecularMap() const;
|
||||||
|
|
@ -107,12 +122,16 @@ namespace Nz
|
||||||
inline bool HasSpecularMap() const;
|
inline bool HasSpecularMap() const;
|
||||||
|
|
||||||
inline bool IsAlphaTestEnabled() const;
|
inline bool IsAlphaTestEnabled() const;
|
||||||
|
inline bool IsBlendingEnabled() const;
|
||||||
|
inline bool IsColorWriteEnabled() const;
|
||||||
|
inline bool IsDepthBufferEnabled() const;
|
||||||
inline bool IsDepthSortingEnabled() const;
|
inline bool IsDepthSortingEnabled() const;
|
||||||
inline bool IsEnabled(RendererParameter renderParameter) const;
|
inline bool IsDepthWriteEnabled() const;
|
||||||
inline bool IsLightingEnabled() const;
|
inline bool IsFaceCullingEnabled() const;
|
||||||
|
inline bool IsScissorTestEnabled() const;
|
||||||
|
inline bool IsStencilTestEnabled() const;
|
||||||
inline bool IsShadowCastingEnabled() const;
|
inline bool IsShadowCastingEnabled() const;
|
||||||
inline bool IsShadowReceiveEnabled() const;
|
inline bool IsShadowReceiveEnabled() const;
|
||||||
inline bool IsTransformEnabled() const;
|
|
||||||
|
|
||||||
inline bool LoadFromFile(const String& filePath, const MaterialParams& params = MaterialParams());
|
inline bool LoadFromFile(const String& filePath, const MaterialParams& params = MaterialParams());
|
||||||
inline bool LoadFromMemory(const void* data, std::size_t size, const MaterialParams& params = MaterialParams());
|
inline bool LoadFromMemory(const void* data, std::size_t size, const MaterialParams& params = MaterialParams());
|
||||||
|
|
@ -139,9 +158,10 @@ namespace Nz
|
||||||
inline void SetFaceFilling(FaceFilling filling);
|
inline void SetFaceFilling(FaceFilling filling);
|
||||||
inline bool SetHeightMap(const String& textureName);
|
inline bool SetHeightMap(const String& textureName);
|
||||||
inline void SetHeightMap(TextureRef textureName);
|
inline void SetHeightMap(TextureRef textureName);
|
||||||
|
inline void SetLineWidth(float lineWidth);
|
||||||
inline bool SetNormalMap(const String& textureName);
|
inline bool SetNormalMap(const String& textureName);
|
||||||
inline void SetNormalMap(TextureRef textureName);
|
inline void SetNormalMap(TextureRef textureName);
|
||||||
inline void SetRenderStates(const RenderStates& states);
|
inline void SetPointSize(float pointSize);
|
||||||
inline void SetShader(UberShaderConstRef uberShader);
|
inline void SetShader(UberShaderConstRef uberShader);
|
||||||
inline bool SetShader(const String& uberShaderName);
|
inline bool SetShader(const String& uberShaderName);
|
||||||
inline void SetShininess(float shininess);
|
inline void SetShininess(float shininess);
|
||||||
|
|
@ -161,16 +181,9 @@ namespace Nz
|
||||||
NazaraSignal(OnMaterialReset, const Material* /*material*/);
|
NazaraSignal(OnMaterialReset, const Material* /*material*/);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct ShaderInstance
|
|
||||||
{
|
|
||||||
const Shader* shader;
|
|
||||||
UberShaderInstance* uberInstance = nullptr;
|
|
||||||
int uniforms[MaterialUniform_Max + 1];
|
|
||||||
};
|
|
||||||
|
|
||||||
void Copy(const Material& material);
|
void Copy(const Material& material);
|
||||||
void GenerateShader(UInt32 flags) const;
|
inline void InvalidatePipeline();
|
||||||
inline void InvalidateShaders();
|
inline void UpdatePipeline() const;
|
||||||
|
|
||||||
static bool Initialize();
|
static bool Initialize();
|
||||||
static void Uninitialize();
|
static void Uninitialize();
|
||||||
|
|
@ -179,7 +192,8 @@ namespace Nz
|
||||||
Color m_diffuseColor;
|
Color m_diffuseColor;
|
||||||
Color m_specularColor;
|
Color m_specularColor;
|
||||||
MaterialRef m_depthMaterial; //< Materialception
|
MaterialRef m_depthMaterial; //< Materialception
|
||||||
RenderStates m_states;
|
mutable const MaterialPipeline* m_pipeline;
|
||||||
|
MaterialPipelineInfo m_pipelineInfo;
|
||||||
TextureSampler m_diffuseSampler;
|
TextureSampler m_diffuseSampler;
|
||||||
TextureSampler m_specularSampler;
|
TextureSampler m_specularSampler;
|
||||||
TextureRef m_alphaMap;
|
TextureRef m_alphaMap;
|
||||||
|
|
@ -188,14 +202,8 @@ namespace Nz
|
||||||
TextureRef m_heightMap;
|
TextureRef m_heightMap;
|
||||||
TextureRef m_normalMap;
|
TextureRef m_normalMap;
|
||||||
TextureRef m_specularMap;
|
TextureRef m_specularMap;
|
||||||
UberShaderConstRef m_uberShader;
|
mutable bool m_pipelineUpdated;
|
||||||
mutable ShaderInstance m_shaders[ShaderFlags_Max + 1];
|
|
||||||
bool m_alphaTestEnabled;
|
|
||||||
bool m_depthSortingEnabled;
|
|
||||||
bool m_lightingEnabled;
|
|
||||||
bool m_shadowCastingEnabled;
|
bool m_shadowCastingEnabled;
|
||||||
bool m_shadowReceiveEnabled;
|
|
||||||
bool m_transformEnabled;
|
|
||||||
float m_alphaThreshold;
|
float m_alphaThreshold;
|
||||||
float m_shininess;
|
float m_shininess;
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,95 @@
|
||||||
|
// Copyright (C) 2016 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Engine - Graphics module"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef NAZARA_MATERIALPIPELINE_HPP
|
||||||
|
#define NAZARA_MATERIALPIPELINE_HPP
|
||||||
|
|
||||||
|
#include <Nazara/Prerequesites.hpp>
|
||||||
|
#include <Nazara/Graphics/Config.hpp>
|
||||||
|
#include <Nazara/Graphics/Enums.hpp>
|
||||||
|
#include <Nazara/Renderer/Enums.hpp>
|
||||||
|
#include <Nazara/Renderer/RenderPipeline.hpp>
|
||||||
|
#include <Nazara/Renderer/UberShader.hpp>
|
||||||
|
#include <Nazara/Utility/Enums.hpp>
|
||||||
|
#include <array>
|
||||||
|
|
||||||
|
namespace Nz
|
||||||
|
{
|
||||||
|
struct MaterialPipelineInfo : RenderStates
|
||||||
|
{
|
||||||
|
bool alphaTest = false;
|
||||||
|
bool depthSorting = false;
|
||||||
|
bool hasAlphaMap = false;
|
||||||
|
bool hasDiffuseMap = false;
|
||||||
|
bool hasEmissiveMap = false;
|
||||||
|
bool hasHeightMap = false;
|
||||||
|
bool hasNormalMap = false;
|
||||||
|
bool hasSpecularMap = false;
|
||||||
|
bool shadowReceive = true;
|
||||||
|
|
||||||
|
UberShaderConstRef uberShader;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline bool operator==(const MaterialPipelineInfo& lhs, const MaterialPipelineInfo& rhs);
|
||||||
|
inline bool operator!=(const MaterialPipelineInfo& lhs, const MaterialPipelineInfo& rhs);
|
||||||
|
|
||||||
|
class MaterialPipeline;
|
||||||
|
|
||||||
|
using MaterialPipelineConstRef = ObjectRef<const MaterialPipeline>;
|
||||||
|
using MaterialPipelineLibrary = ObjectLibrary<MaterialPipeline>;
|
||||||
|
using MaterialPipelineRef = ObjectRef<MaterialPipeline>;
|
||||||
|
|
||||||
|
class NAZARA_GRAPHICS_API MaterialPipeline : public RefCounted
|
||||||
|
{
|
||||||
|
friend class Graphics;
|
||||||
|
friend MaterialPipelineLibrary;
|
||||||
|
|
||||||
|
public:
|
||||||
|
struct Instance;
|
||||||
|
|
||||||
|
MaterialPipeline(const MaterialPipeline&) = delete;
|
||||||
|
MaterialPipeline(MaterialPipeline&&) = delete;
|
||||||
|
~MaterialPipeline() = default;
|
||||||
|
|
||||||
|
inline const Instance& Apply(UInt32 flags = ShaderFlags_None) const;
|
||||||
|
|
||||||
|
MaterialPipeline& operator=(const MaterialPipeline&) = delete;
|
||||||
|
MaterialPipeline& operator=(MaterialPipeline&&) = delete;
|
||||||
|
|
||||||
|
inline const MaterialPipelineInfo& GetInfo() const;
|
||||||
|
inline const Instance& GetInstance(UInt32 flags = ShaderFlags_None) const;
|
||||||
|
|
||||||
|
static MaterialPipelineRef GetPipeline(const MaterialPipelineInfo& pipelineInfo);
|
||||||
|
|
||||||
|
struct Instance
|
||||||
|
{
|
||||||
|
RenderPipeline renderPipeline;
|
||||||
|
UberShaderInstance* uberInstance = nullptr;
|
||||||
|
std::array<int, MaterialUniform_Max + 1> uniforms;
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
inline MaterialPipeline(const MaterialPipelineInfo& pipelineInfo);
|
||||||
|
|
||||||
|
void GenerateRenderPipeline(UInt32 flags) const;
|
||||||
|
|
||||||
|
static bool Initialize();
|
||||||
|
template<typename... Args> static MaterialPipelineRef New(Args&&... args);
|
||||||
|
static void Uninitialize();
|
||||||
|
|
||||||
|
MaterialPipelineInfo m_pipelineInfo;
|
||||||
|
mutable std::array<Instance, ShaderFlags_Max + 1> m_instances;
|
||||||
|
|
||||||
|
using PipelineCache = std::unordered_map<MaterialPipelineInfo, MaterialPipelineRef>;
|
||||||
|
static PipelineCache s_pipelineCache;
|
||||||
|
|
||||||
|
static MaterialPipelineLibrary::LibraryMap s_library;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <Nazara/Graphics/MaterialPipeline.inl>
|
||||||
|
|
||||||
|
#endif // NAZARA_MATERIALPIPELINE_HPP
|
||||||
|
|
@ -0,0 +1,143 @@
|
||||||
|
// Copyright (C) 2016 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Engine - Graphics module"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
|
#include <Nazara/Graphics/MaterialPipeline.hpp>
|
||||||
|
#include <Nazara/Core/Algorithm.hpp>
|
||||||
|
#include <Nazara/Renderer/Renderer.hpp>
|
||||||
|
#include <functional>
|
||||||
|
#include <Nazara/Graphics/Debug.hpp>
|
||||||
|
|
||||||
|
namespace Nz
|
||||||
|
{
|
||||||
|
inline MaterialPipeline::MaterialPipeline(const MaterialPipelineInfo& pipelineInfo) :
|
||||||
|
m_pipelineInfo(pipelineInfo)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Enable pipeline states for rendering
|
||||||
|
*
|
||||||
|
* \param flags Shader flags
|
||||||
|
*/
|
||||||
|
inline const MaterialPipeline::Instance& MaterialPipeline::Apply(UInt32 flags) const
|
||||||
|
{
|
||||||
|
const Instance& instance = GetInstance(flags);
|
||||||
|
instance.uberInstance->Activate();
|
||||||
|
|
||||||
|
Renderer::SetRenderStates(m_pipelineInfo);
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Retrieve a MaterialPipelineInfo object describing this pipeline
|
||||||
|
*
|
||||||
|
* \return Pipeline informations
|
||||||
|
*/
|
||||||
|
const MaterialPipelineInfo& MaterialPipeline::GetInfo() const
|
||||||
|
{
|
||||||
|
return m_pipelineInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Retrieve (and generate if required) a pipeline instance using shader flags without applying it
|
||||||
|
*
|
||||||
|
* \param flags Shader flags
|
||||||
|
*
|
||||||
|
* \return Pipeline instance
|
||||||
|
*/
|
||||||
|
inline const MaterialPipeline::Instance& MaterialPipeline::GetInstance(UInt32 flags) const
|
||||||
|
{
|
||||||
|
const Instance& instance = m_instances[flags];
|
||||||
|
if (!instance.uberInstance)
|
||||||
|
GenerateRenderPipeline(flags);
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const MaterialPipelineInfo& lhs, const MaterialPipelineInfo& rhs)
|
||||||
|
{
|
||||||
|
if (!operator==(static_cast<const RenderStates&>(lhs), static_cast<const RenderStates&>(rhs)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
#define NazaraPipelineMember(field) if (lhs.##field != rhs.##field) return false
|
||||||
|
#define NazaraPipelineBoolMember NazaraPipelineMember
|
||||||
|
|
||||||
|
NazaraPipelineBoolMember(alphaTest);
|
||||||
|
NazaraPipelineBoolMember(depthSorting);
|
||||||
|
NazaraPipelineBoolMember(hasAlphaMap);
|
||||||
|
NazaraPipelineBoolMember(hasDiffuseMap);
|
||||||
|
NazaraPipelineBoolMember(hasEmissiveMap);
|
||||||
|
NazaraPipelineBoolMember(hasHeightMap);
|
||||||
|
NazaraPipelineBoolMember(hasNormalMap);
|
||||||
|
NazaraPipelineBoolMember(hasSpecularMap);
|
||||||
|
NazaraPipelineBoolMember(shadowReceive);
|
||||||
|
|
||||||
|
NazaraPipelineMember(uberShader);
|
||||||
|
|
||||||
|
#undef NazaraPipelineMember
|
||||||
|
#undef NazaraPipelineBoolMember
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const MaterialPipelineInfo& lhs, const MaterialPipelineInfo& rhs)
|
||||||
|
{
|
||||||
|
return !operator==(lhs, rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Creates a new MaterialPipeline from the arguments
|
||||||
|
* \return A reference to the newly created material pipeline
|
||||||
|
*
|
||||||
|
* \param args Arguments for the material pipeline
|
||||||
|
*/
|
||||||
|
template<typename... Args>
|
||||||
|
MaterialPipelineRef MaterialPipeline::New(Args&&... args)
|
||||||
|
{
|
||||||
|
std::unique_ptr<MaterialPipeline> object(new MaterialPipeline(std::forward<Args>(args)...));
|
||||||
|
return object.release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
template<>
|
||||||
|
struct hash<Nz::MaterialPipelineInfo>
|
||||||
|
{
|
||||||
|
size_t operator()(const Nz::MaterialPipelineInfo& pipelineInfo) const
|
||||||
|
{
|
||||||
|
hash<Nz::RenderStates> parentHash;
|
||||||
|
|
||||||
|
std::size_t seed = parentHash(pipelineInfo);
|
||||||
|
|
||||||
|
Nz::UInt16 parameterHash = 0;
|
||||||
|
Nz::UInt16 parameterIndex = 0;
|
||||||
|
|
||||||
|
#define NazaraPipelineMember(member) Nz::HashCombine(seed, pipelineInfo.##member)
|
||||||
|
#define NazaraPipelineBoolMember(member) parameterHash |= ((pipelineInfo.##member) ? 1U : 0U) << (parameterIndex++)
|
||||||
|
|
||||||
|
NazaraPipelineBoolMember(alphaTest);
|
||||||
|
NazaraPipelineBoolMember(depthSorting);
|
||||||
|
NazaraPipelineBoolMember(hasAlphaMap);
|
||||||
|
NazaraPipelineBoolMember(hasDiffuseMap);
|
||||||
|
NazaraPipelineBoolMember(hasEmissiveMap);
|
||||||
|
NazaraPipelineBoolMember(hasHeightMap);
|
||||||
|
NazaraPipelineBoolMember(hasNormalMap);
|
||||||
|
NazaraPipelineBoolMember(hasSpecularMap);
|
||||||
|
NazaraPipelineBoolMember(shadowReceive);
|
||||||
|
|
||||||
|
NazaraPipelineMember(uberShader);
|
||||||
|
|
||||||
|
#undef NazaraPipelineMember
|
||||||
|
#undef NazaraPipelineBoolMember
|
||||||
|
|
||||||
|
Nz::HashCombine(seed, parameterHash);
|
||||||
|
|
||||||
|
return seed;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <Nazara/Graphics/DebugOff.hpp>
|
||||||
|
|
@ -45,6 +45,7 @@ namespace Nz
|
||||||
virtual ~Model();
|
virtual ~Model();
|
||||||
|
|
||||||
void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const override;
|
void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const override;
|
||||||
|
inline void AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix, unsigned int renderOrder = 0);
|
||||||
|
|
||||||
Material* GetMaterial(const String& subMeshName) const;
|
Material* GetMaterial(const String& subMeshName) const;
|
||||||
Material* GetMaterial(unsigned int matIndex) const;
|
Material* GetMaterial(unsigned int matIndex) const;
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,22 @@
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Adds this model to a render queue, using user-specified transform matrix and render order
|
||||||
|
*
|
||||||
|
* This can be useful when drawing particles
|
||||||
|
*
|
||||||
|
* \param renderQueue Queue to be added
|
||||||
|
* \param transformMatrix Transform matrix to be used for rendering the model
|
||||||
|
* \param renderOrder Specify the renderqueue layer to be used
|
||||||
|
*/
|
||||||
|
inline void Model::AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix, unsigned int renderOrder)
|
||||||
|
{
|
||||||
|
InstanceData instanceData(transformMatrix);
|
||||||
|
instanceData.renderOrder = renderOrder;
|
||||||
|
return AddToRenderQueue(renderQueue, instanceData);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Creates a new Model from the arguments
|
* \brief Creates a new Model from the arguments
|
||||||
* \return A reference to the newly created model
|
* \return A reference to the newly created model
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
class ParticleController;
|
class ParticleController;
|
||||||
class ParticleMapper;
|
class ParticleMapper;
|
||||||
class ParticleSystem;
|
class ParticleGroup;
|
||||||
|
|
||||||
using ParticleControllerConstRef = ObjectRef<const ParticleController>;
|
using ParticleControllerConstRef = ObjectRef<const ParticleController>;
|
||||||
using ParticleControllerLibrary = ObjectLibrary<ParticleController>;
|
using ParticleControllerLibrary = ObjectLibrary<ParticleController>;
|
||||||
|
|
@ -34,7 +34,7 @@ namespace Nz
|
||||||
ParticleController(const ParticleController& controller);
|
ParticleController(const ParticleController& controller);
|
||||||
virtual ~ParticleController();
|
virtual ~ParticleController();
|
||||||
|
|
||||||
virtual void Apply(ParticleSystem& system, ParticleMapper& mapper, unsigned int startId, unsigned int endId, float elapsedTime) = 0;
|
virtual void Apply(ParticleGroup& system, ParticleMapper& mapper, unsigned int startId, unsigned int endId, float elapsedTime) = 0;
|
||||||
|
|
||||||
// Signals:
|
// Signals:
|
||||||
NazaraSignal(OnParticleControllerRelease, const ParticleController* /*particleController*/);
|
NazaraSignal(OnParticleControllerRelease, const ParticleController* /*particleController*/);
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
#include <Nazara/Graphics/Config.hpp>
|
#include <Nazara/Graphics/Config.hpp>
|
||||||
#include <Nazara/Graphics/Enums.hpp>
|
#include <Nazara/Graphics/Enums.hpp>
|
||||||
#include <Nazara/Utility/Enums.hpp>
|
#include <Nazara/Utility/Enums.hpp>
|
||||||
|
#include <array>
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
|
|
@ -46,6 +47,7 @@ namespace Nz
|
||||||
|
|
||||||
static ParticleDeclaration* Get(ParticleLayout layout);
|
static ParticleDeclaration* Get(ParticleLayout layout);
|
||||||
static bool IsTypeSupported(ComponentType type);
|
static bool IsTypeSupported(ComponentType type);
|
||||||
|
template<typename... Args> static ParticleDeclarationRef New(Args&&... args);
|
||||||
|
|
||||||
// Signals:
|
// Signals:
|
||||||
NazaraSignal(OnParticleDeclarationRelease, const ParticleDeclaration* /*particleDeclaration*/);
|
NazaraSignal(OnParticleDeclarationRelease, const ParticleDeclaration* /*particleDeclaration*/);
|
||||||
|
|
@ -68,12 +70,14 @@ namespace Nz
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
Component m_components[ParticleComponent_Max + 1];
|
std::array<Component, ParticleComponent_Max + 1> m_components;
|
||||||
unsigned int m_stride;
|
unsigned int m_stride;
|
||||||
|
|
||||||
static ParticleDeclaration s_declarations[ParticleLayout_Max + 1];
|
static std::array<ParticleDeclaration, ParticleLayout_Max + 1> s_declarations;
|
||||||
static ParticleDeclarationLibrary::LibraryMap s_library;
|
static ParticleDeclarationLibrary::LibraryMap s_library;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include <Nazara/Graphics/ParticleDeclaration.inl>
|
||||||
|
|
||||||
#endif // NAZARA_PARTICLEDECLARATION_HPP
|
#endif // NAZARA_PARTICLEDECLARATION_HPP
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
// Copyright (C) 2016 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Engine - Graphics module"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <Nazara/Utility/Debug.hpp>
|
||||||
|
|
||||||
|
namespace Nz
|
||||||
|
{
|
||||||
|
template<typename... Args>
|
||||||
|
ParticleDeclarationRef ParticleDeclaration::New(Args&&... args)
|
||||||
|
{
|
||||||
|
std::unique_ptr<ParticleDeclaration> object(new ParticleDeclaration(std::forward<Args>(args)...));
|
||||||
|
return object.release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <Nazara/Utility/DebugOff.hpp>
|
||||||
|
|
@ -8,23 +8,23 @@
|
||||||
#define NAZARA_PARTICLEEMITTER_HPP
|
#define NAZARA_PARTICLEEMITTER_HPP
|
||||||
|
|
||||||
#include <Nazara/Prerequesites.hpp>
|
#include <Nazara/Prerequesites.hpp>
|
||||||
|
#include <Nazara/Core/Signal.hpp>
|
||||||
#include <Nazara/Graphics/Config.hpp>
|
#include <Nazara/Graphics/Config.hpp>
|
||||||
#include <Nazara/Utility/Node.hpp>
|
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
class ParticleMapper;
|
class ParticleMapper;
|
||||||
class ParticleSystem;
|
class ParticleGroup;
|
||||||
|
|
||||||
class NAZARA_GRAPHICS_API ParticleEmitter : public Node
|
class NAZARA_GRAPHICS_API ParticleEmitter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ParticleEmitter();
|
ParticleEmitter();
|
||||||
ParticleEmitter(const ParticleEmitter& emitter) = default;
|
ParticleEmitter(const ParticleEmitter& emitter);
|
||||||
ParticleEmitter(ParticleEmitter&& emitter) = default;
|
ParticleEmitter(ParticleEmitter&& emitter);
|
||||||
virtual ~ParticleEmitter();
|
virtual ~ParticleEmitter();
|
||||||
|
|
||||||
virtual void Emit(ParticleSystem& system, float elapsedTime) const;
|
virtual void Emit(ParticleGroup& system, float elapsedTime) const;
|
||||||
|
|
||||||
void EnableLagCompensation(bool enable);
|
void EnableLagCompensation(bool enable);
|
||||||
|
|
||||||
|
|
@ -37,7 +37,11 @@ namespace Nz
|
||||||
void SetEmissionRate(float rate);
|
void SetEmissionRate(float rate);
|
||||||
|
|
||||||
ParticleEmitter& operator=(const ParticleEmitter& emitter) = default;
|
ParticleEmitter& operator=(const ParticleEmitter& emitter) = default;
|
||||||
ParticleEmitter& operator=(ParticleEmitter&& emitter) = default;
|
ParticleEmitter& operator=(ParticleEmitter&& emitter);
|
||||||
|
|
||||||
|
// Signals:
|
||||||
|
NazaraSignal(OnParticleEmitterMove, ParticleEmitter* /*oldParticleEmitter*/, ParticleEmitter* /*newParticleEmitter*/);
|
||||||
|
NazaraSignal(OnParticleEmitterRelease, const ParticleEmitter* /*particleEmitter*/);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void SetupParticles(ParticleMapper& mapper, unsigned int count) const = 0;
|
virtual void SetupParticles(ParticleMapper& mapper, unsigned int count) const = 0;
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
class ParticleGenerator;
|
class ParticleGenerator;
|
||||||
class ParticleMapper;
|
class ParticleMapper;
|
||||||
class ParticleSystem;
|
class ParticleGroup;
|
||||||
|
|
||||||
using ParticleGeneratorConstRef = ObjectRef<const ParticleGenerator>;
|
using ParticleGeneratorConstRef = ObjectRef<const ParticleGenerator>;
|
||||||
using ParticleGeneratorLibrary = ObjectLibrary<ParticleGenerator>;
|
using ParticleGeneratorLibrary = ObjectLibrary<ParticleGenerator>;
|
||||||
|
|
@ -34,7 +34,7 @@ namespace Nz
|
||||||
ParticleGenerator(const ParticleGenerator& generator);
|
ParticleGenerator(const ParticleGenerator& generator);
|
||||||
virtual ~ParticleGenerator();
|
virtual ~ParticleGenerator();
|
||||||
|
|
||||||
virtual void Generate(ParticleSystem& system, ParticleMapper& mapper, unsigned int startId, unsigned int endId) = 0;
|
virtual void Generate(ParticleGroup& system, ParticleMapper& mapper, unsigned int startId, unsigned int endId) = 0;
|
||||||
|
|
||||||
// Signals:
|
// Signals:
|
||||||
NazaraSignal(OnParticleGeneratorRelease, const ParticleGenerator* /*particleGenerator*/);
|
NazaraSignal(OnParticleGeneratorRelease, const ParticleGenerator* /*particleGenerator*/);
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,11 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifndef NAZARA_PARTICLESYSTEM_HPP
|
#ifndef NAZARA_PARTICLEGROUP_HPP
|
||||||
#define NAZARA_PARTICLESYSTEM_HPP
|
#define NAZARA_PARTICLEGROUP_HPP
|
||||||
|
|
||||||
#include <Nazara/Prerequesites.hpp>
|
#include <Nazara/Prerequesites.hpp>
|
||||||
|
#include <Nazara/Core/signal.hpp>
|
||||||
#include <Nazara/Graphics/ParticleController.hpp>
|
#include <Nazara/Graphics/ParticleController.hpp>
|
||||||
#include <Nazara/Graphics/ParticleDeclaration.hpp>
|
#include <Nazara/Graphics/ParticleDeclaration.hpp>
|
||||||
#include <Nazara/Graphics/ParticleEmitter.hpp>
|
#include <Nazara/Graphics/ParticleEmitter.hpp>
|
||||||
|
|
@ -22,13 +23,13 @@
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
class NAZARA_GRAPHICS_API ParticleSystem : public Renderable
|
class NAZARA_GRAPHICS_API ParticleGroup : public Renderable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ParticleSystem(unsigned int maxParticleCount, ParticleLayout layout);
|
ParticleGroup(unsigned int maxParticleCount, ParticleLayout layout);
|
||||||
ParticleSystem(unsigned int maxParticleCount, ParticleDeclarationConstRef declaration);
|
ParticleGroup(unsigned int maxParticleCount, ParticleDeclarationConstRef declaration);
|
||||||
ParticleSystem(const ParticleSystem& emitter);
|
ParticleGroup(const ParticleGroup& emitter);
|
||||||
~ParticleSystem();
|
~ParticleGroup();
|
||||||
|
|
||||||
void AddController(ParticleControllerRef controller);
|
void AddController(ParticleControllerRef controller);
|
||||||
void AddEmitter(ParticleEmitter* emitter);
|
void AddEmitter(ParticleEmitter* emitter);
|
||||||
|
|
@ -40,19 +41,14 @@ namespace Nz
|
||||||
void* CreateParticle();
|
void* CreateParticle();
|
||||||
void* CreateParticles(unsigned int count);
|
void* CreateParticles(unsigned int count);
|
||||||
|
|
||||||
void EnableFixedStep(bool fixedStep);
|
|
||||||
|
|
||||||
void* GenerateParticle();
|
void* GenerateParticle();
|
||||||
void* GenerateParticles(unsigned int count);
|
void* GenerateParticles(unsigned int count);
|
||||||
|
|
||||||
const ParticleDeclarationConstRef& GetDeclaration() const;
|
const ParticleDeclarationConstRef& GetDeclaration() const;
|
||||||
float GetFixedStepSize() const;
|
|
||||||
unsigned int GetMaxParticleCount() const;
|
unsigned int GetMaxParticleCount() const;
|
||||||
unsigned int GetParticleCount() const;
|
unsigned int GetParticleCount() const;
|
||||||
unsigned int GetParticleSize() const;
|
unsigned int GetParticleSize() const;
|
||||||
|
|
||||||
bool IsFixedStepEnabled() const;
|
|
||||||
|
|
||||||
void KillParticle(unsigned int index);
|
void KillParticle(unsigned int index);
|
||||||
void KillParticles();
|
void KillParticles();
|
||||||
|
|
||||||
|
|
@ -60,33 +56,42 @@ namespace Nz
|
||||||
void RemoveEmitter(ParticleEmitter* emitter);
|
void RemoveEmitter(ParticleEmitter* emitter);
|
||||||
void RemoveGenerator(ParticleGenerator* generator);
|
void RemoveGenerator(ParticleGenerator* generator);
|
||||||
|
|
||||||
void SetFixedStepSize(float stepSize);
|
|
||||||
void SetRenderer(ParticleRenderer* renderer);
|
void SetRenderer(ParticleRenderer* renderer);
|
||||||
|
|
||||||
void Update(float elapsedTime);
|
void Update(float elapsedTime);
|
||||||
void UpdateBoundingVolume(const Matrix4f& transformMatrix) override;
|
void UpdateBoundingVolume(const Matrix4f& transformMatrix) override;
|
||||||
|
|
||||||
ParticleSystem& operator=(const ParticleSystem& emitter);
|
ParticleGroup& operator=(const ParticleGroup& emitter);
|
||||||
|
|
||||||
|
// Signals:
|
||||||
|
NazaraSignal(OnParticleGroupRelease, const ParticleGroup* /*particleGroup*/);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void MakeBoundingVolume() const override;
|
void MakeBoundingVolume() const override;
|
||||||
|
void OnEmitterMove(ParticleEmitter* oldEmitter, ParticleEmitter* newEmitter);
|
||||||
|
void OnEmitterRelease(const ParticleEmitter* emitter);
|
||||||
void ResizeBuffer();
|
void ResizeBuffer();
|
||||||
|
|
||||||
|
struct EmitterEntry
|
||||||
|
{
|
||||||
|
NazaraSlot(ParticleEmitter, OnParticleEmitterMove, moveSlot);
|
||||||
|
NazaraSlot(ParticleEmitter, OnParticleEmitterRelease, releaseSlot);
|
||||||
|
|
||||||
|
ParticleEmitter* emitter;
|
||||||
|
};
|
||||||
|
|
||||||
std::set<unsigned int, std::greater<unsigned int>> m_dyingParticles;
|
std::set<unsigned int, std::greater<unsigned int>> m_dyingParticles;
|
||||||
mutable std::vector<UInt8> m_buffer;
|
mutable std::vector<UInt8> m_buffer;
|
||||||
std::vector<ParticleControllerRef> m_controllers;
|
std::vector<ParticleControllerRef> m_controllers;
|
||||||
std::vector<ParticleEmitter*> m_emitters;
|
std::vector<EmitterEntry> m_emitters;
|
||||||
std::vector<ParticleGeneratorRef> m_generators;
|
std::vector<ParticleGeneratorRef> m_generators;
|
||||||
ParticleDeclarationConstRef m_declaration;
|
ParticleDeclarationConstRef m_declaration;
|
||||||
ParticleRendererRef m_renderer;
|
ParticleRendererRef m_renderer;
|
||||||
bool m_fixedStepEnabled;
|
|
||||||
bool m_processing;
|
bool m_processing;
|
||||||
float m_stepAccumulator;
|
|
||||||
float m_stepSize;
|
|
||||||
unsigned int m_maxParticleCount;
|
unsigned int m_maxParticleCount;
|
||||||
unsigned int m_particleCount;
|
unsigned int m_particleCount;
|
||||||
unsigned int m_particleSize;
|
unsigned int m_particleSize;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // NAZARA_PARTICLESYSTEM_HPP
|
#endif // NAZARA_PARTICLEGROUP_HPP
|
||||||
|
|
@ -19,7 +19,7 @@ namespace Nz
|
||||||
class AbstractRenderQueue;
|
class AbstractRenderQueue;
|
||||||
class ParticleMapper;
|
class ParticleMapper;
|
||||||
class ParticleRenderer;
|
class ParticleRenderer;
|
||||||
class ParticleSystem;
|
class ParticleGroup;
|
||||||
|
|
||||||
using ParticleRendererConstRef = ObjectRef<const ParticleRenderer>;
|
using ParticleRendererConstRef = ObjectRef<const ParticleRenderer>;
|
||||||
using ParticleRendererLibrary = ObjectLibrary<ParticleRenderer>;
|
using ParticleRendererLibrary = ObjectLibrary<ParticleRenderer>;
|
||||||
|
|
@ -35,7 +35,7 @@ namespace Nz
|
||||||
ParticleRenderer(const ParticleRenderer& renderer);
|
ParticleRenderer(const ParticleRenderer& renderer);
|
||||||
virtual ~ParticleRenderer();
|
virtual ~ParticleRenderer();
|
||||||
|
|
||||||
virtual void Render(const ParticleSystem& system, const ParticleMapper& mapper, unsigned int startId, unsigned int endId, AbstractRenderQueue* renderQueue) = 0;
|
virtual void Render(const ParticleGroup& system, const ParticleMapper& mapper, unsigned int startId, unsigned int endId, AbstractRenderQueue* renderQueue) = 0;
|
||||||
|
|
||||||
// Signals:
|
// Signals:
|
||||||
NazaraSignal(OnParticleRendererRelease, const ParticleRenderer* /*particleRenderer*/);
|
NazaraSignal(OnParticleRendererRelease, const ParticleRenderer* /*particleRenderer*/);
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,8 @@ namespace Nz
|
||||||
struct ParticleStruct_Sprite
|
struct ParticleStruct_Sprite
|
||||||
{
|
{
|
||||||
Color color;
|
Color color;
|
||||||
Vector2f position;
|
Vector3f position;
|
||||||
Vector2f velocity;
|
Vector3f velocity;
|
||||||
UInt32 life;
|
UInt32 life;
|
||||||
float rotation;
|
float rotation;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,7 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Updates the bounding volume by a matrix
|
* \brief Updates the bounding volume
|
||||||
*
|
|
||||||
* \param transformMatrix Matrix transformation for our bounding volume
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline void Renderable::UpdateBoundingVolume() const
|
inline void Renderable::UpdateBoundingVolume() const
|
||||||
|
|
|
||||||
|
|
@ -123,8 +123,7 @@ namespace Nz
|
||||||
inline void Sprite::SetDefaultMaterial()
|
inline void Sprite::SetDefaultMaterial()
|
||||||
{
|
{
|
||||||
MaterialRef material = Material::New();
|
MaterialRef material = Material::New();
|
||||||
material->Enable(RendererParameter_FaceCulling, false);
|
material->EnableFaceCulling(false);
|
||||||
material->EnableLighting(false);
|
|
||||||
|
|
||||||
SetMaterial(std::move(material));
|
SetMaterial(std::move(material));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -119,10 +119,9 @@ namespace Nz
|
||||||
inline void TextSprite::SetDefaultMaterial()
|
inline void TextSprite::SetDefaultMaterial()
|
||||||
{
|
{
|
||||||
MaterialRef material = Material::New();
|
MaterialRef material = Material::New();
|
||||||
material->Enable(RendererParameter_Blend, true);
|
material->EnableBlending(true);
|
||||||
material->Enable(RendererParameter_DepthWrite, false);
|
material->EnableDepthWrite(false);
|
||||||
material->Enable(RendererParameter_FaceCulling, false);
|
material->EnableFaceCulling(false);
|
||||||
material->EnableLighting(false);
|
|
||||||
material->SetDstBlend(BlendFunc_InvSrcAlpha);
|
material->SetDstBlend(BlendFunc_InvSrcAlpha);
|
||||||
material->SetSrcBlend(BlendFunc_SrcAlpha);
|
material->SetSrcBlend(BlendFunc_SrcAlpha);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,97 @@
|
||||||
|
// Copyright (C) 2016 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Engine - Graphics module"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef NAZARA_TILEMAP_HPP
|
||||||
|
#define NAZARA_TILEMAP_HPP
|
||||||
|
|
||||||
|
#include <Nazara/Prerequesites.hpp>
|
||||||
|
#include <Nazara/Graphics/InstancedRenderable.hpp>
|
||||||
|
#include <Nazara/Graphics/Material.hpp>
|
||||||
|
#include <Nazara/Utility/VertexStruct.hpp>
|
||||||
|
#include <array>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
|
namespace Nz
|
||||||
|
{
|
||||||
|
class TileMap;
|
||||||
|
|
||||||
|
using TileMapConstRef = ObjectRef<const TileMap>;
|
||||||
|
using TileMapLibrary = ObjectLibrary<TileMap>;
|
||||||
|
using TileMapRef = ObjectRef<TileMap>;
|
||||||
|
|
||||||
|
class NAZARA_GRAPHICS_API TileMap : public InstancedRenderable
|
||||||
|
{
|
||||||
|
friend TileMapLibrary;
|
||||||
|
friend class Graphics;
|
||||||
|
|
||||||
|
public:
|
||||||
|
struct Tile;
|
||||||
|
|
||||||
|
inline TileMap(const Nz::Vector2ui& mapSize, const Nz::Vector2f& tileSize, std::size_t materialCount = 1);
|
||||||
|
TileMap(const TileMap& TileMap) = default;
|
||||||
|
TileMap(TileMap&&) = delete;
|
||||||
|
~TileMap() = default;
|
||||||
|
|
||||||
|
void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const override;
|
||||||
|
|
||||||
|
inline void DisableTile(const Vector2ui& tilePos);
|
||||||
|
inline void DisableTiles();
|
||||||
|
inline void DisableTiles(const Vector2ui* tilesPos, std::size_t tileCount);
|
||||||
|
|
||||||
|
inline void EnableTile(const Vector2ui& tilePos, const Rectf& coords, const Color& color = Color::White, std::size_t materialIndex = 0U);
|
||||||
|
inline void EnableTile(const Vector2ui& tilePos, const Rectui& rect, const Color& color = Color::White, std::size_t materialIndex = 0U);
|
||||||
|
inline void EnableTiles(const Rectf& coords, const Color& color = Color::White, std::size_t materialIndex = 0U);
|
||||||
|
inline void EnableTiles(const Rectui& rect, const Color& color = Color::White, std::size_t materialIndex = 0U);
|
||||||
|
inline void EnableTiles(const Vector2ui* tilesPos, std::size_t tileCount, const Rectf& coords, const Color& color = Color::White, std::size_t materialIndex = 0U);
|
||||||
|
inline void EnableTiles(const Vector2ui* tilesPos, std::size_t tileCount, const Rectui& rect, const Color& color = Color::White, std::size_t materialIndex = 0U);
|
||||||
|
|
||||||
|
inline const MaterialRef& GetMaterial(std::size_t index) const;
|
||||||
|
inline std::size_t GetMaterialCount() const;
|
||||||
|
inline const Vector2ui& GetMapSize() const;
|
||||||
|
inline Vector2f GetSize() const;
|
||||||
|
inline const Tile& GetTile(const Vector2ui& tilePos) const;
|
||||||
|
inline const Vector2f& GetTileSize() const;
|
||||||
|
|
||||||
|
inline void SetMaterial(std::size_t index, MaterialRef material);
|
||||||
|
|
||||||
|
inline TileMap& operator=(const TileMap& TileMap);
|
||||||
|
TileMap& operator=(TileMap&& TileMap) = delete;
|
||||||
|
|
||||||
|
template<typename... Args> static TileMapRef New(Args&&... args);
|
||||||
|
|
||||||
|
struct Tile
|
||||||
|
{
|
||||||
|
std::size_t layerIndex = 0U;
|
||||||
|
Color color = Color::White;
|
||||||
|
Rectf textureCoords = Rectf::Zero();
|
||||||
|
bool enabled = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
void MakeBoundingVolume() const override;
|
||||||
|
void UpdateData(InstanceData* instanceData) const override;
|
||||||
|
|
||||||
|
static bool Initialize();
|
||||||
|
static void Uninitialize();
|
||||||
|
|
||||||
|
struct Layer
|
||||||
|
{
|
||||||
|
MaterialRef material;
|
||||||
|
std::set<std::size_t> tiles;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<Tile> m_tiles;
|
||||||
|
std::vector<Layer> m_layers;
|
||||||
|
Vector2ui m_mapSize;
|
||||||
|
Vector2f m_tileSize;
|
||||||
|
|
||||||
|
static TileMapLibrary::LibraryMap s_library;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <Nazara/Graphics/TileMap.inl>
|
||||||
|
|
||||||
|
#endif // NAZARA_TILEMAP_HPP
|
||||||
|
|
@ -0,0 +1,441 @@
|
||||||
|
// Copyright (C) 2015 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Engine - Graphics module"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
|
#include <Nazara/Graphics/TileMap.hpp>
|
||||||
|
#include <Nazara/Core/Error.hpp>
|
||||||
|
#include <memory>
|
||||||
|
#include <Nazara/Graphics/Debug.hpp>
|
||||||
|
|
||||||
|
namespace Nz
|
||||||
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Constructs a TileMap object, containing mapSize tileSize-sized tiles
|
||||||
|
*
|
||||||
|
* \param mapSize Number of tiles in each dimension, must be
|
||||||
|
* \param tileSize Size of each tile of the TileMap
|
||||||
|
* \param materialCount The maximum number of differents Material this TileMap will use
|
||||||
|
*
|
||||||
|
* \remark When constructed, a TileMap has no tile active and will not be rendered
|
||||||
|
* To use it, you have to enable some tiles.
|
||||||
|
*
|
||||||
|
* \remark The default material is used for every material requested
|
||||||
|
*/
|
||||||
|
inline TileMap::TileMap(const Nz::Vector2ui& mapSize, const Nz::Vector2f& tileSize, std::size_t materialCount) :
|
||||||
|
m_tiles(mapSize.x * mapSize.y),
|
||||||
|
m_layers(materialCount),
|
||||||
|
m_mapSize(mapSize),
|
||||||
|
m_tileSize(tileSize)
|
||||||
|
{
|
||||||
|
NazaraAssert(m_tiles.size() != 0U, "Invalid map size");
|
||||||
|
NazaraAssert(m_tileSize.x != 0U && m_tileSize.y != 0U, "Invalid tile size");
|
||||||
|
NazaraAssert(m_layers.size() != 0U, "Invalid material count");
|
||||||
|
|
||||||
|
for (Layer& layer : m_layers)
|
||||||
|
layer.material = Material::GetDefault();
|
||||||
|
|
||||||
|
InvalidateBoundingVolume();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Disable the tile at position tilePos, disabling rendering at this location
|
||||||
|
*
|
||||||
|
* \param tilePos Position of the tile to disable
|
||||||
|
*
|
||||||
|
* \see DisableTiles
|
||||||
|
*/
|
||||||
|
inline void TileMap::DisableTile(const Vector2ui& tilePos)
|
||||||
|
{
|
||||||
|
NazaraAssert(tilePos.x < m_mapSize.x && tilePos.y < m_mapSize.y, "Tile position is out of bounds");
|
||||||
|
|
||||||
|
std::size_t tileIndex = tilePos.y * m_mapSize.x + tilePos.x;
|
||||||
|
Tile& tile = m_tiles[tileIndex];
|
||||||
|
tile.enabled = false;
|
||||||
|
|
||||||
|
m_layers[tile.layerIndex].tiles.erase(tileIndex);
|
||||||
|
|
||||||
|
InvalidateInstanceData(1U << tile.layerIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Disable all tiles
|
||||||
|
*/
|
||||||
|
inline void TileMap::DisableTiles()
|
||||||
|
{
|
||||||
|
for (Tile& tile : m_tiles)
|
||||||
|
tile.enabled = false;
|
||||||
|
|
||||||
|
for (Layer& layer : m_layers)
|
||||||
|
layer.tiles.clear();
|
||||||
|
|
||||||
|
InvalidateInstanceData(0xFFFFFFFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Disable tileCount tiles at positions contained at tilesPos location, disabling rendering at those locations
|
||||||
|
*
|
||||||
|
* This is equivalent to calling tileCount times DisableTile with the positions contained at tilesPos
|
||||||
|
*
|
||||||
|
* \param tilesPos Pointer to a valid array of at least tileCount positions
|
||||||
|
* \param tileCount Number of tiles to disable
|
||||||
|
*
|
||||||
|
* \remark if tileCount is zero, this is a no-op and the value of tilesPos is not used
|
||||||
|
*
|
||||||
|
* \see DisableTile
|
||||||
|
*/
|
||||||
|
inline void TileMap::DisableTiles(const Vector2ui* tilesPos, std::size_t tileCount)
|
||||||
|
{
|
||||||
|
NazaraAssert(tilesPos || tileCount == 0, "Invalid tile position array with a non-zero tileCount");
|
||||||
|
|
||||||
|
UInt32 invalidatedLayers = 0;
|
||||||
|
|
||||||
|
for (std::size_t i = 0; i < tileCount; ++i)
|
||||||
|
{
|
||||||
|
NazaraAssert(tilesPos->x < m_mapSize.x && tilesPos->y < m_mapSize.y, "Tile position is out of bounds");
|
||||||
|
|
||||||
|
std::size_t tileIndex = tilesPos->y * m_mapSize.x + tilesPos->x;
|
||||||
|
Tile& tile = m_tiles[tileIndex];
|
||||||
|
tile.enabled = false;
|
||||||
|
|
||||||
|
m_layers[tile.layerIndex].tiles.erase(tileIndex);
|
||||||
|
|
||||||
|
invalidatedLayers |= 1U << tile.layerIndex;
|
||||||
|
|
||||||
|
tilesPos++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tileCount > 0)
|
||||||
|
InvalidateInstanceData(invalidatedLayers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Enable and sets the tile at position tilePos
|
||||||
|
*
|
||||||
|
* Setup the tile at position tilePos using color, normalized coordinates coords and materialIndex
|
||||||
|
*
|
||||||
|
* \param tilePos Position of the tile to enable
|
||||||
|
* \param coords Normalized coordinates ([0..1]) used to specify which region of the material textures will be used
|
||||||
|
* \param color The multiplicative color applied to the tile
|
||||||
|
* \param materialIndex The material which will be used for rendering this tile
|
||||||
|
*
|
||||||
|
* \see EnableTiles
|
||||||
|
*/
|
||||||
|
inline void TileMap::EnableTile(const Vector2ui& tilePos, const Rectf& coords, const Color& color, std::size_t materialIndex)
|
||||||
|
{
|
||||||
|
NazaraAssert(tilePos.x < m_mapSize.x && tilePos.y < m_mapSize.y, "Tile position is out of bounds");
|
||||||
|
NazaraAssert(materialIndex < m_layers.size(), "Material out of bounds");
|
||||||
|
|
||||||
|
UInt32 invalidatedLayers = 1U << materialIndex;
|
||||||
|
|
||||||
|
std::size_t tileIndex = tilePos.y * m_mapSize.x + tilePos.x;
|
||||||
|
Tile& tile = m_tiles[tilePos.y * m_mapSize.x + tilePos.x];
|
||||||
|
|
||||||
|
if (!tile.enabled)
|
||||||
|
m_layers[materialIndex].tiles.insert(tileIndex);
|
||||||
|
else if (materialIndex != tile.layerIndex)
|
||||||
|
{
|
||||||
|
m_layers[materialIndex].tiles.erase(tileIndex);
|
||||||
|
m_layers[tile.layerIndex].tiles.insert(tileIndex);
|
||||||
|
|
||||||
|
invalidatedLayers |= 1U << tile.layerIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
tile.enabled = true;
|
||||||
|
tile.color = color;
|
||||||
|
tile.textureCoords = coords;
|
||||||
|
tile.layerIndex = materialIndex;
|
||||||
|
|
||||||
|
InvalidateInstanceData(invalidatedLayers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Enable and sets the tile at position tilePos
|
||||||
|
*
|
||||||
|
* Setup the tile at position tilePos using color, unnormalized coordinates rect and materialIndex
|
||||||
|
*
|
||||||
|
* \param tilePos Position of the tile to enable
|
||||||
|
* \param coords Unnormalized coordinates ([0..size]) used to specify which region of the material textures will be used
|
||||||
|
* \param color The multiplicative color applied to the tile
|
||||||
|
* \param materialIndex The material which will be used for rendering this tile
|
||||||
|
*
|
||||||
|
* \remark The material at [materialIndex] must have a valid diffuse map before using this function,
|
||||||
|
* as the size of the material diffuse map is used to compute normalized texture coordinates before returning.
|
||||||
|
*
|
||||||
|
* \see EnableTiles
|
||||||
|
*/
|
||||||
|
inline void TileMap::EnableTile(const Vector2ui& tilePos, const Rectui& rect, const Color& color, std::size_t materialIndex)
|
||||||
|
{
|
||||||
|
NazaraAssert(materialIndex < m_layers.size(), "Material out of bounds");
|
||||||
|
NazaraAssert(m_layers[materialIndex].material->HasDiffuseMap(), "Material has no diffuse map");
|
||||||
|
|
||||||
|
Texture* diffuseMap = m_layers[materialIndex].material->GetDiffuseMap();
|
||||||
|
float invWidth = 1.f / diffuseMap->GetWidth();
|
||||||
|
float invHeight = 1.f / diffuseMap->GetHeight();
|
||||||
|
|
||||||
|
Rectf unnormalizedCoords(invWidth * rect.x, invHeight * rect.y, invWidth * rect.width, invHeight * rect.height);
|
||||||
|
EnableTile(tilePos, unnormalizedCoords, color, materialIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Enable and sets all the tiles
|
||||||
|
*
|
||||||
|
* Setup all tiles using color, normalized coordinates coords and materialIndex
|
||||||
|
*
|
||||||
|
* \param coords Normalized coordinates ([0..1]) used to specify which region of the material textures will be used
|
||||||
|
* \param color The multiplicative color applied to the tile
|
||||||
|
* \param materialIndex The material which will be used for rendering this tile
|
||||||
|
*
|
||||||
|
* \remark The material at [materialIndex] must have a valid diffuse map before using this function,
|
||||||
|
* as the size of the material diffuse map is used to compute normalized texture coordinates before returning.
|
||||||
|
*
|
||||||
|
* \see EnableTile
|
||||||
|
*/
|
||||||
|
inline void TileMap::EnableTiles(const Rectf& coords, const Color& color, std::size_t materialIndex)
|
||||||
|
{
|
||||||
|
NazaraAssert(materialIndex < m_layers.size(), "Material out of bounds");
|
||||||
|
|
||||||
|
for (Layer& layer : m_layers)
|
||||||
|
layer.tiles.clear();
|
||||||
|
|
||||||
|
std::size_t tileIndex = 0;
|
||||||
|
for (Tile& tile : m_tiles)
|
||||||
|
{
|
||||||
|
tile.enabled = true;
|
||||||
|
tile.color = color;
|
||||||
|
tile.textureCoords = coords;
|
||||||
|
tile.layerIndex = materialIndex;
|
||||||
|
|
||||||
|
m_layers[materialIndex].tiles.insert(tileIndex++);
|
||||||
|
}
|
||||||
|
|
||||||
|
InvalidateInstanceData(0xFFFFFFFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Enable and sets all the tiles
|
||||||
|
*
|
||||||
|
* Setup all tiles using color, unnormalized coordinates coords and materialIndex
|
||||||
|
*
|
||||||
|
* \param coords Unnormalized coordinates ([0..size]) used to specify which region of the material textures will be used
|
||||||
|
* \param color The multiplicative color applied to the tile
|
||||||
|
* \param materialIndex The material which will be used for rendering this tile
|
||||||
|
*
|
||||||
|
* \remark The material at [materialIndex] must have a valid diffuse map before using this function,
|
||||||
|
* as the size of the material diffuse map is used to compute normalized texture coordinates before returning.
|
||||||
|
*
|
||||||
|
* \see EnableTile
|
||||||
|
*/
|
||||||
|
inline void TileMap::EnableTiles(const Rectui& rect, const Color& color, std::size_t materialIndex)
|
||||||
|
{
|
||||||
|
NazaraAssert(materialIndex < m_layers.size(), "Material out of bounds");
|
||||||
|
|
||||||
|
Texture* diffuseMap = m_layers[materialIndex].material->GetDiffuseMap();
|
||||||
|
float invWidth = 1.f / diffuseMap->GetWidth();
|
||||||
|
float invHeight = 1.f / diffuseMap->GetHeight();
|
||||||
|
|
||||||
|
Rectf unnormalizedCoords(invWidth * rect.x, invHeight * rect.y, invWidth * rect.width, invHeight * rect.height);
|
||||||
|
EnableTiles(unnormalizedCoords, color, materialIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Enable and sets tileCount tiles at positions contained at tilesPos location, enabling rendering at those locations
|
||||||
|
*
|
||||||
|
* Setup all tiles using color, normalized coordinates coords and materialIndex
|
||||||
|
*
|
||||||
|
* \param tilesPos Pointer to a valid array of at least tileCount positions
|
||||||
|
* \param tileCount Number of tiles to enable
|
||||||
|
* \param coords Normalized coordinates ([0..1]) used to specify which region of the material textures will be used
|
||||||
|
* \param color The multiplicative color applied to the tile
|
||||||
|
* \param materialIndex The material which will be used for rendering this tile
|
||||||
|
*
|
||||||
|
* \see EnableTile
|
||||||
|
*/
|
||||||
|
inline void TileMap::EnableTiles(const Vector2ui* tilesPos, std::size_t tileCount, const Rectf& coords, const Color& color, std::size_t materialIndex)
|
||||||
|
{
|
||||||
|
NazaraAssert(tilesPos || tileCount == 0, "Invalid tile position array with a non-zero tileCount");
|
||||||
|
NazaraAssert(materialIndex < m_layers.size(), "Material out of bounds");
|
||||||
|
|
||||||
|
UInt32 invalidatedLayers = 1U << materialIndex;
|
||||||
|
|
||||||
|
for (std::size_t i = 0; i < tileCount; ++i)
|
||||||
|
{
|
||||||
|
NazaraAssert(tilesPos->x < m_mapSize.x && tilesPos->y < m_mapSize.y, "Tile position is out of bounds");
|
||||||
|
|
||||||
|
std::size_t tileIndex = tilesPos->y * m_mapSize.x + tilesPos->x;
|
||||||
|
Tile& tile = m_tiles[tileIndex];
|
||||||
|
|
||||||
|
if (!tile.enabled)
|
||||||
|
m_layers[materialIndex].tiles.insert(tileIndex);
|
||||||
|
else if (materialIndex != tile.layerIndex)
|
||||||
|
{
|
||||||
|
m_layers[materialIndex].tiles.erase(tileIndex);
|
||||||
|
m_layers[tile.layerIndex].tiles.insert(tileIndex);
|
||||||
|
|
||||||
|
invalidatedLayers |= 1U << tile.layerIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
tile.enabled = true;
|
||||||
|
tile.color = color;
|
||||||
|
tile.textureCoords = coords;
|
||||||
|
tile.layerIndex = materialIndex;
|
||||||
|
tilesPos++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tileCount > 0)
|
||||||
|
InvalidateInstanceData(invalidatedLayers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Enable and sets tileCount tiles at positions contained at tilesPos location, enabling rendering at those locations
|
||||||
|
*
|
||||||
|
* Setup all tiles using color, unnormalized coordinates coords and materialIndex
|
||||||
|
*
|
||||||
|
* \param tilesPos Pointer to a valid array of at least tileCount positions
|
||||||
|
* \param tileCount Number of tiles to enable
|
||||||
|
* \param coords Unnormalized coordinates ([0..size]) used to specify which region of the material textures will be used
|
||||||
|
* \param color The multiplicative color applied to the tile
|
||||||
|
* \param materialIndex The material which will be used for rendering this tile
|
||||||
|
*
|
||||||
|
* \remark The material at [materialIndex] must have a valid diffuse map before using this function,
|
||||||
|
* as the size of the material diffuse map is used to compute normalized texture coordinates before returning.
|
||||||
|
*
|
||||||
|
* \see EnableTile
|
||||||
|
*/
|
||||||
|
inline void TileMap::EnableTiles(const Vector2ui* tilesPos, std::size_t tileCount, const Rectui& rect, const Color& color, std::size_t materialIndex)
|
||||||
|
{
|
||||||
|
NazaraAssert(materialIndex < m_layers.size(), "Material out of bounds");
|
||||||
|
NazaraAssert(m_layers[materialIndex].material->HasDiffuseMap(), "Material has no diffuse map");
|
||||||
|
|
||||||
|
Texture* diffuseMap = m_layers[materialIndex].material->GetDiffuseMap();
|
||||||
|
float invWidth = 1.f / diffuseMap->GetWidth();
|
||||||
|
float invHeight = 1.f / diffuseMap->GetHeight();
|
||||||
|
|
||||||
|
Rectf unnormalizedCoords(invWidth * rect.x, invHeight * rect.y, invWidth * rect.width, invHeight * rect.height);
|
||||||
|
EnableTiles(tilesPos, tileCount, unnormalizedCoords, color, materialIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets the material at position index used by the TileMap
|
||||||
|
*
|
||||||
|
* \param index Index of the material to query
|
||||||
|
*
|
||||||
|
* \return Material at index
|
||||||
|
*/
|
||||||
|
inline const MaterialRef& TileMap::GetMaterial(std::size_t index) const
|
||||||
|
{
|
||||||
|
NazaraAssert(index < m_layers.size(), "Material out of bounds");
|
||||||
|
|
||||||
|
return m_layers[index].material;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets the maximum material count this TileMap can use
|
||||||
|
* \return Material count
|
||||||
|
*/
|
||||||
|
inline std::size_t TileMap::GetMaterialCount() const
|
||||||
|
{
|
||||||
|
return m_layers.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets the tilemap size (i.e. number of tiles in each dimension)
|
||||||
|
* \return Number of tiles in each dimension
|
||||||
|
*
|
||||||
|
* \see GetSize
|
||||||
|
* \see GetTileSize
|
||||||
|
*/
|
||||||
|
inline const Vector2ui& TileMap::GetMapSize() const
|
||||||
|
{
|
||||||
|
return m_mapSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Returns the size of the tilemap in units (which is equivalent to GetMapSize() * GetTileSize())
|
||||||
|
* \return Maximum size in units occupied by this tilemap
|
||||||
|
*
|
||||||
|
* \see GetMapSize
|
||||||
|
* \see GetTileSize
|
||||||
|
*/
|
||||||
|
inline Vector2f TileMap::GetSize() const
|
||||||
|
{
|
||||||
|
return Vector2f(m_mapSize) * m_tileSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Returns informations about a particular tile
|
||||||
|
*
|
||||||
|
* \param tilePos Position of the tile to get (enabled or not)
|
||||||
|
*
|
||||||
|
* \return Maximum size in units occupied by this tilemap
|
||||||
|
*/
|
||||||
|
inline const TileMap::Tile& TileMap::GetTile(const Vector2ui& tilePos) const
|
||||||
|
{
|
||||||
|
NazaraAssert(tilePos.x < m_mapSize.x && tilePos.y < m_mapSize.y, "Tile position is out of bounds");
|
||||||
|
|
||||||
|
return m_tiles[tilePos.y * m_mapSize.x + tilePos.x];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets the tile size (i.e. number of units occupied by a tile in each dimension)
|
||||||
|
* \return Tile size in each dimension
|
||||||
|
*
|
||||||
|
* \see GetMapSize
|
||||||
|
* \see GetSize
|
||||||
|
*/
|
||||||
|
inline const Vector2f& TileMap::GetTileSize() const
|
||||||
|
{
|
||||||
|
return m_tileSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Sets a material of the TileMap
|
||||||
|
*
|
||||||
|
* \param index Index of the material to change
|
||||||
|
* \param material Material for the TileMap
|
||||||
|
*/
|
||||||
|
inline void TileMap::SetMaterial(std::size_t index, MaterialRef material)
|
||||||
|
{
|
||||||
|
NazaraAssert(index < m_layers.size(), "Material out of bounds");
|
||||||
|
|
||||||
|
m_layers[index].material = std::move(material);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Sets the current TileMap with the content of the other one
|
||||||
|
* \return A reference to this
|
||||||
|
*
|
||||||
|
* \param TileMap The other TileMap
|
||||||
|
*/
|
||||||
|
inline TileMap& TileMap::operator=(const TileMap& TileMap)
|
||||||
|
{
|
||||||
|
InstancedRenderable::operator=(TileMap);
|
||||||
|
|
||||||
|
m_layers = TileMap.m_layers;
|
||||||
|
m_mapSize = TileMap.m_mapSize;
|
||||||
|
m_tiles = TileMap.m_tiles;
|
||||||
|
m_tileSize = TileMap.m_tileSize;
|
||||||
|
|
||||||
|
// We do not copy final vertices because it's highly probable that our parameters are modified and they must be regenerated
|
||||||
|
InvalidateBoundingVolume();
|
||||||
|
InvalidateInstanceData(0xFFFFFFFF);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Creates a new TileMap from the arguments
|
||||||
|
* \return A reference to the newly created TileMap
|
||||||
|
*
|
||||||
|
* \param args Arguments for the TileMap
|
||||||
|
*/
|
||||||
|
template<typename... Args>
|
||||||
|
TileMapRef TileMap::New(Args&&... args)
|
||||||
|
{
|
||||||
|
std::unique_ptr<TileMap> object(new TileMap(std::forward<Args>(args)...));
|
||||||
|
object->SetPersistent(false);
|
||||||
|
|
||||||
|
return object.release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <Nazara/Graphics/DebugOff.hpp>
|
||||||
|
|
@ -105,7 +105,7 @@ namespace Nz
|
||||||
*
|
*
|
||||||
* \param value Initial value
|
* \param value Initial value
|
||||||
* \param objective Target value
|
* \param objective Target value
|
||||||
* \parma increment One step value
|
* \param increment One step value
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
@ -412,7 +412,7 @@ namespace Nz
|
||||||
* \brief Gets the log in base 2 of integral number, only works for power of two !
|
* \brief Gets the log in base 2 of integral number, only works for power of two !
|
||||||
* \return Log of the number
|
* \return Log of the number
|
||||||
*
|
*
|
||||||
* \param number To get log in base 2
|
* \param pot To get log in base 2
|
||||||
*
|
*
|
||||||
* \remark Only works for power of two
|
* \remark Only works for power of two
|
||||||
* \remark If number is 0, 0 is returned
|
* \remark If number is 0, 0 is returned
|
||||||
|
|
@ -431,7 +431,7 @@ namespace Nz
|
||||||
* \return base^exponent for integral
|
* \return base^exponent for integral
|
||||||
*
|
*
|
||||||
* \param base Base of the exponentation
|
* \param base Base of the exponentation
|
||||||
* \parma exponent Power for the base
|
* \param exponent Power for the base
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//TODO: Mark as constexpr when supported by all major compilers
|
//TODO: Mark as constexpr when supported by all major compilers
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ namespace Nz
|
||||||
void Update(const Vector3<T>& translation);
|
void Update(const Vector3<T>& translation);
|
||||||
|
|
||||||
BoundingVolume operator*(T scalar) const;
|
BoundingVolume operator*(T scalar) const;
|
||||||
|
BoundingVolume& operator=(const BoundingVolume& other) = default;
|
||||||
|
|
||||||
BoundingVolume& operator*=(T scalar);
|
BoundingVolume& operator*=(T scalar);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@ namespace Nz
|
||||||
|
|
||||||
Box operator*(T scalar) const;
|
Box operator*(T scalar) const;
|
||||||
Box operator*(const Vector3<T>& vec) const;
|
Box operator*(const Vector3<T>& vec) const;
|
||||||
|
Box& operator=(const Box& other) = default;
|
||||||
|
|
||||||
Box& operator*=(T scalar);
|
Box& operator*=(T scalar);
|
||||||
Box& operator*=(const Vector3<T>& vec);
|
Box& operator*=(const Vector3<T>& vec);
|
||||||
|
|
|
||||||
|
|
@ -787,7 +787,7 @@ namespace Nz
|
||||||
* \brief Multiplies the lengths with the scalar
|
* \brief Multiplies the lengths with the scalar
|
||||||
* \return A box where the position is the same and width, height and depth are the product of the old width, height and depth and the scalar
|
* \return A box where the position is the same and width, height and depth are the product of the old width, height and depth and the scalar
|
||||||
*
|
*
|
||||||
* \param scale The scalar to multiply width, height and depth with
|
* \param scalar The scalar to multiply width, height and depth with
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ namespace Nz
|
||||||
EulerAngles operator-(const EulerAngles& angles) const;
|
EulerAngles operator-(const EulerAngles& angles) const;
|
||||||
/*EulerAngles operator*(const EulerAngles& angles) const;
|
/*EulerAngles operator*(const EulerAngles& angles) const;
|
||||||
EulerAngles operator/(const EulerAngles& angles) const;*/
|
EulerAngles operator/(const EulerAngles& angles) const;*/
|
||||||
|
EulerAngles& operator=(const EulerAngles& other) = default;
|
||||||
|
|
||||||
EulerAngles& operator+=(const EulerAngles& angles);
|
EulerAngles& operator+=(const EulerAngles& angles);
|
||||||
EulerAngles& operator-=(const EulerAngles& angles);
|
EulerAngles& operator-=(const EulerAngles& angles);
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,8 @@ namespace Nz
|
||||||
IntersectionSide Intersect(const Sphere<T>& sphere) const;
|
IntersectionSide Intersect(const Sphere<T>& sphere) const;
|
||||||
IntersectionSide Intersect(const Vector3<T>* points, unsigned int pointCount) const;
|
IntersectionSide Intersect(const Vector3<T>* points, unsigned int pointCount) const;
|
||||||
|
|
||||||
|
Frustum& operator=(const Frustum& other) = default;
|
||||||
|
|
||||||
Frustum& Set(const Frustum& frustum);
|
Frustum& Set(const Frustum& frustum);
|
||||||
template<typename U> Frustum& Set(const Frustum<U>& frustum);
|
template<typename U> Frustum& Set(const Frustum<U>& frustum);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -750,7 +750,7 @@ namespace Nz
|
||||||
* \brief Inverts this matrix
|
* \brief Inverts this matrix
|
||||||
* \return A reference to this matrix inverted
|
* \return A reference to this matrix inverted
|
||||||
*
|
*
|
||||||
* \param bool Optional argument to know if matrix has been successfully inverted
|
* \param succeeded Optional argument to know if matrix has been successfully inverted
|
||||||
*
|
*
|
||||||
* \see InverseAffine
|
* \see InverseAffine
|
||||||
*/
|
*/
|
||||||
|
|
@ -769,7 +769,7 @@ namespace Nz
|
||||||
* \brief Inverts this matrix
|
* \brief Inverts this matrix
|
||||||
* \return A reference to this matrix inverted
|
* \return A reference to this matrix inverted
|
||||||
*
|
*
|
||||||
* \param bool Optional argument to know if matrix has been successfully inverted
|
* \param succeeded Optional argument to know if matrix has been successfully inverted
|
||||||
*
|
*
|
||||||
* \see Inverse
|
* \see Inverse
|
||||||
*/
|
*/
|
||||||
|
|
@ -1487,7 +1487,7 @@ namespace Nz
|
||||||
* \brief Compares the matrix to other one
|
* \brief Compares the matrix to other one
|
||||||
* \return true if the matrices are the same
|
* \return true if the matrices are the same
|
||||||
*
|
*
|
||||||
* \param matrix Other matrix to compare with
|
* \param mat Other matrix to compare with
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
@ -1504,7 +1504,7 @@ namespace Nz
|
||||||
* \brief Compares the matrix to other one
|
* \brief Compares the matrix to other one
|
||||||
* \return false if the matrices are the same
|
* \return false if the matrices are the same
|
||||||
*
|
*
|
||||||
* \param matrix Other matrix to compare with
|
* \param mat Other matrix to compare with
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ namespace Nz
|
||||||
Vector3<T> operator()(unsigned int i) const;
|
Vector3<T> operator()(unsigned int i) const;
|
||||||
|
|
||||||
OrientedBox operator*(T scalar) const;
|
OrientedBox operator*(T scalar) const;
|
||||||
|
OrientedBox& operator=(const OrientedBox& other) = default;
|
||||||
|
|
||||||
OrientedBox& operator*=(T scalar);
|
OrientedBox& operator*=(T scalar);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -340,7 +340,7 @@ namespace Nz
|
||||||
* \brief Multiplies the lengths with the scalar
|
* \brief Multiplies the lengths with the scalar
|
||||||
* \return A OrientedBox where the position is the same and width, height and depth are the product of the old width, height and depth and the scalar
|
* \return A OrientedBox where the position is the same and width, height and depth are the product of the old width, height and depth and the scalar
|
||||||
*
|
*
|
||||||
* \param scale The scalar to multiply width, height and depth with
|
* \param scalar The scalar to multiply width, height and depth with
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,8 @@ namespace Nz
|
||||||
|
|
||||||
String ToString() const;
|
String ToString() const;
|
||||||
|
|
||||||
|
Plane& operator=(const Plane& other) = default;
|
||||||
|
|
||||||
bool operator==(const Plane& plane) const;
|
bool operator==(const Plane& plane) const;
|
||||||
bool operator!=(const Plane& plane) const;
|
bool operator!=(const Plane& plane) const;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ namespace Nz
|
||||||
String ToString() const;
|
String ToString() const;
|
||||||
|
|
||||||
Vector3<T> operator*(T lambda) const;
|
Vector3<T> operator*(T lambda) const;
|
||||||
|
Ray& operator=(const Ray& other) = default;
|
||||||
|
|
||||||
bool operator==(const Ray& ray) const;
|
bool operator==(const Ray& ray) const;
|
||||||
bool operator!=(const Ray& ray) const;
|
bool operator!=(const Ray& ray) const;
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@ namespace Nz
|
||||||
Rect operator*(const Vector2<T>& vec) const;
|
Rect operator*(const Vector2<T>& vec) const;
|
||||||
Rect operator/(T scalar) const;
|
Rect operator/(T scalar) const;
|
||||||
Rect operator/(const Vector2<T>& vec) const;
|
Rect operator/(const Vector2<T>& vec) const;
|
||||||
|
Rect& operator=(const Rect& other) = default;
|
||||||
|
|
||||||
Rect& operator*=(T scalar);
|
Rect& operator*=(T scalar);
|
||||||
Rect& operator*=(const Vector2<T>& vec);
|
Rect& operator*=(const Vector2<T>& vec);
|
||||||
|
|
|
||||||
|
|
@ -629,7 +629,7 @@ namespace Nz
|
||||||
* \brief Multiplies the lengths with the scalar
|
* \brief Multiplies the lengths with the scalar
|
||||||
* \return A rectangle where the position is the same and width and height are the product of the old width and height and the scalar
|
* \return A rectangle where the position is the same and width and height are the product of the old width and height and the scalar
|
||||||
*
|
*
|
||||||
* \param scale The scalar to multiply width and height with
|
* \param scalar The scalar to multiply width and height with
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
@ -655,13 +655,13 @@ namespace Nz
|
||||||
* \brief Divides the lengths with the scalar
|
* \brief Divides the lengths with the scalar
|
||||||
* \return A rectangle where the position is the same and width and height are the quotient of the old width and height and the scalar
|
* \return A rectangle where the position is the same and width and height are the quotient of the old width and height and the scalar
|
||||||
*
|
*
|
||||||
* \param scale The scalar to divide width and height with
|
* \param scalar The scalar to divide width and height with
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Rect<T> Rect<T>::operator/(T scalar) const
|
Rect<T> Rect<T>::operator/(T scalar) const
|
||||||
{
|
{
|
||||||
return Rect(x, y, width/scalar, height/scalar);
|
return Rect(x, y, width / scalar, height / scalar);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -745,7 +745,7 @@ namespace Nz
|
||||||
* \brief Compares the rectangle to other one
|
* \brief Compares the rectangle to other one
|
||||||
* \return true if the rectangles are the same
|
* \return true if the rectangles are the same
|
||||||
*
|
*
|
||||||
* \param rec Other rectangle to compare with
|
* \param rect Other rectangle to compare with
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
@ -759,7 +759,7 @@ namespace Nz
|
||||||
* \brief Compares the rectangle to other one
|
* \brief Compares the rectangle to other one
|
||||||
* \return false if the rectangles are the same
|
* \return false if the rectangles are the same
|
||||||
*
|
*
|
||||||
* \param rec Other rectangle to compare with
|
* \param rect Other rectangle to compare with
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,7 @@ namespace Nz
|
||||||
T operator[](unsigned int i) const;
|
T operator[](unsigned int i) const;
|
||||||
|
|
||||||
Sphere operator*(T scalar) const;
|
Sphere operator*(T scalar) const;
|
||||||
|
Sphere& operator=(const Sphere& other) = default;
|
||||||
|
|
||||||
Sphere& operator*=(T scalar);
|
Sphere& operator*=(T scalar);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,7 @@ namespace Nz
|
||||||
Vector2 operator*(T scale) const;
|
Vector2 operator*(T scale) const;
|
||||||
Vector2 operator/(const Vector2& vec) const;
|
Vector2 operator/(const Vector2& vec) const;
|
||||||
Vector2 operator/(T scale) const;
|
Vector2 operator/(T scale) const;
|
||||||
|
Vector2& operator=(const Vector2& other) = default;
|
||||||
|
|
||||||
Vector2& operator+=(const Vector2& vec);
|
Vector2& operator+=(const Vector2& vec);
|
||||||
Vector2& operator-=(const Vector2& vec);
|
Vector2& operator-=(const Vector2& vec);
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,7 @@ namespace Nz
|
||||||
Vector3 operator*(T scale) const;
|
Vector3 operator*(T scale) const;
|
||||||
Vector3 operator/(const Vector3& vec) const;
|
Vector3 operator/(const Vector3& vec) const;
|
||||||
Vector3 operator/(T scale) const;
|
Vector3 operator/(T scale) const;
|
||||||
|
Vector3& operator=(const Vector3& vec) = default;
|
||||||
|
|
||||||
Vector3& operator+=(const Vector3& vec);
|
Vector3& operator+=(const Vector3& vec);
|
||||||
Vector3& operator-=(const Vector3& vec);
|
Vector3& operator-=(const Vector3& vec);
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@ namespace Nz
|
||||||
Vector4 operator*(T scale) const;
|
Vector4 operator*(T scale) const;
|
||||||
Vector4 operator/(const Vector4& vec) const;
|
Vector4 operator/(const Vector4& vec) const;
|
||||||
Vector4 operator/(T scale) const;
|
Vector4 operator/(T scale) const;
|
||||||
|
Vector4& operator=(const Vector4& other) = default;
|
||||||
|
|
||||||
Vector4& operator+=(const Vector4& vec);
|
Vector4& operator+=(const Vector4& vec);
|
||||||
Vector4& operator-=(const Vector4& vec);
|
Vector4& operator-=(const Vector4& vec);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
// Copyright (C) 2016 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Engine - Renderer module"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef NAZARA_RENDERPIPELINE_HPP
|
||||||
|
#define NAZARA_RENDERPIPELINE_HPP
|
||||||
|
|
||||||
|
#include <Nazara/Utility/Enums.hpp>
|
||||||
|
#include <Nazara/Renderer/RenderStates.hpp>
|
||||||
|
#include <Nazara/Renderer/Shader.hpp>
|
||||||
|
|
||||||
|
namespace Nz
|
||||||
|
{
|
||||||
|
struct RenderPipelineInfo : RenderStates
|
||||||
|
{
|
||||||
|
ShaderConstRef shader;
|
||||||
|
};
|
||||||
|
|
||||||
|
class RenderPipeline
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
inline RenderPipeline();
|
||||||
|
inline ~RenderPipeline();
|
||||||
|
|
||||||
|
inline bool Create(const RenderPipelineInfo& pipelineInfo);
|
||||||
|
inline void Destroy();
|
||||||
|
|
||||||
|
inline const RenderPipelineInfo& GetInfo() const;
|
||||||
|
|
||||||
|
inline bool IsValid() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
RenderPipelineInfo m_pipelineInfo;
|
||||||
|
bool m_valid;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <Nazara/Renderer/RenderPipeline.inl>
|
||||||
|
|
||||||
|
#endif // NAZARA_RENDERPIPELINE_HPP
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
// Copyright (C) 2016 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Engine - Renderer module"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
|
#include <Nazara/Renderer/RenderPipeline.hpp>
|
||||||
|
#include <Nazara/Core/Error.hpp>
|
||||||
|
#include <Nazara/Renderer/Debug.hpp>
|
||||||
|
|
||||||
|
namespace Nz
|
||||||
|
{
|
||||||
|
inline RenderPipeline::RenderPipeline() :
|
||||||
|
m_valid(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
inline RenderPipeline::~RenderPipeline()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool RenderPipeline::Create(const RenderPipelineInfo& pipelineInfo)
|
||||||
|
{
|
||||||
|
NazaraAssert(pipelineInfo.shader, "Invalid shader");
|
||||||
|
|
||||||
|
m_pipelineInfo = pipelineInfo;
|
||||||
|
m_valid = true;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void RenderPipeline::Destroy()
|
||||||
|
{
|
||||||
|
m_valid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const RenderPipelineInfo& RenderPipeline::GetInfo() const
|
||||||
|
{
|
||||||
|
NazaraAssert(m_valid, "Invalid pipeline info");
|
||||||
|
|
||||||
|
return m_pipelineInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool RenderPipeline::IsValid() const
|
||||||
|
{
|
||||||
|
return m_valid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <Nazara/Renderer/DebugOff.hpp>
|
||||||
|
|
@ -7,39 +7,74 @@
|
||||||
#ifndef NAZARA_RENDERSTATES_HPP
|
#ifndef NAZARA_RENDERSTATES_HPP
|
||||||
#define NAZARA_RENDERSTATES_HPP
|
#define NAZARA_RENDERSTATES_HPP
|
||||||
|
|
||||||
|
#include <Nazara/Prerequesites.hpp>
|
||||||
#include <Nazara/Utility/Enums.hpp>
|
#include <Nazara/Utility/Enums.hpp>
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
struct RenderStates
|
struct RenderStates
|
||||||
{
|
{
|
||||||
RenderStates();
|
BlendFunc dstBlend = BlendFunc_Zero;
|
||||||
RenderStates(const RenderStates& states);
|
BlendFunc srcBlend = BlendFunc_One;
|
||||||
~RenderStates() = default;
|
FaceFilling faceFilling = FaceFilling_Fill;
|
||||||
|
FaceSide cullingSide = FaceSide_Back;
|
||||||
|
RendererComparison depthFunc = RendererComparison_Less;
|
||||||
|
|
||||||
RenderStates& operator=(const RenderStates& states);
|
struct
|
||||||
|
|
||||||
struct Face
|
|
||||||
{
|
{
|
||||||
RendererComparison stencilCompare;
|
RendererComparison back = RendererComparison_Always;
|
||||||
StencilOperation stencilFail;
|
RendererComparison front = RendererComparison_Always;
|
||||||
StencilOperation stencilPass;
|
} stencilCompare;
|
||||||
StencilOperation stencilZFail;
|
|
||||||
UInt32 stencilMask;
|
struct
|
||||||
unsigned int stencilReference;
|
{
|
||||||
|
UInt32 back = 0xFFFFFFFF;
|
||||||
|
UInt32 front = 0xFFFFFFFF;
|
||||||
|
} stencilCompareMask;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
StencilOperation back = StencilOperation_Keep;
|
||||||
|
StencilOperation front = StencilOperation_Keep;
|
||||||
|
} stencilDepthFail;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
StencilOperation back = StencilOperation_Keep;
|
||||||
|
StencilOperation front = StencilOperation_Keep;
|
||||||
|
} stencilFail;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
StencilOperation back = StencilOperation_Keep;
|
||||||
|
StencilOperation front = StencilOperation_Keep;
|
||||||
|
} stencilPass;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
UInt32 back = 0U;
|
||||||
|
UInt32 front = 0U;
|
||||||
|
} stencilReference;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
UInt32 back = 0xFFFFFFFF;
|
||||||
|
UInt32 front = 0xFFFFFFFF;
|
||||||
|
} stencilWriteMask;
|
||||||
|
|
||||||
|
bool blending = false;
|
||||||
|
bool colorWrite = true;
|
||||||
|
bool depthBuffer = false;
|
||||||
|
bool depthWrite = true;
|
||||||
|
bool faceCulling = false;
|
||||||
|
bool scissorTest = false;
|
||||||
|
bool stencilTest = false;
|
||||||
|
|
||||||
|
float lineWidth = 1.f;
|
||||||
|
float pointSize = 1.f;
|
||||||
};
|
};
|
||||||
|
|
||||||
Face backFace;
|
inline bool operator==(const RenderStates& lhs, const RenderStates& rhs);
|
||||||
Face frontFace;
|
|
||||||
BlendFunc dstBlend;
|
|
||||||
BlendFunc srcBlend;
|
|
||||||
FaceFilling faceFilling;
|
|
||||||
FaceSide faceCulling;
|
|
||||||
RendererComparison depthFunc;
|
|
||||||
bool parameters[RendererParameter_Max+1];
|
|
||||||
float lineWidth;
|
|
||||||
float pointSize;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <Nazara/Renderer/RenderStates.inl>
|
#include <Nazara/Renderer/RenderStates.inl>
|
||||||
|
|
|
||||||
|
|
@ -2,52 +2,144 @@
|
||||||
// This file is part of the "Nazara Engine - Renderer module"
|
// This file is part of the "Nazara Engine - Renderer module"
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <cstring>
|
#include <Nazara/Renderer/RenderStates.hpp>
|
||||||
|
#include <Nazara/Core/Algorithm.hpp>
|
||||||
|
#include <Nazara/Math/Algorithm.hpp>
|
||||||
|
#include <functional>
|
||||||
#include <Nazara/Renderer/Debug.hpp>
|
#include <Nazara/Renderer/Debug.hpp>
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
inline RenderStates::RenderStates() :
|
bool operator==(const RenderStates& lhs, const RenderStates& rhs)
|
||||||
dstBlend(BlendFunc_Zero),
|
|
||||||
srcBlend(BlendFunc_One),
|
|
||||||
faceFilling(FaceFilling_Fill),
|
|
||||||
faceCulling(FaceSide_Back),
|
|
||||||
depthFunc(RendererComparison_Less),
|
|
||||||
lineWidth(1.f),
|
|
||||||
pointSize(1.f)
|
|
||||||
{
|
{
|
||||||
parameters[RendererParameter_Blend] = false;
|
#define NazaraRenderStateMember(field) if (lhs.##field != rhs.##field) return false
|
||||||
parameters[RendererParameter_ColorWrite] = true;
|
#define NazaraRenderStateBoolMember NazaraRenderStateMember
|
||||||
parameters[RendererParameter_DepthBuffer] = false;
|
#define NazaraRenderStateFloatMember(field, maxDiff) if (!NumberEquals(lhs.##field, rhs.##field, maxDiff)) return false
|
||||||
parameters[RendererParameter_DepthWrite] = true;
|
|
||||||
parameters[RendererParameter_FaceCulling] = false;
|
|
||||||
parameters[RendererParameter_ScissorTest] = false;
|
|
||||||
parameters[RendererParameter_StencilTest] = false;
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < 2; ++i)
|
NazaraRenderStateBoolMember(blending);
|
||||||
|
NazaraRenderStateBoolMember(colorWrite);
|
||||||
|
NazaraRenderStateBoolMember(depthBuffer);
|
||||||
|
NazaraRenderStateBoolMember(faceCulling);
|
||||||
|
NazaraRenderStateBoolMember(scissorTest);
|
||||||
|
NazaraRenderStateBoolMember(stencilTest);
|
||||||
|
|
||||||
|
if (lhs.depthBuffer)
|
||||||
|
NazaraRenderStateBoolMember(depthWrite);
|
||||||
|
|
||||||
|
NazaraRenderStateMember(faceFilling);
|
||||||
|
|
||||||
|
if (lhs.blending) //< Remember, at this time we know lhs.blending == rhs.blending
|
||||||
{
|
{
|
||||||
Face& face = (i == 0) ? backFace : frontFace;
|
NazaraRenderStateMember(dstBlend);
|
||||||
|
NazaraRenderStateMember(srcBlend);
|
||||||
face.stencilCompare = RendererComparison_Always;
|
|
||||||
face.stencilFail = StencilOperation_Keep;
|
|
||||||
face.stencilMask = 0xFFFFFFFF;
|
|
||||||
face.stencilPass = StencilOperation_Keep;
|
|
||||||
face.stencilReference = 0;
|
|
||||||
face.stencilZFail = StencilOperation_Keep;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline RenderStates::RenderStates(const RenderStates& states)
|
if (lhs.depthBuffer)
|
||||||
|
NazaraRenderStateMember(depthFunc);
|
||||||
|
|
||||||
|
if (lhs.faceCulling)
|
||||||
|
NazaraRenderStateMember(cullingSide);
|
||||||
|
|
||||||
|
if (lhs.stencilTest)
|
||||||
{
|
{
|
||||||
std::memcpy(this, &states, sizeof(RenderStates));
|
NazaraRenderStateMember(stencilCompare.back);
|
||||||
|
NazaraRenderStateMember(stencilCompare.front);
|
||||||
|
NazaraRenderStateMember(stencilCompareMask.back);
|
||||||
|
NazaraRenderStateMember(stencilCompareMask.front);
|
||||||
|
NazaraRenderStateMember(stencilDepthFail.back);
|
||||||
|
NazaraRenderStateMember(stencilDepthFail.front);
|
||||||
|
NazaraRenderStateMember(stencilFail.back);
|
||||||
|
NazaraRenderStateMember(stencilFail.front);
|
||||||
|
NazaraRenderStateMember(stencilPass.back);
|
||||||
|
NazaraRenderStateMember(stencilPass.front);
|
||||||
|
NazaraRenderStateMember(stencilReference.back);
|
||||||
|
NazaraRenderStateMember(stencilReference.front);
|
||||||
|
NazaraRenderStateMember(stencilWriteMask.back);
|
||||||
|
NazaraRenderStateMember(stencilWriteMask.front);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline RenderStates& RenderStates::operator=(const RenderStates& states)
|
NazaraRenderStateFloatMember(lineWidth, 0.001f);
|
||||||
{
|
NazaraRenderStateFloatMember(pointSize, 0.001f);
|
||||||
std::memcpy(this, &states, sizeof(RenderStates));
|
|
||||||
|
|
||||||
return *this;
|
#undef NazaraRenderStateMember
|
||||||
|
#undef NazaraRenderStateBoolMember
|
||||||
|
#undef NazaraRenderStateFloatMember
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
template<>
|
||||||
|
struct hash<Nz::RenderStates>
|
||||||
|
{
|
||||||
|
size_t operator()(const Nz::RenderStates& pipelineInfo) const
|
||||||
|
{
|
||||||
|
std::size_t seed = 0;
|
||||||
|
|
||||||
|
Nz::UInt8 parameterHash = 0;
|
||||||
|
Nz::UInt8 parameterIndex = 0;
|
||||||
|
|
||||||
|
#define NazaraRenderStateMember(member) Nz::HashCombine(seed, pipelineInfo.##member)
|
||||||
|
#define NazaraRenderStateBoolMember(member) parameterHash |= ((pipelineInfo.##member) ? 1U : 0U) << (parameterIndex++)
|
||||||
|
#define NazaraRenderStateBoolMemberDep(dependency, member) parameterHash |= ((pipelineInfo.##dependency && pipelineInfo.##member) ? 1U : 0U) << (parameterIndex++)
|
||||||
|
#define NazaraRenderStateFloatMember(member, maxDiff) Nz::HashCombine(seed, std::floor(pipelineInfo.##member / maxDiff) * maxDiff)
|
||||||
|
|
||||||
|
NazaraRenderStateBoolMember(blending);
|
||||||
|
NazaraRenderStateBoolMember(colorWrite);
|
||||||
|
NazaraRenderStateBoolMember(depthBuffer);
|
||||||
|
NazaraRenderStateBoolMember(faceCulling);
|
||||||
|
NazaraRenderStateBoolMember(scissorTest);
|
||||||
|
NazaraRenderStateBoolMember(stencilTest);
|
||||||
|
|
||||||
|
NazaraRenderStateBoolMemberDep(depthBuffer, depthWrite);
|
||||||
|
|
||||||
|
NazaraRenderStateMember(faceFilling);
|
||||||
|
|
||||||
|
if (pipelineInfo.blending) //< Remember, at this time we know lhs.blending == rhs.blending
|
||||||
|
{
|
||||||
|
NazaraRenderStateMember(dstBlend);
|
||||||
|
NazaraRenderStateMember(srcBlend);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pipelineInfo.depthBuffer)
|
||||||
|
NazaraRenderStateMember(depthFunc);
|
||||||
|
|
||||||
|
if (pipelineInfo.faceCulling)
|
||||||
|
NazaraRenderStateMember(cullingSide);
|
||||||
|
|
||||||
|
if (pipelineInfo.stencilTest)
|
||||||
|
{
|
||||||
|
NazaraRenderStateMember(stencilCompare.back);
|
||||||
|
NazaraRenderStateMember(stencilCompare.front);
|
||||||
|
NazaraRenderStateMember(stencilCompareMask.back);
|
||||||
|
NazaraRenderStateMember(stencilCompareMask.front);
|
||||||
|
NazaraRenderStateMember(stencilDepthFail.back);
|
||||||
|
NazaraRenderStateMember(stencilDepthFail.front);
|
||||||
|
NazaraRenderStateMember(stencilFail.back);
|
||||||
|
NazaraRenderStateMember(stencilFail.front);
|
||||||
|
NazaraRenderStateMember(stencilPass.back);
|
||||||
|
NazaraRenderStateMember(stencilPass.front);
|
||||||
|
NazaraRenderStateMember(stencilReference.back);
|
||||||
|
NazaraRenderStateMember(stencilReference.front);
|
||||||
|
NazaraRenderStateMember(stencilWriteMask.back);
|
||||||
|
NazaraRenderStateMember(stencilWriteMask.front);
|
||||||
|
}
|
||||||
|
|
||||||
|
NazaraRenderStateFloatMember(lineWidth, 0.001f);
|
||||||
|
NazaraRenderStateFloatMember(pointSize, 0.001f);
|
||||||
|
|
||||||
|
#undef NazaraRenderStateMember
|
||||||
|
#undef NazaraRenderStateBoolMember
|
||||||
|
#undef NazaraRenderStateBoolMemberDep
|
||||||
|
#undef NazaraRenderStateFloatMember
|
||||||
|
|
||||||
|
Nz::HashCombine(seed, parameterHash);
|
||||||
|
|
||||||
|
return seed;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
#include <Nazara/Renderer/DebugOff.hpp>
|
#include <Nazara/Renderer/DebugOff.hpp>
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ namespace Nz
|
||||||
inline void Error(const String& message);
|
inline void Error(const String& message);
|
||||||
inline void Flush() const;
|
inline void Flush() const;
|
||||||
inline void Warning(const String& message);
|
inline void Warning(const String& message);
|
||||||
inline void UnrecognizedLine(bool error = false);
|
inline bool UnrecognizedLine(bool error = false);
|
||||||
|
|
||||||
std::vector<Mesh> m_meshes;
|
std::vector<Mesh> m_meshes;
|
||||||
std::vector<String> m_materials;
|
std::vector<String> m_materials;
|
||||||
|
|
@ -99,6 +99,7 @@ namespace Nz
|
||||||
mutable StringStream m_outputStream;
|
mutable StringStream m_outputStream;
|
||||||
bool m_keepLastLine;
|
bool m_keepLastLine;
|
||||||
unsigned int m_lineCount;
|
unsigned int m_lineCount;
|
||||||
|
unsigned int m_errorCount;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,7 @@ namespace Nz
|
||||||
NazaraWarning(message + " at line #" + String::Number(m_lineCount));
|
NazaraWarning(message + " at line #" + String::Number(m_lineCount));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void OBJParser::UnrecognizedLine(bool error)
|
inline bool OBJParser::UnrecognizedLine(bool error)
|
||||||
{
|
{
|
||||||
String message = "Unrecognized \"" + m_currentLine + '"';
|
String message = "Unrecognized \"" + m_currentLine + '"';
|
||||||
|
|
||||||
|
|
@ -176,6 +176,16 @@ namespace Nz
|
||||||
Error(message);
|
Error(message);
|
||||||
else
|
else
|
||||||
Warning(message);
|
Warning(message);
|
||||||
|
|
||||||
|
m_errorCount++;
|
||||||
|
|
||||||
|
if (m_lineCount > 20 && (m_errorCount * 100 / m_lineCount) > 50)
|
||||||
|
{
|
||||||
|
NazaraError("Aborting parsing because of error percentage");
|
||||||
|
return false; //< Abort parsing if error percentage is too high
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ namespace Nz
|
||||||
static constexpr const char* BackFaceStencilZFail = "MatBackFaceStencilZFail";
|
static constexpr const char* BackFaceStencilZFail = "MatBackFaceStencilZFail";
|
||||||
static constexpr const char* Blending = "MatBlending";
|
static constexpr const char* Blending = "MatBlending";
|
||||||
static constexpr const char* CullingSide = "MatCullingSide";
|
static constexpr const char* CullingSide = "MatCullingSide";
|
||||||
static constexpr const char* CustomDefined = "MatCustomDefined";
|
|
||||||
static constexpr const char* ColorWrite = "MatColorWrite";
|
static constexpr const char* ColorWrite = "MatColorWrite";
|
||||||
static constexpr const char* DepthBuffer = "MatDepthBuffer";
|
static constexpr const char* DepthBuffer = "MatDepthBuffer";
|
||||||
static constexpr const char* DepthFunc = "MatDepthfunc";
|
static constexpr const char* DepthFunc = "MatDepthfunc";
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
#include <Nazara/Core/Signal.hpp>
|
#include <Nazara/Core/Signal.hpp>
|
||||||
#include <Nazara/Utility/Config.hpp>
|
#include <Nazara/Utility/Config.hpp>
|
||||||
#include <Nazara/Utility/Enums.hpp>
|
#include <Nazara/Utility/Enums.hpp>
|
||||||
|
#include <array>
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
|
|
@ -69,14 +70,14 @@ namespace Nz
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
Component m_components[VertexComponent_Max+1];
|
std::array<Component, VertexComponent_Max + 1> m_components;
|
||||||
std::size_t m_stride;
|
std::size_t m_stride;
|
||||||
|
|
||||||
static VertexDeclaration s_declarations[VertexLayout_Max+1];
|
static std::array<VertexDeclaration, VertexLayout_Max + 1> s_declarations;
|
||||||
static VertexDeclarationLibrary::LibraryMap s_library;
|
static VertexDeclarationLibrary::LibraryMap s_library;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <Nazara/Utility/VertexDeclaration.hpp>
|
#include <Nazara/Utility/VertexDeclaration.inl>
|
||||||
|
|
||||||
#endif // NAZARA_VERTEXDECLARATION_HPP
|
#endif // NAZARA_VERTEXDECLARATION_HPP
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <CustomStream.hpp>
|
#include <CustomStream.hpp>
|
||||||
|
#include <Nazara/Core/Error.hpp>
|
||||||
#include <Nazara/Core/String.hpp>
|
#include <Nazara/Core/String.hpp>
|
||||||
#include <Nazara/Utility/Mesh.hpp>
|
#include <Nazara/Utility/Mesh.hpp>
|
||||||
#include <Nazara/Utility/IndexIterator.hpp>
|
#include <Nazara/Utility/IndexIterator.hpp>
|
||||||
|
|
@ -130,6 +131,12 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters)
|
||||||
const aiScene* scene = aiImportFileExWithProperties(userdata.originalFilePath, postProcess, &fileIO, properties);
|
const aiScene* scene = aiImportFileExWithProperties(userdata.originalFilePath, postProcess, &fileIO, properties);
|
||||||
aiReleasePropertyStore(properties);
|
aiReleasePropertyStore(properties);
|
||||||
|
|
||||||
|
if (!scene)
|
||||||
|
{
|
||||||
|
NazaraError("Assimp failed to import file: " + Nz::String(aiGetErrorString()));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::set<Nz::String> joints;
|
std::set<Nz::String> joints;
|
||||||
|
|
||||||
bool animatedMesh = false;
|
bool animatedMesh = false;
|
||||||
|
|
@ -237,8 +244,6 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters)
|
||||||
aiColor4D color;
|
aiColor4D color;
|
||||||
if (aiGetMaterialColor(aiMat, aiKey, aiType, aiIndex, &color) == aiReturn_SUCCESS)
|
if (aiGetMaterialColor(aiMat, aiKey, aiType, aiIndex, &color) == aiReturn_SUCCESS)
|
||||||
{
|
{
|
||||||
matData.SetParameter(MaterialData::CustomDefined);
|
|
||||||
|
|
||||||
matData.SetParameter(colorKey, Color(static_cast<UInt8>(color.r * 255), static_cast<UInt8>(color.g * 255), static_cast<UInt8>(color.b * 255), static_cast<UInt8>(color.a * 255)));
|
matData.SetParameter(colorKey, Color(static_cast<UInt8>(color.r * 255), static_cast<UInt8>(color.g * 255), static_cast<UInt8>(color.b * 255), static_cast<UInt8>(color.a * 255)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -249,7 +254,6 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters)
|
||||||
aiTextureMapMode mapMode[3];
|
aiTextureMapMode mapMode[3];
|
||||||
if (aiGetMaterialTexture(aiMat, aiType, 0, &path, nullptr, nullptr, nullptr, nullptr, &mapMode[0], nullptr) == aiReturn_SUCCESS)
|
if (aiGetMaterialTexture(aiMat, aiType, 0, &path, nullptr, nullptr, nullptr, nullptr, &mapMode[0], nullptr) == aiReturn_SUCCESS)
|
||||||
{
|
{
|
||||||
matData.SetParameter(MaterialData::CustomDefined);
|
|
||||||
matData.SetParameter(textureKey, stream.GetDirectory() + String(path.data, path.length));
|
matData.SetParameter(textureKey, stream.GetDirectory() + String(path.data, path.length));
|
||||||
|
|
||||||
if (wrapKey)
|
if (wrapKey)
|
||||||
|
|
|
||||||
|
|
@ -725,7 +725,7 @@ namespace Nz
|
||||||
return true;
|
return true;
|
||||||
else if (path.Match("\\\\*")) // Ex: \\Laptop
|
else if (path.Match("\\\\*")) // Ex: \\Laptop
|
||||||
return true;
|
return true;
|
||||||
else if (path.StartsWith('\\')) // Special : '\' refering to the root
|
else if (path.StartsWith('\\')) // Special : '\' referring to the root
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,11 @@ namespace Nz
|
||||||
{
|
{
|
||||||
namespace Detail
|
namespace Detail
|
||||||
{
|
{
|
||||||
|
inline bool IsSpace(char32_t character)
|
||||||
|
{
|
||||||
|
return character == '\t' || Unicode::GetCategory(character) & Unicode::Category_Separator;
|
||||||
|
}
|
||||||
|
|
||||||
// This algorithm is inspired by the documentation of Qt
|
// This algorithm is inspired by the documentation of Qt
|
||||||
inline std::size_t GetNewSize(std::size_t newSize)
|
inline std::size_t GetNewSize(std::size_t newSize)
|
||||||
{
|
{
|
||||||
|
|
@ -1379,7 +1384,7 @@ namespace Nz
|
||||||
if (it.base() != m_sharedString->string.get())
|
if (it.base() != m_sharedString->string.get())
|
||||||
{
|
{
|
||||||
--it;
|
--it;
|
||||||
if (!(Unicode::GetCategory(*it++) & Unicode::Category_Separator))
|
if (!Detail::IsSpace(*it++))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1391,7 +1396,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
if (*p == '\0')
|
if (*p == '\0')
|
||||||
{
|
{
|
||||||
if (*tIt == '\0' || Unicode::GetCategory(*tIt) & Unicode::Category_Separator)
|
if (*tIt == '\0' || Detail::IsSpace(*tIt))
|
||||||
return it.base() - m_sharedString->string.get();
|
return it.base() - m_sharedString->string.get();
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
|
@ -1421,7 +1426,7 @@ namespace Nz
|
||||||
if (it.base() != m_sharedString->string.get())
|
if (it.base() != m_sharedString->string.get())
|
||||||
{
|
{
|
||||||
--it;
|
--it;
|
||||||
if (!(Unicode::GetCategory(*it++) & Unicode::Category_Separator))
|
if (!Detail::IsSpace(*it++))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1433,7 +1438,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
if (*p == '\0')
|
if (*p == '\0')
|
||||||
{
|
{
|
||||||
if (*tIt == '\0' || Unicode::GetCategory(*tIt) & Unicode::Category_Separator)
|
if (*tIt == '\0' || Detail::IsSpace(*tIt))
|
||||||
return it.base() - m_sharedString->string.get();
|
return it.base() - m_sharedString->string.get();
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
|
@ -1465,7 +1470,7 @@ namespace Nz
|
||||||
if (ptr != m_sharedString->string.get())
|
if (ptr != m_sharedString->string.get())
|
||||||
{
|
{
|
||||||
--ptr;
|
--ptr;
|
||||||
if (!(Unicode::GetCategory(*ptr++) & Unicode::Category_Separator))
|
if (!Detail::IsSpace(*ptr++))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1475,7 +1480,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
if (*p == '\0')
|
if (*p == '\0')
|
||||||
{
|
{
|
||||||
if (*tPtr == '\0' || Unicode::GetCategory(*tPtr) & Unicode::Category_Separator)
|
if (*tPtr == '\0' || Detail::IsSpace(*tPtr))
|
||||||
return ptr-m_sharedString->string.get();
|
return ptr-m_sharedString->string.get();
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
|
@ -1503,7 +1508,7 @@ namespace Nz
|
||||||
if (ptr != m_sharedString->string.get())
|
if (ptr != m_sharedString->string.get())
|
||||||
{
|
{
|
||||||
--ptr;
|
--ptr;
|
||||||
if (!(Unicode::GetCategory(*ptr++) & Unicode::Category_Separator))
|
if (!Detail::IsSpace(*ptr++))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1513,7 +1518,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
if (*p == '\0')
|
if (*p == '\0')
|
||||||
{
|
{
|
||||||
if (*tPtr == '\0' || Unicode::GetCategory(*tPtr) & Unicode::Category_Separator)
|
if (*tPtr == '\0' || Detail::IsSpace(*tPtr))
|
||||||
return ptr-m_sharedString->string.get();
|
return ptr-m_sharedString->string.get();
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
|
@ -1579,7 +1584,7 @@ namespace Nz
|
||||||
if (it.base() != m_sharedString->string.get())
|
if (it.base() != m_sharedString->string.get())
|
||||||
{
|
{
|
||||||
--it;
|
--it;
|
||||||
if (!(Unicode::GetCategory(*it++) & Unicode::Category_Separator))
|
if (!Detail::IsSpace(*it++))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1591,7 +1596,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
if (*p == '\0')
|
if (*p == '\0')
|
||||||
{
|
{
|
||||||
if (*tIt == '\0' || Unicode::GetCategory(*tIt) & Unicode::Category_Separator)
|
if (*tIt == '\0' || Detail::IsSpace(*tIt))
|
||||||
return it.base() - m_sharedString->string.get();
|
return it.base() - m_sharedString->string.get();
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
|
@ -1621,7 +1626,7 @@ namespace Nz
|
||||||
if (it.base() != m_sharedString->string.get())
|
if (it.base() != m_sharedString->string.get())
|
||||||
{
|
{
|
||||||
--it;
|
--it;
|
||||||
if (!(Unicode::GetCategory(*it++) & Unicode::Category_Separator))
|
if (!Detail::IsSpace(*it++))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1633,7 +1638,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
if (*p == '\0')
|
if (*p == '\0')
|
||||||
{
|
{
|
||||||
if (*tIt == '\0' || Unicode::GetCategory(*tIt) & Unicode::Category_Separator)
|
if (*tIt == '\0' || Detail::IsSpace(*tIt))
|
||||||
return it.base() - m_sharedString->string.get();
|
return it.base() - m_sharedString->string.get();
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
|
@ -1664,7 +1669,7 @@ namespace Nz
|
||||||
if (Detail::ToLower(*ptr) == c)
|
if (Detail::ToLower(*ptr) == c)
|
||||||
{
|
{
|
||||||
char nextC = *(ptr + 1);
|
char nextC = *(ptr + 1);
|
||||||
if (nextC != '\0' && (Unicode::GetCategory(nextC) & Unicode::Category_Separator_Space) == 0)
|
if (nextC != '\0' && (Detail::IsSpace(nextC)) == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const char* p = &string.m_sharedString->string[string.m_sharedString->size-1];
|
const char* p = &string.m_sharedString->string[string.m_sharedString->size-1];
|
||||||
|
|
@ -1675,7 +1680,7 @@ namespace Nz
|
||||||
|
|
||||||
if (p == &string.m_sharedString->string[0])
|
if (p == &string.m_sharedString->string[0])
|
||||||
{
|
{
|
||||||
if (ptr == m_sharedString->string.get() || Unicode::GetCategory(*(ptr-1)) & Unicode::Category_Separator_Space)
|
if (ptr == m_sharedString->string.get() || Detail::IsSpace(*(ptr-1)))
|
||||||
return ptr-m_sharedString->string.get();
|
return ptr-m_sharedString->string.get();
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
|
@ -1695,7 +1700,7 @@ namespace Nz
|
||||||
if (*ptr == string.m_sharedString->string[string.m_sharedString->size-1])
|
if (*ptr == string.m_sharedString->string[string.m_sharedString->size-1])
|
||||||
{
|
{
|
||||||
char nextC = *(ptr + 1);
|
char nextC = *(ptr + 1);
|
||||||
if (nextC != '\0' && (Unicode::GetCategory(nextC) & Unicode::Category_Separator_Space) == 0)
|
if (nextC != '\0' && !Detail::IsSpace(nextC))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const char* p = &string.m_sharedString->string[string.m_sharedString->size-1];
|
const char* p = &string.m_sharedString->string[string.m_sharedString->size-1];
|
||||||
|
|
@ -1706,7 +1711,7 @@ namespace Nz
|
||||||
|
|
||||||
if (p == &string.m_sharedString->string[0])
|
if (p == &string.m_sharedString->string[0])
|
||||||
{
|
{
|
||||||
if (ptr == m_sharedString->string.get() || Unicode::GetCategory(*(ptr - 1)) & Unicode::Category_Separator_Space)
|
if (ptr == m_sharedString->string.get() || Detail::IsSpace(*(ptr - 1)))
|
||||||
return ptr-m_sharedString->string.get();
|
return ptr-m_sharedString->string.get();
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
|
@ -1766,7 +1771,7 @@ namespace Nz
|
||||||
if (it.base() != m_sharedString->string.get())
|
if (it.base() != m_sharedString->string.get())
|
||||||
{
|
{
|
||||||
--it;
|
--it;
|
||||||
if (!(Unicode::GetCategory(*it++) & Unicode::Category_Separator))
|
if (!Detail::IsSpace(*it++))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1778,7 +1783,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
if (*p == '\0')
|
if (*p == '\0')
|
||||||
{
|
{
|
||||||
if (*tIt == '\0' || Unicode::GetCategory(*it++) & Unicode::Category_Separator)
|
if (*tIt == '\0' || Detail::IsSpace(*it++))
|
||||||
return it.base() - m_sharedString->string.get();
|
return it.base() - m_sharedString->string.get();
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
|
@ -1806,7 +1811,7 @@ namespace Nz
|
||||||
if (it.base() != m_sharedString->string.get())
|
if (it.base() != m_sharedString->string.get())
|
||||||
{
|
{
|
||||||
--it;
|
--it;
|
||||||
if (!(Unicode::GetCategory(*it++) & Unicode::Category_Separator))
|
if (!Detail::IsSpace(*it++))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1818,7 +1823,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
if (*p == '\0')
|
if (*p == '\0')
|
||||||
{
|
{
|
||||||
if (*tIt == '\0' || Unicode::GetCategory(*it++) & Unicode::Category_Separator)
|
if (*tIt == '\0' || Detail::IsSpace(*it++))
|
||||||
return it.base() - m_sharedString->string.get();
|
return it.base() - m_sharedString->string.get();
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
|
@ -1844,7 +1849,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
if (Detail::ToLower(*ptr) == c)
|
if (Detail::ToLower(*ptr) == c)
|
||||||
{
|
{
|
||||||
if (ptr != m_sharedString->string.get() && (Unicode::GetCategory(*(ptr - 1)) & Unicode::Category_Separator) == 0)
|
if (ptr != m_sharedString->string.get() && !Detail::IsSpace(*(ptr - 1)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const char* p = &string[1];
|
const char* p = &string[1];
|
||||||
|
|
@ -1853,7 +1858,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
if (*p == '\0')
|
if (*p == '\0')
|
||||||
{
|
{
|
||||||
if (*tPtr == '\0' || Unicode::GetCategory(*tPtr) & Unicode::Category_Separator)
|
if (*tPtr == '\0' || Detail::IsSpace(*tPtr))
|
||||||
return ptr - m_sharedString->string.get();
|
return ptr - m_sharedString->string.get();
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
|
@ -1875,7 +1880,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
if (*ptr == string[0])
|
if (*ptr == string[0])
|
||||||
{
|
{
|
||||||
if (ptr != m_sharedString->string.get() && (Unicode::GetCategory(*(ptr-1)) & Unicode::Category_Separator) == 0)
|
if (ptr != m_sharedString->string.get() && !Detail::IsSpace(*(ptr-1)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const char* p = &string[1];
|
const char* p = &string[1];
|
||||||
|
|
@ -1884,7 +1889,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
if (*p == '\0')
|
if (*p == '\0')
|
||||||
{
|
{
|
||||||
if (*tPtr == '\0' || Unicode::GetCategory(*tPtr) & Unicode::Category_Separator)
|
if (*tPtr == '\0' || Detail::IsSpace(*tPtr))
|
||||||
return ptr - m_sharedString->string.get();
|
return ptr - m_sharedString->string.get();
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
|
@ -1947,7 +1952,7 @@ namespace Nz
|
||||||
if (it.base() != m_sharedString->string.get())
|
if (it.base() != m_sharedString->string.get())
|
||||||
{
|
{
|
||||||
--it;
|
--it;
|
||||||
if (!(Unicode::GetCategory(*it++) & Unicode::Category_Separator))
|
if (!Detail::IsSpace(*it++))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1959,7 +1964,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
if (*p == '\0')
|
if (*p == '\0')
|
||||||
{
|
{
|
||||||
if (*tIt == '\0' || Unicode::GetCategory(*it++) & Unicode::Category_Separator)
|
if (*tIt == '\0' || Detail::IsSpace(*it++))
|
||||||
return it.base() - m_sharedString->string.get();
|
return it.base() - m_sharedString->string.get();
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
|
@ -1987,7 +1992,7 @@ namespace Nz
|
||||||
if (it.base() != m_sharedString->string.get())
|
if (it.base() != m_sharedString->string.get())
|
||||||
{
|
{
|
||||||
--it;
|
--it;
|
||||||
if (!(Unicode::GetCategory(*it++) & Unicode::Category_Separator))
|
if (!Detail::IsSpace(*it++))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1999,7 +2004,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
if (*p == '\0')
|
if (*p == '\0')
|
||||||
{
|
{
|
||||||
if (*tIt == '\0' || Unicode::GetCategory(*it++) & Unicode::Category_Separator)
|
if (*tIt == '\0' || Detail::IsSpace(*it++))
|
||||||
return it.base() - m_sharedString->string.get();
|
return it.base() - m_sharedString->string.get();
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
|
@ -2026,7 +2031,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
if (Detail::ToLower(*ptr) == c)
|
if (Detail::ToLower(*ptr) == c)
|
||||||
{
|
{
|
||||||
if (ptr != m_sharedString->string.get() && (Unicode::GetCategory(*(ptr-1)) & Unicode::Category_Separator_Space) == 0)
|
if (ptr != m_sharedString->string.get() && !Detail::IsSpace(*(ptr-1)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const char* p = &string.m_sharedString->string[1];
|
const char* p = &string.m_sharedString->string[1];
|
||||||
|
|
@ -2035,7 +2040,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
if (*p == '\0')
|
if (*p == '\0')
|
||||||
{
|
{
|
||||||
if (*tPtr == '\0' || Unicode::GetCategory(*tPtr) & Unicode::Category_Separator_Space)
|
if (*tPtr == '\0' || Detail::IsSpace(*tPtr))
|
||||||
return ptr - m_sharedString->string.get();
|
return ptr - m_sharedString->string.get();
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
|
@ -2056,7 +2061,7 @@ namespace Nz
|
||||||
while ((ptr = std::strstr(ptr, string.GetConstBuffer())) != nullptr)
|
while ((ptr = std::strstr(ptr, string.GetConstBuffer())) != nullptr)
|
||||||
{
|
{
|
||||||
// If the word is really alone
|
// If the word is really alone
|
||||||
if ((ptr == m_sharedString->string.get() || Unicode::GetCategory(*(ptr-1)) & Unicode::Category_Separator_Space) && (*(ptr+m_sharedString->size) == '\0' || Unicode::GetCategory(*(ptr+m_sharedString->size)) & Unicode::Category_Separator_Space))
|
if ((ptr == m_sharedString->string.get() || Detail::IsSpace(*(ptr-1))) && (*(ptr+m_sharedString->size) == '\0' || Detail::IsSpace(*(ptr+m_sharedString->size))))
|
||||||
return ptr - m_sharedString->string.get();
|
return ptr - m_sharedString->string.get();
|
||||||
|
|
||||||
ptr++;
|
ptr++;
|
||||||
|
|
@ -2219,7 +2224,7 @@ namespace Nz
|
||||||
utf8::unchecked::iterator<const char*> it(ptr);
|
utf8::unchecked::iterator<const char*> it(ptr);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (Unicode::GetCategory(*it) & Unicode::Category_Separator)
|
if (Detail::IsSpace(*it))
|
||||||
{
|
{
|
||||||
endPos = static_cast<std::intmax_t>(it.base() - m_sharedString->string.get() - 1);
|
endPos = static_cast<std::intmax_t>(it.base() - m_sharedString->string.get() - 1);
|
||||||
break;
|
break;
|
||||||
|
|
@ -2231,7 +2236,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (Unicode::GetCategory(*ptr) & Unicode::Category_Separator)
|
if (Detail::IsSpace(*ptr))
|
||||||
{
|
{
|
||||||
endPos = static_cast<std::intmax_t>(ptr - m_sharedString->string.get() - 1);
|
endPos = static_cast<std::intmax_t>(ptr - m_sharedString->string.get() - 1);
|
||||||
break;
|
break;
|
||||||
|
|
@ -2265,7 +2270,7 @@ namespace Nz
|
||||||
utf8::unchecked::iterator<const char*> it(ptr);
|
utf8::unchecked::iterator<const char*> it(ptr);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (Unicode::GetCategory(*it) & Unicode::Category_Separator)
|
if (Detail::IsSpace(*it))
|
||||||
inWord = false;
|
inWord = false;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -2283,7 +2288,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (Unicode::GetCategory(*ptr) & Unicode::Category_Separator)
|
if (Detail::IsSpace(*ptr))
|
||||||
inWord = false;
|
inWord = false;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -3414,7 +3419,7 @@ namespace Nz
|
||||||
utf8::unchecked::iterator<const char*> it(ptr);
|
utf8::unchecked::iterator<const char*> it(ptr);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (Unicode::GetCategory(*it) & Unicode::Category_Separator)
|
if (Detail::IsSpace(*it))
|
||||||
{
|
{
|
||||||
if (inword)
|
if (inword)
|
||||||
{
|
{
|
||||||
|
|
@ -3435,7 +3440,7 @@ namespace Nz
|
||||||
const char* limit = &m_sharedString->string[m_sharedString->size];
|
const char* limit = &m_sharedString->string[m_sharedString->size];
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (Unicode::GetCategory(*ptr) & Unicode::Category_Separator)
|
if (Detail::IsSpace(*ptr))
|
||||||
{
|
{
|
||||||
if (inword)
|
if (inword)
|
||||||
{
|
{
|
||||||
|
|
@ -4240,7 +4245,7 @@ namespace Nz
|
||||||
utf8::unchecked::iterator<const char*> it(m_sharedString->string.get());
|
utf8::unchecked::iterator<const char*> it(m_sharedString->string.get());
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (*it != '\t' && (Unicode::GetCategory(*it) & Unicode::Category_Separator) == 0)
|
if (!Detail::IsSpace(*it))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
while (*++it);
|
while (*++it);
|
||||||
|
|
@ -4255,7 +4260,7 @@ namespace Nz
|
||||||
utf8::unchecked::iterator<const char*> it(&m_sharedString->string[m_sharedString->size]);
|
utf8::unchecked::iterator<const char*> it(&m_sharedString->string[m_sharedString->size]);
|
||||||
while ((it--).base() != m_sharedString->string.get())
|
while ((it--).base() != m_sharedString->string.get())
|
||||||
{
|
{
|
||||||
if (*it != '\t' && (Unicode::GetCategory(*it) & Unicode::Category_Separator) == 0)
|
if (!Detail::IsSpace(*it))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4272,7 +4277,7 @@ namespace Nz
|
||||||
for (; startPos < m_sharedString->size; ++startPos)
|
for (; startPos < m_sharedString->size; ++startPos)
|
||||||
{
|
{
|
||||||
char c = m_sharedString->string[startPos];
|
char c = m_sharedString->string[startPos];
|
||||||
if (c != '\t' && (Unicode::GetCategory(c) & Unicode::Category_Separator) == 0)
|
if (!Detail::IsSpace(c))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4283,7 +4288,7 @@ namespace Nz
|
||||||
for (; endPos > 0; --endPos)
|
for (; endPos > 0; --endPos)
|
||||||
{
|
{
|
||||||
char c = m_sharedString->string[endPos];
|
char c = m_sharedString->string[endPos];
|
||||||
if (c != '\t' && (Unicode::GetCategory(c) & Unicode::Category_Separator) == 0)
|
if (!Detail::IsSpace(c))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue