Ejemplo n.º 1
0
	//矩形和矩形相交判断
	Bool  HawkRect2D::Intersect(const HawkRect2D& oRect) const
	{
		Float fDis = (GetBoundCenter() - oRect.GetBoundCenter()).Length();
		if (fDis > GetBoundRadius() + oRect.GetBoundRadius())
		{
			return false;
		}

		for (Int32 i=0;i<4;i++)
		{
			HawkLine2D oLine(GetPoint(i),GetPoint((i+1)%4));
			PtRelation eRel = IsClockWise()?PT_LEFT:PT_RIGHT;

			if (oLine.GetPtRelation(oRect.GetPoint(0)) == eRel && 
				oLine.GetPtRelation(oRect.GetPoint(1)) == eRel &&
				oLine.GetPtRelation(oRect.GetPoint(2)) == eRel &&
				oLine.GetPtRelation(oRect.GetPoint(3)) == eRel)
				return false;
		}

		for (Int32 i=0;i<4;i++)
		{
			HawkLine2D oLine(oRect.GetPoint(i),oRect.GetPoint((i+1)%4));
			PtRelation eRel = oRect.IsClockWise()?PT_LEFT:PT_RIGHT;

			if (oLine.GetPtRelation(GetPoint(0)) == eRel && 
				oLine.GetPtRelation(GetPoint(1)) == eRel &&
				oLine.GetPtRelation(GetPoint(2)) == eRel &&
				oLine.GetPtRelation(GetPoint(3)) == eRel)
				return false;
		}

		return true;
	}
Ejemplo n.º 2
0
/* This is unfortunately not enough to render sphere maps.
 * The game has more logic to cull objects, but I don't quite know where.
 * In the worst case whole sectors will be culled. */
bool
CEntity::GetIsOnScreen(void)
{
	if(sphereRadius != 0.0f){
		float r;
		CVector c;
		GetBoundCentre(&c);
		r = GetBoundRadius();
		return sq(r) + sq(sphereRadius) >
			sq(reflectionCamPos.x - c.x) +
			sq(reflectionCamPos.y - c.y) +
			sq(reflectionCamPos.z - c.z);
		return false;
	}
	return GetIsOnScreen_orig();
}