private void RecreateWeldedShape(HkShape thisShape) { if (RigidBody == null || RigidBody.IsDisposed) { Debug.Fail("Missing rigid body"); MyTrace.Send(TraceWindow.Analytics, "Recreating welded shape without RB", string.Format("{0},{1}", Entity.MarkedForClose, WeldInfo.Children.Count)); return; } ProfilerShort.Begin("RecreateWeldedShape"); //me.Tranform.Translation = Entity.PositionComp.LocalAABB.Center; if (WeldInfo.Children.Count == 0) { RigidBody.SetShape(thisShape); if (RigidBody2 != null) RigidBody2.SetShape(thisShape); } else { ProfilerShort.Begin("Create shapes"); //m_tmpElements.Add(WeldInfo.MassElement); m_tmpShapeList.Add(thisShape); foreach (var child in WeldInfo.Children) { var transformShape = new HkTransformShape(child.WeldedRigidBody.GetShape(), ref child.WeldInfo.Transform); HkShape.SetUserData(transformShape, child.WeldedRigidBody); m_tmpShapeList.Add(transformShape); //m_tmpElements.Add(child.WeldInfo.MassElement); } //var list = new HkListShape(m_tmpShapeList.ToArray(), HkReferencePolicy.None); var list = new HkSmartListShape(0); foreach (var shape in m_tmpShapeList) list.AddShape(shape); RigidBody.SetShape(list); if (RigidBody2 != null) RigidBody2.SetShape(list); list.Base.RemoveReference(); WeldedMarkBreakable(); for (int i = 1; i < m_tmpShapeList.Count; i++) m_tmpShapeList[i].RemoveReference(); m_tmpShapeList.Clear(); ProfilerShort.End(); ProfilerShort.Begin("CalcMassProps"); UpdateMassProps(); //m_tmpElements.Clear(); ProfilerShort.End(); } ProfilerShort.End(); }
private void RecreateWeldedShape(HkShape thisShape) { if (RigidBody == null || RigidBody.IsDisposed) { Debug.Fail("Missing rigid body"); MyTrace.Send(TraceWindow.Analytics, "Recreating welded shape without RB", string.Format("{0},{1}", Entity.MarkedForClose, WeldInfo.Children.Count)); return; } ProfilerShort.Begin("RecreateWeldedShape"); //me.Tranform.Translation = Entity.PositionComp.LocalAABB.Center; if (WeldInfo.Children.Count == 0) { RigidBody.SetShape(thisShape); if (RigidBody2 != null) RigidBody2.SetShape(thisShape); } else { ProfilerShort.Begin("Create shapes"); //m_tmpElements.Add(WeldInfo.MassElement); m_tmpShapeList.Add(thisShape); foreach (var child in WeldInfo.Children) { var transformShape = new HkTransformShape(child.WeldedRigidBody.GetShape(), ref child.WeldInfo.Transform); HkShape.SetUserData(transformShape, child.WeldedRigidBody); m_tmpShapeList.Add(transformShape); //m_tmpElements.Add(child.WeldInfo.MassElement); } //var list = new HkListShape(m_tmpShapeList.ToArray(), HkReferencePolicy.None); var list = new HkSmartListShape(0); foreach (var shape in m_tmpShapeList) list.AddShape(shape); RigidBody.SetShape(list); if (RigidBody2 != null) RigidBody2.SetShape(list); list.Base.RemoveReference(); WeldedMarkBreakable(); for (int i = 1; i < m_tmpShapeList.Count; i++) m_tmpShapeList[i].RemoveReference(); m_tmpShapeList.Clear(); ProfilerShort.End(); ProfilerShort.Begin("CalcMassProps"); UpdateMassProps(); //m_tmpElements.Clear(); ProfilerShort.End(); } ProfilerShort.End(); }
private void RecreateWeldedShape(HkShape thisShape) { ProfilerShort.Begin("RecreateWeldedShape"); //me.Tranform.Translation = Entity.PositionComp.LocalAABB.Center; if (WeldInfo.Children.Count == 0) { RigidBody.SetShape(thisShape); if (RigidBody2 != null) RigidBody2.SetShape(thisShape); } else { ProfilerShort.Begin("Create shapes"); //m_tmpElements.Add(WeldInfo.MassElement); m_tmpShapeList.Add(thisShape); foreach (var child in WeldInfo.Children) { var transformShape = new HkTransformShape(child.WeldedRigidBody.GetShape(), ref child.WeldInfo.Transform); HkShape.SetUserData(transformShape, child.WeldedRigidBody); m_tmpShapeList.Add(transformShape); //m_tmpElements.Add(child.WeldInfo.MassElement); } //var list = new HkListShape(m_tmpShapeList.ToArray(), HkReferencePolicy.None); var list = new HkSmartListShape(0); foreach (var shape in m_tmpShapeList) list.AddShape(shape); RigidBody.SetShape(list); if (RigidBody2 != null) RigidBody2.SetShape(list); list.Base.RemoveReference(); WeldedMarkBreakable(); for (int i = 1; i < m_tmpShapeList.Count; i++) m_tmpShapeList[i].RemoveReference(); m_tmpShapeList.Clear(); ProfilerShort.End(); ProfilerShort.Begin("CalcMassProps"); UpdateMassProps(); //m_tmpElements.Clear(); ProfilerShort.End(); } ProfilerShort.End(); }