|
@@ -176,26 +176,17 @@
|
176
|
176
|
const float xratio = (RAW_X_POSITION(end[X_AXIS]) - mesh_index_to_xpos(cell_dest_xi)) * (1.0 / (MESH_X_DIST));
|
177
|
177
|
|
178
|
178
|
float z1 = z_values[cell_dest_xi ][cell_dest_yi ] + xratio *
|
179
|
|
- (z_values[cell_dest_xi + 1][cell_dest_yi ] - z_values[cell_dest_xi][cell_dest_yi ]),
|
180
|
|
- z2 = z_values[cell_dest_xi ][cell_dest_yi + 1] + xratio *
|
181
|
|
- (z_values[cell_dest_xi + 1][cell_dest_yi + 1] - z_values[cell_dest_xi][cell_dest_yi + 1]);
|
|
179
|
+ (z_values[cell_dest_xi + 1][cell_dest_yi ] - z_values[cell_dest_xi][cell_dest_yi ]),
|
|
180
|
+ z2 = z_values[cell_dest_xi ][cell_dest_yi + 1] + xratio *
|
|
181
|
+ (z_values[cell_dest_xi + 1][cell_dest_yi + 1] - z_values[cell_dest_xi][cell_dest_yi + 1]);
|
182
|
182
|
|
183
|
|
- if ( cell_dest_xi >= GRID_MAX_POINTS_X-1) {
|
184
|
|
- z1 = 0.0;
|
185
|
|
- z2 = 0.0;
|
186
|
|
- }
|
|
183
|
+ if (cell_dest_xi >= GRID_MAX_POINTS_X - 1) z1 = z2 = 0.0;
|
187
|
184
|
|
188
|
185
|
// we are done with the fractional X distance into the cell. Now with the two Z-Heights we have calculated, we
|
189
|
186
|
// are going to apply the Y-Distance into the cell to interpolate the final Z correction.
|
190
|
187
|
|
191
|
188
|
const float yratio = (RAW_Y_POSITION(end[Y_AXIS]) - mesh_index_to_ypos(cell_dest_yi)) * (1.0 / (MESH_Y_DIST));
|
192
|
|
-
|
193
|
|
- float z0 = z1 + (z2 - z1) * yratio;
|
194
|
|
-
|
195
|
|
- if ( cell_dest_yi >= GRID_MAX_POINTS_Y-1)
|
196
|
|
- z0 = 0.0;
|
197
|
|
-
|
198
|
|
- z0 *= fade_scaling_factor_for_z(end[Z_AXIS]);
|
|
189
|
+ float z0 = cell_dest_yi < GRID_MAX_POINTS_Y - 1 ? z1 + (z2 - z1) * yratio * fade_scaling_factor_for_z(end[Z_AXIS]) : 0.0;
|
199
|
190
|
|
200
|
191
|
/**
|
201
|
192
|
* If part of the Mesh is undefined, it will show up as NAN
|