本文整理汇总了C#中BoundingBoxD.IntersectsTriangle方法的典型用法代码示例。如果您正苦于以下问题:C# BoundingBoxD.IntersectsTriangle方法的具体用法?C# BoundingBoxD.IntersectsTriangle怎么用?C# BoundingBoxD.IntersectsTriangle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoundingBoxD
的用法示例。
在下文中一共展示了BoundingBoxD.IntersectsTriangle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestVoxelNavmeshTriangle
public void TestVoxelNavmeshTriangle(ref Vector3D a, ref Vector3D b, ref Vector3D c, List<MyCubeGrid> gridsToTest, List<MyGridPathfinding.CubeId> linkCandidatesOutput, out bool intersecting)
{
ProfilerShort.Begin("TestVoxelNavmeshTriangle");
ProfilerShort.Begin("Triangle-obstacle tests");
Vector3D s = (a + b + c) / 3.0;
if (m_obstacles.IsInObstacle(s))
{
intersecting = true;
ProfilerShort.End();
ProfilerShort.End();
return;
}
ProfilerShort.End();
BoundingBoxD triBB;
Vector3D aLocal, bLocal, cLocal, gLocal;
Vector3D g = Vector3D.Zero;
if (MyPerGameSettings.NavmeshPresumesDownwardGravity)
{
g = Vector3.Down * 2.0f;
}
m_tmpLinkCandidates.Clear();
intersecting = false;
foreach (var grid in gridsToTest)
{
MatrixD mat = grid.PositionComp.WorldMatrixNormalizedInv;
Vector3D.Transform(ref a, ref mat, out aLocal);
Vector3D.Transform(ref b, ref mat, out bLocal);
Vector3D.Transform(ref c, ref mat, out cLocal);
Vector3D.TransformNormal(ref g, ref mat, out gLocal);
triBB = new BoundingBoxD(Vector3D.MaxValue, Vector3D.MinValue);
triBB.Include(ref aLocal, ref bLocal, ref cLocal);
Vector3I min = grid.LocalToGridInteger(triBB.Min);
Vector3I max = grid.LocalToGridInteger(triBB.Max);
Vector3I pos = min - Vector3I.One;
Vector3I max2 = max + Vector3I.One;
for (var it = new Vector3I_RangeIterator(ref pos, ref max2); it.IsValid(); it.GetNext(out pos))
{
if (grid.GetCubeBlock(pos) != null)
{
Vector3 largeMin = (pos - Vector3.One) * grid.GridSize;
Vector3 largeMax = (pos + Vector3.One) * grid.GridSize;
Vector3 smallMin = (pos - Vector3.Half) * grid.GridSize;
Vector3 smallMax = (pos + Vector3.Half) * grid.GridSize;
BoundingBoxD largeBb = new BoundingBoxD(largeMin, largeMax);
BoundingBoxD bb = new BoundingBoxD(smallMin, smallMax);
largeBb.Include(largeMin + gLocal);
largeBb.Include(largeMax + gLocal);
bb.Include(smallMin + gLocal);
bb.Include(smallMax + gLocal);
ProfilerShort.Begin("Triangle intersection tests");
if (largeBb.IntersectsTriangle(ref aLocal, ref bLocal, ref cLocal))
{
if (bb.IntersectsTriangle(ref aLocal, ref bLocal, ref cLocal))
{
intersecting = true;
ProfilerShort.End();
break;
}
else
{
int dx = Math.Min(Math.Abs(min.X - pos.X), Math.Abs(max.X - pos.X));
int dy = Math.Min(Math.Abs(min.Y - pos.Y), Math.Abs(max.Y - pos.Y));
int dz = Math.Min(Math.Abs(min.Z - pos.Z), Math.Abs(max.Z - pos.Z));
if ((dx + dy + dz) < 3)
m_tmpLinkCandidates.Add(new MyGridPathfinding.CubeId() { Grid = grid, Coords = pos });
}
}
ProfilerShort.End();
}
}
if (intersecting) break;
}
if (!intersecting)
{
for (int i = 0; i < m_tmpLinkCandidates.Count; ++i)
{
linkCandidatesOutput.Add(m_tmpLinkCandidates[i]);
}
}
m_tmpLinkCandidates.Clear();
ProfilerShort.End();
}