Moved Model::EnableDraw to SceneNode::EnableDrawing
Same goes for Model::IsDrawEnabled() => SceneNode::IsDrawingEnabled() Is Drawable is now a pure virtual method from SceneNode Former-commit-id: 217c6a21a98206ee0b283aaa216d419696a70faf
This commit is contained in:
parent
fe6816b089
commit
7fa8f3dafd
|
|
@ -36,6 +36,8 @@ class NAZARA_API NzLight : public NzSceneNode
|
|||
nzSceneNodeType GetSceneNodeType() const;
|
||||
NzColor GetSpecularColor() const;
|
||||
|
||||
bool IsDrawable() const;
|
||||
|
||||
void SetAmbientColor(const NzColor& ambient);
|
||||
void SetAttenuation(float attenuation);
|
||||
void SetDiffuseColor(const NzColor& diffuse);
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ class NAZARA_API NzModel : public NzSceneNode, public NzUpdatable
|
|||
void AdvanceAnimation(float elapsedTime);
|
||||
|
||||
void EnableAnimation(bool animation);
|
||||
void EnableDraw(bool draw);
|
||||
|
||||
NzAnimation* GetAnimation() const;
|
||||
const NzBoundingVolumef& GetBoundingVolume() const;
|
||||
|
|
@ -65,7 +64,6 @@ class NAZARA_API NzModel : public NzSceneNode, public NzUpdatable
|
|||
|
||||
bool IsAnimationEnabled() const;
|
||||
bool IsDrawable() const;
|
||||
bool IsDrawEnabled() const;
|
||||
|
||||
bool LoadFromFile(const NzString& filePath, const NzModelParameters& params = NzModelParameters());
|
||||
bool LoadFromMemory(const void* data, std::size_t size, const NzModelParameters& params = NzModelParameters());
|
||||
|
|
@ -103,7 +101,6 @@ class NAZARA_API NzModel : public NzSceneNode, public NzUpdatable
|
|||
const NzSequence* m_currentSequence;
|
||||
bool m_animationEnabled;
|
||||
mutable bool m_boundingVolumeUpdated;
|
||||
bool m_drawEnabled;
|
||||
float m_interpolation;
|
||||
unsigned int m_currentFrame;
|
||||
unsigned int m_matCount;
|
||||
|
|
|
|||
|
|
@ -20,18 +20,25 @@ class NAZARA_API NzSceneNode : public NzNode
|
|||
|
||||
public:
|
||||
NzSceneNode();
|
||||
NzSceneNode(const NzSceneNode& node);
|
||||
NzSceneNode(const NzSceneNode& sceneNode);
|
||||
virtual ~NzSceneNode();
|
||||
|
||||
virtual void AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const = 0;
|
||||
|
||||
void EnableDrawing(bool drawingEnabled);
|
||||
|
||||
virtual const NzBoundingVolumef& GetBoundingVolume() const = 0;
|
||||
nzNodeType GetNodeType() const final;
|
||||
NzScene* GetScene() const;
|
||||
virtual nzSceneNodeType GetSceneNodeType() const = 0;
|
||||
|
||||
virtual bool IsDrawable() const = 0;
|
||||
bool IsDrawingEnabled() const;
|
||||
bool IsVisible() const;
|
||||
|
||||
NzSceneNode& operator=(const NzSceneNode& sceneNode);
|
||||
NzSceneNode& operator=(NzSceneNode&& sceneNode);
|
||||
|
||||
protected:
|
||||
virtual void OnParenting(const NzNode* parent) override;
|
||||
virtual void OnVisibilityChange(bool visibility);
|
||||
|
|
@ -43,6 +50,7 @@ class NAZARA_API NzSceneNode : public NzNode
|
|||
virtual void Update();
|
||||
|
||||
NzScene* m_scene;
|
||||
bool m_drawingEnabled;
|
||||
bool m_visible;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ class NAZARA_API NzSceneRoot : public NzSceneNode
|
|||
const NzBoundingVolumef& GetBoundingVolume() const override;
|
||||
nzSceneNodeType GetSceneNodeType() const override;
|
||||
|
||||
bool IsDrawable() const;
|
||||
|
||||
private:
|
||||
NzSceneRoot(NzScene* scene);
|
||||
virtual ~NzSceneRoot();
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ class NAZARA_API NzSprite : public NzSceneNode
|
|||
const NzVector2f& GetSize() const;
|
||||
const NzRectf& GetTextureCoords() const;
|
||||
|
||||
bool IsDrawable() const;
|
||||
|
||||
void SetMaterial(NzMaterial* material);
|
||||
void SetSize(const NzVector2f& size);
|
||||
void SetTextureCoords(const NzRectf& coords);
|
||||
|
|
|
|||
|
|
@ -171,6 +171,11 @@ NzColor NzLight::GetSpecularColor() const
|
|||
return m_specularColor;
|
||||
}
|
||||
|
||||
bool NzLight::IsDrawable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void NzLight::SetAmbientColor(const NzColor& ambient)
|
||||
{
|
||||
m_ambientColor = ambient;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ NzModel::NzModel() :
|
|||
m_currentSequence(nullptr),
|
||||
m_animationEnabled(true),
|
||||
m_boundingVolumeUpdated(true),
|
||||
m_drawEnabled(true),
|
||||
m_matCount(0),
|
||||
m_skin(0),
|
||||
m_skinCount(1)
|
||||
|
|
@ -40,7 +39,6 @@ m_boundingVolume(model.m_boundingVolume),
|
|||
m_currentSequence(model.m_currentSequence),
|
||||
m_animationEnabled(model.m_animationEnabled),
|
||||
m_boundingVolumeUpdated(model.m_boundingVolumeUpdated),
|
||||
m_drawEnabled(model.m_drawEnabled),
|
||||
m_interpolation(model.m_interpolation),
|
||||
m_currentFrame(model.m_currentFrame),
|
||||
m_matCount(model.m_matCount),
|
||||
|
|
@ -116,11 +114,6 @@ void NzModel::EnableAnimation(bool animation)
|
|||
m_animationEnabled = animation;
|
||||
}
|
||||
|
||||
void NzModel::EnableDraw(bool draw)
|
||||
{
|
||||
m_drawEnabled = draw;
|
||||
}
|
||||
|
||||
NzAnimation* NzModel::GetAnimation() const
|
||||
{
|
||||
return m_animation;
|
||||
|
|
@ -280,11 +273,6 @@ bool NzModel::IsDrawable() const
|
|||
return m_mesh != nullptr && m_mesh->GetSubMeshCount() >= 1;
|
||||
}
|
||||
|
||||
bool NzModel::IsDrawEnabled() const
|
||||
{
|
||||
return m_drawEnabled;
|
||||
}
|
||||
|
||||
bool NzModel::LoadFromFile(const NzString& filePath, const NzModelParameters& params)
|
||||
{
|
||||
return NzModelLoader::LoadFromFile(this, filePath, params);
|
||||
|
|
@ -590,7 +578,6 @@ NzModel& NzModel::operator=(const NzModel& node)
|
|||
m_boundingVolumeUpdated = node.m_boundingVolumeUpdated;
|
||||
m_currentFrame = node.m_currentFrame;
|
||||
m_currentSequence = node.m_currentSequence;
|
||||
m_drawEnabled = node.m_drawEnabled;
|
||||
m_interpolation = node.m_interpolation;
|
||||
m_matCount = node.m_matCount;
|
||||
m_materials = node.m_materials;
|
||||
|
|
@ -609,40 +596,31 @@ NzModel& NzModel::operator=(NzModel&& node)
|
|||
{
|
||||
NzSceneNode::operator=(node);
|
||||
|
||||
// Ressources
|
||||
m_animation = std::move(node.m_animation);
|
||||
m_mesh = std::move(node.m_mesh);
|
||||
m_materials = std::move(node.m_materials);
|
||||
|
||||
if (m_mesh->GetAnimationType() == nzAnimationType_Skeletal)
|
||||
m_skeleton = std::move(node.m_skeleton);
|
||||
|
||||
// Paramètres
|
||||
m_animationEnabled = node.m_animationEnabled;
|
||||
m_boundingVolume = node.m_boundingVolume;
|
||||
m_boundingVolumeUpdated = node.m_boundingVolumeUpdated;
|
||||
m_currentFrame = node.m_currentFrame;
|
||||
m_currentSequence = node.m_currentSequence;
|
||||
m_drawEnabled = node.m_drawEnabled;
|
||||
m_interpolation = node.m_interpolation;
|
||||
m_matCount = node.m_matCount;
|
||||
m_materials = std::move(node.m_materials);
|
||||
m_mesh = std::move(node.m_mesh);
|
||||
m_nextFrame = node.m_nextFrame;
|
||||
m_skin = node.m_skin;
|
||||
m_skinCount = node.m_skinCount;
|
||||
|
||||
if (m_mesh->GetAnimationType() == nzAnimationType_Skeletal)
|
||||
m_skeleton = std::move(node.m_skeleton);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool NzModel::FrustumCull(const NzFrustumf& frustum)
|
||||
{
|
||||
#if NAZARA_GRAPHICS_SAFE
|
||||
if (!IsDrawable())
|
||||
{
|
||||
NazaraError("Model is not drawable");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!m_drawEnabled)
|
||||
return false;
|
||||
|
||||
if (!m_boundingVolumeUpdated)
|
||||
UpdateBoundingVolume();
|
||||
|
||||
|
|
|
|||
|
|
@ -3,24 +3,32 @@
|
|||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Graphics/SceneNode.hpp>
|
||||
#include <Nazara/Graphics/Config.hpp>
|
||||
#include <Nazara/Graphics/Scene.hpp>
|
||||
#include <Nazara/Graphics/Debug.hpp>
|
||||
|
||||
NzSceneNode::NzSceneNode() :
|
||||
m_scene(nullptr),
|
||||
m_drawingEnabled(true),
|
||||
m_visible(false)
|
||||
{
|
||||
}
|
||||
|
||||
NzSceneNode::NzSceneNode(const NzSceneNode& node) :
|
||||
NzNode(node),
|
||||
m_scene(node.m_scene),
|
||||
NzSceneNode::NzSceneNode(const NzSceneNode& sceneNode) :
|
||||
NzNode(sceneNode),
|
||||
m_scene(sceneNode.m_scene),
|
||||
m_drawingEnabled(sceneNode.m_drawingEnabled),
|
||||
m_visible(false)
|
||||
{
|
||||
}
|
||||
|
||||
NzSceneNode::~NzSceneNode() = default;
|
||||
|
||||
void NzSceneNode::EnableDrawing(bool drawingEnabled)
|
||||
{
|
||||
m_drawingEnabled = drawingEnabled;
|
||||
}
|
||||
|
||||
nzNodeType NzSceneNode::GetNodeType() const
|
||||
{
|
||||
return nzNodeType_Scene;
|
||||
|
|
@ -31,11 +39,34 @@ NzScene* NzSceneNode::GetScene() const
|
|||
return m_scene;
|
||||
}
|
||||
|
||||
bool NzSceneNode::IsDrawingEnabled() const
|
||||
{
|
||||
return m_drawingEnabled;
|
||||
}
|
||||
|
||||
bool NzSceneNode::IsVisible() const
|
||||
{
|
||||
return m_visible;
|
||||
}
|
||||
|
||||
NzSceneNode& NzSceneNode::operator=(const NzSceneNode& sceneNode)
|
||||
{
|
||||
m_drawingEnabled = sceneNode.m_drawingEnabled;
|
||||
m_scene = sceneNode.m_scene;
|
||||
m_visible = false;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
NzSceneNode& NzSceneNode::operator=(NzSceneNode&& sceneNode)
|
||||
{
|
||||
m_drawingEnabled = sceneNode.m_drawingEnabled;
|
||||
m_scene = sceneNode.m_scene;
|
||||
m_visible = sceneNode.m_visible;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void NzSceneNode::OnParenting(const NzNode* parent)
|
||||
{
|
||||
if (parent)
|
||||
|
|
@ -101,7 +132,20 @@ void NzSceneNode::UpdateVisibility(const NzFrustumf& frustum)
|
|||
{
|
||||
bool wasVisible = m_visible;
|
||||
|
||||
if (m_drawingEnabled)
|
||||
{
|
||||
#if NAZARA_GRAPHICS_SAFE
|
||||
if (!IsDrawable())
|
||||
{
|
||||
NazaraError("SceneNode is not drawable");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
m_visible = FrustumCull(frustum);
|
||||
}
|
||||
else
|
||||
m_visible = false;
|
||||
|
||||
if (m_visible != wasVisible)
|
||||
OnVisibilityChange(m_visible);
|
||||
|
|
|
|||
|
|
@ -31,6 +31,11 @@ nzSceneNodeType NzSceneRoot::GetSceneNodeType() const
|
|||
return nzSceneNodeType_Root;
|
||||
}
|
||||
|
||||
bool NzSceneRoot::IsDrawable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NzSceneRoot::FrustumCull(const NzFrustumf& frustum)
|
||||
{
|
||||
NazaraUnused(frustum);
|
||||
|
|
|
|||
|
|
@ -66,6 +66,11 @@ const NzRectf& NzSprite::GetTextureCoords() const
|
|||
return m_textureCoords;
|
||||
}
|
||||
|
||||
bool NzSprite::IsDrawable() const
|
||||
{
|
||||
return m_material != nullptr;
|
||||
}
|
||||
|
||||
void NzSprite::SetMaterial(NzMaterial* material)
|
||||
{
|
||||
m_material = material;
|
||||
|
|
@ -132,7 +137,7 @@ void NzSprite::Unregister()
|
|||
void NzSprite::UpdateBoundingVolume() const
|
||||
{
|
||||
if (m_boundingVolume.IsNull())
|
||||
m_boundingVolume.Set(-m_size.x*0.5f, -m_size.y*0.5f, 0, m_size.x, m_size.y, 1.f);
|
||||
m_boundingVolume.Set(-m_size.x*0.5f, -m_size.y*0.5f, 0, m_size.x, m_size.y, 0.f);
|
||||
|
||||
if (!m_transformMatrixUpdated)
|
||||
UpdateTransformMatrix();
|
||||
|
|
|
|||
Loading…
Reference in New Issue