Physics

From OniGalore
Jump to navigation Jump to search

Collisions

Every object that can collide must have physics.

Max number of all objects with physics which can Oni handle is 128. By "all objects" is meant:

active characters + OBOA objects + powerups + weapons + everything else with physics ^_^


ONI supports these collisions:


Environment collision

  • generally, the engine can only do point-quad and spheretree-quad collision detection.


Object collision

  • generally, all objects with physics context have a sphere tree attached to them and some objects created through OBOA also have an object bounding box.
  • object is anything with a physics context that supports collision: characters, OBOA objects, powerups, weapons


Character - Wall collision

  • this is always sphere tree-quad collision. (Sphere tree can be seen by chr_debug_sphere=1 command)
  • sphere tree always "stays up" (even when the character is fallen). That's why fallen characters pass through walls, their body gets outside the sphere when that happens.


Character - Floor collision

  • there is special function for characters to detect floor collision which checks if a 3x3 quad intersects the floor. This is done to avoid "strange" sinking when the sphere's lowest point goes outside the floor.
  • this is the probable cause why sometimes fallen characters hang on an edge (their 3x3 quad still intersects the floor) or fall of the edge even if their feet or head are still on the floor (the 3x3 quad is too small to cover the feet and head when the character is fallen).


Particle - Wall collision

  • this is always point-quad collision (the point is the position of the particle)


Particle - Object collision

  • this can be sphere-object bounding box or sphere-sphere collision depending on what the object has (object bounding box or sphere tree).
  • radius of the particle sphere is taken from Collision Radius property of the particle class (PAR3). It can be 0 and then the collision degenerates to point-obbox/point-sphere collision.


Moveable objects

AI2 characters can push weapons lying on the ground. Player cannot unless he use "chr_focus chr_index" and then "ai2_takecontrol 0" commands to control some AI2 character.


Other than that, there can be OBOA objects which can be pushed by all characters (player included)

  • cannot be seen in original Oni, yet engine supports it to some extent (OBOA objects even have dynamic grids. Can be seen with "ai2_showgrids=1", then "ai2_showdynamicgrids=1". )
  • OBOA object can be pushed by characters if it is not animated (no OBAN link) and it has "physics type" 2 or 4 (difference between those two unknown so far).
  • What doesn't work:
  • characters fall through objects (the character-floor collision function does not support OBOA objects)
  • due to the sphere-quad collision with environment, you typically cannot push an object very close to the wall (unless of course the object itself is a sphere or close enough to one)
  • objects can fall but because of sphere-quad collision detection they'll get stuck somewhere above the floor
  • OBOA object can fall on another OBOA object but in general multiple object interaction is buggy (depends on collision spheres or bounding boxes).