protected void UpdateConvexShapeInfo(ConvexShapeDescription description) { UpdateEntityShapeVolume(description.EntityShapeVolume); MinimumRadius = description.MinimumRadius; MaximumRadius = description.MaximumRadius; collisionMargin = description.CollisionMargin; }
/// <summary> /// Constructs a minkowski sum shape from cached data. /// </summary> /// <param name="shapeEntries">Entries composing the minkowski sum.</param> /// <param name="localOffset">Local offset of the elements in the minkowski sum.</param> /// <param name="description">Cached information about the shape. Assumed to be correct; no extra processing or validation is performed.</param> public MinkowskiSumShape(IList <OrientedConvexShapeEntry> shapeEntries, Vector3 localOffset, ConvexShapeDescription description) { for (int i = 0; i < shapeEntries.Count; i++) { Shapes.Add(shapeEntries[i]); } this.localOffset = localOffset; UpdateConvexShapeInfo(description); Shapes.Changed += ShapesChanged; }
/// <summary> /// Creates a ConvexHullShape from cached information. Assumes all data provided is accurate- no pre-processing is performed. /// </summary> /// <param name="localSurfaceVertices">List of vertex positions on the surface of the convex hull shape, centered on the desired origin. These vertices are used as-is for the shape representation; no additional processing occurs.</param> /// <param name="description">Cached information about the shape. Assumed to be correct; no extra processing or validation is performed.</param> public ConvexHullShape(IList <Vector3> localSurfaceVertices, ConvexShapeDescription description) { if (localSurfaceVertices.Count == 0) { throw new ArgumentException("Vertices list used to create a ConvexHullShape cannot be empty."); } unexpandedMaximumRadius = description.MaximumRadius - collisionMargin; unexpandedMinimumRadius = description.MinimumRadius - collisionMargin; vertices = new Vector3[localSurfaceVertices.Count]; localSurfaceVertices.CopyTo(vertices, 0); UpdateConvexShapeInfo(description); }
///<summary> /// Constructs a wrapped shape from cached data. ///</summary> ///<param name="shapeEntries">Already centered shape entries used to construct the shape.</param> /// <param name="description">Cached information about the shape. Assumed to be correct; no extra processing or validation is performed.</param> ///<exception cref="Exception">Thrown when the shape list is empty.</exception> public WrappedShape(IList <ConvexShapeEntry> shapeEntries, ConvexShapeDescription description) { if (shapeEntries.Count == 0) { throw new ArgumentException("Cannot create a wrapped shape with no contained shapes."); } for (int i = 0; i < shapeEntries.Count; i++) { Shapes.Add(shapeEntries[i]); } UpdateConvexShapeInfo(description); Shapes.Changed += ShapesChanged; }