【发布时间】:2014-01-13 08:38:52
【问题描述】:
请看下面我的代码。
我有一个尚未添加到 WPF 面板中的对象 - 在本例中是一个简单的 Canvas。当我调试“var A1 = Poly.RenderedGeometry”行时,我看到的唯一内容是{}。根本没有数据 - 没有 pathGeometry,什么都没有。
你能解释一下我的代码有什么问题吗?如何知道我要添加到画布的多边形是否不会与其他多边形发生碰撞?
// First and Second are 2 points, CreateNewTriangle adds a random point
// and creates a new triangle polygon
var Poly = CreateNewTriangle(First, Second);
if (G1.Children.Count == 0)
{
G1.Children.Add(Poly);
}
else
{
// In debug this row is empty - no actual geometry is present
var A1 = Poly.RenderedGeometry;
foreach (Polygon item in G1.Children)
{
if (!item.Equals(Poly))
{
var a2 = item.RenderedGeometry;
var col = A1.FillContainsWithDetail(a2);
if (!(col == IntersectionDetail.Empty))
{
IsAllGood = false;
break;
}
}
}
}
【问题讨论】:
标签: wpf collision-detection collision