Collision Detection

Performance problems?

Page 1 of 1

5 Replies - 5747 Views - Last Post: 11 June 2008 - 03:53 AM Rate Topic: -----

#1 Pontus  Icon User is offline

  • Cattlebruiser
  • member icon

Reputation: 17
  • View blog
  • Posts: 612
  • Joined: 28-December 06

Collision Detection

Posted 04 June 2008 - 09:19 AM

Hi there,

I'm developing an RPG (try nr .7) and i want to make my collision detection code better. Right now it checks if the locations of the given rectangle's corners is black on my collision map. If so it returns true, else false. It's very quick but it leaves me with a problem. If one of the sides of the rectangle is bigger then a object on the collision map it goes trough it. I was thinking of checking every pixel on the 4 edges of my rectangle, that should make it more 'waterproof'. But i'm afraid that it will get really slow on big rectangles. Is there an alternative?

Thanks in regards

Pontus

This post has been edited by manhaeve5: 10 June 2008 - 09:54 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Collision Detection

#2 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 919
  • View blog
  • Posts: 6,443
  • Joined: 07-September 06

Re: Collision Detection

Posted 08 June 2008 - 10:12 AM

Not exacly sure what you are using to make this, but you may be able to check is 2 lines collide instead of pixels. That would make things faster (I think) and would give you the result you are looking for (probably). But as I said, I am not sure what language you are using or if it even supports that type of thing (line collision).
Was This Post Helpful? 0
  • +
  • -

#3 Trogdor  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 15
  • View blog
  • Posts: 627
  • Joined: 06-October 06

Re: Collision Detection

Posted 09 June 2008 - 03:56 AM

I thought that most sprite oriented libraries have collision detection built in.
Are you using any library like SDL or Allegro ?
Was This Post Helpful? 0
  • +
  • -

#4 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 928
  • View blog
  • Posts: 3,997
  • Joined: 14-February 08

Re: Collision Detection

Posted 09 June 2008 - 06:08 PM

SDL doesnt have built in collision that i know of, Are you using an OOP design, if so then it can make collision detection a lot simpler due to different types of objects intersecting, you could also try a circle bounding shape or like a capsule type shape although circles are easier they are also less accurate. could you post your collision code please?

cheers :)
Was This Post Helpful? 0
  • +
  • -

#5 Pontus  Icon User is offline

  • Cattlebruiser
  • member icon

Reputation: 17
  • View blog
  • Posts: 612
  • Joined: 28-December 06

Re: Collision Detection

Posted 10 June 2008 - 09:53 AM

Well, after a few (a bit confusing) posts i managed to figure it out myself. If a map has less then a certain number of rectangles to collide, it will use simple, fast collision check between rectangles. If it has more rectangles, it will use the collision map.

Thanks anyway for trying to help me! Much appreciated :D

Greets

Robin
Was This Post Helpful? 0
  • +
  • -

#6 Trogdor  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 15
  • View blog
  • Posts: 627
  • Joined: 06-October 06

Re: Collision Detection

Posted 11 June 2008 - 03:53 AM

You still might want to check out http://sdl-collide.sourceforge.net/
with in it boundingbox and pixelperfect collision detection.

This library does the following:
- It uses the bounding box collision detection to find a collision
- Then, using the pixel perfect collision to refine that collision
That way you only check the slower pixel perfect routines if you need to.

You can also use only boundingbox or circle collision dectection.

Ofcourse you can reinvent the wheel, but you dont need to.

Good luck.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1