summaryrefslogtreecommitdiff
path: root/src/actors/yoshi_egg/render.inc.c
blob: f39524aa34467b66e1a6e755a5e26850ace73261 (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
73
74
75
76
77
78
79
#include <camera.h>
#include <actors.h>
#include <defines.h>
#include <main.h>
#include "port/interpolation/FrameInterpolation.h"

/**
 * @brief Renders the Yoshi egg actor.
 * Actor used in Yoshi Valley.
 *
 * @param arg0
 * @param arg1
 * @param egg
 * @param arg3
 */
void render_actor_yoshi_egg(Camera* arg0, Mat4 arg1, struct YoshiValleyEgg* egg, u16 arg3) {
    Mat4 sp60;
    Vec3s sp5C;
    Vec3f sp54;
    f32 temp_f0;

    if (gGamestate != CREDITS_SEQUENCE) {
        temp_f0 = is_within_render_distance(arg0->pos, egg->pos, arg0->rot[1], 200.0f, gCameraZoom[arg0 - camera1],
                                            16000000.0f);

        if (CVarGetInteger("gNoCulling", 0) == 1) {
            temp_f0 = MAX(temp_f0, 0.0f);
        }

        if (temp_f0 < 0.0f) {
            return;
        }
    } else {
        arg3 = 15;
        temp_f0 = 0.0f;
    }

    if (CVarGetInteger("gDisableLod", 1) == 1) {
        arg3 = 15;
        temp_f0 = 0.0f;
    }

    gSPSetGeometryMode(gDisplayListHead++, G_SHADING_SMOOTH);
    if ((arg3 > 12) && (arg3 < 20)) {
        if (temp_f0 < 640000.0f) {
            sp54[0] = egg->pos[0];
            sp54[1] = 3.0f;
            sp54[2] = egg->pos[2];
            func_802976D8(sp5C);
            func_8029794C(sp54, sp5C, 10.0f);
        }
        sp5C[0] = 0;
        sp5C[1] = egg->eggRot;
        sp5C[2] = 0;

        FrameInterpolation_RecordMatrixPush(sp60);

        mtxf_pos_rotation_xyz(sp60, egg->pos, sp5C);
        if (render_set_position(sp60, 0) == 0) {
            return;
        }

        gSPSetGeometryMode(gDisplayListHead++, G_LIGHTING);
        gSPDisplayList(gDisplayListHead++, d_course_yoshi_valley_dl_16D70);
        FrameInterpolation_RecordMatrixPop(sp60);
    } else {
        arg1[3][0] = egg->pos[0];
        arg1[3][1] = egg->pos[1];
        arg1[3][2] = egg->pos[2];

        FrameInterpolation_RecordMatrixPush(arg1);

        if (render_set_position(arg1, 0) != 0) {
            gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING);
            gSPDisplayList(gDisplayListHead++, d_course_yoshi_valley_dl_egg_lod0);
        }
        FrameInterpolation_RecordMatrixPop(arg1);
    }
}