#i105323# speedup of 3D handling mostly for CustomShapes; HitTest and interactions optimized
This commit is contained in:
@@ -875,52 +875,147 @@ namespace basegfx
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
bool bRetval(false);
|
||||||
const B3DVector aPlaneNormal(rCandidate.getNormal());
|
const B3DVector aPlaneNormal(rCandidate.getNormal());
|
||||||
|
|
||||||
if(!aPlaneNormal.equalZero())
|
if(!aPlaneNormal.equalZero())
|
||||||
{
|
{
|
||||||
const double fAbsX(fabs(aPlaneNormal.getX()));
|
const sal_uInt32 nPointCount(rCandidate.count());
|
||||||
const double fAbsY(fabs(aPlaneNormal.getY()));
|
|
||||||
const double fAbsZ(fabs(aPlaneNormal.getZ()));
|
|
||||||
|
|
||||||
if(fAbsX > fAbsY && fAbsX > fAbsZ)
|
if(nPointCount)
|
||||||
{
|
{
|
||||||
// normal points mostly in X-Direction, use YZ-Polygon projection for check
|
B3DPoint aCurrentPoint(rCandidate.getB3DPoint(nPointCount - 1));
|
||||||
B3DHomMatrix aTrans;
|
const double fAbsX(fabs(aPlaneNormal.getX()));
|
||||||
|
const double fAbsY(fabs(aPlaneNormal.getY()));
|
||||||
|
const double fAbsZ(fabs(aPlaneNormal.getZ()));
|
||||||
|
|
||||||
aTrans.set(0, 0, 0.0);
|
if(fAbsX > fAbsY && fAbsX > fAbsZ)
|
||||||
aTrans.set(0, 1, 1.0);
|
{
|
||||||
aTrans.set(1, 1, 0.0);
|
// normal points mostly in X-Direction, use YZ-Polygon projection for check
|
||||||
aTrans.set(1, 2, 1.0);
|
// x -> y, y -> z
|
||||||
|
for(sal_uInt32 a(0); a < nPointCount; a++)
|
||||||
|
{
|
||||||
|
const B3DPoint aPreviousPoint(aCurrentPoint);
|
||||||
|
aCurrentPoint = rCandidate.getB3DPoint(a);
|
||||||
|
|
||||||
const B2DPolygon aYZ(createB2DPolygonFromB3DPolygon(rCandidate, aTrans));
|
// cross-over in Z?
|
||||||
|
const bool bCompZA(fTools::more(aPreviousPoint.getZ(), rPoint.getZ()));
|
||||||
|
const bool bCompZB(fTools::more(aCurrentPoint.getZ(), rPoint.getZ()));
|
||||||
|
|
||||||
return isInside(aYZ, B2DPoint(rPoint.getY(), rPoint.getZ()), bWithBorder);
|
if(bCompZA != bCompZB)
|
||||||
}
|
{
|
||||||
else if(fAbsY > fAbsX && fAbsY > fAbsZ)
|
// cross-over in Y?
|
||||||
{
|
const bool bCompYA(fTools::more(aPreviousPoint.getY(), rPoint.getY()));
|
||||||
// normal points mostly in Y-Direction, use XZ-Polygon projection for check
|
const bool bCompYB(fTools::more(aCurrentPoint.getY(), rPoint.getY()));
|
||||||
B3DHomMatrix aTrans;
|
|
||||||
|
|
||||||
aTrans.set(1, 1, 0.0);
|
if(bCompYA == bCompYB)
|
||||||
aTrans.set(1, 2, 1.0);
|
{
|
||||||
|
if(bCompYA)
|
||||||
|
{
|
||||||
|
bRetval = !bRetval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const double fCompare(
|
||||||
|
aCurrentPoint.getY() - (aCurrentPoint.getZ() - rPoint.getZ()) *
|
||||||
|
(aPreviousPoint.getY() - aCurrentPoint.getY()) /
|
||||||
|
(aPreviousPoint.getZ() - aCurrentPoint.getZ()));
|
||||||
|
|
||||||
const B2DPolygon aXZ(createB2DPolygonFromB3DPolygon(rCandidate, aTrans));
|
if(fTools::more(fCompare, rPoint.getY()))
|
||||||
|
{
|
||||||
|
bRetval = !bRetval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(fAbsY > fAbsX && fAbsY > fAbsZ)
|
||||||
|
{
|
||||||
|
// normal points mostly in Y-Direction, use XZ-Polygon projection for check
|
||||||
|
// x -> x, y -> z
|
||||||
|
for(sal_uInt32 a(0); a < nPointCount; a++)
|
||||||
|
{
|
||||||
|
const B3DPoint aPreviousPoint(aCurrentPoint);
|
||||||
|
aCurrentPoint = rCandidate.getB3DPoint(a);
|
||||||
|
|
||||||
return isInside(aXZ, B2DPoint(rPoint.getX(), rPoint.getZ()), bWithBorder);
|
// cross-over in Z?
|
||||||
}
|
const bool bCompZA(fTools::more(aPreviousPoint.getZ(), rPoint.getZ()));
|
||||||
else
|
const bool bCompZB(fTools::more(aCurrentPoint.getZ(), rPoint.getZ()));
|
||||||
{
|
|
||||||
// normal points mostly in Z-Direction, use XY-Polygon projection for check
|
|
||||||
B3DHomMatrix aTrans;
|
|
||||||
|
|
||||||
const B2DPolygon aXY(createB2DPolygonFromB3DPolygon(rCandidate, aTrans));
|
if(bCompZA != bCompZB)
|
||||||
|
{
|
||||||
|
// cross-over in X?
|
||||||
|
const bool bCompXA(fTools::more(aPreviousPoint.getX(), rPoint.getX()));
|
||||||
|
const bool bCompXB(fTools::more(aCurrentPoint.getX(), rPoint.getX()));
|
||||||
|
|
||||||
return isInside(aXY, B2DPoint(rPoint.getX(), rPoint.getY()), bWithBorder);
|
if(bCompXA == bCompXB)
|
||||||
|
{
|
||||||
|
if(bCompXA)
|
||||||
|
{
|
||||||
|
bRetval = !bRetval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const double fCompare(
|
||||||
|
aCurrentPoint.getX() - (aCurrentPoint.getZ() - rPoint.getZ()) *
|
||||||
|
(aPreviousPoint.getX() - aCurrentPoint.getX()) /
|
||||||
|
(aPreviousPoint.getZ() - aCurrentPoint.getZ()));
|
||||||
|
|
||||||
|
if(fTools::more(fCompare, rPoint.getX()))
|
||||||
|
{
|
||||||
|
bRetval = !bRetval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// normal points mostly in Z-Direction, use XY-Polygon projection for check
|
||||||
|
// x -> x, y -> y
|
||||||
|
for(sal_uInt32 a(0); a < nPointCount; a++)
|
||||||
|
{
|
||||||
|
const B3DPoint aPreviousPoint(aCurrentPoint);
|
||||||
|
aCurrentPoint = rCandidate.getB3DPoint(a);
|
||||||
|
|
||||||
|
// cross-over in Y?
|
||||||
|
const bool bCompYA(fTools::more(aPreviousPoint.getY(), rPoint.getY()));
|
||||||
|
const bool bCompYB(fTools::more(aCurrentPoint.getY(), rPoint.getY()));
|
||||||
|
|
||||||
|
if(bCompYA != bCompYB)
|
||||||
|
{
|
||||||
|
// cross-over in X?
|
||||||
|
const bool bCompXA(fTools::more(aPreviousPoint.getX(), rPoint.getX()));
|
||||||
|
const bool bCompXB(fTools::more(aCurrentPoint.getX(), rPoint.getX()));
|
||||||
|
|
||||||
|
if(bCompXA == bCompXB)
|
||||||
|
{
|
||||||
|
if(bCompXA)
|
||||||
|
{
|
||||||
|
bRetval = !bRetval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const double fCompare(
|
||||||
|
aCurrentPoint.getX() - (aCurrentPoint.getY() - rPoint.getY()) *
|
||||||
|
(aPreviousPoint.getX() - aCurrentPoint.getX()) /
|
||||||
|
(aPreviousPoint.getY() - aCurrentPoint.getY()));
|
||||||
|
|
||||||
|
if(fTools::more(fCompare, rPoint.getX()))
|
||||||
|
{
|
||||||
|
bRetval = !bRetval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return bRetval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user