//------------------------------------------------------------------------------
// Lamp : Open source game middleware
// Copyright (C) 2004  Junpei Ohtani ( Email : junpee@users.sourceforge.jp )
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//------------------------------------------------------------------------------

/** @file
 * コリジョンオブジェクト実装
 * @author Junpee
 */

#include "LampBasic.h"
#include "Collision/System/CollisionObject.h"
#include "Collision/System/CollisionNode.h"
#include "Collision/System/CollisionLeaf.h"

namespace Lamp{

//------------------------------------------------------------------------------
// 再帰的破棄
int CollisionObject::recursiveDestroy(CollisionObject* collisionObject){
	Assert(collisionObject != NULL);
	int result = 0;
	if(collisionObject->isCollisionNode()){
		result += CollisionNode::recursiveDestroy(
			collisionObject->castCollisionNode());
	}else if(collisionObject->isCollisionLeaf()){
		result += CollisionLeaf::destroy(collisionObject->castCollisionLeaf());
	}else{
		ErrorOut("CollisionObject::recursiveDestroy Unknown type");
	}
	return result;
}
//------------------------------------------------------------------------------
// 走査
void CollisionObject::traverse(){
	if(parent_ == NULL){
		traverseImplement(Matrix34::unit, true, false, false);
	}else{
		traverseImplement(parent_->getWorldMatrix(), parent_->isGlobalEnabled(),
			parent_->isGlobalScaled(), parent_->isGlobalChanged());
	}
}
//------------------------------------------------------------------------------
} // End of namespace Lamp
//------------------------------------------------------------------------------
