Exemplo n.º 1
0
 unsafe private bool CheckConnection(HkdConnection c)
 {
     HkdBreakableShape par = c.ShapeA;
     while (par.HasParent)
     {
         par = par.GetParent();
     }
     if (par != BreakableShape)
         return false;
     par = c.ShapeB;
     while (par.HasParent)
     {
         par = par.GetParent();
     }
     if (par != BreakableShape)
         return false;
     return true;
 }
Exemplo n.º 2
0
 private static HkdConnection CreateConnection(HkdBreakableShape aShape, HkdBreakableShape bShape, Vector3 pivotA, Vector3 pivotB)
 {
     ProfilerShort.Begin("CreateConnection-Shape-Shape");
     var normal = bShape.CoM - aShape.CoM;
     //if (normal.Length() == 0)
     //    normal = Vector3.Forward;
     HkdConnection c = new HkdConnection(aShape, bShape, pivotA, pivotB, normal, 6.25f);
     ProfilerShort.End();
     return c;
 }
Exemplo n.º 3
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();
                }
            }
        }