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


C++ MapSector类代码示例

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


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

示例1: VersionMismatchException

ServerMapSector* ServerMapSector::deSerialize(
		std::istream &is,
		Map *parent,
		v2s16 p2d,
		std::map<v2s16, MapSector*> & sectors,
		IGameDef *gamedef
	)
{
	/*
		[0] u8 serialization version
		+ heightmap data
	*/

	/*
		Read stuff
	*/
	
	// Read version
	u8 version = SER_FMT_VER_INVALID;
	is.read((char*)&version, 1);
	
	if(!ser_ver_supported(version))
		throw VersionMismatchException("ERROR: MapSector format not supported");
	
	/*
		Add necessary reading stuff here
	*/
	
	/*
		Get or create sector
	*/

	ServerMapSector *sector = NULL;

	std::map<v2s16, MapSector*>::iterator n = sectors.find(p2d);

	if(n != sectors.end())
	{
		dstream<<"WARNING: deSerializing existent sectors not supported "
				"at the moment, because code hasn't been tested."
				<<std::endl;

		MapSector *sector = n->second;
		assert(sector->getId() == MAPSECTOR_SERVER);
		return (ServerMapSector*)sector;
	}
	else
	{
		sector = new ServerMapSector(parent, p2d, gamedef);
		sectors[p2d] = sector;
	}

	/*
		Set stuff in sector
	*/

	// Nothing here

	return sector;
}
开发者ID:DaErHuo,项目名称:minetest,代码行数:60,代码来源:mapsector.cpp

示例2: problemDesc

	virtual string problemDesc(unsigned index)
	{
		if (index >= sectors.size())
			return "No unknown flats found";

		MapSector* sector = sectors[index];
		if (floor[index])
			return S_FMT("Sector %d has unknown floor texture \"%s\"", sector->getIndex(), sector->getFloorTex());
		else
			return S_FMT("Sector %d has unknown ceiling texture \"%s\"", sector->getIndex(), sector->getCeilingTex());
	}
开发者ID:DemolisherOfSouls,项目名称:SLADE,代码行数:11,代码来源:MapChecks.cpp

示例3: if

/* QuickTextureOverlay3d::applyTexture
 * Applies the current texture to all selected walls/flats
 *******************************************************************/
void QuickTextureOverlay3d::applyTexture()
{
	// Check editor is associated
	if (!editor)
		return;

	// Get selection/hilight
	auto& selection = editor->selection();

	// Go through items
	if (!selection.empty())
	{
		for (unsigned a = 0; a < selection.size(); a++)
		{
			// Thing (skip)
			if (selection[a].type == MapEditor::ItemType::Thing)
				continue;

			// Floor
			else if (selection[a].type == MapEditor::ItemType::Floor && (sel_type == 0 || sel_type == 2))
			{
				MapSector* sector = editor->map().getSector(selection[a].index);
				if (sector) sector->setStringProperty("texturefloor", textures[current_index].name);
			}

			// Ceiling
			else if (selection[a].type == MapEditor::ItemType::Ceiling && (sel_type == 0 || sel_type == 2))
			{
				MapSector* sector = editor->map().getSector(selection[a].index);
				if (sector) sector->setStringProperty("textureceiling", textures[current_index].name);
			}

			// Wall
			else if (sel_type > 0)
			{
				MapSide* side = editor->map().getSide(selection[a].index);
				if (side)
				{
					// Upper
					if (selection[a].type == MapEditor::ItemType::WallTop)
						side->setStringProperty("texturetop", textures[current_index].name);
					// Middle
					else if (selection[a].type == MapEditor::ItemType::WallMiddle)
						side->setStringProperty("texturemiddle", textures[current_index].name);
					// Lower
					else if (selection[a].type == MapEditor::ItemType::WallBottom)
						side->setStringProperty("texturebottom", textures[current_index].name);
				}
			}
		}
	}
}
开发者ID:Talon1024,项目名称:SLADE,代码行数:55,代码来源:QuickTextureOverlay3d.cpp

示例4: fixText

	string fixText(unsigned fix_type, unsigned index)
	{
		if (fix_type == 0)
		{
			if (index >= invalid_refs.size())
				return "Fix Sector reference";

			MapSector* sector = invalid_refs[index].sector;
			if (sector)
				return S_FMT("Set to Sector #%d", sector->getIndex());
			else
				return S_FMT("Clear Sector");
		}

		return "";
	}
开发者ID:DemolisherOfSouls,项目名称:SLADE,代码行数:16,代码来源:MapChecks.cpp

示例5: applyVavoomSlopeThing

void MapSpecials::applyVavoomSlopeThing(SLADEMap* map, MapThing* thing)
{
	int target_idx = map->sectorAt(thing->point());
	if (target_idx < 0)
		return;
	MapSector* target = map->getSector(target_idx);

	int tid = thing->intProperty("id");
	vector<MapLine*> lines;
	target->getLines(lines);

	// TODO unclear if this is the same order that ZDoom would go through the
	// lines, which matters if two lines have the same first arg
	for (unsigned a = 0; a < lines.size(); a++)
	{
		if (tid != lines[a]->intProperty("arg0"))
			continue;

		// Vavoom things use the plane defined by the thing and its two
		// endpoints, based on the sector's original (flat) plane and treating
		// the thing's height as absolute
		if (MathStuff::distanceToLineFast(thing->point(), lines[a]->seg()) == 0)
		{
			LOG_MESSAGE(1, "Vavoom thing %d lies directly on its target line %d", thing->getIndex(), a);
			return;
		}

		short height = target->getPlaneHeight<p>();
		fpoint3_t p1(thing->xPos(), thing->yPos(), thing->floatProperty("height"));
		fpoint3_t p2(lines[a]->x1(), lines[a]->y1(), height);
		fpoint3_t p3(lines[a]->x2(), lines[a]->y2(), height);

		target->setPlane<p>(MathStuff::planeFromTriangle(p1, p2, p3));
		return;
	}

	LOG_MESSAGE(1, "Vavoom thing %d has no matching line with first arg %d", thing->getIndex(), tid);
}
开发者ID:Talon1024,项目名称:SLADE,代码行数:38,代码来源:MapSpecials.cpp

示例6: MapSector

/* MapArchClipboardItem::addLines
 * Copies [lines] and all related map structures
 *******************************************************************/
void MapArchClipboardItem::addLines(vector<MapLine*> lines)
{
    // Get sectors and sides to copy
    vector<MapSector*> copy_sectors;
    vector<MapSide*> copy_sides;
    for (unsigned a = 0; a < lines.size(); a++)
    {
        MapSide* s1 = lines[a]->s1();
        MapSide* s2 = lines[a]->s2();

        // Front side
        if (s1)
        {
            copy_sides.push_back(s1);
            if (std::find(copy_sectors.begin(), copy_sectors.end(), s1->getSector()) == copy_sectors.end())
                copy_sectors.push_back(s1->getSector());
        }

        // Back side
        if (s2)
        {
            copy_sides.push_back(s2);
            if (std::find(copy_sectors.begin(), copy_sectors.end(), s2->getSector()) == copy_sectors.end())
                copy_sectors.push_back(s2->getSector());
        }
    }

    // Copy sectors
    for (unsigned a = 0; a < copy_sectors.size(); a++)
    {
        MapSector* copy = new MapSector(NULL);
        copy->copy(copy_sectors[a]);
        sectors.push_back(copy);
    }

    // Copy sides
    for (unsigned a = 0; a < copy_sides.size(); a++)
    {
        MapSide* copy = new MapSide();
        copy->copy(copy_sides[a]);

        // Set relative sector
        for (unsigned b = 0; b < copy_sectors.size(); b++)
        {
            if (copy_sides[a]->getSector() == copy_sectors[b])
            {
                copy->setSector(sectors[b]);
                break;
            }
        }

        sides.push_back(copy);
    }

    // Get vertices to copy (and determine midpoint)
    double min_x = 9999999;
    double max_x = -9999999;
    double min_y = 9999999;
    double max_y = -9999999;
    vector<MapVertex*> copy_verts;
    for (unsigned a = 0; a < lines.size(); a++)
    {
        MapVertex* v1 = lines[a]->v1();
        MapVertex* v2 = lines[a]->v2();

        // Add vertices to copy list
        if (std::find(copy_verts.begin(), copy_verts.end(), v1) == copy_verts.end())
            copy_verts.push_back(v1);
        if (std::find(copy_verts.begin(), copy_verts.end(), v2) == copy_verts.end())
            copy_verts.push_back(v2);

        // Update min/max
        if (v1->xPos() < min_x) min_x = v1->xPos();
        if (v1->xPos() > max_x) max_x = v1->xPos();
        if (v1->yPos() < min_y) min_y = v1->yPos();
        if (v1->yPos() > max_y) max_y = v1->yPos();
        if (v2->xPos() < min_x) min_x = v2->xPos();
        if (v2->xPos() > max_x) max_x = v2->xPos();
        if (v2->yPos() < min_y) min_y = v2->yPos();
        if (v2->yPos() > max_y) max_y = v2->yPos();
    }

    // Determine midpoint
    double mid_x = min_x + ((max_x - min_x) * 0.5);
    double mid_y = min_y + ((max_y - min_y) * 0.5);
    this->midpoint.set(mid_x, mid_y);

    // Copy vertices
    for (unsigned a = 0; a < copy_verts.size(); a++)
    {
        MapVertex* copy = new MapVertex(copy_verts[a]->xPos() - mid_x, copy_verts[a]->yPos() - mid_y);
        copy->copy(copy_verts[a]);
        vertices.push_back(copy);
    }

    // Copy lines
    for (unsigned a = 0; a < lines.size(); a++)
//.........这里部分代码省略.........
开发者ID:Blzut3,项目名称:SLADE,代码行数:101,代码来源:Clipboard.cpp

示例7: LOG_MESSAGE

/* MapSpecials::processEternitySlopes
* Process Eternity slope specials
*******************************************************************/
void MapSpecials::processEternitySlopes(SLADEMap* map)
{
	// Eternity plans on having a few slope mechanisms,
	// which must be evaluated in a specific order.
	//  - Plane_Align, in line order
	//  - vertex triangle slopes, in sector order (wip)
	//  - Plane_Copy, in line order

	// First things first: reset every sector to flat planes
	for(unsigned a = 0; a < map->nSectors(); a++)
	{
		MapSector* target = map->getSector(a);
		target->setPlane<FLOOR_PLANE>(plane_t::flat(target->getPlaneHeight<FLOOR_PLANE>()));
		target->setPlane<CEILING_PLANE>(plane_t::flat(target->getPlaneHeight<CEILING_PLANE>()));
	}

	// Plane_Align (line special 181)
	for(unsigned a = 0; a < map->nLines(); a++)
	{
		MapLine* line = map->getLine(a);
		if(line->getSpecial() != 181)
			continue;

		MapSector* sector1 = line->frontSector();
		MapSector* sector2 = line->backSector();
		if(!sector1 || !sector2)
		{
			LOG_MESSAGE(1, "Ignoring Plane_Align on one-sided line %d", line->getIndex());
			continue;
		}
		if(sector1 == sector2)
		{
			LOG_MESSAGE(1, "Ignoring Plane_Align on line %d, which has the same sector on both sides", line->getIndex());
			continue;
		}

		int floor_arg = line->intProperty("arg0");
		if(floor_arg == 1)
			applyPlaneAlign<FLOOR_PLANE>(line, sector1, sector2);
		else if(floor_arg == 2)
			applyPlaneAlign<FLOOR_PLANE>(line, sector2, sector1);

		int ceiling_arg = line->intProperty("arg1");
		if(ceiling_arg == 1)
			applyPlaneAlign<CEILING_PLANE>(line, sector1, sector2);
		else if(ceiling_arg == 2)
			applyPlaneAlign<CEILING_PLANE>(line, sector2, sector1);
	}

	// Plane_Copy
	vector<MapSector*> sectors;
	for(unsigned a = 0; a < map->nLines(); a++)
	{
		MapLine* line = map->getLine(a);
		if(line->getSpecial() != 118)
			continue;

		int tag;
		MapSector* front = line->frontSector();
		MapSector* back = line->backSector();
		if((tag = line->intProperty("arg0")))
		{
			sectors.clear();
			map->getSectorsByTag(tag, sectors);
			if(sectors.size())
				front->setFloorPlane(sectors[0]->getFloorPlane());
		}
		if((tag = line->intProperty("arg1")))
		{
			sectors.clear();
			map->getSectorsByTag(tag, sectors);
			if(sectors.size())
				front->setCeilingPlane(sectors[0]->getCeilingPlane());
		}
		if((tag = line->intProperty("arg2")))
		{
			sectors.clear();
			map->getSectorsByTag(tag, sectors);
			if(sectors.size())
				back->setFloorPlane(sectors[0]->getFloorPlane());
		}
		if((tag = line->intProperty("arg3")))
		{
			sectors.clear();
			map->getSectorsByTag(tag, sectors);
			if(sectors.size())
				back->setCeilingPlane(sectors[0]->getCeilingPlane());
		}

		// The fifth "share" argument copies from one side of the line to the
		// other
		if(front && back)
		{
			int share = line->intProperty("arg4");

			if((share & 3) == 1)
				back->setFloorPlane(front->getFloorPlane());
//.........这里部分代码省略.........
开发者ID:Talon1024,项目名称:SLADE,代码行数:101,代码来源:MapSpecials.cpp

示例8: p2d

MapBlock* Database_Dummy::loadBlock(v3s16 blockpos)
{
	v2s16 p2d(blockpos.X, blockpos.Z);

        if(m_database.count(getBlockAsInteger(blockpos))) {
                /*
                        Make sure sector is loaded
                */
                MapSector *sector = srvmap->createSector(p2d);
                /*
                        Load block
                */
                std::string datastr = m_database[getBlockAsInteger(blockpos)];
//                srvmap->loadBlock(&datastr, blockpos, sector, false);

		try {
                	std::istringstream is(datastr, std::ios_base::binary);
                   	u8 version = SER_FMT_VER_INVALID;
                     	is.read((char*)&version, 1);

                     	if(is.fail())
                             	throw SerializationError("ServerMap::loadBlock(): Failed"
                                	             " to read MapBlock version");

                     	MapBlock *block = NULL;
                     	bool created_new = false;
                     	block = sector->getBlockNoCreateNoEx(blockpos.Y);
                     	if(block == NULL)
                     	{
                             	block = sector->createBlankBlockNoInsert(blockpos.Y);
                             	created_new = true;
                     	}
                     	// Read basic data
                     	block->deSerialize(is, version, true);
                     	// If it's a new block, insert it to the map
                     	if(created_new)
                             	sector->insertBlock(block);
                     	/*
                             	Save blocks loaded in old format in new format
                     	*/

                     	//if(version < SER_FMT_VER_HIGHEST || save_after_load)
                     	// Only save if asked to; no need to update version
                     	//if(save_after_load)
                        //     	saveBlock(block);
                     	// We just loaded it from, so it's up-to-date.
                     	block->resetModified();

             	}
             	catch(SerializationError &e)
             	{
                     	errorstream<<"Invalid block data in database"
                                     <<" ("<<blockpos.X<<","<<blockpos.Y<<","<<blockpos.Z<<")"
                                     <<" (SerializationError): "<<e.what()<<std::endl;
                     // TODO: Block should be marked as invalid in memory so that it is
                     // not touched but the game can run

                     	if(g_settings->getBool("ignore_world_load_errors")){
                             errorstream<<"Ignoring block load error. Duck and cover! "
                                             <<"(ignore_world_load_errors)"<<std::endl;
                     	} else {
                             throw SerializationError("Invalid block data in database");
                             //assert(0);
                     	}
             	}

                return srvmap->getBlockNoCreateNoEx(blockpos);  // should not be using this here
        }
	return(NULL);
}
开发者ID:0151n,项目名称:minetest,代码行数:70,代码来源:database-dummy.cpp

示例9: if


//.........这里部分代码省略.........
				xscale = side->floatProperty("scalex_mid");
				yscale = side->floatProperty("scaley_mid");
			}
			else
			{
				xscale = side->floatProperty("scalex_top");
				yscale = side->floatProperty("scaley_top");
			}
			info2.push_back(S_FMT("Scale: %1.2fx, %1.2fx", xscale, yscale));
		}
		else
		{
			info2.push_back("");
		}

		// Height of this section of the wall
		// TODO this is wrong in the case of slopes, but slope support only
		// exists in the 3.1.1 branch
		fpoint2_t left_point, right_point;
		MapSide* other_side;
		if (side == line->s1())
		{
			left_point = line->v1()->getPoint(0);
			right_point = line->v2()->getPoint(0);
			other_side = line->s2();
		}
		else
		{
			left_point = line->v2()->getPoint(0);
			right_point = line->v1()->getPoint(0);
			other_side = line->s1();
		}

		MapSector* this_sector = side->getSector();
		MapSector* other_sector = NULL;
		if (other_side)
			other_sector = other_side->getSector();

		double left_height, right_height;
		if (item_type == MapEditor::SEL_SIDE_MIDDLE && other_sector)
		{
			// A two-sided line's middle area is the smallest distance between
			// both sides' floors and ceilings, which is more complicated with
			// slopes.
			plane_t floor1 = this_sector->getFloorPlane();
			plane_t floor2 = other_sector->getFloorPlane();
			plane_t ceiling1 = this_sector->getCeilingPlane();
			plane_t ceiling2 = other_sector->getCeilingPlane();
			left_height = min(ceiling1.height_at(left_point), ceiling2.height_at(left_point))
			            - max(floor1.height_at(left_point), floor2.height_at(left_point));
			right_height = min(ceiling1.height_at(right_point), ceiling2.height_at(right_point))
			             - max(floor1.height_at(right_point), floor2.height_at(right_point));
		}
		else
		{
			plane_t top_plane, bottom_plane;
			if (item_type == MapEditor::SEL_SIDE_MIDDLE)
			{
				top_plane = this_sector->getCeilingPlane();
				bottom_plane = this_sector->getFloorPlane();
			}
			else
			{
				if (!other_sector) return;
				if (item_type == MapEditor::SEL_SIDE_TOP)
				{
开发者ID:Manuel-K,项目名称:SLADE,代码行数:67,代码来源:InfoOverlay3d.cpp

示例10: p2d

MapBlock* Database_SQLite3::loadBlock(v3s16 blockpos)
{
	v2s16 p2d(blockpos.X, blockpos.Z);
        verifyDatabase();
        
        if(sqlite3_bind_int64(m_database_read, 1, getBlockAsInteger(blockpos)) != SQLITE_OK)
                infostream<<"WARNING: Could not bind block position for load: "
                        <<sqlite3_errmsg(m_database)<<std::endl;
        if(sqlite3_step(m_database_read) == SQLITE_ROW) {
                /*
                        Make sure sector is loaded
                */
                MapSector *sector = srvmap->createSector(p2d);
                
                /*
                        Load block
                */
                const char * data = (const char *)sqlite3_column_blob(m_database_read, 0);
                size_t len = sqlite3_column_bytes(m_database_read, 0);
                
                std::string datastr(data, len);
                
//                srvmap->loadBlock(&datastr, blockpos, sector, false);

		try {
                	std::istringstream is(datastr, std::ios_base::binary);
                     
                   	u8 version = SER_FMT_VER_INVALID;
                     	is.read((char*)&version, 1);

                     	if(is.fail())
                             	throw SerializationError("ServerMap::loadBlock(): Failed"
                                	             " to read MapBlock version");

                     	MapBlock *block = NULL;
                     	bool created_new = false;
                     	block = sector->getBlockNoCreateNoEx(blockpos.Y);
                     	if(block == NULL)
                     	{
                             	block = sector->createBlankBlockNoInsert(blockpos.Y);
                             	created_new = true;
                     	}
                     
                     	// Read basic data
                     	block->deSerialize(is, version, true);
                     
                     	// If it's a new block, insert it to the map
                     	if(created_new)
                             	sector->insertBlock(block);
                     
                     	/*
                             	Save blocks loaded in old format in new format
                     	*/

                     	//if(version < SER_FMT_VER_HIGHEST || save_after_load)
                     	// Only save if asked to; no need to update version
                     	//if(save_after_load)
                        //     	saveBlock(block);
                     
                     	// We just loaded it from, so it's up-to-date.
                     	block->resetModified();

             	}
             	catch(SerializationError &e)
             	{
                     	errorstream<<"Invalid block data in database"
                                     <<" ("<<blockpos.X<<","<<blockpos.Y<<","<<blockpos.Z<<")"
                                     <<" (SerializationError): "<<e.what()<<std::endl;
                     
                     // TODO: Block should be marked as invalid in memory so that it is
                     // not touched but the game can run

                     	if(g_settings->getBool("ignore_world_load_errors")){
                             errorstream<<"Ignoring block load error. Duck and cover! "
                                             <<"(ignore_world_load_errors)"<<std::endl;
                     	} else {
                             throw SerializationError("Invalid block data in database");
                             //assert(0);
                     	}
             	}


                sqlite3_step(m_database_read);
                // We should never get more than 1 row, so ok to reset
                sqlite3_reset(m_database_read);

                return srvmap->getBlockNoCreateNoEx(blockpos);  // should not be using this here
        }
        sqlite3_reset(m_database_read);
	return(NULL);
}
开发者ID:minebest,项目名称:minetest,代码行数:91,代码来源:database-sqlite3.cpp

示例11: getAdjacent

/* MapEditContext::floodFill3d
 * Pastes previously copied wall/flat/thing info to selection and ad
 *******************************************************************/
void Edit3D::floodFill(CopyType type)
{
	// Get items to paste to
	auto& selection = context_.selection();
	auto items = getAdjacent(selection.hilight());

	// Restrict floodfill to selection, if any
	if (selection.size() > 0)
	{
		for (auto i = items.begin(); i < items.end(); ++i)
		{
			bool found = false;
			for (unsigned a = 0; a < selection.size(); a++)
			{
				if (selection[a].type == i->type && selection[a].index == i->index)
				{
					found = true;
					break;
				}
			}
			if (!found)
				items.erase(i);
		}
	}

	// Begin undo step
	string ptype = "Floodfill textures";
	undo_manager_->beginRecord(ptype);

	// Go through items
	for (unsigned a = 0; a < items.size(); a++)
	{
		// Wall
		if (items[a].type == ItemType::WallTop ||
			items[a].type == ItemType::WallMiddle ||
			items[a].type == ItemType::WallBottom)
		{
			auto side = context_.map().getSide(items[a].index);
			undo_manager_->recordUndoStep(new MapEditor::PropertyChangeUS(side));

			// Upper wall
			if (items[a].type == ItemType::WallTop)
			{
				// Texture
				if (type == CopyType::TexType)
					side->setStringProperty("texturetop", copy_texture_);
			}

				// Middle wall
			else if (items[a].type == ItemType::WallMiddle)
			{
				// Texture
				if (type == CopyType::TexType)
					side->setStringProperty("texturemiddle", copy_texture_);
			}

				// Lower wall
			else if (items[a].type == ItemType::WallBottom)
			{
				// Texture
				if (type == CopyType::TexType)
					side->setStringProperty("texturebottom", copy_texture_);
			}
		}

		// Flat
		else if (items[a].type == ItemType::Floor || items[a].type == ItemType::Ceiling)
		{
			MapSector* sector = context_.map().getSector(items[a].index);
			undo_manager_->recordUndoStep(new MapEditor::PropertyChangeUS(sector));

			// Floor
			if (items[a].type == ItemType::Floor)
			{
				// Texture
				if (type == CopyType::TexType)
					sector->setStringProperty("texturefloor", copy_texture_);
			}

			// Ceiling
			if (items[a].type == ItemType::Ceiling)
			{
				// Texture
				if (type == CopyType::TexType)
					sector->setStringProperty("textureceiling", copy_texture_);
			}
		}
	}

	// Editor message
	if (type == CopyType::TexType)
	{
		context_.addEditorMessage("Floodfilled Texture");
	}

	undo_manager_->endRecord(true);
}
开发者ID:Gaerzi,项目名称:SLADE,代码行数:100,代码来源:Edit3D.cpp

示例12: if

/* MapEditContext::paste3d
 * Pastes previously copied wall/flat/thing info to selection
 *******************************************************************/
void Edit3D::paste(CopyType type)
{
	// Begin undo step
	string ptype = "Paste Properties";
	if (type == CopyType::TexType)
		ptype = "Paste Texture/Type";
	undo_manager_->beginRecord(ptype);

	// Go through items
	auto& selection = context_.selection();
	for (auto& item : selection.selectionOrHilight())
	{
		// Wall
		if (MapEditor::baseItemType(item.type) == ItemType::Side)
		{
			MapSide* side = context_.map().getSide(item.index);
			undo_manager_->recordUndoStep(new MapEditor::PropertyChangeUS(side));

			// Upper wall
			if (item.type == ItemType::WallTop)
			{
				// Texture
				if (type == CopyType::TexType)
					side->setStringProperty("texturetop", copy_texture_);
			}

				// Middle wall
			else if (item.type == ItemType::WallMiddle)
			{
				// Texture
				if (type == CopyType::TexType)
					side->setStringProperty("texturemiddle", copy_texture_);
			}

				// Lower wall
			else if (item.type == ItemType::WallBottom)
			{
				// Texture
				if (type == CopyType::TexType)
					side->setStringProperty("texturebottom", copy_texture_);
			}
		}

		// Flat
		else if (item.type == ItemType::Floor || item.type == ItemType::Ceiling)
		{
			MapSector* sector = context_.map().getSector(item.index);
			undo_manager_->recordUndoStep(new MapEditor::PropertyChangeUS(sector));

			// Floor
			if (item.type == ItemType::Floor)
			{
				// Texture
				if (type == CopyType::TexType)
					sector->setStringProperty("texturefloor", copy_texture_);
			}

			// Ceiling
			if (item.type == ItemType::Ceiling)
			{
				// Texture
				if (type == CopyType::TexType)
					sector->setStringProperty("textureceiling", copy_texture_);
			}
		}

		// Thing
		else if (item.type == ItemType::Thing)
		{
			MapThing* thing = context_.map().getThing(item.index);
			undo_manager_->recordUndoStep(new MapEditor::PropertyChangeUS(thing));

			// Type
			if (type == CopyType::TexType)
				thing->setIntProperty("type", copy_thing_.getType());
		}
	}

	// Editor message
	if (type == CopyType::TexType)
	{
		if (selection.hilight().type == ItemType::Thing)
			context_.addEditorMessage("Pasted Thing Type");
		else
			context_.addEditorMessage("Pasted Texture");
	}

	undo_manager_->endRecord(true);
}
开发者ID:Gaerzi,项目名称:SLADE,代码行数:92,代码来源:Edit3D.cpp

示例13: sp

void ClientMap::updateDrawList(video::IVideoDriver* driver)
{
	ScopeProfiler sp(g_profiler, "CM::updateDrawList()", SPT_AVG);
	g_profiler->add("CM::updateDrawList() count", 1);

	for (std::map<v3s16, MapBlock*>::iterator i = m_drawlist.begin();
			i != m_drawlist.end(); ++i) {
		MapBlock *block = i->second;
		block->refDrop();
	}
	m_drawlist.clear();

	v3f camera_position = m_camera_position;
	v3f camera_direction = m_camera_direction;
	f32 camera_fov = m_camera_fov;

	// Use a higher fov to accomodate faster camera movements.
	// Blocks are cropped better when they are drawn.
	// Or maybe they aren't? Well whatever.
	camera_fov *= 1.2;

	v3s16 cam_pos_nodes = floatToInt(camera_position, BS);
	v3s16 p_blocks_min;
	v3s16 p_blocks_max;
	getBlocksInViewRange(cam_pos_nodes, &p_blocks_min, &p_blocks_max);

	// Number of blocks in rendering range
	u32 blocks_in_range = 0;
	// Number of blocks occlusion culled
	u32 blocks_occlusion_culled = 0;
	// Number of blocks in rendering range but don't have a mesh
	u32 blocks_in_range_without_mesh = 0;
	// Blocks that had mesh that would have been drawn according to
	// rendering range (if max blocks limit didn't kick in)
	u32 blocks_would_have_drawn = 0;
	// Blocks that were drawn and had a mesh
	u32 blocks_drawn = 0;
	// Blocks which had a corresponding meshbuffer for this pass
	//u32 blocks_had_pass_meshbuf = 0;
	// Blocks from which stuff was actually drawn
	//u32 blocks_without_stuff = 0;
	// Distance to farthest drawn block
	float farthest_drawn = 0;

	// No occlusion culling when free_move is on and camera is
	// inside ground
	bool occlusion_culling_enabled = true;
	if (g_settings->getBool("free_move")) {
		MapNode n = getNodeNoEx(cam_pos_nodes);
		if (n.getContent() == CONTENT_IGNORE ||
				m_nodedef->get(n).solidness == 2)
			occlusion_culling_enabled = false;
	}

	for (std::map<v2s16, MapSector*>::iterator si = m_sectors.begin();
			si != m_sectors.end(); ++si) {
		MapSector *sector = si->second;
		v2s16 sp = sector->getPos();

		if (m_control.range_all == false) {
			if (sp.X < p_blocks_min.X || sp.X > p_blocks_max.X ||
					sp.Y < p_blocks_min.Z || sp.Y > p_blocks_max.Z)
				continue;
		}

		MapBlockVect sectorblocks;
		sector->getBlocks(sectorblocks);

		/*
			Loop through blocks in sector
		*/

		u32 sector_blocks_drawn = 0;

		for (MapBlockVect::iterator i = sectorblocks.begin();
				i != sectorblocks.end(); ++i) {
			MapBlock *block = *i;

			/*
				Compare block position to camera position, skip
				if not seen on display
			*/

			if (block->mesh)
				block->mesh->updateCameraOffset(m_camera_offset);

			float range = 100000 * BS;
			if (!m_control.range_all)
				range = m_control.wanted_range * BS;

			float d = 0.0;
			if (!isBlockInSight(block->getPos(), camera_position,
					camera_direction, camera_fov, range, &d))
				continue;

			blocks_in_range++;

			/*
				Ignore if mesh doesn't exist
			*/
//.........这里部分代码省略.........
开发者ID:kaadmy,项目名称:minetest,代码行数:101,代码来源:clientmap.cpp

示例14: 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,代码来源:main.cpp

示例15: applyChanges

/* SectorPropsPanel::applyChanges
 * Apply values to opened objects
 *******************************************************************/
void SectorPropsPanel::applyChanges()
{
	for (unsigned a = 0; a < objects.size(); a++)
	{
		MapSector* sector = (MapSector*)objects[a];

		// Special
		if (cb_override_special->GetValue())
			sector->setIntProperty("special", panel_special->getSelectedSpecial(theMapEditor->currentMapDesc().format));

		// Floor texture
		if (!fcb_floor->GetValue().IsEmpty())
			sector->setStringProperty("texturefloor", fcb_floor->GetValue());

		// Ceiling texture
		if (!fcb_ceiling->GetValue().IsEmpty())
			sector->setStringProperty("textureceiling", fcb_ceiling->GetValue());

		// Floor height
		if (!text_height_floor->GetValue().IsEmpty())
			sector->setIntProperty("heightfloor", text_height_floor->getNumber(sector->getFloorHeight()));

		// Ceiling height
		if (!text_height_ceiling->GetValue().IsEmpty())
			sector->setIntProperty("heightceiling", text_height_ceiling->getNumber(sector->getCeilingHeight()));

		// Light level
		if (!text_light->GetValue().IsEmpty())
			sector->setIntProperty("lightlevel", text_light->getNumber(sector->getLightLevel()));

		// Tag
		if (!text_tag->GetValue().IsEmpty())
			sector->setIntProperty("id", text_tag->getNumber(sector->getTag()));
	}

	if (mopp_all_props)
		mopp_all_props->applyChanges();
}
开发者ID:Genghoidal,项目名称:SLADE,代码行数:41,代码来源:SectorPropsPanel.cpp


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