コード例 #1
0
        private static void DrawConnections(HkdBreakableShape breakableShape, MatrixD worldMatrix, float alpha, ref int shapeIndex, string customText = null, bool isPhantom = false)
        {
            List <HkdConnection> resultList = new List <HkdConnection>();

            breakableShape.GetConnectionList(resultList);
            List <HkdShapeInstanceInfo> list = new List <HkdShapeInstanceInfo>();

            breakableShape.GetChildren(list);
            foreach (HkdConnection connection in resultList)
            {
                Vector3D pointFrom = DebugShapesPositions[connection.ShapeAName];
                Vector3D pointTo   = DebugShapesPositions[connection.ShapeBName];
                bool     flag      = false;
                foreach (HkdShapeInstanceInfo info in list)
                {
                    if ((info.ShapeName == connection.ShapeAName) || (info.ShapeName == connection.ShapeBName))
                    {
                        flag = true;
                    }
                }
                if (flag)
                {
                    MyRenderProxy.DebugDrawLine3D(pointFrom, pointTo, Color.White, Color.White, false, false);
                }
            }
        }
コード例 #2
0
        private static void DrawConnections(HkdBreakableShape breakableShape, MatrixD worldMatrix, float alpha, ref int shapeIndex, string customText = null, bool isPhantom = false)
        {
            List <HkdConnection> connections = new List <HkdConnection>();

            breakableShape.GetConnectionList(connections);

            List <HkdShapeInstanceInfo> children = new List <HkdShapeInstanceInfo>();

            breakableShape.GetChildren(children);

            foreach (var conn in connections)
            {
                var posA = DebugShapesPositions[conn.ShapeAName];
                var posB = DebugShapesPositions[conn.ShapeBName];

                bool cont = false;
                foreach (var child in children)
                {
                    if ((child.ShapeName == conn.ShapeAName) || (child.ShapeName == conn.ShapeBName))
                    {
                        cont = true;
                    }
                }

                if (cont)
                {
                    VRageRender.MyRenderProxy.DebugDrawLine3D(posA, posB, Color.White, Color.White, false);
                }
            }
        }
コード例 #3
0
        private void DrawConnections(HkdBreakableShape breakableShape, MatrixD worldMatrix, float alpha, ref int shapeIndex, string customText = null, bool isPhantom = false)
        {
            List<HkdConnection> connections = new List<HkdConnection>();
            breakableShape.GetConnectionList(connections);

            List<HkdShapeInstanceInfo> children = new List<HkdShapeInstanceInfo>();
            breakableShape.GetChildren(children);

            foreach (var conn in connections)
            {
                var posA = DebugShapesPositions[conn.ShapeAName];
                var posB = DebugShapesPositions[conn.ShapeBName];

                bool cont = false;
                foreach (var child in children)
                {
                    if ((child.ShapeName == conn.ShapeAName) || (child.ShapeName == conn.ShapeBName))
                        cont = true;
                }

                if (cont)
                    VRageRender.MyRenderProxy.DebugDrawLine3D(posA, posB, Color.White, Color.White, false);
            }
        }
コード例 #4
0
        public static void FixPosition(MyFracturedPiece fp)
        {
            //return;
            ProfilerShort.Begin("FixPosition");
            var shape = fp.Physics.BreakableBody.BreakableShape;

            if (shape.GetChildrenCount() == 0)
            {
                ProfilerShort.End();
                return;
            }
            shape.GetChildren(m_tmpInfos);
            var offset = m_tmpInfos[0].GetTransform().Translation;

            if (offset.LengthSquared() < 1)
            {
                m_tmpInfos.Clear();
                ProfilerShort.End();
                return;
            }
            var lst  = new List <HkdConnection>();
            var set  = new HashSet <HkdBreakableShape>();
            var set2 = new HashSet <HkdBreakableShape>();

            set.Add(shape);
            shape.GetConnectionList(lst);
            fp.PositionComp.SetPosition(Vector3D.Transform(offset, fp.PositionComp.WorldMatrix));
            foreach (var child in m_tmpInfos)
            {
                var m = child.GetTransform();
                m.Translation -= offset;
                child.SetTransform(ref m);
                m_tmpInfos2.Add(child);
                HkdBreakableShape par = child.Shape;
                par.GetConnectionList(lst);
                while (par.HasParent)
                {
                    par = par.GetParent();
                    if (set.Add(par))
                    {
                        par.GetConnectionList(lst);
                    }
                    else
                    {
                    }
                }
                set2.Add(child.Shape);
            }
            m_tmpInfos.Clear();
            HkdBreakableShape compound = new HkdCompoundBreakableShape(shape, m_tmpInfos2);

            //HkMassProperties mp = new HkMassProperties();
            ((HkdCompoundBreakableShape)compound).RecalcMassPropsFromChildren();
            compound.SetChildrenParent(compound);
            foreach (var c in lst)
            {
                HkBaseSystem.EnableAssert(390435339, true);
                if (!set2.Contains(c.ShapeA) || !set2.Contains(c.ShapeB))
                {
                    continue;
                }
                var cref = c;
                compound.AddConnection(ref cref);
            }
            fp.Physics.BreakableBody.BreakableShape = compound;
            m_tmpInfos2.Clear();

            ((HkdCompoundBreakableShape)compound).RecalcMassPropsFromChildren();

            ProfilerShort.End();
        }
コード例 #5
0
        public static unsafe void FixPosition(MyFracturedPiece fp)
        {
            HkdBreakableShape breakableShape = fp.Physics.BreakableBody.BreakableShape;

            if (breakableShape.GetChildrenCount() != 0)
            {
                breakableShape.GetChildren(m_tmpInfos);
                Vector3 translation = m_tmpInfos[0].GetTransform().Translation;
                if (translation.LengthSquared() < 1f)
                {
                    m_tmpInfos.Clear();
                }
                else
                {
                    List <HkdConnection>        resultList = new List <HkdConnection>();
                    HashSet <HkdBreakableShape> set        = new HashSet <HkdBreakableShape>();
                    HashSet <HkdBreakableShape> set2       = new HashSet <HkdBreakableShape>();
                    set.Add(breakableShape);
                    breakableShape.GetConnectionList(resultList);
                    fp.PositionComp.SetPosition(Vector3D.Transform(translation, fp.PositionComp.WorldMatrix), null, false, true);
                    foreach (HkdShapeInstanceInfo info2 in m_tmpInfos)
                    {
                        Matrix  transform  = info2.GetTransform();
                        Matrix *matrixPtr1 = (Matrix *)ref transform;
                        matrixPtr1.Translation -= translation;
                        info2.SetTransform(ref transform);
                        m_tmpInfos2.Add(info2);
                        HkdBreakableShape shape = info2.Shape;
                        shape.GetConnectionList(resultList);
                        while (true)
                        {
                            if (!shape.HasParent)
                            {
                                set2.Add(info2.Shape);
                                break;
                            }
                            shape = shape.GetParent();
                            if (set.Add(shape))
                            {
                                shape.GetConnectionList(resultList);
                            }
                        }
                    }
                    m_tmpInfos.Clear();
                    HkdBreakableShape parent = (HkdBreakableShape) new HkdCompoundBreakableShape(new HkdBreakableShape?(breakableShape), m_tmpInfos2);
                    parent.RecalcMassPropsFromChildren();
                    ((HkdBreakableShape *)ref parent).SetChildrenParent(parent);
                    foreach (HkdConnection connection in resultList)
                    {
                        HkBaseSystem.EnableAssert(0x1745920b, true);
                        if (set2.Contains(connection.ShapeA) && set2.Contains(connection.ShapeB))
                        {
                            HkdConnection connection2 = connection;
                            parent.AddConnection(ref connection2);
                        }
                    }
                    fp.Physics.BreakableBody.BreakableShape = parent;
                    m_tmpInfos2.Clear();
                    parent.RecalcMassPropsFromChildren();
                }
            }
        }