mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 01:07:51 -04:00
tests: Add some unit tests for #987
This commit is contained in:
parent
be24266715
commit
9ac1a4f7cb
@ -1,4 +1,4 @@
|
||||
from panda3d.core import PerspectiveLens, Point3, Point2
|
||||
from panda3d.core import PerspectiveLens, Point3, Point2, CS_zup_right
|
||||
|
||||
|
||||
def test_perspectivelens_extrude():
|
||||
@ -75,3 +75,25 @@ def test_perspectivelens_project():
|
||||
|
||||
assert lens.project((100, 100, 0), point)
|
||||
assert point.almost_equal((1, 0), 0.001)
|
||||
|
||||
|
||||
def test_perspectivelens_far_inf():
|
||||
lens = PerspectiveLens()
|
||||
lens.set_fov(90, 90)
|
||||
lens.set_near_far(2, float("inf"))
|
||||
lens.coordinate_system = CS_zup_right
|
||||
|
||||
mat = lens.get_projection_mat()
|
||||
assert mat[1][2] == 1
|
||||
assert mat[3][2] == -4
|
||||
|
||||
|
||||
def test_perspectivelens_near_inf():
|
||||
lens = PerspectiveLens()
|
||||
lens.set_fov(90, 90)
|
||||
lens.set_near_far(float("inf"), 2)
|
||||
lens.coordinate_system = CS_zup_right
|
||||
|
||||
mat = lens.get_projection_mat()
|
||||
assert mat[1][2] == -1
|
||||
assert mat[3][2] == 4
|
||||
|
@ -62,3 +62,31 @@ def test_vec2_compare():
|
||||
assert Vec2(1, 0).compare_to(Vec2(0, 1)) == 1
|
||||
assert Vec2(0, 1).compare_to(Vec2(1, 0)) == -1
|
||||
assert Vec2(0, 1).compare_to(Vec2(0, 1)) == 0
|
||||
|
||||
|
||||
def test_vec2_nan():
|
||||
nan = float("nan")
|
||||
inf = float("inf")
|
||||
assert not Vec2F(0, 0).is_nan()
|
||||
assert not Vec2F(1, 0).is_nan()
|
||||
assert Vec2F(nan, 0).is_nan()
|
||||
assert Vec2F(0, nan).is_nan()
|
||||
assert Vec2F(nan, nan).is_nan()
|
||||
assert Vec2F(-nan, 0).is_nan()
|
||||
assert Vec2F(-nan, nan).is_nan()
|
||||
assert Vec2F(inf, nan).is_nan()
|
||||
assert not Vec2F(inf, 0).is_nan()
|
||||
assert not Vec2F(inf, inf).is_nan()
|
||||
assert not Vec2F(-inf, 0).is_nan()
|
||||
|
||||
assert not Vec2D(0, 0).is_nan()
|
||||
assert not Vec2D(1, 0).is_nan()
|
||||
assert Vec2D(nan, 0).is_nan()
|
||||
assert Vec2D(0, nan).is_nan()
|
||||
assert Vec2D(nan, nan).is_nan()
|
||||
assert Vec2D(-nan, 0).is_nan()
|
||||
assert Vec2D(-nan, nan).is_nan()
|
||||
assert Vec2D(inf, nan).is_nan()
|
||||
assert not Vec2D(inf, 0).is_nan()
|
||||
assert not Vec2D(inf, inf).is_nan()
|
||||
assert not Vec2D(-inf, 0).is_nan()
|
||||
|
Loading…
x
Reference in New Issue
Block a user