Exemple #1
0
void CComplexArea::AddRect (TArray<SRect> &Array, int x, int y, int cxWidth, int cyHeight, int iRotation)

//	AddRect
//
//	Adds the rect

{
    int i;

    if (cxWidth <= 0 || cyHeight <= 0)
        return;

    //	See if we already have a rect like this

    for (i = 0; i < Array.GetCount(); i++)
    {
        SRect &Test = Array[i];
        if (Test.x == x
                && Test.y == y
                && Test.iRotation == iRotation
                && Test.cxWidth == cxWidth
                && Test.cyHeight == cyHeight)
            return;
    }

    //	Add it

    SRect *pRect = Array.Insert();
    pRect->x = x;
    pRect->y = y;
    pRect->cxWidth = cxWidth;
    pRect->cyHeight = cyHeight;
    pRect->iRotation = (iRotation > 0 ? (iRotation % 360) : 0);

    //	Add to bounds

    if (iRotation > 0)
    {
        int xLL = 0;
        int yLL = 0;

        int xLR, yLR;
        IntPolarToVector(iRotation, cxWidth, &xLR, &yLR);

        int xUL, yUL;
        IntPolarToVector(iRotation + 90, cyHeight, &xUL, &yUL);

        int xUR = xUL + xLR;
        int yUR = yUL + yLR;

        int xLeft = Min(Min(xLL, xLR), Min(xUL, xUR));
        int xRight = Max(Max(xLL, xLR), Max(xUL, xUR));
        int yTop = Max(Max(yLL, yLR), Max(yUL, yUR));
        int yBottom = Min(Min(yLL, yLR), Min(yUL, yUR));

        AddToBounds(x + xLeft, y + yTop, x + xRight, y + yBottom);
    }
    else
        AddToBounds(x, y + cyHeight, x + cxWidth, y);
}
Exemple #2
0
/*
============
Brush_LoadEntity
============
*/
brushset_t *Brush_LoadEntity (entity_t *ent, int hullnum)
{
	brush_t		*b, *next, *water, *other;
	mbrush_t	*mbr;
	int			numbrushes;
	brushset_t	*bset;
		
	bset = malloc (sizeof(brushset_t));
	memset (bset, 0, sizeof(brushset_t));
	ClearBounds (bset);

	numbrushes = 0;
	other = water = NULL;

	qprintf ("--- Brush_LoadEntity ---\n");

	for (mbr = ent->brushes ; mbr ; mbr=mbr->next)
	{
		b = LoadBrush (mbr, hullnum);
		if (!b)
			continue;
		
		numbrushes++;

		if (b->contents != CONTENTS_SOLID)
		{
			b->next = water;
			water = b;
		}
		else
		{
			b->next = other;
			other = b;
		}
	
		AddToBounds (bset, b->mins);
		AddToBounds (bset, b->maxs);
	}

// add all of the water textures at the start
	for (b=water ; b ; b=next)
	{
		next = b->next;
		b->next = other;
		other = b;
	}

	bset->brushes = other;

	brushset = bset;
	Brush_DrawAll (bset);
	
	qprintf ("%i brushes read\n",numbrushes);
	
	return bset;
}
Exemple #3
0
void SE_Bounds::Add(double x, double y)
{
    if (size >= capacity)
        return;
    hull[2*size  ] = x;
    hull[2*size+1] = y;

    AddToBounds(x, y, min, max);

    size++;
}
Exemple #4
0
void CComplexArea::AddCircle (TArray<SCircle> &Array, int x, int y, int iRadius)

//	AddCircle
//
//	Adds a circle to the given array

{
    int i;

    if (iRadius <= 0)
        return;

    //	Make sure that we don't already have a circle like this

    for (i = 0; i < Array.GetCount(); i++)
    {
        SCircle &Test = Array[i];
        if (Test.x == x && Test.y == y)
        {
            if (Test.iRadius2 < (iRadius * iRadius))
            {
                Test.iRadius2 = (iRadius * iRadius);
                AddToBounds(x - iRadius, y + iRadius, x + iRadius, y - iRadius);
            }

            return;
        }
    }

    //	Add it

    SCircle *pCircle = Array.Insert();
    pCircle->x = x;
    pCircle->y = y;
    pCircle->iRadius2 = iRadius * iRadius;

    AddToBounds(x - iRadius, y + iRadius, x + iRadius, y - iRadius);
}
Exemple #5
0
void SE_Bounds::Transform(const SE_Matrix& xform)
{
    double* last = hull + 2*size;
    double* cur = hull;
    min[0] = min[1] = +DBL_MAX;
    max[0] = max[1] = -DBL_MAX;

    while (cur < last)
    {
        xform.transform(cur[0], cur[1]);
        AddToBounds(cur[0], cur[1], min, max);
        cur += 2;
    }
}
Exemple #6
0
/* NOTE: This method is intentionally unchecked, the caller must ensure that the
 *       destination SE_Bounds is large enough, that the source is valid, etc. */
void SE_Bounds::Transform(const SE_Matrix& xform, SE_Bounds* src)
{
    double* last = src->hull + 2*src->size;
    double* cur = src->hull;
    double* dst = hull;
    min[0] = min[1] = +DBL_MAX;
    max[0] = max[1] = -DBL_MAX;
    size = src->size;
    pivot = src->pivot;

    while (cur < last)
    {
        xform.transform(cur[0], cur[1], dst[0], dst[1]);
        AddToBounds(dst[0], dst[1], min, max);
        cur += 2;
        dst += 2;
    }
}
Exemple #7
0
/*
============
Brush_LoadEntity
============
*/
brushset_t *Brush_LoadEntity (entity_t *ent, int hullnum)
{
	brush_t		*b, *next, *water, *other;
	mbrush_t	*mbr;
	int		numbrushes, TotalBrushes = 0;
	brushset_t	*bset;

	CurrEnt = ent;

	bset = AllocOther (sizeof(brushset_t));
	ClearBounds (bset);

	numbrushes = 0;
	other = water = NULL;

	Message (MSGVERBOSE, "------ Brush_LoadEntity ------");

	for (mbr = ent->brushes; mbr; mbr = mbr->next)
		++TotalBrushes;

	for (mbr = ent->brushes ; mbr ; mbr=mbr->next)
	{
		b = LoadBrush (mbr, hullnum);
		if (!b)
			continue;

		numbrushes++;

		if (b->contents != CONTENTS_SOLID)
		{
			b->next = water;
			water = b;
		}
		else
		{
			b->next = other;
			other = b;
		}

		AddToBounds (bset, b->mins);
		AddToBounds (bset, b->maxs);

		ShowBar(numbrushes, TotalBrushes);
	}

	ShowBar(-1, -1);

// add all of the water textures at the start
	for (b=water ; b ; b=next)
	{
		next = b->next;
		b->next = other;
		other = b;
	}

	bset->brushes = other;

	brushset = bset;

	Message (MSGVERBOSE, "%6i brushes read",numbrushes);

	return bset;
}
Exemple #8
0
void UploadXML::Add(GPXRow *row)
{
	kGUIXMLItem *point;
	double lat,lon;
	kGUIString name;
	kGUIString hint;
	kGUIString fullname;
	WPVERIFY_DEF def;
	static char validchars[]={" ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwnyz0123456789"};

	/* am I full already? */
	if(m_numpoints==m_maxpoints)
		return;

	point=m_root->AddChild("wpt");
	lat=row->m_llcoord.GetLat();
	lon=row->m_llcoord.GetLon();
	point->AddParm("lat",lat);
	point->AddParm("lon",lon);

	hint.SetString(row->m_hint.GetString());
	hint.Clean(validchars);

	switch(m_nameformat)
	{
	case UPNAME_WAYNAME:
		name.SetString(row->m_wptname.GetString());
	break;
	case UPNAME_TRUNCATE:
	case UPNAME_DROPVOWELS:
		name.SetString(row->m_name.GetString());
	break;
	}
	fullname.SetString(name.GetString());
	GenName(&name);
	def.found=false;
	def.lat=lat;
	def.lon=lon;
	m_names.Add(name.GetString(),&def);

	/* check hash table fo collisions */
	point->AddChild("name",name.GetString());
	fullname.Clean(validchars);
//	point->AddChild("desc",fullname.GetString());
//	point->AddChild("cmt",fullname.GetString());
	point->AddChild("desc",hint.GetString());
	point->AddChild("cmt",hint.GetString());
	point->AddChild("sym","Geocache");				/* hmmmm */
	AddToBounds(lat,lon);

	if(++m_numpoints==m_maxpoints)
		return;

	if(m_addchildren==true && row->m_numchildren)
	{
		/* download child waypoints too */
		unsigned int c;
		GPXChild *cc;

		for(c=0;c<row->m_numchildren;++c)
		{
			cc=row->m_children.GetEntry(c);
			point=m_root->AddChild("wpt");
			lat=cc->GetLat();
			lon=cc->GetLon();
			point->AddParm("lat",lat);
			point->AddParm("lon",lon);

			switch(m_nameformat)
			{
			case 0:
				name.SetString(cc->GetWptName());
			break;
			case 1:
			case 2:
				name.SetString(cc->GetName());
			break;
			}

			GenName(&name);
			def.found=false;
			def.lat=lat;
			def.lon=lon;
			m_names.Add(name.GetString(),&def);

			point->AddChild("name",name.GetString());
			point->AddChild("desc",name.GetString());
			point->AddChild("cmt",name.GetString());
			point->AddChild("sym","Geocache");			/* todo: other? */
			++m_numchildpoints;
			AddToBounds(lat,lon);
			if(++m_numpoints==m_maxpoints)
				break;
		}
	}
}