| 510 | namespace Poseidon |
| 511 | { |
| 512 | void ForestPlain::Animate(int level) |
| 513 | { |
| 514 | Shape* shape = _shape->Level(level); |
| 515 | if (!shape) |
| 516 | { |
| 517 | return; |
| 518 | } |
| 519 | |
| 520 | PoseidonAssert(GLandscape); |
| 521 | // save original position |
| 522 | shape->SaveOriginalPos(); |
| 523 | |
| 524 | if (_singleMatrixT1 || _singleMatrixT2) |
| 525 | { |
| 526 | // matrix included in object matrix |
| 527 | } |
| 528 | else |
| 529 | { |
| 530 | float xC = Position().X(); |
| 531 | float zC = Position().Z(); |
| 532 | // fine rectangles are not used - use rough instead |
| 533 | // calculate surface level on given coordinates |
| 534 | float xRel = xC * InvLandGrid; |
| 535 | float zRel = zC * InvLandGrid; |
| 536 | int x = toIntFloor(xRel); |
| 537 | int z = toIntFloor(zRel); |
| 538 | float xf = x; |
| 539 | float zf = z; |
| 540 | |
| 541 | int subdivLog = TerrainRangeLog - LandRangeLog; |
| 542 | int subdiv = 1 << subdivLog; |
| 543 | |
| 544 | int xs = x * subdiv; |
| 545 | int zs = z * subdiv; |
| 546 | |
| 547 | Landscape* land = GLandscape; |
| 548 | float y00 = land->GetHeight(zs, xs); |
| 549 | float y01 = land->GetHeight(zs, xs + subdiv); |
| 550 | float y10 = land->GetHeight(zs + subdiv, xs); |
| 551 | float y11 = land->GetHeight(zs + subdiv, xs + subdiv); |
| 552 | |
| 553 | float d1000 = y10 - y00; |
| 554 | float d0100 = y01 - y00; |
| 555 | |
| 556 | float d1011 = y10 - y11; |
| 557 | float d0111 = y01 - y11; |
| 558 | |
| 559 | shape->InvalidateNormals(); |
| 560 | |
| 561 | Matrix4Val toWorld = Transform(); |
| 562 | Matrix4Val fromWorld = GetInvTransform(); |
| 563 | |
| 564 | // convert plane equations to model space |
| 565 | // change object shape to reflect surface |
| 566 | // most forest objects are not rotated, only offseted - this can be easily optimized |
| 567 | bool rotated = Direction() * VForward < 0.99; |
| 568 | float yOffset = -_shape->BoundingCenter().Y(); |
| 569 | if (!rotated) |
nothing calls this directly
no test coverage detected