Example #1
0
 public static bool TryFindTerrainOverlayNode(this TerrainOverlayNetwork terrainOverlayNetwork, DoubleVector3 p, out TerrainOverlayNetworkNode result)
 {
     return(TryFindTerrainOverlayNode(terrainOverlayNetwork, p, out result, out _));
 }
Example #2
0
        public static bool TryFindTerrainOverlayNode(this TerrainOverlayNetwork terrainOverlayNetwork, Vector3 p, out TerrainOverlayNetworkNode result, out Vector3 pLocal)
        {
            foreach (var bvhNode in terrainOverlayNetwork.NodeBvh.FindIntersectingLeaves(p.ToOpenMobaVector()))
            {
                for (var i = bvhNode.StartIndexInclusive; i < bvhNode.EndIndexExclusive; i++)
                {
                    var node = bvhNode.Values[i];

                    pLocal = Vector3.Transform(p, node.SectorNodeDescription.WorldTransformInv);
                    var pLocalXy = new IntVector2((int)pLocal.X, (int)pLocal.Y); // todo: correctness issues

                    if (!node.LandPolyNode.PointInLandPolygonNonrecursive(pLocalXy))
                    {
                        continue;
                    }
                    if (Math.Abs(pLocal.Z) > 1E-3f)
                    {
                        continue;
                    }

                    result = node;
                    return(true);
                }
            }
            result = null;
            pLocal = default(Vector3);
            return(false);
        }
Example #3
0
 public static bool Contains(this TerrainOverlayNetworkNode node, DoubleVector3 world, out DoubleVector3 local)
 {
     local = node.SectorNodeDescription.WorldToLocal(world);
     return(Math.Abs(local.Z) <= 1E-3f &&
            node.LandPolyNode.PointInLandPolygonNonrecursive(local.XY.LossyToIntVector2()));
 }
Example #4
0
        public static bool TryFindTerrainOverlayNode(this TerrainOverlayNetwork terrainOverlayNetwork, DoubleVector3 p, out TerrainOverlayNetworkNode result, out DoubleVector3 pLocal)
        {
            var res = TryFindTerrainOverlayNode(terrainOverlayNetwork, p.ToDotNetVector(), out result, out var pLocalV3);

            pLocal = pLocalV3.ToOpenMobaVector();
            return(res);
        }