Beispiel #1
0
// ----------------------------------------------------------------------------
void DrawCalls::parseSceneManager(core::list<scene::ISceneNode*> &List,
                                  std::vector<scene::ISceneNode *> *ImmediateDraw,
                                  const scene::ICameraSceneNode *cam,
                                  ShadowMatrices& shadow_matrices)
{
    core::list<scene::ISceneNode*>::Iterator I = List.begin(), E = List.end();
    for (; I != E; ++I)
    {
        if (LODNode *node = dynamic_cast<LODNode *>(*I))
            node->updateVisibility();
        (*I)->updateAbsolutePosition();
        if (!(*I)->isVisible())
            continue;

        if (ParticleSystemProxy *node = dynamic_cast<ParticleSystemProxy *>(*I))
        {
            if (!isCulledPrecise(cam, *I))
                m_particles_list.push_back(node);
            continue;
        }

        if (STKBillboard *node = dynamic_cast<STKBillboard *>(*I))
        {
            if (!isCulledPrecise(cam, *I))
                m_billboard_list.push_back(node);
            continue;
        }

        handleSTKCommon((*I), ImmediateDraw, cam, shadow_matrices);
        parseSceneManager((*I)->getChildren(), ImmediateDraw, cam,
            shadow_matrices);
    }
}
void WeatherParticles::removeEmitters(core::list<v2s16> emitters_to_delete) {
	if (emitters_to_delete.size() > 0) {
		core::list<v2s16>::Iterator j;
		for (j = emitters_to_delete.begin(); j != emitters_to_delete.end(); j++) {
			WEmitter *emitter = m_emitter_map[*j];
			m_emitter_map.remove(*j);
			emitter->remove();
		}
	}
}
void ActiveBlockList::update(core::list<v3s16> &active_positions,
		s16 radius,
		core::map<v3s16, bool> &blocks_removed,
		core::map<v3s16, bool> &blocks_added)
{
	/*
		Create the new list
	*/
	core::map<v3s16, bool> newlist;
	for(core::list<v3s16>::Iterator i = active_positions.begin();
			i != active_positions.end(); i++)
	{
		fillRadiusBlock(*i, radius, newlist);
	}

	/*
		Find out which blocks on the old list are not on the new list
	*/
	// Go through old list
	for(core::map<v3s16, bool>::Iterator i = m_list.getIterator();
			i.atEnd()==false; i++)
	{
		v3s16 p = i.getNode()->getKey();
		// If not on new list, it's been removed
		if(newlist.find(p) == NULL)
			blocks_removed.insert(p, true);
	}

	/*
		Find out which blocks on the new list are not on the old list
	*/
	// Go through new list
	for(core::map<v3s16, bool>::Iterator i = newlist.getIterator();
			i.atEnd()==false; i++)
	{
		v3s16 p = i.getNode()->getKey();
		// If not on old list, it's been added
		if(m_list.find(p) == NULL)
			blocks_added.insert(p, true);
	}

	/*
		Update m_list
	*/
	m_list.clear();
	for(core::map<v3s16, bool>::Iterator i = newlist.getIterator();
			i.atEnd()==false; i++)
	{
		v3s16 p = i.getNode()->getKey();
		m_list.insert(p, true);
	}
}
Beispiel #4
0
		virtual bool isValidPosition(v3s16 p)
		{
			//return position_valid ^ (p==position_valid_exception);
			bool exception = false;
			for(core::list<v3s16>::Iterator i=validity_exceptions.begin();
					i != validity_exceptions.end(); i++)
			{
				if(p == *i)
				{
					exception = true;
					break;
				}
			}
			return exception ? !position_valid : position_valid;
		}
Beispiel #5
0
	int Java_zte_irrlib_scene_SceneNode_nativeRemoveAnimator(
		JNIEnv*  env, jobject thiz, jint count, jint Id)
	{
		ISceneNode* node = smgr->getSceneNodeFromId(Id);
		if (!node) 
		{
			WARN_NODE_NOT_FOUND(Id, RemoveAnimator);
			return -1;
		}
		const core::list<ISceneNodeAnimator*> anims = node->getAnimators();
		core::list<ISceneNodeAnimator*>::ConstIterator itr = anims.begin();
		while (count--) itr++;
		node->removeAnimator(*itr);
		return 0;
	}
Beispiel #6
0
	int Java_zte_irrlib_scene_SceneNode_nativeRemoveLastAnimator(
		JNIEnv *env, jobject defaultObj, jint id)
	{
		ISceneNode* node = smgr->getSceneNodeFromId(id);
		if (!node) 
		{
			WARN_NODE_NOT_FOUND(id, RemoveAllAnimator);
			return -1;
		}
		
		const core::list<ISceneNodeAnimator*> anims = node->getAnimators();
		if (anims.empty()) return -2;
		node->removeAnimator(*(anims.getLast()));
		return 0;
	}
Beispiel #7
0
// ----------------------------------------------------------------------------
void DrawCalls::parseSceneManager(core::list<scene::ISceneNode*> &List,
                                  const scene::ICameraSceneNode *cam)
{
    core::list<scene::ISceneNode*>::Iterator I = List.begin(), E = List.end();
    for (; I != E; ++I)
    {
        if (LODNode *node = dynamic_cast<LODNode *>(*I))
        {
            node->updateVisibility();
        }
        (*I)->updateAbsolutePosition();
        if (!(*I)->isVisible())
            continue;

        if (STKParticle *node = dynamic_cast<STKParticle*>(*I))
        {
            if (!isCulledPrecise(cam, *I, irr_driver->getBoundingBoxesViz()))
                CPUParticleManager::getInstance()->addParticleNode(node);
            continue;
        }

        if (scene::IBillboardSceneNode *node =
            dynamic_cast<scene::IBillboardSceneNode*>(*I))
        {
            if (!isCulledPrecise(cam, *I))
                CPUParticleManager::getInstance()->addBillboardNode(node);
            continue;
        }

        if (STKTextBillboard *tb =
            dynamic_cast<STKTextBillboard*>(*I))
        {
            if (!isCulledPrecise(cam, *I, irr_driver->getBoundingBoxesViz()))
                TextBillboardDrawer::addTextBillboard(tb);
            continue;
        }

        SP::SPMeshNode* node = dynamic_cast<SP::SPMeshNode*>(*I);
        if (node)
        {
            SP::addObject(node);
        }
        parseSceneManager((*I)->getChildren(), cam);
    }
}
Beispiel #8
0
    void fillBodyList(core::list<scene::ISceneNode *> &aPlanes, scene::ISceneNode *pNode, const c8 *sClassName, u32 iMax, ode::CIrrOdeWorld *pWorld) {
      if (pNode->getType()==ode::IRR_ODE_BODY_ID) {
        ode::CIrrOdeBody *p=(ode::CIrrOdeBody *)pNode;
        if (p->getOdeClassname().equals_ignore_case(sClassName)) {
          printf("%s found (%i)\n",sClassName,aPlanes.size());
          if (aPlanes.size()<iMax)
            aPlanes.push_back(pNode);
          else {
            m_pCtrlReceiver->removeFromScene(pNode);
            return;
          }
        }
      }

      core::list<scene::ISceneNode *> children=pNode->getChildren();
      core::list<scene::ISceneNode *>::Iterator it;

      for (it=children.begin(); it!=children.end(); it++) fillBodyList(aPlanes,*it,sClassName,iMax, pWorld);
    }
Beispiel #9
0
void Database_SQLite3::listAllLoadableBlocks(core::list<v3s16> &dst)
{
	verifyDatabase();
	
	while(sqlite3_step(m_database_list) == SQLITE_ROW)
	{
		sqlite3_int64 block_i = sqlite3_column_int64(m_database_list, 0);
		v3s16 p = getIntegerAsBlock(block_i);
		//dstream<<"block_i="<<block_i<<" p="<<PP(p)<<std::endl;
		dst.push_back(p);
	}
}
void MapSector::getBlocks(core::list<MapBlock*> &dest)
{
	core::list<MapBlock*> ref_list;

	core::map<s16, MapBlock*>::Iterator bi;

	bi = m_blocks.getIterator();
	for(; bi.atEnd() == false; bi++)
	{
		MapBlock *b = bi.getNode()->getValue();
		dest.push_back(b);
	}
}
Beispiel #11
0
// Get a dependency-sorted list of ModSpecs
core::list<ModSpec> getMods(core::list<std::string> &modspaths)
		throw(ModError)
{
	std::queue<ModSpec> mods_satisfied;
	core::list<ModSpec> mods_unsorted;
	core::list<ModSpec> mods_sorted;
	// name, path: For detecting name conflicts
	std::map<std::string, std::string> mod_names;
	for(core::list<std::string>::Iterator i = modspaths.begin();
			i != modspaths.end(); i++){
		std::string modspath = *i;
		std::vector<fs::DirListNode> dirlist = fs::GetDirListing(modspath);
		for(u32 j=0; j<dirlist.size(); j++){
			if(!dirlist[j].dir)
				continue;
			std::string modname = dirlist[j].name;
			std::string modpath = modspath + DIR_DELIM + modname;
			// Detect mod name conflicts
			{
				std::map<std::string, std::string>::const_iterator i;
				i = mod_names.find(modname);
				if(i != mod_names.end()){
					std::string s;
					infostream<<"WARNING: Mod name conflict detected: "
							<<std::endl
							<<"Already loaded: "<<i->second<<std::endl
							<<"Will not load: "<<modpath<<std::endl;
					continue;
				}
			}
			std::set<std::string> depends;
			std::ifstream is((modpath+DIR_DELIM+"depends.txt").c_str(),
					std::ios_base::binary);
			while(is.good()){
				std::string dep;
				std::getline(is, dep);
				dep = trim(dep);
				if(dep != "")
					depends.insert(dep);
			}
			ModSpec spec(modname, modpath, depends);
			mods_unsorted.push_back(spec);
			if(depends.empty())
				mods_satisfied.push(spec);
			mod_names[modname] = modpath;
		}
	}
	// Sort by depencencies
	while(!mods_satisfied.empty()){
		ModSpec mod = mods_satisfied.front();
		mods_satisfied.pop();
		mods_sorted.push_back(mod);
		for(core::list<ModSpec>::Iterator i = mods_unsorted.begin();
				i != mods_unsorted.end(); i++){
			ModSpec &mod2 = *i;
			if(mod2.unsatisfied_depends.empty())
				continue;
			mod2.unsatisfied_depends.erase(mod.name);
			if(!mod2.unsatisfied_depends.empty())
				continue;
			mods_satisfied.push(mod2);
		}
	}
	std::ostringstream errs(std::ios::binary);
	// Check unsatisfied dependencies
	for(core::list<ModSpec>::Iterator i = mods_unsorted.begin();
			i != mods_unsorted.end(); i++){
		ModSpec &mod = *i;
		if(mod.unsatisfied_depends.empty())
			continue;
		errs<<"mod \""<<mod.name
				<<"\" has unsatisfied dependencies:";
		for(std::set<std::string>::iterator
				i = mod.unsatisfied_depends.begin();
				i != mod.unsatisfied_depends.end(); i++){
			errs<<" \""<<(*i)<<"\"";
		}
		errs<<"."<<std::endl;
		mods_sorted.push_back(mod);
	}
	if(errs.str().size() != 0){
		throw ModError(errs.str());
	}
	return mods_sorted;
}
Beispiel #12
0
void ChatPrompt::nickCompletion(const core::list<std::wstring>& names, bool backwards)
{
	// Two cases:
	// (a) m_nick_completion_start == m_nick_completion_end == 0
	//     Then no previous nick completion is active.
	//     Get the word around the cursor and replace with any nick
	//     that has that word as a prefix.
	// (b) else, continue a previous nick completion.
	//     m_nick_completion_start..m_nick_completion_end are the
	//     interval where the originally used prefix was. Cycle
	//     through the list of completions of that prefix.
	u32 prefix_start = m_nick_completion_start;
	u32 prefix_end = m_nick_completion_end;
	bool initial = (prefix_end == 0);
	if (initial)
	{
		// no previous nick completion is active
		prefix_start = prefix_end = m_cursor;
		while (prefix_start > 0 && !isspace(m_line[prefix_start-1]))
			--prefix_start;
		while (prefix_end < m_line.size() && !isspace(m_line[prefix_end]))
			++prefix_end;
		if (prefix_start == prefix_end)
			return;
	}
	std::wstring prefix = m_line.substr(prefix_start, prefix_end - prefix_start);

	// find all names that start with the selected prefix
	core::array<std::wstring> completions;
	for (core::list<std::wstring>::ConstIterator
			i = names.begin();
			i != names.end(); i++)
	{
		if (str_starts_with(*i, prefix, true))
		{
			std::wstring completion = *i;
			if (prefix_start == 0)
				completion += L":";
			completions.push_back(completion);
		}
	}
	if (completions.empty())
		return;

	// find a replacement string and the word that will be replaced
	u32 word_end = prefix_end;
	u32 replacement_index = 0;
	if (!initial)
	{
		while (word_end < m_line.size() && !isspace(m_line[word_end]))
			++word_end;
		std::wstring word = m_line.substr(prefix_start, word_end - prefix_start);

		// cycle through completions
		for (u32 i = 0; i < completions.size(); ++i)
		{
			if (str_equal(word, completions[i], true))
			{
				if (backwards)
					replacement_index = i + completions.size() - 1;
				else
					replacement_index = i + 1;
				replacement_index %= completions.size();
				break;
			}
		}
	}
	std::wstring replacement = completions[replacement_index] + L" ";
	if (word_end < m_line.size() && isspace(word_end))
		++word_end;

	// replace existing word with replacement word,
	// place the cursor at the end and record the completion prefix
	m_line.replace(prefix_start, word_end - prefix_start, replacement);
	m_cursor = prefix_start + replacement.size();
	clampView();
	m_nick_completion_start = prefix_start;
	m_nick_completion_end = prefix_end;
}