beyond-all-reason / beyond-all-reason/RecoilEngine
Add a synced interface to read images
- Dominant language
- C++
- Stars
- 683
- Forks
- 293
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 40
Description
# User story
Reading an image has many use cases that would be useful in synced.
* define a complex curve by drawing a 1xN gradient, for example for custom weapon damage fall-off.

* define metadata for map terrain simply by drawing over it.

* encoding spatial patterns in an image can generally result in both more readability and less verbosity compared to a bunch of numbers in a lua file.
In particular, the engine currently implements game design via the metalmap being part of the map format. Making it possible to read resource distribution from a raw image would let us decouple it. Mappers would probably be happy as well.
# Request & implementation remarks
Add a synced interface to read a pixel from an image file, i.e.
```
local r, g, b, a = Spring.ReadPixel(img, x, y)
```
I am not specifying what the `img` param should be because there are caveats:
* if it is a filename then there are performance concerns.
* if it is a userdata handle (with corresponding Open/Close inteface) then there may some issues with sync-safety. I believe that synced states are 100% userdata-proof at the moment and that this is done for good reason. Maybe it's still fine but it seems scary.
* if it is a numerical handle then there's the issue of type safety and leaks. This is probably also fine.
Contributor guide
Research direction
Start by reviewing the synced interface request and the proposed Spring.ReadPixel(img, x, y) entry point. Resolve how the image is identified, how pixel reads remain sync-safe, and how handles are opened and closed; done means a documented, working pixel-reading interface that supports the stated image use cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, lua
- Domain
- api, game-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100