Copy link to clipboard
Copied
Does anyone have any experience with determining if an art object is not visible due to being within a clipping mask, but outside the visible area of the mask?
I've been playing around with the GeometrySuite with some success, but not getting quite what I want.
Are there any suite functions available for this check?
Does anyone have an algorithm already that works?
Copy link to clipboard
Copied
What about this?
copy mask and masked object;
DoIntersectEffect for them;
GetSelectedArt( &matches, &count);
if ( count ==0)
{
//no intersection, the object is outside
}
Copy link to clipboard
Copied
Alright, I'm gonna put this here. I'm using wrapper classes for a lot of the SDK functions, but I think it's pretty obvious what's going on. It works, but it's probably not optimized. There may be corner cases where it fails too. Use at your own risk!
bool BtArtHandle::OverlapsRect(AIRealRect rect) const
{
AIRealRect artRect;
if (!ClippedBounds(artRect))
{
artRect = Bounds();
}
return sAIRealMath->AIRealRectOverlap(&artRect, &rect);
}
bool BtArtHandle::ClippedBounds(AIRealRect& result) const
{
bool boundsValid = false;
BtArtHandle enclosingClipArt = GetEnclosingClipArt();
while (!enclosingClipArt.Null())
{
AIRealRect clipRect = enclosingClipArt.Bounds();
AIRealRect thisRect;
if (boundsValid)
{
thisRect = result;
}
else
{
thisRect = Bounds();
}
boundsValid = sAIRealMath->AIRealRectIntersect(&clipRect, &thisRect, &result);
if (boundsValid)
{
enclosingClipArt = enclosingClipArt.Parent().GetEnclosingClipArt();
}
else
{
return boundsValid;
}
}
return boundsValid;
}
BtArtHandle BtArtHandle::GetEnclosingClipArt() const
{
BtArtHandle layerGroup(BtLayer(Layer()).GetLayerGroupArt());
BtArtHandle parent = Parent();
if (*this != layerGroup && parent != layerGroup)
{
if (parent.IsClippingGroup())
{
BtArtHandle sibling = parent.FirstChild();
do
{
if (sibling.ClipMask())
{
return sibling;
}
sibling = sibling.Sibling();
} while (!sibling.Null());
}
return parent.GetEnclosingClipArt();
}
return BtArtHandle();
}