summaryrefslogtreecommitdiff
path: root/src/actors/falling_rock/render.inc.c
blob: 27a5bb55a38314031751f5400f3ab0d8335421ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <racing/actors.h>
#include <main.h>
#include <assets/models/tracks/choco_mountain/choco_mountain_data.h>
#include "port/interpolation/FrameInterpolation.h"

/**
 * @brief Renders the falling rock actor.
 * Actor used in Choco Mountain.
 *
 * @param camera
 * @param rock
 */
void render_actor_falling_rock(Camera* camera, struct FallingRock* rock) {
    Vec3s sp98;
    Vec3f sp8C;
    Mat4 mtx;
    f32 height;
    UNUSED s32 pad[4];

    return; // No longer used. Use the C++ actor!

    if (rock->respawnTimer != 0) {
        return;
    }

    height = is_within_render_distance(camera->pos, rock->pos, camera->rot[1], 400.0f, camera->fieldOfView,
                                       4000000.0f);

    if (CVarGetInteger("gNoCulling", 0) == 1) {
        height = CLAMP(height, 0.0f, 250000.0f);
    }

    if (height < 0.0f) {
        return;
    }

    if (height < 250000.0f) {

        if (rock->unk30.unk34 == 1) {
            sp8C[0] = rock->pos[0];
            sp8C[2] = rock->pos[2];
            height = calculate_surface_height(sp8C[0], rock->pos[1], sp8C[2], rock->unk30.meshIndexZX);
            sp98[0] = 0;
            sp98[1] = 0;
            sp98[2] = 0;
            sp8C[1] = height + 2.0f;

            FrameInterpolation_RecordOpenChild("rock_shadow", (uintptr_t) rock);
            mtxf_pos_rotation_xyz(mtx, sp8C, sp98);
            if (render_set_position(mtx, 0) == 0) {
                FrameInterpolation_RecordCloseChild();
                return;
            }
            gSPDisplayList(gDisplayListHead++, d_course_choco_mountain_dl_6F88);
            FrameInterpolation_RecordCloseChild();
        }
    }

    // @port: Tag the transform.
    FrameInterpolation_RecordOpenChild("rock", (uintptr_t) rock);

    mtxf_pos_rotation_xyz(mtx, rock->pos, rock->rot);
    if (render_set_position(mtx, 0) == 0) {
        // @port Pop the transform id.
        FrameInterpolation_RecordCloseChild();
        return;
    }
    gSPDisplayList(gDisplayListHead++, d_course_choco_mountain_dl_falling_rock);

    // @port Pop the transform id.
    FrameInterpolation_RecordCloseChild();
}