public static float GetConvexRadius(this HkWorld.HitInfo hitInfo) { if (hitInfo.Body == null) { return(0); } HkShape shape = hitInfo.Body.GetShape(); for (int i = 0; i < HkWorld.HitInfo.ShapeKeyCount; i++) { var shapeKey = hitInfo.GetShapeKey(i); if (HkShape.InvalidShapeKey != shapeKey) { if (!shape.IsContainer()) { break; } //shape = shape.GetContainer().GetShape(shapeKey); } else { break; } } if (shape.ShapeType == HkShapeType.ConvexTransform || shape.ShapeType == HkShapeType.ConvexTranslate || shape.ShapeType == HkShapeType.Transform) { shape = shape.GetContainer().GetShape(0); } if (shape.ShapeType == HkShapeType.Sphere || shape.ShapeType == HkShapeType.Capsule) { return(0); } if (!shape.IsConvex) { return(HkConvexShape.DefaultConvexRadius); } return(shape.ConvexRadius); }
public static IMyEntity GetHitEntity(this HkWorld.HitInfo hitInfo) { return(hitInfo.Body.GetEntity(hitInfo.GetShapeKey(0))); }