Aye, I feel you. I noticed increasing the number of quads/triangles my physics objects were made up of helped, despite my original thinking of “Oh one box will make it run faster”
Opps…bad me. Err yeah, 2D.
I created a game engine using LibGDX that keeps a character and other objects level with the ground regardless if the ground level rises or lowers. Not exactly a physics engine though, but partially.
With PC and mobile devices getting faster and faster, I really see no need to build a new one. Bullet runs fine on most phones(even cheap ones) and has a lot of functionality. You would be better spending your time learning Bullet better, IMO. But if you wanted to learn, then definitely go for it.
There are physics engines and there are physics engines. JBullet is designed to work fairly easily in a real time setting. Despite the glitches you get, it is doing a good job. Just look at all that code to deal with edge cases! It is just that hard to do stable Newtonian mechanics.
Now i have worked on real physics engines, ones where you take the results and tell people that you haven’t designed your building well enough. Or that your airplane will fall out of the sky. Now they are not so glitchy, but represent 10,000 of man hours programming in them (and many PhDs thesis ). A good example of how hard it gets, it consider the classic container of balls being tipped into a hopper. To model this properly you need to model the times of every single impact. That is right, it isn’t time stepped anymore, because you can show unbounded errors in that case. But you work out when the first ball collides with something and move to that time, then the second and move forward to that time… In our code we march forward a given amount, check for a collision and then rewind the simulation to that point in time of the collision. This sort of thing is the only way to get rid of the glitches. Much more work in the field has been done since i left however.