예제 #1
0
    void PushData(bool consume = false, data::File::Writer* pwriter = nullptr) {
        assert(!pwriter || consume);

        if (cache_) {
            // previous PushData() has stored data in cache_
            data::File::Reader reader = cache_->GetReader(consume);
            while (reader.HasNext())
                emitter_.Emit(reader.Next<TableItem>());
            return;
        }

        if (!consume) {
            if (subranges_.empty()) {
                Flush();
            }
            else {
                data::FilePtr cache = ctx_.GetFilePtr(dia_id_);
                data::File::Writer writer = cache_->GetWriter();
                PushData(true, &writer);
                cache_ = cache;
                writer.Close();
            }
            return;
        }

        // close File writers
        for (auto& w : subrange_writers_) {
            w.Close();
        }

        if (pwriter) {
            FlushAndConsume<true>(pwriter);
        }
        else {
            FlushAndConsume();
        }

        for (size_t i = 0; i < subranges_.size(); ++i) {
            ReduceByIndexPostPhase<TableItem, Key, Value, KeyExtractor,
                                   ReduceFunction, Emitter, VolatileKey,
                                   ReduceConfig>
            subtable(ctx_, dia_id_, key_extractor_, reduce_function_,
                     emitter_.emit_, config_, neutral_element_);
            subtable.SetRange(subranges_[i]);
            subtable.Initialize(limit_memory_bytes_);

            {
                // insert items
                auto reader = subrange_files_[i]->GetConsumeReader();
                while (reader.HasNext()) {
                    subtable.Insert(reader.template Next<TableItem>());
                }
            }

            subtable.PushData(consume || pwriter, pwriter);

            // delete File
            subrange_files_[i].reset();
        }
    }
예제 #2
0
bool ShaderScript::CmdDepthState::BeginExecute(CommandContext* pContext,
		const ASTCommand* command) const {
	ConstMultiStringHelper h(command->GetParameters().AsString());
	ShaderScriptContext* c = static_cast<ShaderScriptContext*>(pContext);
	String value;
	auto it = h.Iterate();
	auto& depthStencil = c->depthStencilState;
	if (it.HasNext(value)) {
		// expected and set
		if (!value.compare("disable")) {
			depthStencil.depthTest = false;
		} else if (!value.compare("test-and-write")) {
		} else if (!value.compare("advanced")) {
			const ASTParameter& param = command->GetParameters();
			if (param.Find("depth-test", value)) {
				depthStencil.depthTest = Convert::ToBool(value);
			}
			if (param.Find("depth-write", value)) {
				depthStencil.depthWrite = Convert::ToBool(value);
			}
			if (param.Find("depth-compare-op", value)) {
				depthStencil.depthCompareFunc = Helper::GetDepthStencilFunc(value);
			}
		}
	}
	return true;
}
예제 #3
0
파일: sasl.cpp 프로젝트: DreamBNC/znc
    CString GetNext() const {
        if (HasNext()) {
            return at(m_uiIndex + 1);
        }

        return "";
    }
void RecursiveBacktrackerMaze::GenerateNext()
{
  pair<Point, Cell::Direction> new_cur;
  vector<pair<Point, Cell::Direction> > neighbours;

  neighbours = GetUnMarkedNeighbours(current_);

  if (!neighbours.empty())
  {
    new_cur = neighbours[rand() % neighbours.size()];
    backtracker_.push(new_cur.first);
    OpenPassage(current_, new_cur.second);

    current_ = new_cur.first;
    marked_.Mark(current_);
    cell_count_--;
  }
  else if (!backtracker_.empty())
  {
    current_ = backtracker_.top();
    backtracker_.pop();

    if (HasNext())
      GenerateNext();
  }
}
예제 #5
0
DictionaryEntry* HashTable::Iter::Next() {
	if (!HasNext()) {
		return NULL;
	}
	Obj *next = cur;
	cur = cur->next;
	return next;
}
예제 #6
0
/** \fn LiveTVChain::SwitchToNext(bool)
 *  \brief Sets the recording to switch to.
 *  \param up Set to true to switch to the next recording,
 *            false to switch to the previous recording.
 */
void LiveTVChain::SwitchToNext(bool up)
{
    //VERBOSE(VB_PLAYBACK, LOC + "SwitchToNext("<<(up?"up":"down")<<")");
    if (up && HasNext())
        SwitchTo(m_curpos + 1);
    else if (!up && HasPrev())
        SwitchTo(m_curpos - 1);
}
예제 #7
0
/** \fn LiveTVChain::SwitchToNext(bool)
 *  \brief Sets the recording to switch to.
 *  \param up Set to true to switch to the next recording,
 *            false to switch to the previous recording.
 */
void LiveTVChain::SwitchToNext(bool up)
{
#if 0
    LOG(VB_PLAYBACK, LOG_DEBUG, LOC + "SwitchToNext("<<(up?"up":"down")<<")");
#endif
    if (up && HasNext())
        SwitchTo(m_curpos + 1);
    else if (!up && HasPrev())
        SwitchTo(m_curpos - 1);
}
예제 #8
0
int OptionIterator::Next(std::string& argument)
{
	if (!HasNext())
		return '\0';

	char option = fCurrentOption->fShortOption;
	argument = fOptionArgument != NULL ? fOptionArgument : "";

	_FindNext();
	return option;
}
예제 #9
0
bool CmdCreateBuffer::BeginExecute(CommandContext* pContext,
		const ASTCommand* command) const {
	ConstMultiStringHelper h(command->GetParameters().AsString());
	RenderScriptContext* c = static_cast<RenderScriptContext*>(pContext);
	c->_numTargets = 0;
	c->_bufferDim.combined = 0;
	c->_bufferDepth = 1;
	c->_bufferDimFactor = Vector2(1, 1);
	auto it = h.Iterate();
	String temp;
	if (it.HasNext(temp))
		c->_bufferName = temp;
	if (it.HasNext(temp))
		ParseDimension(temp, c->_bufferDim.dx, c->_bufferDimFactor.x);
	if (it.HasNext(temp))
		ParseDimension(temp, c->_bufferDim.dy, c->_bufferDimFactor.y);
	float depthFactor;
	if (it.HasNext(temp))
		ParseDimension(temp, c->_bufferDepth, depthFactor);
	return true;
}
예제 #10
0
void SimulateParticleAging(PartSysEmitter* emitter, float timeToSimulateSec) {

	auto it = emitter->NewIterator();
	auto &ages = emitter->GetParticles();

	while (it.HasNext()) {
		auto particleIdx = it.Next();
		ages[particleIdx] += timeToSimulateSec;
	}

	emitter->PruneExpiredParticles();

}
예제 #11
0
 /// \brief Forward iterator by one and return next element (could be NULL)
 CLASS_TYPE * Next()
 {
   if(Init())
   {
     if(!m_bExecutedHasNext) HasNext(); //just ensure the call (we don't care about the result)
     m_bExecutedHasNext = false;
     return next();
   }
   else
   {
     return NULL;
   }
 }
예제 #12
0
bool FullScanCursor::Next() {
	if (!HasNext())
		return false;

	if (m_currentPage->GetRecordCount() == m_currentRecordNumber + 1) {
		PageID const nextPageID = m_currentPage->GetNextPageID();
		m_currentPage = std::make_unique<DataPage>(m_pageManager, nextPageID, m_descriptors);
		m_currentRecordNumber = 0;
	} else
		++m_currentRecordNumber;

	return true;
}
예제 #13
0
		const char* GetNext(bool* isDirectory){
			if (!HasNext())
				return "";

			if (!pack) {
				boost::filesystem::path path;
				if (mRecursive) {
					auto entity = *mRecursiveIterator;
					mRecursiveIterator++;
					path = entity.path();
				}
				else {
					auto entity = *mIterator;
					mIterator++;
					path = entity.path();
				}

				if (path.empty())
					return "";

				mLastFile = path._tgeneric_string();
				if (isDirectory)
					*isDirectory = boost::filesystem::is_directory(path);
				return mLastFile.c_str();
			}
			else {
				for (unsigned i = current_pack_index; i < pack->headers.size(); ++i) {
					auto& h = pack->headers[i];
					// pack path = Data/actors.fba
					// pack_parent_path = Data/
					// file_path = actors/something.lua
					// output_path = pack_parent_path + file_path = Data/actors/something.lua
					auto output_path = pack_parent_path + h.path;
					if (StartsWith(output_path, path)) {
						if (!mRecursive) {
							auto file = output_path.substr(path.size());
							if (file.find('/') != std::string::npos) {
								continue;
							}
						}
						current_pack_index = i+1;
						mLastFile = output_path;
						if (isDirectory)
							*isDirectory = false;
						return mLastFile.c_str();
					}
				}
				return "";
			}
		}
예제 #14
0
struct ByteTagList::Iterator::Item
ByteTagList::Iterator::Next (void)
{
  NS_ASSERT (HasNext ());
  struct Item item = Item (TagBuffer (m_current+16, m_end));
  item.tid.SetUid (m_nextTid);
  item.size = m_nextSize;
  item.start = std::max (m_nextStart, m_offsetStart);
  item.end = std::min (m_nextEnd, m_offsetEnd);
  m_current += 4 + 4 + 4 + 4 + item.size;
  item.buf.TrimAtEnd (m_end - m_current);
  PrepareForNext ();
  return item;
}
예제 #15
0
  Range Next() {
    assert(HasNext());

    const TCHAR *line_start = start;

    // Search for next line break
    const auto *line_break = StringFind(line_start, _T('\n'));
    if (!line_break) {
      // if no line break was found
      start = NULL;
      return Range(line_start, _tcslen(line_start));
    }

    unsigned length = line_break - line_start;
    start = line_break + 1;
    return Range(line_start, length);
  }
예제 #16
0
char* CNWNXHashSet::OnRequest(char* gameObject, char* Request, char* Parameters)
{
    char* presult = NULL;

    Log(2, "Request: \"%s\"\n", Request);
    Log(3, "Params:  \"%s\"\n", Parameters);

    if (strcmp(Request, "LOOKUP") == 0)
        presult = Lookup(gameObject, Parameters);
    else if (strcmp(Request, "INSERT") == 0)
        presult = Insert(gameObject, Parameters);
    else if (strcmp(Request, "DELETE") == 0)
        presult = Delete(gameObject, Parameters);
    else if (strcmp(Request, "STATUS") == 0)
        presult = (char *)(iLastOperation ? "1" : "0");
    else if (strcmp(Request, "VALID") == 0)
        presult = Valid(gameObject, Parameters);
    else if (strcmp(Request, "EXISTS") == 0)
        presult = Exists(gameObject, Parameters);
    else if (strcmp(Request, "GETFIRSTKEY") == 0)
        presult = GetFirstKey(gameObject, Parameters);
    else if (strcmp(Request, "GETNEXTKEY") == 0)
        presult = GetNextKey(gameObject, Parameters);
    else if (strcmp(Request, "GETCURRENTKEY") == 0)
        presult = GetCurrentKey(gameObject, Parameters);
    else if (strcmp(Request, "GETNTHKEY") == 0)
        presult = GetNthKey(gameObject, Parameters);
    else if (strcmp(Request, "HASNEXT") == 0)
        presult = HasNext(gameObject, Parameters);
    else if (strcmp(Request, "GETSIZE") == 0)
        presult = GetSize(gameObject, Parameters);
    else if (strcmp(Request, "DESTROY") == 0)
        presult = Destroy(gameObject, Parameters);
    else if (strcmp(Request, "CREATE") == 0)
        presult = Create(gameObject, Parameters);

    Log(4, "hashset returns[%s]\n", presult);

    // a return value of NULL tells NWNX that it shouldn't copy
    // any values, a non zero pointer tells NWNX that it should copy
    // the null terminated string pointed to by that pointer back into NWN.
    return presult;
}
예제 #17
0
    T Next() {
        assert(HasNext());

        if (reread_) {
            return cat_reader_.template Next<T>();
        }
        else {
            if (!available_) {
                if (!PullBlock())
                    throw std::runtime_error(
                              "Data underflow in MixBlockQueueReader.");
            }

            assert(available_ > 0);
            assert(selected_ < readers_.size());

            --available_;
            return readers_[selected_].template Next<T>();
        }
    }
예제 #18
0
	void Menu::Update()
	{
		Layer::Update();

		auto iter = this->itemList.GetIterator();
		int i = 0;
		while (iter->HasNext())
		{
			auto item = iter->Next();
			if (item->NeedRemove())
			{
				iter->Remove();
				if (i <= currentSelection)
				{
					currentSelection--;
				}
			}
			i++;
		}
	}
예제 #19
0
bool ShaderScript::CmdStencilState::BeginExecute(CommandContext* pContext,
		const ASTCommand* command) const {
	ConstMultiStringHelper h(command->GetParameters().AsString());
	ShaderScriptContext* c = static_cast<ShaderScriptContext*>(pContext);
	String value;
	auto it = h.Iterate();
	auto& depthStencil = c->depthStencilState;
	if (it.HasNext(value)) {
		// expected and set
		if (!value.compare("disable")) {
			depthStencil.stencilTest = false;
		} else if (!value.compare("advanced")) {
			const ASTParameter& param = command->GetParameters();

			StencilFaceOp* faceOp = &depthStencil.front;
			if (param.Find("face", value) && value == "back") {
				faceOp = &depthStencil.back;
			}
			if (param.Find("depth-stencil-op", value)) {
				faceOp->stencilFunc = Helper::GetDepthStencilFunc(value);
			}
			if (param.Find("stencil-pass", value)) {
				faceOp->stencilPass = Helper::GetStencilOp(value);
			}
			if (param.Find("stencil-fail", value)) {
				faceOp->stencilFail = Helper::GetStencilOp(value);
			}
			if (param.Find("depth-pass", value)) {
				faceOp->depthPass = Helper::GetStencilOp(value);
			}
			if (param.Find("stencil-mask", value)) {
				faceOp->stencilMask = Convert::ToULong(value);
			}
			if (param.Find("stencil-ref", value)) {
				faceOp->stencilRef = Convert::ToULong(value);
			}
		}
	}
	return true;
}
void SideWinderMaze::GenerateNext()
{
  bool open_east = rand() % 2;

  if (j_ > Rows() - 2)
  {
    i_++;
    j_ = 1;

    current_ = Point(i_, 1);
  }

  j_++;

  // FIXME Make this better... to avoid this
  if (!HasNext())
    return;

  if (open_east && InBounds(current_.Right()))
  {
    OpenPassage(current_, Cell::Direction::RIGHT);
    current_ = current_.Right();
    run_set_.push_back(current_);
  }
  else
  {
    Point up_point;

    if (run_set_.empty())
      up_point = current_;
    else
      up_point = run_set_[rand() % run_set_.size()];

    OpenPassage(up_point, Cell::Direction::UP);
    current_ = current_.Right();
    run_set_.clear();
  }
}
예제 #21
0
bool LanguageTranslator::ConstBuffer_BeginExecute(ShaderScriptContext* c,
	const ASTCommand* command) {
	ConstMultiStringHelper h(command->GetParameters().AsString());
	String name;
	String modName;

	bool determineContext = true;
	auto it = h.Iterate();
	if (it.HasNext(name)) {
		StringPair semantic = StringUtils::Split(name, ':');
		if (semantic.second != StringUtils::Null) {
			AutoParamName apn = Helper::GetAutoParam(semantic.second);
			if (apn != AutoParamName::AUTO_INVALID_PARAM) {
				name = std::move(semantic.first);
				c->shader->AddSemanticBinding("_" + name, apn);
				determineContext = false;
				
			}
		}
	}

	modName = "_";
	modName += name;

	if (determineContext) {
		String context;
		String contextStr = _SS(TAG_CONTEXT);
		if (command->GetParameters().Find(contextStr, context)) {
			modName += "__";
			modName += ShaderParameter::GetContextKey(Helper::GetContextFromName(context));
		}
	}

	c->cbIsAutoParam = !determineContext;
	LanguageTranslator::Instance().BeginBuffer(c, name, modName);
	return true;
}
		const char* GetNext(bool* isDirectory){
			if (!HasNext())
				return "";

			boost::filesystem::path path;
			if (mRecursive){
					auto entity = *mRecursiveIterator;
					mRecursiveIterator++;
					path = entity.path();
			}
			else{
					auto entity = *mIterator;
					mIterator++;
					path = entity.path();
			}

			if (path.empty())
				return "";

			mLastFile = path._tgeneric_string();
			if (isDirectory)
				*isDirectory = boost::filesystem::is_directory(path);
			return mLastFile.c_str();			
		}
예제 #23
0
void SimulateParticleMovement(PartSysEmitter* emitter, float timeToSimulateSecs) {

	const auto& spec = emitter->GetSpec();

	// Used as a factor in integrating the acceleration to retroactively calculate
	// its influence on the particle position
	auto accelIntegrationFactor = timeToSimulateSecs * timeToSimulateSecs * 0.5f;

	auto& state = emitter->GetParticleState();
	auto it = emitter->NewIterator();
	while (it.HasNext()) {
		auto particleIdx = it.Next();
		auto particleAge = emitter->GetParticleAge(particleIdx);

		ParticleValueSource valueSource(emitter, particleIdx, particleAge);

		auto x = state.GetState(PSF_X, particleIdx);
		auto y = state.GetState(PSF_Y, particleIdx);
		auto z = state.GetState(PSF_Z, particleIdx);

		auto velX = state.GetState(PSF_VEL_X, particleIdx);
		auto velY = state.GetState(PSF_VEL_Y, particleIdx);
		auto velZ = state.GetState(PSF_VEL_Z, particleIdx);

		// Calculate new position of particle based on velocity
		x += timeToSimulateSecs * velX;
		y += timeToSimulateSecs * velY;
		z += timeToSimulateSecs * velZ;

		// Apply acceleration to velocity (retroactively to position as well)
		float value;
		if (valueSource.GetValue(part_accel_X, &value)) {
			x += accelIntegrationFactor * value;
			velX += timeToSimulateSecs * value;
		}
		if (valueSource.GetValue(part_accel_Y, &value)) {
			y += accelIntegrationFactor * value;
			velY += timeToSimulateSecs * value;
		}
		if (valueSource.GetValue(part_accel_Z, &value)) {
			z += accelIntegrationFactor * value;
			velZ += timeToSimulateSecs * value;
		}

		/*
			Apply Velocity Var
		*/
		if (spec->GetParticleVelocityCoordSys() == PartSysCoordSys::Polar) {
			if (spec->GetParticlePosCoordSys() != PartSysCoordSys::Polar) {
				// Velocity is polar, positions are not -> convert velocity
				auto azimuth = emitter->GetParamValue(part_velVariation_X, particleIdx, particleAge);
				auto inclination = emitter->GetParamValue(part_velVariation_Y, particleIdx, particleAge);
				auto radius = emitter->GetParamValue(part_velVariation_Z, particleIdx, particleAge);

				auto cartesianVel = SphericalDegToCartesian(azimuth, inclination, radius);
				x += cartesianVel.x * timeToSimulateSecs;
				y += cartesianVel.y * timeToSimulateSecs;
				z += cartesianVel.z * timeToSimulateSecs;
			} else {
				// Modify the spherical coordinates of the particle directly
				if (valueSource.GetValue(part_velVariation_X, &value)) {
					auto azimuth = state.GetStatePtr(PSF_POS_AZIMUTH, particleIdx);
					*azimuth += value * timeToSimulateSecs;
				}
				if (valueSource.GetValue(part_velVariation_Y, &value)) {
					auto inclination = state.GetStatePtr(PSF_POS_INCLINATION, particleIdx);
					*inclination += value * timeToSimulateSecs;
				}
				if (valueSource.GetValue(part_velVariation_Z, &value)) {
					auto radius = state.GetStatePtr(PSF_POS_RADIUS, particleIdx);
					*radius += value * timeToSimulateSecs;
				}
			}

		} else {
			// Cartesian velocity seems pretty simple here
			if (valueSource.GetValue(part_velVariation_X, &value)) {
				x += value * timeToSimulateSecs;
			}
			if (valueSource.GetValue(part_velVariation_Y, &value)) {
				y += value * timeToSimulateSecs;
			}
			if (valueSource.GetValue(part_velVariation_Z, &value)) {
				z += value * timeToSimulateSecs;
			}
		}
		
		/*
			Apply Pos Var
		*/
		float xPosVar, yPosVar, zPosVar;

		if (spec->GetParticlePosCoordSys() == PartSysCoordSys::Polar) {
			// Get current particle spherical coordinates
			auto azimuth = state.GetState(PSF_POS_AZIMUTH, particleIdx);
			auto inclination = state.GetState(PSF_POS_INCLINATION, particleIdx);
			auto radius = state.GetState(PSF_POS_RADIUS, particleIdx);

			// Modify them according to position variation parameters
			if (valueSource.GetValue(part_posVariation_X, &value)) {
				azimuth += value;
			}
			if (valueSource.GetValue(part_posVariation_Y, &value)) {
				inclination += value;
			}
			if (valueSource.GetValue(part_posVariation_Z, &value)) {
				radius += value;
			}

			// Convert the position that has been modified this way to cartesian
			auto cartesianPosVar = SphericalDegToCartesian(azimuth, inclination, radius);

			// Add the current unmodified particle pos to get to the final position
			xPosVar = cartesianPosVar.x;
			yPosVar = cartesianPosVar.y;
			zPosVar = cartesianPosVar.z;
		} else {
			xPosVar = emitter->GetParamValue(part_posVariation_X, particleIdx, particleAge);
			yPosVar = emitter->GetParamValue(part_posVariation_Y, particleIdx, particleAge);
			zPosVar = emitter->GetParamValue(part_posVariation_Z, particleIdx, particleAge);
		}
		
		// Save new particle state
		state.SetState(PSF_X, particleIdx, x);
		state.SetState(PSF_Y, particleIdx, y);
		state.SetState(PSF_Z, particleIdx, z);
		state.SetState(PSF_VEL_X, particleIdx, velX);
		state.SetState(PSF_VEL_Y, particleIdx, velY);
		state.SetState(PSF_VEL_Z, particleIdx, velZ);
		state.SetState(PSF_POS_VAR_X, particleIdx, x + xPosVar);
		state.SetState(PSF_POS_VAR_Y, particleIdx, y + yPosVar);
		state.SetState(PSF_POS_VAR_Z, particleIdx, z + zPosVar);
	}

}
void RecursiveBacktrackerMaze::Generate()
{
  while (HasNext())
    GenerateNext();
}
void WilsonsMaze::Generate()
{
  while (HasNext())
    GenerateNext();
}
예제 #26
0
bool LanguageTranslator::Declare_BeginExecute(ShaderScriptContext* c,
	const ASTCommand* command) {
	ConstMultiStringHelper h(command->GetParameters().AsString());
	String name;

	auto it = h.Iterate();

	ParamDataType dataType;
	String value;
	if (it.HasNext(value)) {
		dataType = ShaderParameter::MapParamType(value);
	}
	if (dataType == ParamDataType::PDT_UNKNOWN)
		Error(value + " is unknown data type.");
	if (it.HasNext(value)) {
		StringPair nameSemantic = StringUtils::Split(value, ':');
		AutoParamName apn = AutoParamName::AUTO_INVALID_PARAM;
		if (nameSemantic.second.length()>0)
			apn = Helper::GetAutoParam(nameSemantic.second);

		if (apn != AutoParamName::AUTO_INVALID_PARAM)
			c->shader->AddSemanticBinding(nameSemantic.first, apn);

		size_t pos;
		uint32 arrayCount = 1;
		String name;
		if ((pos = nameSemantic.first.find_first_of('[')) != String::npos) {
			//'01234567
			//'name[10]'
			if (nameSemantic.first.back() == ']' && pos < nameSemantic.first.length() - 1) {
				pos++;
				arrayCount =
					Convert::ToULong(nameSemantic.first.substr(
					pos, nameSemantic.first.length() - 1 - pos));
				if (arrayCount == 0)
					arrayCount = 1;
			} else {
				Error("Variable name is not in good format: " + nameSemantic.first);
				return false;
			}
			name = nameSemantic.first.substr(0, pos);
			StringUtils::Trim(name);
		} else {

			name = std::move(nameSemantic.first);
			std::replace(name.begin(), name.end(), '{', '[');
			std::replace(name.begin(), name.end(), '}', ']');
		}

		LanguageTranslator::Instance().AddParam(c, dataType, name, arrayCount);
		if (apn == AutoParamName::AUTO_INVALID_PARAM && !c->cbIsAutoParam) {
			ShaderTemplate::ParameterDesc desc;
			desc.activateOption = StringUtils::GetTaggedVal("activate", it);
			desc.description = StringUtils::GetTaggedVal("nameref", it);
			desc.type = dataType;
			String contextName = StringUtils::GetTaggedVal("context", it);
			desc.context = Helper::GetContextFromName(contextName);
			c->shader->AddParam(name, desc);
		}
	}
	return true;
}
예제 #27
0
csArray<csSimpleRenderMesh*>* celHPath::GetDebugMeshes ()
{
  float halfHeight = 0.f;
  csHash<csRef<iCelNavMesh>, csPtrKey<iSector> >::GlobalIterator it = navMeshes.GetIterator();
  if (it.HasNext())
  {
    halfHeight = it.Next()->GetParameters()->GetAgentHeight() / 2.0;
  }

  int backCount = 0;
  while (HasPrevious())
  {
    Previous();
    backCount++;
  }

  csRef<iMapNode> current = Current();
  csRef<iMapNode> previous = Current();
  csVector3 currentPosition = current->GetPosition();
  csVector3 previousPosition = previous->GetPosition();  

  DebugDrawCS dd;
  dd.depthMask(false);

  const unsigned int lineCol = duRGBA(255, 255, 255, 230);
  const unsigned int vertexCol = duRGBA(255, 150, 0, 230);
  dd.begin(DU_DRAW_LINES, 4.0f);
  while (HasNext())
  {
    previous = current;
    previousPosition = currentPosition;
    current = Next();
    currentPosition = current->GetPosition();
    
    dd.vertex(previousPosition[0], previousPosition[1] + halfHeight, previousPosition[2], lineCol);
    dd.vertex(currentPosition[0], currentPosition[1] + halfHeight, currentPosition[2], lineCol);
  }
  dd.end();

  Restart();
  currentPosition = Current()->GetPosition();
  dd.begin(DU_DRAW_POINTS, 10.0f);
  dd.vertex(currentPosition[0], currentPosition[1] + halfHeight, currentPosition[2], vertexCol);
  while (HasNext())
  {
    currentPosition = Next()->GetPosition();
    dd.vertex(currentPosition[0], currentPosition[1] + halfHeight, currentPosition[2], vertexCol);
  }
  dd.end();

  dd.depthMask(true);
  Restart();
  for (int i = 0; i < backCount; i++)
  {
    Next();
  }


  // Clear previous meshes
  if (!debugMeshes->IsEmpty()) 
  { 
    csArray<csSimpleRenderMesh*>::Iterator it = debugMeshes->GetIterator(); 
    while (it.HasNext()) 
    { 
      csSimpleRenderMesh* mesh = it.Next(); 
      delete [] mesh->vertices; 
      delete [] mesh->colors; 
    }
    debugMeshes->DeleteAll(); 
  }

  // Update meshes
  debugMeshes = dd.GetMeshes();
  return debugMeshes;
}
void SideWinderMaze::Generate()
{
  while (HasNext())
    GenerateNext();
}