mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
Add remote players to mirror
This commit is contained in:
parent
bb30d28be9
commit
c98edbcb4b
2 changed files with 55 additions and 40 deletions
|
|
@ -70,7 +70,7 @@ static s8 gMarioAttackScaleAnimation[3 * 6] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MarioBodyState gBodyStates[MAX_PLAYERS];
|
struct MarioBodyState gBodyStates[MAX_PLAYERS];
|
||||||
struct GraphNodeObject gMirrorMario; // copy of Mario's geo node for drawing mirror Mario
|
struct GraphNodeObject gMirrorMario[MAX_PLAYERS]; // copy of Mario's geo node for drawing mirror Mario
|
||||||
|
|
||||||
// This whole file is weirdly organized. It has to be the same file due
|
// This whole file is weirdly organized. It has to be the same file due
|
||||||
// to rodata boundaries and function aligns, which means the programmer
|
// to rodata boundaries and function aligns, which means the programmer
|
||||||
|
|
@ -319,6 +319,12 @@ static Gfx *make_gfx_mario_alpha(struct GraphNodeGenerated *node, s16 alpha) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static u8 geo_get_processing_object_index(void) {
|
static u8 geo_get_processing_object_index(void) {
|
||||||
|
// sloppy way to fix mirror marios
|
||||||
|
for (int i = 0; i < MAX_PLAYERS; i++) {
|
||||||
|
if ((struct GraphNodeObject*)gCurGraphNodeObject == &gMirrorMario[i]) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (gCurGraphNodeProcessingObject == NULL) { return 0; }
|
if (gCurGraphNodeProcessingObject == NULL) { return 0; }
|
||||||
u8 index = gCurGraphNodeProcessingObject->oBehParams - 1;
|
u8 index = gCurGraphNodeProcessingObject->oBehParams - 1;
|
||||||
return (index >= MAX_PLAYERS) ? 0 : index;
|
return (index >= MAX_PLAYERS) ? 0 : index;
|
||||||
|
|
@ -625,45 +631,47 @@ Gfx* geo_switch_mario_hand_grab_pos(s32 callContext, struct GraphNode* b, Mat4*
|
||||||
* a mirror image of the player.
|
* a mirror image of the player.
|
||||||
*/
|
*/
|
||||||
Gfx* geo_render_mirror_mario(s32 callContext, struct GraphNode* node, UNUSED Mat4* c) {
|
Gfx* geo_render_mirror_mario(s32 callContext, struct GraphNode* node, UNUSED Mat4* c) {
|
||||||
f32 mirroredX;
|
for (int i = 0; i < MAX_PLAYERS; i++) {
|
||||||
struct MarioState* marioState = geo_get_mario_state();
|
f32 mirroredX;
|
||||||
struct Object* mario = marioState->marioObj;
|
struct MarioState* marioState = &gMarioStates[i];
|
||||||
|
struct Object* mario = marioState->marioObj;
|
||||||
|
|
||||||
switch (callContext) {
|
switch (callContext) {
|
||||||
case GEO_CONTEXT_CREATE:
|
case GEO_CONTEXT_CREATE:
|
||||||
init_graph_node_object(NULL, &gMirrorMario, NULL, gVec3fZero, gVec3sZero, gVec3fOne);
|
init_graph_node_object(NULL, &gMirrorMario[i], NULL, gVec3fZero, gVec3sZero, gVec3fOne);
|
||||||
break;
|
break;
|
||||||
case GEO_CONTEXT_AREA_LOAD:
|
case GEO_CONTEXT_AREA_LOAD:
|
||||||
geo_add_child(node, &gMirrorMario.node);
|
geo_add_child(node, &gMirrorMario[i].node);
|
||||||
break;
|
break;
|
||||||
case GEO_CONTEXT_AREA_UNLOAD:
|
case GEO_CONTEXT_AREA_UNLOAD:
|
||||||
geo_remove_child(&gMirrorMario.node);
|
geo_remove_child(&gMirrorMario[i].node);
|
||||||
break;
|
break;
|
||||||
case GEO_CONTEXT_RENDER:
|
case GEO_CONTEXT_RENDER:
|
||||||
if (mario->header.gfx.pos[0] > 1700.0f) {
|
if (mario->header.gfx.pos[0] > 1700.0f) {
|
||||||
// TODO: Is this a geo layout copy or a graph node copy?
|
// TODO: Is this a geo layout copy or a graph node copy?
|
||||||
gMirrorMario.sharedChild = mario->header.gfx.sharedChild;
|
gMirrorMario[i].sharedChild = mario->header.gfx.sharedChild;
|
||||||
gMirrorMario.unk18 = mario->header.gfx.unk18;
|
gMirrorMario[i].unk18 = mario->header.gfx.unk18;
|
||||||
vec3s_copy(gMirrorMario.angle, mario->header.gfx.angle);
|
vec3s_copy(gMirrorMario[i].angle, mario->header.gfx.angle);
|
||||||
vec3f_copy(gMirrorMario.pos, mario->header.gfx.pos);
|
vec3f_copy(gMirrorMario[i].pos, mario->header.gfx.pos);
|
||||||
vec3f_copy(gMirrorMario.scale, mario->header.gfx.scale);
|
vec3f_copy(gMirrorMario[i].scale, mario->header.gfx.scale);
|
||||||
// FIXME: why does this set unk38, an inline struct, to a ptr to another one? wrong
|
// FIXME: why does this set unk38, an inline struct, to a ptr to another one? wrong
|
||||||
// GraphNode types again?
|
// GraphNode types again?
|
||||||
gMirrorMario.unk38 = *(struct GraphNodeObject_sub*) & mario->header.gfx.unk38.animID;
|
gMirrorMario[i].unk38 = *(struct GraphNodeObject_sub*) & mario->header.gfx.unk38.animID;
|
||||||
mirroredX = MIRROR_X - gMirrorMario.pos[0];
|
mirroredX = MIRROR_X - gMirrorMario[i].pos[0];
|
||||||
gMirrorMario.pos[0] = mirroredX + MIRROR_X;
|
gMirrorMario[i].pos[0] = mirroredX + MIRROR_X;
|
||||||
gMirrorMario.angle[1] = -gMirrorMario.angle[1];
|
gMirrorMario[i].angle[1] = -gMirrorMario[i].angle[1];
|
||||||
gMirrorMario.scale[0] *= -1.0f;
|
gMirrorMario[i].scale[0] *= -1.0f;
|
||||||
// FIXME: Why doesn't this match?
|
// FIXME: Why doesn't this match?
|
||||||
// gMirrorMario.node.flags |= 1;
|
// gMirrorMario.node.flags |= 1;
|
||||||
((s16*)&gMirrorMario)[1] |= 1;
|
((s16*)&gMirrorMario[i])[1] |= 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// FIXME: Why doesn't this match?
|
||||||
|
// gMirrorMario.node.flags &= ~1;
|
||||||
|
((s16*)&gMirrorMario[i])[1] &= ~1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// FIXME: Why doesn't this match?
|
|
||||||
// gMirrorMario.node.flags &= ~1;
|
|
||||||
((s16*)&gMirrorMario)[1] &= ~1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -676,7 +684,14 @@ Gfx* geo_mirror_mario_backface_culling(s32 callContext, struct GraphNode* node,
|
||||||
struct GraphNodeGenerated* asGenerated = (struct GraphNodeGenerated*) node;
|
struct GraphNodeGenerated* asGenerated = (struct GraphNodeGenerated*) node;
|
||||||
Gfx* gfx = NULL;
|
Gfx* gfx = NULL;
|
||||||
|
|
||||||
if (callContext == GEO_CONTEXT_RENDER && gCurGraphNodeObject == &gMirrorMario) {
|
u8 isMirrorMario = FALSE;
|
||||||
|
for (int i = 0; i < MAX_PLAYERS; i++) {
|
||||||
|
if (gCurGraphNodeObject == &gMirrorMario[i]) {
|
||||||
|
isMirrorMario = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (callContext == GEO_CONTEXT_RENDER && isMirrorMario) {
|
||||||
gfx = alloc_display_list(3 * sizeof(*gfx));
|
gfx = alloc_display_list(3 * sizeof(*gfx));
|
||||||
|
|
||||||
if (asGenerated->parameter == 0) {
|
if (asGenerated->parameter == 0) {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
extern struct GraphNodeObject gMirrorMario;
|
extern struct GraphNodeObject gMirrorMario[MAX_PLAYERS];
|
||||||
extern struct MarioBodyState gBodyStates[MAX_PLAYERS];
|
extern struct MarioBodyState gBodyStates[MAX_PLAYERS];
|
||||||
|
|
||||||
Gfx *geo_draw_mario_head_goddard(s32 callContext, struct GraphNode *node, Mat4 *c);
|
Gfx *geo_draw_mario_head_goddard(s32 callContext, struct GraphNode *node, Mat4 *c);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue