public static void ReAddRocketTrajectoryMissingAreas(RocketEntityPoly rocketEntityPoly, BumperEntityPoly bumperEntity, ref List <List <IntPoint> > delPolys) { var bumpRigid = bumperEntity.CompObj as BumpRigid; var bumpPosXNA = bumpRigid.PositionXNA2D; var bumpPosCenter = bumpRigid.PositionXNACenter2D; Vector2 bP1, bP2; ProjectionHandler.FindBumperTwoBorderPoints(bumperEntity, out bP1, out bP2); Vector2 rP1, rP2; ProjectionHandler.FindRocketTwoBorderPoints(rocketEntityPoly, out rP1, out rP2); Vector2 interP; MathHelperModule.FindIntersection(bP1, bP2, rP1, rP2, out interP); Vector2 cutP = GetBumperCutStartingPoint(bumpRigid.Dir, bP1, bP2, (rocketEntityPoly.CompObj as RocketCarrierService).PositionXNACenter2D); if (!RigidsHelperModule.IsCloseEnough(interP, (bumperEntity.CompObj as BumpRigid).PositionXNACenter2D, 20)) // if the bump is not on the collision course with the rocket { // Rocket is not on a collision course with the bump, so cut down the del poly area vertically List <IntPoint> polyInverseCutVertical = GetInverseCutPolygon(cutP, rocketEntityPoly); EntraDrawer.DrawIntoFile(new List <List <IntPoint> >() { polyInverseCutVertical }); delPolys = EntraSolver.GetPolySolution(delPolys, polyInverseCutVertical, ClipType.ctIntersection); EntraDrawer.DrawIntoFile(delPolys); } }
public static void RemoveRocketsPolysIntersectionWithPlanes(RocketCarrierService rocket, ref List <List <IntPoint> > poly) { Vector2 rP1, rP2; ProjectionHandler.FindRocketTwoBorderPoints(rocket, out rP1, out rP2); Vector2 rPosCenter = new Vector2((rP1.X + rP2.X) / 2, (rP1.Y + rP2.Y) / 2); for (int i = 0; i < 7; i += 2) { var cDir = (Direction)i; //if (CompIsOnDirToBump(compPos, rPosCenter, cDir)) //{ Vector2 planeP1, planeP2; GetPlanePoints(cDir, out planeP1, out planeP2); Vector2 interP; MathHelperModule.FindIntersection(planeP1, planeP2, rP1, rP2, out interP); if (interP.X <= StaticData.LevelFarWidth && interP.X >= 0 && interP.Y <= StaticData.LevelFarHeight && interP.Y >= 0) { // Rocket is not on a collision course with the bump, // so cut down the del poly area vertically List <IntPoint> polyInverseCutVertical = GetInverseCutPolygon(interP, rocket.PositionXNACenter2D); EntraDrawer.DrawIntoFile(new List <List <IntPoint> >() { polyInverseCutVertical }); poly = EntraSolver.GetPolySolution(poly, polyInverseCutVertical, ClipType.ctIntersection); EntraDrawer.DrawIntoFile(poly); } // } } }