当前位置: 首页>>代码示例>>C++>>正文


C++ MapBlock::isDummy方法代码示例

本文整理汇总了C++中MapBlock::isDummy方法的典型用法代码示例。如果您正苦于以下问题:C++ MapBlock::isDummy方法的具体用法?C++ MapBlock::isDummy怎么用?C++ MapBlock::isDummy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MapBlock的用法示例。


在下文中一共展示了MapBlock::isDummy方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getBlockOrStartGen

bool EmergeThread::getBlockOrStartGen(v3s16 p, MapBlock **b,
									BlockMakeData *data, bool allow_gen) {
	v2s16 p2d(p.X, p.Z);
	//envlock: usually takes <=1ms, sometimes 90ms or ~400ms to acquire
	JMutexAutoLock envlock(m_server->m_env_mutex);

	// Load sector if it isn't loaded
	if (map->getSectorNoGenerateNoEx(p2d) == NULL)
		map->loadSectorMeta(p2d);

	// Attempt to load block
	MapBlock *block = map->getBlockNoCreateNoEx(p);
	if (!block || block->isDummy() || !block->isGenerated()) {
		EMERGE_DBG_OUT("not in memory, attempting to load from disk");
		block = map->loadBlock(p);
		if (block && block->isGenerated())
			map->prepareBlock(block);
	}

	// If could not load and allowed to generate,
	// start generation inside this same envlock
	if (allow_gen && (block == NULL || !block->isGenerated())) {
		EMERGE_DBG_OUT("generating");
		*b = block;
		return map->initBlockMake(data, p);
	}

	*b = block;
	return false;
}
开发者ID:Adam445,项目名称:minetest,代码行数:30,代码来源:emerge.cpp

示例2: getBlockOrStartGen

bool EmergeThread::getBlockOrStartGen(v3s16 p, MapBlock **b,
									BlockMakeData *data, bool allow_gen) {
	//envlock: usually takes <=1ms, sometimes 90ms or ~400ms to acquire
	//JMutexAutoLock envlock(m_server->m_env_mutex);

	// Attempt to load block
	MapBlock *block = map->getBlockNoCreateNoEx(p);
	if (!block || block->isDummy()) {
		EMERGE_DBG_OUT("not in memory, attempting to load from disk ag="<<allow_gen<<" block="<<block<<" p="<<p);
		block = map->loadBlock(p);
		if(block)
		{
// 			block->pushElementsToCircuit(m_circuit);
// 			m_circuit->processElementsQueue(*map, map->getNodeDefManager());
		}
		if (block && block->isGenerated())
			map->prepareBlock(block);
	}

	// If could not load and allowed to generate,
	// start generation inside this same envlock
	if (allow_gen && (!block)) {
		EMERGE_DBG_OUT("generating b="<<block);
		*b = block;
		return map->initBlockMake(data, p);
	}

	*b = block;
	return false;
}
开发者ID:gourytch,项目名称:freeminer,代码行数:30,代码来源:emerge.cpp

示例3: getBlockOrStartGen

bool EmergeThread::getBlockOrStartGen(v3s16 p, MapBlock **b,
	BlockMakeData *data, bool allow_gen)
{
#if !ENABLE_THREADS
	auto lock = map->m_nothread_locker.lock_unique_rec();
#endif

	MapBlock *block;
	{

	//envlock: usually takes <=1ms, sometimes 90ms or ~400ms to acquire
	//JMutexAutoLock envlock(m_server->m_env_mutex);


	// Attempt to load block
	block = map->getBlockNoCreateNoEx(p);
	if (!block || block->isDummy()) {
		EMERGE_DBG_OUT("not in memory, attempting to load from disk ag="<<allow_gen<<" block="<<block<<" p="<<p);
		block = map->loadBlock(p);
		if (block && block->isGenerated())
			map->prepareBlock(block);
	}
	}

	// If could not load and allowed to generate,
	// start generation inside this same envlock
	if (allow_gen && (!block)) {
		EMERGE_DBG_OUT("generating b="<<block);
		*b = block;
		return map->initBlockMake(data, p);
	}

	*b = block;
	return false;
}
开发者ID:prodigeni,项目名称:freeminer,代码行数:35,代码来源:emerge.cpp

示例4: GetNextBlocks


//.........这里部分代码省略.........
				Don't generate or send if not in sight
				FIXME This only works if the client uses a small enough
				FOV setting. The default of 72 degrees is fine.
			*/

			f32 dist;
			if (!isBlockInSight(p, camera_pos, camera_dir, camera_fov, d_blocks_in_sight, &dist)) {
				continue;
			}

			/*
				Don't send already sent blocks
			*/
			{
				if(m_blocks_sent.find(p) != m_blocks_sent.end())
				{
					continue;
				}
			}

			/*
				Check if map has this block
			*/
			MapBlock *block = env->getMap().getBlockNoCreateNoEx(p);

			bool surely_not_found_on_disk = false;
			bool block_is_invalid = false;
			if (block) {
				// Reset usage timer, this block will be of use in the future.
				block->resetUsageTimer();

				// Block is dummy if data doesn't exist.
				// It means it has been not found from disk and not generated
				if (block->isDummy()) {
					surely_not_found_on_disk = true;
				}

				if (!block->isGenerated())
					block_is_invalid = true;

				/*
					If block is not close, don't send it unless it is near
					ground level.

					Block is near ground level if night-time mesh
					differs from day-time mesh.
				*/
				if (d >= d_opt) {
					if (!block->getDayNightDiff())
						continue;
				}

				if (occ_cull && !block_is_invalid &&
						env->getMap().isBlockOccluded(block, cam_pos_nodes)) {
					continue;
				}
			}

			/*
				If block has been marked to not exist on disk (dummy)
				and generating new ones is not wanted, skip block.
			*/
			if (!generate && surely_not_found_on_disk) {
				// get next one.
				continue;
			}
开发者ID:Ekdohibs,项目名称:minetest,代码行数:67,代码来源:clientiface.cpp

示例5: GetNextBlocks


//.........这里部分代码省略.........
			if(can_skip && isBlockInSight(p, camera_pos, camera_dir, camera_fov, 10000*BS) == false)
			{
				continue;
			}

			/*
				Don't send already sent blocks
			*/
			{
				if(m_blocks_sent.find(p) != m_blocks_sent.end() && m_blocks_sent[p] > 0 && m_blocks_sent[p] + (d <= 2 ? 1 : d*d*d) > m_uptime) {
					continue;
				}
			}

			/*
				Check if map has this block
			*/
			MapBlock *block = env->getMap().getBlockNoCreateNoEx(p);

			bool surely_not_found_on_disk = false;
			bool block_is_invalid = false;
			if(block != NULL)
			{

				if (m_blocks_sent[p] > 0 && m_blocks_sent[p] >= block->m_changed_timestamp) {
					continue;
				}

				// Reset usage timer, this block will be of use in the future.
				block->resetUsageTimer();

				// Block is dummy if data doesn't exist.
				// It means it has been not found from disk and not generated
				if(block->isDummy())
				{
					surely_not_found_on_disk = true;
				}

				if (block->getLightingExpired()) {
					continue;
				}
				// Block is valid if lighting is up-to-date and data exists
				if(block->isValid() == false)
				{
					block_is_invalid = true;
				}

				if(block->isGenerated() == false)
				{
					continue;
				}

				/*
					If block is not close, don't send it unless it is near
					ground level.

					Block is near ground level if night-time mesh
					differs from day-time mesh.
				*/
/*
				if(d >= 4)
				{
					if(block->getDayNightDiff() == false)
						continue;
				}
*/
开发者ID:WantedGames,项目名称:freeminer,代码行数:67,代码来源:clientiface.cpp


注:本文中的MapBlock::isDummy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。