MCPcopy Create free account
hub / github.com/davideberly/GeometricTools / GetNormal

Method GetNormal

GTE/Graphics/Terrain.cpp:96–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94}
95
96Vector3<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
124void Terrain::OnCameraMotion()
125{

Callers 2

GetProjectionMatrixMethod · 0.45
OnIdleMethod · 0.45

Calls 3

NormalizeFunction · 0.50
GetTranslationMethod · 0.45
GetHeightMethod · 0.45

Tested by

no test coverage detected