Skip to main content
deleted 430 characters in body
Source Link

I've started writing code for collision detection in a 2D game, and common methods I've seen include gridding and quadtrees. I also plan to use them for nearest neighbour searches, etc.


I see mostA lot of games store object positions as floats and have a closed ball for the game area (eg. a rectangle and objects are allowed to have position coordinates on all 4 edges).

However, this becomes problematic when dividingpartitioning the game area up (for botheg. gridding/quadtrees). You'll either have to includeThe edge cases would have to be added in your code so that 2 edges of the game area are included in rectangles that touch them or you miss out 2 edges in collision detection (in which case objects on those2 edges won'twould have to be missed out in the grid/tree)partition.


I haven't seen this sort of problem mentioned in any of the articles I've read/when I search it up. So I wonder - isIs there another solution to this or do games (and other programs this applies to) usually go with one of the above 2 solutions?

(In one example I noticed object positions were integers which avoids this problemOne solution is to use integer coordinates, but I'd rather keep them aswhat if using floats in the game I'm makingis unavoidable?)

I've started writing code for collision detection in a 2D game, and common methods I've seen include gridding and quadtrees. I also plan to use them for nearest neighbour searches, etc.


I see most games store object positions as floats and have a closed ball for the game area (eg. a rectangle and objects are allowed to have position coordinates on all 4 edges).

However, this becomes problematic when dividing the game area up (for both gridding/quadtrees). You'll either have to include edge cases in your code so that 2 edges of the game area are included in rectangles that touch them or you miss out 2 edges in collision detection (in which case objects on those edges won't be in the grid/tree).


I haven't seen this sort of problem mentioned in any of the articles I've read/when I search it up. So I wonder - is there another solution to this or do games usually go with one of the above 2 solutions?

(In one example I noticed object positions were integers which avoids this problem, but I'd rather keep them as floats in the game I'm making)

A lot of games store object positions as floats and have a closed ball for the game area (eg. a rectangle and objects are allowed to have position coordinates on all 4 edges).

However, this becomes problematic when partitioning the game area (eg. gridding/quadtrees). The edge cases would have to be added in so that 2 edges of the game area are included in rectangles that touch them or objects on 2 edges would have to be missed out in the partition.


Is there another solution to this or do games (and other programs this applies to) usually go with one of the above 2?

(One solution is to use integer coordinates, but what if using floats is unavoidable?)

deleted 21 characters in body
Source Link

I've started writing code for collision detection in a 2D game, and common methods I've seen include gridding and quadtrees. I also plan to use them for nearest neighbour searches, etc.


I see most games store object positions as floats and have a closed ball for the game area (eg. a rectangle and objects are allowed to have position coordinates on all 4 edges).

However, this becomes problematic when dividing the game area up (for both gridding/quadtrees). You'll either have to include edge cases in your code so that 2 edges of the game area are included in rectangles that touch them or you miss out 2 edges in collision detection (in which case objects on those edges won't be in the grid/tree).


I haven't seen this sort of problem mentioned in any of the articles I've read/when I search it up. So I wonder - is there another solution to this I haven't thought of or do games usually go with one of the above 2 solutions?

(In one example I noticed object positions were integers which avoids this problem, but I'd rather keep them as floats in the game I'm making)

I've started writing code for collision detection in a 2D game, and common methods I've seen include gridding and quadtrees. I also plan to use them for nearest neighbour searches, etc.


I see most games store object positions as floats and have a closed ball for the game area (eg. a rectangle and objects are allowed to have position coordinates on all 4 edges).

However, this becomes problematic when dividing the game area up (for both gridding/quadtrees). You'll either have to include edge cases in your code so that 2 edges of the game area are included in rectangles that touch them or you miss out 2 edges in collision detection (in which case objects on those edges won't be in the grid/tree).


I haven't seen this sort of problem mentioned in any of the articles I've read/when I search it up. So I wonder - is there another solution to this I haven't thought of or do games usually go with one of the above 2 solutions?

(In one example I noticed object positions were integers which avoids this problem, but I'd rather keep them as floats in the game I'm making)

I've started writing code for collision detection in a 2D game, and common methods I've seen include gridding and quadtrees. I also plan to use them for nearest neighbour searches, etc.


I see most games store object positions as floats and have a closed ball for the game area (eg. a rectangle and objects are allowed to have position coordinates on all 4 edges).

However, this becomes problematic when dividing the game area up (for both gridding/quadtrees). You'll either have to include edge cases in your code so that 2 edges of the game area are included in rectangles that touch them or you miss out 2 edges in collision detection (in which case objects on those edges won't be in the grid/tree).


I haven't seen this sort of problem mentioned in any of the articles I've read/when I search it up. So I wonder - is there another solution to this or do games usually go with one of the above 2 solutions?

(In one example I noticed object positions were integers which avoids this problem, but I'd rather keep them as floats in the game I'm making)

added 71 characters in body
Source Link

I've started writing code for collision detection in a 2D game, and common methods I've seen include gridding and quadtrees. I also plan to use them for nearest neighbour searches, etc.

 

I see most games store object positions as floats and have a closed ball for the game area (eg. a rectangle and objects are allowed to have position coordinates on all 4 edges).

However, this becomes problematic when dividing the game area up (for both gridding/quadtrees). You'll either have to include edge cases in your code so that 2 edges of the game area are included in rectangles that touch them or you miss out 2 edges in collision detection (in which case objects on those edges won't be in the grid/tree).

 

I haven't seen this sort of problem mentioned in any of the articles I've read/when I search it up. So I wonder - is there another solution to this I haven't thought of or do games usually go with one of the above 2 solutions?

(In one example I noticed object positions were integers which avoids this problem, but I'd rather keep them as floats in the game I'm making)

I've started writing code for collision detection in a 2D game, and common methods I've seen include gridding and quadtrees. I also plan to use them for nearest neighbour searches, etc.

I see most games store object positions as floats and have a closed ball for the game area (eg. a rectangle and objects are allowed to have position coordinates on all 4 edges).

However, this becomes problematic when dividing the game area up (for both gridding/quadtrees). You'll either have to include edge cases in your code so that 2 edges of the game area are included in rectangles that touch them or you miss out 2 edges in collision detection (in which case objects on those edges won't be in the grid/tree).

I haven't seen this sort of problem mentioned in any of the articles I've read/when I search it up. So I wonder - is there another solution to this I haven't thought of?

(In one example I noticed object positions were integers which avoids this problem, but I'd rather keep them as floats in the game I'm making)

I've started writing code for collision detection in a 2D game, and common methods I've seen include gridding and quadtrees. I also plan to use them for nearest neighbour searches, etc.

 

I see most games store object positions as floats and have a closed ball for the game area (eg. a rectangle and objects are allowed to have position coordinates on all 4 edges).

However, this becomes problematic when dividing the game area up (for both gridding/quadtrees). You'll either have to include edge cases in your code so that 2 edges of the game area are included in rectangles that touch them or you miss out 2 edges in collision detection (in which case objects on those edges won't be in the grid/tree).

 

I haven't seen this sort of problem mentioned in any of the articles I've read/when I search it up. So I wonder - is there another solution to this I haven't thought of or do games usually go with one of the above 2 solutions?

(In one example I noticed object positions were integers which avoids this problem, but I'd rather keep them as floats in the game I'm making)

deleted 2 characters in body
Source Link
Loading
deleted 21 characters in body
Source Link
Loading
"edge case" is a generic term for any rare situation / at the extreme of some parameter's range. Here you mean something more specific.
Link
DMGregory
  • 136.3k
  • 22
  • 247
  • 373
Loading
deleted 11 characters in body
Source Link
Loading
Source Link
Loading