Merge remote-tracking branch 'origin/Scene-Update'
Former-commit-id: 4185e7a826476d3d5b4275b3900fe695bd791f3a
This commit is contained in:
@@ -5,13 +5,14 @@
|
||||
#include <Nazara/Graphics/TextSprite.hpp>
|
||||
#include <Nazara/Core/CallOnExit.hpp>
|
||||
#include <Nazara/Core/SparsePtr.hpp>
|
||||
#include <Nazara/Graphics/AbstractRenderQueue.hpp>
|
||||
#include <Nazara/Graphics/AbstractViewer.hpp>
|
||||
#include <Nazara/Graphics/Scene.hpp>
|
||||
#include <memory>
|
||||
#include <Nazara/Utility/Font.hpp>
|
||||
#include <Nazara/Graphics/Debug.hpp>
|
||||
|
||||
NzTextSprite::NzTextSprite() :
|
||||
m_boundingVolume(NzBoundingVolumef::Null()),
|
||||
m_color(NzColor::White),
|
||||
m_verticesUpdated(false)
|
||||
{
|
||||
@@ -24,11 +25,9 @@ m_atlases(sprite.m_atlases),
|
||||
m_renderInfos(sprite.m_renderInfos),
|
||||
m_localVertices(sprite.m_localVertices),
|
||||
m_vertices(sprite.m_vertices),
|
||||
m_boundingVolume(sprite.m_boundingVolume),
|
||||
m_color(sprite.m_color),
|
||||
m_material(sprite.m_material),
|
||||
m_localBounds(sprite.m_localBounds),
|
||||
m_boundingVolumeUpdated(sprite.m_boundingVolumeUpdated),
|
||||
m_verticesUpdated(sprite.m_verticesUpdated)
|
||||
{
|
||||
SetParent(sprite.GetParent());
|
||||
@@ -66,12 +65,14 @@ void NzTextSprite::Clear()
|
||||
m_vertices.clear();
|
||||
}
|
||||
|
||||
const NzBoundingVolumef& NzTextSprite::GetBoundingVolume() const
|
||||
NzTextSprite* NzTextSprite::Clone() const
|
||||
{
|
||||
if (!m_boundingVolumeUpdated)
|
||||
UpdateBoundingVolume();
|
||||
return new NzTextSprite(*this);
|
||||
}
|
||||
|
||||
return m_boundingVolume;
|
||||
NzTextSprite* NzTextSprite::Create() const
|
||||
{
|
||||
return new NzTextSprite;
|
||||
}
|
||||
|
||||
const NzColor& NzTextSprite::GetColor() const
|
||||
@@ -266,7 +267,6 @@ NzTextSprite& NzTextSprite::operator=(const NzTextSprite& text)
|
||||
m_localVertices = text.m_localVertices;
|
||||
|
||||
// On ne copie pas les sommets finaux car il est très probable que nos paramètres soient modifiés et qu'ils doivent être régénérés de toute façon
|
||||
m_boundingVolumeUpdated = false;
|
||||
m_verticesUpdated = false;
|
||||
|
||||
return *this;
|
||||
@@ -284,10 +284,21 @@ void NzTextSprite::InvalidateNode()
|
||||
{
|
||||
NzSceneNode::InvalidateNode();
|
||||
|
||||
m_boundingVolumeUpdated = false;
|
||||
m_verticesUpdated = false;
|
||||
}
|
||||
|
||||
void NzTextSprite::MakeBoundingVolume() const
|
||||
{
|
||||
NzVector3f down = (m_scene) ? m_scene->GetDown() : NzVector3f::Down();
|
||||
NzVector3f right = (m_scene) ? m_scene->GetRight() : NzVector3f::Right();
|
||||
|
||||
NzRectf bounds(m_localBounds);
|
||||
NzVector2f max = bounds.GetMaximum();
|
||||
NzVector2f min = bounds.GetMinimum();
|
||||
|
||||
m_boundingVolume.Set(min.x*right + min.y*down, max.x*right + max.y*down);
|
||||
}
|
||||
|
||||
bool NzTextSprite::OnAtlasCleared(const NzAbstractAtlas* atlas, void* userdata)
|
||||
{
|
||||
NazaraUnused(userdata);
|
||||
@@ -373,34 +384,13 @@ void NzTextSprite::Unregister()
|
||||
{
|
||||
}
|
||||
|
||||
void NzTextSprite::UpdateBoundingVolume() const
|
||||
{
|
||||
if (m_boundingVolume.IsNull())
|
||||
{
|
||||
NzVector3f down = m_scene->GetDown();
|
||||
NzVector3f right = m_scene->GetRight();
|
||||
|
||||
NzRectf bounds(m_localBounds);
|
||||
NzVector2f max = bounds.GetMaximum();
|
||||
NzVector2f min = bounds.GetMinimum();
|
||||
|
||||
m_boundingVolume.Set(min.x*right + min.y*down, max.x*right + max.y*down);
|
||||
}
|
||||
|
||||
if (!m_transformMatrixUpdated)
|
||||
UpdateTransformMatrix();
|
||||
|
||||
m_boundingVolume.Update(m_transformMatrix);
|
||||
m_boundingVolumeUpdated = true;
|
||||
}
|
||||
|
||||
void NzTextSprite::UpdateVertices() const
|
||||
{
|
||||
if (!m_transformMatrixUpdated)
|
||||
UpdateTransformMatrix();
|
||||
|
||||
NzVector3f down = m_scene->GetDown();
|
||||
NzVector3f right = m_scene->GetRight();
|
||||
NzVector3f down = (m_scene) ? m_scene->GetDown() : NzVector3f::Down();
|
||||
NzVector3f right = (m_scene) ? m_scene->GetRight() : NzVector3f::Right();
|
||||
|
||||
NzSparsePtr<NzColor> colorPtr(&m_vertices[0].color, sizeof(NzVertexStruct_XYZ_Color_UV));
|
||||
NzSparsePtr<NzVector3f> posPtr(&m_vertices[0].position, sizeof(NzVertexStruct_XYZ_Color_UV));
|
||||
|
||||
Reference in New Issue
Block a user