Repository navigation
Fix rand_vec_spread_deg directions, large GL reads, and pixel test helpers - #2945
Merged
Merged
Conversation
…lpers - rand_vec_spread_deg passed degrees to Vec2.from_polar, which takes radians, so its vectors pointed in random directions (#2648). - Texture, texture array, framebuffer and buffer reads used ctypes.string_at, whose size is a C long: 32 bits on Windows, so reads of 2 GB or more failed. They copy with bytes() instead (#2836). - The offscreen test fixture's read_pixel and read_region decoded 4 bytes per channel from 1 byte per channel data, and read_pixel ignored its components argument (#2473). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three small fixes found while triaging issues.
rand_vec_spread_degpoints in random directions (fixes #2648)arcade.math.rand_vec_spread_deg(angle, half_angle_spread, length)passed the angle in degrees toVec2.from_polar, which takes radians. Sorand_vec_spread_deg(90, 5, 1)gave directions like -26°, 110° and -150°. Two emitters in theparticle_systemsexample use it and sprayed everywhere. It now converts the angle to radians, and the docstring says both angles are in degrees.Not changed: the same example calls
rand_vec_magnitude(45, ...), which takes radians, so those two emitters fire at about 58° instead of 45°. They still fire in one fixed direction as described, so I left them alone.Reads of 2 GB or more fail on Windows (fixes #2836)
Texture, texture array, framebuffer and buffer reads used
ctypes.string_at(ptr, size). Its size is a Clong, which is 32 bits on Windows. I confirmed it with a 2 GB ctypes array:string_atraisedSystemError: Negative size passed to PyBytes_FromStringAndSize.bytes(buffer)read all of it in 0.65 s.These reads now copy with
bytes(). The buffer read, which maps a pointer, casts it to a ctypes array of the right size first. Linux has a 64-bitlong, so it wasn't affected.Broken pixel helpers in the test fixture (related to #2473)
The
offscreenfixture'sread_pixelandread_regiondecoded 4 bytes per channel from framebuffer data that has 1 byte per channel, so they returned garbage.read_pixelalso ignored itscomponentsargument. Nothing used them yet. Both are fixed and now tested.#2473 also asks for a window-level
fetch_pixelAPI, so this PR doesn't close it.Tests
rand_vec_spread_deg: checks the direction stays within the spread and the length is right, for four angles. 4 of the 4 cases fail on development.test_offscreen_fixture.py. Both tests fail with the old helpers.Full suite: 1761 passed. ruff, mypy and pyright all pass.
The changelog has entries under Unreleased → Fixes.
🤖 Generated with Claude Code