当前位置: 首页>>代码示例>>C#>>正文


C# HkdBreakableShape.IsValid方法代码示例

本文整理汇总了C#中HkdBreakableShape.IsValid方法的典型用法代码示例。如果您正苦于以下问题:C# HkdBreakableShape.IsValid方法的具体用法?C# HkdBreakableShape.IsValid怎么用?C# HkdBreakableShape.IsValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HkdBreakableShape的用法示例。


在下文中一共展示了HkdBreakableShape.IsValid方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsFixed

 public static bool IsFixed(HkdBreakableShape breakableShape)
 {
     System.Diagnostics.Debug.Assert(m_tmpInfos.Count == 0, "");
     if (!breakableShape.IsValid())
         return false;
     if ((breakableShape.UserObject & (uint)HkdBreakableShape.Flags.IS_FIXED) != 0)
     {
         return true;
     }
     else
     {
         Debug.Assert(m_tmpInfos.Count == 0);
         breakableShape.GetChildren(m_tmpInfos);
         foreach (var child in m_tmpInfos)
         {
             if ((child.Shape.UserObject & (uint)HkdBreakableShape.Flags.IS_FIXED) != 0)
             {
                 m_tmpInfos.Clear();
                 return true;
             }
         }
         m_tmpInfos.Clear();
     }
     return false;
 }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:25,代码来源:MyDestructionHelper.cs

示例2: DontCreateFracture

 private static bool DontCreateFracture(HkdBreakableShape breakableShape)
 {
     if (!breakableShape.IsValid())
         return false;
     return (breakableShape.UserObject & (uint)HkdBreakableShape.Flags.DONT_CREATE_FRACTURE_PIECE) != 0;
 }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:6,代码来源:MyDestructionHelper.cs

示例3: SetShape

        public virtual void SetShape(HkdBreakableShape shape, bool compound)
        {
            Debug.Assert(shape.IsValid());

            if (Shape.IsValid())
                Shape.RemoveReference();

            Shape = shape;

            var render = Entity.Render as MyRenderComponentFracturedPiece;
            Debug.Assert(render != null);

            if (render != null)
            {
                render.ClearModels();

                if (compound)
                {
                    Debug.Assert(m_tmpChildren.Count == 0);

                    shape.GetChildren(m_tmpChildren);

                    foreach (var shapeInstanceInfo in m_tmpChildren)
                    {
                        System.Diagnostics.Debug.Assert(shapeInstanceInfo.IsValid(), "Invalid shapeInstanceInfo!");
                        if (shapeInstanceInfo.IsValid())
                        {
                            render.AddPiece(shapeInstanceInfo.ShapeName, Matrix.Identity);
                        }
                    }

                    m_tmpChildren.Clear();
                }
                else
                {
                    render.AddPiece(shape.Name, Matrix.Identity);
                }

                render.UpdateRenderObject(true);
            }
        }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:41,代码来源:MyFractureComponentBase.cs

示例4: CreateFracturePiece

        private static MyFracturedPiece CreateFracturePiece(ref HkdBreakableShape shape, HkdWorld world, ref MatrixD worldMatrix, bool isStatic)
        {
            Debug.Assert(shape.IsValid());
            ProfilerShort.Begin("CreateFracturePiece");
            var fracturedPiece = MyFracturedPiecesManager.Static.GetPieceFromPool(0);//new MyFracturedPiece();
            fracturedPiece.PositionComp.WorldMatrix = worldMatrix;
            fracturedPiece.Physics.Flags = isStatic ? RigidBodyFlag.RBF_STATIC : RigidBodyFlag.RBF_DEBRIS;
            var physicsBody = fracturedPiece.Physics as MyPhysicsBody;//new MyPhysicsBody(fracturedPiece,isFixed ?RigidBodyFlag.RBF_STATIC : RigidBodyFlag.RBF_DEBRIS);

            HkMassProperties mp = new HkMassProperties();
            shape.BuildMassProperties(ref mp);
            physicsBody.InitialSolverDeactivation = HkSolverDeactivation.High;
            physicsBody.CreateFromCollisionObject(shape.GetShape(), Vector3.Zero, worldMatrix, mp);

            physicsBody.LinearDamping = MyPerGameSettings.DefaultLinearDamping;
            physicsBody.AngularDamping = MyPerGameSettings.DefaultAngularDamping;

            System.Diagnostics.Debug.Assert(physicsBody.BreakableBody == null, "physicsBody.DestructionBody == null");
            physicsBody.BreakableBody = new HkdBreakableBody(shape, physicsBody.RigidBody, world, worldMatrix);
            physicsBody.BreakableBody.AfterReplaceBody += physicsBody.FracturedBody_AfterReplaceBody;
            ProfilerShort.End();

            ProfilerShort.Begin("Sync");
            if (fracturedPiece.SyncFlag)
            {
                fracturedPiece.CreateSync();
            }
            ProfilerShort.End();
            fracturedPiece.NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME;
            //physicsBody.RigidBody.ContactPointCallbackDelay = 0;
            //physicsBody.RigidBody.ContactPointCallbackEnabled = true;
            fracturedPiece.Physics = physicsBody;
            //FixPosition(fracturedPiece);
            fracturedPiece.SetDataFromHavok(shape);
            ProfilerShort.Begin("AddToWorld");
            fracturedPiece.NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME;
            shape.RemoveReference();
            ProfilerShort.End();
            return fracturedPiece;
        }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:40,代码来源:MyDestructionHelper.cs

示例5: GetCurrentFracturedShapeList

        private static bool GetCurrentFracturedShapeList(HkdBreakableShape breakableShape, List<MyObjectBuilder_FractureComponentBase.FracturedShape> shapeList, string[] excludeShapeNames = null)
        {
            Debug.Assert(breakableShape.IsValid());
            if (!breakableShape.IsValid())
                return false;

            var shapeName = breakableShape.Name;
            bool shapeNameEmpty = string.IsNullOrEmpty(shapeName);

            if (excludeShapeNames != null && !shapeNameEmpty)
            {
                foreach (var shapeNameToRemove in excludeShapeNames)
                {
                    if (shapeName == shapeNameToRemove)
                        return false;
                }
            }

            if (breakableShape.GetChildrenCount() > 0)
            {
                List<HkdShapeInstanceInfo> shapeInst = new List<HkdShapeInstanceInfo>();
                breakableShape.GetChildren(shapeInst);

                bool allChildrenAdded = true;
                foreach (var inst in shapeInst)
                {
                    allChildrenAdded &= GetCurrentFracturedShapeList(inst.Shape, shapeList, excludeShapeNames: excludeShapeNames);
                }

                if (!shapeNameEmpty && allChildrenAdded)
                {
                    foreach (var inst in shapeInst)
                    {
                        if (inst.Shape.IsValid())
                            shapeList.RemoveAll(s => s.Name == inst.ShapeName);
                    }

                    shapeList.Add(new MyObjectBuilder_FractureComponentBase.FracturedShape() { Name = shapeName, Fixed = breakableShape.IsFixed() });
                }

                return allChildrenAdded;
            }
            else
            {
                if (!shapeNameEmpty)
                {
                    shapeList.Add(new MyObjectBuilder_FractureComponentBase.FracturedShape() { Name = shapeName, Fixed = breakableShape.IsFixed() });
                    return true;
                }
            }

            return false;
        }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:53,代码来源:MyFractureComponentBase.cs


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