| 2464 | // appear with cracks |
| 2465 | vector Terrain_alter_vec = {19, -19, 19}; |
| 2466 | void RotateTerrainList(int cellcount, bool from_automap) { |
| 2467 | int lod, simplemul, edgecount; |
| 2468 | int i, n[200], t, k, cx, cz; |
| 2469 | vector camlight = Terrain_sky.lightsource; |
| 2470 | vm_NormalizeVector(&camlight); |
| 2471 | // Reset all modified y values for the corners of each cell |
| 2472 | for (i = 0; i < cellcount; i++) { |
| 2473 | int ax, az; |
| 2474 | t = Terrain_list[i].segment; |
| 2475 | lod = Terrain_list[i].lod; |
| 2476 | simplemul = 1 << ((MAX_TERRAIN_LOD - 1) - lod); |
| 2477 | cx = t & (TERRAIN_WIDTH - 1); |
| 2478 | cz = t >> 8; |
| 2479 | |
| 2480 | ax = az = simplemul; |
| 2481 | |
| 2482 | if (cx + ax >= TERRAIN_WIDTH) |
| 2483 | ax = (TERRAIN_WIDTH - 1) - cx; |
| 2484 | if (cz + az >= TERRAIN_DEPTH) |
| 2485 | az = (TERRAIN_DEPTH - 1) - cz; |
| 2486 | |
| 2487 | n[0] = t; |
| 2488 | n[1] = t + (TERRAIN_WIDTH * az); |
| 2489 | n[2] = t + (az * TERRAIN_WIDTH) + ax; |
| 2490 | n[3] = t + ax; |
| 2491 | // This could be in a loop, but I unrolled it for speed |
| 2492 | Terrain_seg[n[0]].mody = Terrain_seg[n[0]].y; |
| 2493 | Terrain_seg[n[1]].mody = Terrain_seg[n[1]].y; |
| 2494 | Terrain_seg[n[2]].mody = Terrain_seg[n[2]].y; |
| 2495 | Terrain_seg[n[3]].mody = Terrain_seg[n[3]].y; |
| 2496 | if (StateLimited || from_automap) // Setup for sorting later |
| 2497 | { |
| 2498 | int unique_id; |
| 2499 | unique_id = Terrain_tex_seg[Terrain_seg[t].texseg_index].tex_index; |
| 2500 | State_elements[i].facenum = i; |
| 2501 | State_elements[i].sort_key = unique_id + (Terrain_seg[t].lm_quad << 24); |
| 2502 | } |
| 2503 | } |
| 2504 | for (i = 0; i < cellcount; i++) { |
| 2505 | edgecount = BuildEdgeLists(n, i); |
| 2506 | for (k = 0; k < edgecount; k++) { |
| 2507 | if (Terrain_rotate_list[n[k]] != TS_FrameCount) { |
| 2508 | Terrain_rotate_list[n[k]] = TS_FrameCount; |
| 2509 | GlobalTransCount++; |
| 2510 | |
| 2511 | cx = n[k] % TERRAIN_WIDTH; |
| 2512 | cz = n[k] / TERRAIN_WIDTH; |
| 2513 | |
| 2514 | World_point_buffer[n[k]].p3_flags = PF_UV | PF_UV2; |
| 2515 | if (Terrain_seg[n[k]].mody == Terrain_seg[n[k]].y) { |
| 2516 | GetPreRotatedPoint(&World_point_buffer[n[k]], cx, cz, Terrain_seg[n[k]].ypos); |
| 2517 | } else { |
| 2518 | GetSpecialRotatedPoint(&World_point_buffer[n[k]], cx, cz, Terrain_seg[n[k]].mody); |
| 2519 | } |
| 2520 | |
| 2521 | if (Viewer_object->effect_info && (Viewer_object->effect_info->type_flags & EF_DEFORM)) { |
| 2522 | float val = (((ps_rand() % 1000) - 500.0f) / 500.0f) * Viewer_object->effect_info->deform_time; |
| 2523 | vector jitterVec = Terrain_alter_vec * (Viewer_object->effect_info->deform_range * val); |
no test coverage detected