mirror of
https://github.com/zeldaret/tww.git
synced 2026-06-20 23:51:19 -04:00
ea7c107eb7
* Add `l_matDL` symbols and assets to config files for all regions for d_menu_cloth * Extend `daCLOTH_HIO_c` with `JORReflexible` and add static instance `l_HIO` in `d_menu_cloth` * Refactor `d_menu_cloth.h` to improve naming consistency for member variables. * Initialize `dMCloth_c` member variables and create HIO child in constructor * Include `l_matDL` in `d_menu_cloth` and call it in `dMCloth_c::draw`. * Add private member variables to `daCLOTH_HIO_c` in `d_menu_cloth.h` * Add virtual destructor to `daCLOTH_HIO_c` in `d_menu_cloth.h` * Swap `daCLOTH_HIO_c` and `daCLOTH_ChildHIO_c` class definitions and adjust member variables in `d_menu_cloth.h`. * Remove non-matching comments from `daCLOTH_ChildHIO_c` constructor and destructor in `d_menu_cloth.cpp`. * Initialize `daCLOTH_HIO_c` member variables and update `daCLOTH_ChildHIO_c` access modifiers in `d_menu_cloth`. * Remove unused member variables from `daCLOTH_HIO_c` and `daCLOTH_ChildHIO_c` in `d_menu_cloth.h`. * Match dMCloth_c::dMCloth_c * Match `dMCloth_c::init`. * Match `dMCloth_c` destructor. * Refactor `dMCloth_c` to use `mCurArr` for indexing and update structure definitions in `d_menu_cloth`. * Define `ARR_SIZE` constant and replace hardcoded array sizes in `d_menu_cloth`. * Match dMCloth_c::TevSetting * Match dMCloth_c::TevSettingMenu * Match `dMCloth_c::TevSettingMenu` and `dMCloth_c::TevSettingFileSelect`. * Match `dMCloth_c::lightSet1` * Start matching `dMCloth_c::cloth_init` and update structure definitions to use `INNER_SIZE` constant, optimize initialization logic, and replace redundant assignments with consolidated methods. * Match `dMCloth_c::setNrmVtx` implementation and update header declaration. * Match `daCLOTH_HIO_c` destructor implementation. * Match `dMenu_ClothCreate`, `dMenu_ClothDelete`, `dMenu_ClothExecute`, `dMenu_ClothDraw`, and `dMenu_ClothIsDelete` implementations and update related structure definitions. * Update `g_fopAc_Method` reference to `g_fopMsg_Method` in cloth menu structure. * Match `dMCloth_c::cloth_move` implementation and update type definitions for `field_0xa` and `field_0x34` to `s16`. * Start matching `dMCloth_c::cloth_move_sin` and `dMCloth_c::cloth_move_simple` implementations. * Match `dMCloth_c::ShadowTevSetting` implementation. * Match `dMCloth_c::ShadowTevSettingMenu` and `dMCloth_c::ShadowTevSettingFileSelect` implementations. * Match `dMCloth_c::alpha_out` implementation. * Match `dMCloth_c::plot` implementation and minor formatting fix in `dMCloth_c::ShadowTevSettingMenu`. * Refactor `d_menu_cloth` to replace s16 color fields with `GXColorS10` and `GXColor` structures. Update all related logic and structure definitions accordingly. * Match `dMCloth_c::draw` implementation, refactor initialization of `field_0x10`, and update associated structure definitions. * Match `dMCloth_c::plot_shadow` implementation and update parameter names in `plot` and `plot_shadow` declarations. * Update `d_menu_cloth` to use `msg_method_class` and `msg_process_profile_definition`. Refactor structure definitions and add TODO comment for size clarification. * Add member comments in `dMenu_ClothMethodTable` * Refactor `d_menu_cloth` to improve pointer arithmetic in `plot` loop and add missing implementations for `getOffsetVec` and `getShadowPos`. * Refactor `dMCloth_c::plot` to improve naming consistency for loop variables and pointer arithmetic. * Refactor `d_menu_cloth` to replace repeated member accesses with `HIO_CHILD` macro for improved readability and maintainability. * Rename fields in `d_menu_cloth` * Add clarifying comments in `dMenu_ClothMethodTable` about function order and usage * Use `TRUE` and `FALSE` macros instead of literal values in `d_menu_cloth` methods for consistency. * Replace numeric cloth type values with `MenuClothType` enum for improved readability and maintainability in `d_menu_cloth`. * Refactor `dMCloth_c::cloth_init`: replace raw pointer arithmetic with `set` calls for improved clarity and maintainability. * Refactor `MENU_CLOTH_TYPE_2` logic: replace hardcoded rotation calculation with `cM_deg2s` for clarity and maintainability. * Change `wavePreSteps` type from `u16` to `s16` in `d_menu_cloth` for alignment with signed calculations. * Replace hardcoded angle conversion with `cM_deg2s` in `MENU_CLOTH_TYPE_0` logic for improved clarity and maintainability. * Change `mWaveProgress` type from `u16` to `s16` in `d_menu_cloth` for consistency with signed calculations. * Match `cloth_init` in `d_menu_cloth` * Fix `INNER_SIZE` iteration in `d_menu_cloth` to properly handle loop bounds. * Update vertex attribute formats in `d_menu_cloth` for improved correctness. * Add inline utility function `GXColor4x8` to `GX.h` for streamlined color input handling * Refactor triangle strip generation in `d_menu_cloth` for improved readability and maintainability. * Refactor vertex and texture coordinate handling in `dMCloth_c::plot_shadow` for improved clarity and correctness. * Refactor vertex handling in `d_menu_cloth` to group vertex and texture operations for improved readability and structure. * Add `GXNormal1x16` and `GXColor3x8` inline utility functions to `GX.h` for simplified normal and color input handling. * Update vertex format in `d_menu_cloth` to use `GXPosition1x16` and `GXNormal1x16` for improved attribute handling. * Add `dMs_clothOnly_create` and `dMs_clothOnly_delete` implementations in `d_menu_window` * Implement `dMs_cloth_create` and `dMs_cloth_delete` functions in `d_menu_window` and update related structure definitions. * Replace hardcoded cloth type with `MENU_CLOTH_TYPE_2` constant in `d_menu_window`. * Refactor `MENU_CLOTH_TYPE` enum names for clarity and update all references across `d_menu_cloth`, `d_s_name`, and `d_menu_window`. * Refactor `mChildren` array indexing in `daCLOTH_HIO_c` constructor to use `MENU_CLOTH_TYPE` constants for improved readability and maintainability. * Refactor `color1` and `color2` fields to `clothColor` and `shadowColor` for improved clarity in `d_menu_cloth` structure and related logic. * Simplify alpha blending logic by removing redundant variables in `d_menu_cloth`. * Refactor `mColor1`/`mColor2` to `mClothColor`/`mShadowColor` for improved clarity in `d_menu_cloth` and update all related logic. * Add temporary `dummy0` function in `d_menu_window` for placeholder debug strings. * Refactor position array access in `d_menu_cloth` to use `getPos()` result for better clarity and maintainability. * Change `waveFreqX` and `waveFreqY` types from `u16` to `s16` in `d_menu_cloth` structure for consistency. * Add demo version-specific mipmap handling logic in `d_menu_cloth` initialization. * Remove demo version-specific mipmap handling logic in `d_menu_cloth` initialization. * Match `cloth_move_sin` and `cloth_move_simple`. * Refactor loop variable initialization in `d_menu_cloth` for improved clarity. * Refactor variable names in alpha calculation for improved clarity in `d_menu_cloth`. * Inline vertex index calculations in `d_menu_cloth` to simplify code and reduce redundant variables. * Match `plot` and `plot_shadow`. * Refactor `lightDistance` variable in `d_menu_cloth` for improved clarity. * Inline empty destructor for `daCLOTH_HIO_c` in `d_menu_cloth` to simplify code. * Match `plot` and `plot_shadow` in demo build. * Update vertex attribute formats and streamline vertex function calls in `d_cloth_packet`. * Match `cloth_init` for JP version * Match `init` for JP version * Match `draw` for JP version * Add TODO note to identify superclass for correct size in `menu_cloth_class`. * Match `d_menu_cloth` for specific regions: GZLJ01, GZLE01, GZLP01. * Adjust `plot_shadow` parameters in `d_menu_cloth` for consistent shadow scaling. * Add dummy functions to ensure correct float order in `d_menu_cloth`. * Use version-specific scale values for `MENU_CLOTH_TYPE_DEFAULT` in `d_menu_cloth`. * Normalize hex color and value formatting in `d_menu_cloth`. * Add `STATIC_ASSERT` checks for struct size validation in `d_menu_cloth`. * Rename ambiguous `field` members to `padding` in `d_menu_cloth` and update struct size. * Replace `menu_cloth_class` size calculation with `sizeof(dMCloth_c)` in `d_menu_cloth`. * Revert "Replace `menu_cloth_class` size calculation with `sizeof(dMCloth_c)` in `d_menu_cloth`." This reverts commit3920b07e1a. * Revert "Rename ambiguous `field` members to `padding` in `d_menu_cloth` and update struct size." This reverts commit153ee490bf. * Rename placeholder fields to `padding_*` in `d_menu_cloth` for clarity. * Update `menu_cloth_class` size handling with `STATIC_ASSERT` and padding. * Clarify comment for `dMenu_ClothMethodTable` initialization. * Replace hardcoded offsets with calculated `INNER_SIZE`-based sizes in `d_menu_cloth`. * Remove stray comments in `setClothType` definition and invocation. * Annotate `mStatus` with offset comment in `dDlst_MENU_CAPTURE_c`. * Replace `g_dComIfG_gameInfo.play` calls with `dComIfGp_` equivalents in `d_menu_window`.
1043 lines
35 KiB
C++
1043 lines
35 KiB
C++
//
|
|
// Generated by dtk
|
|
// Translation Unit: d_cloth_packet.cpp
|
|
//
|
|
|
|
#include "d/dolzel.h" // IWYU pragma: keep
|
|
#include "d/d_cloth_packet.h"
|
|
|
|
#include "SSystem/SComponent/c_counter.h"
|
|
#include "assets/l_matDL__d_cloth_packet.h"
|
|
#include "assets/l_alpha_matDL__d_cloth_packet.h"
|
|
#include "d/d_s_play.h"
|
|
|
|
/* 80062D5C-800630B0 .text __ct__15dCloth_packet_cFP7ResTIMGiiffP12dKy_tevstr_cPP4cXyz */
|
|
dCloth_packet_c::dCloth_packet_c(
|
|
ResTIMG* i_toonimage, int flyGridSize, int hoistGridSize, float flyLength, float hoistLength, dKy_tevstr_c* tevstr, cXyz** posArr
|
|
) {
|
|
JUT_ASSERT(43, i_toonimage != NULL);
|
|
|
|
#if VERSION == VERSION_DEMO
|
|
GXBool mipmap = i_toonimage->mipmapCount > 1;
|
|
#endif
|
|
|
|
GXInitTexObj(
|
|
getToonTexObjP(),
|
|
(u8*)i_toonimage + i_toonimage->imageOffset,
|
|
i_toonimage->width,
|
|
i_toonimage->height,
|
|
(GXTexFmt)i_toonimage->format,
|
|
(GXTexWrapMode)i_toonimage->wrapS,
|
|
(GXTexWrapMode)i_toonimage->wrapT,
|
|
#if VERSION == VERSION_DEMO
|
|
mipmap
|
|
#else
|
|
i_toonimage->mipmapCount > 1
|
|
#endif
|
|
);
|
|
GXInitTexObjLOD(
|
|
getTexObjP(),
|
|
(GXTexFilter)i_toonimage->minFilter,
|
|
(GXTexFilter)i_toonimage->magFilter,
|
|
i_toonimage->minLOD * 0.125f,
|
|
i_toonimage->maxLOD * 0.125f,
|
|
i_toonimage->LODBias * 0.01f,
|
|
i_toonimage->biasClamp,
|
|
i_toonimage->doEdgeLOD,
|
|
(GXAnisotropy)i_toonimage->maxAnisotropy
|
|
);
|
|
|
|
mFlyGridSize = flyGridSize;
|
|
mHoistGridSize = hoistGridSize;
|
|
mFlyLength = flyLength;
|
|
mHoistLength = hoistLength;
|
|
mpTevstr = tevstr;
|
|
mCurArr = 0;
|
|
|
|
#if VERSION == VERSION_DEMO
|
|
const MtxP mtx = mDoMtx_getIdentity();
|
|
setMtx(mtx);
|
|
#else
|
|
setMtx(g_mDoMtx_identity);
|
|
#endif
|
|
|
|
if (posArr == NULL) {
|
|
mpPosArr[0] = new cXyz[mFlyGridSize * mHoistGridSize];
|
|
mpPosArr[1] = new cXyz[mFlyGridSize * mHoistGridSize];
|
|
} else {
|
|
mpPosArr[0] = posArr[0];
|
|
mpPosArr[1] = posArr[1];
|
|
}
|
|
mpNrmArr[0] = new cXyz[mFlyGridSize * mHoistGridSize];
|
|
mpNrmArr[1] = new cXyz[mFlyGridSize * mHoistGridSize];
|
|
mpNrmArrBack[0] = new cXyz[mFlyGridSize * mHoistGridSize];
|
|
mpNrmArrBack[1] = new cXyz[mFlyGridSize * mHoistGridSize];
|
|
mpSpeedArr = new cXyz[mFlyGridSize * mHoistGridSize];
|
|
}
|
|
|
|
dCloth_packet_c::~dCloth_packet_c() {
|
|
}
|
|
|
|
/* 8006310C-8006313C .text default_factor_checkCB__FP15dCloth_packet_cii */
|
|
int default_factor_checkCB(dCloth_packet_c* pPkt, int x, int y) {
|
|
if (x == 0 && (y == 0 || y == pPkt->mHoistGridSize - 1))
|
|
return 1;
|
|
return 0;
|
|
}
|
|
|
|
/* 8006313C-8006337C .text init__15dCloth_packet_cFv */
|
|
void dCloth_packet_c::init() {
|
|
cXyz* pPos0 = mpPosArr[0];
|
|
cXyz* pPos1 = mpPosArr[1];
|
|
cXyz* pSpeed = mpSpeedArr;
|
|
for (int y = 0; y < mHoistGridSize; y++) {
|
|
for (int x = 0; x < mFlyGridSize; x++) {
|
|
pPos0->set(0.0f, mHoistLength * ((f32)-y / (f32)(mHoistGridSize - 1)), mFlyLength * ((f32)x / (f32)(mFlyGridSize - 1)));
|
|
pPos1->set(0.0f, mHoistLength * ((f32)-y / (f32)(mHoistGridSize - 1)), mFlyLength * ((f32)x / (f32)(mFlyGridSize - 1)));
|
|
pSpeed->set(0.0f, 0.0f, 0.0f);
|
|
|
|
pPos0++;
|
|
pPos1++;
|
|
pSpeed++;
|
|
}
|
|
}
|
|
|
|
setNrm();
|
|
|
|
mScale = cXyz::BaseXYZ;
|
|
mGlobalWind = cXyz::BaseZ;
|
|
|
|
DCStoreRangeNoSync(mpPosArr[mCurArr], mFlyGridSize * mHoistGridSize * sizeof(cXyz));
|
|
DCStoreRangeNoSync(mpNrmArr[mCurArr], mFlyGridSize * mHoistGridSize * sizeof(cXyz));
|
|
DCStoreRangeNoSync(mpNrmArrBack[mCurArr], mFlyGridSize * mHoistGridSize * sizeof(cXyz));
|
|
|
|
setFactorCheckCB(default_factor_checkCB);
|
|
}
|
|
|
|
/* 8006337C-80063400 .text setGlobalWind__15dCloth_packet_cFP4cXyz */
|
|
void dCloth_packet_c::setGlobalWind(cXyz* wind) {
|
|
Mtx mtx;
|
|
MTXCopy(mMtx, mtx);
|
|
mtx[2][3] = 0.0f;
|
|
mtx[1][3] = 0.0f;
|
|
mtx[0][3] = 0.0f;
|
|
mDoMtx_stack_c::copy(mtx);
|
|
mDoMtx_stack_c::inverse();
|
|
mDoMtx_stack_c::multVec(wind, &mGlobalWind);
|
|
}
|
|
|
|
/* 80063400-80063728 .text cloth_move__15dCloth_packet_cFv */
|
|
void dCloth_packet_c::cloth_move() {
|
|
cXyz wind = mGlobalWind;
|
|
wind *= mWindSpeed + mWindSpeedWave * cM_ssin(mWave);
|
|
|
|
#if VERSION == VERSION_DEMO
|
|
cXyz* pPosNew;
|
|
cXyz* pSpeed;
|
|
cXyz* pPosOld;
|
|
cXyz* pNrmOld;
|
|
#else
|
|
cXyz* pPosOld;
|
|
cXyz* pNrmOld;
|
|
cXyz* pPosNew;
|
|
cXyz* pSpeed;
|
|
#endif
|
|
|
|
pPosOld = mpPosArr[mCurArr];
|
|
pNrmOld = mpNrmArr[mCurArr];
|
|
changeCurrentBuff();
|
|
pPosNew = mpPosArr[mCurArr];
|
|
pSpeed = mpSpeedArr;
|
|
|
|
float distFly = mFlyLength / (f32)(mFlyGridSize - 1);
|
|
float distHoist = mHoistLength / (f32)(mHoistGridSize - 1);
|
|
distFly *= mFlyFlex;
|
|
distHoist *= mHoistFlex;
|
|
const float distBoth = std::sqrtf(distFly * distFly + distHoist * distHoist);
|
|
|
|
for (int y = 0; y < mHoistGridSize; y++) {
|
|
for (int x = 0; x < mFlyGridSize; x++) {
|
|
const cXyz factor = getFactor(pPosOld, pNrmOld, &wind, distFly, distHoist, distBoth, x, y);
|
|
pSpeed[x + y * mFlyGridSize] += factor;
|
|
pSpeed[x + y * mFlyGridSize] *= mDrag;
|
|
|
|
pPosNew[x + y * mFlyGridSize] = pPosOld[x + y * mFlyGridSize];
|
|
pPosNew[x + y * mFlyGridSize] += pSpeed[x + y * mFlyGridSize];
|
|
}
|
|
}
|
|
|
|
setNrm();
|
|
|
|
DCStoreRangeNoSync(mpPosArr[mCurArr], mFlyGridSize * mHoistGridSize * sizeof(cXyz));
|
|
DCStoreRangeNoSync(mpNrmArr[mCurArr], mFlyGridSize * mHoistGridSize * sizeof(cXyz));
|
|
DCStoreRangeNoSync(mpNrmArrBack[mCurArr], mFlyGridSize * mHoistGridSize * sizeof(cXyz));
|
|
}
|
|
|
|
/* 80063728-800638E4 .text draw__15dCloth_packet_cFv */
|
|
void dCloth_packet_c::draw() {
|
|
j3dSys.reinitGX();
|
|
|
|
#if VERSION > VERSION_JPN
|
|
GXSetNumIndStages(0);
|
|
#endif
|
|
|
|
dKy_GxFog_tevstr_set(mpTevstr);
|
|
dKy_setLight_mine(mpTevstr);
|
|
|
|
GXClearVtxDesc();
|
|
GXSetVtxDesc(GX_VA_POS, GX_INDEX8);
|
|
GXSetVtxDesc(GX_VA_NRM, GX_INDEX8);
|
|
GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT);
|
|
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
|
|
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_NRM, GX_NRM_XYZ, GX_F32, 0);
|
|
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
|
|
|
|
#if VERSION == VERSION_DEMO
|
|
{
|
|
cXyz* pos = getPosP();
|
|
GXSetArray(GX_VA_POS, pos, sizeof(cXyz));
|
|
cXyz* nrm = getNrmP();
|
|
GXSetArray(GX_VA_NRM, nrm, sizeof(cXyz));
|
|
}
|
|
#else
|
|
GXSetArray(GX_VA_POS, getPosP(), sizeof(cXyz));
|
|
GXSetArray(GX_VA_NRM, getNrmP(), sizeof(cXyz));
|
|
#endif
|
|
|
|
TexObjLoad();
|
|
GXLoadTexObj(getToonTexObjP(), GX_TEXMAP1);
|
|
TevSetting();
|
|
|
|
mDoMtx_stack_c::copy(mMtx);
|
|
mDoMtx_stack_c::scaleM(mScale);
|
|
Mtx mtx;
|
|
#if VERSION == VERSION_DEMO
|
|
{
|
|
MtxP calc_mtx = mDoMtx_stack_c::get();
|
|
MTXConcat(j3dSys.getViewMtx(), calc_mtx, mtx);
|
|
}
|
|
#else
|
|
MTXConcat(j3dSys.getViewMtx(), mDoMtx_stack_c::get(), mtx);
|
|
#endif
|
|
GXLoadPosMtxImm(mtx, GX_PNMTX0);
|
|
GXLoadNrmMtxImm(mtx, GX_PNMTX0);
|
|
|
|
// Draw front
|
|
GXSetCullMode(GX_CULL_BACK);
|
|
plot();
|
|
|
|
// Draw back
|
|
GXSetCullMode(GX_CULL_FRONT);
|
|
#if VERSION == VERSION_DEMO
|
|
{
|
|
cXyz* backNrm = getBackNrmP();
|
|
GXSetArray(GX_VA_NRM, backNrm, sizeof(cXyz));
|
|
}
|
|
#else
|
|
GXSetArray(GX_VA_NRM, getBackNrmP(), sizeof(cXyz));
|
|
#endif
|
|
|
|
plot();
|
|
|
|
#if VERSION > VERSION_JPN
|
|
J3DShape::resetVcdVatCache();
|
|
#endif
|
|
}
|
|
|
|
/* 800638E4-80063A10 .text get_cloth_anim_sub_factor__FP4cXyzP4cXyzP4cXyzff */
|
|
void get_cloth_anim_sub_factor(cXyz* pPos, cXyz* pOther, cXyz* pDst, float restDist, float springFactor) {
|
|
cXyz diff = *pOther - *pPos;
|
|
cXyz norm = diff.normZP();
|
|
f32 dist = diff.abs() - restDist;
|
|
dist *= springFactor;
|
|
norm *= dist;
|
|
*pDst += norm;
|
|
}
|
|
|
|
/* 80063A10-80063D84 .text getFactor__15dCloth_packet_cFP4cXyzP4cXyzP4cXyzfffii */
|
|
cXyz dCloth_packet_c::getFactor(cXyz* pPos, cXyz* pNrm, cXyz* pSpeed, float distFly, float distHoist, float distBoth, int x, int y) {
|
|
static const u8 left_bit = 1 << 0;
|
|
static const u8 right_bit = 1 << 1;
|
|
static const u8 up_bit = 1 << 2;
|
|
static const u8 down_bit = 1 << 3;
|
|
|
|
if (mpFactorCheckCB(this, x, y)) {
|
|
return cXyz::Zero;
|
|
}
|
|
|
|
u8 neighborMask = 0;
|
|
|
|
cXyz ret, pos;
|
|
pos = pPos[x + y * mFlyGridSize];
|
|
const float speedDotNrm = pSpeed->inprod(pNrm[x + y * mFlyGridSize]);
|
|
ret = pNrm[x + y * mFlyGridSize] * speedDotNrm;
|
|
ret.y += mGravity;
|
|
|
|
if (x != 0) {
|
|
neighborMask |= left_bit;
|
|
}
|
|
if (x != mFlyGridSize - 1) {
|
|
neighborMask |= right_bit;
|
|
}
|
|
if (y != 0) {
|
|
neighborMask |= up_bit;
|
|
}
|
|
if (y != mHoistGridSize - 1) {
|
|
neighborMask |= down_bit;
|
|
}
|
|
|
|
if (neighborMask & left_bit) {
|
|
get_cloth_anim_sub_factor(&pos, &pPos[x - 1 + y * mFlyGridSize], &ret, distFly, mSpring);
|
|
}
|
|
if (neighborMask & right_bit) {
|
|
get_cloth_anim_sub_factor(&pos, &pPos[x + 1 + y * mFlyGridSize], &ret, distFly, mSpring);
|
|
}
|
|
if (neighborMask & up_bit) {
|
|
get_cloth_anim_sub_factor(&pos, &pPos[x + (y - 1) * mFlyGridSize], &ret, distHoist, mSpring);
|
|
}
|
|
if (neighborMask & down_bit) {
|
|
get_cloth_anim_sub_factor(&pos, &pPos[x + (y + 1) * mFlyGridSize], &ret, distHoist, mSpring);
|
|
}
|
|
if ((neighborMask & left_bit) && (neighborMask & up_bit)) {
|
|
get_cloth_anim_sub_factor(&pos, &pPos[x - 1 + (y - 1) * mFlyGridSize], &ret, distBoth, mSpring);
|
|
}
|
|
if ((neighborMask & left_bit) && (neighborMask & down_bit)) {
|
|
get_cloth_anim_sub_factor(&pos, &pPos[x - 1 + (y + 1) * mFlyGridSize], &ret, distBoth, mSpring);
|
|
}
|
|
if ((neighborMask & right_bit) && (neighborMask & up_bit)) {
|
|
get_cloth_anim_sub_factor(&pos, &pPos[x + 1 + (y - 1) * mFlyGridSize], &ret, distBoth, mSpring);
|
|
}
|
|
if ((neighborMask & right_bit) && (neighborMask & down_bit)) {
|
|
get_cloth_anim_sub_factor(&pos, &pPos[x + 1 + (y + 1) * mFlyGridSize], &ret, distBoth, mSpring);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
/* 80063D84-800642D0 .text setNrm__15dCloth_packet_cFv */
|
|
void dCloth_packet_c::setNrm() {
|
|
cXyz* pPos = getPosP();
|
|
cXyz* pNrm = getNrmP();
|
|
|
|
mWave += mWaveSpeed;
|
|
|
|
// It seems like field_0xF2 is always set to 0.
|
|
field_0xF0 += field_0xF2;
|
|
|
|
for (s32 y = 0; y < mHoistGridSize; y++) {
|
|
for (s32 x = 0; x < mFlyGridSize; x++) {
|
|
cXyz x_diff;
|
|
cXyz y_diff;
|
|
cXyz norm;
|
|
cXyz total;
|
|
cXyz pos;
|
|
|
|
pos = pPos[x + mFlyGridSize * y];
|
|
total = cXyz::Zero;
|
|
if (x != 0) {
|
|
x_diff = pPos[x - 1 + mFlyGridSize * y] - pos;
|
|
if (y != 0) {
|
|
y_diff = pPos[x + mFlyGridSize * (y - 1)] - pos;
|
|
norm = y_diff.outprod(x_diff);
|
|
norm = norm.normZP();
|
|
total += norm;
|
|
}
|
|
if (y != mHoistGridSize - 1) {
|
|
y_diff = pPos[x + mFlyGridSize * (y + 1)] - pos;
|
|
norm = x_diff.outprod(y_diff);
|
|
norm = norm.normZP();
|
|
total += norm;
|
|
}
|
|
}
|
|
if (x != mFlyGridSize - 1) {
|
|
x_diff = pPos[x + 1 + mFlyGridSize * y] - pos;
|
|
if (y != 0) {
|
|
y_diff = pPos[x + mFlyGridSize * (y - 1)] - pos;
|
|
norm = x_diff.outprod(y_diff);
|
|
norm = norm.normZP();
|
|
total += norm;
|
|
}
|
|
if (y != mHoistGridSize - 1) {
|
|
y_diff = pPos[x + mFlyGridSize * (y + 1)] - pos;
|
|
norm = y_diff.outprod(x_diff);
|
|
norm = norm.normZP();
|
|
total += norm;
|
|
}
|
|
}
|
|
|
|
total = total.normZP();
|
|
|
|
mDoMtx_stack_c::YrotS(mRotateY * cM_ssin(mWave + mRipple * (x + y)));
|
|
mDoMtx_stack_c::multVec(&total, &norm);
|
|
pNrm[x + mFlyGridSize * y] = norm.normZP();
|
|
}
|
|
}
|
|
|
|
// Set all back normals to the negative front normals.
|
|
cXyz* pNrmBack = getBackNrmP();
|
|
for (int y = 0; y < mHoistGridSize; y++) {
|
|
for (int x = 0; x < mFlyGridSize; x++) {
|
|
pNrmBack->set(-pNrm->x, -pNrm->y, -pNrm->z);
|
|
pNrm++;
|
|
pNrmBack++;
|
|
}
|
|
}
|
|
}
|
|
|
|
/* 800642D0-800642FC .text setMtx__15dCloth_packet_cFPA4_f */
|
|
void dCloth_packet_c::setMtx(Mtx mtx) {
|
|
MTXCopy(mtx, mMtx);
|
|
}
|
|
|
|
/* 800642FC-80064330 .text cloth_draw__15dCloth_packet_cFv */
|
|
void dCloth_packet_c::cloth_draw() {
|
|
j3dSys.getDrawBuffer(OPA_BUFFER)->entryImm(this, 0);
|
|
}
|
|
|
|
/* 80064330-8006441C .text TexObjInit__15dCloth_packet_cFP7ResTIMG */
|
|
void dCloth_packet_c::TexObjInit(ResTIMG* i_img) {
|
|
#if VERSION == VERSION_DEMO
|
|
GXBool mipmap = i_img->mipmapCount > 1;
|
|
#endif
|
|
|
|
GXInitTexObj(
|
|
getTexObjP(),
|
|
(u8*)i_img + i_img->imageOffset,
|
|
i_img->width,
|
|
i_img->height,
|
|
GXTexFmt(i_img->format),
|
|
GXTexWrapMode(i_img->wrapS),
|
|
GXTexWrapMode(i_img->wrapT),
|
|
#if VERSION == VERSION_DEMO
|
|
mipmap
|
|
#else
|
|
i_img->mipmapCount > 1
|
|
#endif
|
|
);
|
|
GXInitTexObjLOD(
|
|
getTexObjP(),
|
|
GXTexFilter(i_img->minFilter),
|
|
GXTexFilter(i_img->magFilter),
|
|
i_img->minLOD * 0.125f,
|
|
i_img->maxLOD * 0.125f,
|
|
i_img->LODBias * 0.01f,
|
|
i_img->biasClamp,
|
|
i_img->doEdgeLOD,
|
|
GXAnisotropy(i_img->maxAnisotropy)
|
|
);
|
|
}
|
|
|
|
/* 8006441C-80064444 .text TexObjLoad__15dCloth_packet_cFv */
|
|
void dCloth_packet_c::TexObjLoad() {
|
|
GXLoadTexObj(getTexObjP(), GX_TEXMAP0);
|
|
}
|
|
|
|
/* 80064444-80064718 .text TevSetting__15dCloth_packet_cFv */
|
|
void dCloth_packet_c::TevSetting() {
|
|
GXSetNumChans(1);
|
|
u8 numStages;
|
|
u8 lightMask;
|
|
if (mpTevstr->mColorK1.a != 0) {
|
|
numStages = 3;
|
|
lightMask = GX_LIGHT0 | GX_LIGHT1;
|
|
} else {
|
|
numStages = 2;
|
|
lightMask = GX_LIGHT0;
|
|
}
|
|
GXSetChanCtrl(GX_COLOR0, GX_TRUE, GX_SRC_REG, GX_SRC_REG, lightMask, GX_DF_CLAMP, GX_AF_NONE);
|
|
GXSetNumTexGens(2);
|
|
GXSetTexCoordGen2(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY, GX_FALSE, GX_PTIDENTITY);
|
|
GXSetTexCoordGen2(GX_TEXCOORD1, GX_TG_SRTG, GX_TG_COLOR0, GX_IDENTITY, GX_FALSE, GX_PTIDENTITY);
|
|
GXSetNumTevStages(numStages);
|
|
GXSetTevSwapMode(GX_TEVSTAGE0, GX_TEV_SWAP0, GX_TEV_SWAP1);
|
|
GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD1, GX_TEXMAP1, GX_COLOR0A0);
|
|
GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_C0, GX_CC_C1, GX_CC_TEXC, GX_CC_ZERO);
|
|
GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
|
|
GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO);
|
|
GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
|
|
GXSetTevSwapMode(GX_TEVSTAGE1, GX_TEV_SWAP0, GX_TEV_SWAP0);
|
|
GXSetTevOrder(GX_TEVSTAGE1, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL);
|
|
GXSetTevColorIn(GX_TEVSTAGE1, GX_CC_ZERO, GX_CC_TEXC, GX_CC_CPREV, GX_CC_ZERO);
|
|
GXSetTevColorOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
|
|
GXSetTevAlphaIn(GX_TEVSTAGE1, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_TEXA);
|
|
GXSetTevAlphaOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
|
|
if (numStages == 3) {
|
|
GXSetTevSwapMode(GX_TEVSTAGE2, GX_TEV_SWAP0, GX_TEV_SWAP2);
|
|
GXSetTevOrder(GX_TEVSTAGE2, GX_TEXCOORD1, GX_TEXMAP1, GX_COLOR_NULL);
|
|
GXSetTevColorIn(GX_TEVSTAGE2, GX_CC_ZERO, GX_CC_C2, GX_CC_TEXC, GX_CC_CPREV);
|
|
GXSetTevColorOp(GX_TEVSTAGE2, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
|
|
GXSetTevAlphaIn(GX_TEVSTAGE2, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_APREV);
|
|
GXSetTevAlphaOp(GX_TEVSTAGE2, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
|
|
}
|
|
|
|
GXSetTevColorS10(GX_TEVREG0, mpTevstr->mColorC0);
|
|
GXSetTevColor(GX_TEVREG1, mpTevstr->mColorK0);
|
|
GXSetTevColor(GX_TEVREG2, mpTevstr->mColorK1);
|
|
GXCallDisplayList(l_matDL, 0x20);
|
|
}
|
|
|
|
/* 80064718-8006487C .text plot__15dCloth_packet_cFv */
|
|
void dCloth_packet_c::plot() {
|
|
float xPos = 0.0f;
|
|
const float xStep = 1.0f / (f32)(mFlyGridSize - 1);
|
|
const float yStep = 1.0f / (f32)(mHoistGridSize - 1);
|
|
int x, xNext = 1;
|
|
for (x = 0; x < mFlyGridSize - 1; x++, xNext++) {
|
|
GXBegin(GX_TRIANGLESTRIP, GX_VTXFMT0, (u8)(mHoistGridSize * 2));
|
|
|
|
float yPos = 0.0f;
|
|
for (int y = 0; y < mHoistGridSize; y++) {
|
|
GXPosition1x8(x + y * mFlyGridSize);
|
|
GXNormal1x8(x + y * mFlyGridSize);
|
|
GXTexCoord2f32(xPos, yPos);
|
|
|
|
GXPosition1x8(xNext + y * mFlyGridSize);
|
|
GXNormal1x8(xNext + y * mFlyGridSize);
|
|
GXTexCoord2f32(xPos + xStep, yPos);
|
|
|
|
yPos += yStep;
|
|
}
|
|
|
|
xPos += xStep;
|
|
}
|
|
}
|
|
|
|
/* 8006487C-800649C4 .text dCloth_packet_create__FP7ResTIMGP7ResTIMGiiffP12dKy_tevstr_cPP4cXyz */
|
|
dCloth_packet_c* dCloth_packet_create(
|
|
ResTIMG* i_flagimage, ResTIMG* i_toonimage, int flyGridSize, int hoistGridSize, float flyLength, float hoistLength, dKy_tevstr_c* tevstr, cXyz** posArr
|
|
) {
|
|
dCloth_packet_c* pCloth = new dCloth_packet_c(i_toonimage, flyGridSize, hoistGridSize, flyLength, hoistLength, tevstr, posArr);
|
|
if (pCloth && !pCloth->chkCreateBuff()) {
|
|
pCloth = NULL;
|
|
} else if (pCloth && i_flagimage) {
|
|
pCloth->TexObjInit(i_flagimage);
|
|
pCloth->init();
|
|
}
|
|
|
|
return pCloth;
|
|
}
|
|
|
|
/* 800649C4-80064C98 .text TevSetting__18dCloth_packetXlu_cFv */
|
|
void dCloth_packetXlu_c::TevSetting() {
|
|
GXSetNumChans(1);
|
|
u8 numStages;
|
|
u8 lightMask;
|
|
if (mpTevstr->mColorK1.a != 0) {
|
|
numStages = 3;
|
|
lightMask = GX_LIGHT0 | GX_LIGHT1;
|
|
} else {
|
|
numStages = 2;
|
|
lightMask = GX_LIGHT0;
|
|
}
|
|
GXSetChanCtrl(GX_COLOR0, GX_TRUE, GX_SRC_REG, GX_SRC_REG, lightMask, GX_DF_CLAMP, GX_AF_NONE);
|
|
GXSetNumTexGens(2);
|
|
GXSetTexCoordGen2(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY, GX_FALSE, GX_PTIDENTITY);
|
|
GXSetTexCoordGen2(GX_TEXCOORD1, GX_TG_SRTG, GX_TG_COLOR0, GX_IDENTITY, GX_FALSE, GX_PTIDENTITY);
|
|
GXSetNumTevStages(numStages);
|
|
GXSetTevSwapMode(GX_TEVSTAGE0, GX_TEV_SWAP0, GX_TEV_SWAP1);
|
|
GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD1, GX_TEXMAP1, GX_COLOR0A0);
|
|
GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_C0, GX_CC_C1, GX_CC_TEXC, GX_CC_ZERO);
|
|
GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
|
|
GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO);
|
|
GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
|
|
GXSetTevSwapMode(GX_TEVSTAGE1, GX_TEV_SWAP0, GX_TEV_SWAP0);
|
|
GXSetTevOrder(GX_TEVSTAGE1, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL);
|
|
GXSetTevColorIn(GX_TEVSTAGE1, GX_CC_ZERO, GX_CC_TEXC, GX_CC_CPREV, GX_CC_ZERO);
|
|
GXSetTevColorOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
|
|
GXSetTevAlphaIn(GX_TEVSTAGE1, GX_CA_ZERO, GX_CA_A0, GX_CA_TEXA, GX_CA_ZERO); // Differs from dCloth_packet_c::TevSetting() here.
|
|
GXSetTevAlphaOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
|
|
if (numStages == 3) {
|
|
GXSetTevSwapMode(GX_TEVSTAGE2, GX_TEV_SWAP0, GX_TEV_SWAP2);
|
|
GXSetTevOrder(GX_TEVSTAGE2, GX_TEXCOORD1, GX_TEXMAP1, GX_COLOR_NULL);
|
|
GXSetTevColorIn(GX_TEVSTAGE2, GX_CC_ZERO, GX_CC_C2, GX_CC_TEXC, GX_CC_CPREV);
|
|
GXSetTevColorOp(GX_TEVSTAGE2, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
|
|
GXSetTevAlphaIn(GX_TEVSTAGE2, GX_CA_ZERO, GX_CA_A0, GX_CA_TEXA, GX_CA_ZERO); // Differs from dCloth_packet_c::TevSetting() here.
|
|
GXSetTevAlphaOp(GX_TEVSTAGE2, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
|
|
}
|
|
|
|
GXSetTevColorS10(GX_TEVREG0, mpTevstr->mColorC0);
|
|
GXSetTevColor(GX_TEVREG1, mpTevstr->mColorK0);
|
|
GXSetTevColor(GX_TEVREG2, mpTevstr->mColorK1);
|
|
GXCallDisplayList(l_alpha_matDL, 0x20);
|
|
}
|
|
|
|
/* 80064C98-80064CF8 .text cloth_draw__18dCloth_packetXlu_cFv */
|
|
void dCloth_packetXlu_c::cloth_draw() {
|
|
cXyz pos = getPosP()[0];
|
|
g_dComIfG_gameInfo.drawlist.entryZSortXluDrawList(g_dComIfG_gameInfo.drawlist.mpXluList, this, pos);
|
|
}
|
|
|
|
/* 80064CF8-80064E48 .text dCloth_packetXlu_create__FP7ResTIMGP7ResTIMGiiffP12dKy_tevstr_cPP4cXyz */
|
|
dCloth_packetXlu_c* dCloth_packetXlu_create(
|
|
ResTIMG* i_flagimage, ResTIMG* i_toonimage, int flyGridSize, int hoistGridSize, float flyLength, float hoistLength, dKy_tevstr_c* tevstr, cXyz** posArr
|
|
) {
|
|
dCloth_packetXlu_c* pCloth = new dCloth_packetXlu_c(i_toonimage, flyGridSize, hoistGridSize, flyLength, hoistLength, tevstr, posArr);
|
|
if (pCloth && !pCloth->chkCreateBuff()) {
|
|
pCloth = NULL;
|
|
} else if (pCloth && i_flagimage) {
|
|
pCloth->TexObjInit(i_flagimage);
|
|
pCloth->init();
|
|
}
|
|
|
|
return pCloth;
|
|
}
|
|
|
|
dClothVobj03_c* dClothVobj03_c::top_pointer;
|
|
dClothVobj04_c* dClothVobj04_c::top_pointer;
|
|
dClothVobj05_c* dClothVobj05_c::top_pointer;
|
|
dClothVobj07_0_c* dClothVobj07_0_c::top_pointer;
|
|
|
|
s32 dClothVobj03_c::cloth_counter = -1;
|
|
s32 dClothVobj04_c::cloth_counter = -1;
|
|
s32 dClothVobj05_c::cloth_counter = -1;
|
|
s32 dClothVobj07_0_c::cloth_counter = -1;
|
|
|
|
/* 80064E48-80064F0C .text cloth_copy__14dClothVobj03_cFv */
|
|
void dClothVobj03_c::cloth_copy() {
|
|
changeCurrentBuff();
|
|
memcpy(getNrmP(), top_pointer->getNrmP(), sizeof(cXyz) * mHoistGridSize * mFlyGridSize);
|
|
memcpy(getBackNrmP(), top_pointer->getBackNrmP(), sizeof(cXyz) * mHoistGridSize * mFlyGridSize);
|
|
memcpy(getSpdP(), top_pointer->getSpdP(), sizeof(cXyz) * mHoistGridSize * mFlyGridSize);
|
|
}
|
|
|
|
/* 80064F0C-80065020 .text init__14dClothVobj03_cFv */
|
|
void dClothVobj03_c::init() {
|
|
if (cloth_counter == (s32)g_Counter.mTimer) {
|
|
// Cloth sim has already run for this frame.
|
|
memcpy(getNrmP(), top_pointer->getNrmP(), sizeof(cXyz) * mHoistGridSize * mFlyGridSize);
|
|
memcpy(getBackNrmP(), top_pointer->getBackNrmP(), sizeof(cXyz) * mHoistGridSize * mFlyGridSize);
|
|
memcpy(getSpdP(), top_pointer->getSpdP(), sizeof(cXyz) * mHoistGridSize * mFlyGridSize);
|
|
} else {
|
|
dCloth_packet_c::init();
|
|
}
|
|
|
|
if (dStage_stagInfo_GetSTType(dComIfGp_getStageStagInfo()) == dStageType_MISC_e) {
|
|
mIsIndoors = true;
|
|
} else {
|
|
mIsIndoors = false;
|
|
}
|
|
}
|
|
|
|
/* 80065020-8006515C .text cloth_move__14dClothVobj03_cFv */
|
|
void dClothVobj03_c::cloth_move() {
|
|
if (mIsStandItem) {
|
|
// Cloth sim only runs when the timer has changed, and only once for each type of flag.
|
|
if (cloth_counter == (s32)g_Counter.mTimer) {
|
|
// Cloth sim has run already, so copy the geometry to this object and return.
|
|
cloth_copy();
|
|
return;
|
|
}
|
|
|
|
// Make this the simulation object.
|
|
cloth_counter = g_Counter.mTimer;
|
|
top_pointer = this;
|
|
}
|
|
|
|
// Set params for sim.
|
|
|
|
f32 windSpeed = REG10_F(5) + 7.0f;
|
|
f32 windSpeedWave = REG10_F(6) + 2.0f;
|
|
|
|
if (mIsIndoors) {
|
|
// Indoor flags don't get blown much by the wind.
|
|
windSpeed *= 0.05f;
|
|
windSpeedWave = 0.0f;
|
|
setParam(0.4f, -1.5f, 0.7f, 0.75f, 0.6f, 0, 0, 900, -800, 7.0f, 6.0f);
|
|
} else {
|
|
setParam(0.4f, -1.5f, 0.7f, 0.75f, 0.6f, 0x400, 0, 900, -800, 7.0f, 6.0f);
|
|
}
|
|
|
|
setWindPower(windSpeed, windSpeedWave);
|
|
|
|
// Simulate cloth.
|
|
dCloth_packet_c::cloth_move();
|
|
}
|
|
|
|
/* 8006515C-80065268 .text TexObjInit__14dClothVobj03_cFP7ResTIMG */
|
|
void dClothVobj03_c::TexObjInit(ResTIMG* timg) {
|
|
GXInitTlutObj(&mTlutObj, (u8*)&timg->format + timg->paletteOffset, GXTlutFmt(timg->colorFormat), timg->numColors);
|
|
#if VERSION == VERSION_DEMO
|
|
const GXBool mipmap = timg->mipmapCount > 1;
|
|
#endif
|
|
|
|
GXInitTexObjCI(
|
|
getTexObjP(),
|
|
&timg->format + timg->imageOffset,
|
|
timg->width,
|
|
timg->height,
|
|
GXCITexFmt(timg->format),
|
|
GXTexWrapMode(timg->wrapS),
|
|
GXTexWrapMode(timg->wrapT),
|
|
#if VERSION == VERSION_DEMO
|
|
mipmap,
|
|
#else
|
|
timg->mipmapCount > 1,
|
|
#endif
|
|
0
|
|
);
|
|
|
|
GXInitTexObjLOD(
|
|
getTexObjP(),
|
|
GXTexFilter(timg->minFilter),
|
|
GXTexFilter(timg->magFilter),
|
|
timg->minLOD * 0.125f,
|
|
timg->maxLOD * 0.125f,
|
|
timg->LODBias * 0.01f,
|
|
timg->biasClamp,
|
|
timg->doEdgeLOD,
|
|
GXAnisotropy(timg->maxAnisotropy)
|
|
);
|
|
}
|
|
|
|
/* 80065268-800652A8 .text TexObjLoad__14dClothVobj03_cFv */
|
|
void dClothVobj03_c::TexObjLoad() {
|
|
GXLoadTlut(&mTlutObj, 0);
|
|
GXLoadTexObj(getTexObjP(), GX_TEXMAP0);
|
|
}
|
|
|
|
/* 800652A8-800653F4 .text dClothVobj03_create__FP7ResTIMGP7ResTIMGP12dKy_tevstr_cPP4cXyz */
|
|
dClothVobj03_c* dClothVobj03_create(ResTIMG* i_flagimage, ResTIMG* i_toonimage, dKy_tevstr_c* tevstr, cXyz** posArr) {
|
|
dClothVobj03_c* pCloth = new dClothVobj03_c(i_toonimage, tevstr, posArr);
|
|
if (pCloth && !pCloth->chkCreateBuff()) {
|
|
pCloth = NULL;
|
|
} else if (pCloth && i_flagimage) {
|
|
pCloth->TexObjInit(i_flagimage);
|
|
pCloth->init();
|
|
}
|
|
|
|
return pCloth;
|
|
}
|
|
|
|
/* 800653F4-800654B8 .text cloth_copy__14dClothVobj04_cFv */
|
|
void dClothVobj04_c::cloth_copy() {
|
|
changeCurrentBuff();
|
|
memcpy(getNrmP(), top_pointer->getNrmP(), sizeof(cXyz) * mHoistGridSize * mFlyGridSize);
|
|
memcpy(getBackNrmP(), top_pointer->getBackNrmP(), sizeof(cXyz) * mHoistGridSize * mFlyGridSize);
|
|
memcpy(getSpdP(), top_pointer->getSpdP(), sizeof(cXyz) * mHoistGridSize * mFlyGridSize);
|
|
}
|
|
|
|
/* 800654B8-800655CC .text init__14dClothVobj04_cFv */
|
|
void dClothVobj04_c::init() {
|
|
if (cloth_counter == (s32)g_Counter.mTimer) {
|
|
memcpy(getNrmP(), top_pointer->getNrmP(), sizeof(cXyz) * mHoistGridSize * mFlyGridSize);
|
|
memcpy(getBackNrmP(), top_pointer->getBackNrmP(), sizeof(cXyz) * mHoistGridSize * mFlyGridSize);
|
|
memcpy(getSpdP(), top_pointer->getSpdP(), sizeof(cXyz) * mHoistGridSize * mFlyGridSize);
|
|
} else {
|
|
dCloth_packet_c::init();
|
|
}
|
|
|
|
if (dStage_stagInfo_GetSTType(dComIfGp_getStageStagInfo()) == dStageType_MISC_e) {
|
|
mIsIndoors = true;
|
|
} else {
|
|
mIsIndoors = false;
|
|
}
|
|
}
|
|
|
|
/* 800655CC-80065700 .text cloth_move__14dClothVobj04_cFv */
|
|
void dClothVobj04_c::cloth_move() {
|
|
if (mIsStandItem) {
|
|
if (cloth_counter == (s32)g_Counter.mTimer) {
|
|
cloth_copy();
|
|
return;
|
|
}
|
|
cloth_counter = g_Counter.mTimer;
|
|
top_pointer = this;
|
|
}
|
|
|
|
f32 windSpeed = REG10_F(5) + 7.0f;
|
|
f32 windSpeedWave = REG10_F(6) + 2.0f;
|
|
|
|
if (mIsIndoors) {
|
|
windSpeed *= 0.05f;
|
|
windSpeedWave = 0.0f;
|
|
setParam(0.45f, -1.5f, 0.6f, 0.8f, 0.8f, 0, 0, 900, -800, 7.0f, 6.0f);
|
|
} else {
|
|
setParam(0.45f, -1.5f, 0.6f, 0.8f, 0.8f, 0x400, 0, 900, -800, 7.0f, 6.0f);
|
|
}
|
|
|
|
setWindPower(windSpeed, windSpeedWave);
|
|
|
|
dCloth_packet_c::cloth_move();
|
|
}
|
|
|
|
/* 80065700-8006580C .text TexObjInit__14dClothVobj04_cFP7ResTIMG */
|
|
void dClothVobj04_c::TexObjInit(ResTIMG* timg) {
|
|
GXInitTlutObj(&mTlutObj, (u8*)&timg->format + timg->paletteOffset, GXTlutFmt(timg->colorFormat), timg->numColors);
|
|
#if VERSION == VERSION_DEMO
|
|
const GXBool mipmap = timg->mipmapCount > 1;
|
|
#endif
|
|
|
|
GXInitTexObjCI(
|
|
getTexObjP(),
|
|
&timg->format + timg->imageOffset,
|
|
timg->width,
|
|
timg->height,
|
|
GXCITexFmt(timg->format),
|
|
GXTexWrapMode(timg->wrapS),
|
|
GXTexWrapMode(timg->wrapT),
|
|
#if VERSION == VERSION_DEMO
|
|
mipmap,
|
|
#else
|
|
timg->mipmapCount > 1,
|
|
#endif
|
|
0
|
|
);
|
|
|
|
GXInitTexObjLOD(
|
|
getTexObjP(),
|
|
GXTexFilter(timg->minFilter),
|
|
GXTexFilter(timg->magFilter),
|
|
timg->minLOD * 0.125f,
|
|
timg->maxLOD * 0.125f,
|
|
timg->LODBias * 0.01f,
|
|
timg->biasClamp,
|
|
timg->doEdgeLOD,
|
|
GXAnisotropy(timg->maxAnisotropy)
|
|
);
|
|
}
|
|
|
|
/* 8006580C-8006584C .text TexObjLoad__14dClothVobj04_cFv */
|
|
void dClothVobj04_c::TexObjLoad() {
|
|
GXLoadTlut(&mTlutObj, 0);
|
|
GXLoadTexObj(getTexObjP(), GX_TEXMAP0);
|
|
}
|
|
|
|
/* 8006584C-80065998 .text dClothVobj04_create__FP7ResTIMGP7ResTIMGP12dKy_tevstr_cPP4cXyz */
|
|
dClothVobj04_c* dClothVobj04_create(ResTIMG* i_flagimage, ResTIMG* i_toonimage, dKy_tevstr_c* tevstr, cXyz** posArr) {
|
|
dClothVobj04_c* pCloth = new dClothVobj04_c(i_toonimage, tevstr, posArr);
|
|
if (pCloth && !pCloth->chkCreateBuff()) {
|
|
pCloth = NULL;
|
|
} else if (pCloth && i_flagimage) {
|
|
pCloth->TexObjInit(i_flagimage);
|
|
pCloth->init();
|
|
}
|
|
|
|
return pCloth;
|
|
}
|
|
|
|
/* 80065998-80065A5C .text cloth_copy__14dClothVobj05_cFv */
|
|
void dClothVobj05_c::cloth_copy() {
|
|
changeCurrentBuff();
|
|
memcpy(getNrmP(), top_pointer->getNrmP(), sizeof(cXyz) * mHoistGridSize * mFlyGridSize);
|
|
memcpy(getBackNrmP(), top_pointer->getBackNrmP(), sizeof(cXyz) * mHoistGridSize * mFlyGridSize);
|
|
memcpy(getSpdP(), top_pointer->getSpdP(), sizeof(cXyz) * mHoistGridSize * mFlyGridSize);
|
|
}
|
|
|
|
/* 80065A5C-80065B70 .text init__14dClothVobj05_cFv */
|
|
void dClothVobj05_c::init() {
|
|
if (cloth_counter == (s32)g_Counter.mTimer) {
|
|
memcpy(getNrmP(), top_pointer->getNrmP(), sizeof(cXyz) * mHoistGridSize * mFlyGridSize);
|
|
memcpy(getBackNrmP(), top_pointer->getBackNrmP(), sizeof(cXyz) * mHoistGridSize * mFlyGridSize);
|
|
memcpy(getSpdP(), top_pointer->getSpdP(), sizeof(cXyz) * mHoistGridSize * mFlyGridSize);
|
|
} else {
|
|
dCloth_packet_c::init();
|
|
}
|
|
|
|
if (dStage_stagInfo_GetSTType(dComIfGp_getStageStagInfo()) == dStageType_MISC_e) {
|
|
mIsIndoors = true;
|
|
} else {
|
|
mIsIndoors = false;
|
|
}
|
|
}
|
|
|
|
/* 80065B70-80065CA0 .text cloth_move__14dClothVobj05_cFv */
|
|
void dClothVobj05_c::cloth_move() {
|
|
if (mIsStandItem) {
|
|
if (cloth_counter == (s32)g_Counter.mTimer) {
|
|
cloth_copy();
|
|
return;
|
|
}
|
|
cloth_counter = g_Counter.mTimer;
|
|
top_pointer = this;
|
|
}
|
|
|
|
f32 windSpeed = REG10_F(5) + 7.0f;
|
|
f32 windSpeedWave = REG10_F(6) + 2.0f;
|
|
|
|
if (mIsIndoors) {
|
|
windSpeed *= 0.05f;
|
|
windSpeedWave = 0.0f;
|
|
setParam(0.45f, -1.0f, 0.7f, 0.95f, 0.95f, 0, 0, 0, 0, 7.0f, 6.0f);
|
|
} else {
|
|
setParam(0.45f, -1.0f, 0.65f, 0.9f, 0.95f, 0x200, 0, 900, -800, 7.0f, 6.0f);
|
|
}
|
|
|
|
setWindPower(windSpeed, windSpeedWave);
|
|
|
|
dCloth_packet_c::cloth_move();
|
|
}
|
|
|
|
/* 80065CA0-80065DAC .text TexObjInit__14dClothVobj05_cFP7ResTIMG */
|
|
void dClothVobj05_c::TexObjInit(ResTIMG* timg) {
|
|
GXInitTlutObj(&mTlutObj, (u8*)&timg->format + timg->paletteOffset, GXTlutFmt(timg->colorFormat), timg->numColors);
|
|
#if VERSION == VERSION_DEMO
|
|
const GXBool mipmap = timg->mipmapCount > 1;
|
|
#endif
|
|
|
|
GXInitTexObjCI(
|
|
getTexObjP(),
|
|
&timg->format + timg->imageOffset,
|
|
timg->width,
|
|
timg->height,
|
|
GXCITexFmt(timg->format),
|
|
GXTexWrapMode(timg->wrapS),
|
|
GXTexWrapMode(timg->wrapT),
|
|
#if VERSION == VERSION_DEMO
|
|
mipmap,
|
|
#else
|
|
timg->mipmapCount > 1,
|
|
#endif
|
|
0
|
|
);
|
|
|
|
GXInitTexObjLOD(
|
|
getTexObjP(),
|
|
GXTexFilter(timg->minFilter),
|
|
GXTexFilter(timg->magFilter),
|
|
timg->minLOD * 0.125f,
|
|
timg->maxLOD * 0.125f,
|
|
timg->LODBias * 0.01f,
|
|
timg->biasClamp,
|
|
timg->doEdgeLOD,
|
|
GXAnisotropy(timg->maxAnisotropy)
|
|
);
|
|
}
|
|
|
|
/* 80065DAC-80065DEC .text TexObjLoad__14dClothVobj05_cFv */
|
|
void dClothVobj05_c::TexObjLoad() {
|
|
GXLoadTlut(&mTlutObj, 0);
|
|
GXLoadTexObj(getTexObjP(), GX_TEXMAP0);
|
|
}
|
|
|
|
/* 80065DEC-80065DF8 .text dClothVobj05_VtxFactorCB__FP15dCloth_packet_cii */
|
|
int dClothVobj05_VtxFactorCB(dCloth_packet_c* self, int x, int y) {
|
|
return x == 0 ? 1 : 0;
|
|
}
|
|
|
|
/* 80065DF8-80065F50 .text dClothVobj05_create__FP7ResTIMGP7ResTIMGP12dKy_tevstr_cPP4cXyz */
|
|
dClothVobj05_c* dClothVobj05_create(ResTIMG* i_flagimage, ResTIMG* i_toonimage, dKy_tevstr_c* tevstr, cXyz** posArr) {
|
|
dClothVobj05_c* pCloth = new dClothVobj05_c(i_toonimage, tevstr, posArr);
|
|
if (pCloth && !pCloth->chkCreateBuff()) {
|
|
pCloth = NULL;
|
|
} else if (pCloth && i_flagimage) {
|
|
pCloth->TexObjInit(i_flagimage);
|
|
pCloth->init();
|
|
pCloth->setFactorCheckCB(dClothVobj05_VtxFactorCB);
|
|
}
|
|
|
|
return pCloth;
|
|
}
|
|
|
|
/* 80065F50-80066014 .text cloth_copy__16dClothVobj07_0_cFv */
|
|
void dClothVobj07_0_c::cloth_copy() {
|
|
changeCurrentBuff();
|
|
memcpy(getNrmP(), top_pointer->getNrmP(), sizeof(cXyz) * mHoistGridSize * mFlyGridSize);
|
|
memcpy(getBackNrmP(), top_pointer->getBackNrmP(), sizeof(cXyz) * mHoistGridSize * mFlyGridSize);
|
|
memcpy(getSpdP(), top_pointer->getSpdP(), sizeof(cXyz) * mHoistGridSize * mFlyGridSize);
|
|
}
|
|
|
|
/* 80066014-80066128 .text init__16dClothVobj07_0_cFv */
|
|
void dClothVobj07_0_c::init() {
|
|
if (cloth_counter == (s32)g_Counter.mTimer) {
|
|
memcpy(getNrmP(), top_pointer->getNrmP(), sizeof(cXyz) * mHoistGridSize * mFlyGridSize);
|
|
memcpy(getBackNrmP(), top_pointer->getBackNrmP(), sizeof(cXyz) * mHoistGridSize * mFlyGridSize);
|
|
memcpy(getSpdP(), top_pointer->getSpdP(), sizeof(cXyz) * mHoistGridSize * mFlyGridSize);
|
|
} else {
|
|
dCloth_packet_c::init();
|
|
}
|
|
|
|
if (dStage_stagInfo_GetSTType(dComIfGp_getStageStagInfo()) == dStageType_MISC_e) {
|
|
mIsIndoors = true;
|
|
} else {
|
|
mIsIndoors = false;
|
|
}
|
|
}
|
|
|
|
/* 80066128-8006625C .text cloth_move__16dClothVobj07_0_cFv */
|
|
void dClothVobj07_0_c::cloth_move() {
|
|
if (mIsStandItem) {
|
|
if (cloth_counter == (s32)g_Counter.mTimer) {
|
|
cloth_copy();
|
|
return;
|
|
}
|
|
cloth_counter = g_Counter.mTimer;
|
|
top_pointer = this;
|
|
}
|
|
|
|
f32 windSpeed = REG10_F(5) + 7.0f;
|
|
f32 windSpeedWave = REG10_F(6) + 2.0f;
|
|
|
|
if (mIsIndoors) {
|
|
windSpeed *= 0.05f;
|
|
windSpeedWave = 0.0f;
|
|
setParam(0.35f, -1.0f, 0.7f, 1.1f, 1.1f, 0, 0, 900, -800, 7.0f, 6.0f);
|
|
} else {
|
|
setParam(0.4f, -0.5f, 0.7f, 1.1f, 1.1f, 0x100, 0, 900, -800, 7.0f, 6.0f);
|
|
}
|
|
|
|
setWindPower(windSpeed, windSpeedWave);
|
|
|
|
dCloth_packet_c::cloth_move();
|
|
}
|
|
|
|
/* 8006625C-80066368 .text TexObjInit__16dClothVobj07_0_cFP7ResTIMG */
|
|
void dClothVobj07_0_c::TexObjInit(ResTIMG* timg) {
|
|
GXInitTlutObj(&mTlutObj, (u8*)&timg->format + timg->paletteOffset, GXTlutFmt(timg->colorFormat), timg->numColors);
|
|
#if VERSION == VERSION_DEMO
|
|
const GXBool mipmap = timg->mipmapCount > 1;
|
|
#endif
|
|
|
|
GXInitTexObjCI(
|
|
getTexObjP(),
|
|
&timg->format + timg->imageOffset,
|
|
timg->width,
|
|
timg->height,
|
|
GXCITexFmt(timg->format),
|
|
GXTexWrapMode(timg->wrapS),
|
|
GXTexWrapMode(timg->wrapT),
|
|
#if VERSION == VERSION_DEMO
|
|
mipmap,
|
|
#else
|
|
timg->mipmapCount > 1,
|
|
#endif
|
|
0
|
|
);
|
|
|
|
GXInitTexObjLOD(
|
|
getTexObjP(),
|
|
GXTexFilter(timg->minFilter),
|
|
GXTexFilter(timg->magFilter),
|
|
timg->minLOD * 0.125f,
|
|
timg->maxLOD * 0.125f,
|
|
timg->LODBias * 0.01f,
|
|
timg->biasClamp,
|
|
timg->doEdgeLOD,
|
|
GXAnisotropy(timg->maxAnisotropy)
|
|
);
|
|
}
|
|
|
|
/* 80066368-800663A8 .text TexObjLoad__16dClothVobj07_0_cFv */
|
|
void dClothVobj07_0_c::TexObjLoad() {
|
|
GXLoadTlut(&mTlutObj, 0);
|
|
GXLoadTexObj(getTexObjP(), GX_TEXMAP0);
|
|
}
|
|
|
|
/* 800663A8-800663B4 .text dClothVobj07_0_VtxFactorCB__FP15dCloth_packet_cii */
|
|
int dClothVobj07_0_VtxFactorCB(dCloth_packet_c* self, int x, int y) {
|
|
return x == 0 ? 1 : 0;
|
|
}
|
|
|
|
/* 800663B4-8006650C .text dClothVobj07_0_create__FP7ResTIMGP7ResTIMGP12dKy_tevstr_cPP4cXyz */
|
|
dClothVobj07_0_c* dClothVobj07_0_create(ResTIMG* i_flagimage, ResTIMG* i_toonimage, dKy_tevstr_c* tevstr, cXyz** posArr) {
|
|
dClothVobj07_0_c* pCloth = new dClothVobj07_0_c(i_toonimage, tevstr, posArr);
|
|
if (pCloth && !pCloth->chkCreateBuff()) {
|
|
pCloth = NULL;
|
|
} else if (pCloth && i_flagimage) {
|
|
pCloth->TexObjInit(i_flagimage);
|
|
pCloth->init();
|
|
pCloth->setFactorCheckCB(&dClothVobj07_0_VtxFactorCB);
|
|
}
|
|
|
|
return pCloth;
|
|
}
|