Ejemplo n.º 1
0
    def test_detectHit_allParameters(self):
        bge = Mock()

        sourcePosition = "sp"
        targetPosition = "tp"
        distance = "dist"
        filterProperty = "fp"
        normalDirection = "nd"
        excludeUnfiltered = False
        hitObject = "ho"
        hitPosition = "hp"
        hitNormal = "hn"

        mock = MagicMock(
            return_value=[hitObject, hitPosition, hitNormal])
        bge.logic.getCurrentScene().active_camera.rayCast = mock

        with patch.dict('sys.modules', {'bge': bge}):
            from mbge import physics
            hit = physics.detectHit(sourcePosition, targetPosition, distance,
                                    property=filterProperty,
                                    normalDirection=normalDirection,
                                    xray=excludeUnfiltered)
            self.assertEqual(hit.object, hitObject)
            self.assertEqual(hit.position, hitPosition)
            self.assertEqual(hit.normal, hitNormal)

        bge.logic.getCurrentScene().active_camera.rayCast.assert_called_once_with(
                sourcePosition, targetPosition, distance,
                filterProperty, normalDirection, excludeUnfiltered, 0)
Ejemplo n.º 2
0
    def test_detectHit_allParameters(self):
        bge = Mock()

        sourcePosition = "sp"
        targetPosition = "tp"
        distance = "dist"
        filterProperty = "fp"
        normalDirection = "nd"
        excludeUnfiltered = False
        hitObject = "ho"
        hitPosition = "hp"
        hitNormal = "hn"

        mock = MagicMock(return_value=[hitObject, hitPosition, hitNormal])
        bge.logic.getCurrentScene().active_camera.rayCast = mock

        with patch.dict('sys.modules', {'bge': bge}):
            from mbge import physics
            hit = physics.detectHit(sourcePosition,
                                    targetPosition,
                                    distance,
                                    property=filterProperty,
                                    normalDirection=normalDirection,
                                    xray=excludeUnfiltered)
            self.assertEqual(hit.object, hitObject)
            self.assertEqual(hit.position, hitPosition)
            self.assertEqual(hit.normal, hitNormal)

        bge.logic.getCurrentScene(
        ).active_camera.rayCast.assert_called_once_with(
            sourcePosition, targetPosition, distance, filterProperty,
            normalDirection, excludeUnfiltered, 0)
Ejemplo n.º 3
0
    def test_detectHit_only_mandatoryParameters(self):
        bge = Mock()

        sourcePosition = "sp"
        targetPosition = "tp"
        hitObject = "ho"
        hitPosition = "hp"
        hitNormal = "hn"

        mock = MagicMock(return_value=[hitObject, hitPosition, hitNormal])
        bge.logic.getCurrentScene().active_camera.rayCast = mock

        with patch.dict('sys.modules', {'bge': bge}):
            from mbge import physics
            hit = physics.detectHit(sourcePosition, targetPosition)
            self.assertEqual(hit.object, hitObject)
            self.assertEqual(hit.position, hitPosition)
            self.assertEqual(hit.normal, hitNormal)

            bge.logic.getCurrentScene(
            ).active_camera.rayCast.assert_called_once_with(
                sourcePosition, targetPosition, 0, "", 0, 0, 0)
Ejemplo n.º 4
0
    def test_detectHit_only_mandatoryParameters(self):
        bge = Mock()

        sourcePosition = "sp"
        targetPosition = "tp"
        hitObject = "ho"
        hitPosition = "hp"
        hitNormal = "hn"

        mock = MagicMock(
            return_value=[hitObject, hitPosition, hitNormal])
        bge.logic.getCurrentScene().active_camera.rayCast = mock

        with patch.dict('sys.modules', {'bge': bge}):
            from mbge import physics
            hit = physics.detectHit(sourcePosition, targetPosition)
            self.assertEqual(hit.object, hitObject)
            self.assertEqual(hit.position, hitPosition)
            self.assertEqual(hit.normal, hitNormal)

            bge.logic.getCurrentScene().active_camera.rayCast.assert_called_once_with(
                    sourcePosition, targetPosition, 0,
                    "", 0, 0, 0)