Răsfoiți Sursa

Scene refactoring. WONT COMPILE

Panagiotis Christopoulos Charitos 12 ani în urmă
părinte
comite
7ff8ae3ccf

+ 1 - 0
include/anki/Config.h.cmake

@@ -108,6 +108,7 @@
 // General config
 // General config
 #define ANKI_MAX_MULTIDRAW_PRIMITIVES 64
 #define ANKI_MAX_MULTIDRAW_PRIMITIVES 64
 #define ANKI_MAX_INSTANCES 32
 #define ANKI_MAX_INSTANCES 32
+#define ANKI_SAFE_ALIGNMENT 16
 
 
 // Renderer and rendering related config options
 // Renderer and rendering related config options
 #define ANKI_RENDERER_MAX_TILES_X 16
 #define ANKI_RENDERER_MAX_TILES_X 16

+ 21 - 48
include/anki/scene/Camera.h

@@ -3,9 +3,8 @@
 
 
 #include "anki/scene/SceneNode.h"
 #include "anki/scene/SceneNode.h"
 #include "anki/scene/SpatialComponent.h"
 #include "anki/scene/SpatialComponent.h"
-#include "anki/scene/Movable.h"
-#include "anki/scene/Frustumable.h"
-#include "anki/core/Logger.h"
+#include "anki/scene/MoveComponent.h"
+#include "anki/scene/FrustumComponent.h"
 
 
 namespace anki {
 namespace anki {
 
 
@@ -13,8 +12,8 @@ namespace anki {
 /// @{
 /// @{
 
 
 /// Camera SceneNode interface class
 /// Camera SceneNode interface class
-class Camera: public SceneNode, public Movable, public SpatialComponent, 
-	public Frustumable
+class Camera: public SceneNode, public MoveComponent, public SpatialComponent, 
+	public FrustumComponent
 {
 {
 public:
 public:
 	/// @note Don't EVER change the order
 	/// @note Don't EVER change the order
@@ -28,10 +27,9 @@ public:
 	/// @name Constructors/Destructor
 	/// @name Constructors/Destructor
 	/// @{
 	/// @{
 	Camera(
 	Camera(
-		const char* name, SceneGraph* scene, SceneNode* parent, // SceneNode
-		U32 movableFlags, // Movable
+		const char* name, SceneGraph* scene, // SceneNode
 		Frustum* frustum, // Spatial & Frustumable
 		Frustum* frustum, // Spatial & Frustumable
-		CameraType type_); // Self
+		CameraType type); // Self
 
 
 	virtual ~Camera();
 	virtual ~Camera();
 	/// @}
 	/// @}
@@ -54,21 +52,11 @@ public:
 	virtual F32 getFar() const = 0;
 	virtual F32 getFar() const = 0;
 	/// @}
 	/// @}
 
 
-	/// @name SceneNode virtuals
-	/// @{
-
-	/// Override SceneNode::frameUpdate
-	void frameUpdate(F32 prevUpdateTime, F32 crntTime, int frame)
-	{
-		SceneNode::frameUpdate(prevUpdateTime, crntTime, frame);
-	}
-	/// @}
-
 	/// @name Frustumable virtuals
 	/// @name Frustumable virtuals
 	/// @{
 	/// @{
 
 
 	/// Override Frustumable::getFrustumableOrigin()
 	/// Override Frustumable::getFrustumableOrigin()
-	const Vec3& getFrustumableOrigin() const
+	const Vec3& getFrustumOrigin() const
 	{
 	{
 		return getWorldTransform().getOrigin();
 		return getWorldTransform().getOrigin();
 	}
 	}
@@ -115,13 +103,9 @@ private:
 class PerspectiveCamera: public Camera
 class PerspectiveCamera: public Camera
 {
 {
 public:
 public:
-	ANKI_HAS_SLOTS(PerspectiveCamera)
-
 	/// @name Constructors
 	/// @name Constructors
 	/// @{
 	/// @{
-	PerspectiveCamera(
-		const char* name, SceneGraph* scene, SceneNode* parent, // SceneNode
-		U32 movableFlags); // Movable
+	PerspectiveCamera(const char* name, SceneGraph* scene);
 	/// @}
 	/// @}
 
 
 	/// @name Accessors
 	/// @name Accessors
@@ -142,8 +126,8 @@ public:
 	}
 	}
 	void setFovX(F32 x)
 	void setFovX(F32 x)
 	{
 	{
-		frustumUpdate();
 		frustum.setFovX(x);
 		frustum.setFovX(x);
+		frustumUpdate();
 	}
 	}
 
 
 	F32 getFovY() const
 	F32 getFovY() const
@@ -152,8 +136,8 @@ public:
 	}
 	}
 	void setFovY(F32 x)
 	void setFovY(F32 x)
 	{
 	{
-		frustumUpdate();
 		frustum.setFovY(x);
 		frustum.setFovY(x);
+		frustumUpdate();
 	}
 	}
 
 
 	void setAll(F32 fovX_, F32 fovY_, F32 near_, F32 far_)
 	void setAll(F32 fovX_, F32 fovY_, F32 near_, F32 far_)
@@ -169,14 +153,14 @@ public:
 	/// Overrides Movable::moveUpdate(). This does:
 	/// Overrides Movable::moveUpdate(). This does:
 	/// @li Update view matrix
 	/// @li Update view matrix
 	/// @li Update view-projection matrix
 	/// @li Update view-projection matrix
-	/// @li Update frustum
-	void movableUpdate()
+	/// @li Move the frustum
+	void moveUpdate()
 	{
 	{
-		Movable::movableUpdate();
 		updateViewMatrix();
 		updateViewMatrix();
 		updateViewProjectionMatrix();
 		updateViewProjectionMatrix();
 		frustum.setTransform(getWorldTransform());
 		frustum.setTransform(getWorldTransform());
-		spatialMarkForUpdate();
+
+		SpatialComponent::markForUpdate();
 	}
 	}
 	/// @}
 	/// @}
 
 
@@ -186,12 +170,12 @@ private:
 	/// Called when something changes in the frustum
 	/// Called when something changes in the frustum
 	void frustumUpdate()
 	void frustumUpdate()
 	{
 	{
-		frustumableMarkUpdated();
-
 		projectionMat = frustum.calculateProjectionMatrix();
 		projectionMat = frustum.calculateProjectionMatrix();
 		invProjectionMat = projectionMat.getInverse();
 		invProjectionMat = projectionMat.getInverse();
 		updateViewProjectionMatrix();
 		updateViewProjectionMatrix();
-		spatialMarkForUpdate();
+
+		SpatialComponent::markForUpdate();
+		FrustumComponent::markForUpdate();
 	}
 	}
 };
 };
 
 
@@ -199,13 +183,9 @@ private:
 class OrthographicCamera: public Camera
 class OrthographicCamera: public Camera
 {
 {
 public:
 public:
-	ANKI_HAS_SLOTS(OrthographicCamera)
-
 	/// @name Constructors
 	/// @name Constructors
 	/// @{
 	/// @{
-	OrthographicCamera(
-		const char* name, SceneGraph* scene, SceneNode* parent, // SceneNode
-		U32 movableFlags); // Movable
+	OrthographicCamera(const char* name, SceneGraph* scene);
 	/// @}
 	/// @}
 
 
 	/// @name Accessors
 	/// @name Accessors
@@ -243,6 +223,7 @@ public:
 	void setAll(F32 left, F32 right, F32 near, F32 far, F32 top, F32 bottom)
 	void setAll(F32 left, F32 right, F32 near, F32 far, F32 top, F32 bottom)
 	{
 	{
 		frustum.setAll(left, right, near, far, top, bottom);
 		frustum.setAll(left, right, near, far, top, bottom);
+		frustumUpdate();
 	}
 	}
 	/// @}
 	/// @}
 
 
@@ -255,10 +236,7 @@ public:
 	/// @li Update frustum
 	/// @li Update frustum
 	void movableUpdate()
 	void movableUpdate()
 	{
 	{
-		Movable::movableUpdate();
-		updateViewMatrix();
-		updateViewProjectionMatrix();
-		frustum.setTransform(getWorldTransform());
+		ANKI_ASSERT(0 && "TODO");
 	}
 	}
 	/// @}
 	/// @}
 
 
@@ -268,12 +246,7 @@ private:
 	/// Called when something changes in the frustum
 	/// Called when something changes in the frustum
 	void frustumUpdate()
 	void frustumUpdate()
 	{
 	{
-		frustumableMarkUpdated();
-
-		projectionMat = frustum.calculateProjectionMatrix();
-		invProjectionMat = projectionMat.getInverse();
-		updateViewProjectionMatrix();
-		spatialMarkForUpdate();
+		ANKI_ASSERT(0 && "TODO");
 	}
 	}
 };
 };
 /// @}
 /// @}

+ 3 - 3
include/anki/scene/FrustumComponent.h

@@ -36,7 +36,7 @@ public:
 		return *frustum;
 		return *frustum;
 	}
 	}
 
 
-	Timestamp getFrustumComponentTimestamp() const
+	Timestamp getTimestamp() const
 	{
 	{
 		return timestamp;
 		return timestamp;
 	}
 	}
@@ -57,7 +57,7 @@ public:
 	}
 	}
 
 
 	/// Get the origin for sorting and visibility tests
 	/// Get the origin for sorting and visibility tests
-	virtual const Vec3& getFrustumComponentOrigin() const = 0;
+	virtual const Vec3& getFrustumOrigin() const = 0;
 
 
 	void setVisibilityTestResults(VisibilityTestResults* visible_)
 	void setVisibilityTestResults(VisibilityTestResults* visible_)
 	{
 	{
@@ -72,7 +72,7 @@ public:
 	}
 	}
 	/// @}
 	/// @}
 
 
-	void frustumMarkForUpdate()
+	void markForUpdate()
 	{
 	{
 		timestamp = getGlobTimestamp();
 		timestamp = getGlobTimestamp();
 	}
 	}

+ 28 - 29
include/anki/scene/Light.h

@@ -2,8 +2,8 @@
 #define ANKI_SCENE_LIGHT_H
 #define ANKI_SCENE_LIGHT_H
 
 
 #include "anki/scene/SceneNode.h"
 #include "anki/scene/SceneNode.h"
-#include "anki/scene/Movable.h"
-#include "anki/scene/Frustumable.h"
+#include "anki/scene/MoveComponent.h"
+#include "anki/scene/FrustumComponent.h"
 #include "anki/scene/SpatialComponent.h"
 #include "anki/scene/SpatialComponent.h"
 #include "anki/resource/Resource.h"
 #include "anki/resource/Resource.h"
 #include "anki/resource/TextureResource.h"
 #include "anki/resource/TextureResource.h"
@@ -50,7 +50,7 @@ private:
 /// Specular intensity of light:    Sl
 /// Specular intensity of light:    Sl
 /// Specular intensity of material: Sm
 /// Specular intensity of material: Sm
 /// @endcode
 /// @endcode
-class Light: public SceneNode, public Movable, public SpatialComponent
+class Light: public SceneNode, public MoveComponent, public SpatialComponent
 {
 {
 public:
 public:
 	enum LightType
 	enum LightType
@@ -63,10 +63,9 @@ public:
 	/// @name Constructors
 	/// @name Constructors
 	/// @{
 	/// @{
 	Light(
 	Light(
-		const char* name, SceneGraph* scene, SceneNode* parent, // Scene
-		U32 movableFlags, // Movable
-		CollisionShape* cs, // Spatial
-		LightType t, const char* lensFlareFile); // Self
+		const char* name, SceneGraph* scene, // SceneNode
+		CollisionShape* cs, // SpatialComponent
+		LightType t); // Self
 	/// @}
 	/// @}
 
 
 	virtual ~Light();
 	virtual ~Light();
@@ -169,6 +168,12 @@ public:
 	}
 	}
 	/// @}
 	/// @}
 
 
+	void loadLensFlare(const char* filename)
+	{
+		ANKI_ASSERT(!hasLensFlare());
+		flaresTex.load(filename);
+	}
+
 private:
 private:
 	LightType type;
 	LightType type;
 	Vec4 color = Vec4(1.0);
 	Vec4 color = Vec4(1.0);
@@ -192,8 +197,7 @@ class PointLight: public Light
 public:
 public:
 	/// @name Constructors/Destructor
 	/// @name Constructors/Destructor
 	/// @{
 	/// @{
-	PointLight(const char* name, SceneGraph* scene, SceneNode* parent,
-		U32 movableFlags, const char* lensFlareFile = nullptr);
+	PointLight(const char* name, SceneGraph* scene);
 	/// @}
 	/// @}
 
 
 	/// @name Accessors
 	/// @name Accessors
@@ -205,7 +209,7 @@ public:
 	void setRadius(const F32 x)
 	void setRadius(const F32 x)
 	{
 	{
 		sphereW.setRadius(x);
 		sphereW.setRadius(x);
-		spatialMarkForUpdate();
+		SpatialComponent::markForUpdate();
 	}
 	}
 
 
 	const Sphere& getSphere() const
 	const Sphere& getSphere() const
@@ -214,16 +218,15 @@ public:
 	}
 	}
 	/// @}
 	/// @}
 
 
-	/// @name Movable virtuals
+	/// @name MoveComponent virtuals
 	/// @{
 	/// @{
 
 
-	/// Overrides Movable::moveUpdate(). This does:
+	/// Overrides MoveComponent::moveUpdate(). This does:
 	/// - Update the collision shape
 	/// - Update the collision shape
 	void movableUpdate()
 	void movableUpdate()
 	{
 	{
-		Movable::movableUpdate();
 		sphereW.setCenter(getWorldTransform().getOrigin());
 		sphereW.setCenter(getWorldTransform().getOrigin());
-		spatialMarkForUpdate();
+		SpatialComponent::markForUpdate();
 	}
 	}
 	/// @}
 	/// @}
 
 
@@ -232,15 +235,12 @@ public:
 };
 };
 
 
 /// Spot light
 /// Spot light
-class SpotLight: public Light, public Frustumable
+class SpotLight: public Light, public FrustumComponent
 {
 {
 public:
 public:
-	ANKI_HAS_SLOTS(SpotLight)
-
 	/// @name Constructors/Destructor
 	/// @name Constructors/Destructor
 	/// @{
 	/// @{
-	SpotLight(const char* name, SceneGraph* scene, SceneNode* parent,
-		U32 movableFlags, const char* lensFlareFile = nullptr);
+	SpotLight(const char* name, SceneGraph* scene);
 	/// @}
 	/// @}
 
 
 	/// @name Accessors
 	/// @name Accessors
@@ -296,27 +296,26 @@ public:
 	}
 	}
 	/// @}
 	/// @}
 
 
-	/// @name Movable virtuals
+	/// @name MoveComponent virtuals
 	/// @{
 	/// @{
 
 
-	/// Overrides Movable::moveUpdate(). This does:
+	/// Overrides MoveComponent::moveUpdate(). This does:
 	/// - Update the collision shape
 	/// - Update the collision shape
-	void movableUpdate()
+	void moveUpdate()
 	{
 	{
-		Movable::movableUpdate();
 		frustum.setTransform(getWorldTransform());
 		frustum.setTransform(getWorldTransform());
 		viewMat = Mat4(getWorldTransform().getInverse());
 		viewMat = Mat4(getWorldTransform().getInverse());
 		viewProjectionMat = projectionMat * viewMat;
 		viewProjectionMat = projectionMat * viewMat;
 
 
-		spatialMarkForUpdate();
+		SpatialComponent::markForUpdate();
 	}
 	}
 	/// @}
 	/// @}
 
 
-	/// @name Frustumable virtuals
+	/// @name FrustumComponent virtuals
 	/// @{
 	/// @{
 
 
-	/// Override Frustumable::getFrustumableOrigin()
-	const Vec3& getFrustumableOrigin() const
+	/// Override FrustumComponent::getFrustumComponentOrigin()
+	const Vec3& getFrustumComponentOrigin() const
 	{
 	{
 		return getWorldTransform().getOrigin();
 		return getWorldTransform().getOrigin();
 	}
 	}
@@ -338,8 +337,8 @@ private:
 		projectionMat = frustum.calculateProjectionMatrix();
 		projectionMat = frustum.calculateProjectionMatrix();
 		viewProjectionMat = projectionMat * viewMat;
 		viewProjectionMat = projectionMat * viewMat;
 
 
-		spatialMarkForUpdate();
-		frustumableMarkUpdated();
+		SpatialComponent::markForUpdate();
+		FrustumComponent::markForUpdate();
 	}
 	}
 };
 };
 
 

+ 25 - 39
include/anki/scene/ModelNode.h

@@ -2,8 +2,8 @@
 #define ANKI_SCENE_MODEL_NODE_H
 #define ANKI_SCENE_MODEL_NODE_H
 
 
 #include "anki/scene/SceneNode.h"
 #include "anki/scene/SceneNode.h"
-#include "anki/scene/Renderable.h"
-#include "anki/scene/Movable.h"
+#include "anki/scene/RenderComponent.h"
+#include "anki/scene/MoveComponent.h"
 #include "anki/scene/SpatialComponent.h"
 #include "anki/scene/SpatialComponent.h"
 #include "anki/resource/Resource.h"
 #include "anki/resource/Resource.h"
 #include "anki/resource/Model.h"
 #include "anki/resource/Model.h"
@@ -15,7 +15,7 @@ namespace anki {
 /// @{
 /// @{
 
 
 /// A model instance
 /// A model instance
-class ModelPatchNodeInstance: public SceneNode, public Movable, 
+class ModelPatchNodeInstance: public SceneNode, public MoveComponent, 
 	public SpatialComponent
 	public SpatialComponent
 {
 {
 	friend class ModelPatchNode;
 	friend class ModelPatchNode;
@@ -23,27 +23,26 @@ class ModelPatchNodeInstance: public SceneNode, public Movable,
 
 
 public:
 public:
 	ModelPatchNodeInstance(
 	ModelPatchNodeInstance(
-		const char* name, SceneGraph* scene, SceneNode* parent, // Scene
-		U32 movableFlags, // Movable
+		const char* name, SceneGraph* scene, // SceneNode
 		const ModelPatchBase* modelPatchResource); // Self
 		const ModelPatchBase* modelPatchResource); // Self
 
 
-	/// @name Movable virtuals
+	/// @name MoveComponent virtuals
 	/// @{
 	/// @{
 
 
-	/// Overrides Movable::moveUpdate(). This does:
+	/// Overrides MoveComponent::moveUpdate(). This does:
 	/// - Update the collision shape
 	/// - Update the collision shape
 	/// - If it's the last instance update the parent's CS.
 	/// - If it's the last instance update the parent's CS.
-	void movableUpdate();
+	void moveUpdate();
 	/// @}
 	/// @}
 
 
 private:
 private:
 	Obb obb; ///< In world space
 	Obb obb; ///< In world space
-	const ModelPatchBase* modelPatch; ///< Keep the resource for tha OBB
+	const ModelPatchBase* modelPatch; ///< Keep the resource for the OBB
 };
 };
 
 
 /// A fragment of the ModelNode
 /// A fragment of the ModelNode
-class ModelPatchNode: public SceneNode, public Movable, public Renderable,
-	public SpatialComponent
+class ModelPatchNode: public SceneNode, public MoveComponent, 
+	public RenderComponent, public SpatialComponent
 {
 {
 	friend class ModelPatchNodeInstance;
 	friend class ModelPatchNodeInstance;
 	friend class ModelNode;
 	friend class ModelNode;
@@ -52,41 +51,40 @@ public:
 	/// @name Constructors/Destructor
 	/// @name Constructors/Destructor
 	/// @{
 	/// @{
 	ModelPatchNode(
 	ModelPatchNode(
-		const char* name, SceneGraph* scene, SceneNode* parent, // Scene
-		U32 movableFlags, // Movable
+		const char* name, SceneGraph* scene, // Scene
 		const ModelPatchBase* modelPatch, U instances); // Self
 		const ModelPatchBase* modelPatch, U instances); // Self
 
 
 	~ModelPatchNode();
 	~ModelPatchNode();
 	/// @}
 	/// @}
 
 
-	/// @name Movable virtuals
+	/// @name MoveComponent virtuals
 	/// @{
 	/// @{
 
 
-	/// Overrides Movable::moveUpdate(). This does:
+	/// Overrides MoveComponent::moveUpdate(). This does:
 	/// - Update the collision shape
 	/// - Update the collision shape
-	void movableUpdate();
+	void moveUpdate();
 	/// @}
 	/// @}
 
 
-	/// @name Renderable virtuals
+	/// @name RenderComponent virtuals
 	/// @{
 	/// @{
 
 
-	/// Implements Renderable::getModelPatchBase
-	const ModelPatchBase& getRenderableModelPatchBase()
+	/// Implements RenderComponent::getModelPatchBase
+	const ModelPatchBase& getModelPatchBase()
 	{
 	{
 		return *modelPatch;
 		return *modelPatch;
 	}
 	}
 
 
-	/// Implements  Renderable::getMaterial
-	const Material& getRenderableMaterial()
+	/// Implements  RenderComponent::getMaterial
+	const Material& getMaterial()
 	{
 	{
 		return modelPatch->getMaterial();
 		return modelPatch->getMaterial();
 	}
 	}
 
 
-	/// Overrides Renderable::getRenderableWorldTransforms
-	const Transform* getRenderableWorldTransforms();
+	/// Overrides RenderComponent::getRenderComponentWorldTransforms
+	const Transform* getRenderWorldTransforms();
 
 
-	/// Overrides Renderable::getRenderableInstancesCount
-	U32 getRenderableInstancesCount()
+	/// Overrides RenderComponent::getRenderComponentInstancesCount
+	U32 getRenderInstancesCount()
 	{
 	{
 		// return this and the instances 
 		// return this and the instances 
 		return (transforms.size() > 0) ? transforms.size() : 1;
 		return (transforms.size() > 0) ? transforms.size() : 1;
@@ -104,7 +102,7 @@ private:
 };
 };
 
 
 /// The model scene node
 /// The model scene node
-class ModelNode: public SceneNode, public Movable
+class ModelNode: public SceneNode, public MoveComponent
 {
 {
 public:
 public:
 	typedef SceneVector<ModelPatchNode*> ModelPatchNodes;
 	typedef SceneVector<ModelPatchNode*> ModelPatchNodes;
@@ -112,8 +110,7 @@ public:
 	/// @name Constructors/Destructor
 	/// @name Constructors/Destructor
 	/// @{
 	/// @{
 	ModelNode(
 	ModelNode(
-		const char* name, SceneGraph* scene, SceneNode* node, // SceneNode
-		U32 movableFlags, // Movable
+		const char* name, SceneGraph* scene, // SceneNode
 		const char* modelFname, U instances = 1); // Self
 		const char* modelFname, U instances = 1); // Self
 
 
 	virtual ~ModelNode();
 	virtual ~ModelNode();
@@ -127,17 +124,6 @@ public:
 	}
 	}
 	/// @}
 	/// @}
 
 
-	/// @name Movable virtuals
-	/// @{
-
-	/// Overrides Movable::moveUpdate(). This does:
-	/// - Update collision shape
-	void movableUpdate()
-	{
-		Movable::movableUpdate();
-	}
-	/// @}
-
 	/// Set the local transform of one instance
 	/// Set the local transform of one instance
 	void setInstanceLocalTransform(U instanceIndex, const Transform& trf);
 	void setInstanceLocalTransform(U instanceIndex, const Transform& trf);
 
 

+ 14 - 14
include/anki/scene/MoveComponent.h

@@ -50,22 +50,22 @@ public:
 	void setLocalTransform(const Transform& x)
 	void setLocalTransform(const Transform& x)
 	{
 	{
 		lTrf = x;
 		lTrf = x;
-		movableMarkForUpdate();
+		markForUpdate();
 	}
 	}
 	void setLocalOrigin(const Vec3& x)
 	void setLocalOrigin(const Vec3& x)
 	{
 	{
 		lTrf.setOrigin(x);
 		lTrf.setOrigin(x);
-		movableMarkForUpdate();
+		markForUpdate();
 	}
 	}
 	void setLocalRotation(const Mat3& x)
 	void setLocalRotation(const Mat3& x)
 	{
 	{
 		lTrf.setRotation(x);
 		lTrf.setRotation(x);
-		movableMarkForUpdate();
+		markForUpdate();
 	}
 	}
 	void setLocalScale(F32 x)
 	void setLocalScale(F32 x)
 	{
 	{
 		lTrf.setScale(x);
 		lTrf.setScale(x);
-		movableMarkForUpdate();
+		markForUpdate();
 	}
 	}
 
 
 	const Transform& getWorldTransform() const
 	const Transform& getWorldTransform() const
@@ -78,7 +78,7 @@ public:
 		return prevWTrf;
 		return prevWTrf;
 	}
 	}
 
 
-	Timestamp getMoveComponentTimestamp() const
+	Timestamp getTimestamp() const
 	{
 	{
 		return timestamp;
 		return timestamp;
 	}
 	}
@@ -89,40 +89,40 @@ public:
 	void rotateLocalX(F32 angDegrees)
 	void rotateLocalX(F32 angDegrees)
 	{
 	{
 		lTrf.getRotation().rotateXAxis(angDegrees);
 		lTrf.getRotation().rotateXAxis(angDegrees);
-		movableMarkForUpdate();
+		markForUpdate();
 	}
 	}
 	void rotateLocalY(F32 angDegrees)
 	void rotateLocalY(F32 angDegrees)
 	{
 	{
 		lTrf.getRotation().rotateYAxis(angDegrees);
 		lTrf.getRotation().rotateYAxis(angDegrees);
-		movableMarkForUpdate();
+		markForUpdate();
 	}
 	}
 	void rotateLocalZ(F32 angDegrees)
 	void rotateLocalZ(F32 angDegrees)
 	{
 	{
 		lTrf.getRotation().rotateZAxis(angDegrees);
 		lTrf.getRotation().rotateZAxis(angDegrees);
-		movableMarkForUpdate();
+		markForUpdate();
 	}
 	}
 	void moveLocalX(F32 distance)
 	void moveLocalX(F32 distance)
 	{
 	{
 		Vec3 x_axis = lTrf.getRotation().getColumn(0);
 		Vec3 x_axis = lTrf.getRotation().getColumn(0);
 		lTrf.getOrigin() += x_axis * distance;
 		lTrf.getOrigin() += x_axis * distance;
-		movableMarkForUpdate();
+		markForUpdate();
 	}
 	}
 	void moveLocalY(F32 distance)
 	void moveLocalY(F32 distance)
 	{
 	{
 		Vec3 y_axis = lTrf.getRotation().getColumn(1);
 		Vec3 y_axis = lTrf.getRotation().getColumn(1);
 		lTrf.getOrigin() += y_axis * distance;
 		lTrf.getOrigin() += y_axis * distance;
-		movableMarkForUpdate();
+		markForUpdate();
 	}
 	}
 	void moveLocalZ(F32 distance)
 	void moveLocalZ(F32 distance)
 	{
 	{
 		Vec3 z_axis = lTrf.getRotation().getColumn(2);
 		Vec3 z_axis = lTrf.getRotation().getColumn(2);
 		lTrf.getOrigin() += z_axis * distance;
 		lTrf.getOrigin() += z_axis * distance;
-		movableMarkForUpdate();
+		markForUpdate();
 	}
 	}
 	void scale(F32 s)
 	void scale(F32 s)
 	{
 	{
 		lTrf.getScale() *= s;
 		lTrf.getScale() *= s;
-		movableMarkForUpdate();
+		markForUpdate();
 	}
 	}
 	/// @}
 	/// @}
 
 
@@ -138,7 +138,7 @@ public:
 	///       parent
 	///       parent
 	void update();
 	void update();
 
 
-protected:
+private:
 	/// The transformation in local space
 	/// The transformation in local space
 	Transform lTrf = Transform::getIdentity();
 	Transform lTrf = Transform::getIdentity();
 
 
@@ -156,7 +156,7 @@ protected:
 	/// is true. Then it moves to the children.
 	/// is true. Then it moves to the children.
 	void updateWorldTransform();
 	void updateWorldTransform();
 
 
-	void movableMarkForUpdate()
+	void markForUpdate()
 	{
 	{
 		enableBits(MF_MARKED_FOR_UPDATE);
 		enableBits(MF_MARKED_FOR_UPDATE);
 	}
 	}

+ 6 - 6
include/anki/scene/RenderComponent.h

@@ -169,19 +169,19 @@ public:
 	virtual ~RenderComponent();
 	virtual ~RenderComponent();
 
 
 	/// Access to VAOs
 	/// Access to VAOs
-	virtual const ModelPatchBase& getRenderComponentModelPatchBase() = 0;
+	virtual const ModelPatchBase& getModelPatchBase() = 0;
 
 
 	/// Access the material
 	/// Access the material
-	virtual const Material& getRenderComponentMaterial() = 0;
+	virtual const Material& getMaterial() = 0;
 
 
 	/// Information for movables. It's actualy an array of transformations.
 	/// Information for movables. It's actualy an array of transformations.
-	virtual const Transform* getRenderComponentWorldTransforms()
+	virtual const Transform* getRenderWorldTransforms()
 	{
 	{
 		return nullptr;
 		return nullptr;
 	}
 	}
 
 
 	/// Number of instances. If greater than 1 then it's instanced
 	/// Number of instances. If greater than 1 then it's instanced
-	virtual U32 getRenderComponentInstancesCount()
+	virtual U32 getRenderInstancesCount()
 	{
 	{
 		return 1;
 		return 1;
 	}
 	}
@@ -200,7 +200,7 @@ public:
 
 
 	/// Iterate variables using a lambda
 	/// Iterate variables using a lambda
 	template<typename Func>
 	template<typename Func>
-	void iterateRenderComponentVariables(Func func)
+	void iterateVariables(Func func)
 	{
 	{
 		for(auto var : vars)
 		for(auto var : vars)
 		{
 		{
@@ -210,7 +210,7 @@ public:
 
 
 	U32 getSubMeshesCount()
 	U32 getSubMeshesCount()
 	{
 	{
-		return getRenderComponentModelPatchBase().getSubMeshesCount();
+		return getModelPatchBase().getSubMeshesCount();
 	}
 	}
 
 
 	/// Reset on frame start
 	/// Reset on frame start

+ 28 - 55
include/anki/scene/SceneNode.h

@@ -10,24 +10,19 @@ namespace anki {
 class SceneGraph; // Don't include
 class SceneGraph; // Don't include
 
 
 // Components forward. Don't include
 // Components forward. Don't include
-class Movable;
-class Renderable;
-class Frustumable;
+class MoveComponent;
+class RenderComponent;
+class FrustumComponent;
 class SpatialComponent;
 class SpatialComponent;
 class Light;
 class Light;
-class RigidBody;
-class Path;
 
 
 /// @addtogroup Scene
 /// @addtogroup Scene
 /// @{
 /// @{
 
 
 /// Interface class backbone of scene
 /// Interface class backbone of scene
-class SceneNode: public Object<SceneNode, SceneAllocator<SceneNode>>,
-	public PropertyMap
+class SceneNode
 {
 {
 public:
 public:
-	typedef Object<SceneNode, SceneAllocator<SceneNode>> Base;
-
 	/// @name Constructors/Destructor
 	/// @name Constructors/Destructor
 	/// @{
 	/// @{
 
 
@@ -35,11 +30,9 @@ public:
 	/// @param name The unique name of the node. If it's nullptr the the node
 	/// @param name The unique name of the node. If it's nullptr the the node
 	///             is not searchable
 	///             is not searchable
 	/// @param scene The scene that will register it
 	/// @param scene The scene that will register it
-	/// @param parent The parent of tha node. Used mainly in movable nodes
 	explicit SceneNode(
 	explicit SceneNode(
 		const char* name,
 		const char* name,
-		SceneGraph* scene,
-		SceneNode* parent = nullptr);
+		SceneGraph* scene);
 
 
 	/// Unregister node
 	/// Unregister node
 	virtual ~SceneNode();
 	virtual ~SceneNode();
@@ -67,67 +60,49 @@ public:
 
 
 	/// @name Accessors of components
 	/// @name Accessors of components
 	/// @{
 	/// @{
-	Movable* getMovable()
+	MoveComponent* getMoveComponent()
 	{
 	{
-		return sceneNodeProtected.movable;
+		return sceneNodeProtected.moveC;
 	}
 	}
-	const Movable* getMovable() const
+	const MoveComponent* getMoveComponent() const
 	{
 	{
-		return sceneNodeProtected.movable;
+		return sceneNodeProtected.moveC;
 	}
 	}
 
 
-	Renderable* getRenderable()
+	RenderComponent* getRenderComponent()
 	{
 	{
-		return sceneNodeProtected.renderable;
+		return sceneNodeProtected.renderC;
 	}
 	}
-	const Renderable* getRenderable() const
+	const RenderComponent* getRenderComponent() const
 	{
 	{
-		return sceneNodeProtected.renderable;
+		return sceneNodeProtected.renderC;
 	}
 	}
 
 
-	Frustumable* getFrustumable()
+	FrustumComponent* getFrustumComponent()
 	{
 	{
-		return sceneNodeProtected.frustumable;
+		return sceneNodeProtected.frustumC;
 	}
 	}
-	const Frustumable* getFrustumable() const
+	const FrustumComponent* getFrustumComponent() const
 	{
 	{
-		return sceneNodeProtected.frustumable;
+		return sceneNodeProtected.frustumC;
 	}
 	}
 
 
-	SpatialComponent* getSpatial()
+	SpatialComponent* getSpatialComponent()
 	{
 	{
-		return sceneNodeProtected.spatial;
+		return sceneNodeProtected.spatialC;
 	}
 	}
-	const SpatialComponent* getSpatial() const
+	const SpatialComponent* getSpatialComponent() const
 	{
 	{
-		return sceneNodeProtected.spatial;
+		return sceneNodeProtected.spatialC;
 	}
 	}
 
 
 	Light* getLight()
 	Light* getLight()
 	{
 	{
-		return sceneNodeProtected.light;
+		return sceneNodeProtected.lightC;
 	}
 	}
 	const Light* getLight() const 
 	const Light* getLight() const 
 	{
 	{
-		return sceneNodeProtected.light;
-	}
-
-	RigidBody* getRigidBody()
-	{
-		return sceneNodeProtected.rigidBody;
-	}
-	const RigidBody* getRigidBody() const
-	{
-		return sceneNodeProtected.rigidBody;
-	}
-
-	Path* getPath()
-	{
-		return sceneNodeProtected.path;
-	}
-	const Path* getPath() const
-	{
-		return sceneNodeProtected.path;
+		return sceneNodeProtected.lightC;
 	}
 	}
 	/// @}
 	/// @}
 
 
@@ -159,13 +134,11 @@ public:
 protected:
 protected:
 	struct
 	struct
 	{
 	{
-		Movable* movable = nullptr;
-		Renderable* renderable = nullptr;
-		Frustumable* frustumable = nullptr;
-		SpatialComponent* spatial = nullptr;
-		Light* light = nullptr;
-		RigidBody* rigidBody = nullptr;
-		Path* path = nullptr;
+		MoveComponent* moveC = nullptr;
+		RenderComponent* renderC = nullptr;
+		FrustumComponent* frustumC = nullptr;
+		SpatialComponent* spatialC = nullptr;
+		Light* lightC = nullptr;
 	} sceneNodeProtected;
 	} sceneNodeProtected;
 
 
 private:
 private:

+ 5 - 15
include/anki/scene/SpatialComponent.h

@@ -34,9 +34,7 @@ public:
 		/// with any surface then it shouldn't be visible and be processed 
 		/// with any surface then it shouldn't be visible and be processed 
 		/// further. This flag is being used to check if we should test agains
 		/// further. This flag is being used to check if we should test agains
 		/// near plane when using the tiler for visibility tests.
 		/// near plane when using the tiler for visibility tests.
-		SF_FULLY_TRANSPARENT = 1 << 3,
-
-		SF_MARKED_FOR_UPDATE = 1 << 4
+		SF_FULLY_TRANSPARENT = 1 << 3
 	};
 	};
 
 
 	/// Pass the collision shape here so we can avoid the virtuals
 	/// Pass the collision shape here so we can avoid the virtuals
@@ -62,7 +60,7 @@ public:
 	}
 	}
 
 
 	/// Get optimal collision shape for visibility tests
 	/// Get optimal collision shape for visibility tests
-	const CollisionShape& getOptimalCollisionShape() const
+	const CollisionShape& getVisibilityCollisionShape() const
 	{
 	{
 		if(spatialCs->getCollisionShapeType() == CollisionShape::CST_SPHERE)
 		if(spatialCs->getCollisionShapeType() == CollisionShape::CST_SPHERE)
 		{
 		{
@@ -74,7 +72,7 @@ public:
 		}
 		}
 	}
 	}
 
 
-	Timestamp getSpatialTimestamp() const
+	Timestamp getTimestamp() const
 	{
 	{
 		return timestamp;
 		return timestamp;
 	}
 	}
@@ -110,9 +108,7 @@ public:
 
 
 	/// The derived class has to manually call this method when the collision 
 	/// The derived class has to manually call this method when the collision 
 	/// shape got updated
 	/// shape got updated
-	void spatialMarkForUpdate();
-
-	void update();
+	void markForUpdate();
 
 
 	void resetFrame();
 	void resetFrame();
 
 
@@ -124,13 +120,7 @@ private:
 	Vec3 origin; ///< Cached value
 	Vec3 origin; ///< Cached value
 	Timestamp timestamp = getGlobTimestamp();
 	Timestamp timestamp = getGlobTimestamp();
 
 
-	void updateInternal()
-	{
-		spatialCs->toAabb(aabb);
-		origin = (aabb.getMax() + aabb.getMin()) * 0.5;
-		timestamp = getGlobTimestamp();
-		disableBits(SF_MARKED_FOR_UPDATE);
-	}
+	void updateInternal();
 };
 };
 /// @}
 /// @}
 
 

+ 7 - 7
include/anki/scene/Visibility.h

@@ -5,7 +5,7 @@
 #include "anki/collision/Forward.h"
 #include "anki/collision/Forward.h"
 #include "anki/scene/SceneNode.h"
 #include "anki/scene/SceneNode.h"
 #include "anki/scene/SpatialComponent.h"
 #include "anki/scene/SpatialComponent.h"
-#include "anki/scene/Renderable.h"
+#include "anki/scene/RenderComponent.h"
 #include "anki/core/ThreadPool.h"
 #include "anki/core/ThreadPool.h"
 
 
 namespace anki {
 namespace anki {
@@ -112,13 +112,13 @@ struct DistanceSortFunctor
 	{
 	{
 		ANKI_ASSERT(a.node && b.node);
 		ANKI_ASSERT(a.node && b.node);
 
 
-		ANKI_ASSERT(a.node->getSpatial() != nullptr 
-			&& b.node->getSpatial() != nullptr);
+		ANKI_ASSERT(a.node->getSpatialComponent() != nullptr 
+			&& b.node->getSpatialComponent() != nullptr);
 
 
 		F32 dist0 = origin.getDistanceSquared(
 		F32 dist0 = origin.getDistanceSquared(
-			a.node->getSpatial()->getSpatialOrigin());
+			a.node->getSpatialComponent()->getSpatialOrigin());
 		F32 dist1 = origin.getDistanceSquared(
 		F32 dist1 = origin.getDistanceSquared(
-			b.node->getSpatial()->getSpatialOrigin());
+			b.node->getSpatialComponent()->getSpatialOrigin());
 
 
 		return dist0 < dist1;
 		return dist0 < dist1;
 	}
 	}
@@ -134,8 +134,8 @@ struct MaterialSortFunctor
 		ANKI_ASSERT(a.node->getRenderable() != nullptr 
 		ANKI_ASSERT(a.node->getRenderable() != nullptr 
 			&& b.node->getRenderable() != nullptr);
 			&& b.node->getRenderable() != nullptr);
 
 
-		return a.node->getRenderable()->getRenderableMaterial()
-			< b.node->getRenderable()->getRenderableMaterial();
+		return a.node->getRenderComponent()->getRenderableMaterial()
+			< b.node->getRenderComponent()->getRenderableMaterial();
 	}
 	}
 };
 };
 
 

+ 6 - 3
include/anki/util/Allocator.h

@@ -94,14 +94,17 @@ public:
 	/// Allocate memory
 	/// Allocate memory
 	pointer allocate(size_type n, const void* = 0)
 	pointer allocate(size_type n, const void* = 0)
 	{
 	{
-		return static_cast<T*>(::operator new(n * sizeof(T)));
+		// operator new doesn't respect alignment (in GCC at least) so use 
+		// custom mem allocation function
+		PtrSize size = n * sizeof(T);
 		allocatedSize += n * sizeof(T);
 		allocatedSize += n * sizeof(T);
+		return (T*)mallocAligned(size, alignof(T));
 	}
 	}
 
 
 	/// Deallocate memory
 	/// Deallocate memory
 	void deallocate(void* p, size_type n)
 	void deallocate(void* p, size_type n)
 	{
 	{
-		::operator delete(p);
+		freeAligned(p);
 		allocatedSize -= n * sizeof(T);
 		allocatedSize -= n * sizeof(T);
 	}
 	}
 
 
@@ -242,7 +245,7 @@ inline bool operator!=(const Allocator<T1>&, const AnotherAllocator&)
 /// @note Don't ever EVER remove the double copy constructor and the double
 /// @note Don't ever EVER remove the double copy constructor and the double
 ///       operator=. The compiler will create defaults
 ///       operator=. The compiler will create defaults
 template<typename T, Bool deallocationFlag = false,
 template<typename T, Bool deallocationFlag = false,
-	U32 alignmentBytes = StackMemoryPool::SAFE_ALIGNMENT>
+	U32 alignmentBytes = ANKI_SAFE_ALIGNMENT>
 class StackAllocator
 class StackAllocator
 {
 {
 	template<typename U, Bool deallocationFlag_, U32 alignmentBytes_>
 	template<typename U, Bool deallocationFlag_, U32 alignmentBytes_>

+ 9 - 0
include/anki/util/Functions.h

@@ -40,6 +40,15 @@ Type getAlignedRoundUp(PtrSize alignment, Type value)
 	return (Type)v;
 	return (Type)v;
 }
 }
 
 
+/// Align number
+/// @param alignment The bytes of alignment
+/// @param value The value to align
+template<typename Type>
+void alignRoundUp(PtrSize alignment, Type& value)
+{
+	value = getAlignedRoundUp(alignment, value);
+}
+
 /// Check if a number is aligned
 /// Check if a number is aligned
 template<typename Type>
 template<typename Type>
 bool isAligned(PtrSize alignment, Type value)
 bool isAligned(PtrSize alignment, Type value)

+ 2 - 15
include/anki/util/Memory.h

@@ -4,9 +4,8 @@
 #include "anki/util/StdTypes.h"
 #include "anki/util/StdTypes.h"
 #include "anki/util/Assert.h"
 #include "anki/util/Assert.h"
 #include "anki/util/NonCopyable.h"
 #include "anki/util/NonCopyable.h"
-#include "anki/util/Functions.h"
 #include <atomic>
 #include <atomic>
-#include <algorithm>
+#include <algorithm> // For the std::move
 
 
 namespace anki {
 namespace anki {
 
 
@@ -23,20 +22,8 @@ class Allocator;
 class StackMemoryPool: public NonCopyable
 class StackMemoryPool: public NonCopyable
 {
 {
 public:
 public:
-
-	/// Safe alignment in bytes
-	static const U SAFE_ALIGNMENT = 
-#if ANKI_CPU_ARCH == ANKI_CPU_ARCH_INTEL
-		16
-#elif ANKI_CPU_ARCH == ANKI_CPU_ARCH_ARM
-		16
-#else
-#	error "See file"
-#endif
-		;
-
 	/// Default constructor
 	/// Default constructor
-	StackMemoryPool(PtrSize size, U32 alignmentBytes = SAFE_ALIGNMENT);
+	StackMemoryPool(PtrSize size, U32 alignmentBytes = ANKI_SAFE_ALIGNMENT);
 
 
 	/// Move
 	/// Move
 	StackMemoryPool(StackMemoryPool&& other)
 	StackMemoryPool(StackMemoryPool&& other)

+ 12 - 17
src/scene/Camera.cpp

@@ -8,19 +8,18 @@ namespace anki {
 
 
 //==============================================================================
 //==============================================================================
 Camera::Camera(
 Camera::Camera(
-	const char* name, SceneGraph* scene, SceneNode* parent, // SceneNode
-	U32 movableFlags, // Movable
+	const char* name, SceneGraph* scene, // SceneNode
 	Frustum* frustum, // Spatial & Frustumable
 	Frustum* frustum, // Spatial & Frustumable
 	CameraType type_) 
 	CameraType type_) 
-	:	SceneNode(name, scene, parent),
-		Movable(movableFlags, this),
-		SpatialComponent(frustum, getSceneAllocator()),
-		Frustumable(frustum),
+	:	SceneNode(name, scene),
+		MoveComponent(this),
+		SpatialComponent(this, frustum),
+		FrustumComponent(frustum),
 		type(type_)
 		type(type_)
 {
 {
-	sceneNodeProtected.movable = this;
-	sceneNodeProtected.spatial = this;
-	sceneNodeProtected.frustumable = this;
+	sceneNodeProtected.moveC = this;
+	sceneNodeProtected.spatialC = this;
+	sceneNodeProtected.frustumC = this;
 }
 }
 
 
 //==============================================================================
 //==============================================================================
@@ -45,10 +44,8 @@ void Camera::lookAtPoint(const Vec3& point)
 //==============================================================================
 //==============================================================================
 
 
 //==============================================================================
 //==============================================================================
-PerspectiveCamera::PerspectiveCamera(
-	const char* name, SceneGraph* scene, SceneNode* parent,
-	U32 movableFlags)
-	: Camera(name, scene, parent, movableFlags, &frustum, CT_PERSPECTIVE)
+PerspectiveCamera::PerspectiveCamera(const char* name, SceneGraph* scene)
+	: Camera(name, scene, &frustum, CT_PERSPECTIVE)
 {}
 {}
 
 
 //==============================================================================
 //==============================================================================
@@ -56,10 +53,8 @@ PerspectiveCamera::PerspectiveCamera(
 //==============================================================================
 //==============================================================================
 
 
 //==============================================================================
 //==============================================================================
-OrthographicCamera::OrthographicCamera(
-	const char* name, SceneGraph* scene, SceneNode* parent,
-	U32 movableFlags)
-	: Camera(name, scene, parent, movableFlags, &frustum, CT_ORTHOGRAPHIC)
+OrthographicCamera::OrthographicCamera(const char* name, SceneGraph* scene)
+	: Camera(name, scene, &frustum, CT_ORTHOGRAPHIC)
 {}
 {}
 
 
 } // end namespace
 } // end namespace

+ 15 - 37
src/scene/Light.cpp

@@ -8,30 +8,17 @@ namespace anki {
 
 
 //==============================================================================
 //==============================================================================
 Light::Light(
 Light::Light(
-	const char* name, SceneGraph* scene, SceneNode* parent, // Scene
-	U32 movableFlags, // Movable
+	const char* name, SceneGraph* scene, // SceneNode
 	CollisionShape* cs, // Spatial
 	CollisionShape* cs, // Spatial
-	LightType t, const char* lensFlareFile) // Self
-	:	SceneNode(name, scene, parent),
-		Movable(movableFlags, this),
-		SpatialComponent(cs, getSceneAllocator()),
+	LightType t) // Self
+	:	SceneNode(name, scene),
+		MoveComponent(this),
+		SpatialComponent(this, cs),
 		type(t)
 		type(t)
 {
 {
-	sceneNodeProtected.movable = this;
-	sceneNodeProtected.spatial = this;
-	sceneNodeProtected.light = this;
-
-	if(lensFlareFile)
-	{
-		flaresTex.load(lensFlareFile);
-	}
-
-	addNewProperty(new ReadWritePointerProperty<Vec4>("color", &color));
-
-	addNewProperty(
-		new ReadWritePointerProperty<Vec4>("specularColor", &specColor));
-
-	//addNewProperty(new ReadWritePointerProperty<bool>("shadow", &shadow));
+	sceneNodeProtected.moveC = this;
+	sceneNodeProtected.spatialC = this;
+	sceneNodeProtected.lightC = this;
 }
 }
 
 
 //==============================================================================
 //==============================================================================
@@ -43,29 +30,20 @@ Light::~Light()
 //==============================================================================
 //==============================================================================
 
 
 //==============================================================================
 //==============================================================================
-PointLight::PointLight(
-	const char* name, SceneGraph* scene, SceneNode* parent,
-	U32 movableFlags, const char* lensFlareFile)
-	:	Light(name, scene, parent, movableFlags, &sphereW, LT_POINT,
-			lensFlareFile)
-{
-	F32& r = sphereW.getRadius();
-	addNewProperty(new ReadWritePointerProperty<F32>("radius", &r));
-}
+PointLight::PointLight(const char* name, SceneGraph* scene)
+	:	Light(name, scene, &sphereW, LT_POINT)
+{}
 
 
 //==============================================================================
 //==============================================================================
 // SpotLight                                                                   =
 // SpotLight                                                                   =
 //==============================================================================
 //==============================================================================
 
 
 //==============================================================================
 //==============================================================================
-SpotLight::SpotLight(
-	const char* name, SceneGraph* scene, SceneNode* parent,
-	U32 movableFlags, const char* lensFlareFile)
-	: 	Light(name, scene, parent, movableFlags, &frustum, LT_SPOT, 
-			lensFlareFile),
-		Frustumable(&frustum)
+SpotLight::SpotLight(const char* name, SceneGraph* scene)
+	:	Light(name, scene, &frustum, LT_SPOT),
+		FrustumComponent(&frustum)
 {
 {
-	sceneNodeProtected.frustumable = this;
+	sceneNodeProtected.frustumC = this;
 
 
 	const F32 ang = toRad(45.0);
 	const F32 ang = toRad(45.0);
 	setOuterAngle(ang / 2.0);
 	setOuterAngle(ang / 2.0);

+ 28 - 35
src/scene/ModelNode.cpp

@@ -11,25 +11,24 @@ namespace anki {
 
 
 //==============================================================================
 //==============================================================================
 ModelPatchNodeInstance::ModelPatchNodeInstance(
 ModelPatchNodeInstance::ModelPatchNodeInstance(
-	const char* name, SceneGraph* scene, SceneNode* parent, // Scene
-	U32 movableFlags, // Movable
+	const char* name, SceneGraph* scene, // Scene
 	const ModelPatchBase* modelPatchResource) // Self
 	const ModelPatchBase* modelPatchResource) // Self
-	:	SceneNode(name, scene, parent),
-		Movable(movableFlags, this),
-		SpatialComponent(&obb, getSceneAllocator()),
+	:	SceneNode(name, scene),
+		MoveComponent(this),
+		SpatialComponent(this, &obb),
 		modelPatch(modelPatchResource)
 		modelPatch(modelPatchResource)
 {
 {
-	sceneNodeProtected.movable = this;
+	sceneNodeProtected.moveC = this;
 
 
 	// Dont mark it as spatial because it's sub-spatial and don't want to 
 	// Dont mark it as spatial because it's sub-spatial and don't want to 
 	// be updated by the scene
 	// be updated by the scene
-	sceneNodeProtected.spatial = nullptr;
+	sceneNodeProtected.spatialC = nullptr;
 
 
 	ANKI_ASSERT(modelPatch);
 	ANKI_ASSERT(modelPatch);
 }
 }
 
 
 //==============================================================================
 //==============================================================================
-void ModelPatchNodeInstance::movableUpdate()
+void ModelPatchNodeInstance::moveUpdate()
 {
 {
 	ANKI_ASSERT(modelPatch);
 	ANKI_ASSERT(modelPatch);
 
 
@@ -39,14 +38,14 @@ void ModelPatchNodeInstance::movableUpdate()
 	spatialMarkForUpdate();
 	spatialMarkForUpdate();
 
 
 	// If this instance is the last update the parent's collision shape
 	// If this instance is the last update the parent's collision shape
-	SceneNode* parentNode = SceneNode::getParent();
-	ANKI_ASSERT(parentNode);
+	MoveComponent* parentM = MoveComponent::getParent();
+	ANKI_ASSERT(parentM);
 
 
 	ModelPatchNode* modelPatchNode = 
 	ModelPatchNode* modelPatchNode = 
 #if ANKI_DEBUG
 #if ANKI_DEBUG
-		dynamic_cast<ModelPatchNode*>(parentNode);
+		dynamic_cast<ModelPatchNode*>(parentM);
 #else
 #else
-		static_cast<ModelPatchNode*>(parentNode);
+		static_cast<ModelPatchNode*>(parentM);
 #endif
 #endif
 	ANKI_ASSERT(modelPatchNode);
 	ANKI_ASSERT(modelPatchNode);
 
 
@@ -63,22 +62,21 @@ void ModelPatchNodeInstance::movableUpdate()
 
 
 //==============================================================================
 //==============================================================================
 ModelPatchNode::ModelPatchNode(
 ModelPatchNode::ModelPatchNode(
-	const char* name, SceneGraph* scene, SceneNode* parent,
-	U32 movableFlags,
+	const char* name, SceneGraph* scene,
 	const ModelPatchBase* modelPatch_, U instancesCount)
 	const ModelPatchBase* modelPatch_, U instancesCount)
-	:	SceneNode(name, scene, parent),
-		Movable(movableFlags, this),
-		Renderable(getSceneAllocator()),
-		SpatialComponent(&obb, getSceneAllocator()), 
+	:	SceneNode(name, scene),
+		MoveComponent(this, MoveComponent::MF_IGNORE_LOCAL_TRANSFORM),
+		RenderComponent(this),
+		SpatialComponent(this, &obb), 
 		modelPatch(modelPatch_),
 		modelPatch(modelPatch_),
 		instances(getSceneAllocator()),
 		instances(getSceneAllocator()),
 		transforms(getSceneAllocator())
 		transforms(getSceneAllocator())
 {
 {
-	sceneNodeProtected.movable = this;
-	sceneNodeProtected.renderable = this;
-	sceneNodeProtected.spatial = this;
+	sceneNodeProtected.moveC = this;
+	sceneNodeProtected.renderC = this;
+	sceneNodeProtected.spatialC = this;
 
 
-	Renderable::init(*this);
+	RenderComponent::init(*this);
 
 
 	// Create the instances as ModelPatchNodeInstance
 	// Create the instances as ModelPatchNodeInstance
 	if(instancesCount > 1)
 	if(instancesCount > 1)
@@ -91,8 +89,7 @@ ModelPatchNode::ModelPatchNode(
 		for(U i = 0; i < instancesCount; i++)
 		for(U i = 0; i < instancesCount; i++)
 		{
 		{
 			ModelPatchNodeInstance* instance;
 			ModelPatchNodeInstance* instance;
-			getSceneGraph().newSceneNode(instance, nullptr, this, 
-				Movable::MF_IGNORE_PARENT, modelPatch);
+			getSceneGraph().newSceneNode(instance, nullptr, modelPatch);
 
 
 			instance->setLocalOrigin(pos);
 			instance->setLocalOrigin(pos);
 			pos.x() += 2.0;
 			pos.x() += 2.0;
@@ -113,7 +110,7 @@ ModelPatchNode::~ModelPatchNode()
 }
 }
 
 
 //==============================================================================
 //==============================================================================
-const Transform* ModelPatchNode::getRenderableWorldTransforms()
+const Transform* ModelPatchNode::getRenderWorldTransforms()
 {
 {
 	if(transforms.size() == 0)
 	if(transforms.size() == 0)
 	{
 	{
@@ -137,10 +134,8 @@ const Transform* ModelPatchNode::getRenderableWorldTransforms()
 }
 }
 
 
 //==============================================================================
 //==============================================================================
-void ModelPatchNode::movableUpdate()
+void ModelPatchNode::moveUpdate()
 {
 {
-	Movable::movableUpdate();
-
 	if(instances.size() == 0)
 	if(instances.size() == 0)
 	{
 	{
 		// NO instancing
 		// NO instancing
@@ -183,14 +178,13 @@ void ModelPatchNode::updateSpatialCs()
 
 
 //==============================================================================
 //==============================================================================
 ModelNode::ModelNode(
 ModelNode::ModelNode(
-	const char* name, SceneGraph* scene, SceneNode* parent,
-	U32 movableFlags,
+	const char* name, SceneGraph* scene,
 	const char* modelFname, U instances)
 	const char* modelFname, U instances)
-	: 	SceneNode(name, scene, parent),
-		Movable(movableFlags, this),
+	: 	SceneNode(name, scene),
+		MoveComponent(this),
 		patches(getSceneAllocator())
 		patches(getSceneAllocator())
 {
 {
-	sceneNodeProtected.movable = this;
+	sceneNodeProtected.moveC = this;
 
 
 	model.load(modelFname);
 	model.load(modelFname);
 
 
@@ -200,8 +194,7 @@ ModelNode::ModelNode(
 	for(const ModelPatchBase* patch : model->getModelPatches())
 	for(const ModelPatchBase* patch : model->getModelPatches())
 	{
 	{
 		ModelPatchNode* mpn;
 		ModelPatchNode* mpn;
-		getSceneGraph().newSceneNode(mpn, nullptr, this,
-			Movable::MF_IGNORE_LOCAL_TRANSFORM, patch, instances);
+		getSceneGraph().newSceneNode(mpn, nullptr, this, patch, instances);
 
 
 		patches.push_back(mpn);
 		patches.push_back(mpn);
 		++i;
 		++i;

+ 7 - 6
src/scene/MoveComponent.cpp

@@ -8,7 +8,7 @@ MoveComponent::MoveComponent(SceneNode* node, U32 flags)
 	:	Base(nullptr, node->getSceneAllocator()),
 	:	Base(nullptr, node->getSceneAllocator()),
 		Bitset<U8>(flags)
 		Bitset<U8>(flags)
 {
 {
-	movableMarkForUpdate();
+	markForUpdate();
 }
 }
 
 
 //==============================================================================
 //==============================================================================
@@ -19,10 +19,11 @@ MoveComponent::~MoveComponent()
 void MoveComponent::update()
 void MoveComponent::update()
 {
 {
 	// Call this only on roots
 	// Call this only on roots
-	ANKI_ASSERT(getParent() == nullptr);
-
-	// If root begin updating
-	updateWorldTransform();
+	if(getParent() == nullptr)
+	{
+		// If root begin updating
+		updateWorldTransform();
+	}
 }
 }
 
 
 //==============================================================================
 //==============================================================================
@@ -62,7 +63,7 @@ void MoveComponent::updateWorldTransform()
 		// If parent is dirty then make children dirty as well
 		// If parent is dirty then make children dirty as well
 		if(dirty)
 		if(dirty)
 		{
 		{
-			mov.movableMarkForUpdate();
+			mov.markForUpdate();
 		}
 		}
 
 
 		mov.updateWorldTransform();
 		mov.updateWorldTransform();

+ 3 - 3
src/scene/RenderComponent.cpp

@@ -100,7 +100,7 @@ RenderComponent::~RenderComponent()
 //==============================================================================
 //==============================================================================
 void RenderComponent::init()
 void RenderComponent::init()
 {
 {
-	const Material& mtl = getRenderComponentMaterial();
+	const Material& mtl = getMaterial();
 
 
 	// Create the material variables using a visitor
 	// Create the material variables using a visitor
 	CreateNewRenderComponentVariableVisitor vis;
 	CreateNewRenderComponentVariableVisitor vis;
@@ -115,8 +115,8 @@ void RenderComponent::init()
 	}
 	}
 
 
 	// Instancing sanity checks
 	// Instancing sanity checks
-	U32 instancesCount = getRenderComponentInstancesCount();
-	iterateRenderComponentVariables([&](RenderComponentVariable& var)
+	U32 instancesCount = getRenderInstancesCount();
+	iterateVariables([&](RenderComponentVariable& var)
 	{
 	{
 		if(var.getArraySize() < instancesCount)
 		if(var.getArraySize() < instancesCount)
 		{
 		{

+ 13 - 17
src/scene/SceneNode.cpp

@@ -1,15 +1,14 @@
 #include "anki/scene/SceneNode.h"
 #include "anki/scene/SceneNode.h"
 #include "anki/scene/SceneGraph.h"
 #include "anki/scene/SceneGraph.h"
-#include "anki/scene/Movable.h"
+#include "anki/scene/MoveComponent.h"
 #include "anki/scene/SpatialComponent.h"
 #include "anki/scene/SpatialComponent.h"
-#include "anki/scene/Frustumable.h"
+#include "anki/scene/FrustumComponent.h"
 
 
 namespace anki {
 namespace anki {
 
 
 //==============================================================================
 //==============================================================================
-SceneNode::SceneNode(const char* name_, SceneGraph* scene_, SceneNode* parent)
-	:	Base(parent, scene_->getAllocator()),
-		scene(scene_),
+SceneNode::SceneNode(const char* name_, SceneGraph* scene_)
+	:	scene(scene_),
 		name(getSceneAllocator()),
 		name(getSceneAllocator()),
 		markedForDeletion(false)
 		markedForDeletion(false)
 {
 {
@@ -19,9 +18,6 @@ SceneNode::SceneNode(const char* name_, SceneGraph* scene_, SceneNode* parent)
 	{
 	{
 		name = SceneString(name_, scene->getAllocator());
 		name = SceneString(name_, scene->getAllocator());
 	}
 	}
-	
-	/// Add the first property
-	//addNewProperty(new ReadPointerProperty<std::string>("name", &name));
 }
 }
 
 
 //==============================================================================
 //==============================================================================
@@ -47,22 +43,22 @@ U32 SceneNode::getLastUpdateFrame() const
 {
 {
 	U32 max = 0;
 	U32 max = 0;
 
 
-	const Movable* m = getMovable();
-	if(m && m->getMovableTimestamp() > max)
+	const MoveComponent* m = getMoveComponent();
+	if(m && m->getTimestamp() > max)
 	{
 	{
-		max = m->getMovableTimestamp();
+		max = m->getTimestamp();
 	}
 	}
 
 
-	const Frustumable* fr = getFrustumable();
-	if(fr && fr->getFrustumableTimestamp() > max)
+	const FrustumComponent* fr = getFrustumComponent();
+	if(fr && fr->getTimestamp() > max)
 	{
 	{
-		max = fr->getFrustumableTimestamp();
+		max = fr->getTimestamp();
 	}
 	}
 
 
-	const SpatialComponent* s = getSpatial();
-	if(s && s->getSpatialTimestamp() > max)
+	const SpatialComponent* s = getSpatialComponent();
+	if(s && s->getTimestamp() > max)
 	{
 	{
-		max = s->getSpatialTimestamp();
+		max = s->getTimestamp();
 	}
 	}
 
 
 	return max;
 	return max;

+ 15 - 19
src/scene/SpatialComponent.cpp

@@ -7,9 +7,11 @@ namespace anki {
 SpatialComponent::SpatialComponent(SceneNode* node, const CollisionShape* cs,
 SpatialComponent::SpatialComponent(SceneNode* node, const CollisionShape* cs,
 	U32 flags)
 	U32 flags)
 	:	Base(nullptr, node->getSceneAllocator()), 
 	:	Base(nullptr, node->getSceneAllocator()), 
-		Bitset<U8>(flags | SF_MARKED_FOR_UPDATE),
+		Bitset<U8>(flags),
 		spatialCs(cs)
 		spatialCs(cs)
 {
 {
+	ANKI_ASSERT(spatialCs);
+	markForUpdate();
 }
 }
 
 
 //==============================================================================
 //==============================================================================
@@ -17,39 +19,33 @@ SpatialComponent::~SpatialComponent()
 {}
 {}
 
 
 //==============================================================================
 //==============================================================================
-void SpatialComponent::spatialMarkForUpdate()
+void SpatialComponent::markForUpdate()
 {
 {
-	// Call this only on roots
-	ANKI_ASSERT(getParent() == nullptr);
-
 	visitThisAndChildren([](SpatialComponent& sp)
 	visitThisAndChildren([](SpatialComponent& sp)
 	{
 	{
-		sp.enableBits(SF_MARKED_FOR_UPDATE);
+		sp.updateInternal();
 	});
 	});
 }
 }
 
 
 //==============================================================================
 //==============================================================================
-void SpatialComponent::update()
+void SpatialComponent::updateInternal()
 {
 {
-	// Call this only on roots
-	ANKI_ASSERT(getParent() == nullptr);
-
-	visitThisAndChildren([](SpatialComponent& sp)
-	{
-		sp.updateInternal();
-	});
+	spatialCs->toAabb(aabb);
+	origin = (aabb.getMax() + aabb.getMin()) * 0.5;
+	timestamp = getGlobTimestamp();
 }
 }
 
 
 //==============================================================================
 //==============================================================================
 void SpatialComponent::resetFrame()
 void SpatialComponent::resetFrame()
 {
 {
 	// Call this only on roots
 	// Call this only on roots
-	ANKI_ASSERT(getParent() == nullptr);
-
-	visitThisAndChildren([](SpatialComponent& sp)
+	if(getParent() == nullptr)
 	{
 	{
-		sp.disableBits(SF_VISIBLE_ANY);
-	});
+		visitThisAndChildren([](SpatialComponent& sp)
+		{
+			sp.disableBits(SF_VISIBLE_ANY);
+		});
+	}
 }
 }
 
 
 } // end namespace anki
 } // end namespace anki

+ 10 - 2
src/util/Memory.cpp

@@ -1,6 +1,7 @@
 #include "anki/util/Memory.h"
 #include "anki/util/Memory.h"
 #include "anki/util/Assert.h"
 #include "anki/util/Assert.h"
 #include "anki/util/Exception.h"
 #include "anki/util/Exception.h"
+#include "anki/util/Functions.h"
 #include <limits>
 #include <limits>
 #include <cstdlib>
 #include <cstdlib>
 #include <cstring>
 #include <cstring>
@@ -93,6 +94,9 @@ void* StackMemoryPool::allocate(PtrSize size_) throw()
 
 
 		// Set the correct output
 		// Set the correct output
 		out += headerSize;
 		out += headerSize;
+
+		// Check alignment
+		ANKI_ASSERT(isAligned(alignmentBytes, out));
 	}
 	}
 	else
 	else
 	{
 	{
@@ -106,8 +110,12 @@ void* StackMemoryPool::allocate(PtrSize size_) throw()
 //==============================================================================
 //==============================================================================
 Bool StackMemoryPool::free(void* ptr) throw()
 Bool StackMemoryPool::free(void* ptr) throw()
 {
 {
+	// ptr shouldn't be null or not aligned. If not aligned it was not 
+	// allocated by this class
+	ANKI_ASSERT(ptr != nullptr && isAligned(alignmentBytes, ptr));
+
 	// memory is nullptr if moved
 	// memory is nullptr if moved
-	ANKI_ASSERT(memory != nullptr && ptr != nullptr);
+	ANKI_ASSERT(memory != nullptr);
 
 
 	// Correct the p
 	// Correct the p
 	PtrSize headerSize = 
 	PtrSize headerSize = 
@@ -147,7 +155,7 @@ void StackMemoryPool::reset()
 	memset(memory, 0xCC, memsize);
 	memset(memory, 0xCC, memsize);
 #endif
 #endif
 
 
-	top = getAlignedRoundUp(alignmentBytes, memory);
+	top = memory;
 }
 }
 
 
 //==============================================================================
 //==============================================================================