| 753 | } |
| 754 | |
| 755 | void Foliage::SetInstanceTransform(int32 index, const Transform& value) |
| 756 | { |
| 757 | auto& instance = Instances[index]; |
| 758 | auto type = &FoliageTypes[instance.Type]; |
| 759 | |
| 760 | // Change transform |
| 761 | instance.Transform = value; |
| 762 | |
| 763 | // Update bounds |
| 764 | instance.Bounds = BoundingSphere::Empty; |
| 765 | if (!type->IsReady()) |
| 766 | return; |
| 767 | Vector3 corners[8]; |
| 768 | auto& meshes = type->Model->LODs[0].Meshes; |
| 769 | const Transform transform = _transform.LocalToWorld(instance.Transform); |
| 770 | for (int32 j = 0; j < meshes.Count(); j++) |
| 771 | { |
| 772 | meshes[j].GetBox().GetCorners(corners); |
| 773 | |
| 774 | for (int32 k = 0; k < 8; k++) |
| 775 | { |
| 776 | Vector3::Transform(corners[k], transform, corners[k]); |
| 777 | } |
| 778 | BoundingSphere meshBounds; |
| 779 | BoundingSphere::FromPoints(corners, 8, meshBounds); |
| 780 | ASSERT(meshBounds.Radius > ZeroTolerance); |
| 781 | |
| 782 | BoundingSphere::Merge(instance.Bounds, meshBounds, instance.Bounds); |
| 783 | } |
| 784 | instance.Bounds.Radius += ZeroTolerance; |
| 785 | } |
| 786 | |
| 787 | void Foliage::OnFoliageTypeModelLoaded(int32 index) |
| 788 | { |
no test coverage detected