// Author : Chris Tolley
// Date   : 7/13/2004
// LeafQuadNode.h contains the class declaration for a leaf node class 
// to use in a quad tree.

#if !defined(AFX_LEAFQUADNODE_H__3F7C093A_2A62_4E0D_A892_A66D4367735F__INCLUDED_)
#define AFX_LEAFQUADNODE_H__3F7C093A_2A62_4E0D_A892_A66D4367735F__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <vector>
using namespace std;

#include "SmartPointer.h"
#include "QuadNode.h"

// The edge length of a leaf node
const unsigned short LEAF_EDGE_LENGTH = 4;

// Forward class declarations
class Object;

class LeafQuadNode : public QuadNode  
{
public:
	// Constructor
	LeafQuadNode( unsigned short midX, unsigned short midZ, float radius )
		: QuadNode( midX, midZ, radius ) {};

	// Destructor
	virtual ~LeafQuadNode();

	// Adds an object to the vector
	inline void AddObject( SmartPointer& sp )
	{ m_vObjects.push_back( sp ); };

	// Removes an object from the vector
	void Remove( SmartPointer& sp );

	// Stores all object contained on this leaf node that are in the sphere
	// formed by x,z and radius in objects
	void GetAllInSphere( float x, float z, float radius, 
						 vector< SmartPointer >& objects );

	// Removes all SmartPointers stored in this leaf
	void RemoveAll();
private:
	// Holds the objects
	vector< SmartPointer > m_vObjects;
};

#endif // !defined(AFX_LEAFQUADNODE_H__3F7C093A_2A62_4E0D_A892_A66D4367735F__INCLUDED_)
