z_skin and z_skin_awb OK and documented a bit (#415)

* oot copypaste

* func_8013859C non matching and func_80138700

* protos

* the other functions

* func_80138300

* progress

* func_80137F58

* func_80137EBC

* func_80137B34 NON_MATCHING

* func_80137970

* func_8013835C

* z64skin

* some docs

* some bits

* Match func_80137B34

* Match Skin_DrawImpl

* Match Skin_Init tahnks to Anon

* Some docs?

* AnimatedLimb

* SkinVtx

* more names

* fix merge issue

* format

* another clean

* trailing comma

* cleanup

* format

* add some descriptions

* Import bss

* last cleanup

* Update ZAPD symbol map

* Reanme gIdentityMtx and gIdentityMtxF

* fix merge issues

* bss

* review

* Update include/z64skin.h

Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>

* bss

* Port @fig02 skin docs

* format and a few changes

* format

* Port over OoT review

* fixes

* Engineer's review

* format

* address pr

* Fix bss

* fix bss

* Update src/code/z_skin_awb.c

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>

* bss

* bss

* undo

* pr

* Skin_Setup

Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>
Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>
This commit is contained in:
Anghelo Carvajal
2022-03-23 17:30:34 -04:00
committed by GitHub
co-authored by Derek Hensley engineer124
parent f1560614d6
commit 92c4d42f44
20 changed files with 618 additions and 126 deletions
+4 -19
View File
@@ -1388,7 +1388,7 @@ s32 func_800E9138(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s*
s32 func_800E9250(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* param_4, Vec3f param_5);
void SaveContext_Init(void);
void GameInfo_Init(void);
// void func_800E9470(void);
// void DebugDisplay_Init(void);
DebugDispObject* DebugDisplay_AddObject(f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, f32 scaleX, f32 scaleY, f32 scaleZ, u8 red, u8 green, u8 blue, u8 alpha, s16 type, GraphicsContext* gfxCtx);
// void func_800E9C90(void);
// void func_800E9CA0(s32 param_1, UNK_TYPE1 param_2, s8* param_3);
@@ -2386,7 +2386,7 @@ s32 Animation_OnFrameImpl(SkelAnime* skelAnime, f32 frame, f32 updateRate);
s32 LinkAnimation_OnFrame(SkelAnime* skelAnime, f32 frame);
void SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount);
void SkelAnime_InitFlex(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount);
void SkelAnime_InitSkin(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation);
void SkelAnime_InitSkin(GameState* gameState, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animationSeg);
void SkelAnime_SetUpdate(SkelAnime* skelAnime);
s32 SkelAnime_Update(SkelAnime* skelAnime);
s32 SkelAnime_Morph(SkelAnime* skelAnime);
@@ -2411,23 +2411,7 @@ void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* pos, s16 angle);
s32 Animation_OnFrame(SkelAnime* skelAnime, f32 frame);
void SkelAnime_Free(SkelAnime* skelAnime, GlobalContext* globalCtx);
void SkelAnime_CopyFrameTable(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src);
// void func_80137970(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5);
// void func_80137B34(void);
// void func_80137EBC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5);
// void func_80137F58(void);
// void func_80138050(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8);
// void func_80138228(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5);
// void func_80138258(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6);
// void func_8013828C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7);
// void func_801382C4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8);
// void func_80138300(void);
// void func_8013835C(void);
// void func_80138410(void);
// void func_80138424(void);
// void func_8013859C(void);
// void func_80138700(void);
// void func_801387D4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5);
// void func_801388E4(void);
void SkinMatrix_Vec3fMtxFMultXYZW(MtxF* mf, Vec3f* src, Vec3f* xyzDest, f32* wDest);
void SkinMatrix_Vec3fMtxFMultXYZ(MtxF* mf, Vec3f* src, Vec3f* dest);
void SkinMatrix_MtxFMtxFMult(MtxF* mfB, MtxF* mfA, MtxF* dest);
@@ -2452,6 +2436,7 @@ void SkinMatrix_MulXRotation(MtxF* mf, s16 a);
void SkinMatrix_SetYRotation(MtxF* mf, s16 a);
void SkinMatrix_MulYRotation(MtxF* mf, s16 a);
void SkinMatrix_SetZRotation(MtxF* mf, s16 a);
s32 func_8013A240(GlobalContext* globalCtx);
void func_8013A41C(s32 flag);
void func_8013A46C(s32 flag);
-3
View File
@@ -1616,8 +1616,6 @@ extern Vec3f gZeroVec3f;
extern Vec3s gZeroVec3s;
extern Mtx gIdentityMtx;
extern MtxF gIdentityMtxF;
// extern u64* initialgspUcodeText;
// extern u64* initialgspUcodeData;
// extern UNK_TYPE1 D_801D1E70;
// extern UNK_TYPE1 gLowPassFilterData;
// extern UNK_TYPE1 gHighPassFilterData;
@@ -3268,7 +3266,6 @@ extern LightsBuffer sLightsBuffer;
// extern UNK_TYPE1 D_801F59F0;
// extern UNK_TYPE1 D_801F59F4;
// extern UNK_TYPE1 D_801F59F8;
// extern UNK_TYPE1 D_801F5AC0;
// extern UNK_TYPE1 D_801F69D0;
// extern UNK_TYPE1 D_801F6A10;
// extern UNK_TYPE1 D_801F6AD4;
+2 -1
View File
@@ -36,8 +36,9 @@
#include "z64object.h"
#include "z64ocarina.h"
#include "z64player.h"
#include "z64scene.h"
#include "z64save.h"
#include "z64scene.h"
#include "z64skin.h"
#include "z64transition.h"
#include "regs.h"
+3 -48
View File
@@ -1,5 +1,5 @@
#ifndef _Z64_ANIMATION_H
#define _Z64_ANIMATION_H
#ifndef Z64_ANIMATION_H
#define Z64_ANIMATION_H
#include "PR/ultratypes.h"
#include "PR/gbi.h"
@@ -28,7 +28,7 @@ typedef enum {
} AnimationModes;
typedef enum {
/* -1 */ ANIMTAPER_DECEL = -1,
/* -1 */ ANIMTAPER_DECEL = -1,
/* 0 */ ANIMTAPER_NONE,
/* 1 */ ANIMTAPER_ACCEL
} AnimationTapers;
@@ -49,14 +49,6 @@ typedef struct {
/* 0x08 */ Gfx* dLists[2]; // Near and far
} LodLimb; // size = 0x10
typedef struct {
/* 0x00 */ Vec3s jointPos; // Root is position in model space, children are relative to parent
/* 0x06 */ u8 child;
/* 0x07 */ u8 sibling;
/* 0x08 */ s32 unk_8; // Type of data contained in segment
/* 0x0C */ void* segment; // Segment address of data. Currently unclear what.
} SkinLimb; // size = 0x10
// Model has limbs with only rigid meshes
typedef struct {
/* 0x00 */ void** segment;
@@ -279,43 +271,6 @@ typedef s32 (*OverrideCurveLimbDraw)(struct GlobalContext* globalCtx, SkelAnimeC
typedef void (*PostCurveLimbDraw)(struct GlobalContext* globalCtx, SkelAnimeCurve* skelCuve, s32 limbIndex,
struct Actor* actor);
// TODO the name of this struct is imported from OoT and cannot change until the ZAPD name also changes
typedef struct {
/* 0x000 */ u16 unk_0;
/* 0x002 */ s16 unk_2;
/* 0x004 */ s16 unk_4;
/* 0x006 */ s8 unk_6;
/* 0x007 */ s8 unk_7;
/* 0x008 */ s8 unk_8;
/* 0x009 */ u8 unk_9;
} Struct_800A57C0; // size = 0xA
// TODO the name of this struct is imported from OoT and cannot change until the ZAPD name also changes
typedef struct {
/* 0x000 */ u8 unk_0;
/* 0x002 */ s16 x;
/* 0x004 */ s16 y;
/* 0x006 */ s16 z;
/* 0x008 */ u8 unk_8;
} Struct_800A598C_2; // size = 0xA
// TODO the name of this struct is imported from OoT and cannot change until the ZAPD name also changes
typedef struct {
/* 0x000 */ u16 unk_0;
/* 0x002 */ u16 unk_2;
/* 0x004 */ u16 unk_4;
/* 0x008 */ Struct_800A57C0* unk_8;
/* 0x00C */ Struct_800A598C_2* unk_C;
} Struct_800A598C; // size = 0x10
// TODO the name of this struct is imported from OoT and cannot change until the ZAPD name also changes
typedef struct {
/* 0x000 */ u16 unk_0;
/* 0x002 */ u16 unk_2;
/* 0x004 */ Struct_800A598C* unk_4;
/* 0x008 */ Gfx* unk_8;
} Struct_800A5E28; // size = 0xC
typedef struct {
/* 0x00 */ AnimationHeader* animation;
/* 0x04 */ f32 playSpeed;
+106
View File
@@ -0,0 +1,106 @@
#ifndef Z64_SKIN_H
#define Z64_SKIN_H
#include "z64animation.h"
struct GraphicsContext;
struct GameState;
struct GlobalContext;
/**
* Holds a compact version of a vertex used in the Skin system (doesn't has the x, y, z positions or the flag member)
* It is used to initialise the Vtx used by an animated limb
*/
typedef struct {
/* 0x0 */ u16 index;
/* 0x2 */ s16 s; // s and t are texture coordinates (also known as u and v)
/* 0x4 */ s16 t;
/* 0x6 */ s8 normX;
/* 0x7 */ s8 normY;
/* 0x8 */ s8 normZ;
/* 0x9 */ u8 alpha;
} SkinVertex; // size = 0xA
/**
* Describes a position displacement and a scale to be applied to a limb at index `limbIndex`
*/
typedef struct {
/* 0x0 */ u8 limbIndex;
/* 0x2 */ s16 x;
/* 0x4 */ s16 y;
/* 0x6 */ s16 z;
/* 0x8 */ u8 scale;
} SkinTransformation; // size = 0xA
typedef struct {
/* 0x00 */ u16 vtxCount; // number of vertices in this modif entry
/* 0x02 */ u16 transformCount;
/* 0x04 */ u16 unk_04; // index of limbTransformations
/* 0x08 */ SkinVertex* skinVertices;
/* 0x0C */ SkinTransformation* limbTransformations;
} SkinLimbModif; // size = 0x10
typedef struct {
/* 0x00 */ u16 totalVtxCount; // total vertex count for all modif entries
/* 0x02 */ u16 limbModifCount; // count of limbModifCount
/* 0x04 */ SkinLimbModif* limbModifications;
/* 0x08 */ Gfx* dlist;
} SkinAnimatedLimbData; // size = 0xC
// ZAPD compatibility typedefs
// TODO: Remove when ZAPD adds support for them
typedef SkinVertex Struct_800A57C0;
typedef SkinTransformation Struct_800A598C_2;
typedef SkinAnimatedLimbData Struct_800A5E28;
typedef SkinLimbModif Struct_800A598C;
#define SKIN_LIMB_TYPE_ANIMATED 4
#define SKIN_LIMB_TYPE_NORMAL 11
typedef struct {
/* 0x00 */ Vec3s jointPos; // Root is position in model space, children are relative to parent
/* 0x06 */ u8 child;
/* 0x07 */ u8 sibling;
/* 0x08 */ s32 segmentType; // Type of data contained in segment
/* 0x0C */ void* segment; // Gfx* if segmentType is SKIN_LIMB_TYPE_NORMAL, SkinAnimatedLimbData if segmentType is SKIN_LIMB_TYPE_ANIMATED, NULL otherwise
} SkinLimb; // size = 0x10
typedef struct {
/* 0x0 */ u8 index; // alternates every draw cycle
/* 0x4 */ Vtx* buf[2]; // number of vertices in buffer determined by `totalVtxCount`
} SkinLimbVtx; // size = 0xC
typedef struct {
/* 0x000 */ SkeletonHeader* skeletonHeader;
/* 0x004 */ MtxF mtx;
/* 0x044 */ s32 limbCount;
/* 0x048 */ SkinLimbVtx* vtxTable; // double buffered list of vertices for each limb
/* 0x04C */ SkelAnime skelAnime;
} Skin; // size = 0x90
typedef void (*SkinPostDraw)(struct Actor*, struct GlobalContext*, Skin*);
typedef s32 (*SkinOverrideLimbDraw)(struct Actor*, struct GlobalContext*, s32, Skin*);
#define SKIN_DRAW_FLAG_CUSTOM_TRANSFORMS (1 << 0)
#define SKIN_DRAW_FLAG_CUSTOM_MATRIX (1 << 1)
void Skin_UpdateVertices(MtxF* mtx, SkinVertex* skinVertices, SkinLimbModif* modifEntry, Vtx* vtxBuf, Vec3f* pos);
void Skin_ApplyLimbModifications(struct GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, s32 arg3);
void Skin_DrawAnimatedLimb(struct GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, s32 arg3, s32 drawFlags);
void Skin_DrawLimb(struct GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, Gfx* dListOverride, s32 drawFlags);
void func_80138228(Actor* actor, struct GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, s32 setTranslation);
void func_80138258(Actor* actor, struct GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation);
void func_8013828C(Actor* actor, struct GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6);
void func_801382C4(Actor* actor, struct GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6, s32 drawFlags);
void Skin_GetLimbPos(Skin* skin, s32 limbIndex, Vec3f* offset, Vec3f* dst);
void Skin_GetVertexPos(Skin* skin, s32 limbIndex, s32 vtxIndex, Vec3f* dst);
void Skin_Setup(Skin* skin);
void Skin_InitAnimatedLimb(struct GameState* gameState, Skin* skin, s32 limbIndex);
void Skin_Init(struct GameState* gameState, Skin* skin, SkeletonHeader* skeletonHeader, AnimationHeader* animationHeader);
void Skin_Free(struct GameState* gameState, Skin* skin);
s32 func_801387D4(Skin* skin, SkinLimb** skeleton, MtxF* limbMatrices, u8 parentIndex, u8 limbIndex);
s32 Skin_ApplyAnimTransformations(Skin* skin, MtxF* limbMatrices, Actor* actor, s32 setTranslation);
#endif