Matched ClusterExec

This commit is contained in:
mrshigure 2024-01-16 01:02:58 -08:00
parent 0ac89c38dc
commit 03f1cd89a3
9 changed files with 195 additions and 10 deletions

View file

@ -343,7 +343,7 @@ config.libs = [
Object(Matching, "game/ovllist.c"), Object(Matching, "game/ovllist.c"),
Object(NonMatching, "game/esprite.c"), Object(NonMatching, "game/esprite.c"),
Object(NonMatching, "game/code_8003FF68.c"), Object(NonMatching, "game/code_8003FF68.c"),
Object(NonMatching, "game/ClusterExec.c"), Object(Matching, "game/ClusterExec.c"),
Object(NonMatching, "game/ShapeExec.c"), Object(NonMatching, "game/ShapeExec.c"),
Object(Matching, "game/wipe.c"), Object(Matching, "game/wipe.c"),
Object(Matching, "game/window.c"), Object(Matching, "game/window.c"),

View file

@ -0,0 +1,13 @@
#ifndef _GAME_CLUSTER_EXEC_H
#define _GAME_CLUSTER_EXEC_H
#include "game/hsfformat.h"
#include "game/hsfman.h"
float GetClusterCurve(HsfTrack *arg0, float arg1);
float GetClusterWeightCurve(HsfTrack *arg0, float arg1);
void SetClusterMain(HsfCluster *arg0);
void ClusterProc(ModelData *arg0);
void ClusterMotionExec(ModelData *arg0);
#endif

View file

@ -7,4 +7,6 @@ void InitEnvelope(HsfData *arg0);
void EnvelopeProc(HsfData *arg0); void EnvelopeProc(HsfData *arg0);
void InitVtxParm(HsfData *arg0); void InitVtxParm(HsfData *arg0);
extern Vec *Vertextop;
#endif #endif

View file

@ -238,7 +238,7 @@ typedef struct hsf_cluster {
char *name[2]; char *name[2];
union { union {
char *targetName; char *targetName;
u32 target; s32 target;
}; };
HsfPart *part; HsfPart *part;
float unk10; float unk10;

View file

@ -117,8 +117,6 @@ typedef struct light_data {
GXColor color; GXColor color;
} LightData; } LightData;
extern void ClusterMotionExec(ModelData*); /* extern */
extern void ClusterProc(ModelData*); /* extern */
extern void GXWaitDrawDone(); /* extern */ extern void GXWaitDrawDone(); /* extern */
extern void ShapeProc(HsfData*); /* extern */ extern void ShapeProc(HsfData*); /* extern */
extern void GXInitSpecularDir(GXLightObj*, f32, f32, f32); extern void GXInitSpecularDir(GXLightObj*, f32, f32, f32);

174
src/game/ClusterExec.c Normal file
View file

@ -0,0 +1,174 @@
#include "game/ClusterExec.h"
#include "game/EnvelopeExec.h"
#include "game/hsfmotion.h"
float GetClusterCurve(HsfTrack *arg0, float arg1) {
float *var_r30;
switch (arg0->curveType) {
case 1:
return GetLinear(arg0->numKeyframes, arg0->data, arg1);
case 2:
return GetBezier(arg0->numKeyframes, arg0, arg1);
case 4:
var_r30 = &arg0->value;
return *var_r30;
}
return 0.0f;
}
float GetClusterWeightCurve(HsfTrack *arg0, float arg1) {
float *var_r30;
switch (arg0->curveType) {
case 1:
return GetLinear(arg0->numKeyframes, arg0->data, arg1);
case 2:
return GetBezier(arg0->numKeyframes, arg0, arg1);
case 4:
var_r30 = &arg0->value;
return *var_r30;
}
return 0.0f;
}
void SetClusterMain(HsfCluster *arg0) {
float var_f30;
float var_f31;
s32 temp_r24;
s32 temp_r29;
u16 *var_r28;
s32 var_r23;
s32 i;
s32 j;
HsfBuffer *temp_r25;
HsfPart *temp_r27;
HsfBuffer *temp_r30;
temp_r27 = arg0->part;
if (arg0->vertexCnt != 0) {
if (arg0->type == 2) {
var_r28 = temp_r27->vertex;
temp_r30 = *arg0->vertex;
var_f30 = 0.0f;
for (i = 0; i < arg0->vertexCnt; i++) {
var_f30 += arg0->unk14[i];
}
for (i = 0; i < temp_r27->count; i++, var_r28++) {
temp_r29 = *var_r28;
Vertextop[temp_r29].x = ((Vec*) temp_r30->data)[i].x;
Vertextop[temp_r29].y = ((Vec*) temp_r30->data)[i].y;
Vertextop[temp_r29].z = ((Vec*) temp_r30->data)[i].z;
}
for (i = 1; i < arg0->vertexCnt; i++) {
temp_r30 = arg0->vertex[i];
var_r28 = temp_r27->vertex;
var_f31 = arg0->unk14[i];
if (var_f31 < 0.0f) {
var_f31 = 0.0f;
} else if (var_f30 > 1.0f) {
var_f31 /= var_f30;
}
for (j = 0; j < temp_r27->count; j++, var_r28++) {
temp_r29 = *var_r28;
Vertextop[temp_r29].x += var_f31 * (((Vec*) temp_r30->data)[j].x - Vertextop[temp_r29].x);
Vertextop[temp_r29].y += var_f31 * (((Vec*) temp_r30->data)[j].y - Vertextop[temp_r29].y);
Vertextop[temp_r29].z += var_f31 * (((Vec*) temp_r30->data)[j].z - Vertextop[temp_r29].z);
}
}
return;
}
temp_r24 = arg0->unk10;
var_r23 = temp_r24 + 1;
if (var_r23 >= arg0->vertexCnt) {
var_r23 = temp_r24;
}
var_f31 = arg0->unk10 - temp_r24;
temp_r30 = arg0->vertex[temp_r24];
temp_r25 = arg0->vertex[var_r23];
var_r28 = temp_r27->vertex;
for (i = 0; i < temp_r27->count; i++, var_r28++) {
temp_r29 = *var_r28;
Vertextop[temp_r29].x = ((Vec*) temp_r30->data)[i].x + var_f31 * (((Vec*) temp_r25->data)[i].x - ((Vec*) temp_r30->data)[i].x);
Vertextop[temp_r29].y = ((Vec*) temp_r30->data)[i].y + var_f31 * (((Vec*) temp_r25->data)[i].y - ((Vec*) temp_r30->data)[i].y);
Vertextop[temp_r29].z = ((Vec*) temp_r30->data)[i].z + var_f31 * (((Vec*) temp_r25->data)[i].z - ((Vec*) temp_r30->data)[i].z);
}
}
}
void ClusterProc(ModelData *arg0) {
s32 temp_r24;
s32 i;
s32 j;
s32 k;
HsfData *temp_r27;
HsfData *temp_r23;
MotionData *temp_r22;
HsfCluster *var_r29;
HsfObject *temp_r31;
for (i = 0; i < 4; i++) {
temp_r24 = arg0->unk_10[i];
if (temp_r24 != -1) {
temp_r22 = &Hu3DMotion[temp_r24];
temp_r27 = temp_r22->unk_04;
temp_r23 = arg0->hsfData;
var_r29 = temp_r27->cluster;
for (j = 0; j < temp_r27->clusterCnt; j++, var_r29++) {
if (var_r29->target != -1) {
temp_r31 = temp_r23->object;
temp_r31 += var_r29->target;
Vertextop = temp_r31->data.vertex->data;
if (temp_r31->data.hook) {
for (k = 0; k < temp_r31->data.vertex->count; k++) {
Vertextop[k].x = ((Vec*) temp_r31->data.file[0])[k].x;
Vertextop[k].y = ((Vec*) temp_r31->data.file[0])[k].y;
Vertextop[k].z = ((Vec*) temp_r31->data.file[0])[k].z;
}
}
SetClusterMain(var_r29);
DCStoreRangeNoSync(Vertextop, temp_r31->data.vertex->count * sizeof(Vec));
temp_r31->data.unk120[0]++;
}
}
}
}
}
void ClusterMotionExec(ModelData *arg0) {
float temp_f31;
s32 i;
s32 j;
s16 var_r20;
HsfCluster *temp_r26;
HsfData *temp_r28;
HsfMotion *temp_r27;
HsfTrack *var_r31;
HsfTrack *var_r30;
MotionData *var_r23;
var_r31 = temp_r27->track;
for (i = 0; i < 4; i++) {
if (arg0->unk_10[i] != -1) {
var_r20 = arg0->unk_10[i];
var_r23 = &Hu3DMotion[var_r20];
temp_r28 = var_r23->unk_04;
temp_r27 = temp_r28->motion;
var_r31 = temp_r27->track;
temp_f31 = arg0->unk_A4[i];
for (j = 0; j < temp_r27->numTracks; j++, var_r31++) {
switch (var_r31->type) {
case 5:
temp_r26 = &temp_r28->cluster[var_r31->target_s16];
temp_r26->unk10 = GetClusterCurve(var_r31, temp_f31);
break;
case 6:
var_r30 = var_r31;
temp_r26 = &temp_r28->cluster[var_r30->target_s16];
temp_r26->unk14[var_r30->unk04] = GetClusterCurve(var_r30, temp_f31);
break;
}
}
}
}
}

View file

@ -185,8 +185,8 @@ static void SetEnvelopMain(HsfData *arg0) {
sp10 = temp_r30->data; sp10 = temp_r30->data;
spC = var_r31->data.file[0]; spC = var_r31->data.file[0];
sp8 = temp_r30->data; sp8 = temp_r30->data;
DCStoreRangeNoSync(normenv, temp_r28->count * 0xC); DCStoreRangeNoSync(normenv, temp_r28->count * sizeof(Vec));
DCStoreRangeNoSync(vtxenv, temp_r30->count * 0xC); DCStoreRangeNoSync(vtxenv, temp_r30->count * sizeof(Vec));
Meshno++; Meshno++;
} }
} }

View file

@ -1,4 +1,5 @@
#include "game/hsfman.h" #include "game/hsfman.h"
#include "game/ClusterExec.h"
#include "game/data.h" #include "game/data.h"
#include "game/EnvelopeExec.h" #include "game/EnvelopeExec.h"
#include "game/hsfdraw.h" #include "game/hsfdraw.h"

View file

@ -1,4 +1,5 @@
#include "game/hsfmotion.h" #include "game/hsfmotion.h"
#include "game/ClusterExec.h"
#include "game/EnvelopeExec.h" #include "game/EnvelopeExec.h"
#include "game/hsfdraw.h" #include "game/hsfdraw.h"
#include "game/hsfload.h" #include "game/hsfload.h"
@ -11,10 +12,6 @@
static s32 SearchObjectIndex(HsfData *arg0, u32 arg1); static s32 SearchObjectIndex(HsfData *arg0, u32 arg1);
static s32 SearchAttributeIndex(HsfData *arg0, u32 arg1); static s32 SearchAttributeIndex(HsfData *arg0, u32 arg1);
float GetClusterCurve(HsfTrack*, float);
float GetClusterWeightCurve(HsfTrack*, float);
void ClusterMotionExec(ModelData*);
void ClusterProc(ModelData*);
void ShapeProc(HsfData*); void ShapeProc(HsfData*);
MotionData Hu3DMotion[256]; MotionData Hu3DMotion[256];