def __calculateClosestPoint(self, start, dir): dir.normalise() end = start + dir.scale(10000.0) testResTerrain = BigWorld.wg_collideSegment(BigWorld.player().spaceID, start, end, 128, 8) terrainSuitsForCheck = testResTerrain and testResTerrain[1].dot(Math.Vector3(0.0, 1.0, 0.0)) <= math.cos(ShotPointCalculatorPlanar.TERRAIN_MIN_ANGLE) testResNonTerrain = BigWorld.wg_collideSegment(BigWorld.player().spaceID, start, end, 136) testResDynamic = collideDynamic(start, end, (BigWorld.player().playerVehicleID,), False) closestPoint = None closestDist = 1000000 isPointConvenient = True if testResTerrain: closestPoint = testResTerrain[0] closestDist = (testResTerrain[0] - start).length if terrainSuitsForCheck: isPointConvenient = closestDist >= ShotPointCalculatorPlanar.MIN_DIST if testResNonTerrain is not None: dist = (testResNonTerrain[0] - start).length if dist < closestDist: closestPoint = testResNonTerrain[0] closestDist = dist isPointConvenient = closestDist >= ShotPointCalculatorPlanar.MIN_DIST if closestPoint is None and testResDynamic is None: return (AimingSystems.shootInSkyPoint(start, dir), True) else: if testResDynamic is not None: dynDist = testResDynamic[0] if dynDist <= closestDist: dir = end - start dir.normalise() closestPoint = start + dir * dynDist isPointConvenient = True return (closestPoint, isPointConvenient)
def __calculateClosestPoint(self, start, direction): direction.normalise() distance = self.__vehicleDesc.shot.maxDistance if self.__vehicleDesc is not None else 10000.0 end = start + direction.scale(distance) testResStatic = BigWorld.wg_collideSegment(BigWorld.player().spaceID, start, end, 128) testResDynamic = collideDynamic(start, end, (BigWorld.player().playerVehicleID, ), False) closestPoint = None closestDist = 1000000 isPointConvenient = True if testResStatic: closestPoint = testResStatic.closestPoint closestDist = (closestPoint - start).length shouldCheck = True if testResStatic.isTerrain(): shouldCheck = testResStatic.normal.dot( Math.Vector3(0.0, 1.0, 0.0)) <= math.cos( ShotPointCalculatorPlanar.TERRAIN_MIN_ANGLE) if shouldCheck: isPointConvenient = closestDist >= self.__minDist if closestPoint is None and testResDynamic is None: return (AimingSystems.shootInSkyPoint(start, direction), True) else: if testResDynamic is not None: dynDist = testResDynamic[0] if dynDist <= closestDist: direction = end - start direction.normalise() closestPoint = start + direction * dynDist isPointConvenient = True return (closestPoint, isPointConvenient)