XNA Creators Club Online
Page 1 of 1 (4 items)
Sort Posts: Previous Next

Engine Design - Collision Detection

Last post 08/05/2007 9:23 by Pfo Cubed. 3 replies.
  • 08/05/2007 6:33

    Engine Design - Collision Detection

    For a long time now i'm working on a game engine in c++ using DirectX.
    Last weekend i bought a good book about writing a physics engine.

    Now i noticed that the book also covers collision detection, so i'm wondering where i should put this part.
    My engine is split into different components (different DLL's) so if i only want to use parts of the engine in a game or application i dont need to implement the entire engine. This is how my engine looks like atm:
    - Core (allways required)
    - Graphics
    - Sound
    - Input
    - Physics
    - Game
    Later a scripting engine will also be added. The game component is a kind of helper component that has the base code for a game (mainloop, engine implementation, callback functions for rendering ... kinda based on the DXUT lib)

    Currently the collision detection is part of the graphics component cause its only used on the render objects.

    So where should i put the collision detection part? Keep it in the graphics component or put it in the physics engine?
    I'm using custom vector, matrix, ... structures that are inline files. Those are in the SDK include files and not part of any engine component. The graphics component is using these files from the SDK, so will the physics engine, so that the render engine and physics engine are compactible with eachother and no convertions are needed.

  • 08/05/2007 8:54 In reply to

    Re: Engine Design - Collision Detection

    IMO the graphics should only handle rendering since you have physics broken out. Physics would involve collision.
    Jim Perry - Microsoft XNA MVP
    If people spent a minute searching the forums and reading the FAQs before posting I'd be out of a job.
      Got some XNA Game Studio/XNA Framework development info to share with the community? Put it on the XNA Wiki.
        Please mark posts as Answers or Good Feedback when appropriate.
  • 08/05/2007 8:58 In reply to

    Re: Engine Design - Collision Detection

    From a design perspective I would say that Collision Detection belongs to your Physics System. The Graphics System might be an easy place to store it at first, since you have easy access to the location of different Entities, but as your game becomes more complicated I think you'll discover that it is not the correct place.

    But that doesn't mean it is the best thing for your situation. Sometimes the best design does not work or is overly complicated for your specific situation.
  • 08/05/2007 9:23 In reply to

    Re: Engine Design - Collision Detection

    The collisions system seems to belong to the physics system more, but not necessarily.  If you are using convex hulls, the scene graph might use them for projecting shadows.  Also, various collision detection shapes might be useful for culling in the scene graph.  You may want to consider keeping the collision library separate, or as a subset of the physics library.
Page 1 of 1 (4 items) Previous Next