I’m using Bullet if any one is interested on reading about it. Bullet is quite a famous physics engine, you may have seen it more than you realize.

Below is a picture of the debug wireframe mesh that shows the physics layout in the world. For good measure is a cube sitting on the ground. The spotlight shadows need bit more work as you can see, it looks like there’s 3 spotlights, but there’s actually only one.

Physics demonstration

How it’s applied to the engine

Physics can be quite a tough thing for the end developer to get right. That’s why I’ve abstracted all the hard stuff to the internals of the engine. The developer only has to worry about what kind of constraints, forces and collision shapes they want.

The engine handles tricky stuff like minimum and maximum time steps and also keeps track of all the collision shapes and rigidbodies that have been created. Which allows the engine to handle memory automatically.

All positional variables use 64bit double precision numbers. This means you can have huge worlds without having to worry glitchyness.

This is good news for our open-world target.


The only trouble I’ve had using Bullet Physics is sometimes it’s hard to figure out what’s causing a problem due to it being a native library. When things do go wrong, they don’t exactly give me a useful means of debugging, meaning I usually have to search for clues on the internet.

The most annoying bug I’ve had so far seems to actually be a bug currently in BulletSharp. If I send in my own inertia values it causes an AccessViolation. An AccessViolation is when the program tries to read some memory outside of where it’s supposed to. I think it may be something to do with the fact I’m using the 64bit version.

External Editors

Also this week I’ve worked on adding external editor support to the editor. For now, this mostly means opening script files with a text editor of choice. Mine being Notepad++. However since Notepad++ doesn’t support intellisense, I eventually want to add support for using Visual Studio.

What’s next

Over the next week I’ll be focusing on adding scripting to the engine. It’s not really scripting. It’s more like loading a .Net DLL and using reflection to examine objects and start loading them as demanded by the scene.

I’m still deciding if I should make it import the DLL directly, or compile it on demand.

  1. Andres Traks
    Andres Traks
    June 28, 2018 at 10:04 pm

    I’d like to fix the BulletSharp bug.
    Can you show where you are setting the inertia values?
    Is it in the RigidBodyConstructionInfo constructor or are you setting the RigidBodyConstructionInfo.LocalInertia property?

    • Devin
      June 30, 2018 at 11:33 am

      I can’t really remember haha. Seems like a long time ago now.
      But here is the code currently.

      bool isDynamic = (Mass != 0.0);

      Vector3d localInertia = Vector3d.Zero;
      if (isDynamic)
      shape.CalculateLocalInertia(Mass, out localInertia);

      myMotionState = new DefaultMotionState(Transform.ModelMatrix);
      rbInfo = new RigidBodyConstructionInfo(Mass, myMotionState, shape);

      Body = new Body(rbInfo);

    • Devin
      June 30, 2018 at 11:35 am

      Oh now I remember it was taking the localInertia and putting it in to the end of ‘RigidBodyConstructionInfo’ constructor

Leave a Reply

Your email address will not be published. Required fields are marked *