void BucketKDTreeNode<D, ELEM_TYPE>::splitAndInsert( const typename BucketKDTreeNode<D, ELEM_TYPE>::PointType& p) { m_cuttingDimension = CuttingDimensionStrategies<D, ELEM_TYPE> ::dimensionWithHighestRange(m_points); m_cuttingValue = CuttingValueStrategies<D, ELEM_TYPE> ::averageOfDimension(m_cuttingDimension, m_points); // Partition points using cutting plane SplitPredicate predicate(m_cuttingDimension, m_cuttingValue); typename PointList::iterator endOfLeft = std::partition( m_points.begin(), m_points.end(), predicate); // Construct children to hold both partitions m_leftChild = new BucketKDTreeNode<D, ELEM_TYPE>( this, PointList(m_points.begin(), endOfLeft) ); m_rightChild = new BucketKDTreeNode<D, ELEM_TYPE>( this, PointList(endOfLeft, m_points.end()) ); // Turn node into a non-leaf m_isLeaf = false; m_points.clear(); // Insert given point into one of the new children if (p[m_cuttingDimension] < m_cuttingValue) { m_leftChild->addPoint(p); } else { m_rightChild->addPoint(p); } }
NPC::NPC(Scene& scene, Map* map, Player* player) : Drawable(scene, 0.0, 0.0, 0.0), _drawable(NULL), _id(-1), _spawnX(0.0), _spawnY(0.0), _spawnDirection(0.0), _oriX(0.0), _oriY(0.0), _nxtX(0.0), _nxtY(0.0), _dstX(0.0), _dstY(0.0), _speed(0.0), _direction(0.0), _walking(false), _map(map), _player(player), _sectorID(-1), _restlessnessRating(0.0), _restlessness(0.0), _walkingAnimationPosition(0.0) { _path = PointList(); _tShirtColor = Color3f(1.0, 1.0, 1.0); }
void IndexPseudoPyramidTree::clear() { // NOTE: Using assigment not clear() to ensure memory is de-allocated // (through destructors of containers) points = PointList(); pointSums = RealList(); hashMap = OneDMap(); emptyElementIndices = IndexList(); }
void NPC::place(float x, float y, float direction) { if(_map->getObstructingObjectF(_x, _y) == _id) { _map->setObstructingObjectF(_x, _y, 0); } _x = x; _y = y; _oriX = x; _oriY = y; _nxtX = x; _nxtY = y; _dstX = x; _dstY = y; _direction = direction; _altitude = _map->getSurfaceHeight(_x, _y); _restlessnessRating = 0.0; _path = PointList(); updateSectorID(); _map->setObstructingObjectF(_x, _y, _id); }