Comments (5)
I thought we settled for using directions?
from pygame-geometry.
I don't like this as it's sub-optimal to go trough 2 lists just to get the origin and end positions so this
@overload
def multiraycast(
origin_positions: Sequence[Coordinate],
end_positions: Sequence[Coordinate],
colliders: Sequence[Rect, Circle, Line],
) -> Sequence[Optional[Tuple[float, float]]]: ...
Is a No-No for me.
I was thinking of something more like the pygame.Surface.blits() function, in that you pass it a list of containers that represent the surface, where you wanna blit it etc.
Basically i was thinking of a very compact approach that accepts a list of tuples that represent a ray, and that ray can be interpreted in various ways
@overload
def multiraycast(
rays: Sequence[Ray],
colliders: Sequence[Rect, Circle, Line],
) -> Sequence[Optional[Tuple[float, float]]]: ...
Where Ray
can be either of the following:
- Tuple
(origin_pos, end_pos, max_dist)
- Tuple
(origin_pos, angle, max_dist)
- Tuple
(origin_pos, direction, max_dist)
Line
Would also be interesting to have an additional parameter that dictates whether None
objects are appended to the return list if no intersection is found, so something like:
@overload
def multiraycast(
rays: Sequence[Ray],
colliders: Sequence[Rect, Circle, Line],
include_miss: bool,
) -> Sequence[Optional[Tuple[float, float]]]: ...
And also, given that the majority of the times people will either use a batch of rays with infinite max_dist
or all with the same max_dist
, could be an efficiency fix to add another parameter that applies the same max_distance to each ray so that you don't have to specify a max_dist for each ray and we don't need to exract them:
@overload
def multiraycast(
rays: Sequence[Ray],
colliders: Sequence[Rect, Circle, Line],
include_miss: bool,
global_max_dist: float,
) -> Sequence[Optional[Tuple[float, float]]]: ...
And with that, given that it's possible that someone might want to set global_max_dist
and not include_miss
, i'd suggest we make this one a kwargs function.
from pygame-geometry.
It seems that @itzpr3d4t0r has the right idea about optimizing this even further. I just want to be clear that we will not be creating a new Ray
object.
I think adding None
to the returned list is a good idea so that users can index the results better, I don't see how else they'll be able to do so.
from pygame-geometry.
This also must not be worked on until #127 is fixed and #126 is merged.
from pygame-geometry.
I propose to work on this one after #126 is merged, which is pretty close anyway...
from pygame-geometry.
Related Issues (20)
- Add Polygon collide_circle()
- Add Polygon `colliderect()`
- Make Circle.collideswith() accept Polygons
- Make Line.collideswith() accept Polygons
- Add Line collide_polygon() HOT 1
- Add Circle collide_polygon()
- Line.as_segments() and Line.as_points() functions
- Rename Line's flip()/flip_ip() functions
- Add Line `flip()`
- Add Polygon `flip()`
- Segfault and unwanted behaviour in Line conversion HOT 2
- Python crashes when running the unittests on Linux Mint
- New 3D colliders, like parallelepiped and spheres HOT 1
- Circle `collidelist / collidelistall`
- Line `collidelist / collidelistall`
- Polygon `collidelist / collidelistall`
- Rename "collideswith" methods to "collide"
- Circle `top` / `bottom` / `left` / `right` attribs HOT 2
- Collision indices
- Add `Circle.rotate`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pygame-geometry.