(61d00a474) v0.9.7.1
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
using System;
|
||||
using FarseerPhysics.Dynamics;
|
||||
/* Original source Farseer Physics Engine:
|
||||
* Copyright (c) 2014 Ian Qvist, http://farseerphysics.codeplex.com
|
||||
* Microsoft Permissive License (Ms-PL) v1.1
|
||||
*/
|
||||
|
||||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
using FarseerPhysics.Common.PhysicsLogic;
|
||||
using FarseerPhysics.Dynamics;
|
||||
|
||||
namespace FarseerPhysics.Controllers
|
||||
{
|
||||
@@ -85,10 +91,7 @@ namespace FarseerPhysics.Controllers
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public AbstractForceController()
|
||||
: base(ControllerType.AbstractForceController)
|
||||
{
|
||||
Enabled = true;
|
||||
|
||||
Strength = 1.0f;
|
||||
Position = new Vector2(0, 0);
|
||||
MaximumSpeed = 100.0f;
|
||||
@@ -115,7 +118,6 @@ namespace FarseerPhysics.Controllers
|
||||
/// </summary>
|
||||
/// <param name="mode"></param>
|
||||
public AbstractForceController(TimingModes mode)
|
||||
: base(ControllerType.AbstractForceController)
|
||||
{
|
||||
TimingMode = mode;
|
||||
switch (mode)
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
/* Original source Farseer Physics Engine:
|
||||
* Copyright (c) 2014 Ian Qvist, http://farseerphysics.codeplex.com
|
||||
* Microsoft Permissive License (Ms-PL) v1.1
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Xna.Framework;
|
||||
using FarseerPhysics.Collision;
|
||||
using FarseerPhysics.Collision.Shapes;
|
||||
using FarseerPhysics.Common.PhysicsLogic;
|
||||
using FarseerPhysics.Dynamics;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace FarseerPhysics.Controllers
|
||||
{
|
||||
@@ -35,7 +41,7 @@ namespace FarseerPhysics.Controllers
|
||||
private Vector2 _gravity;
|
||||
private Vector2 _normal;
|
||||
private float _offset;
|
||||
private Dictionary<int, Body> _uniqueBodies = new Dictionary<int, Body>();
|
||||
private ICollection<Body> _uniqueBodies = new List<Body>();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BuoyancyController"/> class.
|
||||
@@ -46,7 +52,6 @@ namespace FarseerPhysics.Controllers
|
||||
/// <param name="rotationalDragCoefficient">Rotational drag coefficient of the fluid</param>
|
||||
/// <param name="gravity">The direction gravity acts. Buoyancy force will act in opposite direction of gravity.</param>
|
||||
public BuoyancyController(AABB container, float density, float linearDragCoefficient, float rotationalDragCoefficient, Vector2 gravity)
|
||||
: base(ControllerType.BuoyancyController)
|
||||
{
|
||||
Container = container;
|
||||
_normal = new Vector2(0, 1);
|
||||
@@ -71,19 +76,17 @@ namespace FarseerPhysics.Controllers
|
||||
_uniqueBodies.Clear();
|
||||
World.QueryAABB(fixture =>
|
||||
{
|
||||
if (fixture.Body.IsStatic || !fixture.Body.Awake)
|
||||
if (fixture.Body.BodyType == BodyType.Static || !fixture.Body.Awake)
|
||||
return true;
|
||||
|
||||
if (!_uniqueBodies.ContainsKey(fixture.Body.BodyId))
|
||||
_uniqueBodies.Add(fixture.Body.BodyId, fixture.Body);
|
||||
if (!_uniqueBodies.Contains(fixture.Body))
|
||||
_uniqueBodies.Add(fixture.Body);
|
||||
|
||||
return true;
|
||||
}, ref _container);
|
||||
|
||||
foreach (KeyValuePair<int, Body> kv in _uniqueBodies)
|
||||
foreach (Body body in _uniqueBodies)
|
||||
{
|
||||
Body body = kv.Value;
|
||||
|
||||
Vector2 areac = Vector2.Zero;
|
||||
Vector2 massc = Vector2.Zero;
|
||||
float area = 0;
|
||||
|
||||
@@ -1,67 +1,28 @@
|
||||
using System;
|
||||
/* Original source Farseer Physics Engine:
|
||||
* Copyright (c) 2014 Ian Qvist, http://farseerphysics.codeplex.com
|
||||
* Microsoft Permissive License (Ms-PL) v1.1
|
||||
*/
|
||||
|
||||
using System;
|
||||
using FarseerPhysics.Common.PhysicsLogic;
|
||||
using FarseerPhysics.Dynamics;
|
||||
|
||||
namespace FarseerPhysics.Controllers
|
||||
{
|
||||
[Flags]
|
||||
public enum ControllerType
|
||||
{
|
||||
GravityController = (1 << 0),
|
||||
VelocityLimitController = (1 << 1),
|
||||
AbstractForceController = (1 << 2),
|
||||
BuoyancyController = (1 << 3),
|
||||
}
|
||||
|
||||
public struct ControllerFilter
|
||||
{
|
||||
public ControllerType ControllerFlags;
|
||||
|
||||
/// <summary>
|
||||
/// Ignores the controller. The controller has no effect on this body.
|
||||
/// </summary>
|
||||
/// <param name="controller">The controller type.</param>
|
||||
public void IgnoreController(ControllerType controller)
|
||||
{
|
||||
ControllerFlags |= controller;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restore the controller. The controller affects this body.
|
||||
/// </summary>
|
||||
/// <param name="controller">The controller type.</param>
|
||||
public void RestoreController(ControllerType controller)
|
||||
{
|
||||
ControllerFlags &= ~controller;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether this body ignores the the specified controller.
|
||||
/// </summary>
|
||||
/// <param name="controller">The controller type.</param>
|
||||
/// <returns>
|
||||
/// <c>true</c> if the body has the specified flag; otherwise, <c>false</c>.
|
||||
/// </returns>
|
||||
public bool IsControllerIgnored(ControllerType controller)
|
||||
{
|
||||
return (ControllerFlags & controller) == controller;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class Controller : FilterData
|
||||
{
|
||||
public bool Enabled;
|
||||
public World World;
|
||||
private ControllerType _type;
|
||||
public ControllerCategory ControllerCategory = ControllerCategory.Cat01;
|
||||
|
||||
public Controller(ControllerType controllerType)
|
||||
public bool Enabled = true;
|
||||
public World World { get; internal set; }
|
||||
|
||||
public Controller()
|
||||
{
|
||||
_type = controllerType;
|
||||
}
|
||||
|
||||
public override bool IsActiveOn(Body body)
|
||||
{
|
||||
if (body.ControllerFilter.IsControllerIgnored(_type))
|
||||
if (body.ControllerFilter.IsControllerIgnored(ControllerCategory))
|
||||
return false;
|
||||
|
||||
return base.IsActiveOn(body);
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
using System;
|
||||
/* Original source Farseer Physics Engine:
|
||||
* Copyright (c) 2014 Ian Qvist, http://farseerphysics.codeplex.com
|
||||
* Microsoft Permissive License (Ms-PL) v1.1
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FarseerPhysics.Dynamics;
|
||||
using Microsoft.Xna.Framework;
|
||||
using FarseerPhysics.Common.PhysicsLogic;
|
||||
using FarseerPhysics.Dynamics;
|
||||
|
||||
namespace FarseerPhysics.Controllers
|
||||
{
|
||||
@@ -14,7 +20,6 @@ namespace FarseerPhysics.Controllers
|
||||
public class GravityController : Controller
|
||||
{
|
||||
public GravityController(float strength)
|
||||
: base(ControllerType.GravityController)
|
||||
{
|
||||
Strength = strength;
|
||||
MaxRadius = float.MaxValue;
|
||||
@@ -24,7 +29,6 @@ namespace FarseerPhysics.Controllers
|
||||
}
|
||||
|
||||
public GravityController(float strength, float maxRadius, float minRadius)
|
||||
: base(ControllerType.GravityController)
|
||||
{
|
||||
MinRadius = minRadius;
|
||||
MaxRadius = maxRadius;
|
||||
@@ -52,7 +56,7 @@ namespace FarseerPhysics.Controllers
|
||||
|
||||
foreach (Body controllerBody in Bodies)
|
||||
{
|
||||
if (worldBody == controllerBody || (worldBody.IsStatic && controllerBody.IsStatic) || !controllerBody.Enabled)
|
||||
if (worldBody == controllerBody || (worldBody.BodyType == BodyType.Static && controllerBody.BodyType == BodyType.Static) || !controllerBody.Enabled)
|
||||
continue;
|
||||
|
||||
Vector2 d = controllerBody.Position - worldBody.Position;
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
using FarseerPhysics.Dynamics;
|
||||
/* Original source Farseer Physics Engine:
|
||||
* Copyright (c) 2014 Ian Qvist, http://farseerphysics.codeplex.com
|
||||
* Microsoft Permissive License (Ms-PL) v1.1
|
||||
*/
|
||||
|
||||
using FarseerPhysics.Dynamics;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace FarseerPhysics.Controllers
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
using System;
|
||||
/* Original source Farseer Physics Engine:
|
||||
* Copyright (c) 2014 Ian Qvist, http://farseerphysics.codeplex.com
|
||||
* Microsoft Permissive License (Ms-PL) v1.1
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FarseerPhysics.Common.PhysicsLogic;
|
||||
using FarseerPhysics.Dynamics;
|
||||
|
||||
namespace FarseerPhysics.Controllers
|
||||
@@ -24,7 +30,6 @@ namespace FarseerPhysics.Controllers
|
||||
/// Sets the max angular velocity to Settings.MaxRotation
|
||||
/// </summary>
|
||||
public VelocityLimitController()
|
||||
: base(ControllerType.VelocityLimitController)
|
||||
{
|
||||
MaxLinearVelocity = Settings.MaxTranslation;
|
||||
MaxAngularVelocity = Settings.MaxRotation;
|
||||
@@ -38,7 +43,6 @@ namespace FarseerPhysics.Controllers
|
||||
/// <param name="maxLinearVelocity">The max linear velocity.</param>
|
||||
/// <param name="maxAngularVelocity">The max angular velocity.</param>
|
||||
public VelocityLimitController(float maxLinearVelocity, float maxAngularVelocity)
|
||||
: base(ControllerType.VelocityLimitController)
|
||||
{
|
||||
if (maxLinearVelocity == 0 || maxLinearVelocity == float.MaxValue)
|
||||
LimitLinearVelocity = false;
|
||||
|
||||
Reference in New Issue
Block a user