Pill collision model for player

Hey guys. I’ve made a lot of progress on this VR mod, and I’m about to start working on this part I’ve neglected for a while, and that’s the collision.

I’ve wanted to use pill collision for a long time which basically means instead of the standard mins maxs values, you’d have a 8-16 sided cylinder, with two 16 sided UV spheres on either end. The pill should also be able to collide properly with surfaces after experiencing any arbitrary rotation.

I get confused when I start reading the deeper collision code, and am not entirely sure what’s going on? Anyone willing to help push me in the right direction?

Page 25 (PDF 35) of this explains the basics of how collision works.

The trace functions do take a capsule argument, but IIRC, it doesn’t work correctly.

Unless you want to rewrite all the collision and pmove code, you’re better off sticking with AABBs.

1 Like

Holy crap! That would be a ton of work. I think it’s doable, but it feels to me like I would be basically writing a physics engine, which would probably be totally unnecessary. :frowning:

There’s gotta be a way to just make the player physics a compound cylinder + two spheres without changing the code too much. Q3Rally did something similar, but with vehicle meshes. Does anyone know about that?

Non-rotating capsule collision (cylinder + two spheres) is mostly working in Spearmint. Set g_playerCapsule 1 before player spawns.

Unfortunately, players sometimes get stuck to each other. Presumably due to bugs in cm_trace.c. Start q3ctf1 and add 60 bots on blue team and wait at blue jumppad. :man_shrugging:

Players landing on players often don’t get groundEntityNum set.

Running into a crouching player makes runner move up. Probably trying to step up on the player due to shorter height at sphere edges.

Pre-2013 history squash: cm_trace.c capsules fixes
Current code: Spearmint engine + mint-arena mod code
Note: GPLv3+ with additional Zenimax license clauses. The capsule fixes are my code though and I don’t have an issue with them being used as GPLv2+. Capsule engine improvements may be ported to ioq3 if I ever actually finish fixing them.

There is potential bot issues with changing the bounding box due to AAS just using player origin with a world has been expanded based on player’s AABB bounding box size. Worse case scenario, bots have to use AABB for collision with the world.

1 Like

Awesome. I might start writing my own thing from scratch though, since I have to make sure the pill can be rotated arbitrarily and collide with, for instance, a ledge, at an angle like 30 or 78 degrees.

The reason is I’m trying to have objects be able to collide with a wall and move along a wall like this:

It’s similar to how Sonic moves in this very faithful sonic 3D remake:

Do you think it’s possible to get a mesh to collide at whatever rotation, and B, be able to move along a wall as if it were the floor? If not, what steps do you think I might need to take to make that happen?

Yeah, I think pretty much anything can be done if you spend enough time on it.

  1. Add start origin angles and maybe end origin angles to trap_Trace() so engine knows angles of the moving object.
  2. Get angles of entities collided with in SV_ClipMoveToEntities() / CG_ClipMoveToEntities() – which is already done for BSP submodels (doors and moving platforms).
  3. Handle the collision physics in cm_trace.c using the existing BSP submodel/leaf collision. The hardest part is figuring out how to setup a BSP submodel shaped like an approximated pill. I would make a test map with a func_static shaped like the collision pill and then make player collision use BSP submodel index 1 instead of BOX_MODEL_HANDLE. Then try printing the information for the pill so it can be set up in code so you don’t have to include the collision mesh into every map. Or just rewrite/fix the capsule code in cm_trace.c.
  4. Make Pmove() handle per-player directional gravity.

I think the biggest flaw of this is that rotating an approximated sized cylinder would prevent players from turning it they are against the wall or another player. Though that can probably be solved by not rotating the YAW of the collision pill.

2 Likes

So I think I’m going to use Bullet 3D for it. I’m wondering if it makes sense to replace the box tracing and world collision code with a proper physics engine that handles all player vs world collisions. Is that even feasible to do, while being networked, do you think? Would it make more sense to try to figure out how to do it by modding Q3A’s existing code?

I’ve made progress in the VR Q3A mod, and having 6dof would be more than icing on the cake. It would be like having an extra cake entirely.

Maybe this is of some interest to you.
OpenWolf supports the Newton (or Bullet?) physics engine: https://github.com/TheDushan/OpenWolf

The most sophisticated/usable/stable approach of idtech3 + physics engine is the Qio engine. The Qio engine supports world to model collision (e.g. barrels, crates), and model to model collision. It also supports Doom 3 md5/IQM ragdoll characters (as shown in this video: https://www.youtube.com/watch?v=YlUczDfqMFs and this one https://www.youtube.com/watch?v=2THr8A8aKGg)
Here is the Qio engine source code: https://sourceforge.net/projects/qio/

NOTE: although both engines are still idtech3 based, they do not have much to do with Q3 anymore (they are based upon Xreal).
Moreover, both are in a very early stage (or dead?), and as far as Qio is concerned the game code, ui etc. is missing.

But hey, maybe it helps you to add a physics engine!