mirror of
https://github.com/panda3d/panda3d.git
synced 2026-04-30 11:40:47 -05:00
Merge branch 'release/1.10.x'
This commit is contained in:
@@ -101,3 +101,65 @@ def test_geom_linestrips_adjacency():
|
||||
3, 4, 5, 6,
|
||||
4, 5, 6, 6,
|
||||
)
|
||||
|
||||
|
||||
def test_geom_linestrips_offset_indexed():
|
||||
prim = core.GeomLinestrips(core.GeomEnums.UH_static)
|
||||
prim.add_vertex(0)
|
||||
prim.add_vertex(1)
|
||||
prim.close_primitive()
|
||||
prim.add_vertex(1)
|
||||
prim.add_vertex(2)
|
||||
prim.add_vertex(3)
|
||||
prim.close_primitive()
|
||||
prim.add_vertex(3)
|
||||
prim.add_vertex(4)
|
||||
prim.add_vertex(5)
|
||||
prim.add_vertex(6)
|
||||
prim.close_primitive()
|
||||
|
||||
prim.offset_vertices(100)
|
||||
verts = prim.get_vertex_list()
|
||||
cut = prim.strip_cut_index
|
||||
assert tuple(verts) == (
|
||||
100, 101,
|
||||
cut,
|
||||
101, 102, 103,
|
||||
cut,
|
||||
103, 104, 105, 106,
|
||||
)
|
||||
|
||||
prim.offset_vertices(-100)
|
||||
verts = prim.get_vertex_list()
|
||||
cut = prim.strip_cut_index
|
||||
assert tuple(verts) == (
|
||||
0, 1,
|
||||
cut,
|
||||
1, 2, 3,
|
||||
cut,
|
||||
3, 4, 5, 6,
|
||||
)
|
||||
|
||||
prim.offset_vertices(100, 4, 9)
|
||||
verts = prim.get_vertex_list()
|
||||
cut = prim.strip_cut_index
|
||||
assert tuple(verts) == (
|
||||
0, 1,
|
||||
cut,
|
||||
1, 102, 103,
|
||||
cut,
|
||||
103, 104, 5, 6,
|
||||
)
|
||||
|
||||
# Automatically upgrade to uint32
|
||||
prim.offset_vertices(100000)
|
||||
assert prim.index_type == core.GeomEnums.NT_uint32
|
||||
verts = prim.get_vertex_list()
|
||||
cut = prim.strip_cut_index
|
||||
assert tuple(verts) == (
|
||||
100000, 100001,
|
||||
cut,
|
||||
100001, 100102, 100103,
|
||||
cut,
|
||||
100103, 100104, 100005, 100006,
|
||||
)
|
||||
|
||||
@@ -158,3 +158,51 @@ def test_texture_peek_int_i():
|
||||
col = LColor()
|
||||
peeker.fetch_pixel(col, 0, 0)
|
||||
assert col == (minval, -1, 0, maxval)
|
||||
|
||||
|
||||
def test_texture_peek_cube():
|
||||
maxval = 255
|
||||
data_list = []
|
||||
for z in range(6):
|
||||
for y in range(3):
|
||||
for x in range(3):
|
||||
data_list += [z, y, x, maxval]
|
||||
data = array('B', data_list)
|
||||
tex = Texture("")
|
||||
tex.setup_cube_map(3, Texture.T_unsigned_byte, Texture.F_rgba8i)
|
||||
tex.set_ram_image(data)
|
||||
peeker = tex.peek()
|
||||
assert peeker.has_pixel(0, 0)
|
||||
assert peeker.has_pixel(0, 0, 0)
|
||||
|
||||
# If no z is specified, face 0 is used by default
|
||||
col = LColor()
|
||||
peeker.fetch_pixel(col, 1, 2)
|
||||
assert col == (1, 2, 0, maxval)
|
||||
|
||||
# Now try each face
|
||||
for faceidx in range(6):
|
||||
col = LColor()
|
||||
peeker.fetch_pixel(col, 0, 0, faceidx)
|
||||
assert col == (0, 0, faceidx, maxval)
|
||||
|
||||
# Try some vector lookups.
|
||||
def lookup(*vec):
|
||||
col = LColor()
|
||||
peeker.lookup(col, *vec)
|
||||
return col
|
||||
assert lookup(1, 0, 0) == (1, 1, 0, maxval)
|
||||
assert lookup(-1, 0, 0) == (1, 1, 1, maxval)
|
||||
assert lookup(0, 1, 0) == (1, 1, 2, maxval)
|
||||
assert lookup(0, -1, 0) == (1, 1, 3, maxval)
|
||||
assert lookup(0, 0, 1) == (1, 1, 4, maxval)
|
||||
assert lookup(0, 0, -1) == (1, 1, 5, maxval)
|
||||
|
||||
# Magnitude shouldn't matter
|
||||
assert lookup(0, 2, 0) == (1, 1, 2, maxval)
|
||||
assert lookup(0, 0, -0.5) == (1, 1, 5, maxval)
|
||||
|
||||
# Sample in corner (slight bias to disambiguate which face is selected)
|
||||
assert lookup(1.00001, 1, 1) == (0, 0, 0, maxval)
|
||||
assert lookup(1.00001, 1, 0) == (1, 0, 0, maxval)
|
||||
assert lookup(1, 1.00001, 0) == (2, 1, 2, maxval)
|
||||
|
||||
@@ -157,3 +157,25 @@ def test_weighted_choice():
|
||||
# When subtracting that number by each weight, it will reach 0
|
||||
# by the time it hits 'item6' in the iteration.
|
||||
assert item == items[5]
|
||||
|
||||
|
||||
def test_serial():
|
||||
gen = PythonUtil.SerialNumGen()
|
||||
assert gen.next() == 0
|
||||
assert next(gen) == 1
|
||||
assert next(gen) == 2
|
||||
assert gen.next() == 3
|
||||
|
||||
|
||||
def test_alphabet_counter():
|
||||
counter = PythonUtil.AlphabetCounter()
|
||||
assert next(counter) == 'A'
|
||||
assert counter.next() == 'B'
|
||||
assert counter.next() == 'C'
|
||||
assert next(counter) == 'D'
|
||||
|
||||
for i in range(26 - 4):
|
||||
next(counter)
|
||||
|
||||
assert next(counter) == 'AA'
|
||||
assert next(counter) == 'AB'
|
||||
|
||||
Reference in New Issue
Block a user