2
0
Panagiotis Christopoulos Charitos 14 жил өмнө
parent
commit
247ac69c16

+ 4 - 0
anki/scene/Movable.h

@@ -94,6 +94,10 @@ public:
 	{
 		return flags & flag;
 	}
+	uint getFlagsBitmask() const
+	{
+		return flags;
+	}
 	/// @}
 
 	/// @name Mess with the local transform

+ 32 - 0
anki/scene/Renderable.h

@@ -52,10 +52,21 @@ private:
 class Renderable
 {
 public:
+	/// Renderable flags
+	enum RenderableFlag
+	{
+		RF_NONE = 0,
+		RF_VISIBLE = 1 ///< Visible or not. The visibility tester sets it
+	};
+
 	typedef std::vector<PropertyBase*> Properties;
 	typedef boost::iterator_range<Properties::iterator> MutableRange;
 	typedef boost::iterator_range<Properties::const_iterator> ConstRange;
 
+	Renderable()
+		: flags(RF_NONE)
+	{}
+
 	/// Access to VAOs
 	virtual const ModelPatchBase& getModelPatchBase() const = 0;
 
@@ -72,11 +83,32 @@ public:
 		return ConstRange(props.begin(), props.end());
 	}
 
+	/// @name Flag manipulation
+	/// @{
+	void enableFlag(RenderableFlag flag, bool enable = true)
+	{
+		flags = enable ? flags | flag : flags & ~flag;
+	}
+	void disableFlag(RenderableFlag flag)
+	{
+		enableFlag(flag, false);
+	}
+	bool isFlagEnabled(RenderableFlag flag) const
+	{
+		return flags & flag;
+	}
+	uint getFlagsBitmask() const
+	{
+		return flags;
+	}
+	/// @}
+
 protected:
 	void init(PropertyMap& pmap);
 
 private:
 	Properties props;
+	uint flags; ///< Bitmask
 };
 /// @}
 

+ 9 - 17
anki/scene/Scene.h

@@ -10,6 +10,8 @@ namespace anki {
 
 
 /// The Scene contains all the dynamic entities
+///
+/// XXX Add physics
 class Scene
 {
 public:
@@ -23,8 +25,11 @@ public:
 		typedef boost::iterator_range<ConstIterator> ConstRange;
 	};
 
+	/// @name Constructors/Destructor
+	/// @{
 	Scene();
 	~Scene();
+	/// @}
 
 	/// Put a node in the appropriate containers
 	void registerNode(SceneNode* node);
@@ -52,20 +57,6 @@ public:
 		ambientCol = x;
 	}
 
-	/*PhysWorld& getPhysWorld()
-	{
-		return *physPhysWorld;
-	}
-	const PhysWorld& getPhysWorld() const
-	{
-		return *physPhysWorld;
-	}
-
-	const VisibilityTester& getVisibilityTester() const
-	{
-		return *visibilityTester;
-	}*/
-
 	Types<SceneNode>::ConstRange getAllNodes() const
 	{
 		return Types<SceneNode>::ConstRange(nodes.begin(), nodes.end());
@@ -80,12 +71,13 @@ private:
 	/// @name Containers of scene's data
 	/// @{
 	Types<SceneNode>::Container nodes;
+	Types<Movable>::Container movables;
+	Types<Renderable>::Container renderables;
+	Types<Spatial>::Container spatials;
+	Types<Frustumable>::Container frustumables;
 	/// @}
 
 	Vec3 ambientCol; ///< The global ambient color
-	/// Connection with Bullet wrapper
-	/*boost::scoped_ptr<PhysWorld> physPhysWorld;
-	boost::scoped_ptr<VisibilityTester> visibilityTester;*/
 };
 
 

+ 12 - 6
anki/scene/SkinNode.cpp

@@ -37,32 +37,37 @@ const Vbo* SkinMesh::getVbo(VboId id) const
 SkinMesh::SkinMesh(const MeshBase* mesh_)
 	: mesh(mesh_)
 {
+	const Vbo* vbo;
+
 	// Positions
-	if(mesh->getVbo(VBO_POSITIONS))
+	vbo = mesh->getVbo(VBO_POSITIONS);
+	if(vbo)
 	{
 		tfVbos[VBO_TF_POSITIONS].create(
 			GL_ARRAY_BUFFER,
-			mesh->getVbo(VBO_POSITIONS)->getSizeInBytes(),
+			vbo->getSizeInBytes(),
 			NULL,
 			GL_STATIC_DRAW);
 	}
 
 	// Normals
-	if(mesh->getVbo(VBO_NORMALS))
+	vbo = mesh->getVbo(VBO_NORMALS);
+	if(vbo)
 	{
 		tfVbos[VBO_TF_NORMALS].create(
 			GL_ARRAY_BUFFER,
-			mesh->getVbo(VBO_NORMALS)->getSizeInBytes(),
+			vbo->getSizeInBytes(),
 			NULL,
 			GL_STATIC_DRAW);
 	}
 
 	// Tangents
-	if(mesh->getVbo(VBO_TANGENTS))
+	vbo = mesh->getVbo(VBO_TANGENTS);
+	if(vbo)
 	{
 		tfVbos[VBO_TF_TANGENTS].create(
 			GL_ARRAY_BUFFER,
-			mesh->getVbo(VBO_TANGENTS)->getSizeInBytes(),
+			vbo->getSizeInBytes(),
 			NULL,
 			GL_STATIC_DRAW);
 	}
@@ -207,6 +212,7 @@ SkinNode::SkinNode(const char* skinFname,
 SkinNode::~SkinNode()
 {}
 
+
 //==============================================================================
 void SkinNode::movableUpdate()
 {

+ 13 - 10
anki/scene/SkinNode.h

@@ -18,7 +18,9 @@ namespace anki {
 class Skin;
 
 
-/// XXX
+/// Skin specific mesh
+///
+/// It contains a number of VBOs for transform feedback
 class SkinMesh: public MeshBase
 {
 public:
@@ -78,7 +80,10 @@ private:
 };
 
 
-/// XXX
+/// Skin specific ModelPatch
+///
+/// It uses a SkinMesh to create the VAOs. It also creates a VAO for the
+/// transform feedback pass
 class SkinModelPatch: public ModelPatchBase
 {
 public:
@@ -109,6 +114,11 @@ public:
 	{
 		return *skinMesh;
 	}
+
+	const Vao& getTransformFeedbackVao() const
+	{
+		return tfVao;
+	}
 	/// @}
 
 	/// @name Implementations of ModelPatchBase virtuals
@@ -127,7 +137,7 @@ public:
 private:
 	boost::scoped_ptr<SkinMesh> skinMesh;
 	const ModelPatch* mpatch;
-	Vao tfVao;
+	Vao tfVao; ///< Used as a source VAO in TFB
 };
 
 
@@ -184,7 +194,6 @@ public:
 
 private:
 	boost::scoped_ptr<SkinModelPatch> skinModelPatch;
-	Vao tfVao;
 };
 
 
@@ -289,12 +298,6 @@ public:
 		return PatchesMutableRange(patches.begin(), patches.end());
 	}
 
-	const CollisionShape*
-		getVisibilityCollisionShapeWorldSpace() const
-	{
-		return &visibilityShapeWSpace;
-	}
-
 	const Skin& getSkin() const
 	{
 		return *skin;