A "new" way for Collision detection

Started by
41 comments, last by Red Drake 19 years, 11 months ago
It certainly isn''t "a piece of crap," but octrees are really more practical for 3D applications. 2D applications that have limited sizes (i.e. without scrolling) could use it, however. The problem with your system isn''t that approximations aren''t faster than with a tree, it''s that it can''t resolve the problems I put in my last post.

Again, your approximation is O(1), or constant time... that is a very good thing. But, it really cannot be implemented in a 3D game due to the problems I mentioned.
Advertisement
Not true (at least not at all of it)

You mis understud my idea (completly)

1.) It is not used for Collision detection alone
it yust culls out the uneded detection betwen two objects that are to far away widouth "if" comands (using pointers) and when you cull out the unnedded objects you get the objects that shoud be checked with box, sphere ... or another coalision detection algoritam

2.) You can scale it during runtime - all you need to do is incrise/decrease the metric unit used for dividing the space


3.) And for culling of render

OOOOOOOOOOO
OOOOOOOUUUU
OOOOX->UUUU
OOOOOOOUUUU
OOOOOOOOOOO

the X in the uper matrix is the player camera and the arow
("->") is the direction of viewing so if you render the "U" signs by the pointer you don''t even need to check all if the other "0" are in player view - so you cut back on position comparing (no "if''s") becouse they are all aranged in the matrix (it is why i built it in the first place)

4.) I hawe wrote somthing that you cuod call engine and coallision and culling is not the problem in it

So the only problem lies in the memoy and I hawe yust got an idea how to reduce its size.

so you hawe a square struct

struct MatSquare
{
Character *Chars;
int nChars
Objects *Obj;
int nObjects;
int ObjAloc; //Count of memory alocated
}

but it is not wery good for moving static models (objects)

so you separate the moving objects from non moving

struct MatSquare
{
Character *Chars;
int nChars

Objects *NM_Obj;
int NM_nObjects;
int NM_ObjAloc; //Count of memory alocated

Objects M_*Obj;
int M_nObjects;
int M_ObjAloc; //Count of memory alocated
}

the NM_ prefix is for non moving and the M_ is for moving so if you want to so you can hawe exact num of non moving objects and for moveing you do the folowing
You check the near cordinates for moving objects and alocate the number of moving objects in this square + suraunding squares /2 becouse it is higly unlikely that they wil all be moved in the one square and if this does hapen you keep the old allocation cheking code

M_nObjects++;
if (M_nObjects >= M_ObjAloc)
{
// Hear we woud bil a temporery memory to delit the square then alocate more memory for objects and then copy the data back (prety time consuming)
}

so the ting you did with chapter 4 is avoid this function unles apsolutly nesesary.

P.S.
I am about to write an article becouse most of you people did not understand what i ment to say.

But if you think that the article is a waste of time write in and explain so i might save time (i go to school you know )
Red Drake
I recommend you test your theory, comparing it for speed with other methods before writing an article on it.
The problem is I don''t know other ways of this if I knew i woud not think of a new way to do this.
So in a couple of weeks you will get a source with an article becouse my summer vication is only 1 month away and wright now I am so dedicatet to game developing so much that my grades in school are so low that I yust might hawe to go on extended summer class (hopfuly it won''t come to that).
Theoreticly the my idea shoud work faster becouse it eliminates all unneeded data widouth any if arguments ("Matrix culling").
"Matrix culling" - it is what i am about to call it
is faster (probably) buth somwer inacurate and memory consuming. So if you prefer speed over memory consumation the "Matrix culling" is a choice that you might consider.

Please don''t stop sending any questions & ideas to this forum if you hawe som bceouse i hawe put only basic teory about this , and the practical use is still far away.

If you want to contact me
marino.munitic@public.carnet.hr

Rafael Munitic - The Red Drake
Red Drake
I''m not sure if you understand all the considerations that sirSolarius has brought forward. What happens if more entities are positioned inside the same box? What if an entity occupies two boxes?

Or are you saying that each box is dynamically created to encompass groups of entities? In that case, you could take a look at Recursive Dimensional Clustering (Game Programming Gems 2).

Sorry that most of us here are skeptical, but there aren''t very many new things under the sun. Not that we should give up altogether but, it seems that you''re crying wolf since you haven''t put your theory to the test.

It could be that countless others have done the exact same thing with deplorable results. Hopefully that''s not the case =p DO work out your theory and then we''ll see.
What red drake is talking about is a simple 2d grid that is typically sized to contain only one game object. Such games this could be used for are isometric RPG games. It is quite easy to determine the cells included in the view frustrum and the fact that each grid is of a set size it is easy to test the neighbours for collision/action etc, and its is also easy to move game objects into differrent cells without having to alter a quad tree. As long as the dimensions (ie number of cells) of the grid is set at a small managable amount then it is quite a good system to use.

And sorry red drake, this system was and is being used quite extensively. It was the precursor to quadtrees after all
I''ve tried this system before - its not even slightly as good as a proper oct or quad tree. The main problem being that you don''t take into account the sizes of the objects. Any object spanning a cell boundary gets ignored by others in adjacent cells even though they actually intersect.

If you manually try and compensate then you end up checking adjacent cells. But then it breaks down when you get objects bigger than a cell in size, and don''t even think about detecting collisions between two large objects.

Generalising it by taking into account object sizes ends you up reinventing a quad tree.
I implemented a similar collision detection system about 10 years ago. The big difference between what you're thinking of doing and what I did was that my bins were spherical shells rather than boxes. I calculated the distance of each object from an arbitrary point (the arbritrary point might aswell be the camera position) and placed each object in a shell bin according to the distance. Only objects that were in the same bin or in the 2 adjacent bins were checked for collision. Large objects that spanned more than one shell were placed in all the bins they spanned.

It was for a space game with lots of rocks flying around, since the rocks were fairly evenly spaced the system worked very well.

I hadnt even heard of octree/quadtrees back then so I cant make any performance comparisons.

The advantage of using shells is that you only need a 1 dimensional array so the memory usage is less. The disdavantage being that potentially objects a long way away could be in the same shell. This isn't really a big issue though since you're still culling a lot of objects that cant be in collision, very efficiently.

[edited by - AdrianL on May 20, 2004 1:16:00 PM]
Sory if I did not anwser a questions in past couple of houers - i was in school.

Lets go for anwsers:

1.) I realized i caled this topic the wrong way - it shoud be caled Collision CULLING
Why ?
Becouse it does not check for coalision it yust eliminates the objets that are too far away widouth any IF comands so you detirmine the objets that are best candidates for Collision

2.) SoulSpectre your thinking is so limited .
How can you put 3D space in 2D map - BLUEPRINT (i don't know if i writed that down corectly ) you watch your map from above (imaginary) and flaten the terain so you actualy ditch the height cordinate . This is not wery efective but the theory stil speeds up things (theoreticaly) and it is dedfinetly not the stuf you said (about one object in one square) it can store multiple objects in one cel - Read the cel structure in uper post - it contains a pointer to an struc object so you ccan dinamicly alocate the memory neded for objects in that cell.

P.S. So you se I did think of somthing that goes beyond the limits of 2D

3.)AdrianL you totaly mised the point of the matrtix - it main purpose is the 2D positioning of object in array i dont see how can you use spherical objects but i use SQUARES - 2D not 3D ( again read 1. ). Then you probably did not do the same thing as I do.

4.) OrangyTang - not true.
Lets say that i hawe an object thet goes in to one Square/Cell end ends 3 cels away . Why can't i put a pointer to this object in all the cell that the object pases ??? The trought is that i can and it is exactly what i said in the previus posts

5.) Darkor - See nunmber 1.) at this post THIS IS NOT COLLISION DETECTION it is CULLING WIDOUTH IF COMANDS WITCH BUSTS PREFORMANCE

Men this debating has been so entartainig that i am starting to have fun

So any more Questions
But please read the all posts before you ask and try to understand what i am saying to you ! Then ask becouse i hate repeating things


[edited by - Red Drake on May 20, 2004 1:55:23 PM]
Red Drake
quote:Original post by Red Drake
Why can''t i put a pointer to this object in all the cell that the object pases ??? The trought is that i can and it is exactly what i said in the previus posts

You could do that (and I''ve tried it), but it makes maintaining the entire structure a nightmare. You''ll end up doing so many pointer removals and re-insertions that you''ll kill your performance. One of the main advantages of a quad or oct tree is that objects are stored once *and only once* which makes rearranging a snap.

Plus it means that you''ve now got many more pointers stored in your structure, vastly increasing the memory used. And intersection testing now has to maintain lists of objects checked against - when an object is found it needs to scan the entire list to check if its already been found, and then insert into this intersection list if not.

This topic is closed to new replies.

Advertisement