protected override void ApplyBodyPosition() { for (int i = 0; i < this.countWorld; i++) { this.worldVertices[i] = this.Body.BodyToWorldPointCurrent(this.bodyVertices[i]); this.worldAxes[i] = this.Body.BodyToWorldAxisCurrent(this.bodyAxes[i]); } this.worldSpaceAABB = VoltPolygon.ComputeBounds(this.worldVertices, this.countWorld); }
internal void InitializeFromWorldVertices( Vector2[] vertices, float density, float friction, float restitution) { base.Initialize(density, friction, restitution); this.UpdateArrays(vertices.Length); this.countWorld = vertices.Length; Array.Copy(vertices, this.worldVertices, this.countWorld); VoltPolygon.ComputeAxes(vertices, this.countWorld, ref this.worldAxes); this.worldSpaceAABB = VoltPolygon.ComputeBounds(vertices, this.countWorld); this.countBody = 0; // Needs to be set on metric compute }
internal void InitializeFromBodyVertices( Vector2[] vertices, float density, float friction, float restitution) { base.Initialize(density, friction, restitution); this.UpdateArrays(vertices.Length); // World vertices will be computed on position update this.countWorld = vertices.Length; this.countBody = vertices.Length; Array.Copy(vertices, this.bodyVertices, vertices.Length); VoltPolygon.ComputeAxes(vertices, this.countBody, ref this.bodyAxes); this.bodySpaceAABB = VoltPolygon.ComputeBounds(vertices, this.countBody); }
protected override void ComputeMetrics() { // If we were initialized with world points, we need to compute body if (this.countBody == 0) { // Compute body-space geometry data (only need to do this once) VoltPolygon.WorldToBody( this.Body, this.worldVertices, this.bodyVertices, this.countWorld); this.countBody = this.countWorld; VoltPolygon.ComputeAxes(this.bodyVertices, this.countBody, ref this.bodyAxes); this.bodySpaceAABB = VoltPolygon.ComputeBounds(this.bodyVertices, this.countBody); } this.Area = this.ComputeArea(); this.Mass = this.Area * this.Density * VoltConfig.AreaMassRatio; this.Inertia = this.ComputeInertia(); }