mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
* 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>
118 lines
3.2 KiB
C#
118 lines
3.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using JetBrains.Annotations;
|
|
using Robust.Shared.Configuration;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Maths;
|
|
using Robust.Shared.Serialization;
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
|
using Robust.Shared.ViewVariables;
|
|
|
|
namespace Robust.Shared.Physics.Dynamics.Shapes
|
|
{
|
|
/// <summary>
|
|
/// A physics shape that represents an Axis-Aligned Bounding Box.
|
|
/// This box does not rotate with the entity, and will always be offset from the
|
|
/// entity origin in world space.
|
|
/// </summary>
|
|
[Serializable, NetSerializable]
|
|
[DataDefinition]
|
|
public class PhysShapeAabb : IPhysShape
|
|
{
|
|
public int ChildCount => 1;
|
|
|
|
/// <summary>
|
|
/// The radius of this AABB
|
|
/// </summary>
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
|
public float Radius
|
|
{
|
|
get => _radius;
|
|
set
|
|
{
|
|
if (MathHelper.CloseTo(_radius, value)) return;
|
|
_radius = value;
|
|
OnDataChanged?.Invoke();
|
|
}
|
|
}
|
|
|
|
private float _radius;
|
|
|
|
public ShapeType ShapeType => ShapeType.Aabb;
|
|
|
|
[DataField("bounds")]
|
|
private Box2 _localBounds = Box2.UnitCentered;
|
|
|
|
/// <summary>
|
|
/// Local AABB bounds of this shape.
|
|
/// </summary>
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
|
public Box2 LocalBounds
|
|
{
|
|
get => _localBounds;
|
|
set
|
|
{
|
|
if (_localBounds == value)
|
|
return;
|
|
|
|
_localBounds = value;
|
|
OnDataChanged?.Invoke();
|
|
}
|
|
}
|
|
|
|
public PhysShapeAabb(float radius)
|
|
{
|
|
_radius = radius;
|
|
}
|
|
|
|
public PhysShapeAabb()
|
|
{
|
|
_radius = IoCManager.Resolve<IConfigurationManager>().GetCVar(CVars.PolygonRadius);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void ApplyState() { }
|
|
|
|
public void DebugDraw(DebugDrawingHandle handle, in Matrix3 modelMatrix, in Box2 worldViewport,
|
|
float sleepPercent)
|
|
{
|
|
var m = Matrix3.Identity;
|
|
m.R0C2 = modelMatrix.R0C2;
|
|
m.R1C2 = modelMatrix.R1C2;
|
|
|
|
handle.SetTransform(m);
|
|
handle.DrawRect(LocalBounds, handle.CalcWakeColor(handle.RectFillColor, sleepPercent));
|
|
handle.SetTransform(Matrix3.Identity);
|
|
}
|
|
|
|
// TODO
|
|
[field: NonSerialized]
|
|
public event Action? OnDataChanged;
|
|
|
|
/// <inheritdoc />
|
|
public Box2 CalculateLocalBounds(Angle rotation)
|
|
{
|
|
// TODO: Make a new ComputeAABB func or just wrap ComputeAABB into the existing methods?
|
|
return _localBounds.Scale(1 + Radius);
|
|
}
|
|
|
|
[Pure]
|
|
internal List<Vector2> GetVertices()
|
|
{
|
|
return new()
|
|
{
|
|
_localBounds.BottomRight,
|
|
_localBounds.TopRight,
|
|
_localBounds.TopLeft,
|
|
_localBounds.BottomLeft,
|
|
};
|
|
}
|
|
|
|
public bool Equals(IPhysShape? other)
|
|
{
|
|
if (other is not PhysShapeAabb otherAABB) return false;
|
|
return _localBounds.EqualsApprox(otherAABB._localBounds);
|
|
}
|
|
}
|
|
}
|