public bool collidesWith(GameObject2D other) { if (BBox.Intersects(other.BBox)) { // inverse of transform matrix of other object (faster than actually calculate the inverse) Matrix inverseTransform = Matrix.CreateTranslation(new Vector3(-other.Position.X * referenceWidth, -other.Position.Y * referenceHeight, 0.0f)) * Matrix.CreateRotationZ(-other.Rotation) * Matrix.CreateScale(1 / other.ScaleX, 1 / other.ScaleY, 1.0f) * Matrix.CreateTranslation(new Vector3(other.Origin, 0.0f)); if (IntersectPixels(ref transform, Texture.Width, Texture.Height, ref textureData, ref inverseTransform, other.Texture.Width, other.Texture.Height, ref other.textureData)) { return(true); } } return(false); }
public bool collidesWith(GameObject2D other) { if (BBox.Intersects(other.BBox)) { // inverse of transform matrix of other object (faster than actually calculate the inverse) Matrix inverseTransform = Matrix.CreateTranslation(new Vector3(-other.Position.X * referenceWidth, -other.Position.Y * referenceHeight, 0.0f)) * Matrix.CreateRotationZ(-other.Rotation) * Matrix.CreateScale(1 / other.ScaleX, 1 / other.ScaleY, 1.0f) * Matrix.CreateTranslation(new Vector3(other.Origin, 0.0f)); if (IntersectPixels(ref transform, Texture.Width, Texture.Height, ref textureData, ref inverseTransform, other.Texture.Width, other.Texture.Height, ref other.textureData)) return true; } return false; }