public void ComputeAABB(Transform tx, out AABB aabb) { Transform world = Transform.Mul(tx, local); Vec3 min = new Vec3(double.MaxValue, double.MaxValue, double.MaxValue); Vec3 max = new Vec3(-double.MaxValue, -double.MaxValue, -double.MaxValue); for (int i = 0; i < 8; ++i) { var v = Transform.Mul(world, Vec3.Mul(kBoxVertices[i], e)); min = Vec3.Min(min, v); max = Vec3.Max(max, v); } aabb.min = min; aabb.max = max; }
//-------------------------------------------------------------------------------------------------- public static Vec3 Mul(Transform tx, Vec3 scale, Vec3 v) { return(tx.rotation * Vec3.Mul(scale, v) + tx.position); }