Hey let's switch away from bullet to anything else (discussion)

Everything about development and the OpenMW source code.
User avatar
wareya
Posts: 338
Joined: 09 May 2015, 13:07

Re: Hey let's switch away from bullet to anything else (discussion)

Post by wareya »

That was me. It's probably a good idea to go with AABBs first, because they're probably simpler to implement mesh collision tracing for than capsules and because we want to switch to them anyways. The only real reason why we haven't switched away from capsules yet is because single-precision bullet gives bad collision normals for mesh collisions with anything that has sharp edges, if you touch part of the mesh that's particularly long or large, and Morrowind has LOTS of triangles that are long and large.

Another thing to consider: most collision systems are designed to be used with units of meters, but in Morrowind and OpenMW, the unit is more like a screwed up semi-centimeter thing (a "meter"-ish distance is close to 64 units). This is probably the reason that Morrowind's assets cause accuracy problems in single-precision bullet.

Also, just a possible issue to consider: we have an issue with one-way walls. These work totally fine in vanilla, but not in bullet. I suspect the reason is because internal edges are colliding with one another because they probably don't have any face direction information attached to them. If I was the one doing this, I might test collision meshes against eachother by triangle pairs, instead of as collections of triangles, edges, and points, because doing so (per-triangle) would avoid any possible issues with internal edge/point rejection. One-way walls would Just Work after throwing away potential contacts that have backwards collision normals.
User avatar
Stomy
Posts: 47
Joined: 11 Dec 2018, 02:55
Location: Fhloston Paradise!
Contact:

Re: Hey let's switch away from bullet to anything else (discussion)

Post by Stomy »

Pretty much all of those issues can be blamed on Bullet's intended use being as a physics simulation first and a collision detection system distant second. It's far more comfortable smashing apart piles of cubes than it is preventing characters penetrating objects and that's why it has the recommendation of sticking to within the 0.2f to 10.f range for all calculations as it's trying to do everything at once.

The question of AABBs vs Capsules I'd put down to which one is more desirable gameplay-wise as either would be about as easy to implement. NetImmerse's 64 units to a yard scale can be worked around as we know it going in, and some floating-point precision could potentially be preserved by subtracting extra cell lengths before intersection tests and then adding them back afterward. One-way walls I'd be willing to bet is from Bullet completely ignoring triangle windings for intersection tests as an assumption that a "real" physics simulation doesn't have such a thing as one-way surfaces for complex geometry, otherwise it should just be a single bool switch when creating a btTriangleMesh. Writing it ourselves you can just dot product the trace direction with the triangle's normal and throw away negatives early.

EDIT: Reading it back, I ended up just repeating what you said about one-way walls anyway! It's as simple as Bullet not considering it as a use-case, which we on the other hand, do.
User avatar
AnyOldName3
Posts: 2666
Joined: 26 Nov 2015, 03:25

Re: Hey let's switch away from bullet to anything else (discussion)

Post by AnyOldName3 »

The question of AABBs vs Capsules I'd put down to which one is more desirable gameplay-wise as either would be about as easy to implement.
Morrowind's original engine used AABBs, so it should be easier to replicate what the player can and can't do if we use them, too. However, it also did lots of weird/wrong things, and it may turn out that a sane collision system can't offer the same restrictions and freedoms, so we may at some point need to support a Morrowind-faithful mode and a modernised sane mode for new games. It would be nicest if there was scope to add capsules at a later date without having to redo everything.
User avatar
Stomy
Posts: 47
Joined: 11 Dec 2018, 02:55
Location: Fhloston Paradise!
Contact:

Re: Hey let's switch away from bullet to anything else (discussion)

Post by Stomy »

For now then I'll do this: I'll add a config setting under [Game] called "actor capsule collision" defaulting to false. When false, actors will emulate Vanilla with AABBs. When true, they will use Capsules.
User avatar
wareya
Posts: 338
Joined: 09 May 2015, 13:07

Re: Hey let's switch away from bullet to anything else (discussion)

Post by wareya »

Capsules cause serious issues with vanilla level design because they have steep sloped parts on them. I was initially considering cylinders or octagonal prisms but we decided that AABBs, like Morrowind itself uses, are the best. It's probably best to not consider non-AABB shapes until post-1.0.
User avatar
lysol
Posts: 1513
Joined: 26 Mar 2013, 01:48
Location: Sweden

Re: Hey let's switch away from bullet to anything else (discussion)

Post by lysol »

wareya wrote: 10 Jan 2019, 08:18 Capsules cause serious issues with vanilla level design because they have steep sloped parts on them. I was initially considering cylinders or octagonal prisms but we decided that AABBs, like Morrowind itself uses, are the best. It's probably best to not consider non-AABB shapes until post-1.0.
Why not a setting then that defaults to false as Stomy suggested? If users set capsules to true, then it's their business.
User avatar
Stomy
Posts: 47
Joined: 11 Dec 2018, 02:55
Location: Fhloston Paradise!
Contact:

Re: Hey let's switch away from bullet to anything else (discussion)

Post by Stomy »

I wouldn't go as far as ruling out shapes, whatever works best for the game is of higher concern than whether we adhere to versioning wishlists. But that said the steeply sloping caps on the capsules interacting with stairs and affecting step-up heights is a serious concern that can have real impact. I'm starting to be more inclined towards on AABBs in that regard.

Another option is cylinders which I've used before. They might make a better alternative to capsules to avoid step/slope problems while better allowing players to pass NPCs in hallways.

Wasn't there also some special case in vanilla regarding actor collision specifically for passing NPCs in tight spaces as well? Like using a smaller inner collider instead of the one used against the world? I seem to recall seeing something about that around here somewhere.
User avatar
wareya
Posts: 338
Joined: 09 May 2015, 13:07

Re: Hey let's switch away from bullet to anything else (discussion)

Post by wareya »

If you're in the air and falling, other actors that you're above act like platforms that push you off of them. If you're in them and on the floor, they act like cylinders that are just barely touching you, i.e. any collision towards them gives a distance of 0 and a collision normal facing away from them. This logic is probably best handled by a callback like the movement solver fixes PR currently has: https://github.com/OpenMW/openmw/pull/1 ... dcf9231ba2
User avatar
Stomy
Posts: 47
Joined: 11 Dec 2018, 02:55
Location: Fhloston Paradise!
Contact:

Re: Hey let's switch away from bullet to anything else (discussion)

Post by Stomy »

Given that behavior, is there any particular reason why we wouldn't want to use cylinders all the time for consistency? It isn't perfectly representative of vanilla but I can't immediately think of anything that would work better with AABBs, at least in terms of gameplay implications.
User avatar
Capostrophic
Posts: 794
Joined: 22 Feb 2016, 20:32

Re: Hey let's switch away from bullet to anything else (discussion)

Post by Capostrophic »

Cylinders had significantly worse performance in testing for whatever reason.
Post Reply