| 818 | } |
| 819 | |
| 820 | int SimplifyVertex(int x, int z, float delta) { |
| 821 | vector *eye = TS_View_position; |
| 822 | vector vec; |
| 823 | float inner; |
| 824 | |
| 825 | vec.x = x * TERRAIN_SIZE; |
| 826 | vec.z = z * TERRAIN_SIZE; |
| 827 | vec.y = Terrain_seg[z * TERRAIN_WIDTH + x].y; |
| 828 | |
| 829 | float delta_squared = delta * delta; |
| 830 | float first_part, second_part; |
| 831 | |
| 832 | float ex_minus_vx_squared = (eye->x - vec.x) * (eye->x - vec.x); |
| 833 | float ez_minus_vz_squared = (eye->z - vec.z) * (eye->z - vec.z); |
| 834 | float ey_minus_vy_squared = (eye->y - vec.y) * (eye->y - vec.y); |
| 835 | |
| 836 | first_part = delta_squared * (ex_minus_vx_squared + ez_minus_vz_squared); |
| 837 | |
| 838 | inner = ex_minus_vx_squared + ez_minus_vz_squared + ey_minus_vy_squared; |
| 839 | |
| 840 | second_part = (TS_SimplifyCondition) * (inner * inner); |
| 841 | |
| 842 | if (first_part <= second_part) |
| 843 | return 1; |
| 844 | |
| 845 | return 0; |
| 846 | } |
| 847 | |
| 848 | // Returns 1 if the given block (specified by the upper left corder x,z) lod can |
| 849 | // be simplified |