Esempio n. 1
0
bool PointRenderer::Hits(const RenderState &inState)
{
    UserPoint screen(inState.mClipRect.x, inState.mClipRect.y);

    Extent2DF extent;
    CachedExtentRenderer::GetExtent(inState.mTransform,extent);
    if (!extent.Contains(screen))
        return false;

    UserPoint hit_test = inState.mTransform.mMatrix->ApplyInverse(screen);
    if (inState.mTransform.mScale9->Active())
    {
        hit_test.x = inState.mTransform.mScale9->InvTransX(hit_test.x);
        hit_test.y = inState.mTransform.mScale9->InvTransY(hit_test.y);
    }

    for(int i=0; i<mTransformed.size(); i++)
    {
        const UserPoint &point = mTransformed[i];
        if ( fabs(point.x-screen.x) < 1 && fabs(point.y-screen.y) < 1 )
            return true;
    }
    return false;
}
Esempio n. 2
0
	bool PolygonRender::Hits(const RenderState &inState)
	{
		if (inState.mClipRect.w != 1 || inState.mClipRect.h != 1)
			return false;
		
		UserPoint screen(inState.mClipRect.x, inState.mClipRect.y);
		
		Extent2DF extent;
		CachedExtentRenderer::GetExtent(inState.mTransform, extent);
		
		if (!extent.Contains(screen))
			return false;
		
		mHitTest = inState.mTransform.mMatrix->ApplyInverse(screen);
		if (inState.mTransform.mScale9->Active())
		{
			mHitTest.x = inState.mTransform.mScale9->InvTransX(mHitTest.x);
			mHitTest.y = inState.mTransform.mScale9->InvTransY(mHitTest.y);
		}
		
		mHitsLeft = 0;
		Iterate(itHitTest, Matrix());
		return mHitsLeft & 0x01;
	}