Made bounding volume handing part of SceneNodes
Former-commit-id: d09d06ac4515ce09aa16fd92dd045c2a06730a99
This commit is contained in:
parent
bce3cadfd5
commit
8a3c410d60
|
|
@ -225,6 +225,11 @@ int main()
|
||||||
bool smoothMovement = true;
|
bool smoothMovement = true;
|
||||||
NzVector3f targetPos = camera.GetPosition();
|
NzVector3f targetPos = camera.GetPosition();
|
||||||
|
|
||||||
|
NzTextSprite text;
|
||||||
|
text.SetParent(scene);
|
||||||
|
text.Update(NzSimpleTextDrawer::Draw("Hello world !", 72));
|
||||||
|
text.Scale(0.1f);
|
||||||
|
|
||||||
// Début de la boucle de rendu du programme
|
// Début de la boucle de rendu du programme
|
||||||
while (window.IsOpen())
|
while (window.IsOpen())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,12 @@
|
||||||
|
|
||||||
#include <Nazara/Prerequesites.hpp>
|
#include <Nazara/Prerequesites.hpp>
|
||||||
#include <Nazara/Graphics/AbstractViewer.hpp>
|
#include <Nazara/Graphics/AbstractViewer.hpp>
|
||||||
#include <Nazara/Graphics/SceneNode.hpp>
|
|
||||||
#include <Nazara/Math/Frustum.hpp>
|
#include <Nazara/Math/Frustum.hpp>
|
||||||
#include <Nazara/Math/Matrix4.hpp>
|
#include <Nazara/Math/Matrix4.hpp>
|
||||||
#include <Nazara/Math/Rect.hpp>
|
#include <Nazara/Math/Rect.hpp>
|
||||||
#include <Nazara/Math/Vector3.hpp>
|
#include <Nazara/Math/Vector3.hpp>
|
||||||
#include <Nazara/Renderer/RenderTarget.hpp>
|
#include <Nazara/Renderer/RenderTarget.hpp>
|
||||||
|
#include <Nazara/Utility/Node.hpp>
|
||||||
|
|
||||||
class NAZARA_API NzCamera : public NzAbstractViewer, public NzNode, NzRenderTarget::Listener
|
class NAZARA_API NzCamera : public NzAbstractViewer, public NzNode, NzRenderTarget::Listener
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,6 @@ class NAZARA_API NzLight : public NzSceneNode
|
||||||
|
|
||||||
float GetAmbientFactor() const;
|
float GetAmbientFactor() const;
|
||||||
float GetAttenuation() const;
|
float GetAttenuation() const;
|
||||||
const NzBoundingVolumef& GetBoundingVolume() const;
|
|
||||||
NzColor GetColor() const;
|
NzColor GetColor() const;
|
||||||
float GetDiffuseFactor() const;
|
float GetDiffuseFactor() const;
|
||||||
float GetInnerAngle() const;
|
float GetInnerAngle() const;
|
||||||
|
|
@ -54,15 +53,13 @@ class NAZARA_API NzLight : public NzSceneNode
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool FrustumCull(const NzFrustumf& frustum) const override;
|
bool FrustumCull(const NzFrustumf& frustum) const override;
|
||||||
void InvalidateNode() override;
|
void MakeBoundingVolume() const override;
|
||||||
void Register() override;
|
void Register() override;
|
||||||
void Unregister() override;
|
void Unregister() override;
|
||||||
void UpdateBoundingVolume() const;
|
void UpdateBoundingVolume() const;
|
||||||
|
|
||||||
nzLightType m_type;
|
nzLightType m_type;
|
||||||
mutable NzBoundingVolumef m_boundingVolume;
|
|
||||||
NzColor m_color;
|
NzColor m_color;
|
||||||
mutable bool m_boundingVolumeUpdated;
|
|
||||||
float m_ambientFactor;
|
float m_ambientFactor;
|
||||||
float m_attenuation;
|
float m_attenuation;
|
||||||
float m_diffuseFactor;
|
float m_diffuseFactor;
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,6 @@ class NAZARA_API NzModel : public NzSceneNode
|
||||||
void EnableAnimation(bool animation);
|
void EnableAnimation(bool animation);
|
||||||
|
|
||||||
NzAnimation* GetAnimation() const;
|
NzAnimation* GetAnimation() const;
|
||||||
const NzBoundingVolumef& GetBoundingVolume() const;
|
|
||||||
NzMaterial* GetMaterial(const NzString& subMeshName) const;
|
NzMaterial* GetMaterial(const NzString& subMeshName) const;
|
||||||
NzMaterial* GetMaterial(unsigned int matIndex) const;
|
NzMaterial* GetMaterial(unsigned int matIndex) const;
|
||||||
NzMaterial* GetMaterial(unsigned int skinIndex, const NzString& subMeshName) const;
|
NzMaterial* GetMaterial(unsigned int skinIndex, const NzString& subMeshName) const;
|
||||||
|
|
@ -84,13 +83,10 @@ class NAZARA_API NzModel : public NzSceneNode
|
||||||
NzModel& operator=(const NzModel& node);
|
NzModel& operator=(const NzModel& node);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void InvalidateNode() override;
|
void MakeBoundingVolume() const override;
|
||||||
virtual void UpdateBoundingVolume() const;
|
|
||||||
|
|
||||||
std::vector<NzMaterialRef> m_materials;
|
std::vector<NzMaterialRef> m_materials;
|
||||||
mutable NzBoundingVolumef m_boundingVolume;
|
|
||||||
NzMeshRef m_mesh;
|
NzMeshRef m_mesh;
|
||||||
mutable bool m_boundingVolumeUpdated;
|
|
||||||
unsigned int m_matCount;
|
unsigned int m_matCount;
|
||||||
unsigned int m_skin;
|
unsigned int m_skin;
|
||||||
unsigned int m_skinCount;
|
unsigned int m_skinCount;
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,6 @@ class NAZARA_API NzParticleSystem : public NzSceneNode, NzUpdatable
|
||||||
void* GenerateParticle();
|
void* GenerateParticle();
|
||||||
void* GenerateParticles(unsigned int count);
|
void* GenerateParticles(unsigned int count);
|
||||||
|
|
||||||
const NzBoundingVolumef& GetBoundingVolume() const override;
|
|
||||||
const NzParticleDeclaration* GetDeclaration() const;
|
const NzParticleDeclaration* GetDeclaration() const;
|
||||||
float GetFixedStepSize() const;
|
float GetFixedStepSize() const;
|
||||||
unsigned int GetMaxParticleCount() const;
|
unsigned int GetMaxParticleCount() const;
|
||||||
|
|
@ -67,22 +66,19 @@ class NAZARA_API NzParticleSystem : public NzSceneNode, NzUpdatable
|
||||||
NzParticleSystem& operator=(const NzParticleSystem& emitter);
|
NzParticleSystem& operator=(const NzParticleSystem& emitter);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void GenerateAABB() const;
|
void MakeBoundingVolume() const override;
|
||||||
void Register() override;
|
void Register() override;
|
||||||
void ResizeBuffer();
|
void ResizeBuffer();
|
||||||
void Unregister() override;
|
void Unregister() override;
|
||||||
void Update() override;
|
void Update() override;
|
||||||
void UpdateBoundingVolume() const;
|
|
||||||
|
|
||||||
std::set<unsigned int, std::greater<unsigned int>> m_dyingParticles;
|
std::set<unsigned int, std::greater<unsigned int>> m_dyingParticles;
|
||||||
mutable std::vector<nzUInt8> m_buffer;
|
mutable std::vector<nzUInt8> m_buffer;
|
||||||
std::vector<NzParticleControllerRef> m_controllers;
|
std::vector<NzParticleControllerRef> m_controllers;
|
||||||
std::vector<NzParticleEmitter*> m_emitters;
|
std::vector<NzParticleEmitter*> m_emitters;
|
||||||
std::vector<NzParticleGeneratorRef> m_generators;
|
std::vector<NzParticleGeneratorRef> m_generators;
|
||||||
mutable NzBoundingVolumef m_boundingVolume;
|
|
||||||
NzParticleDeclarationConstRef m_declaration;
|
NzParticleDeclarationConstRef m_declaration;
|
||||||
NzParticleRendererRef m_renderer;
|
NzParticleRendererRef m_renderer;
|
||||||
mutable bool m_boundingVolumeUpdated;
|
|
||||||
bool m_fixedStepEnabled;
|
bool m_fixedStepEnabled;
|
||||||
bool m_processing;
|
bool m_processing;
|
||||||
float m_stepAccumulator;
|
float m_stepAccumulator;
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@
|
||||||
#include <Nazara/Math/Frustum.hpp>
|
#include <Nazara/Math/Frustum.hpp>
|
||||||
#include <Nazara/Utility/Node.hpp>
|
#include <Nazara/Utility/Node.hpp>
|
||||||
|
|
||||||
|
class NzScene;
|
||||||
|
|
||||||
class NAZARA_API NzSceneNode : public NzNode
|
class NAZARA_API NzSceneNode : public NzNode
|
||||||
{
|
{
|
||||||
friend class NzScene;
|
friend class NzScene;
|
||||||
|
|
@ -29,7 +31,7 @@ class NAZARA_API NzSceneNode : public NzNode
|
||||||
void EnableDrawing(bool drawingEnabled);
|
void EnableDrawing(bool drawingEnabled);
|
||||||
|
|
||||||
NzVector3f GetBackward() const;
|
NzVector3f GetBackward() const;
|
||||||
virtual const NzBoundingVolumef& GetBoundingVolume() const = 0;
|
virtual const NzBoundingVolumef& GetBoundingVolume() const;
|
||||||
NzVector3f GetDown() const;
|
NzVector3f GetDown() const;
|
||||||
NzVector3f GetForward() const;
|
NzVector3f GetForward() const;
|
||||||
NzVector3f GetLeft() const;
|
NzVector3f GetLeft() const;
|
||||||
|
|
@ -39,6 +41,8 @@ class NAZARA_API NzSceneNode : public NzNode
|
||||||
virtual nzSceneNodeType GetSceneNodeType() const = 0;
|
virtual nzSceneNodeType GetSceneNodeType() const = 0;
|
||||||
NzVector3f GetUp() const;
|
NzVector3f GetUp() const;
|
||||||
|
|
||||||
|
void InvalidateAABB();
|
||||||
|
|
||||||
virtual bool IsDrawable() const = 0;
|
virtual bool IsDrawable() const = 0;
|
||||||
bool IsDrawingEnabled() const;
|
bool IsDrawingEnabled() const;
|
||||||
bool IsVisible() const;
|
bool IsVisible() const;
|
||||||
|
|
@ -48,6 +52,8 @@ class NAZARA_API NzSceneNode : public NzNode
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool FrustumCull(const NzFrustumf& frustum) const;
|
virtual bool FrustumCull(const NzFrustumf& frustum) const;
|
||||||
|
virtual void InvalidateNode() override;
|
||||||
|
virtual void MakeBoundingVolume() const = 0;
|
||||||
virtual void OnParenting(const NzNode* parent) override;
|
virtual void OnParenting(const NzNode* parent) override;
|
||||||
virtual void OnVisibilityChange(bool visibility);
|
virtual void OnVisibilityChange(bool visibility);
|
||||||
void RecursiveSetScene(NzScene* scene, NzNode* node);
|
void RecursiveSetScene(NzScene* scene, NzNode* node);
|
||||||
|
|
@ -55,8 +61,11 @@ class NAZARA_API NzSceneNode : public NzNode
|
||||||
void SetScene(NzScene* scene);
|
void SetScene(NzScene* scene);
|
||||||
virtual void Unregister();
|
virtual void Unregister();
|
||||||
virtual void Update();
|
virtual void Update();
|
||||||
|
virtual void UpdateBoundingVolume() const;
|
||||||
|
|
||||||
|
mutable NzBoundingVolumef m_boundingVolume;
|
||||||
NzScene* m_scene;
|
NzScene* m_scene;
|
||||||
|
mutable bool m_boundingVolumeUpdated;
|
||||||
bool m_drawingEnabled;
|
bool m_drawingEnabled;
|
||||||
bool m_visible;
|
bool m_visible;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ class NAZARA_API NzSceneRoot : public NzSceneNode
|
||||||
public:
|
public:
|
||||||
void AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const override;
|
void AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const override;
|
||||||
|
|
||||||
const NzBoundingVolumef& GetBoundingVolume() const override;
|
|
||||||
nzSceneNodeType GetSceneNodeType() const override;
|
nzSceneNodeType GetSceneNodeType() const override;
|
||||||
|
|
||||||
bool IsDrawable() const;
|
bool IsDrawable() const;
|
||||||
|
|
@ -26,6 +25,7 @@ class NAZARA_API NzSceneRoot : public NzSceneNode
|
||||||
NzSceneRoot(NzScene* scene);
|
NzSceneRoot(NzScene* scene);
|
||||||
virtual ~NzSceneRoot();
|
virtual ~NzSceneRoot();
|
||||||
|
|
||||||
|
void MakeBoundingVolume() const override;
|
||||||
void Register();
|
void Register();
|
||||||
void Unregister();
|
void Unregister();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -69,10 +69,10 @@ class NAZARA_API NzSkeletalModel : public NzModel, NzUpdatable
|
||||||
NzSkeletalModel& operator=(NzSkeletalModel&& node);
|
NzSkeletalModel& operator=(NzSkeletalModel&& node);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void MakeBoundingVolume() const override;
|
||||||
void Register() override;
|
void Register() override;
|
||||||
void Unregister() override;
|
void Unregister() override;
|
||||||
void Update() override;
|
void Update() override;
|
||||||
void UpdateBoundingVolume() const;
|
|
||||||
|
|
||||||
NzAnimationRef m_animation;
|
NzAnimationRef m_animation;
|
||||||
NzSkeleton m_skeleton;
|
NzSkeleton m_skeleton;
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ class NAZARA_API NzSprite : public NzSceneNode
|
||||||
|
|
||||||
void AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const override;
|
void AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const override;
|
||||||
|
|
||||||
const NzBoundingVolumef& GetBoundingVolume() const override;
|
|
||||||
const NzColor& GetColor() const;
|
const NzColor& GetColor() const;
|
||||||
NzMaterial* GetMaterial() const;
|
NzMaterial* GetMaterial() const;
|
||||||
nzSceneNodeType GetSceneNodeType() const override;
|
nzSceneNodeType GetSceneNodeType() const override;
|
||||||
|
|
@ -44,18 +43,16 @@ class NAZARA_API NzSprite : public NzSceneNode
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InvalidateNode() override;
|
void InvalidateNode() override;
|
||||||
|
void MakeBoundingVolume() const override;
|
||||||
void Register() override;
|
void Register() override;
|
||||||
void Unregister() override;
|
void Unregister() override;
|
||||||
void UpdateBoundingVolume() const;
|
|
||||||
void UpdateVertices() const;
|
void UpdateVertices() const;
|
||||||
|
|
||||||
mutable NzBoundingVolumef m_boundingVolume;
|
|
||||||
NzColor m_color;
|
NzColor m_color;
|
||||||
NzMaterialRef m_material;
|
NzMaterialRef m_material;
|
||||||
NzRectf m_textureCoords;
|
NzRectf m_textureCoords;
|
||||||
NzVector2f m_size;
|
NzVector2f m_size;
|
||||||
mutable NzVertexStruct_XYZ_Color_UV m_vertices[4];
|
mutable NzVertexStruct_XYZ_Color_UV m_vertices[4];
|
||||||
mutable bool m_boundingVolumeUpdated;
|
|
||||||
mutable bool m_verticesUpdated;
|
mutable bool m_verticesUpdated;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,6 @@ class NAZARA_API NzTextSprite : public NzSceneNode, NzAbstractAtlas::Listener
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
const NzBoundingVolumef& GetBoundingVolume() const override;
|
|
||||||
const NzColor& GetColor() const;
|
const NzColor& GetColor() const;
|
||||||
NzMaterial* GetMaterial() const;
|
NzMaterial* GetMaterial() const;
|
||||||
nzSceneNodeType GetSceneNodeType() const override;
|
nzSceneNodeType GetSceneNodeType() const override;
|
||||||
|
|
@ -47,12 +46,12 @@ class NAZARA_API NzTextSprite : public NzSceneNode, NzAbstractAtlas::Listener
|
||||||
private:
|
private:
|
||||||
void ClearAtlases();
|
void ClearAtlases();
|
||||||
void InvalidateNode() override;
|
void InvalidateNode() override;
|
||||||
|
void MakeBoundingVolume() const override;
|
||||||
bool OnAtlasCleared(const NzAbstractAtlas* atlas, void* userdata) override;
|
bool OnAtlasCleared(const NzAbstractAtlas* atlas, void* userdata) override;
|
||||||
bool OnAtlasLayerChange(const NzAbstractAtlas* atlas, NzAbstractImage* oldLayer, NzAbstractImage* newLayer, void* userdata) override;
|
bool OnAtlasLayerChange(const NzAbstractAtlas* atlas, NzAbstractImage* oldLayer, NzAbstractImage* newLayer, void* userdata) override;
|
||||||
void OnAtlasReleased(const NzAbstractAtlas* atlas, void* userdata) override;
|
void OnAtlasReleased(const NzAbstractAtlas* atlas, void* userdata) override;
|
||||||
void Register() override;
|
void Register() override;
|
||||||
void Unregister() override;
|
void Unregister() override;
|
||||||
void UpdateBoundingVolume() const;
|
|
||||||
void UpdateVertices() const;
|
void UpdateVertices() const;
|
||||||
|
|
||||||
struct RenderIndices
|
struct RenderIndices
|
||||||
|
|
@ -65,11 +64,9 @@ class NAZARA_API NzTextSprite : public NzSceneNode, NzAbstractAtlas::Listener
|
||||||
mutable std::unordered_map<NzTexture*, RenderIndices> m_renderInfos;
|
mutable std::unordered_map<NzTexture*, RenderIndices> m_renderInfos;
|
||||||
mutable std::vector<NzVertexStruct_XY_Color> m_localVertices;
|
mutable std::vector<NzVertexStruct_XY_Color> m_localVertices;
|
||||||
mutable std::vector<NzVertexStruct_XYZ_Color_UV> m_vertices;
|
mutable std::vector<NzVertexStruct_XYZ_Color_UV> m_vertices;
|
||||||
mutable NzBoundingVolumef m_boundingVolume;
|
|
||||||
NzColor m_color;
|
NzColor m_color;
|
||||||
NzMaterialRef m_material;
|
NzMaterialRef m_material;
|
||||||
NzRectui m_localBounds;
|
NzRectui m_localBounds;
|
||||||
mutable bool m_boundingVolumeUpdated;
|
|
||||||
mutable bool m_verticesUpdated;
|
mutable bool m_verticesUpdated;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,12 @@
|
||||||
|
|
||||||
#include <Nazara/Prerequesites.hpp>
|
#include <Nazara/Prerequesites.hpp>
|
||||||
#include <Nazara/Graphics/AbstractViewer.hpp>
|
#include <Nazara/Graphics/AbstractViewer.hpp>
|
||||||
#include <Nazara/Graphics/SceneNode.hpp>
|
|
||||||
#include <Nazara/Math/Frustum.hpp>
|
#include <Nazara/Math/Frustum.hpp>
|
||||||
#include <Nazara/Math/Matrix4.hpp>
|
#include <Nazara/Math/Matrix4.hpp>
|
||||||
#include <Nazara/Math/Rect.hpp>
|
#include <Nazara/Math/Rect.hpp>
|
||||||
#include <Nazara/Math/Vector3.hpp>
|
#include <Nazara/Math/Vector3.hpp>
|
||||||
#include <Nazara/Renderer/RenderTarget.hpp>
|
#include <Nazara/Renderer/RenderTarget.hpp>
|
||||||
|
#include <Nazara/Utility/Node.hpp>
|
||||||
|
|
||||||
class NAZARA_API NzView : public NzAbstractViewer, public NzNode, NzRenderTarget::Listener
|
class NAZARA_API NzView : public NzAbstractViewer, public NzNode, NzRenderTarget::Listener
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,11 @@
|
||||||
#include <Nazara/Graphics/Debug.hpp>
|
#include <Nazara/Graphics/Debug.hpp>
|
||||||
|
|
||||||
///TODO: Utilisation des UBOs
|
///TODO: Utilisation des UBOs
|
||||||
|
///TODO: Scale ?
|
||||||
|
|
||||||
NzLight::NzLight(nzLightType type) :
|
NzLight::NzLight(nzLightType type) :
|
||||||
m_type(type),
|
m_type(type),
|
||||||
m_color(NzColor::White),
|
m_color(NzColor::White),
|
||||||
m_boundingVolumeUpdated(false),
|
|
||||||
m_ambientFactor((type == nzLightType_Directional) ? 0.2f : 0.f),
|
m_ambientFactor((type == nzLightType_Directional) ? 0.2f : 0.f),
|
||||||
m_attenuation(0.9f),
|
m_attenuation(0.9f),
|
||||||
m_diffuseFactor(1.f),
|
m_diffuseFactor(1.f),
|
||||||
|
|
@ -31,9 +31,7 @@ m_radius(5.f)
|
||||||
NzLight::NzLight(const NzLight& light) :
|
NzLight::NzLight(const NzLight& light) :
|
||||||
NzSceneNode(light),
|
NzSceneNode(light),
|
||||||
m_type(light.m_type),
|
m_type(light.m_type),
|
||||||
m_boundingVolume(light.m_boundingVolume),
|
|
||||||
m_color(light.m_color),
|
m_color(light.m_color),
|
||||||
m_boundingVolumeUpdated(light.m_boundingVolumeUpdated),
|
|
||||||
m_ambientFactor(light.m_ambientFactor),
|
m_ambientFactor(light.m_ambientFactor),
|
||||||
m_attenuation(light.m_attenuation),
|
m_attenuation(light.m_attenuation),
|
||||||
m_diffuseFactor(light.m_diffuseFactor),
|
m_diffuseFactor(light.m_diffuseFactor),
|
||||||
|
|
@ -112,14 +110,6 @@ float NzLight::GetAttenuation() const
|
||||||
return m_attenuation;
|
return m_attenuation;
|
||||||
}
|
}
|
||||||
|
|
||||||
const NzBoundingVolumef& NzLight::GetBoundingVolume() const
|
|
||||||
{
|
|
||||||
if (!m_boundingVolumeUpdated)
|
|
||||||
UpdateBoundingVolume();
|
|
||||||
|
|
||||||
return m_boundingVolume;
|
|
||||||
}
|
|
||||||
|
|
||||||
NzColor NzLight::GetColor() const
|
NzColor NzLight::GetColor() const
|
||||||
{
|
{
|
||||||
return m_color;
|
return m_color;
|
||||||
|
|
@ -251,11 +241,45 @@ bool NzLight::FrustumCull(const NzFrustumf& frustum) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzLight::InvalidateNode()
|
void NzLight::MakeBoundingVolume() const
|
||||||
{
|
{
|
||||||
NzSceneNode::InvalidateNode();
|
switch (m_type)
|
||||||
|
{
|
||||||
|
case nzLightType_Directional:
|
||||||
|
m_boundingVolume.MakeInfinite();
|
||||||
|
break;
|
||||||
|
|
||||||
m_boundingVolumeUpdated = false;
|
case nzLightType_Point:
|
||||||
|
{
|
||||||
|
NzVector3f radius(m_radius);
|
||||||
|
m_boundingVolume.Set(-radius, radius);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case nzLightType_Spot:
|
||||||
|
{
|
||||||
|
// On forme une boite sur l'origine
|
||||||
|
NzBoxf box(NzVector3f::Zero());
|
||||||
|
|
||||||
|
// On calcule le reste des points
|
||||||
|
NzVector3f base(NzVector3f::Forward()*m_radius);
|
||||||
|
|
||||||
|
// Il nous faut maintenant le rayon du cercle projeté à cette distance
|
||||||
|
// Tangente = Opposé/Adjaçent <=> Opposé = Adjaçent*Tangente
|
||||||
|
float radius = m_radius*std::tan(NzDegreeToRadian(m_outerAngle));
|
||||||
|
NzVector3f lExtend = NzVector3f::Left()*radius;
|
||||||
|
NzVector3f uExtend = NzVector3f::Up()*radius;
|
||||||
|
|
||||||
|
// Et on ajoute ensuite les quatres extrémités de la pyramide
|
||||||
|
box.ExtendTo(base + lExtend + uExtend);
|
||||||
|
box.ExtendTo(base + lExtend - uExtend);
|
||||||
|
box.ExtendTo(base - lExtend + uExtend);
|
||||||
|
box.ExtendTo(base - lExtend - uExtend);
|
||||||
|
|
||||||
|
m_boundingVolume.Set(box);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzLight::Register()
|
void NzLight::Register()
|
||||||
|
|
@ -269,46 +293,7 @@ void NzLight::Unregister()
|
||||||
void NzLight::UpdateBoundingVolume() const
|
void NzLight::UpdateBoundingVolume() const
|
||||||
{
|
{
|
||||||
if (m_boundingVolume.IsNull())
|
if (m_boundingVolume.IsNull())
|
||||||
{
|
MakeBoundingVolume();
|
||||||
switch (m_type)
|
|
||||||
{
|
|
||||||
case nzLightType_Directional:
|
|
||||||
m_boundingVolume.MakeInfinite();
|
|
||||||
m_boundingVolumeUpdated = true;
|
|
||||||
return; // Rien d'autre à faire
|
|
||||||
|
|
||||||
case nzLightType_Point:
|
|
||||||
{
|
|
||||||
NzVector3f radius(m_radius);
|
|
||||||
m_boundingVolume.Set(-radius, radius);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case nzLightType_Spot:
|
|
||||||
{
|
|
||||||
// On forme une boite sur l'origine
|
|
||||||
NzBoxf box(NzVector3f::Zero());
|
|
||||||
|
|
||||||
// On calcule le reste des points
|
|
||||||
NzVector3f base(NzVector3f::Forward()*m_radius);
|
|
||||||
|
|
||||||
// Il nous faut maintenant le rayon du cercle projeté à cette distance
|
|
||||||
// Tangente = Opposé/Adjaçent <=> Opposé = Adjaçent*Tangente
|
|
||||||
float radius = m_radius*std::tan(NzDegreeToRadian(m_outerAngle));
|
|
||||||
NzVector3f lExtend = NzVector3f::Left()*radius;
|
|
||||||
NzVector3f uExtend = NzVector3f::Up()*radius;
|
|
||||||
|
|
||||||
// Et on ajoute ensuite les quatres extrémités de la pyramide
|
|
||||||
box.ExtendTo(base + lExtend + uExtend);
|
|
||||||
box.ExtendTo(base + lExtend - uExtend);
|
|
||||||
box.ExtendTo(base - lExtend + uExtend);
|
|
||||||
box.ExtendTo(base - lExtend - uExtend);
|
|
||||||
|
|
||||||
m_boundingVolume.Set(box);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (m_type)
|
switch (m_type)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ bool NzModelParameters::IsValid() const
|
||||||
}
|
}
|
||||||
|
|
||||||
NzModel::NzModel() :
|
NzModel::NzModel() :
|
||||||
m_boundingVolumeUpdated(true),
|
|
||||||
m_matCount(0),
|
m_matCount(0),
|
||||||
m_skin(0),
|
m_skin(0),
|
||||||
m_skinCount(1)
|
m_skinCount(1)
|
||||||
|
|
@ -35,9 +34,7 @@ m_skinCount(1)
|
||||||
NzModel::NzModel(const NzModel& model) :
|
NzModel::NzModel(const NzModel& model) :
|
||||||
NzSceneNode(model),
|
NzSceneNode(model),
|
||||||
m_materials(model.m_materials),
|
m_materials(model.m_materials),
|
||||||
m_boundingVolume(model.m_boundingVolume),
|
|
||||||
m_mesh(model.m_mesh),
|
m_mesh(model.m_mesh),
|
||||||
m_boundingVolumeUpdated(model.m_boundingVolumeUpdated),
|
|
||||||
m_matCount(model.m_matCount),
|
m_matCount(model.m_matCount),
|
||||||
m_skin(model.m_skin),
|
m_skin(model.m_skin),
|
||||||
m_skinCount(model.m_skinCount)
|
m_skinCount(model.m_skinCount)
|
||||||
|
|
@ -69,24 +66,6 @@ void NzModel::AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const NzBoundingVolumef& NzModel::GetBoundingVolume() const
|
|
||||||
{
|
|
||||||
#if NAZARA_GRAPHICS_SAFE
|
|
||||||
if (!m_mesh)
|
|
||||||
{
|
|
||||||
NazaraError("Model has no mesh");
|
|
||||||
|
|
||||||
static NzBoundingVolumef dummy(nzExtend_Null);
|
|
||||||
return dummy;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!m_boundingVolumeUpdated)
|
|
||||||
UpdateBoundingVolume();
|
|
||||||
|
|
||||||
return m_boundingVolume;
|
|
||||||
}
|
|
||||||
|
|
||||||
NzMaterial* NzModel::GetMaterial(const NzString& subMeshName) const
|
NzMaterial* NzModel::GetMaterial(const NzString& subMeshName) const
|
||||||
{
|
{
|
||||||
#if NAZARA_GRAPHICS_SAFE
|
#if NAZARA_GRAPHICS_SAFE
|
||||||
|
|
@ -414,23 +393,12 @@ NzModel& NzModel::operator=(const NzModel& node)
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzModel::InvalidateNode()
|
void NzModel::MakeBoundingVolume() const
|
||||||
{
|
{
|
||||||
NzSceneNode::InvalidateNode();
|
if (m_mesh)
|
||||||
|
|
||||||
m_boundingVolumeUpdated = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NzModel::UpdateBoundingVolume() const
|
|
||||||
{
|
|
||||||
if (m_boundingVolume.IsNull())
|
|
||||||
m_boundingVolume.Set(m_mesh->GetAABB());
|
m_boundingVolume.Set(m_mesh->GetAABB());
|
||||||
|
else
|
||||||
if (!m_transformMatrixUpdated)
|
m_boundingVolume.MakeNull();
|
||||||
UpdateTransformMatrix();
|
|
||||||
|
|
||||||
m_boundingVolume.Update(m_transformMatrix);
|
|
||||||
m_boundingVolumeUpdated = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NzModelLoader::LoaderList NzModel::s_loaders;
|
NzModelLoader::LoaderList NzModel::s_loaders;
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ NzParticleSystem(maxParticleCount, NzParticleDeclaration::Get(layout))
|
||||||
|
|
||||||
NzParticleSystem::NzParticleSystem(unsigned int maxParticleCount, const NzParticleDeclaration* declaration) :
|
NzParticleSystem::NzParticleSystem(unsigned int maxParticleCount, const NzParticleDeclaration* declaration) :
|
||||||
m_declaration(declaration),
|
m_declaration(declaration),
|
||||||
m_boundingVolumeUpdated(false),
|
|
||||||
m_fixedStepEnabled(false),
|
m_fixedStepEnabled(false),
|
||||||
m_processing(false),
|
m_processing(false),
|
||||||
m_stepAccumulator(0.f),
|
m_stepAccumulator(0.f),
|
||||||
|
|
@ -38,10 +37,8 @@ NzParticleSystem::NzParticleSystem(const NzParticleSystem& system) :
|
||||||
NzSceneNode(system),
|
NzSceneNode(system),
|
||||||
m_controllers(system.m_controllers),
|
m_controllers(system.m_controllers),
|
||||||
m_generators(system.m_generators),
|
m_generators(system.m_generators),
|
||||||
m_boundingVolume(system.m_boundingVolume),
|
|
||||||
m_declaration(system.m_declaration),
|
m_declaration(system.m_declaration),
|
||||||
m_renderer(system.m_renderer),
|
m_renderer(system.m_renderer),
|
||||||
m_boundingVolumeUpdated(system.m_boundingVolumeUpdated),
|
|
||||||
m_fixedStepEnabled(system.m_fixedStepEnabled),
|
m_fixedStepEnabled(system.m_fixedStepEnabled),
|
||||||
m_processing(false),
|
m_processing(false),
|
||||||
m_stepAccumulator(0.f),
|
m_stepAccumulator(0.f),
|
||||||
|
|
@ -132,14 +129,6 @@ void* NzParticleSystem::GenerateParticles(unsigned int count)
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const NzBoundingVolumef& NzParticleSystem::GetBoundingVolume() const
|
|
||||||
{
|
|
||||||
if (!m_boundingVolumeUpdated)
|
|
||||||
UpdateBoundingVolume();
|
|
||||||
|
|
||||||
return m_boundingVolume;
|
|
||||||
}
|
|
||||||
|
|
||||||
const NzParticleDeclaration* NzParticleSystem::GetDeclaration() const
|
const NzParticleDeclaration* NzParticleSystem::GetDeclaration() const
|
||||||
{
|
{
|
||||||
return m_declaration;
|
return m_declaration;
|
||||||
|
|
@ -238,8 +227,6 @@ NzParticleSystem& NzParticleSystem::operator=(const NzParticleSystem& system)
|
||||||
|
|
||||||
NzSceneNode::operator=(system);
|
NzSceneNode::operator=(system);
|
||||||
|
|
||||||
m_boundingVolume = system.m_boundingVolume;
|
|
||||||
m_boundingVolumeUpdated = system.m_boundingVolumeUpdated;
|
|
||||||
m_controllers = system.m_controllers;
|
m_controllers = system.m_controllers;
|
||||||
m_declaration = system.m_declaration;
|
m_declaration = system.m_declaration;
|
||||||
m_fixedStepEnabled = system.m_fixedStepEnabled;
|
m_fixedStepEnabled = system.m_fixedStepEnabled;
|
||||||
|
|
@ -308,7 +295,7 @@ void NzParticleSystem::ApplyControllers(NzParticleMapper& mapper, unsigned int p
|
||||||
m_dyingParticles.clear();
|
m_dyingParticles.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzParticleSystem::GenerateAABB() const
|
void NzParticleSystem::MakeBoundingVolume() const
|
||||||
{
|
{
|
||||||
///TODO: Calculer l'AABB (prendre la taille des particules en compte s'il y a)
|
///TODO: Calculer l'AABB (prendre la taille des particules en compte s'il y a)
|
||||||
m_boundingVolume.MakeInfinite();
|
m_boundingVolume.MakeInfinite();
|
||||||
|
|
@ -356,16 +343,3 @@ void NzParticleSystem::Update()
|
||||||
ApplyControllers(mapper, m_particleCount, elapsedTime, m_stepAccumulator);
|
ApplyControllers(mapper, m_particleCount, elapsedTime, m_stepAccumulator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzParticleSystem::UpdateBoundingVolume() const
|
|
||||||
{
|
|
||||||
if (m_boundingVolume.IsNull())
|
|
||||||
GenerateAABB();
|
|
||||||
|
|
||||||
if (!m_transformMatrixUpdated)
|
|
||||||
UpdateTransformMatrix();
|
|
||||||
|
|
||||||
///FIXME: Pourquoi est-ce que le particle system est un node ? Il serait trop coûteux de calculer les particules relativement
|
|
||||||
m_boundingVolume.Update(m_transformMatrix);
|
|
||||||
m_boundingVolumeUpdated = true;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
NzSceneNode::NzSceneNode() :
|
NzSceneNode::NzSceneNode() :
|
||||||
m_scene(nullptr),
|
m_scene(nullptr),
|
||||||
|
m_boundingVolumeUpdated(false),
|
||||||
m_drawingEnabled(true),
|
m_drawingEnabled(true),
|
||||||
m_visible(false)
|
m_visible(false)
|
||||||
{
|
{
|
||||||
|
|
@ -19,6 +20,7 @@ m_visible(false)
|
||||||
NzSceneNode::NzSceneNode(const NzSceneNode& sceneNode) :
|
NzSceneNode::NzSceneNode(const NzSceneNode& sceneNode) :
|
||||||
NzNode(sceneNode),
|
NzNode(sceneNode),
|
||||||
m_scene(nullptr),
|
m_scene(nullptr),
|
||||||
|
m_boundingVolumeUpdated(false),
|
||||||
m_drawingEnabled(sceneNode.m_drawingEnabled),
|
m_drawingEnabled(sceneNode.m_drawingEnabled),
|
||||||
m_visible(false)
|
m_visible(false)
|
||||||
{
|
{
|
||||||
|
|
@ -44,6 +46,14 @@ NzVector3f NzSceneNode::GetBackward() const
|
||||||
return NzNode::GetBackward();
|
return NzNode::GetBackward();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const NzBoundingVolumef& NzSceneNode::GetBoundingVolume() const
|
||||||
|
{
|
||||||
|
if (!m_boundingVolumeUpdated)
|
||||||
|
UpdateBoundingVolume();
|
||||||
|
|
||||||
|
return m_boundingVolume;
|
||||||
|
}
|
||||||
|
|
||||||
NzVector3f NzSceneNode::GetDown() const
|
NzVector3f NzSceneNode::GetDown() const
|
||||||
{
|
{
|
||||||
if (m_scene)
|
if (m_scene)
|
||||||
|
|
@ -145,6 +155,13 @@ bool NzSceneNode::FrustumCull(const NzFrustumf& frustum) const
|
||||||
return frustum.Contains(GetBoundingVolume());
|
return frustum.Contains(GetBoundingVolume());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NzSceneNode::InvalidateNode()
|
||||||
|
{
|
||||||
|
NzNode::InvalidateNode();
|
||||||
|
|
||||||
|
m_boundingVolumeUpdated = false;
|
||||||
|
}
|
||||||
|
|
||||||
void NzSceneNode::OnParenting(const NzNode* parent)
|
void NzSceneNode::OnParenting(const NzNode* parent)
|
||||||
{
|
{
|
||||||
if (parent)
|
if (parent)
|
||||||
|
|
@ -207,6 +224,18 @@ void NzSceneNode::Update()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NzSceneNode::UpdateBoundingVolume() const
|
||||||
|
{
|
||||||
|
if (m_boundingVolume.IsNull())
|
||||||
|
MakeBoundingVolume();
|
||||||
|
|
||||||
|
if (!m_transformMatrixUpdated)
|
||||||
|
UpdateTransformMatrix();
|
||||||
|
|
||||||
|
m_boundingVolume.Update(m_transformMatrix);
|
||||||
|
m_boundingVolumeUpdated = true;
|
||||||
|
}
|
||||||
|
|
||||||
void NzSceneNode::UpdateVisibility(const NzFrustumf& frustum)
|
void NzSceneNode::UpdateVisibility(const NzFrustumf& frustum)
|
||||||
{
|
{
|
||||||
bool wasVisible = m_visible;
|
bool wasVisible = m_visible;
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,6 @@ void NzSceneRoot::AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const
|
||||||
NazaraInternalError("SceneNode::AddToRenderQueue() called on SceneRoot");
|
NazaraInternalError("SceneNode::AddToRenderQueue() called on SceneRoot");
|
||||||
}
|
}
|
||||||
|
|
||||||
const NzBoundingVolumef& NzSceneRoot::GetBoundingVolume() const
|
|
||||||
{
|
|
||||||
static NzBoundingVolumef infinite(nzExtend_Infinite);
|
|
||||||
return infinite;
|
|
||||||
}
|
|
||||||
|
|
||||||
nzSceneNodeType NzSceneRoot::GetSceneNodeType() const
|
nzSceneNodeType NzSceneRoot::GetSceneNodeType() const
|
||||||
{
|
{
|
||||||
return nzSceneNodeType_Root;
|
return nzSceneNodeType_Root;
|
||||||
|
|
@ -36,6 +30,11 @@ bool NzSceneRoot::IsDrawable() const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NzSceneRoot::MakeBoundingVolume() const
|
||||||
|
{
|
||||||
|
m_boundingVolume.MakeInfinite();
|
||||||
|
}
|
||||||
|
|
||||||
void NzSceneRoot::Register()
|
void NzSceneRoot::Register()
|
||||||
{
|
{
|
||||||
NazaraInternalError("SceneNode::Register() called on SceneRoot");
|
NazaraInternalError("SceneNode::Register() called on SceneRoot");
|
||||||
|
|
|
||||||
|
|
@ -325,6 +325,11 @@ NzSkeletalModel& NzSkeletalModel::operator=(NzSkeletalModel&& node)
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NzSkeletalModel::MakeBoundingVolume() const
|
||||||
|
{
|
||||||
|
m_boundingVolume.Set(m_skeleton.GetAABB());
|
||||||
|
}
|
||||||
|
|
||||||
void NzSkeletalModel::Register()
|
void NzSkeletalModel::Register()
|
||||||
{
|
{
|
||||||
if (m_animation)
|
if (m_animation)
|
||||||
|
|
@ -342,16 +347,4 @@ void NzSkeletalModel::Update()
|
||||||
AdvanceAnimation(m_scene->GetUpdateTime());
|
AdvanceAnimation(m_scene->GetUpdateTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzSkeletalModel::UpdateBoundingVolume() const
|
|
||||||
{
|
|
||||||
if (m_boundingVolume.IsNull())
|
|
||||||
m_boundingVolume.Set(m_skeleton.GetAABB());
|
|
||||||
|
|
||||||
if (!m_transformMatrixUpdated)
|
|
||||||
UpdateTransformMatrix();
|
|
||||||
|
|
||||||
m_boundingVolume.Update(m_transformMatrix);
|
|
||||||
m_boundingVolumeUpdated = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
NzSkeletalModelLoader::LoaderList NzSkeletalModel::s_loaders;
|
NzSkeletalModelLoader::LoaderList NzSkeletalModel::s_loaders;
|
||||||
|
|
|
||||||
|
|
@ -9,22 +9,18 @@
|
||||||
#include <Nazara/Graphics/Debug.hpp>
|
#include <Nazara/Graphics/Debug.hpp>
|
||||||
|
|
||||||
NzSprite::NzSprite() :
|
NzSprite::NzSprite() :
|
||||||
m_boundingVolume(NzBoundingVolumef::Null()),
|
|
||||||
m_color(NzColor::White),
|
m_color(NzColor::White),
|
||||||
m_textureCoords(0.f, 0.f, 1.f, 1.f),
|
m_textureCoords(0.f, 0.f, 1.f, 1.f),
|
||||||
m_size(64.f, 64.f),
|
m_size(64.f, 64.f),
|
||||||
m_boundingVolumeUpdated(true),
|
|
||||||
m_verticesUpdated(false)
|
m_verticesUpdated(false)
|
||||||
{
|
{
|
||||||
SetDefaultMaterial();
|
SetDefaultMaterial();
|
||||||
}
|
}
|
||||||
|
|
||||||
NzSprite::NzSprite(NzTexture* texture) :
|
NzSprite::NzSprite(NzTexture* texture) :
|
||||||
m_boundingVolume(NzBoundingVolumef::Null()),
|
|
||||||
m_color(NzColor::White),
|
m_color(NzColor::White),
|
||||||
m_textureCoords(0.f, 0.f, 1.f, 1.f),
|
m_textureCoords(0.f, 0.f, 1.f, 1.f),
|
||||||
m_size(64.f, 64.f),
|
m_size(64.f, 64.f),
|
||||||
m_boundingVolumeUpdated(false),
|
|
||||||
m_verticesUpdated(false)
|
m_verticesUpdated(false)
|
||||||
{
|
{
|
||||||
SetTexture(texture, true);
|
SetTexture(texture, true);
|
||||||
|
|
@ -32,13 +28,11 @@ m_verticesUpdated(false)
|
||||||
|
|
||||||
NzSprite::NzSprite(const NzSprite& sprite) :
|
NzSprite::NzSprite(const NzSprite& sprite) :
|
||||||
NzSceneNode(sprite),
|
NzSceneNode(sprite),
|
||||||
m_boundingVolume(sprite.m_boundingVolume),
|
|
||||||
m_color(sprite.m_color),
|
m_color(sprite.m_color),
|
||||||
m_material(sprite.m_material),
|
m_material(sprite.m_material),
|
||||||
m_textureCoords(sprite.m_textureCoords),
|
m_textureCoords(sprite.m_textureCoords),
|
||||||
m_size(sprite.m_size),
|
m_size(sprite.m_size),
|
||||||
m_vertices(sprite.m_vertices),
|
m_vertices(sprite.m_vertices),
|
||||||
m_boundingVolumeUpdated(sprite.m_boundingVolumeUpdated),
|
|
||||||
m_verticesUpdated(sprite.m_verticesUpdated)
|
m_verticesUpdated(sprite.m_verticesUpdated)
|
||||||
{
|
{
|
||||||
SetParent(sprite.GetParent());
|
SetParent(sprite.GetParent());
|
||||||
|
|
@ -52,14 +46,6 @@ void NzSprite::AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const
|
||||||
renderQueue->AddSprites(m_material, m_vertices, 1);
|
renderQueue->AddSprites(m_material, m_vertices, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const NzBoundingVolumef& NzSprite::GetBoundingVolume() const
|
|
||||||
{
|
|
||||||
if (!m_boundingVolumeUpdated)
|
|
||||||
UpdateBoundingVolume();
|
|
||||||
|
|
||||||
return m_boundingVolume;
|
|
||||||
}
|
|
||||||
|
|
||||||
const NzColor& NzSprite::GetColor() const
|
const NzColor& NzSprite::GetColor() const
|
||||||
{
|
{
|
||||||
return m_color;
|
return m_color;
|
||||||
|
|
@ -189,7 +175,6 @@ NzSprite& NzSprite::operator=(const NzSprite& sprite)
|
||||||
m_size = sprite.m_size;
|
m_size = sprite.m_size;
|
||||||
|
|
||||||
// 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
|
// 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;
|
m_verticesUpdated = false;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
|
|
@ -199,7 +184,6 @@ void NzSprite::InvalidateNode()
|
||||||
{
|
{
|
||||||
NzSceneNode::InvalidateNode();
|
NzSceneNode::InvalidateNode();
|
||||||
|
|
||||||
m_boundingVolumeUpdated = false;
|
|
||||||
m_verticesUpdated = false;
|
m_verticesUpdated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -213,21 +197,12 @@ void NzSprite::Unregister()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzSprite::UpdateBoundingVolume() const
|
void NzSprite::MakeBoundingVolume() const
|
||||||
{
|
{
|
||||||
if (m_boundingVolume.IsNull())
|
NzVector3f down = (m_scene) ? m_scene->GetDown() : NzVector3f::Down();
|
||||||
{
|
NzVector3f right = (m_scene) ? m_scene->GetRight() : NzVector3f::Right();
|
||||||
NzVector3f down = m_scene->GetDown();
|
|
||||||
NzVector3f right = m_scene->GetRight();
|
|
||||||
|
|
||||||
m_boundingVolume.Set(NzVector3f(0.f), m_size.x*right + m_size.y*down);
|
m_boundingVolume.Set(NzVector3f(0.f), m_size.x*right + m_size.y*down);
|
||||||
}
|
|
||||||
|
|
||||||
if (!m_transformMatrixUpdated)
|
|
||||||
UpdateTransformMatrix();
|
|
||||||
|
|
||||||
m_boundingVolume.Update(m_transformMatrix);
|
|
||||||
m_boundingVolumeUpdated = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzSprite::UpdateVertices() const
|
void NzSprite::UpdateVertices() const
|
||||||
|
|
@ -235,8 +210,8 @@ void NzSprite::UpdateVertices() const
|
||||||
if (!m_transformMatrixUpdated)
|
if (!m_transformMatrixUpdated)
|
||||||
UpdateTransformMatrix();
|
UpdateTransformMatrix();
|
||||||
|
|
||||||
NzVector3f down = m_scene->GetDown();
|
NzVector3f down = (m_scene) ? m_scene->GetDown() : NzVector3f::Down();
|
||||||
NzVector3f right = m_scene->GetRight();
|
NzVector3f right = (m_scene) ? m_scene->GetRight() : NzVector3f::Right();
|
||||||
|
|
||||||
m_vertices[0].color = m_color;
|
m_vertices[0].color = m_color;
|
||||||
m_vertices[0].position = m_transformMatrix.Transform(NzVector3f(0.f));
|
m_vertices[0].position = m_transformMatrix.Transform(NzVector3f(0.f));
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@
|
||||||
#include <Nazara/Graphics/Debug.hpp>
|
#include <Nazara/Graphics/Debug.hpp>
|
||||||
|
|
||||||
NzTextSprite::NzTextSprite() :
|
NzTextSprite::NzTextSprite() :
|
||||||
m_boundingVolume(NzBoundingVolumef::Null()),
|
|
||||||
m_color(NzColor::White),
|
m_color(NzColor::White),
|
||||||
m_verticesUpdated(false)
|
m_verticesUpdated(false)
|
||||||
{
|
{
|
||||||
|
|
@ -24,11 +23,9 @@ m_atlases(sprite.m_atlases),
|
||||||
m_renderInfos(sprite.m_renderInfos),
|
m_renderInfos(sprite.m_renderInfos),
|
||||||
m_localVertices(sprite.m_localVertices),
|
m_localVertices(sprite.m_localVertices),
|
||||||
m_vertices(sprite.m_vertices),
|
m_vertices(sprite.m_vertices),
|
||||||
m_boundingVolume(sprite.m_boundingVolume),
|
|
||||||
m_color(sprite.m_color),
|
m_color(sprite.m_color),
|
||||||
m_material(sprite.m_material),
|
m_material(sprite.m_material),
|
||||||
m_localBounds(sprite.m_localBounds),
|
m_localBounds(sprite.m_localBounds),
|
||||||
m_boundingVolumeUpdated(sprite.m_boundingVolumeUpdated),
|
|
||||||
m_verticesUpdated(sprite.m_verticesUpdated)
|
m_verticesUpdated(sprite.m_verticesUpdated)
|
||||||
{
|
{
|
||||||
SetParent(sprite.GetParent());
|
SetParent(sprite.GetParent());
|
||||||
|
|
@ -66,14 +63,6 @@ void NzTextSprite::Clear()
|
||||||
m_vertices.clear();
|
m_vertices.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
const NzBoundingVolumef& NzTextSprite::GetBoundingVolume() const
|
|
||||||
{
|
|
||||||
if (!m_boundingVolumeUpdated)
|
|
||||||
UpdateBoundingVolume();
|
|
||||||
|
|
||||||
return m_boundingVolume;
|
|
||||||
}
|
|
||||||
|
|
||||||
const NzColor& NzTextSprite::GetColor() const
|
const NzColor& NzTextSprite::GetColor() const
|
||||||
{
|
{
|
||||||
return m_color;
|
return m_color;
|
||||||
|
|
@ -266,7 +255,6 @@ NzTextSprite& NzTextSprite::operator=(const NzTextSprite& text)
|
||||||
m_localVertices = text.m_localVertices;
|
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
|
// 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;
|
m_verticesUpdated = false;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
|
|
@ -284,10 +272,21 @@ void NzTextSprite::InvalidateNode()
|
||||||
{
|
{
|
||||||
NzSceneNode::InvalidateNode();
|
NzSceneNode::InvalidateNode();
|
||||||
|
|
||||||
m_boundingVolumeUpdated = false;
|
|
||||||
m_verticesUpdated = 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)
|
bool NzTextSprite::OnAtlasCleared(const NzAbstractAtlas* atlas, void* userdata)
|
||||||
{
|
{
|
||||||
NazaraUnused(userdata);
|
NazaraUnused(userdata);
|
||||||
|
|
@ -373,34 +372,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
|
void NzTextSprite::UpdateVertices() const
|
||||||
{
|
{
|
||||||
if (!m_transformMatrixUpdated)
|
if (!m_transformMatrixUpdated)
|
||||||
UpdateTransformMatrix();
|
UpdateTransformMatrix();
|
||||||
|
|
||||||
NzVector3f down = m_scene->GetDown();
|
NzVector3f down = (m_scene) ? m_scene->GetDown() : NzVector3f::Down();
|
||||||
NzVector3f right = m_scene->GetRight();
|
NzVector3f right = (m_scene) ? m_scene->GetRight() : NzVector3f::Right();
|
||||||
|
|
||||||
NzSparsePtr<NzColor> colorPtr(&m_vertices[0].color, sizeof(NzVertexStruct_XYZ_Color_UV));
|
NzSparsePtr<NzColor> colorPtr(&m_vertices[0].color, sizeof(NzVertexStruct_XYZ_Color_UV));
|
||||||
NzSparsePtr<NzVector3f> posPtr(&m_vertices[0].position, sizeof(NzVertexStruct_XYZ_Color_UV));
|
NzSparsePtr<NzVector3f> posPtr(&m_vertices[0].position, sizeof(NzVertexStruct_XYZ_Color_UV));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue