return;
spline.getCentrePath().cacheLength(true);
Vec3D p1 = null, p2 = null;
Vec2D p12D = null, p22D = null;
for (int i = 0; i < spline.getCentrePath().size() - 1; i++) {
SketchPoint point1 = spline.getCentrePath().get(i);
SketchPoint point2 = spline.getCentrePath().get(i + 1);
float step = 1;
if (point1.containsBezier() || point2.containsBezier())
step = GLOBAL.SketchGlobals.BEZIER_DETAIL_CALCULATIONS;
float offset = 0;
if (step != 1)
offset = step;
p22D = (Vec2D) point1.copy();
spline.getCentrePath().resetPosStep();
for (float i2 = 0; i2 < 1; i2 += step) {
//If we are on a curve step though the curve
if (step == 1) {
p12D = (Vec2D) spline.getCentrePath().get(i);
p22D = (Vec2D) spline.getCentrePath().get(i + 1);
p1 = this.getWorldPos(p12D);
p2 = this.getWorldPos(p22D);
} else {
p12D = p22D.copy();//get the previous point// (Vec2D) spline.getCentrePath().getPosStep(step);
Vec2D p22dTemp = (Vec2D) spline.getCentrePath().getPosStep(
point1, point2, step);//step to the next point
if (p22dTemp != null) {
p22D = p22dTemp;
}
p1 = this.getWorldPos(p12D);
p2 = this.getWorldPos(p22D);
// LOGGER.info("p1" + p1.x + ":" + p1.y);
// LOGGER.info("p2" + p2.x + ":" + p2.y);
}
if (p2 != null) {
/*
if(p12D.distanceTo(p22D) > 100)
LOGGER.info("-------------------------------------------------------");
LOGGER.info("p12D.distanceTo(p22D); " + p12D.distanceTo(p22D) + " i2 " + i2);
LOGGER.info(" p1 " + p1 + " p2 " + p2);
LOGGER.info("");
*/
//if(p12D.distanceTo(p22D) < 100)
//
lenToNext += p12D.distanceTo(p22D);
// if one point is on one side of the plane and the other point is
// on the other side !
if ((slicePlane.getPlane().classifyPoint(p1) != slicePlane
.getPlane().classifyPoint(p2))) {
//LOGGER.info("i2 on p"+i2 );
Vec3D intersect = null;
//try intersecting ray in one direction
intersect = (Vec3D) slicePlane.getPlane()
.getIntersectionWithRay(
new Ray3D(p1, p2.sub(p1)));
//if we do not find a point try the other direction
if (intersect == null)
intersect = (Vec3D) slicePlane.getPlane()
.getIntersectionWithRay(
new Ray3D(p2, p1.sub(p2)));
//if we do not find a point try the other direction
if (intersect == null)
intersect = (Vec3D) slicePlane.getPlane()
.getIntersectionWithRay(
new Ray3D(p2.sub(p1.sub(p2)), p1
.sub(p2)));
//if we do not find a point try the other direction
if (intersect == null)
intersect = (Vec3D) slicePlane.getPlane()
.getIntersectionWithRay(
new Ray3D(p2.add(p1.sub(p2)), p1
.sub(p2)));
collisionsFound++;
//we found a intersection with the plane
if (intersect != null) {
float distToP1 = intersect.distanceTo(p1); //dist to intersection
float distToP2 = intersect.distanceTo(p2); //dist to intersection
float distBetweenP1P2 = p1.distanceTo(p2);
float percentBetween = distToP1 / distBetweenP1P2; //distBetweenP1P2;
float percent = 0;
//special case for 2 point lines
float splneLen = (spline.getCentrePath()
.getlength());
percent = ((lenToNext - distToP2) / splneLen);
// System.out.println(percentBetween + "in");
// for (int k = 0; k < points.size(); k++) {
// float percent = (Float) points.get(k);
float deltaPercent = Math.abs(percent
- externalCurvePercent);
/*
LOGGER.info("distToP1 " + distToP1 +
" distToP2 "+distToP2 +
" lenToNext " + lenToNext +
" percentBetween " + percentBetween +
" percent" + percent +
" splneLen " + splneLen +
" i " + i + " i2 " + i2 +
" externalCurvePercent "+externalCurvePercent +
" deltaPercent "+ deltaPercent +
" neartestDist " + neartestDist);
*/
if (deltaPercent < neartestDist
|| neartestDist == -1) {
// if ( collisionsFound == 3){
neartestDist = deltaPercent;
percentReturn.x = (p12D.x * (1 - percentBetween))
+ (p22D.x * (percentBetween));
percentReturn.y = (p12D.y * (1 - percentBetween))
+ (p22D.y * (percentBetween));
returnVec3D = intersect.copy();
//if(neartestDist > .2f)
// returnVec3D = null;
// System.out.println(percent +" P");
//LOGGER.info("percent "+percentBetween);
}
// }
// returnList.add(new Float(percent));
}
// System.out.println(p1);
// System.out.println(p2);
}
}
}
//.info("returnVec3D " + returnVec3D);
}
if (returnVec3D != null) {
returnVec3D.subSelf(slicePlane.getPlane());
returnVec3D
.rotateY((float) (functions.angleOf(new Vec2D(slicePlane
.getPlane().normal.x,
slicePlane.getPlane().normal.z)) - (Math.PI / 2)));
float rotateAn = (functions.angleOf(new Vec2D(
slicePlane.getPlane().normal.x,
slicePlane.getPlane().normal.y)));
if (rotateAn < Math.PI / 2 || rotateAn > (Math.PI / 2) * 3){
rotateAn = (float) ((Math.PI * 2) - Math.abs(rotateAn));