• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IntersectionFlags类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IntersectionFlags的典型用法代码示例。如果您正苦于以下问题:C# IntersectionFlags类的具体用法?C# IntersectionFlags怎么用?C# IntersectionFlags使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IntersectionFlags类属于命名空间,在下文中一共展示了IntersectionFlags类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Start

 public void Start(MyModel model, MyLine line, IntersectionFlags flags = IntersectionFlags.DIRECT_TRIANGLES)
 {
     result = null;
     m_model = model;
     m_line = line;
     m_flags = flags;
 }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:7,代码来源:MyQuantizedBvhResult.cs


示例2: GetIntersectionWithLine

        //  Calculates intersection of line with any triangleVertexes in this model instance. Closest intersection and intersected triangleVertexes will be returned.
        internal override bool GetIntersectionWithLine(ref LineD line, out MyIntersectionResultLineTriangleEx? t, IntersectionFlags flags = IntersectionFlags.ALL_TRIANGLES)
        {
            t = null;
            return false;

            //Matrix invWorld = Matrix.Invert(WorldMatrix);
            //Vector3 from = Vector3.Transform(line.From, invWorld);
            //Vector3 to = Vector3.Transform(line.To, invWorld);

            //Line lineLocal = new Line(from, to);

            //bool res = base.GetIntersectionWithLine(ref line, out t, flags);

            //if (res)
            //{
            //    var definition = MyDefinitionManager.Static.GetCubeBlockDefinition(new MyDefinitionId(MyObjectBuilderTypeEnum.Ladder));
            //    if (definition.ExcludedAreaForCamera != null)
            //    {
            //        foreach (var b in definition.ExcludedAreaForCamera)
            //        {
            //            if (b.Contains(t.Value.IntersectionPointInObjectSpace) == ContainmentType.Contains)
            //            {
            //                t = null;
            //                return false;
            //            }
            //        }
            //    }
            //}

            //return res;
        }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:32,代码来源:MyLadder.cs


示例3: GetIntersectionWithLine

        public MyIntersectionResultLineTriangleEx? GetIntersectionWithLine(MyEntity physObject, ref MyLine line, ref Matrix customInvMatrix, IntersectionFlags flags)
        {
            MyLine lineInModelSpace = new MyLine(MyUtils.GetTransform(line.From, ref customInvMatrix), MyUtils.GetTransform(line.To, ref customInvMatrix), true);

            MyIntersectionResultLineTriangleEx? ret = m_rootNode.GetIntersectionWithLine(physObject, m_model, ref lineInModelSpace, null, flags);

            return ret;
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:8,代码来源:MyModelOctree.cs


示例4: GetIntersectionWithLine

        public Sandbox.Common.MyIntersectionResultLineTriangleEx? GetIntersectionWithLine(IMyEntity physObject, ref LineD line, ref MatrixD customInvMatrix, IntersectionFlags flags)
        {
            LineD lineInModelSpace = new LineD(Vector3D.Transform(line.From, ref customInvMatrix), Vector3D.Transform(line.To, ref customInvMatrix));

            MyIntersectionResultLineTriangleEx? ret = m_rootNode.GetIntersectionWithLine(physObject, m_model, ref lineInModelSpace, null, flags);

            return ret;
        }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:8,代码来源:MyModelOctree.cs


示例5: GetIntersectionWithLine

        //  Difference between GetIntersectionWithLine and GetIntersectionWithLineRecursive is that the later doesn't calculate
        //  final result, but is better suited for recursive nature of octree. Don't call GetIntersectionWithLineRecursive() from
        //  the outisde of this class, it's private method.
        public MyIntersectionResultLineTriangleEx? GetIntersectionWithLine(MyEntity physObject, MyModel model, ref MyLine line, float? minDistanceUntilNow, IntersectionFlags flags)
        {
            MyIntersectionResultLineTriangle? foundTriangle = GetIntersectionWithLineRecursive(model, ref line, minDistanceUntilNow);

            if (foundTriangle != null)
            {
                return new MyIntersectionResultLineTriangleEx(foundTriangle.Value, physObject, ref line);
            }
            else
            {
                return null;
            }
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:16,代码来源:MyModelOctreeNode.cs


示例6: GetIntersectionWithLine

        public MyIntersectionResultLineTriangleEx? GetIntersectionWithLine(MyEntity physObject, ref MyLine line, ref Matrix customInvMatrix, IntersectionFlags flags)
        {
            MyLine lineInModelSpace = new MyLine(MyUtils.GetTransform(line.From, ref customInvMatrix), MyUtils.GetTransform(line.To, ref customInvMatrix), true);

            //MyIntersectionResultLineTriangle? result = null;

            m_result.Start(m_model, lineInModelSpace, flags);

            var dir = new IndexedVector3(lineInModelSpace.Direction);
            var from = new IndexedVector3(lineInModelSpace.From);

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("m_bvh.RayQueryClosest()");
            m_bvh.RayQueryClosest(ref dir, ref from, m_result.ProcessTriangleHandler);
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();

            if (m_result.Result.HasValue)
            {
                return new MyIntersectionResultLineTriangleEx(m_result.Result.Value, physObject, ref lineInModelSpace);
            }
            else
            {
                return null;
            }
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:24,代码来源:MyQuantizedBvhAdapter.cs


示例7: GetIntersectionWithLine

        public override bool GetIntersectionWithLine(ref MyLine line, out Vector3? v, bool useCollisionModel = true, IntersectionFlags flags = IntersectionFlags.ALL_TRIANGLES)
        {
            v = null;
            Ray ray = new Ray(line.From, line.Direction);
            float? ds = null;
            BoundingBox boundingBox = new BoundingBox(WorldMatrix.Translation - Size / 2f, WorldMatrix.Translation + Size / 2f);
            ds = ray.Intersects(boundingBox);            

            if (ds == null)
                return false;

            v = line.From + line.Direction * ds;
            return true;
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:14,代码来源:MyPrefabScanner.cs


示例8: GetIntersectionWithLine

        //  Calculates intersection of line with any triangleVertexes in this model instance. Closest intersection and intersected triangleVertexes will be returned.
        public virtual bool GetIntersectionWithLine(ref LineD line, out VRage.Game.Models.MyIntersectionResultLineTriangleEx? t, IntersectionFlags flags = IntersectionFlags.ALL_TRIANGLES)
        {
            bool ret = false;

            t = null;
            MyModel collisionModel = Model;

            if (collisionModel != null)
            {
                VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyEntity.GetIntersectionWithLine on model");
                VRage.Game.Models.MyIntersectionResultLineTriangleEx? result = collisionModel.GetTrianglePruningStructure().GetIntersectionWithLine(this, ref line, flags);
                VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
                if (result != null)
                {
                    t = result.Value;
                    ret = true;
                }
            }

            return ret;

        }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:23,代码来源:MyEntity.cs


示例9: GetIntersectionWithLine

 public override bool GetIntersectionWithLine(ref LineD worldLine, out Vector3D? v, bool useCollisionModel = true, IntersectionFlags flags = IntersectionFlags.ALL_TRIANGLES)
 {
     MyIntersectionResultLineTriangleEx? result;
     GetIntersectionWithLine(ref worldLine, out result);
     v = null;
     if (result != null)
     {
         v = result.Value.IntersectionPointInWorldSpace;
         return true;
     }
     return false;
 }
开发者ID:austusross,项目名称:SpaceEngineers,代码行数:12,代码来源:MyVoxelBase.cs


示例10: GetIntersectionWithLine

        /// <summary>
        /// Returns closest hit from line start position.
        /// </summary>
        public bool GetIntersectionWithLine(ref LineD line, ref MyCharacterHitInfo info, IntersectionFlags flags = IntersectionFlags.ALL_TRIANGLES)
        {
            // TODO: This now uses caspule of physics rigid body on the character, it needs to be changed to ragdoll
            //       Currently this approach will be used to support Characters with different skeleton than humanoid
            if (info == null)
                info = new MyCharacterHitInfo();

            info.Reset();

            bool capsulesReady = UpdateCapsuleBones();
            if (!capsulesReady)
                return false;

            double closestDistanceToHit = double.MaxValue;

            Vector3D hitPosition = Vector3D.Zero;
            Vector3D hitPosition2 = Vector3D.Zero;
            Vector3 hitNormal = Vector3.Zero;
            Vector3 hitNormal2 = Vector3.Zero;

            int capsuleIndex = -1;
            for (int i = 0; i < m_bodyCapsules.Length; i++)
            {
                CapsuleD capsule = m_bodyCapsules[i];
                if (capsule.Intersect(line, ref hitPosition, ref hitPosition2, ref hitNormal, ref hitNormal2))
                {
                    double distanceToHit = Vector3.Distance(hitPosition, line.From);
                    if (distanceToHit >= closestDistanceToHit)
                        continue;

                    closestDistanceToHit = distanceToHit;
                    capsuleIndex = i;
                }
            }

            if (capsuleIndex != -1)
            {
                Matrix worldMatrix = PositionComp.WorldMatrix;
                int boneIndex = FindBestBone(capsuleIndex, ref hitPosition, ref worldMatrix);

                // Transform line to model static position and compute accurate collision there
                // 1. Transform line in local coordinates (used later)
                Matrix worldMatrixInv = PositionComp.WorldMatrixNormalizedInv;
                Vector3 fromTrans = Vector3.Transform(line.From, ref worldMatrixInv);
                Vector3 toTrans = Vector3.Transform(line.To, ref worldMatrixInv);
                LineD lineLocal = new LineD(fromTrans, toTrans);

                // 2. Transform line to to bone pose in binding position
                var bone = AnimationController.CharacterBones[boneIndex];
                bone.ComputeAbsoluteTransform();
                Matrix boneAbsTrans = bone.AbsoluteTransform;
                Matrix skinTransform = bone.SkinTransform;
                Matrix boneTrans = skinTransform * boneAbsTrans;
                Matrix invBoneTrans = Matrix.Invert(boneTrans);
                fromTrans = Vector3.Transform(fromTrans, ref invBoneTrans);
                toTrans = Vector3.Transform(toTrans, ref invBoneTrans);

                // 3. Move back line to world coordinates
                LineD lineTransWorld = new LineD(Vector3.Transform(fromTrans, ref worldMatrix), Vector3.Transform(toTrans, ref worldMatrix));
                MyIntersectionResultLineTriangleEx? triangle_;
                bool success = base.GetIntersectionWithLine(ref lineTransWorld, out triangle_, flags);
                if (success)
                {
                    MyIntersectionResultLineTriangleEx triangle = triangle_.Value;

                    info.CapsuleIndex = capsuleIndex;
                    info.BoneIndex = boneIndex;
                    info.Capsule = m_bodyCapsules[info.CapsuleIndex];
                    info.HitHead = info.CapsuleIndex == 0 && m_bodyCapsules.Length > 1;
                    info.HitPositionBindingPose = triangle.IntersectionPointInObjectSpace;
                    info.HitNormalBindingPose = triangle.NormalInObjectSpace;

                    // 4. Move intersection from binding to dynamic pose
                    MyTriangle_Vertexes vertices = new MyTriangle_Vertexes();
                    vertices.Vertex0 = Vector3.Transform(triangle.Triangle.InputTriangle.Vertex0, ref boneTrans);
                    vertices.Vertex1 = Vector3.Transform(triangle.Triangle.InputTriangle.Vertex1, ref boneTrans);
                    vertices.Vertex2 = Vector3.Transform(triangle.Triangle.InputTriangle.Vertex2, ref boneTrans);
                    Vector3 triangleNormal = Vector3.TransformNormal(triangle.Triangle.InputTriangleNormal, boneTrans);
                    MyIntersectionResultLineTriangle triraw = new MyIntersectionResultLineTriangle(ref vertices, ref triangleNormal, triangle.Triangle.Distance);

                    Vector3 intersectionLocal = Vector3.Transform(triangle.IntersectionPointInObjectSpace, ref boneTrans);
                    Vector3 normalLocal = Vector3.TransformNormal(triangle.NormalInObjectSpace, boneTrans);

                    // 5. Store results
                    triangle = new MyIntersectionResultLineTriangleEx();
                    triangle.Triangle = triraw;
                    triangle.IntersectionPointInObjectSpace = intersectionLocal;
                    triangle.NormalInObjectSpace = normalLocal;
                    triangle.IntersectionPointInWorldSpace = Vector3.Transform(intersectionLocal, ref worldMatrix);
                    triangle.NormalInWorldSpace = Vector3.TransformNormal(normalLocal, worldMatrix);
                    triangle.InputLineInObjectSpace = lineLocal;

                    info.Triangle = triangle;

                    if (MyDebugDrawSettings.ENABLE_DEBUG_DRAW)
                    {
                        MyRenderProxy.DebugClearPersistentMessages();
//.........这里部分代码省略.........
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:101,代码来源:MyCharacter.cs


示例11: GetIntersectionWithLine_FullyBuiltProgressModels

        /// <summary>
        /// Calculates intersected block with all models replaced by final models. Useful for construction/deconstruction when models are made from wooden construction.
        /// </summary>
        public bool GetIntersectionWithLine_FullyBuiltProgressModels(ref LineD line, out VRage.Game.Models.MyIntersectionResultLineTriangleEx? t, out ushort blockId, IntersectionFlags flags = IntersectionFlags.ALL_TRIANGLES, bool checkZFight = false, bool ignoreGenerated = false)
        {
            t = null;
            blockId = 0;

            double distanceSquaredInCompound = double.MaxValue;

            bool foundIntersection = false;

            foreach (var blockPair in m_mapIdToBlock)
            {
                MySlimBlock cmpSlimBlock = blockPair.Value;

                if (ignoreGenerated && cmpSlimBlock.BlockDefinition.IsGeneratedBlock)
                    continue;

                MyModel collisionModel = MyModels.GetModelOnlyData(cmpSlimBlock.BlockDefinition.Model);
                if (collisionModel != null)
                {
                    VRage.Game.Models.MyIntersectionResultLineTriangleEx? intersectionTriResult = collisionModel.GetTrianglePruningStructure().GetIntersectionWithLine(
                        cmpSlimBlock.FatBlock, ref line, flags);

                    if (intersectionTriResult != null)
                    {
                        Vector3D startToIntersection = intersectionTriResult.Value.IntersectionPointInWorldSpace - line.From;
                        double instrDistanceSq = startToIntersection.LengthSquared();
                        if (instrDistanceSq < distanceSquaredInCompound)
                        {
                            if (checkZFight && distanceSquaredInCompound < instrDistanceSq + 0.001f)
                                continue;

                            distanceSquaredInCompound = instrDistanceSq;
                            t = intersectionTriResult;
                            blockId = blockPair.Key;
                            foundIntersection = true;
                        }
                    }
                }
            }

            return foundIntersection;
        }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:45,代码来源:MyCompoundCubeBlock.cs


示例12: GetIntersectionWithLine

        public override bool GetIntersectionWithLine(ref MyLine line, out Vector3? v, bool useCollisionModel = true, IntersectionFlags flags = IntersectionFlags.ALL_TRIANGLES)
        {
            BoundingSphere boundingSphere = new BoundingSphere(GetPosition(), BoundingSphereRadius);
            Ray ray = new Ray(line.From, line.Direction);

            float? result = ray.Intersects(boundingSphere);
            v = result.HasValue ? ray.Position + ray.Direction * result.Value : (Vector3?)null;

            return result.HasValue;
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:10,代码来源:MySpawnPoint.cs


示例13: GetIntersectionWithLine

 public override bool GetIntersectionWithLine(ref MyLine line, out Vector3? v, bool useCollisionModel = true, IntersectionFlags flags = IntersectionFlags.ALL_TRIANGLES)
 {
     return m_gun.GetIntersectionWithLine(ref line, out v, useCollisionModel);
 }
开发者ID:ripark,项目名称:Miner-Wars-2081,代码行数:4,代码来源:MyPrefabLargeWeapon.cs


示例14: Explode

                      /*
        protected override void Explode()
        {
            MyExplosion newExplosion = MyExplosions.AddExplosion();
            if (newExplosion != null)
            {
                BoundingSphere explosionSphere = WorldVolumeHr;
                explosionSphere.Radius *= m_config.ExplosionRadiusMultiplier;
                MyVoxelMap voxelMap = MyVoxelMaps.GetOverlappingWithSphere(ref explosionSphere);
                MyExplosionDebrisModel.CreateExplosionDebris(ref explosionSphere, MyGroupMask.Empty, this, voxelMap);
                newExplosion.Start(0, MyPrefabConstants.VOLUME_DAMAGE_MULTIPLIER * m_config.ExplosionDamageMultiplier * WorldVolumeHr.Radius, 0, m_config.ExplosionType, explosionSphere, MyExplosionsConstants.EXPLOSION_LIFESPAN);
            }
        }               */

        public override bool GetIntersectionWithLine(ref MyLine line, out MyIntersectionResultLineTriangleEx? t, IntersectionFlags flags = IntersectionFlags.ALL_TRIANGLES)
        {
            return m_gun.GetIntersectionWithLine(ref line, out t);
        }
开发者ID:ripark,项目名称:Miner-Wars-2081,代码行数:18,代码来源:MyPrefabLargeWeapon.cs


示例15: GetIntersectionWithLine

        public bool GetIntersectionWithLine(ref LineD line, out MyIntersectionResultLineTriangleEx? t, out ushort blockId, IntersectionFlags flags = IntersectionFlags.ALL_TRIANGLES, bool checkZFight = false, bool ignoreGenerated = false)
        {
            t = null;
            blockId = 0;

            double distanceSquaredInCompound = double.MaxValue;

            bool foundIntersection = false;

            foreach (var blockPair in m_blocks)
            {
                MySlimBlock cmpSlimBlock = blockPair.Value;

				if (ignoreGenerated && cmpSlimBlock.BlockDefinition.IsGeneratedBlock)
					continue;

                MyIntersectionResultLineTriangleEx? intersectionTriResult;
                if (cmpSlimBlock.FatBlock.GetIntersectionWithLine(ref line, out intersectionTriResult) && intersectionTriResult != null)
                {
                    Vector3D startToIntersection = intersectionTriResult.Value.IntersectionPointInWorldSpace - line.From;
                    double instrDistanceSq = startToIntersection.LengthSquared();
                    if (instrDistanceSq < distanceSquaredInCompound)
                    {
						if (checkZFight && distanceSquaredInCompound < instrDistanceSq + 0.001f)
							continue;

                        distanceSquaredInCompound = instrDistanceSq;
                        t = intersectionTriResult;
                        blockId = blockPair.Key;
                        foundIntersection = true;
                    }
                }
            }

            return foundIntersection;
        }
开发者ID:martejj,项目名称:SpaceEngineers,代码行数:36,代码来源:MyCompoundCubeBlock.cs


示例16: GetTrianglesIntersectingLine

 public void GetTrianglesIntersectingLine(IMyEntity entity, ref LineD line, IntersectionFlags flags, List<Sandbox.Common.MyIntersectionResultLineTriangleEx> result)
 {
     MatrixD worldInv = entity.GetWorldMatrixNormalizedInv();
     GetTrianglesIntersectingLine(entity, ref line, ref worldInv, flags, result);
 }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:5,代码来源:MyModelOctree.cs


示例17: GetCellLineIntersectionOctree

        private void GetCellLineIntersectionOctree(ref VRage.Game.Models.MyIntersectionResultLineTriangle? result, ref Line modelSpaceLine, ref float? minDistanceUntilNow, CellData cachedDataCell, IntersectionFlags flags)
        {
            m_overlapElementCache.Clear();
            if (cachedDataCell.Octree != null)
            {
                Vector3 packedStart, packedEnd;
                cachedDataCell.GetPackedPosition(ref modelSpaceLine.From, out packedStart);
                cachedDataCell.GetPackedPosition(ref modelSpaceLine.To, out packedEnd);
                var ray = new Ray(packedStart, packedEnd - packedStart);
                cachedDataCell.Octree.GetIntersectionWithLine(ref ray, m_overlapElementCache);
            }

            for (int j = 0; j < m_overlapElementCache.Count; j++)
            {
                var i = m_overlapElementCache[j];

                if (cachedDataCell.VoxelTriangles == null) //probably not calculated yet
                    continue;

                // this should never happen
                if (i >= cachedDataCell.VoxelTriangles.Length)
                {
                    Debug.Assert(i < cachedDataCell.VoxelTriangles.Length);
                    continue;
                }

                MyVoxelTriangle voxelTriangle = cachedDataCell.VoxelTriangles[i];

                MyTriangle_Vertexes triangleVertices;
                cachedDataCell.GetUnpackedPosition(voxelTriangle.VertexIndex0, out triangleVertices.Vertex0);
                cachedDataCell.GetUnpackedPosition(voxelTriangle.VertexIndex1, out triangleVertices.Vertex1);
                cachedDataCell.GetUnpackedPosition(voxelTriangle.VertexIndex2, out triangleVertices.Vertex2);

                Vector3 calculatedTriangleNormal = MyUtils.GetNormalVectorFromTriangle(ref triangleVertices);
                if (!calculatedTriangleNormal.IsValid())
                    continue;
                //We dont want backside intersections
                if (((int)(flags & IntersectionFlags.FLIPPED_TRIANGLES) == 0) &&
                    Vector3.Dot(modelSpaceLine.Direction, calculatedTriangleNormal) > 0)
                    continue;

                // AABB intersection test removed, AABB is tested inside BVH
                float? distance = MyUtils.GetLineTriangleIntersection(ref modelSpaceLine, ref triangleVertices);

                //  If intersection occured and if distance to intersection is closer to origin than any previous intersection
                if ((distance != null) && ((result == null) || (distance.Value < result.Value.Distance)))
                {
                    minDistanceUntilNow = distance.Value;
                    result = new VRage.Game.Models.MyIntersectionResultLineTriangle(ref triangleVertices, ref calculatedTriangleNormal, distance.Value);
                }
            }
        }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:52,代码来源:MyVoxelGeometry.cs


示例18: GetIntersectionWithLine

        /// <summary>
        /// Gets the intersection with line.
        /// </summary>
        /// <param name="line">The line.</param>
        /// <returns></returns>
        public override bool GetIntersectionWithLine(ref MyLine line, out MyIntersectionResultLineTriangleEx? t, IntersectionFlags flags = IntersectionFlags.ALL_TRIANGLES)
        {
            t = null;
            //  First check bounding sphere of whole physic object. We must trust that all his childs are inside of default model bounding sphere.
            Matrix worldMatrix = this.WorldMatrix;
            BoundingSphere boundingSphere = new BoundingSphere(MyUtils.GetTransform(ModelLod0.BoundingSphere.Center, ref worldMatrix), ModelLod0.BoundingSphere.Radius);
            if (MyUtils.IsLineIntersectingBoundingSphere(ref line, ref boundingSphere) == false)
                return false;

            //  Test against default object model
            MyIntersectionResultLineTriangleEx? intersectionWithBase;
            base.GetIntersectionWithLine(ref line, out intersectionWithBase);

            //  Test against childs of this phys object (in this case guns)
            MyIntersectionResultLineTriangleEx? intersectionWithWeapons = Weapons != null ? Weapons.GetIntersectionWithLine(ref line) : null;

            //  Find closer intersection of these two
            MyIntersectionResultLineTriangleEx? result = MyIntersectionResultLineTriangleEx.GetCloserIntersection(ref intersectionWithBase, ref intersectionWithWeapons);

            //  Only if this is "player's ship" - thus someone is siting in inside (this is an optimization - enemy ships don't render glass decals, they don't need this code)
            if (this == MySession.PlayerShip)
            {
                //  Intersection with ideal glass
                if (GetShipCockpitGlass() != null && GetShipCockpitGlass().ModelLod0 != null && GetShipCockpitGlass().ModelLod0.GetTrianglePruningStructure() != null)
                {
                    var intersectionGlass =
                        GetShipCockpitGlass().ModelLod0.GetTrianglePruningStructure().GetIntersectionWithLine(
                            GetShipCockpitGlass(), ref line, IntersectionFlags.FLIPPED_TRIANGLES);

                    const float GLASS_DISTANCE_TOLERANCE = 3 * MySmallShipConstants.ALL_SMALL_SHIP_MODEL_SCALE;
                    if (MyIntersectionResultLineTriangleEx.IsDistanceLessThanTolerance(ref result, ref intersectionGlass, GLASS_DISTANCE_TOLERANCE))
                    {
                        result = intersectionGlass;
                    }
                }
            }
            t = result;

            return result != null;
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:45,代码来源:MySmallShip.cs


示例19: Intersect

        public bool Intersect(ref Line localLine, out VRage.Game.Models.MyIntersectionResultLineTriangle result, IntersectionFlags flags)
        {
            MyPrecalcComponent.AssertUpdateThread();

            ProfilerShort.Begin("VoxelMap.LineIntersection AABB sweep");
            m_sweepResultCache.Clear();
            MyGridIntersection.Calculate(
                m_sweepResultCache,
                (int)MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_METRES,
                localLine.From,
                localLine.To,
                new Vector3I(0, 0, 0),
                m_cellsCount - 1
            );
            ProfilerShort.End();

            ProfilerShort.Begin("VoxelMap.LineIntersection test AABBs");
            float? minDistanceUntilNow = null;
            BoundingBox cellBoundingBox;
            MyCellCoord cell = new MyCellCoord();
            VRage.Game.Models.MyIntersectionResultLineTriangle? tmpResult = null;
            for (int index = 0; index < m_sweepResultCache.Count; index++)
            {
                cell.CoordInLod = m_sweepResultCache[index];

                MyVoxelCoordSystems.GeometryCellCoordToLocalAABB(ref cell.CoordInLod, out cellBoundingBox);

                float? distanceToBoundingBox = MyUtils.GetLineBoundingBoxIntersection(ref localLine, ref cellBoundingBox);

                // Sweep results are sorted; when we get far enough, make an early exit
                const float earlyOutDistance = 1.948557f * MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_METRES;  // = sqrt(3) * 9/8 * cell_side
                if (minDistanceUntilNow != null && distanceToBoundingBox != null && minDistanceUntilNow + earlyOutDistance < distanceToBoundingBox.Value)
                {
                    break;
                }

                //  Get cell from cache. If not there, precalc it and store in the cache.
                //  If null is returned, we know that cell doesn't contain any triangleVertexes so we don't need to do intersections.
                CellData cachedDataCell = GetCell(ref cell);

                if (cachedDataCell == null || cachedDataCell.VoxelTrianglesCount == 0) continue;

                GetCellLineIntersectionOctree(ref tmpResult, ref localLine, ref minDistanceUntilNow, cachedDataCell, flags);
            }

            ProfilerShort.End();

            result = tmpResult ?? default(VRage.Game.Models.MyIntersectionResultLineTriangle);
            return tmpResult.HasValue;
        }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:50,代码来源:MyVoxelGeometry.cs


示例20: GetIntersectionWithLine

        public VRage.Game.Models.MyIntersectionResultLineTriangleEx? GetIntersectionWithLine(IMyEntity entity, ref LineD line, ref MatrixD customInvMatrix, IntersectionFlags flags)
        {
            LineD lineInModelSpace = new LineD(Vector3D.Transform(line.From, ref customInvMatrix), Vector3D.Transform(line.To, ref customInvMatrix));

            //MyIntersectionResultLineTriangle? result = null;

            m_result.Start(m_model, lineInModelSpace, flags);

            var dir = lineInModelSpace.Direction.ToBullet();
            var from = lineInModelSpace.From.ToBullet();

            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("m_bvh.RayQueryClosest()");
            m_bvh.RayQueryClosest(ref dir, ref from, m_result.ProcessTriangleHandler);
            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();

            if (m_result.Result.HasValue)
            {
                return new VRage.Game.Models.MyIntersectionResultLineTriangleEx(m_result.Result.Value, entity, ref lineInModelSpace);
            }
            else
            {
                return null;
            }
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:24,代码来源:MyQuantizedBvhAdapter.cs



注:本文中的IntersectionFlags类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Interval类代码示例发布时间:2022-05-24
下一篇:
C# Interrupter类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap