| 1547 | } |
| 1548 | |
| 1549 | void Foliage::OnTransformChanged() |
| 1550 | { |
| 1551 | // Base |
| 1552 | Actor::OnTransformChanged(); |
| 1553 | |
| 1554 | PROFILE_CPU(); |
| 1555 | |
| 1556 | // Update instances matrices and cached world bounds |
| 1557 | Vector3 corners[8]; |
| 1558 | Matrix world; |
| 1559 | GetLocalToWorldMatrix(world); |
| 1560 | for (auto i = Instances.Begin(); i.IsNotEnd(); ++i) |
| 1561 | { |
| 1562 | auto& instance = *i; |
| 1563 | auto type = &FoliageTypes[instance.Type]; |
| 1564 | |
| 1565 | // Update bounds |
| 1566 | instance.Bounds = BoundingSphere::Empty; |
| 1567 | if (!type->IsReady()) |
| 1568 | continue; |
| 1569 | auto& meshes = type->Model->LODs[0].Meshes; |
| 1570 | const Transform transform = _transform.LocalToWorld(instance.Transform); |
| 1571 | for (int32 j = 0; j < meshes.Count(); j++) |
| 1572 | { |
| 1573 | meshes[j].GetBox().GetCorners(corners); |
| 1574 | |
| 1575 | for (int32 k = 0; k < 8; k++) |
| 1576 | { |
| 1577 | Vector3::Transform(corners[k], transform, corners[k]); |
| 1578 | } |
| 1579 | BoundingSphere meshBounds; |
| 1580 | BoundingSphere::FromPoints(corners, 8, meshBounds); |
| 1581 | |
| 1582 | BoundingSphere::Merge(instance.Bounds, meshBounds, instance.Bounds); |
| 1583 | } |
| 1584 | } |
| 1585 | |
| 1586 | RebuildClusters(); |
| 1587 | } |
nothing calls this directly
no test coverage detected