Commits

Christian Fischer committed 83941f2

added Node::setVisible & Node::isVisible

Comments (0)

Files changed (2)

src/core/wiesel/graph/node.cpp

 	local_transform(matrix4x4::identity),
 	world_transform(matrix4x4::identity),
 	transform_dirty(true),
+	visible(true),
 	parent(NULL)
 {
 	return;
 }
 
 
+void Node::setVisisble(bool visible) {
+	this->visible = visible;
+}
+
+
 void Node::setTransformDirty() {
 	transform_dirty = true;
 
 void Node::render(video::RenderContext *render_context) {
 	bool this_drawn = false;
 
+	// skip rendering when the node is not visible
+	// NOTE: it would be still possible to call onDraw directly
+	if (visible == false) {
+		return;
+	}
+
 	for(NodeList::iterator it=children.begin(); it!=children.end(); it++) {
 		Node *child = *it;
 

src/core/wiesel/graph/node.h

 		 */
 		void sortChildren();
 
+	// getter / setter
+	public:
+		/**
+		 * @brief Set the visibility of this node and all of it's children.
+		 */
+		void setVisisble(bool visible);
+
+		/**
+		 * @brief Tells whether this node is visible or not.
+		 */
+		inline bool isVisible() const {
+			return visible;
+		}
+
 	// matrix access and manipulation
 	public:
 		/**
 		bool		transform_dirty;	//!< When true, the world transformation matrix has to be updated.
 
 	private:
+		bool		visible;
+
 		/// the parent node of this one.
 		Node*		parent;