@@ -1685,25 +1685,30 @@ def get_nearby_sprite_indices(self, pos: Point, size: Point, length: int) -> lis
16851685 A list of indices of nearby sprites.
16861686 """
16871687 ctx = self .ctx
1688+ if ctx ._gl_api == "webgl" :
1689+ raise RuntimeError ("GPU Collision is not supported on WebGL Backends" )
1690+
1691+ # All of these type ignores are because of GPU collision not being supported on WebGL
1692+ # Unfortuantely the type checkers don't have a sane way of understanding that, and it's
1693+ # not worth run-time checking all of these things, because they are guaranteed based on
1694+ # active GL api of the context. Pyright actually does seem to be able to figure it out
1695+ # but mypy does not
16881696
1689- ctx .collision_detection_program ["check_pos" ] = pos
1690- ctx .collision_detection_program ["check_size" ] = size
1697+ ctx .collision_detection_program ["check_pos" ] = pos # type: ignore
1698+ ctx .collision_detection_program ["check_size" ] = size # type: ignore
16911699 buffer = ctx .collision_buffer
1692- with ctx .collision_query :
1693- # These calls are typed as | None because of the arcade.gl backends, but at this
1694- # point if we have SpriteListBufferData these are guaranteed to be on a backend
1695- # where they will not be None.
1700+ with ctx .collision_query : # type: ignore
16961701 self ._geometry .transform (
16971702 ctx .collision_detection_program , # type: ignore
16981703 buffer , # type: ignore
16991704 vertices = length ,
17001705 )
17011706
17021707 # Store the number of sprites emitted
1703- emit_count = ctx .collision_query .primitives_generated
1708+ emit_count = ctx .collision_query .primitives_generated # type: ignore
17041709 if emit_count == 0 :
17051710 return []
1706- return [i for i in struct .unpack (f"{ emit_count } i" , buffer .read (size = emit_count * 4 ))]
1711+ return [i for i in struct .unpack (f"{ emit_count } i" , buffer .read (size = emit_count * 4 ))] # type: ignore
17071712
17081713
17091714class SpriteListTextureData (SpriteListData ):
@@ -1892,25 +1897,30 @@ def get_nearby_sprite_indices(self, pos: Point, size: Point, length: int) -> lis
18921897 ctx = self .ctx
18931898 if ctx ._gl_api == "webgl" :
18941899 raise RuntimeError ("GPU Collision is not supported on WebGL Backends" )
1900+
1901+ # All of these type ignores are because of GPU collision not being supported on WebGL
1902+ # Unfortuantely the type checkers don't have a sane way of understanding that, and it's
1903+ # not worth run-time checking all of these things, because they are guaranteed based on
1904+ # active GL api of the context. Pyright actually does seem to be able to figure it out
1905+ # but mypy does not
1906+
18951907 buffer = ctx .collision_buffer
18961908 program = ctx .collision_detection_program_simple
1897- program ["check_pos" ] = pos
1898- program ["check_size" ] = size
1909+ program ["check_pos" ] = pos # type: ignore
1910+ program ["check_size" ] = size # type: ignore
18991911
19001912 self ._storage_pos_angle .use (0 )
19011913 self ._storage_size .use (1 )
19021914 self ._storage_index .use (2 )
19031915
1904- with ctx .collision_query :
1905- # This is ignored because it is guaranteed to not be none by the above context GL api
1906- # check. This is only able to be None when we are on WebGL.
1916+ with ctx .collision_query : # type: ignore
19071917 ctx .geometry_empty .transform (
1908- program ,
1918+ program , # type: ignore
19091919 buffer , # type: ignore
19101920 vertices = length ,
19111921 )
1912- emit_count = ctx .collision_query .primitives_generated
1922+ emit_count = ctx .collision_query .primitives_generated # type: ignore
19131923 # print(f"Collision query emitted {emit_count} sprites")
19141924 if emit_count == 0 :
19151925 return []
1916- return [i for i in struct .unpack (f"{ emit_count } i" , buffer .read (size = emit_count * 4 ))]
1926+ return [i for i in struct .unpack (f"{ emit_count } i" , buffer .read (size = emit_count * 4 ))] # type: ignore
0 commit comments