| 1550 | } |
| 1551 | |
| 1552 | void Flag::Init(Matrix4Par pos) |
| 1553 | { |
| 1554 | Shape* shape = _shape->Level(0); |
| 1555 | int selIndex = _fabric.GetSelection(0); |
| 1556 | if (selIndex >= 0) |
| 1557 | { |
| 1558 | const NamedSelection& sel = shape->NamedSel(selIndex); |
| 1559 | |
| 1560 | shape->SaveOriginalPos(); |
| 1561 | float minX = +1e10, minY = +1e10; |
| 1562 | float maxX = -1e10, maxY = -1e10; |
| 1563 | for (int i = 0; i < sel.Size(); i++) |
| 1564 | { |
| 1565 | int index = sel[i]; |
| 1566 | Vector3Val val = shape->OrigPos(index); |
| 1567 | saturateMin(minX, val.X()); |
| 1568 | saturateMin(minY, val.Y()); |
| 1569 | saturateMax(maxX, val.X()); |
| 1570 | saturateMax(maxY, val.Y()); |
| 1571 | } |
| 1572 | |
| 1573 | float xSize = maxX - minX; |
| 1574 | float ySize = maxY - minY; |
| 1575 | |
| 1576 | _cloth = new ClothObject(); |
| 1577 | const ParamEntry& entry = Pars >> "CfgCloth" >> "flag"; |
| 1578 | _cloth->Init(entry, pos, minX, minY, xSize, ySize); |
| 1579 | } |
| 1580 | } |
| 1581 | |
| 1582 | Flag::~Flag() |
| 1583 | { |
no test coverage detected