Sign in to follow this  
digital_phantom

Help with collision management

Recommended Posts

I need help writing my collision engine for my game. Right now I have it set up so that objects are drawn normally, but then when objects move, it then checks the collsion ray tracing for each object when the object requests a move. This method seems really slow, but it's the only way I know of. Is there any other better ways that are faster ?

Share this post


Link to post
Share on other sites
A general solution is to eleminate the number of objects you check agaist. This is very specific to how you store your data. Perhapes your ray-tracing code already does this. Another way is to decrease the complexity of your collision detection system. Ie: insted of using ray-tracing try simplifing it to a 2D collision map. I'm assuming your game is 3D. Do you really need to check all your collisions in 3D?
Anyways, it's pretty specific to how you represent your objects.

Nick

Share this post


Link to post
Share on other sites
My game will need to check a lot of objects for collisions.
My goal for my game is to create a giant city with buildings with
inside rooms and more. So I'm trying to figure out a way to do all
of this. Collisions is just my first step to try to get things going.
So if anyone knows any better ways for doing the collisions in the way
that I want to, I would really need the help.

Share this post


Link to post
Share on other sites
Well, if it helps, I know a lot of games eliminate processing of objects that they know the user won't be in contact with in the near future when they build large areas. For example, if the player goes into a building, you could halt collision detection/object updating outside of the building, or do so in a really simplified way if you feel you still have to. That way, you're culling the total amount of things that have to be processed at once.

Share this post


Link to post
Share on other sites
But how would you know when a object is inside a building or not ?
For my engine, for my building objects, the walls are made up of seperate
wall objects, which could be anything, solid walls, walls with windows, doors, fences, etc... so even with the player inside the building, the engine has to go through all the walls in the scene that are visible (unless stepping backwards) and check them for collisions. I know of no other way to do this.

Share this post


Link to post
Share on other sites
Perhaps you could divide your whole world/scene into zones.
For example a specific building is one zone and the different rooms are subzones of the buildings zone.
Then tag every object so you know which zone they belong to.
Now you can check for collision with only the objects that belongs to the zone your in.
To know which zone you're in you could use some kind of trigger in every doorway(could be a box or sphere that you check for collision with).



Share this post


Link to post
Share on other sites
Wow, that is good information, thanks Sweenie.

I have already thought about using zones. And in a way, the building
would already be considered a zone since it has it's own boundries
since it's an object made up of several real-time objects (because of
doors being able to swing open and windows able to open up too.)

But I don't know about the part with checking for which zone the
player is in. After all zones would be square shape so you wouldn't
be able to put sphere or box triggers all around the zone for outside.
And then with the door, that would be hard to check because the sphere
and the box triggers would have a radius on them, which would be sticking
outside the boundries. Because you wouldn't want the box trigger to be
inside the building because then it wouldn't detect the player doing a
collection on the building's outside walls.

But my building lay to another problem. It would be faster if the player
went inside the building and then the game wouldn't draw the outside
world, but I'm heading to realistic and speed, I want it so there are
windows the player will be able to look out of to see the city streets.
If anyone has played the game called Silent Hill 4, you will understand
what I mean for when your looking outside the window of the apartment.

But now this doesn't have to do with my original topic anymore. LOL.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Why not use "octree-like" collision culling? Divide the world into massive bounding boxes. The clip planes have a "tag" saying which bounding box they're in. So you don't check against planes that aren't in the current bb.

Share this post


Link to post
Share on other sites
Is there any tutorials on the net for using an octree collision culling?
I'm using DirectX 8.0, so any of those websites would be useful.

With my original topic, I have thought that maybe instead of me using that whenever an object moves that a collision detection starts, that maybe instead I can have for when each object renders, and after so many frames that it will do a cache of collisions with objects, and then when anything needs to know the collision, it will then look it up in that cache. Which of these ideas would be better ? Are there any better ones ?

Share this post


Link to post
Share on other sites
why don't make another 3d object, besides the object that you render, and in this new, one, you will includ polies that actually are likely to be involved in the collision detection. then use a simple octree that devides this object. just search for octrees in gamedev. and you'll find a whole lot of stuff.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You really should look in the Articles section first. http://www.gamedev.net/reference/list.asp?categoryid=40
There are several articles here. This is also what Google is for

Share this post


Link to post
Share on other sites
if you want collision detection, you'd basicely have to test collision against polygons, (which can make any geometric object). if you don't want to, you can use bounding objects, such as a bounding cubes, are spheres. they require less processing but they wont fit with objects of your scene well, and you probably will have to implement them manually.
so for me, I would stick with the collision per polygon, and if you don't decide to use some kind of geometry partitioning system, like octree's or binay trees, or portals, then you'll have to test the collision with all of the polygons, even if they are very very far from your target, and aren't likely to be involved in a collision, in that is basicely a waste of frame rate. so I think it is a good thing to reduce the amount of proccessing you do on collision detection, using a space partitionin systems.

Share this post


Link to post
Share on other sites
I already have my collision engine built, it tests per polygon. The reason for this is because I have also made it for polygon object editing, it is designed for I can test at 3D or 2D coordiates. Great for clicking on an object and then for an object detecting collisions on another object.
But the bit about my collision engine was not even my original question. It had to do with the managment of a collision engine, not the coding of a collision engine.

For now, all I'm doing is when you create the object in the object editor, you also have to create it's bounding box which is tested against the viewport so if it should be rendered or not.

Share this post


Link to post
Share on other sites
You need to cull objects so that there are only a few you need to check for collisions.

Generally, for outside areas, an octree/quadtree like structure would be a good choice.

For inside culling, you could use a solid space bsp tree, or PVS system.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this