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:
@@ -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;
|
||||
|
||||
m_visible = FrustumCull(frustum);
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user