Mario Kart 64
Loading...
Searching...
No Matches
render.inc.c
Go to the documentation of this file.
1#include <actors.h>
2#include <main.h>
3#include <libultra/gbi.h>
6
15void render_actor_piranha_plant(Camera* arg0, Mat4 arg1, struct PiranhaPlant* arg2) {
16 UNUSED s32 pad;
17 u8* addr;
18 s16 temp_lo = arg0 - camera1;
19 s16 animationFrame; // unconfirmed
20 s16 temp = arg2->flags;
21 f32 temp_f0;
22 s32 maxObjectsReached;
23
24 if (temp & 0x800) {
25 return;
26 }
27
28 temp_f0 = is_within_render_distance(arg0->pos, arg2->pos, arg0->rot[1], 0, gCameraZoom[arg0 - camera1], 1000000.0f);
29
30 if (CVarGetInteger("gNoCulling", 0) == 1) {
31 temp_f0 = MAX(temp_f0, 0.0f);
32 }
33
34 if (temp_f0 < 0.0f) {
35
36 switch (temp_lo) {
37 case 0:
38 arg2->visibilityStates[0] = -1;
39 break;
40 case 1:
41 arg2->visibilityStates[1] = -1;
42 break;
43 case 2:
44 arg2->visibilityStates[2] = -1;
45 break;
46 case 3:
47 arg2->visibilityStates[3] = -1;
48 break;
49 }
50 return;
51 }
52 arg1[3][0] = arg2->pos[0];
53 arg1[3][1] = arg2->pos[1];
54 arg1[3][2] = arg2->pos[2];
55 maxObjectsReached = render_set_position(arg1, 0) == 0;
56 if (maxObjectsReached) {
57 return;
58 }
59
60 if (CVarGetInteger("gDisableLod", 1) == 1) {
61 temp_f0 = 0.0f;
62 }
63
64 if (90000.0f < temp_f0) {
65
66 switch (temp_lo) {
67 case 0:
68 arg2->visibilityStates[0] = 0;
69 break;
70 case 1:
71 arg2->visibilityStates[1] = 0;
72 break;
73 case 2:
74 arg2->visibilityStates[2] = 0;
75 break;
76 case 3:
77 arg2->visibilityStates[3] = 0;
78 break;
79 }
80 animationFrame = 0;
81
82 } else {
83 switch (temp_lo) {
84 case 0:
85 arg2->visibilityStates[0] = 1;
86 break;
87 case 1:
88 arg2->visibilityStates[1] = 1;
89 break;
90 case 2:
91 arg2->visibilityStates[2] = 1;
92 break;
93 case 3:
94 arg2->visibilityStates[3] = 1;
95 break;
96 }
97
98 switch (temp_lo) {
99 case 0:
100 animationFrame = arg2->timers[0];
101 break;
102 case 1:
103 animationFrame = arg2->timers[1];
104 break;
105 case 2:
106 animationFrame = arg2->timers[2];
107 break;
108 case 3:
109 animationFrame = arg2->timers[3];
110 break;
111 }
112 }
113 animationFrame /= 6;
114
115 if (animationFrame > 8) {
116 animationFrame = 8;
117 }
118 addr = D_802BA058 + (animationFrame << 0xB);
119 gDPLoadTextureBlock(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(addr), G_IM_FMT_CI, G_IM_SIZ_8b, 32, 64, 0,
120 G_TX_MIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD,
121 G_TX_NOLOD);
122
123 if (IsMarioRaceway()) {
124 gSPDisplayList(gDisplayListHead++, &d_course_mario_raceway_dl_piranha_plant);
125 } else {
126 gSPDisplayList(gDisplayListHead++, &d_course_royal_raceway_dl_piranha_plant);
127 }
128}
void gSPDisplayList(Gfx *pkt, Gfx *dl)
Definition GBIMiddleware.cpp:11
bool IsMarioRaceway()
Definition Game.cpp:720
u8 * D_802BA058
Definition actors.c:53
Camera * camera1
Definition camera.c:29
f32 Mat4[4][4]
Definition common_structs.h:20
#define UNUSED
Definition macros.h:26
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:91
#define MAX(a, b)
Definition macros.h:130
Gfx * gDisplayListHead
Definition main.c:136
f32 gCameraZoom[4]
Definition main.c:126
s32 render_set_position(Mat4 mtx, s32 arg1)
Definition math_util.c:54
f32 is_within_render_distance(Vec3f cameraPos, Vec3f objectPos, u16 orientationY, f32 minDistance, f32 fov, f32 maxDistance)
Definition math_util.c:1100
void render_actor_piranha_plant(Camera *arg0, Mat4 arg1, struct PiranhaPlant *arg2)
Renders the piranha plant actor. Actor used in Mario Raceway and Royal Raceway.
Definition render.inc.c:15
Definition camera.h:27
Vec3s rot
Definition camera.h:34
Vec3f pos
Definition camera.h:28
Definition actor_types.h:275
Vec4s visibilityStates
Definition actor_types.h:278
Vec4s timers
Definition actor_types.h:282
s16 flags
Definition actor_types.h:277
Vec3f pos
Definition actor_types.h:281