MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / BuildNormalForTerrainSegment

Function BuildNormalForTerrainSegment

Descent3/terrain.cpp:1126–1164  ·  view source on GitHub ↗

Builds the surface normal for terrain segment n

Source from the content-addressed store, hash-verified

1124
1125// Builds the surface normal for terrain segment n
1126void BuildNormalForTerrainSegment(int n) {
1127 int i, t;
1128
1129 vector a, b, c;
1130
1131 if (n < 0 || n >= (TERRAIN_WIDTH - 1) * (TERRAIN_DEPTH - 1))
1132 return;
1133
1134 i = n / TERRAIN_WIDTH;
1135 t = n % TERRAIN_WIDTH;
1136
1137 a.x = t * TERRAIN_SIZE;
1138 a.y = Terrain_seg[(i * TERRAIN_WIDTH) + (t)].y;
1139 a.z = i * TERRAIN_SIZE;
1140
1141 b.x = t * TERRAIN_SIZE;
1142 b.y = Terrain_seg[(i * TERRAIN_WIDTH) + (t + TERRAIN_WIDTH)].y;
1143 b.z = (i + 1) * TERRAIN_SIZE;
1144
1145 c.x = (t + 1) * TERRAIN_SIZE;
1146 c.y = Terrain_seg[(i * TERRAIN_WIDTH) + (t + TERRAIN_WIDTH + 1)].y;
1147 c.z = (i + 1) * TERRAIN_SIZE;
1148
1149 vm_GetNormal(&TerrainNormals[MAX_TERRAIN_LOD - 1][i * TERRAIN_WIDTH + t].normal1, &a, &b, &c);
1150
1151 a.x = t * TERRAIN_SIZE;
1152 a.y = Terrain_seg[(i * TERRAIN_WIDTH) + (t)].y;
1153 a.z = i * TERRAIN_SIZE;
1154
1155 b.x = (t + 1) * TERRAIN_SIZE;
1156 b.y = Terrain_seg[(i * TERRAIN_WIDTH) + (t + TERRAIN_WIDTH + 1)].y;
1157 b.z = (i + 1) * TERRAIN_SIZE;
1158
1159 c.x = (t + 1) * TERRAIN_SIZE;
1160 c.y = Terrain_seg[(i * TERRAIN_WIDTH) + (t + 1)].y;
1161 c.z = (i)*TERRAIN_SIZE;
1162
1163 vm_GetNormal(&TerrainNormals[MAX_TERRAIN_LOD - 1][i * TERRAIN_WIDTH + t].normal2, &a, &b, &c);
1164}
1165
1166// Builds the vertex normal for terrain segment n
1167void BuildLightingNormalForSegment(int n) {

Callers

nothing calls this directly

Calls 1

vm_GetNormalFunction · 0.50

Tested by

no test coverage detected