Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8846591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:01:37+00:00 2026-06-14T12:01:37+00:00

I have been using Farseer for quite a while now, working on a physics

  • 0

I have been using Farseer for quite a while now, working on a physics teaching platform project. There are a couple of questions about the engine in my brain that are left unanswered for quite some time, many of which are about collision handling of the engine.

Many people seem to have problems understanding the working of the engine, partly because Farseer lacks a proper API. It might be a good idea for those in the know to confirm the following concepts and KILL any concepts that are wrong.

Concept 0: The Two Stages

Collision in Farseer is divided into two stages:

  1. Broad phase collision
  2. Precise collision (please correct my use of term, if there’s another more official name for it…)

Concept 1: Broadphase

Farseer, using broad phase collision, will find potential collisions in a scene. Said broad phase collision test is done by…

  1. The use a quad tree, which can be found in package "Farseer.Collision".

  2. The class "Farseer.Dynamics.World" has a reference to "Farseer.Collision.QuadTreeBroadphase".

  3. "Farseer.Collision.QuadTreeBroadphase" has a reference to "Farseer.Collision.QuadTree".

  4. Further bounding box test is also done.

  5. If we ever find a need to know which pair(s) of fixtures has the potential to collide, we may do this…

    /* Game.Initialize */
    public override void Initialize() {
        OtherIrrelevantInitCode();
        _world.OnBroadphaseCollision += BroadphaseHandler;
        base.Initialize();
    }
    public void BroadphaseHandler(ref FixtureProxy fp1, ref FixtureProxy fp2) {
        // code to read about fp1 and fp2
    }
    

But then…

Small question 1

What are some of the common situations that it is useful for us to know which pairs of fixtures are potentially colliding?

Concept 2: Meaning of Events

Definition of two keywords:

  1. Touching: two objects are in contact. The array Manifold.Points is NOT empty.
  2. Colliding: two objects touch each other for the first time.

BeforeCollision means two objects are NOT colliding and NOT touching.

OnCollision means two objects are colliding, but touching will NOT fire this event.

AfterCollision means two objects were colliding, but now they are touching only.

OnSeparation means two objects were touching, but now they are not.

Concept 3: Using the Events

Broadphase collision test and precise collision tests are always carried out.

Precise collision may be disabled by returning false in event OnCollision or by using the IgnoreCollision method.

I have heard for more than one time that people say "just leave OnCollision empty and return true". What on earth does that mean? Using the events means that we would like to apply additional effects (e.g. kill an enemy, score, play a sound etc.) when the above events happen.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T12:01:39+00:00Added an answer on June 14, 2026 at 12:01 pm

    This answer applies to Farseer Physics 3.3.1 (The current stable version, at time of writing)


    Broad-phase is just a performance optimisation. It quickly determines what could collide, so that things that can’t collide don’t have the more-expensive narrow-phase collision-detection run.


    In my experience, the events in Farseer aren’t designed as well as they could be. I’ve found I’ve had to modify them for my own game – but fortunately this code is actually not too hard to read and modify. Also the documentation isn’t accurate in a few places.

    Here’s what the events in Farseer Physics actually do:

    BeforeCollision happens when broad-phase registers a new potential collision, before it creates a Contact object for the two fixtures. You can block the creation of the Contact by returning false in your event handler.

    The existence of a Contact does not necessarily mean that the two fixtures are actually in contact – just that the broad phase succeeded. A Contact can be touching/not-touching and they can be enabled/disabled (they start out enabled and not-touching).

    OnCollision happens when a Contact changes from not-touching to touching. You can disable the contact by returning false. Oddly enough, you can re-enable a contact that another event handler disabled on that step if you return true (this is one of the things I changed for my own game).

    Only an enabled, touching contact has any effect on the physics simulation.

    OnSeparation is the opposite of OnCollision: it triggers when the contact changes from touching to not-touching. There’s no way to disable/enable a contact here.

    AfterCollision is called for every Contact that is involved in the physics simulation on that frame (so: those that are enabled, touching, and not in an asleep island). It is called after the the physics simulation step, but before clean-up – most notably before Body.Force and Body.Torque are cleared (handy for sound effects and such).


    Usually you just use these events to trigger your effects – particles, sounds, game mechanics like destroying objects, and so on. In which case you subscribe to whichever one you want, do whatever you like, and then return true (not disabling/overriding the contact).

    It gets a lot more complicated if you want to mess with the physics engine or disable contacts (particularly when you can accidentally re-enable them, with another event handler, as I mentioned earlier). If Farseer’s built-in events don’t work for you, then it’s perfectly reasonable to go into its code and add your own. At this advanced level, it’s practically a necessity to be building from source so you can examine exactly what is going on anyway.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using a WordPress based PHP function for quite a while now
I have been using the PyDev in eclipse for quite a while with no
We have been using CruiseControl for quite a while with NUnit and NAnt. For
I have been using C# for a while now, and going back to C++
I have been using Ruby for a while now and I find, for bigger
I have been using IoC for a little while now and I am curious
I have been using the CSLA framework for couple of years now for windows
Have been using ActivePython on windows7 and lxml seems working without an issue.. There
I have been using the storyboard to make an application and currently there are
Have been using a simple CSS only tooltip. Working Example css: .tip { position:relative;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.