您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ v2s16函数代码示例

51自学网 2021-06-03 09:29:14
  C++
这篇教程C++ v2s16函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中v2s16函数的典型用法代码示例。如果您正苦于以下问题:C++ v2s16函数的具体用法?C++ v2s16怎么用?C++ v2s16使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

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

示例1: n_dirt

void MapgenV6::addMud(){	// 15ms @cs=8	//TimeTaker timer1("add mud");	MapNode n_dirt(c_dirt), n_gravel(c_gravel);	MapNode n_sand(c_sand), n_desert_sand(c_desert_sand);	MapNode addnode;	u32 index = 0;	for (s16 z = node_min.Z; z <= node_max.Z; z++)	for (s16 x = node_min.X; x <= node_max.X; x++, index++) {		// Randomize mud amount		s16 mud_add_amount = getMudAmount(index) / 2.0 + 0.5;		// Find ground level		s16 surface_y = find_stone_level(v2s16(x, z)); /////////////////optimize this!		// Handle area not found		if (surface_y == vm->m_area.MinEdge.Y - 1)			continue;		BiomeV6Type bt = getBiome(v2s16(x, z));		addnode = (bt == BT_DESERT) ? n_desert_sand : n_dirt;		if (bt == BT_DESERT && surface_y + mud_add_amount <= water_level + 1) {			addnode = n_sand;		} else if (mud_add_amount <= 0) {			mud_add_amount = 1 - mud_add_amount;			addnode = n_gravel;		} else if (bt != BT_DESERT && getHaveBeach(index) &&				surface_y + mud_add_amount <= water_level + 2) {			addnode = n_sand;		}		if ((bt == BT_DESERT || bt == BT_TUNDRA) && surface_y > 20)			mud_add_amount = MYMAX(0, mud_add_amount - (surface_y - 20) / 5);		/* If topmost node is grass, change it to mud.  It might be if it was		// flown to there from a neighboring chunk and then converted.		u32 i = vm->m_area.index(x, surface_y, z);		if (vm->m_data[i].getContent() == c_dirt_with_grass)			vm->m_data[i] = n_dirt;*/		// Add mud on ground		s16 mudcount = 0;		v3s16 em = vm->m_area.getExtent();		s16 y_start = surface_y + 1;		u32 i = vm->m_area.index(x, y_start, z);		for (s16 y = y_start; y <= node_max.Y; y++) {			if (mudcount >= mud_add_amount)				break;			vm->m_data[i] = addnode;			mudcount++;			vm->m_area.add_y(em, i, 1);		}	}}
开发者ID:4aiman,项目名称:Magichet-stable,代码行数:59,


示例2: get_sector_minimum_ground_level

double get_sector_minimum_ground_level(u64 seed, v3s16 node_min, v3s16 node_max, double p=4){	double a = 31000;	// Corners	a = MYMIN(a, find_ground_level_from_noise(seed,			v2s16(node_min.X, node_min.Z), p));	a = MYMIN(a, find_ground_level_from_noise(seed,			v2s16(node_min.X, node_max.Z), p));	a = MYMIN(a, find_ground_level_from_noise(seed,			v2s16(node_max.X, node_max.Z), p));	a = MYMIN(a, find_ground_level_from_noise(seed,			v2s16(node_min.X, node_min.Z), p));	// Center	a = MYMIN(a, find_ground_level_from_noise(seed,			v2s16((node_min.X+node_max.X)/2, (node_min.Z+node_max.Z)/2), p));	// Side middle points	a = MYMIN(a, find_ground_level_from_noise(seed,			v2s16((node_min.X+node_max.X)/2, node_min.Z), p));	a = MYMIN(a, find_ground_level_from_noise(seed,			v2s16((node_min.X+node_max.X)/2, node_max.Z), p));	a = MYMIN(a, find_ground_level_from_noise(seed,			v2s16(node_min.X, (node_min.Z+node_max.Z)/2), p));	a = MYMIN(a, find_ground_level_from_noise(seed,			v2s16(node_max.X, (node_min.Z+node_max.Z)/2), p));	return a;}
开发者ID:WantedGames,项目名称:freeminer,代码行数:26,


示例3: Run

	void Run()	{		TC parent;		parent.position_valid = false;		// Create one with no heightmaps		ServerMapSector sector(&parent, v2s16(1,1));		UASSERT(sector.getBlockNoCreateNoEx(0) == 0);		UASSERT(sector.getBlockNoCreateNoEx(1) == 0);		MapBlock * bref = sector.createBlankBlock(-2);		UASSERT(sector.getBlockNoCreateNoEx(0) == 0);		UASSERT(sector.getBlockNoCreateNoEx(-2) == bref);		//TODO: Check for AlreadyExistsException		/*bool exception_thrown = false;		try{			sector.getBlock(0);		}		catch(InvalidPositionException &e){			exception_thrown = true;		}		UASSERT(exception_thrown);*/	}
开发者ID:Jetqvvf,项目名称:minetest,代码行数:28,


示例4: get_sector_average_ground_level

double get_sector_average_ground_level(u64 seed, v3s16 node_min, v3s16 node_max, double p=4){	double a = 0;	a += find_ground_level_from_noise(seed,			v2s16(node_min.X, node_min.Z), p);	a += find_ground_level_from_noise(seed,			v2s16(node_min.X, node_max.Z), p);	a += find_ground_level_from_noise(seed,			v2s16(node_max.X, node_max.Z), p);	a += find_ground_level_from_noise(seed,			v2s16(node_max.X, node_min.Z), p);	a += find_ground_level_from_noise(seed,			v2s16((node_min.X+node_max.X)/2, (node_min.Z+node_max.Z)/2), p);	a /= 5;	return a;}
开发者ID:WantedGames,项目名称:freeminer,代码行数:16,


示例5: UnitSAO

PlayerSAO::PlayerSAO(ServerEnvironment *env_, u16 peer_id_, bool is_singleplayer):	UnitSAO(env_, v3f(0,0,0)),	m_player(NULL),	m_peer_id(peer_id_),	m_inventory(NULL),	m_damage(0),	m_last_good_position(0,0,0),	m_time_from_last_punch(0),	m_nocheat_dig_pos(32767, 32767, 32767),	m_nocheat_dig_time(0),	m_wield_index(0),	m_position_not_sent(false),	m_armor_groups_sent(false),	m_properties_sent(true),	m_is_singleplayer(is_singleplayer),	m_animation_speed(0),	m_animation_blend(0),	m_animation_loop(true),	m_animation_sent(false),	m_bone_position_sent(false),	m_attachment_parent_id(0),	m_attachment_sent(false),	m_breath(PLAYER_MAX_BREATH),	m_pitch(0),	m_fov(0),	m_wanted_range(0),	// public	m_physics_override_speed(1),	m_physics_override_jump(1),	m_physics_override_gravity(1),	m_physics_override_sneak(true),	m_physics_override_sneak_glitch(true),	m_physics_override_sent(false){	m_ms_from_last_respawn = 10000; //more than ignore move time (1)	if (m_player) {		++m_player->refs;	}	//assert(m_peer_id != 0);	// pre-condition	m_armor_groups["fleshy"] = 100;	m_prop.hp_max = PLAYER_MAX_HP;	m_prop.physical = false;	m_prop.weight = 75;	m_prop.collisionbox = aabb3f(-1/3.,-1.0,-1/3., 1/3.,1.0,1/3.);	// start of default appearance, this should be overwritten by LUA	m_prop.visual = "upright_sprite";	m_prop.visual_size = v2f(1, 2);	m_prop.textures.clear();	m_prop.textures.push_back("player.png");	m_prop.textures.push_back("player_back.png");	m_prop.colors.clear();	m_prop.colors.push_back(video::SColor(255, 255, 255, 255));	m_prop.spritediv = v2s16(1,1);	// end of default appearance	m_prop.is_visible = true;	m_prop.makes_footstep_sound = true;	m_hp = PLAYER_MAX_HP;}
开发者ID:alexxvk,项目名称:freeminer,代码行数:60,


示例6: NoisePerlin2D

void MapgenV6::generateCaves(int max_stone_y){	float cave_amount = NoisePerlin2D(np_cave, node_min.X, node_min.Y, seed);	int volume_nodes = (node_max.X - node_min.X + 1) *					   (node_max.Y - node_min.Y + 1) * MAP_BLOCKSIZE;	cave_amount = MYMAX(0.0, cave_amount);	u32 caves_count = cave_amount * volume_nodes / 50000;	u32 bruises_count = 1;	PseudoRandom ps(blockseed + 21343);	PseudoRandom ps2(blockseed + 1032);	if (ps.range(1, 6) == 1)		bruises_count = ps.range(0, ps.range(0, 2));	if (getBiome(v2s16(node_min.X, node_min.Z)) == BT_DESERT) {		caves_count   /= 3;		bruises_count /= 3;	}	for (u32 i = 0; i < caves_count + bruises_count; i++) {		bool large_cave = (i >= caves_count);		CaveV6 cave(this, &ps, &ps2, large_cave);		cave.makeCave(node_min, node_max, max_stone_y);	}}
开发者ID:4aiman,项目名称:Magichet-stable,代码行数:26,


示例7: ServerActiveObject

PlayerSAO::PlayerSAO(ServerEnvironment *env_, Player *player_, u16 peer_id_,		const std::set<std::string> &privs, bool is_singleplayer):	ServerActiveObject(env_, v3f(0,0,0)),	m_player(player_),	m_peer_id(peer_id_),	m_inventory(NULL),	m_damage(0),	m_last_good_position(0,0,0),	m_time_from_last_punch(0),	m_nocheat_dig_pos(32767, 32767, 32767),	m_nocheat_dig_time(0),	m_wield_index(0),	m_position_not_sent(false),	m_armor_groups_sent(false),	m_properties_sent(true),	m_privs(privs),	m_is_singleplayer(is_singleplayer),	m_animation_speed(0),	m_animation_blend(0),	m_animation_sent(false),	m_bone_position_sent(false),	m_attachment_parent_id(0),	m_attachment_sent(false),	// public	m_moved(false),	m_inventory_not_sent(false),	m_hp_not_sent(false),	m_breath_not_sent(false),	m_wielded_item_not_sent(false),	m_physics_override_speed(1),	m_physics_override_jump(1),	m_physics_override_gravity(1),	m_physics_override_sneak(true),	m_physics_override_sneak_glitch(true),	m_physics_override_sent(false){	assert(m_player);	assert(m_peer_id != 0);	setBasePosition(m_player->getPosition());	m_inventory = &m_player->inventory;	m_armor_groups["fleshy"] = 100;	m_prop.hp_max = PLAYER_MAX_HP;	m_prop.physical = false;	m_prop.weight = 75;	m_prop.collisionbox = core::aabbox3d<f32>(-1/3.,-1.0,-1/3., 1/3.,1.0,1/3.);	// start of default appearance, this should be overwritten by LUA	m_prop.visual = "upright_sprite";	m_prop.visual_size = v2f(1, 2);	m_prop.textures.clear();	m_prop.textures.push_back("player.png");	m_prop.textures.push_back("player_back.png");	m_prop.colors.clear();	m_prop.colors.push_back(video::SColor(255, 255, 255, 255));	m_prop.spritediv = v2s16(1,1);	// end of default appearance	m_prop.is_visible = true;	m_prop.makes_footstep_sound = true;}
开发者ID:Adam445,项目名称:minetest,代码行数:59,


示例8: v3s16

void WeatherParticles::render() {	core::list<v2s16> emitters_to_delete;	scene::ISceneManager *smgr = m_device->getSceneManager();	for (s16 zi = -m_particle_radius_i; zi < m_particle_radius_i; zi++) {		if(zi < -(m_particle_radius_i/3) || zi > (m_particle_radius_i/3))			zi++;		for (s16 xi = -m_particle_radius_i; xi < m_particle_radius_i; xi++) {			if(xi < -(m_particle_radius_i/3) || xi > (m_particle_radius_i/3))						xi++;			v3s16 pos = v3s16(m_camera_pos.X / BS, m_camera_pos.Y / BS,					m_camera_pos.Z / BS);			pos.X = pos.X + xi;			pos.Z = pos.Z + zi;			pos.Y = traceGroundLevel(pos);			pos.Y += 1;			if (m_emitter_map.find(v2s16(pos.X, pos.Z)) == 0) {				if(pos.Y >= 100)					continue;				m_emitter_map.insert(						v2s16(pos.X, pos.Z),						new WEmitter(smgr->getRootSceneNode(), smgr, -1, pos,								100-pos.Y));			} else {			}		}	}	core::map<v2s16, WEmitter*>::Iterator ei;	ei = m_emitter_map.getIterator();	for (; ei.atEnd() == false; ei++) {		if (ei.getNode()->getKey().X < (m_camera_pos.X / BS				- m_particle_radius_i) || ei.getNode()->getKey().X				> (m_camera_pos.X / BS + m_particle_radius_i)				|| ei.getNode()->getKey().Y < (m_camera_pos.Z / BS						- m_particle_radius_i - 1) || ei.getNode()->getKey().Y				> (m_camera_pos.Z / BS + m_particle_radius_i)) {			emitters_to_delete.push_back(ei.getNode()->getKey());		}	}	removeEmitters(emitters_to_delete);}
开发者ID:TeddyDesTodes,项目名称:minetest-delta,代码行数:46,


示例9: v2s16

bool EmergeManager::isBlockUnderground(v3s16 blockpos){#if 0	v2s16 p = v2s16((blockpos.X * MAP_BLOCKSIZE) + MAP_BLOCKSIZE / 2,					(blockpos.Y * MAP_BLOCKSIZE) + MAP_BLOCKSIZE / 2);	int ground_level = getGroundLevelAtPoint(p);	return blockpos.Y * (MAP_BLOCKSIZE + 1) <= min(water_level, ground_level);#endif	// Use a simple heuristic; the above method is wildly inaccurate anyway.	return blockpos.Y * (MAP_BLOCKSIZE + 1) <= params.water_level;}
开发者ID:viphotman,项目名称:minetest,代码行数:12,


示例10: n_dirt_with_grass

void MapgenV6::growGrass() // Add surface nodes{	MapNode n_dirt_with_grass(c_dirt_with_grass);	MapNode n_dirt_with_snow(c_dirt_with_snow);	MapNode n_snowblock(c_snowblock);	MapNode n_snow(c_snow);	v3s16 em = vm->m_area.getExtent();	u32 index = 0;	for (s16 z = full_node_min.Z; z <= full_node_max.Z; z++)	for (s16 x = full_node_min.X; x <= full_node_max.X; x++, index++) {		// Find the lowest surface to which enough light ends up to make		// grass grow.  Basically just wait until not air and not leaves.		s16 surface_y = 0;		{			u32 i = vm->m_area.index(x, node_max.Y, z);			s16 y;			// Go to ground level			for (y = node_max.Y; y >= full_node_min.Y; y--) {				MapNode &n = vm->m_data[i];				if (ndef->get(n).param_type != CPT_LIGHT ||						ndef->get(n).liquid_type != LIQUID_NONE ||						n.getContent() == c_ice)					break;				vm->m_area.add_y(em, i, -1);			}			surface_y = (y >= full_node_min.Y) ? y : full_node_min.Y;		}		BiomeV6Type bt = getBiome(index, v2s16(x, z));		u32 i = vm->m_area.index(x, surface_y, z);		content_t c = vm->m_data[i].getContent();		if (surface_y >= water_level - 20) {			if (bt == BT_TAIGA && c == c_dirt) {				vm->m_data[i] = n_snowblock;				vm->m_area.add_y(em, i, -1);				vm->m_data[i] = n_dirt_with_snow;			} else if (bt == BT_TUNDRA) {				if (c == c_dirt) {					vm->m_data[i] = n_dirt_with_snow;				} else if (c == c_stone && surface_y < node_max.Y) {					vm->m_area.add_y(em, i, 1);					vm->m_data[i] = n_snow;				}			} else if (c == c_dirt) {				vm->m_data[i] = n_dirt_with_grass;			}		}	}}
开发者ID:4aiman,项目名称:Magichet-stable,代码行数:50,


示例11: UnitSAO

PlayerSAO::PlayerSAO(ServerEnvironment *env_, RemotePlayer *player_, u16 peer_id_,		bool is_singleplayer):	UnitSAO(env_, v3f(0,0,0)),	m_player(player_),	m_peer_id(peer_id_),	m_inventory(NULL),	m_damage(0),	m_last_good_position(0,0,0),	m_time_from_last_teleport(0),	m_time_from_last_punch(0),	m_nocheat_dig_pos(32767, 32767, 32767),	m_nocheat_dig_time(0),	m_wield_index(0),	m_position_not_sent(false),	m_is_singleplayer(is_singleplayer),	m_breath(PLAYER_MAX_BREATH),	m_pitch(0),	m_fov(0),	m_wanted_range(0),	m_extended_attributes_modified(false),	// public	m_physics_override_speed(1),	m_physics_override_jump(1),	m_physics_override_gravity(1),	m_physics_override_sneak(true),	m_physics_override_sneak_glitch(false),	m_physics_override_new_move(true),	m_physics_override_sent(false){	assert(m_peer_id != 0);	// pre-condition	m_prop.hp_max = PLAYER_MAX_HP;	m_prop.physical = false;	m_prop.weight = 75;	m_prop.collisionbox = aabb3f(-0.3f, -1.0f, -0.3f, 0.3f, 0.75f, 0.3f);	// start of default appearance, this should be overwritten by LUA	m_prop.visual = "upright_sprite";	m_prop.visual_size = v2f(1, 2);	m_prop.textures.clear();	m_prop.textures.push_back("player.png");	m_prop.textures.push_back("player_back.png");	m_prop.colors.clear();	m_prop.colors.push_back(video::SColor(255, 255, 255, 255));	m_prop.spritediv = v2s16(1,1);	// end of default appearance	m_prop.is_visible = true;	m_prop.makes_footstep_sound = true;	m_hp = PLAYER_MAX_HP;}
开发者ID:MultiCraftProject,项目名称:MultiCraft,代码行数:49,


示例12: content_features

s16 WeatherParticles::traceGroundLevel(v3s16 p) {	//@TODO needs cachepurging	if (m_heightmap.find(v2s16(p.X, p.Z)) > 0) {		return m_heightmap.find(v2s16(p.X, p.Z))->getValue();	}	s16 y = p.Y + 100;	if (y > 100)		y = 100;	bool isair = true;	do {		y--;		try {			isair					= content_features(m_client->getNode(v3s16(p.X, y, p.Z)).d).air_equivalent;		} catch (InvalidPositionException &e) {		}		if (y < p.Y - 100)			break;	} while (isair);	m_heightmap.insert(v2s16(p.X, p.Z), y);	//dstream << y << std::endl;	return y;}
开发者ID:TeddyDesTodes,项目名称:minetest-delta,代码行数:24,


示例13: os

void TestSerialization::testStreamWrite(){	std::ostringstream os(std::ios_base::binary);	std::string data;	writeU8(os, 0x11);	writeU16(os, 0x2233);	writeU32(os, 0x44556677);	writeU64(os, 0x8899AABBCCDDEEFF);	writeS8(os, -128);	writeS16(os, 30000);	writeS32(os, -6);	writeS64(os, -43);	writeF1000(os, 53.53467f);	writeF1000(os, -300000.32f);	writeF1000(os, F1000_MIN);	writeF1000(os, F1000_MAX);	os << serializeString("foobar!");	data = os.str();	UASSERT(data.size() < sizeof(test_serialized_data));	UASSERT(!memcmp(&data[0], test_serialized_data, data.size()));	writeV2S16(os, v2s16(500, 500));	writeV3S16(os, v3s16(4207, 604, -30));	writeV2S32(os, v2s32(1920, 1080));	writeV3S32(os, v3s32(-400, 6400054, 290549855));	writeV2F1000(os, v2f(500.65661f, 350.34567f));	os << serializeWideString(L"/x02~woof~/x5455");	writeV3F1000(os, v3f(500, 10024.2f, -192.54f));	writeARGB8(os, video::SColor(255, 128, 50, 128));	os << serializeLongString("some longer string here");	writeU16(os, 0xF00D);	data = os.str();	UASSERT(data.size() == sizeof(test_serialized_data));	UASSERT(!memcmp(&data[0], test_serialized_data, sizeof(test_serialized_data)));}
开发者ID:MultiCraftProject,项目名称:MultiCraft,代码行数:45,


示例14: ServerActiveObject

PlayerSAO::PlayerSAO(ServerEnvironment *env_, Player *player_, u16 peer_id_,		const std::set<std::string> &privs, bool is_singleplayer):	ServerActiveObject(env_, v3f(0,0,0)),	m_player(player_),	m_peer_id(peer_id_),	m_inventory(NULL),	m_last_good_position(0,0,0),	m_last_good_position_age(0),	m_time_from_last_punch(0),	m_nocheat_dig_pos(32767, 32767, 32767),	m_nocheat_dig_time(0),	m_wield_index(0),	m_position_not_sent(false),	m_armor_groups_sent(false),	m_properties_sent(true),	m_privs(privs),	m_is_singleplayer(is_singleplayer),	// public	m_teleported(false),	m_inventory_not_sent(false),	m_hp_not_sent(false),	m_wielded_item_not_sent(false){	assert(m_player);	assert(m_peer_id != 0);	setBasePosition(m_player->getPosition());	m_inventory = &m_player->inventory;	m_armor_groups["choppy"] = 2;	m_armor_groups["fleshy"] = 3;	m_prop.hp_max = PLAYER_MAX_HP;	m_prop.physical = false;	m_prop.weight = 75;	m_prop.collisionbox = core::aabbox3d<f32>(-1/3.,-1.0,-1/3., 1/3.,1.0,1/3.);	m_prop.visual = "upright_sprite";	m_prop.visual_size = v2f(1, 2);	m_prop.textures.clear();	m_prop.textures.push_back("player.png");	m_prop.textures.push_back("player_back.png");	m_prop.spritediv = v2s16(1,1);	m_prop.is_visible = (getHP() != 0);	m_prop.makes_footstep_sound = true;}
开发者ID:AMDmi3,项目名称:minetest,代码行数:43,


示例15: n_air

int MapgenV6::generateGround(){	//TimeTaker timer1("Generating ground level");	MapNode n_air(CONTENT_AIR), n_water_source(c_water_source);	MapNode n_stone(c_stone), n_desert_stone(c_desert_stone);	MapNode n_ice(c_ice);	int stone_surface_max_y = -MAP_GENERATION_LIMIT;	u32 index = 0;	for (s16 z = node_min.Z; z <= node_max.Z; z++)	for (s16 x = node_min.X; x <= node_max.X; x++, index++) {		// Surface height		s16 surface_y = (s16)baseTerrainLevelFromMap(index);		// Log it		if (surface_y > stone_surface_max_y)			stone_surface_max_y = surface_y;		BiomeV6Type bt = getBiome(v2s16(x, z));		// Fill ground with stone		v3s16 em = vm->m_area.getExtent();		u32 i = vm->m_area.index(x, node_min.Y, z);		for (s16 y = node_min.Y; y <= node_max.Y; y++) {			if (vm->m_data[i].getContent() == CONTENT_IGNORE) {				if (y <= surface_y) {					vm->m_data[i] = (y >= DESERT_STONE_BASE							&& bt == BT_DESERT) ?						n_desert_stone : n_stone;				} else if (y <= water_level) {					vm->m_data[i] = (y >= ICE_BASE							&& bt == BT_TUNDRA) ?						n_ice : n_water_source;				} else {					vm->m_data[i] = n_air;				}			}			vm->m_area.add_y(em, i, 1);		}	}	return stone_surface_max_y;}
开发者ID:4aiman,项目名称:Magichet-stable,代码行数:43,


示例16: datastr

void TestSerialization::testStreamRead(){	std::string datastr(		(const char *)test_serialized_data,		sizeof(test_serialized_data));	std::istringstream is(datastr, std::ios_base::binary);	UASSERT(readU8(is) == 0x11);	UASSERT(readU16(is) == 0x2233);	UASSERT(readU32(is) == 0x44556677);	UASSERT(readU64(is) == 0x8899AABBCCDDEEFF);	UASSERT(readS8(is) == -128);	UASSERT(readS16(is) == 30000);	UASSERT(readS32(is) == -6);	UASSERT(readS64(is) == -43);	UASSERT(readF1000(is) == 53.534f);	UASSERT(readF1000(is) == -300000.32f);	UASSERT(readF1000(is) == F1000_MIN);	UASSERT(readF1000(is) == F1000_MAX);	UASSERT(deSerializeString(is) == "foobar!");	UASSERT(readV2S16(is) == v2s16(500, 500));	UASSERT(readV3S16(is) == v3s16(4207, 604, -30));	UASSERT(readV2S32(is) == v2s32(1920, 1080));	UASSERT(readV3S32(is) == v3s32(-400, 6400054, 290549855));	UASSERT(readV2F1000(is) == v2f(500.656f, 350.345f));	UASSERT(deSerializeWideString(is) == L"/x02~woof~/x5455");	UASSERT(readV3F1000(is) == v3f(500, 10024.2f, -192.54f));	UASSERT(readARGB8(is) == video::SColor(255, 128, 50, 128));	UASSERT(deSerializeLongString(is) == "some longer string here");	UASSERT(is.rdbuf()->in_avail() == 2);	UASSERT(readU16(is) == 0xF00D);	UASSERT(is.rdbuf()->in_avail() == 0);}
开发者ID:MultiCraftProject,项目名称:MultiCraft,代码行数:41,


示例17: findGroundLevel

void Mapgen::updateHeightmap(v3s16 nmin, v3s16 nmax) {	if (!heightmap)		return;	//TimeTaker t("Mapgen::updateHeightmap", NULL, PRECISION_MICRO);	int index = 0;	for (s16 z = nmin.Z; z <= nmax.Z; z++) {		for (s16 x = nmin.X; x <= nmax.X; x++, index++) {			s16 y = findGroundLevel(v2s16(x, z), nmin.Y, nmax.Y);			// if the values found are out of range, trust the old heightmap			if (y == nmax.Y && heightmap[index] > nmax.Y)				continue;			if (y == nmin.Y - 1 && heightmap[index] < nmin.Y)				continue;			heightmap[index] = y;		}	}	//printf("updateHeightmap: %dus/n", t.stop());}
开发者ID:Nate-Devv,项目名称:freeminer,代码行数:21,


示例18: n_air

int MapgenV6::generateGround() {	//TimeTaker timer1("Generating ground level");	MapNode n_air(CONTENT_AIR), n_water_source(c_water_source);	MapNode n_stone(c_stone), n_desert_stone(c_desert_stone);	MapNode n_ice(c_ice);	int stone_surface_max_y = -MAP_GENERATION_LIMIT;	u32 index = 0;		for (s16 z = node_min.Z; z <= node_max.Z; z++)	for (s16 x = node_min.X; x <= node_max.X; x++, index++) {		// Surface height		s16 surface_y = (s16)baseTerrainLevelFromMap(index);				// Log it		if (surface_y > stone_surface_max_y)			stone_surface_max_y = surface_y;		BiomeType bt = getBiome(index, v2s16(x, z));				// Fill ground with stone		v3s16 em = vm->m_area.getExtent();		u32 i = vm->m_area.index(x, node_min.Y, z);		for (s16 y = node_min.Y; y <= node_max.Y; y++) {			if (vm->m_data[i].getContent() == CONTENT_IGNORE) {				if (y <= surface_y) {					vm->m_data[i] = (y > water_level - surface_y && bt == BT_DESERT) ? 						n_desert_stone : n_stone;				} else if (y <= water_level) {					s16 heat = emerge->env->m_use_weather ? emerge->env->getServerMap().updateBlockHeat(emerge->env, v3s16(x,y,z)) : 0;					vm->m_data[i] = (heat < 0 && y > heat/3) ? n_ice : n_water_source;				} else {					vm->m_data[i] = n_air;				}			}			vm->m_area.add_y(em, i, 1);		}	}		return stone_surface_max_y;}
开发者ID:jojoa1997,项目名称:freeminer,代码行数:40,


示例19: putU8

void TestSerialization::testVecPut(){	std::vector<u8> buf;	putU8(&buf, 0x11);	putU16(&buf, 0x2233);	putU32(&buf, 0x44556677);	putU64(&buf, 0x8899AABBCCDDEEFF);	putS8(&buf, -128);	putS16(&buf, 30000);	putS32(&buf, -6);	putS64(&buf, -43);	putF1000(&buf, 53.53467f);	putF1000(&buf, -300000.32f);	putF1000(&buf, F1000_MIN);	putF1000(&buf, F1000_MAX);	putString(&buf, "foobar!");	putV2S16(&buf, v2s16(500, 500));	putV3S16(&buf, v3s16(4207, 604, -30));	putV2S32(&buf, v2s32(1920, 1080));	putV3S32(&buf, v3s32(-400, 6400054, 290549855));	putV2F1000(&buf, v2f(500.65661f, 350.34567f));	putWideString(&buf, L"/x02~woof~/x5455");	putV3F1000(&buf, v3f(500, 10024.2f, -192.54f));	putARGB8(&buf, video::SColor(255, 128, 50, 128));	putLongString(&buf, "some longer string here");	putU16(&buf, 0xF00D);	UASSERT(buf.size() == sizeof(test_serialized_data));	UASSERT(!memcmp(&buf[0], test_serialized_data, sizeof(test_serialized_data)));}
开发者ID:MultiCraftProject,项目名称:MultiCraft,代码行数:39,


示例20: pr

void MapgenV6::addDirtGravelBlobs() {	if (getBiome(v2s16(node_min.X, node_min.Z)) != BT_NORMAL)		return;		PseudoRandom pr(blockseed + 983);	for (int i = 0; i < volume_nodes/10/10/10; i++) {		bool only_fill_cave = (myrand_range(0,1) != 0);		v3s16 size(			pr.range(1, 8),			pr.range(1, 8),			pr.range(1, 8)		);		v3s16 p0(			pr.range(node_min.X, node_max.X) - size.X / 2,			pr.range(node_min.Y, node_max.Y) - size.Y / 2,			pr.range(node_min.Z, node_max.Z) - size.Z / 2		);				MapNode n1((p0.Y > -32 && !pr.range(0, 1)) ? c_dirt : c_gravel);		for (int z1 = 0; z1 < size.Z; z1++)		for (int y1 = 0; y1 < size.Y; y1++)		for (int x1 = 0; x1 < size.X; x1++) {			v3s16 p = p0 + v3s16(x1, y1, z1);			u32 i = vm->m_area.index(p);			if (!vm->m_area.contains(i))				continue;			// Cancel if not stone and not cave air			if (vm->m_data[i].getContent() != c_stone &&				!(vm->m_flags[i] & VMANIP_FLAG_CAVE))				continue;			if (only_fill_cave && !(vm->m_flags[i] & VMANIP_FLAG_CAVE))				continue;			vm->m_data[i] = n1;		}	}}
开发者ID:jojoa1997,项目名称:freeminer,代码行数:36,


示例21: UnitSAO

PlayerSAO::PlayerSAO(ServerEnvironment *env_, RemotePlayer *player_, session_t peer_id_,		bool is_singleplayer):	UnitSAO(env_, v3f(0,0,0)),	m_player(player_),	m_peer_id(peer_id_),	m_is_singleplayer(is_singleplayer){	assert(m_peer_id != 0);	// pre-condition	m_prop.hp_max = PLAYER_MAX_HP_DEFAULT;	m_prop.breath_max = PLAYER_MAX_BREATH_DEFAULT;	m_prop.physical = false;	m_prop.weight = 75;	m_prop.collisionbox = aabb3f(-0.3f, 0.0f, -0.3f, 0.3f, 1.77f, 0.3f);	m_prop.selectionbox = aabb3f(-0.3f, 0.0f, -0.3f, 0.3f, 1.77f, 0.3f);	m_prop.pointable = true;	// Start of default appearance, this should be overwritten by Lua	m_prop.visual = "upright_sprite";	m_prop.visual_size = v2f(1, 2);	m_prop.textures.clear();	m_prop.textures.emplace_back("player.png");	m_prop.textures.emplace_back("player_back.png");	m_prop.colors.clear();	m_prop.colors.emplace_back(255, 255, 255, 255);	m_prop.spritediv = v2s16(1,1);	m_prop.eye_height = 1.625f;	// End of default appearance	m_prop.is_visible = true;	m_prop.backface_culling = false;	m_prop.makes_footstep_sound = true;	m_prop.stepheight = PLAYER_DEFAULT_STEPHEIGHT * BS;	m_hp = m_prop.hp_max;	m_breath = m_prop.breath_max;	// Disable zoom in survival mode using a value of 0	m_prop.zoom_fov = g_settings->getBool("creative_mode") ? 15.0f : 0.0f;}
开发者ID:Gael-de-Sailly,项目名称:minetest,代码行数:36,


示例22: grassrandom

void MapgenV6::placeTreesAndJungleGrass(){	//TimeTaker t("placeTrees");	PseudoRandom grassrandom(blockseed + 53);	content_t c_sand            = ndef->getId("mapgen_sand");	content_t c_junglegrass = ndef->getId("mapgen_junglegrass");	// if we don't have junglegrass, don't place cignore... that's bad	if (c_junglegrass == CONTENT_IGNORE)		c_junglegrass = CONTENT_AIR;	MapNode n_junglegrass(c_junglegrass);	v3s16 em = vm->m_area.getExtent();	// Divide area into parts	s16 div = 8;	s16 sidelen = central_area_size.X / div;	double area = sidelen * sidelen;	// N.B.  We must add jungle grass first, since tree leaves will	// obstruct the ground, giving us a false ground level	for (s16 z0 = 0; z0 < div; z0++)	for (s16 x0 = 0; x0 < div; x0++) {		// Center position of part of division		v2s16 p2d_center(			node_min.X + sidelen / 2 + sidelen * x0,			node_min.Z + sidelen / 2 + sidelen * z0		);		// Minimum edge of part of division		v2s16 p2d_min(			node_min.X + sidelen * x0,			node_min.Z + sidelen * z0		);		// Maximum edge of part of division		v2s16 p2d_max(			node_min.X + sidelen + sidelen * x0 - 1,			node_min.Z + sidelen + sidelen * z0 - 1		);		// Get biome at center position of part of division		BiomeV6Type bt = getBiome(v3POS(p2d_center.X, node_min.Y, p2d_center.Y));		// Amount of trees		float humidity = getHumidity(v3POS(p2d_center.X, node_max.Y, p2d_center.Y));		s32 tree_count;		if (bt == BT_JUNGLE || bt == BT_TAIGA || bt == BT_NORMAL) {			tree_count = area * getTreeAmount(p2d_center) * ((humidity + 1)/2.0);			if (bt == BT_JUNGLE)				tree_count *= 4;		} else {			tree_count = 0;		}		if (node_max.Y < water_level)			tree_count /= 2;		// Add jungle grass		if (bt == BT_JUNGLE) {			u32 grass_count = 5 * humidity * tree_count;			for (u32 i = 0; i < grass_count; i++) {				s16 x = grassrandom.range(p2d_min.X, p2d_max.X);				s16 z = grassrandom.range(p2d_min.Y, p2d_max.Y);/* wtf				int mapindex = central_area_size.X * (z - node_min.Z)								+ (x - node_min.X);				s16 y = heightmap[mapindex];*/				s16 y = findGroundLevelFull(v2s16(x, z));				if (y < water_level)					continue;				u32 vi = vm->m_area.index(x, y, z);				// place on dirt_with_grass, since we know it is exposed to sunlight				if (vm->m_data[vi].getContent() == c_dirt_with_grass) {					vm->m_area.add_y(em, vi, 1);					vm->m_data[vi] = n_junglegrass;				}			}		}		// Put trees in random places on part of division		for (s32 i = 0; i < tree_count; i++) {			s16 x = myrand_range(p2d_min.X, p2d_max.X);			s16 z = myrand_range(p2d_min.Y, p2d_max.Y);/* wtf			int mapindex = central_area_size.X * (z - node_min.Z)							+ (x - node_min.X);			s16 y = heightmap[mapindex];*/			s16 y = findGroundLevelFull(v2s16(x, z));			// Don't make a tree under water level			// Don't make a tree so high that it doesn't fit			if (y > node_max.Y - 6)				continue;			v3s16 p(x, y, z);			// Trees grow only on mud and grass and snowblock			{//.........这里部分代码省略.........
开发者ID:Wayward1,项目名称:freeminer,代码行数:101,


示例23: v3f

void ClientLauncher::speed_tests(){    // volatile to avoid some potential compiler optimisations    volatile static s16 temp16;    volatile static f32 tempf;    static v3f tempv3f1;    static v3f tempv3f2;    static std::string tempstring;    static std::string tempstring2;    tempv3f1 = v3f();    tempv3f2 = v3f();    tempstring = std::string();    tempstring2 = std::string();    {        infostream << "The following test should take around 20ms." << std::endl;        TimeTaker timer("Testing std::string speed");        const u32 jj = 10000;        for (u32 j = 0; j < jj; j++) {            tempstring = "";            tempstring2 = "";            const u32 ii = 10;            for (u32 i = 0; i < ii; i++) {                tempstring2 += "asd";            }            for (u32 i = 0; i < ii+1; i++) {                tempstring += "asd";                if (tempstring == tempstring2)                    break;            }        }    }    infostream << "All of the following tests should take around 100ms each."               << std::endl;    {        TimeTaker timer("Testing floating-point conversion speed");        tempf = 0.001;        for (u32 i = 0; i < 4000000; i++) {            temp16 += tempf;            tempf += 0.001;        }    }    {        TimeTaker timer("Testing floating-point vector speed");        tempv3f1 = v3f(1, 2, 3);        tempv3f2 = v3f(4, 5, 6);        for (u32 i = 0; i < 10000000; i++) {            tempf += tempv3f1.dotProduct(tempv3f2);            tempv3f2 += v3f(7, 8, 9);        }    }    {        TimeTaker timer("Testing std::map speed");        std::map<v2s16, f32> map1;        tempf = -324;        const s16 ii = 300;        for (s16 y = 0; y < ii; y++) {            for (s16 x = 0; x < ii; x++) {                map1[v2s16(x, y)] =  tempf;                tempf += 1;            }        }        for (s16 y = ii - 1; y >= 0; y--) {            for (s16 x = 0; x < ii; x++) {                tempf = map1[v2s16(x, y)];            }        }    }    {        infostream << "Around 5000/ms should do well here." << std::endl;        TimeTaker timer("Testing mutex speed");        JMutex m;        u32 n = 0;        u32 i = 0;        do {            n += 10000;            for (; i < n; i++) {                m.Lock();                m.Unlock();            }        }        // Do at least 10ms        while(timer.getTimerTime() < 10);        u32 dtime = timer.stop();        u32 per_ms = n / dtime;        infostream << "Done. " << dtime << "ms, " << per_ms << "/ms" << std::endl;    }}
开发者ID:4aiman,项目名称:MultiCraft,代码行数:98,


示例24: SpeedTests

void SpeedTests(){	{		dstream<<"The following test should take around 20ms."<<std::endl;		TimeTaker timer("Testing std::string speed");		const u32 jj = 10000;		for(u32 j=0; j<jj; j++)		{			tempstring = "";			tempstring2 = "";			const u32 ii = 10;			for(u32 i=0; i<ii; i++){				tempstring2 += "asd";			}			for(u32 i=0; i<ii+1; i++){				tempstring += "asd";				if(tempstring == tempstring2)					break;			}		}	}		dstream<<"All of the following tests should take around 100ms each."			<<std::endl;	{		TimeTaker timer("Testing floating-point conversion speed");		tempf = 0.001;		for(u32 i=0; i<4000000; i++){			temp16 += tempf;			tempf += 0.001;		}	}		{		TimeTaker timer("Testing floating-point vector speed");		tempv3f1 = v3f(1,2,3);		tempv3f2 = v3f(4,5,6);		for(u32 i=0; i<10000000; i++){			tempf += tempv3f1.dotProduct(tempv3f2);			tempv3f2 += v3f(7,8,9);		}	}	{		TimeTaker timer("Testing core::map speed");				core::map<v2s16, f32> map1;		tempf = -324;		const s16 ii=300;		for(s16 y=0; y<ii; y++){			for(s16 x=0; x<ii; x++){				map1.insert(v2s16(x,y), tempf);				tempf += 1;			}		}		for(s16 y=ii-1; y>=0; y--){			for(s16 x=0; x<ii; x++){				tempf = map1[v2s16(x,y)];			}		}	}	{		dstream<<"Around 5000/ms should do well here."<<std::endl;		TimeTaker timer("Testing mutex speed");				JMutex m;		m.Init();		u32 n = 0;		u32 i = 0;		do{			n += 10000;			for(; i<n; i++){				m.Lock();				m.Unlock();			}		}		// Do at least 10ms		while(timer.getTime() < 10);		u32 dtime = timer.stop();		u32 per_ms = n / dtime;		dstream<<"Done. "<<dtime<<"ms, "				<<per_ms<<"/ms"<<std::endl;	}}
开发者ID:Oblomov,项目名称:minetest,代码行数:88,


示例25: v2s16

void MapgenV6::flowMud(s16 &mudflow_minpos, s16 &mudflow_maxpos){	// 340ms @cs=8	//TimeTaker timer1("flow mud");	// Iterate a few times	for (s16 k = 0; k < 3; k++) {		for (s16 z = mudflow_minpos; z <= mudflow_maxpos; z++)		for (s16 x = mudflow_minpos; x <= mudflow_maxpos; x++) {			// Invert coordinates every 2nd iteration			if (k % 2 == 0) {				x = mudflow_maxpos - (x - mudflow_minpos);				z = mudflow_maxpos - (z - mudflow_minpos);			}			// Node position in 2d			v2s16 p2d = v2s16(node_min.X, node_min.Z) + v2s16(x, z);			v3s16 em = vm->m_area.getExtent();			u32 i = vm->m_area.index(p2d.X, node_max.Y, p2d.Y);			s16 y = node_max.Y;			while (y >= node_min.Y) {			for (;; y--) {				MapNode *n = NULL;				// Find mud				for (; y >= node_min.Y; y--) {					n = &vm->m_data[i];					if (n->getContent() == c_dirt ||							n->getContent() == c_dirt_with_grass ||							n->getContent() == c_gravel)						break;					vm->m_area.add_y(em, i, -1);				}				// Stop if out of area				//if(vmanip.m_area.contains(i) == false)				if (y < node_min.Y)					break;				if (n->getContent() == c_dirt ||						n->getContent() == c_dirt_with_grass) {					// Make it exactly mud					n->setContent(c_dirt);					// Don't flow it if the stuff under it is not mud					{						u32 i2 = i;						vm->m_area.add_y(em, i2, -1);						// Cancel if out of area						if (vm->m_area.contains(i2) == false)							continue;						MapNode *n2 = &vm->m_data[i2];						if (n2->getContent() != c_dirt &&								n2->getContent() != c_dirt_with_grass)							continue;					}				}				v3s16 dirs4[4] = {					v3s16(0, 0, 1), // back					v3s16(1, 0, 0), // right					v3s16(0, 0, -1), // front					v3s16(-1, 0, 0), // left				};				// Check that upper is air or doesn't exist.				// Cancel dropping if upper keeps it in place				u32 i3 = i;				vm->m_area.add_y(em, i3, 1);				if (vm->m_area.contains(i3) == true &&						ndef->get(vm->m_data[i3]).walkable)					continue;				// Drop mud on side				for(u32 di = 0; di < 4; di++) {					v3s16 dirp = dirs4[di];					u32 i2 = i;					// Move to side					vm->m_area.add_p(em, i2, dirp);					// Fail if out of area					if (vm->m_area.contains(i2) == false)						continue;					// Check that side is air					MapNode *n2 = &vm->m_data[i2];					if (ndef->get(*n2).walkable)						continue;					// Check that under side is air					vm->m_area.add_y(em, i2, -1);					if (vm->m_area.contains(i2) == false)						continue;					n2 = &vm->m_data[i2];					if (ndef->get(*n2).walkable)						continue;					// Loop further down until not air					bool dropped_to_unknown = false;					do {						vm->m_area.add_y(em, i2, -1);//.........这里部分代码省略.........
开发者ID:Wayward1,项目名称:freeminer,代码行数:101,


示例26: ps

size_t Decoration::placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax){	PseudoRandom ps(blockseed + 53);	int carea_size = nmax.X - nmin.X + 1;	// Divide area into parts	if (carea_size % sidelen) {		errorstream << "Decoration::placeDeco: chunk size is not divisible by "			"sidelen; setting sidelen to " << carea_size << std::endl;		sidelen = carea_size;	}	s16 divlen = carea_size / sidelen;	int area = sidelen * sidelen;	for (s16 z0 = 0; z0 < divlen; z0++)	for (s16 x0 = 0; x0 < divlen; x0++) {		v2s16 p2d_center( // Center position of part of division			nmin.X + sidelen / 2 + sidelen * x0,			nmin.Z + sidelen / 2 + sidelen * z0		);		v2s16 p2d_min( // Minimum edge of part of division			nmin.X + sidelen * x0,			nmin.Z + sidelen * z0		);		v2s16 p2d_max( // Maximum edge of part of division			nmin.X + sidelen + sidelen * x0 - 1,			nmin.Z + sidelen + sidelen * z0 - 1		);		// Amount of decorations		float nval = (flags & DECO_USE_NOISE) ?			NoisePerlin2D(&np, p2d_center.X, p2d_center.Y, mapseed) :			fill_ratio;		u32 deco_count = area * MYMAX(nval, 0.f);		for (u32 i = 0; i < deco_count; i++) {			s16 x = ps.range(p2d_min.X, p2d_max.X);			s16 z = ps.range(p2d_min.Y, p2d_max.Y);			int mapindex = carea_size * (z - nmin.Z) + (x - nmin.X);			s16 y = mg->heightmap ?					mg->heightmap[mapindex] :					mg->findGroundLevel(v2s16(x, z), nmin.Y, nmax.Y);			if (y < nmin.Y || y > nmax.Y ||				y < y_min  || y > y_max)				continue;			if (y + getHeight() >= mg->vm->m_area.MaxEdge.Y) {				continue;#if 0				printf("Decoration at (%d %d %d) cut off/n", x, y, z);				//add to queue				JMutexAutoLock cutofflock(cutoff_mutex);				cutoffs.push_back(CutoffData(x, y, z, height));#endif			}			if (mg->biomemap) {				std::set<u8>::iterator iter;				if (!biomes.empty()) {					iter = biomes.find(mg->biomemap[mapindex]);					if (iter == biomes.end())						continue;				}			}			v3s16 pos(x, y, z);			if (generate(mg->vm, &ps, pos))				mg->gennotify.addEvent(GENNOTIFY_DECORATION, pos, index);		}	}	return 0;}
开发者ID:maksimkurb,项目名称:minetest,代码行数:78,


示例27: main

//.........这里部分代码省略.........				errorstream << "Please specify your current backend in world.mt file:"					<< std::endl << "	backend = {sqlite3|leveldb|redis|dummy}" << std::endl;				return 1;			}			std::string backend = world_mt.get("backend");			Database *new_db;			if (backend == migrate_to) {				errorstream << "Cannot migrate: new backend is same as the old one" << std::endl;				return 1;			}			if (migrate_to == "sqlite3")				new_db = new Database_SQLite3(&(ServerMap&)server.getMap(), world_path);			#if USE_LEVELDB			else if (migrate_to == "leveldb")				new_db = new Database_LevelDB(&(ServerMap&)server.getMap(), world_path);			#endif			#if USE_REDIS			else if (migrate_to == "redis")				new_db = new Database_Redis(&(ServerMap&)server.getMap(), world_path);			#endif			else {				errorstream << "Migration to " << migrate_to << " is not supported" << std::endl;				return 1;			}			std::list<v3s16> blocks;			ServerMap &old_map = ((ServerMap&)server.getMap());			old_map.listAllLoadableBlocks(blocks);			int count = 0;			new_db->beginSave();			for (std::list<v3s16>::iterator i = blocks.begin(); i != blocks.end(); ++i) {				MapBlock *block = old_map.loadBlock(*i);				new_db->saveBlock(block);				MapSector *sector = old_map.getSectorNoGenerate(v2s16(i->X, i->Z));				sector->deleteBlock(block);				++count;				if (count % 500 == 0)					actionstream << "Migrated " << count << " blocks "						<< (100.0 * count / blocks.size()) << "% completed" << std::endl;			}			new_db->endSave();			delete new_db;			actionstream << "Successfully migrated " << count << " blocks" << std::endl;			world_mt.set("backend", migrate_to);			if(!world_mt.updateConfigFile((world_path + DIR_DELIM + "world.mt").c_str()))				errorstream<<"Failed to update world.mt!"<<std::endl;			else				actionstream<<"world.mt updated"<<std::endl;			return 0;		}		server.start(bind_addr);		// Run server		dedicated_server_loop(server, kill);		return 0;	}#ifndef SERVER // Exclude from dedicated server build	/*		More parameters	*/
开发者ID:FessWolf,项目名称:minetest,代码行数:67,


示例28: assert

void MapgenV6::makeChunk(BlockMakeData *data){	// Pre-conditions	assert(data->vmanip);	assert(data->nodedef);	assert(data->blockpos_requested.X >= data->blockpos_min.X &&		   data->blockpos_requested.Y >= data->blockpos_min.Y &&		   data->blockpos_requested.Z >= data->blockpos_min.Z);	assert(data->blockpos_requested.X <= data->blockpos_max.X &&		   data->blockpos_requested.Y <= data->blockpos_max.Y &&		   data->blockpos_requested.Z <= data->blockpos_max.Z);	this->generating = true;	this->vm   = data->vmanip;	this->ndef = data->nodedef;	// Hack: use minimum block coords for old code that assumes a single block	v3s16 blockpos_min = data->blockpos_min;	v3s16 blockpos_max = data->blockpos_max;	// Area of central chunk	node_min = blockpos_min * MAP_BLOCKSIZE;	node_max = (blockpos_max + v3s16(1, 1, 1)) * MAP_BLOCKSIZE - v3s16(1, 1, 1);	// Full allocated area	full_node_min = (blockpos_min - 1) * MAP_BLOCKSIZE;	full_node_max = (blockpos_max + 2) * MAP_BLOCKSIZE - v3s16(1, 1, 1);	central_area_size = node_max - node_min + v3s16(1, 1, 1);	assert(central_area_size.X == central_area_size.Z);	int volume_blocks = (blockpos_max.X - blockpos_min.X + 1)					  * (blockpos_max.Y - blockpos_min.Y + 1)					  * (blockpos_max.Z - blockpos_max.Z + 1);	volume_nodes = volume_blocks *		MAP_BLOCKSIZE * MAP_BLOCKSIZE * MAP_BLOCKSIZE;	// Create a block-specific seed	blockseed = get_blockseed(data->seed, full_node_min);	// Make some noise	calculateNoise();	// Maximum height of the stone surface and obstacles.	// This is used to guide the cave generation	s16 stone_surface_max_y;	// Generate general ground level to full area	stone_surface_max_y = generateGround();	// Create initial heightmap to limit caves	updateHeightmap(node_min, node_max);	const s16 max_spread_amount = MAP_BLOCKSIZE;	// Limit dirt flow area by 1 because mud is flown into neighbors.	s16 mudflow_minpos = -max_spread_amount + 1;	s16 mudflow_maxpos = central_area_size.X + max_spread_amount - 2;	// Loop this part, it will make stuff look older and newer nicely	const u32 age_loops = 2;	for (u32 i_age = 0; i_age < age_loops; i_age++) { // Aging loop		// Make caves (this code is relatively horrible)		if (flags & MG_CAVES)			generateCaves(stone_surface_max_y);		// Add mud to the central chunk		addMud();		// Flow mud away from steep edges		if (spflags & MGV6_MUDFLOW)			flowMud(mudflow_minpos, mudflow_maxpos);	}	// Update heightmap after mudflow	updateHeightmap(node_min, node_max);	// Add dungeons	if ((flags & MG_DUNGEONS) && (stone_surface_max_y >= node_min.Y)) {		DungeonParams dp;		dp.np_rarity  = nparams_dungeon_rarity;		dp.np_density = nparams_dungeon_density;		dp.np_wetness = nparams_dungeon_wetness;		dp.c_water    = c_water_source;		if (getBiome(0, v2s16(node_min.X, node_min.Z)) == BT_DESERT) {			dp.c_cobble = c_desert_stone;			dp.c_moss   = c_desert_stone;			dp.c_stair  = c_desert_stone;			dp.diagonal_dirs = true;			dp.mossratio     = 0.0;			dp.holesize      = v3s16(2, 3, 2);			dp.roomsize      = v3s16(2, 5, 2);			dp.notifytype    = GENNOTIFY_TEMPLE;		} else {			dp.c_cobble = c_cobble;			dp.c_moss   = c_mossycobble;			dp.c_stair  = c_stair_cobble;//.........这里部分代码省略.........
开发者ID:4aiman,项目名称:Magichet-stable,代码行数:101,


示例29: ps

void Decoration::placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax) {	PseudoRandom ps(blockseed + 53);	int carea_size = nmax.X - nmin.X + 1;	// Divide area into parts	if (carea_size % sidelen) {		errorstream << "Decoration::placeDeco: chunk size is not divisible by "			"sidelen; setting sidelen to " << carea_size << std::endl;		sidelen = carea_size;	}	s16 divlen = carea_size / sidelen;	int area = sidelen * sidelen;	for (s16 z0 = 0; z0 < divlen; z0++)	for (s16 x0 = 0; x0 < divlen; x0++) {		v2s16 p2d_center( // Center position of part of division			nmin.X + sidelen / 2 + sidelen * x0,			nmin.Z + sidelen / 2 + sidelen * z0		);		v2s16 p2d_min( // Minimum edge of part of division			nmin.X + sidelen * x0,			nmin.Z + sidelen * z0		);		v2s16 p2d_max( // Maximum edge of part of division			nmin.X + sidelen + sidelen * x0 - 1,			nmin.Z + sidelen + sidelen * z0 - 1		);		// Amount of decorations		float nval = np ?			NoisePerlin2D(np, p2d_center.X, p2d_center.Y, mapseed) :			fill_ratio;		u32 deco_count = area * MYMAX(nval, 0.f);		for (u32 i = 0; i < deco_count; i++) {			s16 x = ps.range(p2d_min.X, p2d_max.X);			s16 z = ps.range(p2d_min.Y, p2d_max.Y);			int mapindex = carea_size * (z - nmin.Z) + (x - nmin.X);			s16 y = mg->heightmap ?					mg->heightmap[mapindex] :					mg->findGroundLevel(v2s16(x, z), nmin.Y, nmax.Y);			if (y < nmin.Y || y > nmax.Y)				continue;			int height = getHeight();			int max_y = nmax.Y;// + MAP_BLOCKSIZE - 1;			if (y + 1 + height > max_y) {				continue;#if 0				printf("Decoration at (%d %d %d) cut off/n", x, y, z);				//add to queue				JMutexAutoLock cutofflock(cutoff_mutex);				cutoffs.push_back(CutoffData(x, y, z, height));#endif			}			if (mg->biomemap) {				std::set<u8>::iterator iter;				if (biomes.size()) {					iter = biomes.find(mg->biomemap[mapindex]);					if (iter == biomes.end())						continue;				}			}			generate(mg, &ps, max_y, v3s16(x, y, z));		}	}}
开发者ID:Nate-Devv,项目名称:freeminer,代码行数:74,


示例30: grid_speed

void FarMesh::render(){	video::IVideoDriver* driver = SceneManager->getVideoDriver();	/*if(SceneManager->getSceneNodeRenderPass() != scene::ESNRP_TRANSPARENT)		return;*/	if(SceneManager->getSceneNodeRenderPass() != scene::ESNRP_SOLID)		return;	/*if(SceneManager->getSceneNodeRenderPass() != scene::ESNRP_SKY_BOX)		return;*/	driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);		//const s16 grid_radius_i = 12;	//const float grid_size = BS*50;	const s16 grid_radius_i = m_render_range/MAP_BLOCKSIZE;	const float grid_size = BS*MAP_BLOCKSIZE;	const v2f grid_speed(-BS*0, 0);		// Position of grid noise origin in world coordinates	v2f world_grid_origin_pos_f(0,0);	// Position of grid noise origin from the camera	v2f grid_origin_from_camera_f = world_grid_origin_pos_f - m_camera_pos;	// The center point of drawing in the noise	v2f center_of_drawing_in_noise_f = -grid_origin_from_camera_f;	// The integer center point of drawing in the noise	v2s16 center_of_drawing_in_noise_i(		MYROUND(center_of_drawing_in_noise_f.X / grid_size),		MYROUND(center_of_drawing_in_noise_f.Y / grid_size)	);	// The world position of the integer center point of drawing in the noise	v2f world_center_of_drawing_in_noise_f = v2f(		center_of_drawing_in_noise_i.X * grid_size,		center_of_drawing_in_noise_i.Y * grid_size	) + world_grid_origin_pos_f;	for(s16 zi=-grid_radius_i; zi<grid_radius_i; zi++)	for(s16 xi=-grid_radius_i; xi<grid_radius_i; xi++)	{		/*// Don't draw very close to player		s16 dd = 3;		if(zi > -dd && zi < dd && xi > -dd && xi < dd)			continue;*/		v2s16 p_in_noise_i(			xi+center_of_drawing_in_noise_i.X,			zi+center_of_drawing_in_noise_i.Y		);				// If sector was drawn, don't draw it this way		if(m_client->m_env.getClientMap().sectorWasDrawn(p_in_noise_i))			continue;		/*if((p_in_noise_i.X + p_in_noise_i.Y)%2==0)			continue;*/		/*if((p_in_noise_i.X/2 + p_in_noise_i.Y/2)%2==0)			continue;*/		v2f p0 = v2f(xi,zi)*grid_size + world_center_of_drawing_in_noise_f;				/*double noise[4];		double d = 100*BS;		noise[0] = d*noise2d_perlin(				(float)(p_in_noise_i.X+0)*grid_size/BS/100,				(float)(p_in_noise_i.Y+0)*grid_size/BS/100,				m_seed, 3, 0.5);				noise[1] = d*noise2d_perlin(				(float)(p_in_noise_i.X+0)*grid_size/BS/100,				(float)(p_in_noise_i.Y+1)*grid_size/BS/100,				m_seed, 3, 0.5);				noise[2] = d*noise2d_perlin(				(float)(p_in_noise_i.X+1)*grid_size/BS/100,				(float)(p_in_noise_i.Y+1)*grid_size/BS/100,				m_seed, 3, 0.5);				noise[3] = d*noise2d_perlin(				(float)(p_in_noise_i.X+1)*grid_size/BS/100,				(float)(p_in_noise_i.Y+0)*grid_size/BS/100,				m_seed, 3, 0.5);*/				HeightPoint hps[5];		hps[0] = ground_height(m_seed, v2s16(				(p_in_noise_i.X+0)*grid_size/BS,				(p_in_noise_i.Y+0)*grid_size/BS));		hps[1] = ground_height(m_seed, v2s16(				(p_in_noise_i.X+0)*grid_size/BS,				(p_in_noise_i.Y+1)*grid_size/BS));		hps[2] = ground_height(m_seed, v2s16(				(p_in_noise_i.X+1)*grid_size/BS,				(p_in_noise_i.Y+1)*grid_size/BS));		hps[3] = ground_height(m_seed, v2s16(				(p_in_noise_i.X+1)*grid_size/BS,				(p_in_noise_i.Y+0)*grid_size/BS));		v2s16 centerpoint(				(p_in_noise_i.X+0)*grid_size/BS+MAP_BLOCKSIZE/2,				(p_in_noise_i.Y+0)*grid_size/BS+MAP_BLOCKSIZE/2);		hps[4] = ground_height(m_seed, centerpoint);		//.........这里部分代码省略.........
开发者ID:Neear,项目名称:minetest,代码行数:101,



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


C++ v2s32函数代码示例
C++ v2f函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。