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


C++ MapLine::setS2方法代码示例

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


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

示例1: findInMap

/* MapArchClipboardItem::pasteToMap
 * Pastes copied architecture to [map] at [position]
 *******************************************************************/
vector<MapVertex*> MapArchClipboardItem::pasteToMap(SLADEMap* map, fpoint2_t position)
{
    std::map<MapVertex*, MapVertex*> vertMap;
    std::map<MapSector*, MapSector*> sectMap;
    std::map<MapSide*, MapSide*> sideMap;
    // Not used yet...
    // std::map<MapLine*, MapLine*> lineMap;

    // Add vertices
    vector<MapVertex*> new_verts;
    for (unsigned a = 0; a < vertices.size(); a++)
    {
        new_verts.push_back(map->createVertex(position.x + vertices[a]->xPos(), position.y + vertices[a]->yPos()));
        new_verts.back()->copy(vertices[a]);
        vertMap[vertices[a]] = new_verts.back();
    }

    // Add sectors
    for (unsigned a = 0; a < sectors.size(); a++)
    {
        MapSector* new_sector = map->createSector();
        new_sector->copy(sectors[a]);
        sectMap[sectors[a]] = new_sector;
    }

    // Add sides
    int first_new_side = map->nSides();
    for (unsigned a = 0; a < sides.size(); a++)
    {
        // Get relative sector
        MapSector* sector = findInMap(sectMap, sides[a]->getSector());

        MapSide* new_side = map->createSide(sector);
        new_side->copy(sides[a]);
        sideMap[sides[a]] = new_side;
    }

    // Add lines
    int first_new_line = map->nLines();
    for (unsigned a = 0; a < lines.size(); a++)
    {
        // Get relative vertices
        MapVertex* v1 = findInMap(vertMap, lines[a]->v1());
        MapVertex* v2 = findInMap(vertMap, lines[a]->v2());

        if (!v1)
        {
            wxLogMessage("no v1");
            continue;
        }
        if (!v2)
        {
            wxLogMessage("no v2");
        }

        MapLine* newline = map->createLine(v1, v2, true);
        newline->copy(lines[a]);
        // lineMap[lines[a]] = newline;

        // Set relative sides
        bool s1 = false;
        bool s2 = !(lines[a]->s2());
        MapSide* newS1 = findInMap(sideMap, lines[a]->s1());
        MapSide* newS2 = findInMap(sideMap, lines[a]->s2());
        if(newS1)
            newline->setS1(newS1);
        if(newS2)
            newline->setS2(newS2);

        // Set important flags (needed when copying from Doom/Hexen format to UDMF)
        // Won't be needed when proper map format conversion stuff is implemented
        theGameConfiguration->setLineBasicFlag(
            "twosided",
            newline,
            map->currentFormat(),
            (newS1 && newS2)
        );
        theGameConfiguration->setLineBasicFlag(
            "blocking",
            newline,
            map->currentFormat(),
            !newS2
        );
    }

    // TODO:
    // - Split lines
    // - Merge lines

    //// Fix sector references
    //// TODO: figure out what lines are 'outside' on copy, only fix said lines
    //for (unsigned a = first_new_line; a < map->nLines(); a++)
    //{
    //	MapLine* line = map->getLine(a);
    //	MapSector* sec1 = map->getLineSideSector(line, true);
    //	MapSector* sec2 = map->getLineSideSector(line, false);
    //	int i1 = -1;
//.........这里部分代码省略.........
开发者ID:Blzut3,项目名称:SLADE,代码行数:101,代码来源:Clipboard.cpp

示例2: findInMap

/* MapArchClipboardItem::pasteToMap
 * Pastes copied architecture to [map] at [position]
 *******************************************************************/
vector<MapVertex*> MapArchClipboardItem::pasteToMap(SLADEMap* map, fpoint2_t position)
{
	std::map<MapVertex*, MapVertex*> vertMap;
	std::map<MapSector*, MapSector*> sectMap;
	std::map<MapSide*, MapSide*> sideMap;
	// Not used yet...
	// std::map<MapLine*, MapLine*> lineMap;

	// Add vertices
	vector<MapVertex*> new_verts;
	for (unsigned a = 0; a < vertices.size(); a++)
	{
		new_verts.push_back(map->createVertex(position.x + vertices[a]->xPos(), position.y + vertices[a]->yPos()));
		new_verts.back()->copy(vertices[a]);
		vertMap[vertices[a]] = new_verts.back();
	}

	// Add sectors
	for (unsigned a = 0; a < sectors.size(); a++)
	{
		MapSector* new_sector = map->createSector();
		new_sector->copy(sectors[a]);
		sectMap[sectors[a]] = new_sector;
	}

	// Add sides
	int first_new_side = map->nSides();
	for (unsigned a = 0; a < sides.size(); a++)
	{
		// Get relative sector
		MapSector* sector = findInMap(sectMap, sides[a]->getSector());

		MapSide* new_side = map->createSide(sector);
		new_side->copy(sides[a]);
		sideMap[sides[a]] = new_side;
	}

	// Add lines
	int first_new_line = map->nLines();
	for (unsigned a = 0; a < lines.size(); a++)
	{
		// Get relative vertices
		MapVertex* v1 = findInMap(vertMap, lines[a]->v1());
		MapVertex* v2 = findInMap(vertMap, lines[a]->v2());

		if (!v1)
		{
			wxLogMessage("no v1");
			continue;
		}
		if (!v2)
		{
			wxLogMessage("no v2");
		}

		MapLine* newline = map->createLine(v1, v2, true);
		newline->copy(lines[a]);
		// lineMap[lines[a]] = newline;

		// Set relative sides
		bool s1 = false;
		bool s2 = !(lines[a]->s2());
		MapSide* newS1 = findInMap(sideMap, lines[a]->s1());
		MapSide* newS2 = findInMap(sideMap, lines[a]->s2());
		if(newS1)
			newline->setS1(newS1);
		if(newS2)
			newline->setS2(newS2);
	}

	// TODO:
	// - Split lines
	// - Merge lines

	// Fix sector references
	// TODO: figure out what lines are 'outside' on copy, only fix said lines
	for (unsigned a = first_new_line; a < map->nLines(); a++)
	{
		MapLine* line = map->getLine(a);
		MapSector* sec1 = map->getLineSideSector(line, true);
		MapSector* sec2 = map->getLineSideSector(line, false);
		int i1 = -1;
		int i2 = -2;
		if (sec1) i1 = sec1->getIndex();
		if (sec2) i2 = sec2->getIndex();
		map->setLineSector(a, i1, true);
		map->setLineSector(a, i2, false);
	}

	return new_verts;
}
开发者ID:DemolisherOfSouls,项目名称:SLADE,代码行数:94,代码来源:Clipboard.cpp


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