Adding checks for if objects get deleted too fast

Fixing post-build event to create combined directory
This commit is contained in:
nathan@daedalus
2012-03-19 20:33:25 -05:00
parent 5bdc5db408
commit 4755ff6b87
6 changed files with 74 additions and 18 deletions

View File

@@ -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;
}
}
}
}