Colors Collison
Colors Collison
Is it possible to detect if an object collides with an other that has a specific color (or outline color) without using any other collision detection techniques? (e.g. AABB)
Weeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeooow!!
Re: Colors Collison
Not really, no.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
-
- Party member
- Posts: 730
- Joined: Sat Apr 26, 2014 7:46 pm
Re: Colors Collison
You could write some code that can take an image and generate a list of polygons or triangles that would give a more accurate collision box without having to check the color of each pixel. There is programs like this that exist and you could probably adapt them to work with your choice collision lib. I personally used it to export bounding boxes for love.physics. This is the tool I used https://www.codeandweb.com/physicseditor it may be possible to make your own.
Re: Colors Collison
I would just assign collision groups by giving each object's table another variable.
Code: Select all
-- In collision detection function...
if object1.colGroup == "red" and object2.colGroup == "green" then
-- collide
end
Re: Colors Collison
I'm a fan of spatial-hashing.
Take a table, and assign each location on screen a value. 1 for top left. 16 for top right, 17 for just below top left, you get the idea. For a 16:9 aspect ratio, that's 144 cells. In each cell, have a table. Now, on each update, you clear those tables, and then iterate through your entities. Map them as best you can to the cells that they're overlapping with. Since all the cells will be the same size, this is easy math, but it's important that ALL of the cells the entity overlaps are mapped. In each mapped cell, add that entity to the back of the list. Now, for each entity, if you're adding it to a list that has anything else in that list, you collect those entities into another list.
Now, you have a short list of potential hits for each entity. You can AABB or any more expensive collision checks against the smaller set.
Take a table, and assign each location on screen a value. 1 for top left. 16 for top right, 17 for just below top left, you get the idea. For a 16:9 aspect ratio, that's 144 cells. In each cell, have a table. Now, on each update, you clear those tables, and then iterate through your entities. Map them as best you can to the cells that they're overlapping with. Since all the cells will be the same size, this is easy math, but it's important that ALL of the cells the entity overlaps are mapped. In each mapped cell, add that entity to the back of the list. Now, for each entity, if you're adding it to a list that has anything else in that list, you collect those entities into another list.
Now, you have a short list of potential hits for each entity. You can AABB or any more expensive collision checks against the smaller set.
- Roland_Yonaba
- Inner party member
- Posts: 1563
- Joined: Tue Jun 21, 2011 6:08 pm
- Location: Ouagadougou (Burkina Faso)
- Contact:
Re: Colors Collison
And in that respect, I might already have something ready.Inny wrote:I'm a fan of spatial-hashing.
Take a table, and assign each location on screen a value. 1 for top left. 16 for top right, 17 for just below top left, you get the idea. For a 16:9 aspect ratio, that's 144 cells. In each cell, have a table. Now, on each update, you clear those tables, and then iterate through your entities. Map them as best you can to the cells that they're overlapping with. Since all the cells will be the same size, this is easy math, but it's important that ALL of the cells the entity overlaps are mapped. In each mapped cell, add that entity to the back of the list. Now, for each entity, if you're adding it to a list that has anything else in that list, you collect those entities into another list.
Now, you have a short list of potential hits for each entity. You can AABB or any more expensive collision checks against the smaller set.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 2 guests