| 94 | } |
| 95 | |
| 96 | Vector3<float> Terrain::GetNormal(float x, float y) const |
| 97 | { |
| 98 | float xp = x + mSpacing; |
| 99 | float xm = x - mSpacing; |
| 100 | float yp = y + mSpacing; |
| 101 | float ym = y - mSpacing; |
| 102 | |
| 103 | auto page = GetPage(xp, y); |
| 104 | Vector3<float> trn = page->localTransform.GetTranslation(); |
| 105 | float hpz = page->GetHeight(xp - trn[0], y - trn[1]); |
| 106 | |
| 107 | page = GetPage(xm, y); |
| 108 | trn = page->localTransform.GetTranslation(); |
| 109 | float hmz = page->GetHeight(xm - trn[0], y - trn[1]); |
| 110 | |
| 111 | page = GetPage(x, yp); |
| 112 | trn = page->localTransform.GetTranslation(); |
| 113 | float hzp = page->GetHeight(x - trn[0], yp - trn[1]); |
| 114 | |
| 115 | page = GetPage(x, ym); |
| 116 | trn = page->localTransform.GetTranslation(); |
| 117 | float hzm = page->GetHeight(x - trn[0], ym - trn[1]); |
| 118 | |
| 119 | Vector3<float> normal{ hmz - hpz, hzm - hzp, 1.0f }; |
| 120 | Normalize(normal); |
| 121 | return normal; |
| 122 | } |
| 123 | |
| 124 | void Terrain::OnCameraMotion() |
| 125 | { |
no test coverage detected