Unstable 1.8.4.0
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user