本文整理汇总了C#中Sandbox.GetFractureComponent方法的典型用法代码示例。如果您正苦于以下问题:C# Sandbox.GetFractureComponent方法的具体用法?C# Sandbox.GetFractureComponent怎么用?C# Sandbox.GetFractureComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sandbox
的用法示例。
在下文中一共展示了Sandbox.GetFractureComponent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateBlockShape
private HkdBreakableShape? CreateBlockShape(Sandbox.Game.Entities.Cube.MySlimBlock b, out Matrix blockTransform)
{
ProfilerShort.Begin("CreateBlockShape");
blockTransform = Matrix.Identity;
if (b.FatBlock == null)
{
Debug.Fail("Armor blocks are not allowed in medieval");
ProfilerShort.End();
return null;
}
HkdBreakableShape breakableShape;
Matrix compoundChildTransform = Matrix.Identity;
if (b.FatBlock is MyCompoundCubeBlock)
{
ProfilerShort.Begin("Cmpnd");
blockTransform.Translation = b.FatBlock.PositionComp.LocalMatrix.Translation;
var cb = b.FatBlock as MyCompoundCubeBlock;
if (cb.GetBlocksCount() == 1)
{
ProfilerShort.Begin("SingleBlock");
var block = cb.GetBlocks()[0];
ushort? compoundId = cb.GetBlockId(block);
Debug.Assert(compoundId != null);
MyFractureComponentBase fractureComponent = block.GetFractureComponent();
if (fractureComponent != null)
{
breakableShape = fractureComponent.Shape;
Debug.Assert(breakableShape.IsValid(), "Invalid breakableShape");
breakableShape.AddReference();
}
else
{
var defId = block.FatBlock.BlockDefinition;
Matrix m;
var model = block.CalculateCurrentModel(out m);
if (MyFakes.LAZY_LOAD_DESTRUCTION || HasBreakableShape(model, defId))
{
ProfilerShort.Begin("Clone");
breakableShape = GetBreakableShape(model, defId);
ProfilerShort.End();
}
}
if (breakableShape.IsValid())
{
HkPropertyBase idProp = new HkSimpleValueProperty((uint)compoundId.Value);
breakableShape.SetPropertyRecursively(HkdBreakableShape.PROPERTY_BLOCK_COMPOUND_ID, idProp);
idProp.RemoveReference();
}
block.Orientation.GetMatrix(out compoundChildTransform);
blockTransform = compoundChildTransform * blockTransform;
ProfilerShort.End();
}
else
{
var pos = b.Position * m_grid.GridSize;
float mass = 0;
ProfilerShort.Begin("GetBlocks");
foreach (var block in cb.GetBlocks())
{
block.Orientation.GetMatrix(out compoundChildTransform);
compoundChildTransform.Translation = Vector3.Zero;
ushort? compoundId = cb.GetBlockId(block);
Debug.Assert(compoundId != null);
MyFractureComponentBase fractureComponent = block.GetFractureComponent();
if (fractureComponent != null)
{
breakableShape = fractureComponent.Shape;
breakableShape.UserObject |= (uint)HkdBreakableShape.Flags.FRACTURE_PIECE;
breakableShape.AddReference();
Debug.Assert(breakableShape.IsValid(), "Invalid breakableShape");
m_shapeInfosList2.Add(new HkdShapeInstanceInfo(breakableShape, compoundChildTransform));
}
else
{
var blockDef = block.BlockDefinition;
Matrix m;
var model = block.CalculateCurrentModel(out m);
if (MyFakes.LAZY_LOAD_DESTRUCTION || HasBreakableShape(model, blockDef))
{
ProfilerShort.Begin("Clone");
breakableShape = GetBreakableShape(model, blockDef);
breakableShape.UserObject |= (uint)HkdBreakableShape.Flags.FRACTURE_PIECE;
Debug.Assert(breakableShape.IsValid(), "Invalid breakableShape");
ProfilerShort.End();
mass += blockDef.Mass;
m_shapeInfosList2.Add(new HkdShapeInstanceInfo(breakableShape, compoundChildTransform));
}
}
//.........这里部分代码省略.........