public void UpdateBoundingBox() { boundingBox = JBBox.SmallBox; boundingBox.AddPoint(ref owner.points[indices.I0].position); boundingBox.AddPoint(ref owner.points[indices.I1].position); boundingBox.AddPoint(ref owner.points[indices.I2].position); boundingBox.Min -= new JVector(owner.triangleExpansion); boundingBox.Max += new JVector(owner.triangleExpansion); }
public virtual void Update(float timestep) { active = false; foreach (MassPoint point in points) { if (point.isActive && !point.isStatic) { active = true; break; } } if(!active) return; box = JBBox.SmallBox; volume = 0.0f; mass = 0.0f; foreach (MassPoint point in points) { mass += point.Mass; box.AddPoint(point.position); } box.Min -= new JVector(TriangleExpansion); box.Max += new JVector(TriangleExpansion); foreach (Triangle t in triangles) { // Update bounding box and move proxy in dynamic tree. JVector prevCenter = t.boundingBox.Center; t.UpdateBoundingBox(); JVector linVel = t.VertexBody1.linearVelocity + t.VertexBody2.linearVelocity + t.VertexBody3.linearVelocity; linVel *= 1.0f / 3.0f; dynamicTree.MoveProxy(t.dynamicTreeID, ref t.boundingBox, linVel * timestep); JVector v1 = points[t.indices.I0].position; JVector v2 = points[t.indices.I1].position; JVector v3 = points[t.indices.I2].position; volume -= ((v2.Y - v1.Y) * (v3.Z - v1.Z) - (v2.Z - v1.Z) * (v3.Y - v1.Y)) * (v1.X + v2.X + v3.X); } volume /= 6.0f; AddPressureForces(timestep); }