Ejemplo n.º 1
0
def test_projection_matrix_updates_when_assigning_new_projection():
    cam = Camera()
    assert (cam.projection_matrix == cam.projection.projection_matrix).all()

    old_projmat = cam.projection_matrix.copy()
    cam.projection = OrthoProjection()
    assert (cam.projection_matrix == cam.projection.projection_matrix).all()
    assert not (cam.projection_matrix == old_projmat).all()
    assert not (cam.projection.projection_matrix == old_projmat).all()

    cam.projection = PerspectiveProjection()
    assert (cam.projection_matrix == old_projmat).all()
Ejemplo n.º 2
0
def test_projection_attributes_change_cameras_projection_matrix_uniform():
    cam = Camera()
    for proj in [(), PerspectiveProjection(), PerspectiveProjection()]:
        if isinstance(proj, int):
            cam, proj = Camera(name='Early'), PerspectiveProjection()
            cam.projection = proj
        elif proj:
            cam = Camera(projection=proj)
        old_projmat = cam.projection_matrix.copy()
        old_pm_uni = cam.uniforms['projection_matrix'].copy()
        assert np.all(old_projmat == old_pm_uni)
        cam.projection.aspect = np.random.random()
        assert np.any(cam.projection_matrix != old_projmat)
        assert np.any(cam.uniforms['projection_matrix'] != old_pm_uni)
        assert np.all(
            cam.projection_matrix == cam.uniforms['projection_matrix'])
        assert np.all(
            cam.projection.projection_matrix == cam.projection_matrix)
        assert np.all(cam.uniforms['projection_matrix'] ==
                      cam.projection.projection_matrix)