| 1590 | case AI::PosFlankRight: |
| 1591 | offset[0] += sizeX * coef; |
| 1592 | break; |
| 1593 | } |
| 1594 | return _formationPos + offset; |
| 1595 | } |
| 1596 | |
| 1597 | Vector3 AIUnit::GetFormationAbsolute(AIUnit* leader) const |
| 1598 | { |
| 1599 | // absolute formation position |
| 1600 | // suppose leader is formation leader |
| 1601 | EntityAI* lVehicle = leader->GetVehicle(); |
| 1602 | |
| 1603 | AISubgroup* subgrp = leader->GetSubgroup(); |
| 1604 | Matrix4 transform; |
| 1605 | Vector3Val formDir = subgrp->GetFormationDirection(); |
| 1606 | transform.SetDirectionAndUp(formDir, VUp); |
| 1607 | transform.SetPosition(lVehicle->Position()); |
| 1608 | |
| 1609 | Vector3 pos = transform.FastTransform(GetFormationRelative() - leader->GetFormationRelative()); |
| 1610 | if (GetVehicle()->GetType()->GetKind() != VAir) |
| 1611 | { |
| 1612 | // absolute formation position |
| 1613 | pos[1] = GLandscape->SurfaceYAboveWater(pos[0], pos[2]); |
| 1614 | } |
| 1615 | else |
| 1616 | { |
| 1617 | float landY = GLandscape->SurfaceYAboveWater(pos[0], pos[2]); |
| 1618 | saturateMax(pos[1], landY + 25); |
| 1619 | } |
no test coverage detected