SpaghettiKart
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
7const char* sPiranhaPlantTextures[] = {
8 gTexturePiranhaPlant1,
9 gTexturePiranhaPlant2,
10 gTexturePiranhaPlant3,
11 gTexturePiranhaPlant4,
12 gTexturePiranhaPlant5,
13 gTexturePiranhaPlant6,
14 gTexturePiranhaPlant7,
15 gTexturePiranhaPlant8,
16 gTexturePiranhaPlant9
17};
18
27void render_actor_piranha_plant(Camera* camera, Mat4 arg1, struct PiranhaPlant* arg2) {
28 UNUSED s32 pad;
29 u8* addr;
30 s16 temp_lo = camera - camera1;
31 s16 animationFrame; // unconfirmed
32 s16 temp = arg2->flags;
33 f32 temp_f0;
34 s32 maxObjectsReached;
35
36 if (temp & 0x800) {
37 return;
38 }
39
40 temp_f0 = is_within_render_distance(camera->pos, arg2->pos, camera->rot[1], 0, camera->fieldOfView, 1000000.0f);
41
42 if (CVarGetInteger("gNoCulling", 0) == 1) {
43 temp_f0 = MAX(temp_f0, 0.0f);
44 }
45
46 if (temp_f0 < 0.0f) {
47
48 switch (temp_lo) {
49 case 0:
50 arg2->visibilityStates[0] = -1;
51 break;
52 case 1:
53 arg2->visibilityStates[1] = -1;
54 break;
55 case 2:
56 arg2->visibilityStates[2] = -1;
57 break;
58 case 3:
59 arg2->visibilityStates[3] = -1;
60 break;
61 }
62 return;
63 }
64 arg1[3][0] = arg2->pos[0];
65 arg1[3][1] = arg2->pos[1];
66 arg1[3][2] = arg2->pos[2];
67 maxObjectsReached = render_set_position(arg1, 0) == 0;
68 if (maxObjectsReached) {
69 return;
70 }
71
72 if (CVarGetInteger("gDisableLod", 1) == 1) {
73 temp_f0 = 0.0f;
74 }
75
76 if (90000.0f < temp_f0) {
77
78 switch (temp_lo) {
79 case 0:
80 arg2->visibilityStates[0] = 0;
81 break;
82 case 1:
83 arg2->visibilityStates[1] = 0;
84 break;
85 case 2:
86 arg2->visibilityStates[2] = 0;
87 break;
88 case 3:
89 arg2->visibilityStates[3] = 0;
90 break;
91 }
92 animationFrame = 0;
93
94 } else {
95 switch (temp_lo) {
96 case 0:
97 arg2->visibilityStates[0] = 1;
98 break;
99 case 1:
100 arg2->visibilityStates[1] = 1;
101 break;
102 case 2:
103 arg2->visibilityStates[2] = 1;
104 break;
105 case 3:
106 arg2->visibilityStates[3] = 1;
107 break;
108 }
109
110 switch (temp_lo) {
111 case 0:
112 animationFrame = arg2->timers[0];
113 break;
114 case 1:
115 animationFrame = arg2->timers[1];
116 break;
117 case 2:
118 animationFrame = arg2->timers[2];
119 break;
120 case 3:
121 animationFrame = arg2->timers[3];
122 break;
123 }
124 }
125 animationFrame /= 6;
126
127 if (animationFrame > 8) {
128 animationFrame = 8;
129 }
130 gDPLoadTextureBlock(gDisplayListHead++, sPiranhaPlantTextures[animationFrame], G_IM_FMT_CI, G_IM_SIZ_8b, 32, 64, 0,
131 G_TX_MIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD,
132 G_TX_NOLOD);
133
134 if (IsMarioRaceway()) {
135 gSPDisplayList(gDisplayListHead++, &d_course_mario_raceway_dl_piranha_plant);
136 } else {
137 gSPDisplayList(gDisplayListHead++, &d_course_royal_raceway_dl_piranha_plant);
138 }
139}
void gSPDisplayList(Gfx *pkt, Gfx *dl)
Definition GBIMiddleware.cpp:12
bool IsMarioRaceway()
Definition Game.cpp:830
Camera * camera1
Definition camera.c:30
f32 Mat4[4][4]
Definition common_structs.h:20
#define UNUSED
Definition macros.h:40
#define MAX(a, b)
Definition macros.h:144
Gfx * gDisplayListHead
Definition main.c:129
s32 render_set_position(Mat4 mtx, s32 arg1)
Definition math_util.c:53
f32 is_within_render_distance(Vec3f cameraPos, Vec3f objectPos, u16 orientationY, f32 minDistance, f32 fov, f32 maxDistance)
Definition math_util.c:1099
void render_actor_piranha_plant(Camera *camera, Mat4 arg1, struct PiranhaPlant *arg2)
Renders the piranha plant actor. Actor used in Mario Raceway and Royal Raceway.
Definition render.inc.c:27
const char * sPiranhaPlantTextures[]
Definition render.inc.c:7
Definition camera.h:35
Vec3s rot
Definition camera.h:42
f32 fieldOfView
Definition camera.h:43
Vec3f pos
Definition camera.h:36
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