Exemplo n.º 1
0
        bool GetPositionByCursor(Viewport viewport, out Vector3 pos)
        {
            var context = new Component_Scene_DocumentWindow.GetMouseOverObjectToSelectByClickContext();

            context.CheckOnlyObjectsWithEnabledSelectionByCursorFlag = false;

            DocumentWindow.GetMouseOverObjectToSelectByClick(context);
            var resultObjectComponent = context.ResultObject as Component;

            if (resultObjectComponent != null)
            {
                //!!!!так? может в GetMouseOverObjectForSelection указывать фильтр делегатом

                //!!!!проверять что Walkable Area?

                var geometry = resultObjectComponent.GetComponent <Component_Pathfinding_GeometryTag>(false, true);
                if (geometry != null)
                {
                    pos = context.ResultPosition.HasValue ? context.ResultPosition.Value : Vector3.Zero;
                    return(true);
                }
            }

            //RayCastResult[] results = PhysicsWorld.Instance.RayCastPiercing( ray, (int)ContactGroup.CastOnlyCollision );
            //foreach( RayCastResult result in results )
            //{
            //	Radian angle = MathUtils.GetVectorsAngle( result.Normal, ray.Direction );
            //	if( angle > Math.PI / 2 )
            //	{
            //		pos = result.Position;
            //		return true;
            //	}
            //}
            //}

            pos = Vector3.Zero;
            return(false);
        }