/// <summary>Creates a rectangle with the specified parameters.</summary> /// <param name="manager">The manager to create the object in.</param> /// <param name="width">The width of the rectangle.</param> /// <param name="height">The height of the rectangle.</param> /// <param name="localPosition">The offset of the rectangle relative to the body's local origin.</param> /// <param name="localAngle">The rotation of the rectangle relative to the body.</param> /// <param name="worldAngle">The initial world angle of the body.</param> /// <param name="type">The type of the body.</param> /// <param name="fixedRotation"> /// if set to <c>true</c> the rotation of the body is fixed to its initial value. /// </param> /// <param name="isBullet"> /// if set to <c>true</c> enables continuous collision with other dynamic bodies. /// </param> /// <param name="allowSleep"> /// if set to <c>true</c> allows the object to sleep when it is not moving (for improved performance). /// </param> /// <param name="density">The density of the fixture.</param> /// <param name="friction">The friction of the fixture.</param> /// <param name="restitution">The restitution of the fixture.</param> /// <param name="isSensor"> /// if set to <c>true</c> the created fixture is marked as a sensor (i.e. it will fire collision events but the /// collision will not be handled by the solver). /// </param> /// <param name="collisionCategory">The collision groups for the fixture.</param> /// <param name="collisionMask">The collision groups to collide with.</param> /// <returns>The created body.</returns> public static PolygonFixture AddRectangle( this IManager manager, float width, float height, LocalPoint localPosition, float localAngle = 0, float worldAngle = 0, Body.BodyType type = Body.BodyType.Static, bool fixedRotation = false, bool isBullet = false, bool allowSleep = true, float density = 0, float friction = 0.2f, float restitution = 0, bool isSensor = false, uint collisionCategory = 1, uint collisionMask = 0xFFFFFFFF) { var body = manager.AddBody(WorldPoint.Zero, worldAngle, type, fixedRotation, isBullet, allowSleep); return(manager.AttachRectangle( body, width, height, localPosition, localAngle, density, friction, restitution, isSensor, collisionCategory, collisionMask)); }
/// <summary>Creates a circle with the specified parameters.</summary> /// <param name="manager">The manager to create the object in.</param> /// <param name="radius">The radius of the circle.</param> /// <param name="worldAngle">The initial world angle of the body.</param> /// <param name="type">The type of the body.</param> /// <param name="fixedRotation"> /// if set to <c>true</c> the rotation of the body is fixed to its initial value. /// </param> /// <param name="isBullet"> /// if set to <c>true</c> enables continuous collision with other dynamic bodies. /// </param> /// <param name="allowSleep"> /// if set to <c>true</c> allows the object to sleep when it is not moving (for improved performance). /// </param> /// <param name="density">The density of the fixture.</param> /// <param name="friction">The friction of the fixture.</param> /// <param name="restitution">The restitution of the fixture.</param> /// <param name="isSensor"> /// if set to <c>true</c> the created fixture is marked as a sensor (i.e. it will fire collision events but the /// collision will not be handled by the solver). /// </param> /// <param name="collisionCategory">The collision groups for the fixture.</param> /// <param name="collisionMask">The collision groups to collide with.</param> /// <returns>The created body.</returns> public static CircleFixture AddCircle( this IManager manager, float radius, float worldAngle = 0, Body.BodyType type = Body.BodyType.Static, bool fixedRotation = false, bool isBullet = false, bool allowSleep = true, float density = 0, float friction = 0.2f, float restitution = 0, bool isSensor = false, uint collisionCategory = 1, uint collisionMask = 0xFFFFFFFF) { return(manager.AddCircle( LocalPoint.Zero, radius, WorldPoint.Zero, worldAngle, type, fixedRotation, isBullet, allowSleep, density, friction, restitution, isSensor, collisionCategory, collisionMask)); }
public void SetMassFromShapes() { Box2DXDebug.Assert(!this._world._lock); if (!this._world._lock) { this._mass = 0f; this._invMass = 0f; this._I = 0f; this._invI = 0f; Vec2 vec = Vec2.Zero; for (Shape shape = this._shapeList; shape != null; shape = shape._next) { MassData massData; shape.ComputeMass(out massData); this._mass += massData.Mass; vec += massData.Mass * massData.Center; this._I += massData.I; } if (this._mass > 0f) { this._invMass = 1f / this._mass; vec *= this._invMass; } if (this._I > 0f && (this._flags & Body.BodyFlags.FixedRotation) == (Body.BodyFlags) 0) { this._I -= this._mass * Vec2.Dot(vec, vec); Box2DXDebug.Assert(this._I > 0f); this._invI = 1f / this._I; } else { this._I = 0f; this._invI = 0f; } this._sweep.LocalCenter = vec; this._sweep.C0 = (this._sweep.C = Box2DX.Common.Math.Mul(this._xf, this._sweep.LocalCenter)); for (Shape shape = this._shapeList; shape != null; shape = shape._next) { shape.UpdateSweepRadius(this._sweep.LocalCenter); } Body.BodyType type = this._type; if (this._invMass == 0f && this._invI == 0f) { this._type = Body.BodyType.Static; } else { this._type = Body.BodyType.Dynamic; } if (type != this._type) { for (Shape shape = this._shapeList; shape != null; shape = shape._next) { shape.RefilterProxy(this._world._broadPhase, this._xf); } } } }
/// <summary>Creates the a new body with the specified properties.</summary> /// <param name="manager">The manager to create the body in.</param> /// <param name="angle">The initial world angle of the body.</param> /// <param name="type">The type of the body.</param> /// <param name="fixedRotation"> /// if set to <c>true</c> the rotation of the body is fixed to its initial value. /// </param> /// <param name="isBullet"> /// if set to <c>true</c> enables continuous collision with other dynamic bodies. /// </param> /// <param name="allowSleep"> /// if set to <c>true</c> allows the object to sleep when it is not moving (for improved performance). /// </param> /// <returns>The created body.</returns> public static Body AddBody( this IManager manager, float angle = 0, Body.BodyType type = Body.BodyType.Static, bool fixedRotation = false, bool isBullet = false, bool allowSleep = true) { return(manager.AddBody(WorldPoint.Zero, angle, type, fixedRotation, isBullet, allowSleep)); }
/// <summary>Creates the a new body with the specified properties.</summary> /// <param name="manager">The manager to create the body in.</param> /// <param name="worldPosition">The initial world position of the body.</param> /// <param name="worldAngle">The initial world angle of the body.</param> /// <param name="type">The type of the body.</param> /// <param name="fixedRotation"> /// if set to <c>true</c> the rotation of the body is fixed to its initial value. /// </param> /// <param name="isBullet"> /// if set to <c>true</c> enables continuous collision with other dynamic bodies. /// </param> /// <param name="allowSleep"> /// if set to <c>true</c> allows the object to sleep when it is not moving (for improved performance). /// </param> /// <returns>The created body.</returns> public static Body AddBody( this IManager manager, WorldPoint worldPosition, float worldAngle = 0, Body.BodyType type = Body.BodyType.Static, bool fixedRotation = false, bool isBullet = false, bool allowSleep = true) { return(manager.AddBody(manager.AddEntity(), worldPosition, worldAngle, type, fixedRotation, isBullet, allowSleep)); }
/// <summary>Creates the a new body with the specified properties.</summary> /// <param name="manager">The manager to create the body in.</param> /// <param name="entity">The entity to attach the body to.</param> /// <param name="worldPosition">The initial world position of the body.</param> /// <param name="worldAngle">The initial world angle of the body.</param> /// <param name="type">The type of the body.</param> /// <param name="fixedRotation"> /// if set to <c>true</c> the rotation of the body is fixed to its initial value. /// </param> /// <param name="isBullet"> /// if set to <c>true</c> enables continuous collision with other dynamic bodies. /// </param> /// <param name="allowSleep"> /// if set to <c>true</c> allows the object to sleep when it is not moving (for improved performance). /// </param> /// <returns>The created body.</returns> public static Body AddBody( this IManager manager, int entity, WorldPoint worldPosition, float worldAngle = 0, Body.BodyType type = Body.BodyType.Static, bool fixedRotation = false, bool isBullet = false, bool allowSleep = true) { return(manager.AddComponent <Body>(entity) .Initialize(worldPosition, worldAngle, type, fixedRotation, isBullet, allowSleep)); }
} // STEVE Added public void SetMass(MassData massData) { Box2DXDebug.Assert(!this._world._lock); if (!this._world._lock) { this._invMass = 0f; this._I = 0f; this._invI = 0f; this._mass = massData.Mass; if (this._mass > 0f) { this._invMass = 1f / this._mass; } if ((this._flags & Body.BodyFlags.FixedRotation) == (Body.BodyFlags) 0) { this._I = massData.I; } if (this._I > 0f) { this._invI = 1f / this._I; } this._sweep.LocalCenter = massData.Center; this._sweep.C0 = (this._sweep.C = Box2DX.Common.Math.Mul(this._xf, this._sweep.LocalCenter)); for (Shape shape = this._shapeList; shape != null; shape = shape._next) { shape.UpdateSweepRadius(this._sweep.LocalCenter); } Body.BodyType type = this._type; if (this._invMass == 0f && this._invI == 0f) { this._type = Body.BodyType.Static; } else { this._type = Body.BodyType.Dynamic; } if (type != this._type) { for (Shape shape = this._shapeList; shape != null; shape = shape._next) { shape.RefilterProxy(this._world._broadPhase, this._xf); } } } }
/// <summary>Creates a polygon with the specified parameters.</summary> /// <param name="manager">The manager to create the object in.</param> /// <param name="vertices">The vertices relative to the body's local origin.</param> /// <param name="worldPosition">The initial world position of the body.</param> /// <param name="worldAngle">The initial world angle of the body.</param> /// <param name="type">The type of the body.</param> /// <param name="fixedRotation"> /// if set to <c>true</c> the rotation of the body is fixed to its initial value. /// </param> /// <param name="isBullet"> /// if set to <c>true</c> enables continuous collision with other dynamic bodies. /// </param> /// <param name="allowSleep"> /// if set to <c>true</c> allows the object to sleep when it is not moving (for improved performance). /// </param> /// <param name="density">The density of the fixture.</param> /// <param name="friction">The friction of the fixture.</param> /// <param name="restitution">The restitution of the fixture.</param> /// <param name="isSensor"> /// if set to <c>true</c> the created fixture is marked as a sensor (i.e. it will fire collision events but the /// collision will not be handled by the solver). /// </param> /// <param name="collisionCategory">The collision groups for the fixture.</param> /// <param name="collisionMask">The collision groups to collide with.</param> /// <returns>The created body.</returns> public static PolygonFixture AddPolygon( this IManager manager, IList <LocalPoint> vertices, WorldPoint worldPosition, float worldAngle = 0, Body.BodyType type = Body.BodyType.Static, bool fixedRotation = false, bool isBullet = false, bool allowSleep = true, float density = 0, float friction = 0.2f, float restitution = 0, bool isSensor = false, uint collisionCategory = 1, uint collisionMask = 0xFFFFFFFF) { var body = manager.AddBody(worldPosition, worldAngle, type, fixedRotation, isBullet, allowSleep); return(manager.AttachPolygon(body, vertices, density, friction, restitution, isSensor, collisionCategory, collisionMask)); }
public IFluentHttpRequestBuilder WithBody(Body.BodyType type, string value) { var builder = new FluentBodyBuilder(); switch (type) { case Body.BodyType.JSON: builder.WithExactJson(value); break; case Body.BodyType.JSON_PATH: builder.MatchingJsonPath(value); break; case Body.BodyType.JSON_SCHEMA: builder.MatchingJsonSchema(value); break; case Body.BodyType.XML: builder.WithXmlContent(value); break; case Body.BodyType.XPATH: builder.MatchingXPath(value); break; case Body.BodyType.XML_SCHEMA: builder.MatchingXmlSchema(value); break; case Body.BodyType.STRING: builder.WithExactContent(value); break; } _body = builder.Build(); return(this); }
internal bool _useGravity; // STEVE Added internal Body(BodyDef bd, World world) { Box2DXDebug.Assert(!world._lock); this._flags = (Body.BodyFlags) 0; if (bd.IsBullet) { this._flags |= Body.BodyFlags.Bullet; } if (bd.FixedRotation) { this._flags |= Body.BodyFlags.FixedRotation; } if (bd.AllowSleep) { this._flags |= Body.BodyFlags.AllowSleep; } if (bd.IsSleeping) { this._flags |= Body.BodyFlags.Sleep; } this._world = world; this._xf.Position = bd.Position; this._xf.R.Set(bd.Angle); this._sweep.LocalCenter = bd.MassData.Center; this._sweep.T0 = 1f; this._sweep.A0 = (this._sweep.A = bd.Angle); this._sweep.C0 = (this._sweep.C = Box2DX.Common.Math.Mul(this._xf, this._sweep.LocalCenter)); this._jointList = null; this._contactList = null; this._prev = null; this._next = null; this._linearDamping = bd.LinearDamping; this._angularDamping = bd.AngularDamping; this._force.Set(0f, 0f); this._torque = 0f; this._linearVelocity.SetZero(); this._angularVelocity = 0f; this._sleepTime = 0f; this._invMass = 0f; this._I = 0f; this._invI = 0f; this._mass = bd.MassData.Mass; if (this._mass > 0f) { this._invMass = 1f / this._mass; } if ((this._flags & Body.BodyFlags.FixedRotation) == (Body.BodyFlags) 0) { this._I = bd.MassData.I; } if (this._I > 0f) { this._invI = 1f / this._I; } if (this._invMass == 0f && this._invI == 0f) { this._type = Body.BodyType.Static; } else { this._type = Body.BodyType.Dynamic; } this._userData = bd.UserData; this._shapeList = null; this._shapeCount = 0; this._gravity = _world.Gravity; // STEVE Added this._useGravity = false; // STEVE Added }
public void SetMassFromShapes() { Box2DXDebug.Assert(!this._world._lock); if (!this._world._lock) { this._mass = 0f; this._invMass = 0f; this._I = 0f; this._invI = 0f; Vec2 vec = Vec2.Zero; for (Shape shape = this._shapeList; shape != null; shape = shape._next) { MassData massData; shape.ComputeMass(out massData); this._mass += massData.Mass; vec += massData.Mass * massData.Center; this._I += massData.I; } if (this._mass > 0f) { this._invMass = 1f / this._mass; vec *= this._invMass; } if (this._I > 0f && (this._flags & Body.BodyFlags.FixedRotation) == (Body.BodyFlags)0) { this._I -= this._mass * Vec2.Dot(vec, vec); Box2DXDebug.Assert(this._I > 0f); this._invI = 1f / this._I; } else { this._I = 0f; this._invI = 0f; } this._sweep.LocalCenter = vec; this._sweep.C0 = (this._sweep.C = Box2DX.Common.Math.Mul(this._xf, this._sweep.LocalCenter)); for (Shape shape = this._shapeList; shape != null; shape = shape._next) { shape.UpdateSweepRadius(this._sweep.LocalCenter); } Body.BodyType type = this._type; if (this._invMass == 0f && this._invI == 0f) { this._type = Body.BodyType.Static; } else { this._type = Body.BodyType.Dynamic; } if (type != this._type) { for (Shape shape = this._shapeList; shape != null; shape = shape._next) { shape.RefilterProxy(this._world._broadPhase, this._xf); } } } }
public void SetMass(MassData massData) { Box2DXDebug.Assert(!this._world._lock); if (!this._world._lock) { this._invMass = 0f; this._I = 0f; this._invI = 0f; this._mass = massData.Mass; if (this._mass > 0f) { this._invMass = 1f / this._mass; } if ((this._flags & Body.BodyFlags.FixedRotation) == (Body.BodyFlags)0) { this._I = massData.I; } if (this._I > 0f) { this._invI = 1f / this._I; } this._sweep.LocalCenter = massData.Center; this._sweep.C0 = (this._sweep.C = Box2DX.Common.Math.Mul(this._xf, this._sweep.LocalCenter)); for (Shape shape = this._shapeList; shape != null; shape = shape._next) { shape.UpdateSweepRadius(this._sweep.LocalCenter); } Body.BodyType type = this._type; if (this._invMass == 0f && this._invI == 0f) { this._type = Body.BodyType.Static; } else { this._type = Body.BodyType.Dynamic; } if (type != this._type) { for (Shape shape = this._shapeList; shape != null; shape = shape._next) { shape.RefilterProxy(this._world._broadPhase, this._xf); } } } }
internal Body(BodyDef bd, World world) { Box2DXDebug.Assert(!world._lock); this._flags = (Body.BodyFlags)0; if (bd.IsBullet) { this._flags |= Body.BodyFlags.Bullet; } if (bd.FixedRotation) { this._flags |= Body.BodyFlags.FixedRotation; } if (bd.AllowSleep) { this._flags |= Body.BodyFlags.AllowSleep; } if (bd.IsSleeping) { this._flags |= Body.BodyFlags.Sleep; } this._world = world; this._xf.Position = bd.Position; this._xf.R.Set(bd.Angle); this._sweep.LocalCenter = bd.MassData.Center; this._sweep.T0 = 1f; this._sweep.A0 = (this._sweep.A = bd.Angle); this._sweep.C0 = (this._sweep.C = Box2DX.Common.Math.Mul(this._xf, this._sweep.LocalCenter)); this._jointList = null; this._contactList = null; this._prev = null; this._next = null; this._linearDamping = bd.LinearDamping; this._angularDamping = bd.AngularDamping; this._force.Set(0f, 0f); this._torque = 0f; this._linearVelocity.SetZero(); this._angularVelocity = 0f; this._sleepTime = 0f; this._invMass = 0f; this._I = 0f; this._invI = 0f; this._mass = bd.MassData.Mass; if (this._mass > 0f) { this._invMass = 1f / this._mass; } if ((this._flags & Body.BodyFlags.FixedRotation) == (Body.BodyFlags)0) { this._I = bd.MassData.I; } if (this._I > 0f) { this._invI = 1f / this._I; } if (this._invMass == 0f && this._invI == 0f) { this._type = Body.BodyType.Static; } else { this._type = Body.BodyType.Dynamic; } this._userData = bd.UserData; this._shapeList = null; this._shapeCount = 0; this._gravity = _world.Gravity; // STEVE Added this._useGravity = false; // STEVE Added }