Made bounding volume handing part of SceneNodes

Former-commit-id: d09d06ac4515ce09aa16fd92dd045c2a06730a99
This commit is contained in:
Lynix
2015-01-20 20:35:16 +01:00
parent bce3cadfd5
commit 8a3c410d60
19 changed files with 127 additions and 229 deletions

View File

@@ -9,12 +9,12 @@
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Graphics/AbstractViewer.hpp>
#include <Nazara/Graphics/SceneNode.hpp>
#include <Nazara/Math/Frustum.hpp>
#include <Nazara/Math/Matrix4.hpp>
#include <Nazara/Math/Rect.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Renderer/RenderTarget.hpp>
#include <Nazara/Utility/Node.hpp>
class NAZARA_API NzCamera : public NzAbstractViewer, public NzNode, NzRenderTarget::Listener
{

View File

@@ -28,7 +28,6 @@ class NAZARA_API NzLight : public NzSceneNode
float GetAmbientFactor() const;
float GetAttenuation() const;
const NzBoundingVolumef& GetBoundingVolume() const;
NzColor GetColor() const;
float GetDiffuseFactor() const;
float GetInnerAngle() const;
@@ -54,15 +53,13 @@ class NAZARA_API NzLight : public NzSceneNode
private:
bool FrustumCull(const NzFrustumf& frustum) const override;
void InvalidateNode() override;
void MakeBoundingVolume() const override;
void Register() override;
void Unregister() override;
void UpdateBoundingVolume() const;
nzLightType m_type;
mutable NzBoundingVolumef m_boundingVolume;
NzColor m_color;
mutable bool m_boundingVolumeUpdated;
float m_ambientFactor;
float m_attenuation;
float m_diffuseFactor;

View File

@@ -44,7 +44,6 @@ class NAZARA_API NzModel : public NzSceneNode
void EnableAnimation(bool animation);
NzAnimation* GetAnimation() const;
const NzBoundingVolumef& GetBoundingVolume() const;
NzMaterial* GetMaterial(const NzString& subMeshName) const;
NzMaterial* GetMaterial(unsigned int matIndex) 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);
protected:
void InvalidateNode() override;
virtual void UpdateBoundingVolume() const;
void MakeBoundingVolume() const override;
std::vector<NzMaterialRef> m_materials;
mutable NzBoundingVolumef m_boundingVolume;
NzMeshRef m_mesh;
mutable bool m_boundingVolumeUpdated;
unsigned int m_matCount;
unsigned int m_skin;
unsigned int m_skinCount;

View File

@@ -43,7 +43,6 @@ class NAZARA_API NzParticleSystem : public NzSceneNode, NzUpdatable
void* GenerateParticle();
void* GenerateParticles(unsigned int count);
const NzBoundingVolumef& GetBoundingVolume() const override;
const NzParticleDeclaration* GetDeclaration() const;
float GetFixedStepSize() const;
unsigned int GetMaxParticleCount() const;
@@ -67,22 +66,19 @@ class NAZARA_API NzParticleSystem : public NzSceneNode, NzUpdatable
NzParticleSystem& operator=(const NzParticleSystem& emitter);
private:
void GenerateAABB() const;
void MakeBoundingVolume() const override;
void Register() override;
void ResizeBuffer();
void Unregister() override;
void Update() override;
void UpdateBoundingVolume() const;
std::set<unsigned int, std::greater<unsigned int>> m_dyingParticles;
mutable std::vector<nzUInt8> m_buffer;
std::vector<NzParticleControllerRef> m_controllers;
std::vector<NzParticleEmitter*> m_emitters;
std::vector<NzParticleGeneratorRef> m_generators;
mutable NzBoundingVolumef m_boundingVolume;
NzParticleDeclarationConstRef m_declaration;
NzParticleRendererRef m_renderer;
mutable bool m_boundingVolumeUpdated;
bool m_fixedStepEnabled;
bool m_processing;
float m_stepAccumulator;

View File

@@ -14,6 +14,8 @@
#include <Nazara/Math/Frustum.hpp>
#include <Nazara/Utility/Node.hpp>
class NzScene;
class NAZARA_API NzSceneNode : public NzNode
{
friend class NzScene;
@@ -29,7 +31,7 @@ class NAZARA_API NzSceneNode : public NzNode
void EnableDrawing(bool drawingEnabled);
NzVector3f GetBackward() const;
virtual const NzBoundingVolumef& GetBoundingVolume() const = 0;
virtual const NzBoundingVolumef& GetBoundingVolume() const;
NzVector3f GetDown() const;
NzVector3f GetForward() const;
NzVector3f GetLeft() const;
@@ -39,6 +41,8 @@ class NAZARA_API NzSceneNode : public NzNode
virtual nzSceneNodeType GetSceneNodeType() const = 0;
NzVector3f GetUp() const;
void InvalidateAABB();
virtual bool IsDrawable() const = 0;
bool IsDrawingEnabled() const;
bool IsVisible() const;
@@ -48,6 +52,8 @@ class NAZARA_API NzSceneNode : public NzNode
protected:
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 OnVisibilityChange(bool visibility);
void RecursiveSetScene(NzScene* scene, NzNode* node);
@@ -55,8 +61,11 @@ class NAZARA_API NzSceneNode : public NzNode
void SetScene(NzScene* scene);
virtual void Unregister();
virtual void Update();
virtual void UpdateBoundingVolume() const;
mutable NzBoundingVolumef m_boundingVolume;
NzScene* m_scene;
mutable bool m_boundingVolumeUpdated;
bool m_drawingEnabled;
bool m_visible;

View File

@@ -17,7 +17,6 @@ class NAZARA_API NzSceneRoot : public NzSceneNode
public:
void AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const override;
const NzBoundingVolumef& GetBoundingVolume() const override;
nzSceneNodeType GetSceneNodeType() const override;
bool IsDrawable() const;
@@ -26,6 +25,7 @@ class NAZARA_API NzSceneRoot : public NzSceneNode
NzSceneRoot(NzScene* scene);
virtual ~NzSceneRoot();
void MakeBoundingVolume() const override;
void Register();
void Unregister();
};

View File

@@ -69,10 +69,10 @@ class NAZARA_API NzSkeletalModel : public NzModel, NzUpdatable
NzSkeletalModel& operator=(NzSkeletalModel&& node);
private:
void MakeBoundingVolume() const override;
void Register() override;
void Unregister() override;
void Update() override;
void UpdateBoundingVolume() const;
NzAnimationRef m_animation;
NzSkeleton m_skeleton;

View File

@@ -22,7 +22,6 @@ class NAZARA_API NzSprite : public NzSceneNode
void AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const override;
const NzBoundingVolumef& GetBoundingVolume() const override;
const NzColor& GetColor() const;
NzMaterial* GetMaterial() const;
nzSceneNodeType GetSceneNodeType() const override;
@@ -44,18 +43,16 @@ class NAZARA_API NzSprite : public NzSceneNode
private:
void InvalidateNode() override;
void MakeBoundingVolume() const override;
void Register() override;
void Unregister() override;
void UpdateBoundingVolume() const;
void UpdateVertices() const;
mutable NzBoundingVolumef m_boundingVolume;
NzColor m_color;
NzMaterialRef m_material;
NzRectf m_textureCoords;
NzVector2f m_size;
mutable NzVertexStruct_XYZ_Color_UV m_vertices[4];
mutable bool m_boundingVolumeUpdated;
mutable bool m_verticesUpdated;
};

View File

@@ -28,7 +28,6 @@ class NAZARA_API NzTextSprite : public NzSceneNode, NzAbstractAtlas::Listener
void Clear();
const NzBoundingVolumef& GetBoundingVolume() const override;
const NzColor& GetColor() const;
NzMaterial* GetMaterial() const;
nzSceneNodeType GetSceneNodeType() const override;
@@ -47,12 +46,12 @@ class NAZARA_API NzTextSprite : public NzSceneNode, NzAbstractAtlas::Listener
private:
void ClearAtlases();
void InvalidateNode() override;
void MakeBoundingVolume() const override;
bool OnAtlasCleared(const NzAbstractAtlas* atlas, void* userdata) override;
bool OnAtlasLayerChange(const NzAbstractAtlas* atlas, NzAbstractImage* oldLayer, NzAbstractImage* newLayer, void* userdata) override;
void OnAtlasReleased(const NzAbstractAtlas* atlas, void* userdata) override;
void Register() override;
void Unregister() override;
void UpdateBoundingVolume() const;
void UpdateVertices() const;
struct RenderIndices
@@ -65,11 +64,9 @@ class NAZARA_API NzTextSprite : public NzSceneNode, NzAbstractAtlas::Listener
mutable std::unordered_map<NzTexture*, RenderIndices> m_renderInfos;
mutable std::vector<NzVertexStruct_XY_Color> m_localVertices;
mutable std::vector<NzVertexStruct_XYZ_Color_UV> m_vertices;
mutable NzBoundingVolumef m_boundingVolume;
NzColor m_color;
NzMaterialRef m_material;
NzRectui m_localBounds;
mutable bool m_boundingVolumeUpdated;
mutable bool m_verticesUpdated;
};

View File

@@ -9,12 +9,12 @@
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Graphics/AbstractViewer.hpp>
#include <Nazara/Graphics/SceneNode.hpp>
#include <Nazara/Math/Frustum.hpp>
#include <Nazara/Math/Matrix4.hpp>
#include <Nazara/Math/Rect.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Renderer/RenderTarget.hpp>
#include <Nazara/Utility/Node.hpp>
class NAZARA_API NzView : public NzAbstractViewer, public NzNode, NzRenderTarget::Listener
{