Build 0.18.0.0

This commit is contained in:
Markus Isberg
2022-05-13 00:55:52 +09:00
parent 15d18e6ff6
commit 7547a9b78a
218 changed files with 3881 additions and 2192 deletions
@@ -44,13 +44,13 @@ namespace FarseerPhysics.Common
if (path.Closed)
{
ChainShape chain = new ChainShape(verts, true);
body.CreateFixture(chain);
body.CreateFixture(chain, Category.Cat1, Category.All);
}
else
{
for (int i = 1; i < verts.Count; i++)
{
body.CreateFixture(new EdgeShape(verts[i], verts[i - 1]));
body.CreateFixture(new EdgeShape(verts[i], verts[i - 1]), Category.Cat1, Category.All);
}
}
}
@@ -74,7 +74,7 @@ namespace FarseerPhysics.Common
foreach (Vertices item in decomposedVerts)
{
body.CreateFixture(new PolygonShape(item, density));
body.CreateFixture(new PolygonShape(item, density), Category.Cat1, Category.All);
}
}
@@ -105,7 +105,7 @@ namespace FarseerPhysics.Common
foreach (Shape shape in shapes)
{
b.CreateFixture(shape);
b.CreateFixture(shape, Category.Cat1, Category.All);
}
bodyList.Add(b);
@@ -56,7 +56,7 @@ namespace FarseerPhysics.Common.PhysicsLogic
foreach (Vertices part in vertices)
{
PolygonShape polygonShape = new PolygonShape(part, density);
Fixture fixture = MainBody.CreateFixture(polygonShape);
Fixture fixture = MainBody.CreateFixture(polygonShape, Category.Cat1, Category.All);
Parts.Add(fixture);
}
}
@@ -67,7 +67,7 @@ namespace FarseerPhysics.Common.PhysicsLogic
foreach (Shape part in shapes)
{
Fixture fixture = MainBody.CreateFixture(part);
Fixture fixture = MainBody.CreateFixture(part, Category.Cat1, Category.All);
Parts.Add(fixture);
}
}
@@ -82,7 +82,7 @@ namespace FarseerPhysics.Common.PhysicsLogic
foreach (Vertices part in triangles)
{
PolygonShape polygonShape = new PolygonShape(part, density);
Fixture fixture = MainBody.CreateFixture(polygonShape);
Fixture fixture = MainBody.CreateFixture(polygonShape, Category.Cat1, Category.All);
Parts.Add(fixture);
}
}
@@ -161,7 +161,7 @@ namespace FarseerPhysics.Common.PhysicsLogic
Body body = World.CreateBody(MainBody.Position, MainBody.Rotation, BodyType.Dynamic);
body.UserData = MainBody.UserData;
Fixture newFixture = body.CreateFixture(shape);
Fixture newFixture = body.CreateFixture(shape, Category.Cat1, Category.All);
newFixture.UserData = fixtureTag;
Parts[i] = newFixture;
@@ -614,7 +614,7 @@ namespace FarseerPhysics.Common
{
foreach (XMLFragmentElement element in fixtureElement.Elements)
{
Fixture fixture = new Fixture();
Fixture fixture = new Fixture(Category.Cat1, Category.All);
if (element.Name.ToLower() != "fixture")
throw new Exception();
@@ -35,7 +35,7 @@ namespace FarseerPhysics.Content
foreach (FixtureTemplate fixtureTemplate in Fixtures)
{
Fixture fixture = body.CreateFixture(fixtureTemplate.Shape);
Fixture fixture = body.CreateFixture(fixtureTemplate.Shape, Category.Cat1, Category.All);
fixture.UserData = fixtureTemplate.Name;
fixture.Restitution = fixtureTemplate.Restitution;
fixture.Friction = fixtureTemplate.Friction;
@@ -27,76 +27,76 @@ namespace FarseerPhysics.Dynamics
/// <param name="shape">The shape.</param>
/// <param name="userData">Application specific data</param>
/// <returns></returns>
public virtual Fixture CreateFixture(Shape shape)
public virtual Fixture CreateFixture(Shape shape, Category collisionCategory, Category collidesWith)
{
Fixture fixture = new Fixture(shape);
Fixture fixture = new Fixture(shape, collisionCategory, collidesWith);
Add(fixture);
return fixture;
}
public Fixture CreateEdge(Vector2 start, Vector2 end)
public Fixture CreateEdge(Vector2 start, Vector2 end, Category collisionCategory, Category collidesWith)
{
EdgeShape edgeShape = new EdgeShape(start, end);
return CreateFixture(edgeShape);
return CreateFixture(edgeShape, collisionCategory, collidesWith);
}
public Fixture CreateChainShape(Vertices vertices)
public Fixture CreateChainShape(Vertices vertices, Category collisionCategory, Category collidesWith)
{
ChainShape shape = new ChainShape(vertices);
return CreateFixture(shape);
return CreateFixture(shape, collisionCategory, collidesWith);
}
public Fixture CreateLoopShape(Vertices vertices)
public Fixture CreateLoopShape(Vertices vertices, Category collisionCategory, Category collidesWith)
{
ChainShape shape = new ChainShape(vertices, true);
return CreateFixture(shape);
return CreateFixture(shape, collisionCategory, collidesWith);
}
public Fixture CreateRectangle(float width, float height, float density, Vector2 offset)
public Fixture CreateRectangle(float width, float height, float density, Vector2 offset, Category collisionCategory, Category collidesWith)
{
Vertices rectangleVertices = PolygonTools.CreateRectangle(width / 2, height / 2);
rectangleVertices.Translate(ref offset);
PolygonShape rectangleShape = new PolygonShape(rectangleVertices, density);
return CreateFixture(rectangleShape);
return CreateFixture(rectangleShape, collisionCategory, collidesWith);
}
public Fixture CreateRectangle(float width, float height, float density, float rotation, Vector2 offset)
public Fixture CreateRectangle(float width, float height, float density, float rotation, Vector2 offset, Category collisionCategory, Category collidesWith)
{
Vertices rectangleVertices = PolygonTools.CreateRectangle(width / 2, height / 2, Vector2.Zero, rotation);
rectangleVertices.Translate(ref offset);
PolygonShape rectangleShape = new PolygonShape(rectangleVertices, density);
return CreateFixture(rectangleShape);
return CreateFixture(rectangleShape, collisionCategory, collidesWith);
}
public Fixture CreateCircle(float radius, float density)
public Fixture CreateCircle(float radius, float density, Category collisionCategory, Category collidesWith)
{
if (radius <= 0)
throw new ArgumentOutOfRangeException("radius", "Radius must be more than 0 meters");
CircleShape circleShape = new CircleShape(radius, density);
return CreateFixture(circleShape);
return CreateFixture(circleShape, collisionCategory, collidesWith);
}
public Fixture CreateCircle(float radius, float density, Vector2 offset)
public Fixture CreateCircle(float radius, float density, Vector2 offset, Category collisionCategory, Category collidesWith)
{
if (radius <= 0)
throw new ArgumentOutOfRangeException("radius", "Radius must be more than 0 meters");
CircleShape circleShape = new CircleShape(radius, density);
circleShape.Position = offset;
return CreateFixture(circleShape);
return CreateFixture(circleShape, collisionCategory, collidesWith);
}
public Fixture CreatePolygon(Vertices vertices, float density)
public Fixture CreatePolygon(Vertices vertices, float density, Category collisionCategory, Category collidesWith)
{
if (vertices.Count <= 1)
throw new ArgumentOutOfRangeException("vertices", "Too few points to be a polygon");
PolygonShape polygon = new PolygonShape(vertices, density);
return CreateFixture(polygon);
return CreateFixture(polygon, collisionCategory, collidesWith);
}
public Fixture CreateEllipse(float xRadius, float yRadius, int edges, float density)
public Fixture CreateEllipse(float xRadius, float yRadius, int edges, float density, Category collisionCategory, Category collidesWith)
{
if (xRadius <= 0)
throw new ArgumentOutOfRangeException("xRadius", "X-radius must be more than 0");
@@ -106,10 +106,10 @@ namespace FarseerPhysics.Dynamics
Vertices ellipseVertices = PolygonTools.CreateEllipse(xRadius, yRadius, edges);
PolygonShape polygonShape = new PolygonShape(ellipseVertices, density);
return CreateFixture(polygonShape);
return CreateFixture(polygonShape, collisionCategory, collidesWith);
}
public List<Fixture> CreateCompoundPolygon(List<Vertices> list, float density)
public List<Fixture> CreateCompoundPolygon(List<Vertices> list, float density, Category collisionCategory, Category collidesWith)
{
List<Fixture> res = new List<Fixture>(list.Count);
@@ -119,26 +119,26 @@ namespace FarseerPhysics.Dynamics
if (vertices.Count == 2)
{
EdgeShape shape = new EdgeShape(vertices[0], vertices[1]);
res.Add(CreateFixture(shape));
res.Add(CreateFixture(shape, collisionCategory, collidesWith));
}
else
{
PolygonShape shape = new PolygonShape(vertices, density);
res.Add(CreateFixture(shape));
res.Add(CreateFixture(shape, collisionCategory, collidesWith));
}
}
return res;
}
public Fixture CreateLineArc(float radians, int sides, float radius, bool closed)
public Fixture CreateLineArc(float radians, int sides, float radius, bool closed, Category collisionCategory, Category collidesWith)
{
Vertices arc = PolygonTools.CreateArc(radians, sides, radius);
arc.Rotate((MathHelper.Pi - radians) / 2);
return closed ? CreateLoopShape(arc) : CreateChainShape(arc);
return closed ? CreateLoopShape(arc, collisionCategory, collidesWith) : CreateChainShape(arc, collisionCategory, collidesWith);
}
public List<Fixture> CreateSolidArc(float density, float radians, int sides, float radius)
public List<Fixture> CreateSolidArc(float density, float radians, int sides, float radius, Category collisionCategory, Category collidesWith)
{
Vertices arc = PolygonTools.CreateArc(radians, sides, radius);
arc.Rotate((MathHelper.Pi - radians) / 2);
@@ -148,7 +148,7 @@ namespace FarseerPhysics.Dynamics
List<Vertices> triangles = Triangulate.ConvexPartition(arc, TriangulationAlgorithm.Earclip);
return CreateCompoundPolygon(triangles, density);
return CreateCompoundPolygon(triangles, density, collisionCategory, collidesWith);
}
}
}
@@ -82,10 +82,10 @@ namespace FarseerPhysics.Dynamics
/// </summary>
public OnSeparationEventHandler OnSeparation;
internal Fixture() // Note: This is internal because it's used by Deserialization.
internal Fixture(Category collisionCategory, Category collidesWith) // Note: This is internal because it's used by Deserialization.
{
_collisionCategories = Category.Cat1;
_collidesWith = Category.All;
_collisionCategories = collisionCategory;
_collidesWith = collidesWith;
_collisionGroup = 0;
//Fixture defaults
@@ -93,7 +93,7 @@ namespace FarseerPhysics.Dynamics
Restitution = 0f;
}
public Fixture(Shape shape) : this()
public Fixture(Shape shape, Category collisionCategory, Category collidesWith) : this(collisionCategory, collidesWith)
{
Shape = shape.Clone();
@@ -375,15 +375,15 @@ namespace FarseerPhysics.Dynamics
/// <returns>The cloned fixture.</returns>
internal Fixture CloneOnto(Body body, Shape shape)
{
Fixture fixture = new Fixture(shape.Clone());
fixture.UserData = UserData;
fixture.Restitution = Restitution;
fixture.Friction = Friction;
fixture.IsSensor = IsSensor;
fixture._collisionGroup = _collisionGroup;
fixture._collisionCategories = _collisionCategories;
fixture._collidesWith = _collidesWith;
Fixture fixture = new Fixture(shape.Clone(), _collisionCategories, _collidesWith)
{
UserData = UserData,
Restitution = Restitution,
Friction = Friction,
IsSensor = IsSensor,
_collisionGroup = _collisionGroup
};
body.Add(fixture);
return fixture;
}
@@ -17,43 +17,42 @@ namespace FarseerPhysics.Dynamics
{
public partial class World
{
public virtual Body CreateBody(Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static)
public virtual Body CreateBody(Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, bool findNewContacts = true)
{
Body body = new Body();
body.Position = position;
body.Rotation = rotation;
body.BodyType = bodyType;
AddAsync(body);
Body body = new Body
{
Position = position,
Rotation = rotation,
BodyType = bodyType
};
AddAsync(body, findNewContacts);
return body;
}
public Body CreateEdge(Vector2 start, Vector2 end)
public Body CreateEdge(Vector2 start, Vector2 end, BodyType bodyType = BodyType.Static, Category collisionCategory = Category.Cat1, Category collidesWith = Category.All, bool findNewContacts = true)
{
Body body = CreateBody();
body.CreateEdge(start, end);
Body body = CreateBody(bodyType: bodyType, findNewContacts: findNewContacts);
body.CreateEdge(start, end, collisionCategory, collidesWith);
return body;
}
public Body CreateChainShape(Vertices vertices, Vector2 position = new Vector2())
public Body CreateChainShape(Vertices vertices, Vector2 position = new Vector2(), Category collisionCategory = Category.Cat1, Category collidesWith = Category.All, bool findNewContacts = true)
{
Body body = CreateBody(position);
body.CreateChainShape(vertices);
Body body = CreateBody(position, findNewContacts: findNewContacts);
body.CreateChainShape(vertices, collisionCategory, collidesWith);
return body;
}
public Body CreateLoopShape(Vertices vertices, Vector2 position = new Vector2())
public Body CreateLoopShape(Vertices vertices, Vector2 position = new Vector2(), Category collisionCategory = Category.Cat1, Category collidesWith = Category.All, bool findNewContacts = true)
{
Body body = CreateBody(position);
body.CreateLoopShape(vertices);
Body body = CreateBody(position, findNewContacts: findNewContacts);
body.CreateLoopShape(vertices, collisionCategory, collidesWith);
return body;
}
public Body CreateRectangle(float width, float height, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static)
public Body CreateRectangle(float width, float height, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, Category collisionCategory = Category.Cat1, Category collidesWith = Category.All, bool findNewContacts = true)
{
if (width <= 0)
throw new ArgumentOutOfRangeException("width", "Width must be more than 0 meters");
@@ -61,44 +60,44 @@ namespace FarseerPhysics.Dynamics
if (height <= 0)
throw new ArgumentOutOfRangeException("height", "Height must be more than 0 meters");
Body body = CreateBody(position, rotation, bodyType);
Body body = CreateBody(position, rotation, bodyType, findNewContacts);
Vertices rectangleVertices = PolygonTools.CreateRectangle(width / 2, height / 2);
body.CreatePolygon(rectangleVertices, density);
body.CreatePolygon(rectangleVertices, density, collisionCategory, collidesWith);
return body;
}
public Body CreateCircle(float radius, float density, Vector2 position = new Vector2(), BodyType bodyType = BodyType.Static)
public Body CreateCircle(float radius, float density, Vector2 position = new Vector2(), BodyType bodyType = BodyType.Static, Category collisionCategory = Category.Cat1, Category collidesWith = Category.All, bool findNewContacts = true)
{
Body body = CreateBody(position, 0, bodyType);
body.CreateCircle(radius, density);
Body body = CreateBody(position, 0, bodyType, findNewContacts);
body.CreateCircle(radius, density, collisionCategory, collidesWith);
return body;
}
public Body CreateEllipse(float xRadius, float yRadius, int edges, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static)
public Body CreateEllipse(float xRadius, float yRadius, int edges, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, Category collisionCategory = Category.Cat1, Category collidesWith = Category.All, bool findNewContacts = true)
{
Body body = CreateBody(position, rotation, bodyType);
body.CreateEllipse(xRadius, yRadius, edges, density);
Body body = CreateBody(position, rotation, bodyType, findNewContacts);
body.CreateEllipse(xRadius, yRadius, edges, density, collisionCategory, collidesWith);
return body;
}
public Body CreatePolygon(Vertices vertices, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static)
public Body CreatePolygon(Vertices vertices, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, Category collisionCategory = Category.Cat1, Category collidesWith = Category.All, bool findNewContacts = true)
{
Body body = CreateBody(position, rotation, bodyType);
body.CreatePolygon(vertices, density);
Body body = CreateBody(position, rotation, bodyType, findNewContacts);
body.CreatePolygon(vertices, density, collisionCategory, collidesWith);
return body;
}
public Body CreateCompoundPolygon(List<Vertices> list, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static)
public Body CreateCompoundPolygon(List<Vertices> list, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, Category collisionCategory = Category.Cat1, Category collidesWith = Category.All, bool findNewContacts = true)
{
//We create a single body
Body body = CreateBody(position, rotation, bodyType);
body.CreateCompoundPolygon(list, density);
Body body = CreateBody(position, rotation, bodyType, findNewContacts);
body.CreateCompoundPolygon(list, density, collisionCategory, collidesWith);
return body;
}
public Body CreateGear(float radius, int numberOfTeeth, float tipPercentage, float toothHeight, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static)
public Body CreateGear(float radius, int numberOfTeeth, float tipPercentage, float toothHeight, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, Category collisionCategory = Category.Cat1, Category collidesWith = Category.All)
{
Vertices gearPolygon = PolygonTools.CreateGear(radius, numberOfTeeth, tipPercentage, toothHeight);
@@ -108,13 +107,13 @@ namespace FarseerPhysics.Dynamics
//Decompose the gear:
List<Vertices> list = Triangulate.ConvexPartition(gearPolygon, TriangulationAlgorithm.Earclip);
return CreateCompoundPolygon(list, density, position, rotation, bodyType);
return CreateCompoundPolygon(list, density, position, rotation, bodyType, collisionCategory, collidesWith);
}
return CreatePolygon(gearPolygon, density, position, rotation, bodyType);
return CreatePolygon(gearPolygon, density, position, rotation, bodyType, collisionCategory, collidesWith);
}
public Body CreateCapsule(float height, float topRadius, int topEdges, float bottomRadius, int bottomEdges, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static)
public Body CreateCapsule(float height, float topRadius, int topEdges, float bottomRadius, int bottomEdges, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, Category collisionCategory = Category.Cat1, Category collidesWith = Category.All, bool findNewContacts = true)
{
Vertices verts = PolygonTools.CreateCapsule(height, topRadius, topEdges, bottomRadius, bottomEdges);
@@ -122,23 +121,25 @@ namespace FarseerPhysics.Dynamics
if (verts.Count >= Settings.MaxPolygonVertices)
{
List<Vertices> vertList = Triangulate.ConvexPartition(verts, TriangulationAlgorithm.Earclip);
return CreateCompoundPolygon(vertList, density, position, rotation, bodyType);
return CreateCompoundPolygon(vertList, density, position, rotation, bodyType, collisionCategory, collidesWith, findNewContacts);
}
return CreatePolygon(verts, density, position, rotation, bodyType);
return CreatePolygon(verts, density, position, rotation, bodyType, collisionCategory, collidesWith, findNewContacts);
}
public Body CreateCapsuleHorizontal(float width, float endRadius, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static)
public Body CreateCapsuleHorizontal(float width, float endRadius, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, Category collisionCategory = Category.Cat1, Category collidesWith = Category.All, bool findNewContacts = true)
{
//Create the middle rectangle
Vertices rectangle = PolygonTools.CreateRectangle(width / 2, endRadius);
List<Vertices> list = new List<Vertices>();
list.Add(rectangle);
List<Vertices> list = new List<Vertices>
{
rectangle
};
Body body = CreateCompoundPolygon(list, density, position, rotation, bodyType);
body.CreateCircle(endRadius, density, new Vector2(width / 2, 0));
body.CreateCircle(endRadius, density, new Vector2(-width / 2, 0));
Body body = CreateCompoundPolygon(list, density, position, rotation, bodyType, collisionCategory, collidesWith, findNewContacts);
body.CreateCircle(endRadius, density, new Vector2(width / 2, 0), collisionCategory, collidesWith);
body.CreateCircle(endRadius, density, new Vector2(-width / 2, 0), collisionCategory, collidesWith);
//Create the two circles
//CircleShape topCircle = new CircleShape(endRadius, density);
@@ -150,17 +151,19 @@ namespace FarseerPhysics.Dynamics
//body.CreateFixture(bottomCircle);
return body;
}
public Body CreateCapsule(float height, float endRadius, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static)
public Body CreateCapsule(float height, float endRadius, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, Category collisionCategory = Category.Cat1, Category collidesWith = Category.All, bool findNewContacts = true)
{
//Create the middle rectangle
Vertices rectangle = PolygonTools.CreateRectangle(endRadius, height / 2);
List<Vertices> list = new List<Vertices>();
list.Add(rectangle);
List<Vertices> list = new List<Vertices>()
{
rectangle
};
Body body = CreateCompoundPolygon(list, density, position, rotation, bodyType);
body.CreateCircle(endRadius, density, new Vector2(0, height / 2));
body.CreateCircle(endRadius, density, new Vector2(0, -(height / 2)));
Body body = CreateCompoundPolygon(list, density, position, rotation, bodyType, collisionCategory, collidesWith, findNewContacts);
body.CreateCircle(endRadius, density, new Vector2(0, height / 2), collisionCategory, collidesWith);
body.CreateCircle(endRadius, density, new Vector2(0, -(height / 2)), collisionCategory, collidesWith);
//Create the two circles
//CircleShape topCircle = new CircleShape(endRadius, density);
@@ -173,7 +176,7 @@ namespace FarseerPhysics.Dynamics
return body;
}
public Body CreateRoundedRectangle(float width, float height, float xRadius, float yRadius, int segments, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static)
public Body CreateRoundedRectangle(float width, float height, float xRadius, float yRadius, int segments, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, Category collisionCategory = Category.Cat1, Category collidesWith = Category.All)
{
Vertices verts = PolygonTools.CreateRoundedRectangle(width, height, xRadius, yRadius, segments);
@@ -181,23 +184,23 @@ namespace FarseerPhysics.Dynamics
if (verts.Count >= Settings.MaxPolygonVertices)
{
List<Vertices> vertList = Triangulate.ConvexPartition(verts, TriangulationAlgorithm.Earclip);
return CreateCompoundPolygon(vertList, density, position, rotation, bodyType);
return CreateCompoundPolygon(vertList, density, position, rotation, bodyType, collisionCategory, collidesWith);
}
return CreatePolygon(verts, density, position, rotation, bodyType);
return CreatePolygon(verts, density, position, rotation, bodyType, collisionCategory, collidesWith);
}
public Body CreateLineArc(float radians, int sides, float radius, bool closed = false, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static)
public Body CreateLineArc(float radians, int sides, float radius, bool closed = false, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, Category collisionCategory = Category.Cat1, Category collidesWith = Category.All)
{
Body body = CreateBody(position, rotation, bodyType);
body.CreateLineArc(radians, sides, radius, closed);
body.CreateLineArc(radians, sides, radius, closed, collisionCategory, collidesWith);
return body;
}
public Body CreateSolidArc(float density, float radians, int sides, float radius, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static)
public Body CreateSolidArc(float density, float radians, int sides, float radius, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, Category collisionCategory = Category.Cat1, Category collidesWith = Category.All)
{
Body body = CreateBody(position, rotation, bodyType);
body.CreateSolidArc(density, radians, sides, radius);
body.CreateSolidArc(density, radians, sides, radius, collisionCategory, collidesWith);
return body;
}
@@ -936,7 +936,7 @@ namespace FarseerPhysics.Dynamics
/// Warning: This method is locked during callbacks.
/// </summary>
/// <exception cref="System.InvalidOperationException">Thrown when the world is Locked/Stepping.</exception>
public virtual void Add(Body body)
public virtual void Add(Body body, bool findNewContacts)
{
if (IsLocked)
throw new WorldLockedException("Cannot add bodies when the World is locked.");
@@ -972,8 +972,10 @@ namespace FarseerPhysics.Dynamics
if (Enabled)
body.CreateProxies();
ContactManager.FindNewContacts();
if (findNewContacts)
{
ContactManager.FindNewContacts();
}
// Fire World events:
@@ -1227,7 +1229,7 @@ namespace FarseerPhysics.Dynamics
/// Add a rigid body.
/// </summary>
/// <returns></returns>
public void AddAsync(Body body)
public void AddAsync(Body body, bool findNewContacts)
{
if (body == null)
throw new ArgumentNullException("body");
@@ -1243,7 +1245,7 @@ namespace FarseerPhysics.Dynamics
Debug.WriteLine("You are adding the same body more than once.");
}
else
Add(body);
Add(body, findNewContacts);
}
/// <summary>
@@ -1322,7 +1324,7 @@ namespace FarseerPhysics.Dynamics
if (_bodyAddList.Count > 0)
{
foreach (Body body in _bodyAddList)
Add(body);
Add(body, findNewContacts: true);
_bodyAddList.Clear();
}
@@ -1414,7 +1416,7 @@ namespace FarseerPhysics.Dynamics
ProcessChanges();
if (Settings.EnableDiagnostics)
AddRemoveTime = TimeSpan.FromTicks(_watch.ElapsedTicks);
AddRemoveTime = TimeSpan.FromTicks(_watch.Elapsed.Ticks);
// If new fixtures were added, we need to find the new contacts.
if (_worldHasNewFixture)
@@ -1423,7 +1425,7 @@ namespace FarseerPhysics.Dynamics
_worldHasNewFixture = false;
}
if (Settings.EnableDiagnostics)
NewContactsTime = TimeSpan.FromTicks(_watch.ElapsedTicks) - AddRemoveTime;
NewContactsTime = TimeSpan.FromTicks(_watch.Elapsed.Ticks) - AddRemoveTime;
//FPE only: moved position and velocity iterations into Settings.cs
TimeStep step;
@@ -1443,12 +1445,12 @@ namespace FarseerPhysics.Dynamics
ControllerList[i].Update(dt);
}
if (Settings.EnableDiagnostics)
ControllersUpdateTime = TimeSpan.FromTicks(_watch.ElapsedTicks) - (AddRemoveTime + NewContactsTime);
ControllersUpdateTime = TimeSpan.FromTicks(_watch.Elapsed.Ticks) - (AddRemoveTime + NewContactsTime);
// Update contacts. This is where some contacts are destroyed.
ContactManager.Collide();
if (Settings.EnableDiagnostics)
ContactsUpdateTime = TimeSpan.FromTicks(_watch.ElapsedTicks) - (AddRemoveTime + NewContactsTime + ControllersUpdateTime);
ContactsUpdateTime = TimeSpan.FromTicks(_watch.Elapsed.Ticks) - (AddRemoveTime + NewContactsTime + ControllersUpdateTime);
// Integrate velocities, solve velocity constraints, and integrate positions.
if (_stepComplete && step.dt > 0.0f)
@@ -1456,7 +1458,7 @@ namespace FarseerPhysics.Dynamics
Solve(ref step);
}
if (Settings.EnableDiagnostics)
SolveUpdateTime = TimeSpan.FromTicks(_watch.ElapsedTicks) - (AddRemoveTime + NewContactsTime + ControllersUpdateTime + ContactsUpdateTime);
SolveUpdateTime = TimeSpan.FromTicks(_watch.Elapsed.Ticks) - (AddRemoveTime + NewContactsTime + ControllersUpdateTime + ContactsUpdateTime);
// Handle TOI events.
if (Settings.ContinuousPhysics && step.dt > 0.0f)
@@ -1464,7 +1466,7 @@ namespace FarseerPhysics.Dynamics
SolveTOI(ref step, ref iterations);
}
if (Settings.EnableDiagnostics)
ContinuousPhysicsTime = TimeSpan.FromTicks(_watch.ElapsedTicks) - (AddRemoveTime + NewContactsTime + ControllersUpdateTime + ContactsUpdateTime + SolveUpdateTime);
ContinuousPhysicsTime = TimeSpan.FromTicks(_watch.Elapsed.Ticks) - (AddRemoveTime + NewContactsTime + ControllersUpdateTime + ContactsUpdateTime + SolveUpdateTime);
if (step.dt > 0.0f)
Fluid.Update(dt);
@@ -35,6 +35,7 @@ namespace Microsoft.Xna.Framework.Graphics
format.GetGLFormat(GraphicsDevice, out glInternalFormat, out glFormat, out glType);
Threading.BlockOnUIThread(() =>
{
var prev = GraphicsExtensions.GetBoundTexture2D();
GenerateGLTextureIfRequired();
int w = width;
int h = height;
@@ -80,6 +81,8 @@ namespace Microsoft.Xna.Framework.Graphics
h = h / 2;
++level;
}
GL.BindTexture(TextureTarget.Texture2D, prev);
});
}