Unstable 1.8.4.0
This commit is contained in:
@@ -53,7 +53,7 @@ namespace FarseerPhysics.Collision
|
||||
internal int Height;
|
||||
internal int ParentOrNext;
|
||||
|
||||
public object Body;
|
||||
public Body Body;
|
||||
|
||||
internal T UserData;
|
||||
|
||||
@@ -319,7 +319,7 @@ namespace FarseerPhysics.Collision
|
||||
return _nodes[proxyId].AABB;
|
||||
}
|
||||
|
||||
public object GetBody(int proxyId)
|
||||
public Body GetBody(int proxyId)
|
||||
{
|
||||
Debug.Assert(0 <= proxyId && proxyId < _nodeCapacity);
|
||||
return _nodes[proxyId].Body;
|
||||
@@ -344,7 +344,7 @@ namespace FarseerPhysics.Collision
|
||||
/// </summary>
|
||||
/// <param name="callback">The callback.</param>
|
||||
/// <param name="aabb">The aabb.</param>
|
||||
public void Query(Func<int, bool> callback, ref AABB aabb, ref object body)
|
||||
public void Query(Func<int, bool> callback, ref AABB aabb, ref Body body)
|
||||
{
|
||||
_queryStack.Clear();
|
||||
_queryStack.Push(_root);
|
||||
@@ -357,22 +357,38 @@ namespace FarseerPhysics.Collision
|
||||
continue;
|
||||
}
|
||||
|
||||
//TreeNode<T>* node = &_nodes[nodeId];
|
||||
if (!ReferenceEquals(_nodes[nodeId].Body, body) && AABB.TestOverlap(ref _nodes[nodeId].AABB, ref aabb))
|
||||
TreeNode<T> node = _nodes[nodeId];
|
||||
if (node.Body != body && AABB.TestOverlap(ref node.AABB, ref aabb))
|
||||
{
|
||||
if (_nodes[nodeId].IsLeaf())
|
||||
if (node.IsLeaf())
|
||||
{
|
||||
if (node.Body.CollidesWithMatchesBetweenFixtures &&
|
||||
body.CollisionCategoriesMatchBetweenFixtures)
|
||||
{
|
||||
//equivalent to
|
||||
//collide = node.Body.CollidesWith.HasAnyFlag(body.CollisionCategories) && body.CollidesWith.HasAnyFlag(node.Body.CollisionCategories)
|
||||
//same check as in ContactManager.ShouldCollide
|
||||
//inlined here using binary operations because this is performance critical code
|
||||
bool collide =
|
||||
(node.Body.CollidesWith & body.CollisionCategories) != 0 &&
|
||||
(body.CollidesWith & node.Body.CollisionCategories) != 0;
|
||||
if (!collide)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
bool proceed = callback(nodeId);
|
||||
if (proceed == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
_queryStack.Push(_nodes[nodeId].Child1);
|
||||
_queryStack.Push(_nodes[nodeId].Child2);
|
||||
}
|
||||
_queryStack.Push(node.Child1);
|
||||
_queryStack.Push(node.Child2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ namespace FarseerPhysics.Collision
|
||||
// we don't fail to create a pair that may touch later.
|
||||
AABB fatAABB = _tree.GetFatAABB(_queryProxyId);
|
||||
|
||||
object body = _tree.GetBody(_queryProxyId);
|
||||
Body body = _tree.GetBody(_queryProxyId);
|
||||
|
||||
// Query tree, create pairs and add them pair buffer.
|
||||
_tree.Query(_queryCallback, ref fatAABB, ref body);
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace FarseerPhysics.Collision.Shapes
|
||||
}
|
||||
|
||||
// Find the point of intersection of the line with the circle.
|
||||
float a = -(c + (float)Math.Sqrt(sigma));
|
||||
float a = -(c + MathF.Sqrt(sigma));
|
||||
|
||||
// Is the intersection point on the segment?
|
||||
if (0.0f <= a && a <= input.MaxFraction * rr)
|
||||
@@ -177,8 +177,8 @@ namespace FarseerPhysics.Collision.Shapes
|
||||
|
||||
//Magic
|
||||
float l2 = l * l;
|
||||
float area = _2radius * (float)((Math.Asin(l / Radius) + MathHelper.Pi / 2) + l * Math.Sqrt(_2radius - l2));
|
||||
float com = -2.0f / 3.0f * (float)Math.Pow(_2radius - l2, 1.5f) / area;
|
||||
float area = _2radius * ((MathF.Asin(l / Radius) + MathHelper.Pi / 2) + l * MathF.Sqrt(_2radius - l2));
|
||||
float com = -2.0f / 3.0f * MathF.Pow(_2radius - l2, 1.5f) / area;
|
||||
|
||||
sc.X = p.X + normal.X * com;
|
||||
sc.Y = p.Y + normal.Y * com;
|
||||
|
||||
+1
-1
@@ -150,7 +150,7 @@ namespace FarseerPhysics.Common.Decomposition.Seidel
|
||||
{
|
||||
Point a = (p.Next - p);
|
||||
Point b = (p.Prev - p);
|
||||
return (float)Math.Atan2(a.Cross(b), a.Dot(b));
|
||||
return MathF.Atan2(a.Cross(b), a.Dot(b));
|
||||
}
|
||||
|
||||
private bool AngleSign()
|
||||
|
||||
@@ -709,7 +709,7 @@ namespace FarseerPhysics.Common
|
||||
/// </summary>
|
||||
public void Normalize()
|
||||
{
|
||||
float d = MathHelper.TwoPi * (float)Math.Floor(A0 / MathHelper.TwoPi);
|
||||
float d = MathHelper.TwoPi * MathF.Floor(A0 / MathHelper.TwoPi);
|
||||
A0 -= d;
|
||||
A -= d;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace FarseerPhysics.Common.Maths
|
||||
|
||||
public float Phase
|
||||
{
|
||||
get { return (float)Math.Atan2(Imaginary, Real); }
|
||||
get { return MathF.Atan2(Imaginary, Real); }
|
||||
set
|
||||
{
|
||||
if (value == 0)
|
||||
@@ -26,14 +26,14 @@ namespace FarseerPhysics.Common.Maths
|
||||
this = Complex.One;
|
||||
return;
|
||||
}
|
||||
this.Real = (float)Math.Cos(value);
|
||||
this.Imaginary = (float)Math.Sin(value);
|
||||
this.Real = MathF.Cos(value);
|
||||
this.Imaginary = MathF.Sin(value);
|
||||
}
|
||||
}
|
||||
|
||||
public float Magnitude
|
||||
{
|
||||
get { return (float)Math.Round(Math.Sqrt(MagnitudeSquared())); }
|
||||
get { return MathF.Round(MathF.Sqrt(MagnitudeSquared())); }
|
||||
}
|
||||
|
||||
|
||||
@@ -49,8 +49,8 @@ namespace FarseerPhysics.Common.Maths
|
||||
return Complex.One;
|
||||
|
||||
return new Complex(
|
||||
(float)Math.Cos(angle),
|
||||
(float)Math.Sin(angle));
|
||||
MathF.Cos(angle),
|
||||
MathF.Sin(angle));
|
||||
}
|
||||
|
||||
public void Conjugate()
|
||||
|
||||
@@ -315,7 +315,7 @@ namespace FarseerPhysics.Common
|
||||
for (int i = 1; i < divisions; i++)
|
||||
{
|
||||
Vector2 normal = GetPositionNormal(t);
|
||||
float angle = (float)Math.Atan2(normal.Y, normal.X);
|
||||
float angle = MathF.Atan2(normal.Y, normal.X);
|
||||
|
||||
verts.Add(new Vector3(end, angle));
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Original source Farseer Physics Engine:
|
||||
/* Original source Farseer Physics Engine:
|
||||
* Copyright (c) 2014 Ian Qvist, http://farseerphysics.codeplex.com
|
||||
* Microsoft Permissive License (Ms-PL) v1.1
|
||||
*/
|
||||
@@ -14,7 +14,7 @@ using FarseerPhysics.Dynamics;
|
||||
namespace FarseerPhysics.Common.PhysicsLogic
|
||||
{
|
||||
// Original Code by Steven Lu - see http://www.box2d.org/forum/viewtopic.php?f=3&t=1688
|
||||
// Ported to Farseer 3.0 by Nicolás Hormazábal
|
||||
// Ported to Farseer 3.0 by Nicolás Hormazábal
|
||||
|
||||
internal struct ShapeData
|
||||
{
|
||||
@@ -185,7 +185,7 @@ namespace FarseerPhysics.Common.PhysicsLogic
|
||||
if ((shapes[i].Body.BodyType == BodyType.Dynamic) && ps != null)
|
||||
{
|
||||
Vector2 toCentroid = shapes[i].Body.GetWorldPoint(ps.MassData.Centroid) - pos;
|
||||
float angleToCentroid = (float)Math.Atan2(toCentroid.Y, toCentroid.X);
|
||||
float angleToCentroid = MathF.Atan2(toCentroid.Y, toCentroid.X);
|
||||
float min = float.MaxValue;
|
||||
float max = float.MinValue;
|
||||
float minAbsolute = 0.0f;
|
||||
@@ -194,7 +194,7 @@ namespace FarseerPhysics.Common.PhysicsLogic
|
||||
for (int j = 0; j < ps.Vertices.Count; ++j)
|
||||
{
|
||||
Vector2 toVertex = (shapes[i].Body.GetWorldPoint(ps.Vertices[j]) - pos);
|
||||
float newAngle = (float)Math.Atan2(toVertex.Y, toVertex.X);
|
||||
float newAngle = MathF.Atan2(toVertex.Y, toVertex.X);
|
||||
float diff = (newAngle - angleToCentroid);
|
||||
|
||||
diff = (diff - MathHelper.Pi) % (2 * MathHelper.Pi);
|
||||
@@ -253,7 +253,7 @@ namespace FarseerPhysics.Common.PhysicsLogic
|
||||
midpt = midpt / 2;
|
||||
|
||||
Vector2 p1 = pos;
|
||||
Vector2 p2 = radius * new Vector2((float)Math.Cos(midpt), (float)Math.Sin(midpt)) + pos;
|
||||
Vector2 p2 = radius * new Vector2(MathF.Cos(midpt), MathF.Sin(midpt)) + pos;
|
||||
|
||||
// RaycastOne
|
||||
bool hitClosest = false;
|
||||
@@ -343,7 +343,7 @@ namespace FarseerPhysics.Common.PhysicsLogic
|
||||
j += offset)
|
||||
{
|
||||
Vector2 p1 = pos;
|
||||
Vector2 p2 = pos + radius * new Vector2((float)Math.Cos(j), (float)Math.Sin(j));
|
||||
Vector2 p2 = pos + radius * new Vector2(MathF.Cos(j), MathF.Sin(j));
|
||||
Vector2 hitpoint = Vector2.Zero;
|
||||
float minlambda = float.MaxValue;
|
||||
|
||||
@@ -371,7 +371,7 @@ namespace FarseerPhysics.Common.PhysicsLogic
|
||||
float impulse = (arclen / (MinRays + insertedRays)) * maxForce * 180.0f / MathHelper.Pi * (1.0f - Math.Min(1.0f, minlambda));
|
||||
|
||||
// We Apply the impulse!!!
|
||||
Vector2 vectImp = Vector2.Dot(impulse * new Vector2((float)Math.Cos(j), (float)Math.Sin(j)), -ro.Normal) * new Vector2((float)Math.Cos(j), (float)Math.Sin(j));
|
||||
Vector2 vectImp = Vector2.Dot(impulse * new Vector2(MathF.Cos(j), MathF.Sin(j)), -ro.Normal) * new Vector2(MathF.Cos(j), MathF.Sin(j));
|
||||
_data[i].Body.ApplyLinearImpulse(ref vectImp, ref hitpoint);
|
||||
|
||||
// We gather the fixtures for returning them
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace FarseerPhysics.Common.PhysicsLogic
|
||||
float forcePercent = GetPercent(distance, radius);
|
||||
|
||||
Vector2 forceVector = pos - overlappingBody.Position;
|
||||
forceVector *= 1f / (float)Math.Sqrt(forceVector.X * forceVector.X + forceVector.Y * forceVector.Y);
|
||||
forceVector *= 1f / MathF.Sqrt(forceVector.X * forceVector.X + forceVector.Y * forceVector.Y);
|
||||
forceVector *= MathHelper.Min(force * forcePercent, maxForce);
|
||||
forceVector *= -1;
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace FarseerPhysics.Common.PhysicsLogic
|
||||
private float GetPercent(float distance, float radius)
|
||||
{
|
||||
//(1-(distance/radius))^power-1
|
||||
float percent = (float)Math.Pow(1 - ((distance - radius) / radius), Power) - 1;
|
||||
float percent = MathF.Pow(1 - ((distance - radius) / radius), Power) - 1;
|
||||
|
||||
if (float.IsNaN(percent))
|
||||
return 0f;
|
||||
|
||||
@@ -137,8 +137,8 @@ namespace FarseerPhysics.Common.PolygonManipulation
|
||||
float dy0 = vertices[middle].Y - vertices[lower].Y;
|
||||
float dx1 = vertices[upper].Y - vertices[middle].X;
|
||||
float dy1 = vertices[upper].Y - vertices[middle].Y;
|
||||
float norm0 = (float)Math.Sqrt(dx0 * dx0 + dy0 * dy0);
|
||||
float norm1 = (float)Math.Sqrt(dx1 * dx1 + dy1 * dy1);
|
||||
float norm0 = MathF.Sqrt(dx0 * dx0 + dy0 * dy0);
|
||||
float norm1 = MathF.Sqrt(dx1 * dx1 + dy1 * dy1);
|
||||
|
||||
if (!(norm0 > 0.0f && norm1 > 0.0f) && newNVertices > 3)
|
||||
{
|
||||
|
||||
@@ -112,8 +112,8 @@ namespace FarseerPhysics.Common
|
||||
phase--;
|
||||
}
|
||||
|
||||
vertices.Add(posOffset + new Vector2(xRadius * (float)Math.Cos(stepSize * -(i + phase)),
|
||||
-yRadius * (float)Math.Sin(stepSize * -(i + phase))));
|
||||
vertices.Add(posOffset + new Vector2(xRadius * MathF.Cos(stepSize * -(i + phase)),
|
||||
-yRadius * MathF.Sin(stepSize * -(i + phase))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,8 +160,8 @@ namespace FarseerPhysics.Common
|
||||
|
||||
vertices.Add(new Vector2(xRadius, 0));
|
||||
for (int i = numberOfEdges - 1; i > 0; --i)
|
||||
vertices.Add(new Vector2(xRadius * (float)Math.Cos(stepSize * i),
|
||||
-yRadius * (float)Math.Sin(stepSize * i)));
|
||||
vertices.Add(new Vector2(xRadius * MathF.Cos(stepSize * i),
|
||||
-yRadius * MathF.Sin(stepSize * i)));
|
||||
|
||||
return vertices;
|
||||
}
|
||||
@@ -177,8 +177,8 @@ namespace FarseerPhysics.Common
|
||||
float stepSize = radians / sides;
|
||||
for (int i = sides - 1; i > 0; i--)
|
||||
{
|
||||
vertices.Add(new Vector2(radius * (float)Math.Cos(stepSize * i),
|
||||
radius * (float)Math.Sin(stepSize * i)));
|
||||
vertices.Add(new Vector2(radius * MathF.Cos(stepSize * i),
|
||||
radius * MathF.Sin(stepSize * i)));
|
||||
}
|
||||
|
||||
return vertices;
|
||||
@@ -252,8 +252,8 @@ namespace FarseerPhysics.Common
|
||||
float stepSize = MathHelper.Pi / topEdges;
|
||||
for (int i = 1; i < topEdges; i++)
|
||||
{
|
||||
vertices.Add(new Vector2(topRadius * (float)Math.Cos(stepSize * i),
|
||||
topRadius * (float)Math.Sin(stepSize * i) + newHeight));
|
||||
vertices.Add(new Vector2(topRadius * MathF.Cos(stepSize * i),
|
||||
topRadius * MathF.Sin(stepSize * i) + newHeight));
|
||||
}
|
||||
|
||||
vertices.Add(new Vector2(-topRadius, newHeight));
|
||||
@@ -264,8 +264,8 @@ namespace FarseerPhysics.Common
|
||||
stepSize = MathHelper.Pi / bottomEdges;
|
||||
for (int i = 1; i < bottomEdges; i++)
|
||||
{
|
||||
vertices.Add(new Vector2(-bottomRadius * (float)Math.Cos(stepSize * i),
|
||||
-bottomRadius * (float)Math.Sin(stepSize * i) - newHeight));
|
||||
vertices.Add(new Vector2(-bottomRadius * MathF.Cos(stepSize * i),
|
||||
-bottomRadius * MathF.Sin(stepSize * i) - newHeight));
|
||||
}
|
||||
|
||||
vertices.Add(new Vector2(bottomRadius, -newHeight));
|
||||
@@ -298,24 +298,24 @@ namespace FarseerPhysics.Common
|
||||
{
|
||||
vertices.Add(
|
||||
new Vector2(radius *
|
||||
(float)Math.Cos(stepSize * i + toothAngleStepSize * 2f + toothTipStepSize),
|
||||
MathF.Cos(stepSize * i + toothAngleStepSize * 2f + toothTipStepSize),
|
||||
-radius *
|
||||
(float)Math.Sin(stepSize * i + toothAngleStepSize * 2f + toothTipStepSize)));
|
||||
MathF.Sin(stepSize * i + toothAngleStepSize * 2f + toothTipStepSize)));
|
||||
|
||||
vertices.Add(
|
||||
new Vector2((radius + toothHeight) *
|
||||
(float)Math.Cos(stepSize * i + toothAngleStepSize + toothTipStepSize),
|
||||
MathF.Cos(stepSize * i + toothAngleStepSize + toothTipStepSize),
|
||||
-(radius + toothHeight) *
|
||||
(float)Math.Sin(stepSize * i + toothAngleStepSize + toothTipStepSize)));
|
||||
MathF.Sin(stepSize * i + toothAngleStepSize + toothTipStepSize)));
|
||||
}
|
||||
|
||||
vertices.Add(new Vector2((radius + toothHeight) *
|
||||
(float)Math.Cos(stepSize * i + toothAngleStepSize),
|
||||
MathF.Cos(stepSize * i + toothAngleStepSize),
|
||||
-(radius + toothHeight) *
|
||||
(float)Math.Sin(stepSize * i + toothAngleStepSize)));
|
||||
MathF.Sin(stepSize * i + toothAngleStepSize)));
|
||||
|
||||
vertices.Add(new Vector2(radius * (float)Math.Cos(stepSize * i),
|
||||
-radius * (float)Math.Sin(stepSize * i)));
|
||||
vertices.Add(new Vector2(radius * MathF.Cos(stepSize * i),
|
||||
-radius * MathF.Sin(stepSize * i)));
|
||||
}
|
||||
|
||||
return vertices;
|
||||
|
||||
@@ -287,8 +287,8 @@ namespace FarseerPhysics.Common
|
||||
{
|
||||
Debug.Assert(!AttachedToBody, "Rotating vertices that are used by a Body can result in unstable behavior.");
|
||||
|
||||
float num1 = (float)Math.Cos(value);
|
||||
float num2 = (float)Math.Sin(value);
|
||||
float num1 = MathF.Cos(value);
|
||||
float num2 = MathF.Sin(value);
|
||||
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace FarseerPhysics.Controllers
|
||||
f = Strength / r2 * worldBody.Mass * controllerBody.Mass * d;
|
||||
break;
|
||||
case GravityType.Linear:
|
||||
f = Strength / (float)Math.Sqrt(r2) * worldBody.Mass * controllerBody.Mass * d;
|
||||
f = Strength / MathF.Sqrt(r2) * worldBody.Mass * controllerBody.Mass * d;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace FarseerPhysics.Controllers
|
||||
f = Strength / r2 * worldBody.Mass * d;
|
||||
break;
|
||||
case GravityType.Linear:
|
||||
f = Strength / (float)Math.Sqrt(r2) * worldBody.Mass * d;
|
||||
f = Strength / MathF.Sqrt(r2) * worldBody.Mass * d;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace FarseerPhysics.Controllers
|
||||
|
||||
if (result > dt * _maxLinearSqared)
|
||||
{
|
||||
float sq = (float)Math.Sqrt(result);
|
||||
float sq = MathF.Sqrt(result);
|
||||
|
||||
float ratio = _maxLinearVelocity / sq;
|
||||
body._linearVelocity.X *= ratio;
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using FarseerPhysics.Collision;
|
||||
using FarseerPhysics.Collision.Shapes;
|
||||
using FarseerPhysics.Common;
|
||||
@@ -98,7 +99,7 @@ namespace FarseerPhysics.Dynamics
|
||||
/// <value>The revolutions.</value>
|
||||
public float Revolutions
|
||||
{
|
||||
get { return Rotation / (float)Math.PI; }
|
||||
get { return Rotation / MathF.PI; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -614,6 +615,10 @@ namespace FarseerPhysics.Dynamics
|
||||
|
||||
fixture.Body = this;
|
||||
this.FixtureList.Add(fixture);
|
||||
|
||||
RefreshCollidesWithMatchesBetweenFixtures();
|
||||
RefreshCollisionCategoriesMatchBetweenFixtures();
|
||||
|
||||
#if DEBUG
|
||||
if (fixture.Shape.ShapeType == ShapeType.Polygon)
|
||||
((PolygonShape)fixture.Shape).Vertices.AttachedToBody = true;
|
||||
@@ -685,6 +690,8 @@ namespace FarseerPhysics.Dynamics
|
||||
|
||||
fixture.Body = null;
|
||||
FixtureList.Remove(fixture);
|
||||
RefreshCollidesWithMatchesBetweenFixtures();
|
||||
RefreshCollisionCategoriesMatchBetweenFixtures();
|
||||
#if DEBUG
|
||||
if (fixture.Shape.ShapeType == ShapeType.Polygon)
|
||||
((PolygonShape)fixture.Shape).Vertices.AttachedToBody = false;
|
||||
@@ -1241,29 +1248,89 @@ namespace FarseerPhysics.Dynamics
|
||||
FixtureList[i].Friction = friction;
|
||||
}
|
||||
|
||||
public bool CollisionCategoriesMatchBetweenFixtures
|
||||
{
|
||||
get; private set;
|
||||
} = false;
|
||||
|
||||
private Category _collisionCategories;
|
||||
public Category CollisionCategories
|
||||
{
|
||||
get { return _collisionCategories; }
|
||||
set { SetCollisionCategories(value); }
|
||||
}
|
||||
|
||||
public bool CollidesWithMatchesBetweenFixtures
|
||||
{
|
||||
get; private set;
|
||||
} = false;
|
||||
|
||||
private Category _collidesWith;
|
||||
public Category CollidesWith
|
||||
{
|
||||
get { return _collidesWith; }
|
||||
set { SetCollidesWith(value); }
|
||||
}
|
||||
|
||||
public void RefreshCollisionCategoriesMatchBetweenFixtures()
|
||||
{
|
||||
if (FixtureList.Count < 2)
|
||||
{
|
||||
if (FixtureList.Count > 0) { _collisionCategories = FixtureList[0].CollisionCategories; }
|
||||
CollisionCategoriesMatchBetweenFixtures = true;
|
||||
return;
|
||||
}
|
||||
for (int i = 1; i < FixtureList.Count; i++)
|
||||
{
|
||||
if (FixtureList[i].CollisionCategories != FixtureList[0].CollisionCategories)
|
||||
{
|
||||
CollisionCategoriesMatchBetweenFixtures = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
CollisionCategoriesMatchBetweenFixtures = true;
|
||||
_collisionCategories = FixtureList[0].CollisionCategories;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Warning: This method applies the value on existing Fixtures. It's not a property of Body.
|
||||
/// </summary>
|
||||
public void SetCollisionCategories(Category category)
|
||||
{
|
||||
CollisionCategoriesMatchBetweenFixtures = true;
|
||||
_collisionCategories = category;
|
||||
for (int i = 0; i < FixtureList.Count; i++)
|
||||
FixtureList[i].CollisionCategories = category;
|
||||
}
|
||||
|
||||
public void RefreshCollidesWithMatchesBetweenFixtures()
|
||||
{
|
||||
if (FixtureList.Count < 2)
|
||||
{
|
||||
if (FixtureList.Count > 0) { _collidesWith = FixtureList[0].CollidesWith; }
|
||||
CollidesWithMatchesBetweenFixtures = true;
|
||||
return;
|
||||
}
|
||||
for (int i = 1; i < FixtureList.Count; i++)
|
||||
{
|
||||
if (FixtureList[i].CollidesWith != FixtureList[0].CollidesWith)
|
||||
{
|
||||
CollidesWithMatchesBetweenFixtures = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
CollidesWithMatchesBetweenFixtures = true;
|
||||
_collidesWith = FixtureList[0].CollidesWith;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Warning: This method applies the value on existing Fixtures. It's not a property of Body.
|
||||
/// </summary>
|
||||
public void SetCollidesWith(Category category)
|
||||
{
|
||||
CollidesWithMatchesBetweenFixtures = true;
|
||||
_collidesWith = category;
|
||||
for (int i = 0; i < FixtureList.Count; i++)
|
||||
FixtureList[i].CollidesWith = category;
|
||||
}
|
||||
|
||||
@@ -172,7 +172,6 @@ namespace FarseerPhysics.Dynamics
|
||||
if (bodyB.ShouldCollide(bodyA) == false)
|
||||
return;
|
||||
|
||||
//Check default filter
|
||||
if (ShouldCollide(fixtureA, fixtureB) == false)
|
||||
return;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2017 Kastellanos Nikolaos
|
||||
// Copyright (c) 2017 Kastellanos Nikolaos
|
||||
|
||||
/* Original source Farseer Physics Engine:
|
||||
* Copyright (c) 2014 Ian Qvist, http://farseerphysics.codeplex.com
|
||||
@@ -139,6 +139,10 @@ namespace FarseerPhysics.Dynamics
|
||||
|
||||
_collidesWith = value;
|
||||
Refilter();
|
||||
if (Body != null)
|
||||
{
|
||||
Body.RefreshCollidesWithMatchesBetweenFixtures();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,13 +155,17 @@ namespace FarseerPhysics.Dynamics
|
||||
{
|
||||
get { return _collisionCategories; }
|
||||
|
||||
set
|
||||
internal set
|
||||
{
|
||||
if (_collisionCategories == value)
|
||||
return;
|
||||
|
||||
_collisionCategories = value;
|
||||
Refilter();
|
||||
if (Body != null)
|
||||
{
|
||||
Body.RefreshCollisionCategoriesMatchBetweenFixtures();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Original source Farseer Physics Engine:
|
||||
/* Original source Farseer Physics Engine:
|
||||
* Copyright (c) 2014 Ian Qvist, http://farseerphysics.codeplex.com
|
||||
* Microsoft Permissive License (Ms-PL) v1.1
|
||||
*/
|
||||
@@ -243,7 +243,7 @@ namespace FarseerPhysics.Dynamics.Joints
|
||||
Enabled = false;
|
||||
|
||||
if (Broke != null)
|
||||
Broke(this, (float)Math.Sqrt(jointErrorSquared));
|
||||
Broke(this, MathF.Sqrt(jointErrorSquared));
|
||||
}
|
||||
|
||||
internal abstract void SolveVelocityConstraints(ref SolverData data);
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace FarseerPhysics.Fluids
|
||||
|
||||
if (u > 0.0f)
|
||||
{
|
||||
q = 1.0f - (float)Math.Sqrt(q) / Definition.InfluenceRadius;
|
||||
q = 1.0f - MathF.Sqrt(q) / Definition.InfluenceRadius;
|
||||
|
||||
float impulseFactor = 0.5f * timeStep * q * (u * (Definition.ViscositySigma + Definition.ViscosityBeta * u));
|
||||
|
||||
@@ -152,7 +152,7 @@ namespace FarseerPhysics.Fluids
|
||||
// _distanceCache[_j] = _q;
|
||||
// if (_q < _influenceRadiusSquared && _q != 0)
|
||||
// {
|
||||
// _q = (float)Math.Sqrt(_q);
|
||||
// _q = MathF.Sqrt(_q);
|
||||
// _q /= Definition.InfluenceRadius;
|
||||
// _qq = ((1 - _q) * (1 - _q));
|
||||
// _density += _qq;
|
||||
@@ -170,7 +170,7 @@ namespace FarseerPhysics.Fluids
|
||||
// _q = _distanceCache[_j];
|
||||
// if (_q < _influenceRadiusSquared && _q != 0)
|
||||
// {
|
||||
// _q = (float)Math.Sqrt(_q);
|
||||
// _q = MathF.Sqrt(_q);
|
||||
// _rij = p.Neighbours[_j].Position;
|
||||
// _rij -= p.Position;
|
||||
// _rij *= 1 / _q;
|
||||
@@ -209,7 +209,7 @@ namespace FarseerPhysics.Fluids
|
||||
if (q > _influenceRadiusSquared)
|
||||
continue;
|
||||
|
||||
q = 1.0f - (float)Math.Sqrt(q) / Definition.InfluenceRadius;
|
||||
q = 1.0f - MathF.Sqrt(q) / Definition.InfluenceRadius;
|
||||
|
||||
float densityDelta = q * q;
|
||||
_density += densityDelta;
|
||||
@@ -237,7 +237,7 @@ namespace FarseerPhysics.Fluids
|
||||
if (q > _influenceRadiusSquared)
|
||||
continue;
|
||||
|
||||
q = 1.0f - (float)Math.Sqrt(q) / Definition.InfluenceRadius;
|
||||
q = 1.0f - MathF.Sqrt(q) / Definition.InfluenceRadius;
|
||||
|
||||
float dispFactor = deltaTime2 * (q * (_pressure + _pressureNear * q));
|
||||
|
||||
@@ -281,7 +281,7 @@ namespace FarseerPhysics.Fluids
|
||||
if (!_springs.ContainsKey(hash))
|
||||
{
|
||||
//TODO: Use pool?
|
||||
Spring spring = new Spring(p, neighbour) { RestLength = (float)Math.Sqrt(q) };
|
||||
Spring spring = new Spring(p, neighbour) { RestLength = MathF.Sqrt(q) };
|
||||
_springs.Add(hash, spring);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ namespace FarseerPhysics.Fluids
|
||||
Vector2.DistanceSquared(ref particle.Position, ref tempParticle.Position, out q);
|
||||
if ((q < InfluenceRadiusSquared) && (q != 0))
|
||||
{
|
||||
q = (float)Math.Sqrt(q);
|
||||
q = MathF.Sqrt(q);
|
||||
Vector2.Subtract(ref tempParticle.Position, ref particle.Position, out _rij);
|
||||
Vector2.Divide(ref _rij, q, out _rij);
|
||||
|
||||
@@ -329,7 +329,7 @@ namespace FarseerPhysics.Fluids
|
||||
Vector2.DistanceSquared(ref particle.Position, ref tempParticle.Position, out q);
|
||||
if (q < InfluenceRadiusSquared && q != 0)
|
||||
{
|
||||
q = (float)Math.Sqrt(q);
|
||||
q = MathF.Sqrt(q);
|
||||
q /= InfluenceRadius;
|
||||
float qq = ((1 - q) * (1 - q));
|
||||
particle.Density += qq;
|
||||
@@ -348,7 +348,7 @@ namespace FarseerPhysics.Fluids
|
||||
Vector2.DistanceSquared(ref particle.Position, ref tempParticle.Position, out q);
|
||||
if ((q < InfluenceRadiusSquared) && (q != 0))
|
||||
{
|
||||
q = (float)Math.Sqrt(q);
|
||||
q = MathF.Sqrt(q);
|
||||
Vector2.Subtract(ref tempParticle.Position, ref particle.Position, out _rij);
|
||||
Vector2.Divide(ref _rij, q, out _rij);
|
||||
q /= InfluenceRadius;
|
||||
|
||||
@@ -220,7 +220,7 @@ namespace FarseerPhysics
|
||||
/// <returns></returns>
|
||||
public static float MixFriction(float friction1, float friction2)
|
||||
{
|
||||
return (float)Math.Sqrt(friction1 * friction2);
|
||||
return MathF.Sqrt(friction1 * friction2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user