Adding checks for if objects get deleted too fast
Fixing post-build event to create combined directory
This commit is contained in:
@@ -7,7 +7,10 @@ using Microsoft.Xna.Framework.Graphics;
|
||||
using FarseerPhysics.Dynamics;
|
||||
using FarseerPhysics.SamplesFramework;
|
||||
using Axios.Engine.Interfaces;
|
||||
|
||||
using FarseerPhysics.Common.Decomposition;
|
||||
using FarseerPhysics.Common;
|
||||
using FarseerPhysics.Factories;
|
||||
using FarseerPhysics.Common.PolygonManipulation;
|
||||
|
||||
namespace Axios.Engine
|
||||
{
|
||||
@@ -88,5 +91,36 @@ namespace Axios.Engine
|
||||
this._draworder = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateBodyFromTexture(AxiosGameScreen gameScreen)
|
||||
{
|
||||
if (this.Texture != null)
|
||||
{
|
||||
uint[] data = new uint[this.Texture.Width * this.Texture.Height];
|
||||
this.Texture.GetData<uint>(data);
|
||||
Vertices vertices = PolygonTools.CreatePolygon(data, this.Texture.Width, false);
|
||||
Vector2 vector = -vertices.GetCentroid();
|
||||
vertices.Translate(ref vector);
|
||||
base.Origin = -vector;
|
||||
List<Vertices> list = BayazitDecomposer.ConvexPartition(SimplifyTools.ReduceByDistance(vertices, 4f));
|
||||
base._scale = 1f;
|
||||
Vector2 vector2 = (Vector2)(new Vector2(ConvertUnits.ToSimUnits(1)) * base._scale);
|
||||
foreach (Vertices vertices2 in list)
|
||||
{
|
||||
vertices2.Scale(ref vector2);
|
||||
}
|
||||
base.BodyPart = BodyFactory.CreateCompoundPolygon(gameScreen.World, list, 1f, BodyType.Dynamic);
|
||||
base.BodyPart.BodyType = BodyType.Dynamic;
|
||||
base.BodyPart.Position = base.Position;
|
||||
base.BodyPart.UserData = this;
|
||||
base.BodyPart.CollidesWith = Category.All;
|
||||
base.BodyPart.CollisionCategories = Category.All;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user