Files
RobustToolbox/Robust.Shared/Physics/IPhysBody.cs
metalgearsloth c17c8d7a11 Physics (#1605)
* Physics worlds

* Paul's a good boy

* Build working

* Ingame and not lagging to hell

* Why didn't you commit ahhhhh

* Hard collisions working

* Solver parity

* Decent broadphase work done

* BroadPhase outline done

* BroadPhase working

* waiting for pvs

* Fix static PVS AABB

* Stop static bodies from awakening

* Optimise a bunch of stuff

* Even more broadphase stuff

* I'm fucking stupid

* Optimise fixture updates

* Collision solver start

* Building

* A is for Argumentative

* Fix contact caching island flags

* Circle shapes actually workeded

* Damping

* DS2 consumables only

* Slightly more stable

* Even slightlier more stablier

* VV your heart out

* Initial joint support

* 90% of joints I just wanted to push as I'd scream if I lost progress

* JOINT PURGATORY

* Joints barely functional lmao

* Okay these joints slightly more functional

* Remove station FrictionJoint

* Also that

* Some Box2D ports

* Cleanup mass

* Edge shape

* Active contacts

* Fix active contacts

* Optimise active contacts even more

* Boxes be stacking

* I would die for smug oh my fucking god

* In which everything is fixed

* Distance joints working LETS GO

* Remove frequency on distancejoint

* Fix some stuff and break joints

* Crashing fixed mehbeh

* ICollideSpecial and more resilience

* auto-clear

* showbb vera

* Slap that TODO in there

* Fix restartround crash

* Random fixes

* Fix fixture networking

* Add intersection method for broadphase

* Fix contacts

* Licenses done

* Optimisations

* Fix wall clips

* Config caching for island

* allocations optimisations

* Optimise casts

* Optimise events queue for physics

* Contact manager optimisations

* Optimise controllers

* Sloth joint or something idk

* Controller graph

* Remove content cvar

* Random cleanup

* Finally remove VirtualController

* Manifold structs again

* Optimise this absolute retardation

* Optimise

* fix license

* Cleanup physics interface

* AHHHHHHHHHHHHH

* Fix collisions again

* snivybus

* Fix potential nasty manifold bug

* Tests go snivy

* Disable prediction for now

* Spans

* Fix ShapeTypes

* fixes

* ch ch changeesss

* Kinematic idea

* Prevent static bodies from waking

* Pass WorldAABB to MoveEvent

* Fix collisions

* manifold structs fucking WOOORRKKKINNGGG

* Better pushing

* Fix merge ickies

* Optimise MoveEvents

* Use event for collisions performance

* Fix content tests

* Do not research tests

* Fix most conflicts

* Paul's trying to kill me

* Maybe collisions work idk

* Make us whole again

* Smug is also trying to kill me

* nani

* shitty collisions

* Settling

* Do not research collisions

* SHIP IT

* Fix joints

* PVS moment

* Fix other assert

* Fix locker collisions

* serializable sleeptime

* Aether2D contacts

* Physics is no longer crashing (and burning)

* Add to the TODO list

Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
2021-03-08 03:19:01 +11:00

182 lines
5.4 KiB
C#

using System.Collections.Generic;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Physics.Broadphase;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Physics.Dynamics.Contacts;
namespace Robust.Shared.Physics
{
/// <summary>
///
/// </summary>
public interface IPhysBody : IComponent
{
bool IgnoreGravity { get; set; }
int IslandIndex { get; set; }
/// <summary>
/// Has this body already been added to a physics island
/// </summary>
bool Island { get; set; }
/// <summary>
/// Should the body still have physics updates applied even if paused
/// </summary>
bool IgnorePaused { get; set; }
/// <summary>
/// Entity that this physBody represents.
/// </summary>
IEntity Entity { get; }
/// <summary>
/// AABB of this entity in world space.
/// </summary>
Box2 GetWorldAABB(IMapManager? mapManager = null);
/// <summary>
/// Whether or not this body can collide.
/// </summary>
bool CanCollide { get; set; }
/// <summary>
/// Bitmask of the collision layers this body is a part of. The layers are calculated from
/// all of the shapes of this body.
/// </summary>
int CollisionLayer { get; }
/// <summary>
/// Bitmask of the layers this body collides with. The mask is calculated from
/// all of the shapes of this body.
/// </summary>
int CollisionMask { get; }
void CreateProxies(IMapManager? mapManager = null, SharedBroadPhaseSystem? broadPhaseSystem = null);
void ClearProxies();
/// <summary>
/// Removes all of the currently active contacts for this body.
/// </summary>
void DestroyContacts();
IReadOnlyList<Fixture> Fixtures { get; }
/// <summary>
/// The map index this physBody is located upon
/// </summary>
MapId MapID { get; }
/// <summary>
/// The type of the body, which determines how collisions effect this object.
/// </summary>
BodyType BodyType { get; set; }
/// <summary>
/// Whether the body is affected by tile friction or not.
/// </summary>
BodyStatus BodyStatus { get; set; }
bool Awake { get; set; }
bool SleepingAllowed { get; set; }
float SleepTime { get; set; }
float LinearDamping { get; set; }
float AngularDamping { get; set; }
/// <summary>
/// Non-hard <see cref="IPhysBody"/>s will not cause action collision (e.g. blocking of movement)
/// while still raising collision events.
/// </summary>
/// <remarks>
/// This is useful for triggers or such to detect collision without actually causing a blockage.
/// </remarks>
bool Hard { get; set; }
/// <summary>
/// Inverse mass of the entity in kilograms (1 / Mass).
/// </summary>
float InvMass { get; }
/// <summary>
/// Mass of the entity in kilograms
/// </summary>
float Mass { get; set; }
/// <summary>
/// Inverse inertia
/// </summary>
float InvI { get; set; }
/// <summary>
/// Current Force being applied to this entity in Newtons.
/// </summary>
/// <remarks>
/// The force is applied to the center of mass.
/// https://en.wikipedia.org/wiki/Force
/// </remarks>
Vector2 Force { get; set; }
/// <summary>
/// Current torque being applied to this entity in N*m.
/// </summary>
/// <remarks>
/// The torque rotates around the Z axis on the object.
/// https://en.wikipedia.org/wiki/Torque
/// </remarks>
float Torque { get; set; }
/// <summary>
/// Sliding friction coefficient. This is how slippery a material is,
/// or how much of it's velocity is being countered.
/// </summary>
/// <remarks>
/// This value ranges from 0 to greater than one.
/// Ice is 0.03, steel is 0.4, rubber is 1.
/// </remarks>
float Friction { get; set; }
/// <summary>
/// Current linear velocity of the entity in meters per second.
/// </summary>
Vector2 LinearVelocity { get; set; }
/// <summary>
/// Current angular velocity of the entity in radians per sec.
/// </summary>
float AngularVelocity { get; set; }
/// <summary>
/// Current position of the body in the world, in meters.
/// </summary>
Vector2 WorldPosition
{
get => Entity.Transform.WorldPosition;
set => Entity.Transform.WorldPosition = value;
}
/// <summary>
/// Current rotation of the body in the world, in radians.
/// </summary>
float WorldRotation
{
get => (float) Entity.Transform.WorldRotation.Theta;
set => Entity.Transform.WorldRotation = new Angle(value);
}
void WakeBody();
void ApplyLinearImpulse(in Vector2 impulse);
void ApplyAngularImpulse(float impulse);
IEnumerable<IPhysBody> GetCollidingEntities(Vector2 offset, bool approx = true);
}
}