本文整理汇总了C#中HkdBreakableShape.RemoveReference方法的典型用法代码示例。如果您正苦于以下问题:C# HkdBreakableShape.RemoveReference方法的具体用法?C# HkdBreakableShape.RemoveReference怎么用?C# HkdBreakableShape.RemoveReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HkdBreakableShape
的用法示例。
在下文中一共展示了HkdBreakableShape.RemoveReference方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: FindFracturedBlocks
private void FindFracturedBlocks(HkdBreakableBodyInfo b)
{
ProfilerShort.Begin("DBHelper");
var dbHelper = new HkdBreakableBodyHelper(b);
ProfilerShort.BeginNextBlock("GetRBMatrix");
var bodyMatrix = dbHelper.GetRigidBodyMatrix();
ProfilerShort.BeginNextBlock("SearchChildren");
dbHelper.GetChildren(m_children);
foreach (var child in m_children)
{
if (!child.IsFracturePiece())
continue;
//var blockPosWorld = ClusterToWorld(Vector3.Transform(child.GetTransform().Translation, bodyMatrix));
var bShape = child.Shape;
HkVec3IProperty pProp = bShape.GetProperty(HkdBreakableShape.PROPERTY_GRID_POSITION);
var blockPos = pProp.Value; //Vector3I.Round(child.GetTransform().Translation / m_grid.GridSize);
if (!m_grid.CubeExists(blockPos))
{
//Debug.Fail("FindFracturedBlocks:Fracture piece missing block");//safe to ignore
continue;
}
if (MyFakes.ENABLE_FRACTURE_COMPONENT)
{
var block = m_grid.GetCubeBlock(blockPos);
if (block == null)
continue;
if (!FindFractureComponentBlocks(block, child))
continue;
}
else
{
if (!m_fracturedBlocksShapes.ContainsKey(blockPos))
m_fracturedBlocksShapes[blockPos] = new List<HkdShapeInstanceInfo>();
m_fracturedBlocksShapes[blockPos].Add(child);
}
}
ProfilerShort.BeginNextBlock("CreateFreacturedBlocks");
if (!MyFakes.ENABLE_FRACTURE_COMPONENT)
{
foreach (var key in m_fracturedBlocksShapes.Keys)
{
HkdBreakableShape shape;
var shapeList = m_fracturedBlocksShapes[key];
foreach (var s in shapeList)
{
var matrix = s.GetTransform();
matrix.Translation = Vector3.Zero;
s.SetTransform(ref matrix);
}
ProfilerShort.Begin("CreateShape");
HkdBreakableShape compound = new HkdCompoundBreakableShape(null, shapeList);
((HkdCompoundBreakableShape)compound).RecalcMassPropsFromChildren();
var mp = new HkMassProperties();
compound.BuildMassProperties(ref mp);
shape = compound;
var sh = compound.GetShape();
shape = new HkdBreakableShape(sh, ref mp);
//shape.SetMassProperties(mp); //important! pass mp to constructor
foreach (var si in shapeList)
{
var siRef = si;
shape.AddShape(ref siRef);
}
compound.RemoveReference();
ProfilerShort.BeginNextBlock("Connect");
//shape.SetChildrenParent(shape);
ConnectPiecesInBlock(shape, shapeList);
ProfilerShort.End();
var info = new MyFracturedBlock.Info()
{
Shape = shape,
Position = key,
Compound = true,
};
var originalBlock = m_grid.GetCubeBlock(key);
if (originalBlock == null)
{
//Debug.Fail("Missing fracture piece original block.");//safe to ignore
shape.RemoveReference();
continue;
}
Debug.Assert(originalBlock != null);
if (originalBlock.FatBlock is MyFracturedBlock)
{
var fractured = originalBlock.FatBlock as MyFracturedBlock;
info.OriginalBlocks = fractured.OriginalBlocks;
info.Orientations = fractured.Orientations;
info.MultiBlocks = fractured.MultiBlocks;
}
else if (originalBlock.FatBlock is MyCompoundCubeBlock)
{
info.OriginalBlocks = new List<MyDefinitionId>();
info.Orientations = new List<MyBlockOrientation>();
MyCompoundCubeBlock compoundBlock = originalBlock.FatBlock as MyCompoundCubeBlock;
bool hasMultiBlockPart = false;
var blocksInCompound = compoundBlock.GetBlocks();
foreach (var block in blocksInCompound)
//.........这里部分代码省略.........