diff --git a/configure.py b/configure.py index cca6518fb..dad5552c1 100644 --- a/configure.py +++ b/configure.py @@ -453,7 +453,7 @@ def MatchingFor(*versions): Object(NonMatching, "SB/Core/x/xpkrsvc.cpp"), Object(Matching, "SB/Core/x/xQuickCull.cpp"), Object(Matching, "SB/Core/x/xsavegame.cpp"), - Object(NonMatching, "SB/Core/x/xScene.cpp"), + Object(NonMatching, "SB/Core/x/xScene.cpp", extra_cflags=["-sym on"]), Object(NonMatching, "SB/Core/x/xScrFx.cpp"), Object(NonMatching, "SB/Core/x/xserializer.cpp"), Object(NonMatching, "SB/Core/x/xSFX.cpp"), diff --git a/src/SB/Core/gc/iCollide.h b/src/SB/Core/gc/iCollide.h index d6901e9ed..0db5cbe2f 100644 --- a/src/SB/Core/gc/iCollide.h +++ b/src/SB/Core/gc/iCollide.h @@ -13,6 +13,7 @@ RpCollisionTriangle* sphereHitsEnvCB(RpIntersection* isx, RpWorldSector* sector, S32 iSphereHitsEnv3(const xSphere* b, const xEnv* env, xCollis* colls, U8 ncolls, F32 sth); S32 iSphereHitsModel3(const xSphere* b, const xModelInstance* m, xCollis* colls, U8 ncolls, F32 sth); +U32 iRayHitsEnv(const xRay3* r, const xEnv* env, xCollis* coll); U32 iRayHitsModel(const xRay3* r, const xModelInstance* m, xCollis* coll); void iSphereForModel(xSphere* o, const xModelInstance* m); void iCollideInit(xScene* sc); diff --git a/src/SB/Core/x/xGrid.cpp b/src/SB/Core/x/xGrid.cpp index 6b2733de6..9ff56f898 100644 --- a/src/SB/Core/x/xGrid.cpp +++ b/src/SB/Core/x/xGrid.cpp @@ -6,10 +6,6 @@ #include "xMemMgr.h" #include "xEnt.h" -extern float xGrid_float_0p001; -extern float xGrid_float_one; -extern float xGrid_float_one_quarter; - volatile S32 gGridIterActive = 0; void xGridBoundInit(xGridBound* bound, void* data) @@ -43,25 +39,25 @@ void xGridInit(xGrid* grid, const xBox* bounds, U16 nx, U16 nz, U8 ingrid_id) grid->csizex = gsizex / nx; grid->csizez = gsizex / nz; - if (__fabs(gsizex) <= xGrid_float_0p001) + if (__fabs(gsizex) <= 0.001f) { - grid->inv_csizex = xGrid_float_one; + grid->inv_csizex = 1.0f; } else { grid->inv_csizex = nx / gsizex; } - if (__fabs(gsizez) <= xGrid_float_0p001) + if (__fabs(gsizez) <= 0.001f) { - grid->inv_csizez = xGrid_float_one; + grid->inv_csizez = 1.0f; } else { grid->inv_csizez = nz / gsizez; } - grid->maxr = xGrid_float_one_quarter * MAX(grid->csizex, grid->csizez); + grid->maxr = 0.25f * MAX(grid->csizex, grid->csizez); grid->cells = (xGridBound**)xMemAllocSize(nx * nz * sizeof(xGridBound*)); memset(grid->cells, 0, sizeof(xGridBound*) * (nz * nx)); } @@ -128,6 +124,94 @@ void xGridAdd(xGrid* grid, xGridBound* bound, S32 x, S32 z) xGridAddToCell(&grid->cells[z * grid->nx] + x, bound); } +S32 xGridAdd(xGrid* grid, xEnt* ent) +//NONMATCH("https://decomp.me/scratch/5R7FZ") +{ + xBound* bound; + xVec3* center; + F32 maxr; + + bound = &ent->bound; + maxr = grid->maxr; + + if (bound->type == XBOUND_TYPE_SPHERE) + { + xSphere* sph = &bound->sph; + center = &sph->center; + if (bound->sph.r >= maxr) + { + S32 r = xGridAddToCell(&grid->other, &ent->gridb); + if (r) + { + ent->gridb.ingrid = grid->ingrid_id; + } + return r; + } + } + else if (bound->type == XBOUND_TYPE_OBB) + { + xBBox* bbox = &bound->box; + center = &bbox->center; + F32 rx = bbox->box.upper.x - bbox->box.lower.x; + F32 ry = bbox->box.upper.y - bbox->box.lower.y; + F32 rz = bbox->box.upper.z - bbox->box.lower.z; + F32 len2 = + SQR(rx) * + (SQR(bound->mat->right.x) + SQR(bound->mat->right.y) + SQR(bound->mat->right.z)) + + SQR(ry) * (SQR(bound->mat->up.x) + SQR(bound->mat->up.y) + SQR(bound->mat->up.z)) + + SQR(rz) * (SQR(bound->mat->at.x) + SQR(bound->mat->at.y) + SQR(bound->mat->at.z)); + if (len2 >= 4.0f * maxr * maxr) + { + S32 r = xGridAddToCell(&grid->other, &ent->gridb); + if (r) + { + ent->gridb.ingrid = grid->ingrid_id; + } + return r; + } + } + else if (bound->type == XBOUND_TYPE_BOX) + { + xBBox* bbox = &bound->box; + center = &bbox->center; + F32 rx = bound->box.box.upper.x - bound->box.box.lower.x; + F32 rz = bound->box.box.upper.z - bound->box.box.lower.z; + F32 len2 = SQR(rx) + SQR(rz); + if (len2 >= 4.0f * maxr * maxr) + { + S32 r = xGridAddToCell(&grid->other, &ent->gridb); + if (r) + { + ent->gridb.ingrid = grid->ingrid_id; + } + return r; + } + } + else + { + return 0; + } + + F32 cgridx = center->x - grid->minx; + cgridx *= grid->inv_csizex; + + F32 cgridz = center->z - grid->minz; + cgridz *= grid->inv_csizez; + + S32 x = (S32)MIN(grid->nx - 1, MAX(0.0f, cgridx)); + S32 z = (S32)MIN(grid->nz - 1, MAX(0.0f, cgridz)); + + if (1) + { + ent->gridb.gx = x; + ent->gridb.gz = z; + ent->gridb.ingrid = grid->ingrid_id; + return 1; + } + + return 0; +} + S32 xGridRemove(xGridBound* bound) { if (bound->head) @@ -214,3 +298,142 @@ xGridBound* xGridIterFirstCell(xGrid* grid, F32 posx, F32 posy, F32 posz, S32& g xGridGetCell(grid, posx, posy, posz, grx, grz); return xGridIterFirstCell(grid, grx, grz, iter); } + +S32 xGridEntIsTooBig(xGrid* grid, const xEnt* ent) +{ + const xBound* bound = &ent->bound; + F32 maxr = grid->maxr; + + if (bound->type == XBOUND_TYPE_SPHERE) + { + const xSphere* sph = &bound->sph; + if (sph->r >= maxr) + { + return 1; + } + } + else if (bound->type == XBOUND_TYPE_OBB) + { + const xBBox* bbox = &bound->box; + F32 rx = bbox->box.upper.x - bbox->box.lower.x; + F32 ry = bbox->box.upper.y - bbox->box.lower.y; + F32 rz = bbox->box.upper.z - bbox->box.lower.z; + F32 len2 = + SQR(rx) * + (SQR(bound->mat->right.x) + SQR(bound->mat->right.y) + SQR(bound->mat->right.z)) + + SQR(ry) * (SQR(bound->mat->up.x) + SQR(bound->mat->up.y) + SQR(bound->mat->up.z)) + + SQR(rz) * (SQR(bound->mat->at.x) + SQR(bound->mat->at.y) + SQR(bound->mat->at.z)); + if (len2 >= 4.0f * maxr * maxr) + { + return 1; + } + } + else if (bound->type == XBOUND_TYPE_BOX) + { + const xBBox* bbox = &bound->box; + F32 rx = bbox->box.upper.x - bbox->box.lower.x; + F32 rz = bbox->box.upper.z - bbox->box.lower.z; + F32 len2 = SQR(rx) + SQR(rz); + if (len2 >= 4.0f * maxr * maxr) + { + return 1; + } + } + + return 0; +} + +void xGridCheckPosition(xGrid* grid, xVec3* pos, xQCData* qcd, xGridCheckPositionCallback hitCB, + void* cbdata) +{ + xGridIterator it; + S32 px, pz; + xGridBound* cell; + + cell = xGridIterFirstCell(grid, pos->x, pos->y, pos->z, px, pz, it); + while (cell) + { + xBound* cellbound = (xBound*)(cell + 1); + if (xQuickCullIsects(qcd, &cellbound->qcd) && !hitCB((xEnt*)cell->data, cbdata)) + { + xGridIterClose(it); + return; + } + cell = xGridIterNextCell(it); + } + + xBox clbox; + clbox.lower.x = grid->csizex * px; + clbox.lower.z = grid->csizez * pz; + clbox.lower.x += grid->minx; + clbox.lower.z += grid->minz; + + F32 clcenterx = 0.5f * grid->csizex; + clcenterx += clbox.lower.x; + + F32 clcenterz = 0.5f * grid->csizez; + clcenterz += clbox.lower.z; + + static S32 offs[4][3][2] = { -1, 0, -1, -1, 0, -1, 0, -1, 1, -1, 1, 0, + 1, 0, 1, 1, 0, 1, 0, 1, -1, 1, -1, 0 }; + + static S32 k; + + if (pos->x < clcenterx) + { + if (pos->z < clcenterz) + { + k = 0; + } + else + { + k = 1; + } + } + else + { + if (pos->z < clcenterz) + { + k = 3; + } + else + { + k = 2; + } + } + + for (S32 i = 0; i < 3; i++) + { + S32 _x = px + offs[k][i][1]; + if (_x >= 0 && _x < grid->nx) + { + S32 _z = pz + offs[k][i][0]; + if (_z >= 0 && _z < grid->nz) + { + cell = xGridIterFirstCell(grid, _x, _z, it); + while (cell) + { + xBound* cellbound = (xBound*)(cell + 1); + if (xQuickCullIsects(qcd, &cellbound->qcd) && !hitCB((xEnt*)cell->data, cbdata)) + { + xGridIterClose(it); + return; + } + cell = xGridIterNextCell(it); + } + } + } + } + + cell = xGridIterFirstCell(&grid->other, it); + while (cell) + { + xBound* cellbound = (xBound*)(cell + 1); + if (xQuickCullIsects(qcd, &cellbound->qcd) && !hitCB((xEnt*)cell->data, cbdata)) + { + xGridIterClose(it); + return; + } + cell = xGridIterNextCell(it); + } +} diff --git a/src/SB/Core/x/xGrid.h b/src/SB/Core/x/xGrid.h index 653df9e32..0f0c543f9 100644 --- a/src/SB/Core/x/xGrid.h +++ b/src/SB/Core/x/xGrid.h @@ -5,9 +5,13 @@ #include "xMath3.h" +#include "xBound.h" + struct xEnt; struct xQCData; +typedef S32 (*xGridCheckPositionCallback)(xEnt*, void*); + struct xGridBound { void* data; @@ -174,4 +178,74 @@ inline void xGridIterClose(xGridIterator& it) } } +struct grid_index +{ + U16 x; + U16 z; +}; + +inline grid_index get_grid_index(const xGrid& grid, F32 x, F32 z) + +//NONMATCH("https://decomp.me/scratch/pMa66") +{ + grid_index index = { range_limit((U16)((x - grid.minx) * grid.inv_csizex), 0, grid.nx - 1), + range_limit((U16)((z - grid.minz) * grid.inv_csizez), 0, + grid.nz - 1) }; + return index; +} + +template +inline void xGridCheckBound(xGrid& grid, const xBound& bound, const xQCData& qcd, T cb) +{ + xGridIterator it; + + xBox box; + xBoundGetBox(box, bound); + + F32 ex = 0.25f * grid.csizex; + F32 ez = 0.25f * grid.csizez; + box.lower.x -= ex; + box.lower.z -= ez; + box.upper.x += ex; + box.upper.z += ez; + + grid_index var_4C, var_50; + var_50 = get_grid_index(grid, box.lower.x, box.lower.z); + var_4C = get_grid_index(grid, box.upper.x, box.upper.z); + + xGridBound* cell = xGridIterFirstCell(&grid.other, it); + while (cell) + { + if (xQuickCullIsects(&qcd, &((xBound*)(cell + 1))->qcd)) + { + if (!cb(*(xEnt*)cell->data, *cell)) + { + xGridIterClose(it); + return; + } + } + cell = xGridIterNextCell(it); + } + + for (U16 gx = var_50.x; gx <= var_4C.x; gx++) + { + for (U16 gz = var_50.z; gz <= var_4C.z; gz++) + { + xGridBound* cell = xGridIterFirstCell(&grid, gx, gz, it); + while (cell) + { + if (xQuickCullIsects(&qcd, &((xBound*)(cell + 1))->qcd)) + { + if (!cb(*(xEnt*)cell->data, *cell)) + { + xGridIterClose(it); + return; + } + } + cell = xGridIterNextCell(it); + } + } + } +} + #endif diff --git a/src/SB/Core/x/xQuickCull.h b/src/SB/Core/x/xQuickCull.h index 679592c6d..de95fa927 100644 --- a/src/SB/Core/x/xQuickCull.h +++ b/src/SB/Core/x/xQuickCull.h @@ -54,6 +54,7 @@ static void xQuickCullCellForVec(xQCControl* ctrl, xQCData* c, const xVec3* v); static void xQuickCullCellMerge(xQCData* dest, const xQCData* a, const xQCData* b); void xQuickCullForLine(xQCControl* ctrl, xQCData* q, const xLine3* ln); void xQuickCullForRay(xQCControl* ctrl, xQCData* q, const xRay3* r); +void xQuickCullForRay(xQCData* q, const xRay3* r); void xQuickCullForSphere(xQCControl* ctrl, xQCData* q, const xSphere* s); void xQuickCullForBox(xQCControl* ctrl, xQCData* q, const xBox* box); void xQuickCullForBox(xQCData* q, const xBox* box); diff --git a/src/SB/Core/x/xScene.cpp b/src/SB/Core/x/xScene.cpp index e2b6655d8..785551bec 100644 --- a/src/SB/Core/x/xScene.cpp +++ b/src/SB/Core/x/xScene.cpp @@ -3,10 +3,12 @@ #include "xMemMgr.h" #include "xCollideFast.h" #include "xMath.h" +#include "xMathInlines.h" #include "iMath.h" #include "iCollide.h" #include "zBase.h" +#include "zGrid.h" #include #include @@ -14,7 +16,15 @@ #include -extern F32 lbl_803CCF78; +xScene* g_xSceneCur; +static xMat4x3* sBoxTestMat; +static U8 sUseJSP; +static void* sTestOPtr; +static xModelInstance* sTestMPtr; +static xBound sNearestBound; +static U8 sNearestChk; +static U8 sNearestCollType; +static RpIntersection sSphereIsx; namespace { @@ -167,6 +177,335 @@ void xSceneForAllNPCs(xScene* sc, xSceneEntCallback func, void* data) } } +void xRayHitsGrid(xGrid* grid, xScene* sc, xRay3* r, xRayEntCallback rentcb, xQCData* qcr, + void* data) +//NONMATCH("https://decomp.me/scratch/2kH6a") +{ + xLine3 ln; + xGridIterator it; + + r->flags |= (XRAY3_USE_MIN | XRAY3_USE_MAX); + if (r->flags & XRAY3_USE_MIN) + { + xVec3 delta; + delta.x = r->dir.x * r->min_t; + delta.y = r->dir.y * r->min_t; + delta.z = r->dir.z * r->min_t; + ln.p1.x = r->origin.x + delta.x; + ln.p1.y = r->origin.y + delta.y; + ln.p1.z = r->origin.z + delta.z; + } + else + { + ln.p1.x = r->origin.x; + ln.p1.y = r->origin.y; + ln.p1.z = r->origin.z; + } + if (r->flags & XRAY3_USE_MAX) + { + F32 len; + if (r->flags & XRAY3_USE_MIN) + { + len = r->max_t - r->min_t; + } + else + { + len = r->max_t; + } + ln.p2.x = r->dir.x * len; + ln.p2.y = r->dir.y * len; + ln.p2.z = r->dir.z * len; + } + else + { + ln.p2.x = r->dir.x; + ln.p2.y = r->dir.y; + ln.p2.z = r->dir.z; + } + + ln.p2.x = ln.p1.x + ln.p2.x; + ln.p2.y = ln.p1.y + ln.p2.y; + ln.p2.z = ln.p1.z + ln.p2.z; + + S32 sclgx, sclgz; + S32 eclgx, eclgz; + F32 sclcx, sclcz; + F32 eclcx, eclcz; + F32 halfclx, halfclz; + F32 quatrclx, quatrclz; + S32 sz, ez; + S32 x, z; + + halfclx = 0.5f * grid->csizex; + halfclz = 0.5f * grid->csizez; + quatrclx = 0.25f * grid->csizex; + quatrclz = 0.25f * grid->csizez; + + if (xeq(r->dir.z, 0.0f, 1e-5f)) + { + if (r->dir.z >= 0.0f) + { + r->dir.z = 1e-5f; + } + else + { + r->dir.z = -1e-5f; + } + } + + F32 dxdz = r->dir.x / r->dir.z; + + xGridGetCell(grid, ln.p1.x, ln.p1.y, ln.p1.z, sclgx, sclgz); + xGridGetCell(grid, ln.p2.x, ln.p2.y, ln.p2.z, eclgx, eclgz); + + sclcx = grid->csizex * sclgx; + sclcz = grid->csizez * sclgz; + eclcx = grid->csizex * eclgx; + eclcz = grid->csizez * eclgz; + sclcx += grid->minx; + sclcz += grid->minz; + eclcx += grid->minx; + eclcz += grid->minz; + sclcx += halfclx; + sclcz += halfclz; + eclcx += halfclx; + eclcz += halfclz; + + if (ln.p1.z < ln.p2.z) + { + sz = sclgz; + ez = eclgz; + if (sclgz > 0 && ln.p1.z < sclcz - quatrclz) + sz--; + if (eclgz < grid->nz - 1 && ln.p2.z > eclcz + quatrclz) + ez++; + for (z = sz; z <= ez; z++) + { + F32 cz; + F32 lz, rz; + F32 lx, rx; + F32 ly, ry; + S32 aclgx, aclgz; + S32 bclgx, bclgz; + F32 aclcx, aclcz; + F32 bclcx, bclcz; + S32 ax, bx; + + cz = sclcz + grid->csizez * (z - sz); + lz = cz - halfclz; + rz = cz + halfclz; + + if (lz < ln.p1.z) + { + lx = ln.p1.x; + lz = ln.p1.z; + } + else + { + lx = ln.p1.x + dxdz * (lz - ln.p1.z); + } + + if (rz > ln.p2.z) + { + rx = ln.p2.x; + rz = ln.p2.z; + } + else + { + rx = ln.p1.x + dxdz * (rz - ln.p1.z); + } + + ly = 0.0f; + ry = 0.0f; + + xGridGetCell(grid, lx, ly, lz, aclgx, aclgz); + xGridGetCell(grid, rx, ry, rz, bclgx, bclgz); + + aclcx = grid->csizex * aclgx; + aclcz = grid->csizez * aclgz; + bclcx = grid->csizex * bclgx; + bclcz = grid->csizez * bclgz; + aclcx += grid->minx; + aclcz += grid->minz; + bclcx += grid->minx; + bclcz += grid->minz; + aclcx += halfclx; + aclcz += halfclz; + bclcx += halfclx; + bclcz += halfclz; + + if (lx < rx) + { + ax = aclgx; + bx = bclgx; + if (aclgx > 0 && lx < aclcx - quatrclx) + ax--; + if (bclgx < grid->nx - 1 && rx > bclcx + quatrclx) + bx++; + + for (x = ax; x <= bx; x++) + { + xGridBound* cell = xGridIterFirstCell(grid, x, z, it); + while (cell) + { + xBound* cellbound = (xBound*)(cell + 1); + if (xQuickCullIsects(qcr, &cellbound->qcd)) + { + rentcb(sc, r, qcr, (xEnt*)cell->data, data); + } + cell = xGridIterNextCell(it); + } + } + } + else + { + ax = aclgx; + bx = bclgx; + if (bclgx > 0 && rx < bclcx - quatrclx) + bx--; + if (aclgx < grid->nx - 1 && lx > bclcx + quatrclx) + ax++; + + for (x = bx; x <= ax; x++) + { + xGridBound* cell = xGridIterFirstCell(grid, x, z, it); + while (cell) + { + xBound* cellbound = (xBound*)(cell + 1); + if (xQuickCullIsects(qcr, &cellbound->qcd)) + { + rentcb(sc, r, qcr, (xEnt*)cell->data, data); + } + cell = xGridIterNextCell(it); + } + } + } + } + } + else + { + sz = sclgz; + ez = eclgz; + if (eclgz > 0 && ln.p2.z < eclcz - quatrclz) + ez--; + if (sclgz < grid->nz - 1 && ln.p1.z > sclcz + quatrclz) + sz++; + for (z = ez; z <= sz; z++) + { + F32 cz; + F32 lz, rz; + F32 lx, rx; + F32 ly, ry; + S32 aclgx, aclgz; + S32 bclgx, bclgz; + F32 aclcx, aclcz; + F32 bclcx, bclcz; + S32 ax, bx; + + cz = eclcz + grid->csizez * (z - ez); + lz = cz - halfclz; + rz = cz + halfclz; + + if (lz < ln.p2.z) + { + lx = ln.p2.x; + lz = ln.p2.z; + } + else + { + lx = ln.p2.x + dxdz * (ln.p2.z - lz); + } + + if (rz > ln.p1.z) + { + rx = ln.p1.x; + rz = ln.p1.z; + } + else + { + rx = ln.p2.x + dxdz * (ln.p2.z - rz); + } + + ly = 0.0f; + ry = 0.0f; + + xGridGetCell(grid, lx, ly, lz, aclgx, aclgz); + xGridGetCell(grid, rx, ry, rz, bclgx, bclgz); + + aclcx = grid->csizex * aclgx; + aclcz = grid->csizez * aclgz; + bclcx = grid->csizex * bclgx; + bclcz = grid->csizez * bclgz; + aclcx += grid->minx; + aclcz += grid->minz; + bclcx += grid->minx; + bclcz += grid->minz; + aclcx += halfclx; + aclcz += halfclz; + bclcx += halfclx; + bclcz += halfclz; + + if (lx < rx) + { + ax = aclgx; + bx = bclgx; + if (aclgx > 0 && lx < aclcx - quatrclx) + ax--; + if (bclgx < grid->nx - 1 && rx > bclcx + quatrclx) + bx++; + + for (x = ax; x <= bx; x++) + { + xGridBound* cell = xGridIterFirstCell(grid, x, z, it); + while (cell) + { + xBound* cellbound = (xBound*)(cell + 1); + if (xQuickCullIsects(qcr, &cellbound->qcd)) + { + rentcb(sc, r, qcr, (xEnt*)cell->data, data); + } + cell = xGridIterNextCell(it); + } + } + } + else + { + ax = aclgx; + bx = bclgx; + if (bclgx > 0 && rx < bclcx - quatrclx) + bx--; + if (aclgx < grid->nx - 1 && lx > bclcx + quatrclx) + ax++; + + for (x = bx; x <= ax; x++) + { + xGridBound* cell = xGridIterFirstCell(grid, x, z, it); + while (cell) + { + xBound* cellbound = (xBound*)(cell + 1); + if (xQuickCullIsects(qcr, &cellbound->qcd)) + { + rentcb(sc, r, qcr, (xEnt*)cell->data, data); + } + cell = xGridIterNextCell(it); + } + } + } + } + } + + xGridBound* cell = xGridIterFirstCell(&grid->other, it); + while (cell) + { + xBound* cellbound = (xBound*)(cell + 1); + if (xQuickCullIsects(qcr, &cellbound->qcd)) + { + rentcb(sc, r, qcr, (xEnt*)cell->data, data); + } + cell = xGridIterNextCell(it); + } +} + void xRayHitsTikiLandableEnt(xScene* sc, xRay3* r, xQCData* qcr, xEnt* ent, void* colldata) { xCollis* coll = (xCollis*)colldata; @@ -249,11 +588,119 @@ void xRayHitsEnt(xScene* sc, xRay3* r, xQCData* qcr, xEnt* ent, void* colldata) } } +void xRayHitsTikiLandableScene(xScene* sc, xRay3* r, xCollis* coll) +{ + coll->dist = HUGE; + + xQCData q; + xQuickCullForRay(&q, r); + + xRayHitsGrid(&colls_grid, sc, r, xRayHitsTikiLandableEnt, &q, coll); + xRayHitsGrid(&colls_oso_grid, sc, r, xRayHitsTikiLandableEnt, &q, coll); + xRayHitsGrid(&npcs_grid, sc, r, xRayHitsTikiLandableEnt, &q, coll); + + xCollis c; + iRayHitsEnv(r, sc->env, &c); + + if (c.dist < coll->dist) + { + coll->dist = c.dist; + coll->oid = c.oid; + coll->optr = NULL; + coll->mptr = NULL; + } + + if (coll->dist < HUGE) + { + coll->flags |= k_HIT_IT; + } + else + { + coll->flags &= ~k_HIT_IT; + } +} + +void xRayHitsScene(xScene* sc, xRay3* r, xCollis* coll) +{ + coll->dist = HUGE; + + xQCData q; + xQuickCullForRay(&q, r); + + xRayHitsGrid(&colls_grid, sc, r, xRayHitsEnt, &q, coll); + xRayHitsGrid(&colls_oso_grid, sc, r, xRayHitsEnt, &q, coll); + xRayHitsGrid(&npcs_grid, sc, r, xRayHitsEnt, &q, coll); + + xCollis c; + iRayHitsEnv(r, sc->env, &c); + + if (c.dist < coll->dist) + { + coll->dist = c.dist; + coll->oid = c.oid; + coll->optr = NULL; + coll->mptr = NULL; + } + + if (coll->dist < HUGE) + { + coll->flags |= k_HIT_IT; + } + else + { + coll->flags &= ~k_HIT_IT; + } +} + cb_ray_hits_ent::cb_ray_hits_ent(const xRay3& ray, xCollis& coll, U8 chkby, U8 collType) : ray(ray), coll(coll), chkby(chkby), collType(collType) { } +void xRayHitsSceneFlags(xScene* sc, xRay3* r, xCollis* coll, U8 collType, U8 chk) +//NONMATCH("https://decomp.me/scratch/ZJEEb") +{ + coll->dist = HUGE; + coll->flags = (coll->flags & ~k_HIT_IT) | k_HIT_0x100; + + cb_ray_hits_ent cb(*r, *coll, collType, chk); + + xBound bound; + bound.type = XBOUND_TYPE_BOX; + xBoxFromRay(bound.box.box, *r); + xVec3Add(&bound.box.center, &bound.box.box.lower, &bound.box.box.upper); + xVec3SMul(&bound.box.center, &bound.box.center, 0.5f); + + xQuickCullForRay(&bound.qcd, r); + + if (chk & (XENT_COLLTYPE_STAT | XENT_COLLTYPE_DYN)) + { + xGridCheckBound(colls_grid, bound, bound.qcd, cb); + xGridCheckBound(colls_oso_grid, bound, bound.qcd, cb); + } + + if (chk & XENT_COLLTYPE_NPC) + { + xGridCheckBound(npcs_grid, bound, bound.qcd, cb); + } + + if (chk & 0x20) + { + xCollis temp_coll; + temp_coll.flags = coll->flags; + temp_coll.dist = HUGE; + + iRayHitsEnv(r, sc->env, &temp_coll); + + if (temp_coll.dist < coll->dist) + { + memcpy(coll, &temp_coll, sizeof(xCollis)); + coll->optr = NULL; + coll->mptr = NULL; + } + } +} + void ProjectTriangle(xVec3* param_1, xVec3* param_2, float* param_3, float* param_4) { float fVar1; @@ -287,26 +734,402 @@ void ProjectTriangle(xVec3* param_1, xVec3* param_2, float* param_3, float* para void ProjectBox(xVec3* param_1, xBox* param_2, float* param_3, float* param_4) { - F32 fVar7 = lbl_803CCF78 * (param_1->x * ((param_2->upper).x + (param_2->lower).x) + - param_1->y * ((param_2->upper).y + (param_2->lower).y) + - param_1->z * ((param_2->upper).z + (param_2->lower).z)); - F32 fVar1 = lbl_803CCF78 * (iabs(param_1->x * ((param_2->upper).x - (param_2->lower).x)) + - iabs(param_1->y * ((param_2->upper).y - (param_2->lower).y)) + - iabs(param_1->z * ((param_2->upper).z - (param_2->lower).z))); + F32 fVar7 = 0.5f * (param_1->x * ((param_2->upper).x + (param_2->lower).x) + + param_1->y * ((param_2->upper).y + (param_2->lower).y) + + param_1->z * ((param_2->upper).z + (param_2->lower).z)); + F32 fVar1 = 0.5f * (iabs(param_1->x * ((param_2->upper).x - (param_2->lower).x)) + + iabs(param_1->y * ((param_2->upper).y - (param_2->lower).y)) + + iabs(param_1->z * ((param_2->upper).z - (param_2->lower).z))); *param_3 = fVar7 - fVar1; *param_4 = fVar7 + fVar1; } -static RpCollisionTriangle* nearestFloorCB(RpIntersection*, RpCollisionTriangle* collTriangle, F32, - void* data); +static U32 Mgc_TriBoxTest(xVec3* apkTri, xBox* rkBox) +// NONMATCH("https://decomp.me/scratch/xYaVl") +{ + F32 fMin0, fMax0, fMin1, fMax1; + xVec3 kD, akE[3], baxis; + U32 andflag, curflag; + S32 i, i0, i1; + + andflag = 0x3F; + + for (i = 0; i < 3; i++) + { + curflag = 0; + + if (apkTri[i].x > rkBox->upper.x) + { + curflag |= 0x1; + } + else if (apkTri[i].x < rkBox->lower.x) + { + curflag |= 0x2; + } + if (apkTri[i].y > rkBox->upper.y) + { + curflag |= 0x4; + } + else if (apkTri[i].y < rkBox->lower.y) + { + curflag |= 0x8; + } + if (apkTri[i].z > rkBox->upper.z) + { + curflag |= 0x10; + } + else if (apkTri[i].z < rkBox->lower.z) + { + curflag |= 0x20; + } + + if (curflag == 0) + return 1; + + andflag &= curflag; + } + + if (andflag != 0) + return 0; + + akE[0].x = apkTri[1].x - apkTri[0].x, akE[0].y = apkTri[1].y - apkTri[0].y, + akE[0].z = apkTri[1].z - apkTri[0].z; + akE[1].x = apkTri[2].x - apkTri[0].x, akE[1].y = apkTri[2].y - apkTri[0].y, + akE[1].z = apkTri[2].z - apkTri[0].z; + + kD.x = akE[0].y * akE[1].z - akE[1].y * akE[0].z, + kD.y = akE[0].z * akE[1].x - akE[1].z * akE[0].x, + kD.z = akE[0].x * akE[1].y - akE[1].x * akE[0].y; + + fMin0 = kD.x * apkTri[0].x + kD.y * apkTri[0].y + kD.z * apkTri[0].z; + fMax0 = fMin0; + + ProjectBox(&kD, rkBox, &fMin1, &fMax1); + + if (fMax1 < fMin0 || fMax0 < fMin1) + return 0; + + baxis.x = 0.0f; + baxis.y = 0.0f; + baxis.z = 0.0f; + + akE[2].x = akE[1].x - akE[0].x, akE[2].y = akE[1].y - akE[0].y, akE[2].z = akE[1].z - akE[0].z; + + for (i0 = 0; i0 < 3; i0++) + { + for (i1 = 0; i1 < 3; i1++) + { + ((F32*)&baxis)[i1] = 1.0f; + + kD.x = akE[i0].y * baxis.z - baxis.y * akE[i0].z, + kD.y = akE[i0].z * baxis.x - baxis.z * akE[i0].x, + kD.z = akE[i0].x * baxis.y - baxis.x * akE[i0].y; + + ((F32*)&baxis)[i1] = 0.0f; + + ProjectTriangle(&kD, &apkTri[0], &fMin0, &fMax0); + ProjectBox(&kD, rkBox, &fMin1, &fMax1); + + if (fMax1 < fMin0 || fMax0 < fMin1) + return 0; + } + } + + return 1; +} + +static RpCollisionTriangle* nearestFloorCB(RpIntersection*, RpCollisionTriangle* collTriangle, + RwReal, void* data) +//NONMATCH("https://decomp.me/scratch/0VY4M") +{ + xNearFloorPoly* nfpoly = (xNearFloorPoly*)data; + F32 currnear = nfpoly->neardist; + xVec3 currpt; + S32 currvert, curredge; + xVec3 xformVert[4], xformNorm; + U32 potentialOID; + S32 i; + F32 pdx[3], pdz[3]; + F32 numer, denom, t, testdist2, neardx, neardz, nearmag; + xVec3 edgevec, centvec, testpt; + + if (sUseJSP) + { + if (((xClumpCollBSPTriangle*)collTriangle->index)->flags & 0x10) + { + return collTriangle; + } + potentialOID = ((xClumpCollBSPTriangle*)collTriangle->index)->matIndex; + } + else + { + potentialOID = collTriangle->index; + } + + if (sBoxTestMat) + { + xMat4x3Toworld(&xformVert[0], sBoxTestMat, (xVec3*)collTriangle->vertices[0]); + xMat4x3Toworld(&xformVert[1], sBoxTestMat, (xVec3*)collTriangle->vertices[1]); + xMat4x3Toworld(&xformVert[2], sBoxTestMat, (xVec3*)collTriangle->vertices[2]); + xMat3x3RMulVec(&xformNorm, sBoxTestMat, (xVec3*)&collTriangle->normal); + xVec3Normalize(&xformNorm, &xformNorm); + } + else + { + xformVert[0] = *(xVec3*)collTriangle->vertices[0]; + xformVert[1] = *(xVec3*)collTriangle->vertices[1]; + xformVert[2] = *(xVec3*)collTriangle->vertices[2]; + xformNorm = *(xVec3*)&collTriangle->normal; + } + + if (xformNorm.y < nfpoly->floorDot) + { + return collTriangle; + } + + pdx[0] = nfpoly->center.x - xformVert[0].x; + pdx[1] = nfpoly->center.x - xformVert[1].x; + pdx[2] = nfpoly->center.x - xformVert[2].x; + pdz[0] = nfpoly->center.z - xformVert[0].z; + pdz[1] = nfpoly->center.z - xformVert[1].z; + pdz[2] = nfpoly->center.z - xformVert[2].z; + + F32 f3 = pdx[0] * pdz[1] - pdz[0] * pdx[1]; + F32 f2 = pdx[1] * pdz[2] - pdz[1] * pdx[2]; + F32 f1 = pdx[2] * pdz[0] - pdz[2] * pdx[0]; + + if ((f3 >= 0.0f && f2 >= 0.0f && f1 >= 0.0f) || (f3 <= 0.0f && f2 <= 0.0f && f1 <= 0.0f)) + { + nfpoly->neardist = 0.0f; + nfpoly->vert[0] = xformVert[0]; + nfpoly->vert[1] = xformVert[1]; + nfpoly->vert[2] = xformVert[2]; + nfpoly->optr = sTestOPtr; + nfpoly->mptr = sTestMPtr; + nfpoly->oid = potentialOID; + + return NULL; + } + + xformVert[1] = xformVert[0]; + + for (i = 0; i < 3; i++) + { + edgevec.x = xformVert[i + 1].x - xformVert[i].x; + edgevec.y = xformVert[i + 1].y - xformVert[i].y; + edgevec.z = xformVert[i + 1].z - xformVert[i].z; + centvec.x = nfpoly->center.x - xformVert[i].x; + centvec.y = nfpoly->center.y - xformVert[i].y; + centvec.z = nfpoly->center.z - xformVert[i].z; + + numer = centvec.x * edgevec.x + centvec.y * edgevec.y + centvec.z * edgevec.z; + denom = edgevec.x * edgevec.x + edgevec.y * edgevec.y + edgevec.z * edgevec.z; + + if (denom < 0.000001f) + { + return collTriangle; + } + + if (numer <= 0.0f) + { + testdist2 = SQR(centvec.x) + SQR(centvec.y) + SQR(centvec.z); + if (testdist2 < currnear) + { + currnear = testdist2; + currpt = xformVert[i]; + currvert = i; + curredge = -1; + } + } + else if (numer < denom) + { + t = numer / denom; + testpt.x = t * edgevec.x + xformVert[i].x; + testpt.y = t * edgevec.y + xformVert[i].y; + testpt.z = t * edgevec.z + xformVert[i].z; + testdist2 = SQR(nfpoly->center.x - testpt.x) + SQR(nfpoly->center.y - testpt.y) + + SQR(nfpoly->center.z - testpt.z); + + if (testdist2 < currnear) + { + currnear = testdist2; + currpt = testpt; + currvert = -1; + curredge = i; + } + } + } + + if (currnear != nfpoly->neardist) + { + if (nfpoly->facingDot > 0.0f) + { + neardx = currpt.x - nfpoly->center.x; + neardz = currpt.z - nfpoly->center.z; + nearmag = xsqrt(SQR(neardx) + SQR(neardz)); + + if (nearmag < 0.000001f) + { + return collTriangle; + } + + if ((neardx * nfpoly->facingVec.x + neardz * nfpoly->facingVec.z) / nearmag < + nfpoly->facingDot) + { + return collTriangle; + } + } + + nfpoly->vert[0] = xformVert[0]; + nfpoly->vert[1] = xformVert[1]; + nfpoly->vert[2] = xformVert[2]; + nfpoly->neardist = currnear; + nfpoly->nearpt = currpt; + nfpoly->nearvert = currvert; + nfpoly->nearedge = curredge; + nfpoly->optr = sTestOPtr; + nfpoly->mptr = sTestMPtr; + nfpoly->oid = potentialOID; + } + + return collTriangle; +} + +static RpCollisionTriangle* boxNearestFloorCB(RpIntersection* intersection, + RpCollisionTriangle* collTriangle, RwReal distance, + void* data) +{ + xNearFloorPoly* nfpoly = (xNearFloorPoly*)data; + xVec3 xformVert[3]; + + if (sBoxTestMat) + { + xMat4x3Toworld(&xformVert[0], sBoxTestMat, (xVec3*)collTriangle->vertices[0]); + xMat4x3Toworld(&xformVert[1], sBoxTestMat, (xVec3*)collTriangle->vertices[1]); + xMat4x3Toworld(&xformVert[2], sBoxTestMat, (xVec3*)collTriangle->vertices[2]); + } + else + { + xformVert[0] = *(xVec3*)collTriangle->vertices[0]; + xformVert[1] = *(xVec3*)collTriangle->vertices[1]; + xformVert[2] = *(xVec3*)collTriangle->vertices[2]; + } + + if (Mgc_TriBoxTest(xformVert, &nfpoly->box)) + { + return nearestFloorCB(intersection, collTriangle, distance, data); + } + + return collTriangle; +} static RpCollisionTriangle* sectorNearestFloorCB(RpIntersection* intersection, RpWorldSector*, - RpCollisionTriangle* collTriangle, F32 distance, + RpCollisionTriangle* collTriangle, RwReal distance, void* data) { return nearestFloorCB(intersection, collTriangle, distance, data); } +static S32 gridNearestFloorCB(xEnt* ent, void* cbdata) +{ + xNearFloorPoly* nfpoly = (xNearFloorPoly*)cbdata; + + if (!(ent->moreFlags & 0x80)) + return 1; + if (!(ent->collType & sNearestChk)) + return 1; + if (!(ent->chkby & sNearestCollType)) + return 1; + + xCollis tempC; + tempC.flags = 0; + + xBoundHitsBound(&sNearestBound, &ent->bound, &tempC); + if (!(tempC.flags & k_HIT_IT)) + return 1; + + if (ent->collLev == 5) + { + sTestOPtr = ent; + sTestMPtr = ent->collModel ? ent->collModel : ent->model; + + RwFrame* frame = RpAtomicGetFrame(sTestMPtr->Data); + RwFrameTransform(frame, sTestMPtr->Mat, rwCOMBINEREPLACE); + + sBoxTestMat = (xMat4x3*)sTestMPtr->Mat; + RpAtomicForAllIntersections(sTestMPtr->Data, &sSphereIsx, boxNearestFloorCB, nfpoly); + } + + return 1; +} + +U32 xSceneNearestFloorPoly(xScene* sc, xNearFloorPoly* nfpoly, U8 collType, U8 chk) +//NONMATCH("https://decomp.me/scratch/yCzQV") +{ + sNearestBound.type = XBOUND_TYPE_BOX; + sNearestBound.box.box = nfpoly->box; + + xVec3Lerp(&sNearestBound.box.center, &sNearestBound.box.box.upper, &sNearestBound.box.box.lower, + 0.5f); + xQuickCullForBox(&sNearestBound.qcd, &sNearestBound.box.box); + + RpIntersection isx; + isx.type = rpINTERSECTBOX; + isx.t.box.sup = *(RwV3d*)&sNearestBound.box.box.upper; + isx.t.box.inf = *(RwV3d*)&sNearestBound.box.box.lower; + + sSphereIsx.type = rpINTERSECTSPHERE; + sSphereIsx.t.sphere.radius = + xsqrt((SQR(isx.t.box.sup.x - isx.t.box.inf.x) + SQR(isx.t.box.sup.y - isx.t.box.inf.y) + + SQR(isx.t.box.sup.z - isx.t.box.inf.z)) * + 0.25f); + sSphereIsx.t.sphere.center = *(RwV3d*)&sNearestBound.box.center; + + nfpoly->neardist = HUGE; + nfpoly->center = sNearestBound.box.center; + nfpoly->oid = NULL; + nfpoly->optr = NULL; + nfpoly->mptr = NULL; + + if (chk & (XENT_COLLTYPE_STAT | XENT_COLLTYPE_DYN)) + { + sNearestChk = chk; + sNearestCollType = collType; + xGridCheckPosition(&colls_grid, &sNearestBound.box.center, &sNearestBound.qcd, + gridNearestFloorCB, nfpoly); + xGridCheckPosition(&colls_oso_grid, &sNearestBound.box.center, &sNearestBound.qcd, + gridNearestFloorCB, nfpoly); + } + + if (chk & 0x20) + { + sTestOPtr = NULL; + sTestMPtr = NULL; + sBoxTestMat = NULL; + + if (sc->env->geom->jsp) + { + sUseJSP = true; + xClumpColl_ForAllIntersections(sc->env->geom->jsp->colltree, &isx, sectorNearestFloorCB, + nfpoly); + sUseJSP = false; + } + else + { + RpCollisionWorldForAllIntersections(sc->env->geom->world, &isx, sectorNearestFloorCB, + nfpoly); + } + } + + if (nfpoly->neardist != HUGE) + { + nfpoly->neardist = xsqrt(nfpoly->neardist); + return 1; + } + + return 0; +} + bool cb_ray_hits_ent::operator()(xEnt& ent, xGridBound& gridb) { xCollis c; diff --git a/src/SB/Core/x/xScene.h b/src/SB/Core/x/xScene.h index 206e7343f..5e99a358e 100644 --- a/src/SB/Core/x/xScene.h +++ b/src/SB/Core/x/xScene.h @@ -45,6 +45,23 @@ struct xScene xSceneID2NameCallback id2Name; }; +struct xNearFloorPoly +{ + xBox box; + xVec3 center; + xVec3 facingVec; + F32 facingDot; + F32 floorDot; + xVec3 vert[3]; + F32 neardist; + xVec3 nearpt; + S32 nearvert; + S32 nearedge; + U32 oid; + void* optr; + xModelInstance* mptr; +}; + extern xScene* g_xSceneCur; void xSceneInit(xScene* sc, U16 num_trigs, U16 num_stats, U16 num_dyns, U16 num_npcs); diff --git a/src/SB/Game/zEntCruiseBubble.cpp b/src/SB/Game/zEntCruiseBubble.cpp index 17c4a9a66..d0b55d61c 100644 --- a/src/SB/Game/zEntCruiseBubble.cpp +++ b/src/SB/Game/zEntCruiseBubble.cpp @@ -33,16 +33,13 @@ #include "xString.h" #include "xVec3.h" -basic_rect screen_bounds = { 0.0f, 0.0f, 1.0f, 1.0f }; +basic_rect screen_bounds = { 0.0f, 0.0f, 1.0f, 1.0f }; basic_rect default_adjust = { 0.0f, 0.0f, 1.0f, 1.0f }; extern iColor_tag zEntCruiseBubble_color_80_00_00_FF; // 128, 0, 0, 255 extern iColor_tag zEntCruiseBubble_color_FF_14_14_FF; // 255, 20, 20, 255 -extern RpAtomic *(*gAtomicRenderCallBack)(RpAtomic*); - -template -void xGridCheckBound(xGrid& grid, const xBound& bound, const xQCData& qcd, T param); +extern RpAtomic* (*gAtomicRenderCallBack)(RpAtomic*); namespace cruise_bubble { @@ -52,15 +49,13 @@ namespace cruise_bubble tweak_group cheat_tweak; xMat4x3 start_cam_mat; - const xDecalEmitter::curve_node explode_curve[3] = - { + const xDecalEmitter::curve_node explode_curve[3] = { { 0.0f, { 0xFF, 0xFF, 0xFF, 0xFF }, 0.1f }, { 0.5f, { 0xFF, 0xFF, 0xFF, 0xFF }, 2.55f }, { 1.0f, { 0xFF, 0xFF, 0xFF, 0x00 }, 5.0f }, }; - const xDecalEmitter::curve_node cheat_explode_curve[3] = - { + const xDecalEmitter::curve_node cheat_explode_curve[3] = { { 0.0f, { 0xFF, 0xFF, 0xFF, 0xFF }, 0.1f }, { 0.5f, { 0xFF, 0xFF, 0xFF, 0xFF }, 3.55f }, { 1.0f, { 0xFF, 0xFF, 0xFF, 0x00 }, 7.0f }, @@ -71,58 +66,25 @@ namespace cruise_bubble xBase base = { 0, eBaseTypeCruiseBubble }; - const char* start_anim_states[37] = - { - "Idle01", - "Idle02", - "Idle03", - "Idle04", - "Idle05", - "Idle06", - "Idle07", - "Idle08", - "Idle09", - "Idle10", - "Idle11", - "Idle12", - "Idle13", - "SlipIdle01", - "Inactive01", - "Inactive02", - "Inactive03", - "Inactive04", - "Inactive05", - "Inactive06", - "Inactive07", - "Inactive08", - "Inactive09", - "Inactive10", - "Walk01", - "Run01", - "Run02", - "Run03", - "Land01", - "LandRun01", - "LandHigh01", - "WallLand01", - "Hit01", - "Hit02", - "Hit03", - "Hit04", + const char* start_anim_states[37] = { + "Idle01", "Idle02", "Idle03", "Idle04", "Idle05", "Idle06", + "Idle07", "Idle08", "Idle09", "Idle10", "Idle11", "Idle12", + "Idle13", "SlipIdle01", "Inactive01", "Inactive02", "Inactive03", "Inactive04", + "Inactive05", "Inactive06", "Inactive07", "Inactive08", "Inactive09", "Inactive10", + "Walk01", "Run01", "Run02", "Run03", "Land01", "LandRun01", + "LandHigh01", "WallLand01", "Hit01", "Hit02", "Hit03", "Hit04", "Hit05" }; xFXRibbon wake_ribbon[2]; xDecalEmitter explode_decal; - const xFXRibbon::curve_node wake_ribbon_curve[2] = - { + const xFXRibbon::curve_node wake_ribbon_curve[2] = { { 0.0f, { 0xFF, 0xFF, 0xFF, 0x64 }, 0.3f }, { 1.0f, { 0x00, 0x00, 0x00, 0x00 }, 1.0f }, }; - const xFXRibbon::curve_node cheat_wake_ribbon_curve[2] = - { + const xFXRibbon::curve_node cheat_wake_ribbon_curve[2] = { { 0.0f, { 0xFF, 0x9B, 0x9B, 0x64 }, 0.5f }, { 1.0f, { 0x00, 0x00, 0x00, 0x00 }, 2.0f }, }; @@ -215,17 +177,15 @@ namespace cruise_bubble xAnimTransition* fly; } missle; } atran; - } shared = - { + } shared = { 1 // flags }; - sound_config sounds[4] = - { - { "SB_cruise_start", 1.0f, 5.0f, 20.0f, 0, 0, SDR_CruiseBubbleLaunch, 0, 0, 0, 0 }, - { "SB_cruise_hit", 1.0f, 15.0f, 60.0f, 0, 0, SDR_CruiseBubbleExplode, 0, 0, 0, 0 }, - { "SB_cruise_nav_loop", 1.0f, 0.0f, 10.0f, 0, 1, SDR_None, 0, 0, 0, 0 }, - { NULL, 1.0f, 0.0f, 0.0f, 1, 0, SDR_None, 23, 25, 0, 0 }, + sound_config sounds[4] = { + { "SB_cruise_start", 1.0f, 5.0f, 20.0f, 0, 0, SDR_CruiseBubbleLaunch, 0, 0, 0, 0 }, + { "SB_cruise_hit", 1.0f, 15.0f, 60.0f, 0, 0, SDR_CruiseBubbleExplode, 0, 0, 0, 0 }, + { "SB_cruise_nav_loop", 1.0f, 0.0f, 10.0f, 0, 1, SDR_None, 0, 0, 0, 0 }, + { NULL, 1.0f, 0.0f, 0.0f, 1, 0, SDR_None, 23, 25, 0, 0 }, }; void init_sound() @@ -393,9 +353,8 @@ namespace cruise_bubble shared.hits_size = 0; } - - static void damage_entity(xEnt& ent, const xVec3& loc, const xVec3& dir, const xVec3& hit_norm, - F32 radius, bool explosive) + static void damage_entity(xEnt& ent, const xVec3& loc, const xVec3& dir, + const xVec3& hit_norm, F32 radius, bool explosive) { if (shared.hits_size >= 32) { @@ -554,7 +513,7 @@ namespace cruise_bubble } } want_enter = want_enter && !(trig.entered & 0x2); - want_exit = want_exit && (trig.entered & 0x2); + want_exit = want_exit && (trig.entered & 0x2); if (want_enter || want_exit) { @@ -769,7 +728,8 @@ namespace cruise_bubble if (!stop) { - shared.player_motion += cruise_bubble::get_player_loc() - pre_update_loc - drive_motion; + shared.player_motion += + cruise_bubble::get_player_loc() - pre_update_loc - drive_motion; if (shared.player_motion.length2() > 0.25f) { @@ -863,16 +823,20 @@ namespace cruise_bubble if (current_tweak->material.fresnel_texture != 0) { fresnel_coeff = current_tweak->material.fresnel_coeff * fade; - iModelSetMaterialAlpha(atomic, (S32)(current_tweak->material.fresnel_alpha * 255.0f * fade + 0.5f) & 0xFF); + iModelSetMaterialAlpha( + atomic, + (S32)(current_tweak->material.fresnel_alpha * 255.0f * fade + 0.5f) & 0xFF); gFXSurfaceFlags = 0x10; - xFXAtomicEnvMapSetup(atomic, current_tweak->material.fresnel_texture, fresnel_coeff); + xFXAtomicEnvMapSetup(atomic, current_tweak->material.fresnel_texture, + fresnel_coeff); gFXSurfaceFlags = 0; (*gAtomicRenderCallBack)(atomic); } if (current_tweak->material.env_texture != 0) { env_coeff = current_tweak->material.env_coeff * fade; - iModelSetMaterialAlpha(atomic, (S32)(current_tweak->material.env_alpha * 255.0f * fade + 0.5f) & 0xFF); + iModelSetMaterialAlpha( + atomic, (S32)(current_tweak->material.env_alpha * 255.0f * fade + 0.5f) & 0xFF); AtomicDisableMatFX(atomic); gFXSurfaceFlags = 0x10; xFXAtomicEnvMapSetup(atomic, current_tweak->material.env_texture, env_coeff); @@ -923,7 +887,8 @@ namespace cruise_bubble shared.states[STATE_CAMERA_RESTORE] = &camera_return; } - cruise_bubble::state_camera_restore::state_camera_restore() : state_type(STATE_CAMERA_RESTORE) + cruise_bubble::state_camera_restore::state_camera_restore() + : state_type(STATE_CAMERA_RESTORE) { } @@ -948,7 +913,8 @@ namespace cruise_bubble { } - cruise_bubble::state_missle_explode::state_missle_explode() : state_type(STATE_MISSLE_EXPLODE) + cruise_bubble::state_missle_explode::state_missle_explode() + : state_type(STATE_MISSLE_EXPLODE) { } @@ -1292,10 +1258,8 @@ namespace cruise_bubble void update_gizmo(cruise_bubble::hud_gizmo& gizmo, F32 dt) { - gizmo.alpha = range_limit(gizmo.alpha_vel * dt + gizmo.alpha, 0.0f, - 1.0f); - gizmo.glow = range_limit(gizmo.glow_vel * dt + gizmo.glow, 0.0f, - 1.0f); + gizmo.alpha = range_limit(gizmo.alpha_vel * dt + gizmo.alpha, 0.0f, 1.0f); + gizmo.glow = range_limit(gizmo.glow_vel * dt + gizmo.glow, 0.0f, 1.0f); } void flash_hud() @@ -1315,15 +1279,14 @@ namespace cruise_bubble F32 life = state->life; char buffer[16]; - sprintf(buffer, "%02d:%02d", (S32)life, - ((S32)(100.0f * life)) - (100 * (S32)life)); + sprintf(buffer, "%02d:%02d", (S32)life, ((S32)(100.0f * life)) - (100 * (S32)life)); F32 dsize = glow * current_tweak->hud.timer.glow_size; // zEntCruiseBubble_f_0_0 is loaded too early, should be just before the call - xfont font = - xfont::create(current_tweak->hud.timer.font, current_tweak->hud.timer.font_width + dsize, - current_tweak->hud.timer.font_height + dsize, 0.0f, g_WHITE, - screen_bounds); + xfont font = xfont::create(current_tweak->hud.timer.font, + current_tweak->hud.timer.font_width + dsize, + current_tweak->hud.timer.font_height + dsize, 0.0f, g_WHITE, + screen_bounds); // register use for copying fields into font off, also causes a larger stack frame // also the color tags are loaded too early, should be just before the call cruise_bubble::lerp(font.color, glow, zEntCruiseBubble_color_80_00_00_FF, @@ -1385,10 +1348,8 @@ namespace cruise_bubble return; } - hud.alpha = range_limit(hud.alpha_vel * dt + hud.alpha, 0.0f, - 1.0f); - hud.glow = range_limit(hud.glow_vel * dt + hud.glow, 0.0f, - 1.0f); + hud.alpha = range_limit(hud.alpha_vel * dt + hud.alpha, 0.0f, 1.0f); + hud.glow = range_limit(hud.glow_vel * dt + hud.glow, 0.0f, 1.0f); // scheduling off F32 vel_frac = ((state_missle_fly*)shared.states[STATE_MISSLE_FLY])->vel / @@ -1431,8 +1392,7 @@ namespace cruise_bubble void uv_animated_model::update(F32 dt) { - if (0.0f == this->offset_vel.x && - 0.0f == this->offset_vel.y) + if (0.0f == this->offset_vel.x && 0.0f == this->offset_vel.y) { return; } @@ -1504,7 +1464,6 @@ namespace cruise_bubble render_timer(hud.alpha, hud.glow); } - void show_hud() { // scheduling and register usage off @@ -1647,7 +1606,7 @@ namespace cruise_bubble *(volatile F32*)(&cheat_tweak.missle.fly.turn.xdelta) = 7.0f; *(volatile F32*)(&cheat_tweak.missle.fly.turn.ydelta) = 5.0f; *(volatile F32*)(&cheat_tweak.missle.fly.turn.ydecay) = - *(volatile F32*)(&cheat_tweak.missle.fly.turn.xdecay) = 0.985f; + *(volatile F32*)(&cheat_tweak.missle.fly.turn.xdecay) = 0.985f; *(volatile F32*)(&cheat_tweak.missle.fly.turn.ybound) = 1.24248f; F32 one_tenth = 0.1f; @@ -1662,7 +1621,8 @@ namespace cruise_bubble *(volatile U32*)(&cheat_tweak.material.env_texture) = xStrHash("aura2"); *(volatile F32*)(&cheat_tweak.material.fresnel_alpha) = 0.1f; *(volatile F32*)(&cheat_tweak.material.fresnel_coeff) = 1.0f; - *(volatile U32*)(&cheat_tweak.material.fresnel_texture) = xStrHash("par_cruise_explode"); + *(volatile U32*)(&cheat_tweak.material.fresnel_texture) = + xStrHash("par_cruise_explode"); *(volatile F32*)(&cheat_tweak.trail.bubble_rate) = 90.0f; *(volatile F32*)(&cheat_tweak.trail.bubble_emit_radius) = 0.75f; *(volatile F32*)(&cheat_tweak.trail.wake_emit_radius) = 0.3f; @@ -1695,78 +1655,71 @@ namespace cruise_bubble this->register_tweaks(true, params, size, NULL); } - void tweak_group::register_tweaks(bool init, xModelAssetParam* ap, U32 apsize, - const char*) + void tweak_group::register_tweaks(bool init, xModelAssetParam* ap, U32 apsize, const char*) { if (init) { this->aim_delay = 0.2f; - auto_tweak::load_param(this->aim_delay, 1.0f, 0.0f, 1.0f, ap, - apsize, "aim_delay"); + auto_tweak::load_param(this->aim_delay, 1.0f, 0.0f, 1.0f, ap, apsize, + "aim_delay"); } if (init) { this->player.halt_time = 0.5f; - auto_tweak::load_param(this->player.halt_time, 1.0f, - 0.0f, 1.0f, ap, apsize, - "player.halt_time"); + auto_tweak::load_param(this->player.halt_time, 1.0f, 0.0f, 1.0f, ap, + apsize, "player.halt_time"); } if (init) { this->player.aim.turn_speed = 0.05f; - auto_tweak::load_param(this->player.aim.turn_speed, 1.0f, - 0.01f, 1000000000.0f, - ap, apsize, "player.aim.turn_speed"); + auto_tweak::load_param(this->player.aim.turn_speed, 1.0f, 0.01f, + 1000000000.0f, ap, apsize, + "player.aim.turn_speed"); } if (init) { this->player.aim.anim_delta = 0.5f; - auto_tweak::load_param(this->player.aim.anim_delta, 1.0f, - 0.0f, 1000000000.0f, - ap, apsize, "player.aim.anim_delta"); + auto_tweak::load_param(this->player.aim.anim_delta, 1.0f, 0.0f, + 1000000000.0f, ap, apsize, + "player.aim.anim_delta"); } if (init) { this->player.fire.delay_wand = 0.06666667f; - auto_tweak::load_param(this->player.fire.delay_wand, 1.0f, - 0.0f, 100.0f, ap, - apsize, "player.fire.delay_wand"); + auto_tweak::load_param(this->player.fire.delay_wand, 1.0f, 0.0f, 100.0f, + ap, apsize, "player.fire.delay_wand"); } if (init) { this->missle.life = 6.0f; - auto_tweak::load_param(this->missle.life, 1.0f, - 0.01f, 1000000000.0f, - ap, apsize, "missle.life"); + auto_tweak::load_param(this->missle.life, 1.0f, 0.01f, 1000000000.0f, ap, + apsize, "missle.life"); } if (init) { this->missle.hit_dist = 0.3f; - auto_tweak::load_param(this->missle.hit_dist, 1.0f, - 0.0f, 1.0f, ap, apsize, - "missle.hit_dist"); + auto_tweak::load_param(this->missle.hit_dist, 1.0f, 0.0f, 1.0f, ap, + apsize, "missle.hit_dist"); } if (init) { this->missle.crash_angle = 30.0f; - auto_tweak::load_param(this->missle.crash_angle, DEG2RAD(1), - 0.0f, 60.0f, ap, - apsize, "missle.crash_angle"); + auto_tweak::load_param(this->missle.crash_angle, DEG2RAD(1), 0.0f, 60.0f, + ap, apsize, "missle.crash_angle"); } if (init) { this->missle.collide_twist = 0.025f; - auto_tweak::load_param(this->missle.collide_twist, 1.0f, - 0.0f, 1.0f, ap, apsize, - "missle.collide_twist"); + auto_tweak::load_param(this->missle.collide_twist, 1.0f, 0.0f, 1.0f, ap, + apsize, "missle.collide_twist"); } if (init) @@ -1779,17 +1732,15 @@ namespace cruise_bubble if (init) { this->missle.appear.delay_show = 0.13333334f; - auto_tweak::load_param(this->missle.appear.delay_show, 1.0f, - 0.0f, 100.0f, ap, - apsize, "missle.appear.delay_show"); + auto_tweak::load_param(this->missle.appear.delay_show, 1.0f, 0.0f, 100.0f, + ap, apsize, "missle.appear.delay_show"); } if (init) { this->missle.appear.delay_fly = 0.6666667f; - auto_tweak::load_param(this->missle.appear.delay_fly, 1.0f, - 0.0f, 100.0f, ap, - apsize, "missle.appear.delay_fly"); + auto_tweak::load_param(this->missle.appear.delay_fly, 1.0f, 0.0f, 100.0f, + ap, apsize, "missle.appear.delay_fly"); } if (init) @@ -1802,439 +1753,395 @@ namespace cruise_bubble if (init) { this->missle.fly.accel = 6.0f; - auto_tweak::load_param(this->missle.fly.accel, 1.0f, - 0.01f, 1000000000.0f, + auto_tweak::load_param(this->missle.fly.accel, 1.0f, 0.01f, 1000000000.0f, ap, apsize, "missle.fly.accel"); } if (init) { this->missle.fly.max_vel = 12.0f; - auto_tweak::load_param(this->missle.fly.max_vel, 1.0f, - 0.01f, 1000000000.0f, - ap, apsize, "missle.fly.max_vel"); + auto_tweak::load_param(this->missle.fly.max_vel, 1.0f, 0.01f, + 1000000000.0f, ap, apsize, "missle.fly.max_vel"); } if (init) { this->missle.fly.engine_pitch_max = 10.0f; - auto_tweak::load_param(this->missle.fly.engine_pitch_max, 1.0f, - 0.01f, 1000000000.0f, - ap, apsize, "missle.fly.engine_pitch_max"); + auto_tweak::load_param(this->missle.fly.engine_pitch_max, 1.0f, 0.01f, + 1000000000.0f, ap, apsize, + "missle.fly.engine_pitch_max"); } if (init) { this->missle.fly.engine_pitch_sensitivity = 0.005f; - auto_tweak::load_param(this->missle.fly.engine_pitch_sensitivity, - 1.0f, 0.0f, - 1.0f, ap, apsize, + auto_tweak::load_param(this->missle.fly.engine_pitch_sensitivity, 1.0f, + 0.0f, 1.0f, ap, apsize, "missle.fly.engine_pitch_sensitivity"); } if (init) { this->missle.fly.flash_interval = 2.0f; - auto_tweak::load_param(this->missle.fly.flash_interval, 1.0f, - 0.0f, 1000000000.0f, - ap, apsize, "missle.fly.flash_interval"); + auto_tweak::load_param(this->missle.fly.flash_interval, 1.0f, 0.0f, + 1000000000.0f, ap, apsize, + "missle.fly.flash_interval"); } if (init) { this->missle.fly.turn.xdelta = 5.0f; - auto_tweak::load_param(this->missle.fly.turn.xdelta, 1.0f, - 0.01f, 1000000000.0f, - ap, apsize, "missle.fly.turn.xdelta"); + auto_tweak::load_param(this->missle.fly.turn.xdelta, 1.0f, 0.01f, + 1000000000.0f, ap, apsize, + "missle.fly.turn.xdelta"); } if (init) { this->missle.fly.turn.ydelta = 4.0f; - auto_tweak::load_param(this->missle.fly.turn.ydelta, 1.0f, - 0.01f, 1000000000.0f, - ap, apsize, "missle.fly.turn.ydelta"); + auto_tweak::load_param(this->missle.fly.turn.ydelta, 1.0f, 0.01f, + 1000000000.0f, ap, apsize, + "missle.fly.turn.ydelta"); } if (init) { this->missle.fly.turn.xdecay = 0.99f; - auto_tweak::load_param(this->missle.fly.turn.xdecay, 1.0f, - 0.0f, 1.0f, ap, apsize, - "missle.fly.turn.xdecay"); + auto_tweak::load_param(this->missle.fly.turn.xdecay, 1.0f, 0.0f, 1.0f, ap, + apsize, "missle.fly.turn.xdecay"); } if (init) { this->missle.fly.turn.ydecay = 0.99f; - auto_tweak::load_param(this->missle.fly.turn.ydecay, 1.0f, - 0.0f, 1.0f, ap, apsize, - "missle.fly.turn.ydecay"); + auto_tweak::load_param(this->missle.fly.turn.ydecay, 1.0f, 0.0f, 1.0f, ap, + apsize, "missle.fly.turn.ydecay"); } if (init) { this->missle.fly.turn.ybound = 0.6f; - auto_tweak::load_param(this->missle.fly.turn.ybound, PI / 2, - 0.0f, 1.0f, ap, apsize, - "missle.fly.turn.ybound"); + auto_tweak::load_param(this->missle.fly.turn.ybound, PI / 2, 0.0f, 1.0f, + ap, apsize, "missle.fly.turn.ybound"); } if (init) { this->missle.fly.turn.roll_frac = 0.2f; - auto_tweak::load_param(this->missle.fly.turn.roll_frac, 1.0f, - -1.0f, 1.0f, ap, - apsize, "missle.fly.turn.roll_frac"); + auto_tweak::load_param(this->missle.fly.turn.roll_frac, 1.0f, -1.0f, 1.0f, + ap, apsize, "missle.fly.turn.roll_frac"); } if (init) { this->missle.explode.hit_radius = 1.0f; - auto_tweak::load_param(this->missle.explode.hit_radius, 1.0f, - 0.0f, 10.0f, ap, - apsize, "missle.explode.hit_radius"); + auto_tweak::load_param(this->missle.explode.hit_radius, 1.0f, 0.0f, 10.0f, + ap, apsize, "missle.explode.hit_radius"); } if (init) { this->missle.explode.hit_duration = 0.25f; - auto_tweak::load_param(this->missle.explode.hit_duration, 1.0f, - 0.0f, 10.0f, ap, - apsize, "missle.explode.hit_duration"); + auto_tweak::load_param(this->missle.explode.hit_duration, 1.0f, 0.0f, + 10.0f, ap, apsize, "missle.explode.hit_duration"); } if (init) { this->camera.aim.dist = 2.0f; - auto_tweak::load_param(this->camera.aim.dist, 1.0f, - 0.0f, 100.0f, ap, + auto_tweak::load_param(this->camera.aim.dist, 1.0f, 0.0f, 100.0f, ap, apsize, "camera.aim.dist"); } if (init) { this->camera.aim.height = 1.5f; - auto_tweak::load_param(this->camera.aim.height, 1.0f, - -10.0f, 10.0f, ap, + auto_tweak::load_param(this->camera.aim.height, 1.0f, -10.0f, 10.0f, ap, apsize, "camera.aim.height"); } if (init) { this->camera.aim.pitch = 0.0f; - auto_tweak::load_param(this->camera.aim.pitch, DEG2RAD(1), - -90.0f, 90.0f, ap, - apsize, "camera.aim.pitch"); + auto_tweak::load_param(this->camera.aim.pitch, DEG2RAD(1), -90.0f, 90.0f, + ap, apsize, "camera.aim.pitch"); } if (init) { this->camera.aim.accel = 10.0f; - auto_tweak::load_param(this->camera.aim.accel, 1.0f, - 0.01f, 1000000000.0f, + auto_tweak::load_param(this->camera.aim.accel, 1.0f, 0.01f, 1000000000.0f, ap, apsize, "camera.aim.accel"); } if (init) { this->camera.aim.max_vel = 5.0f; - auto_tweak::load_param(this->camera.aim.max_vel, 1.0f, - 0.01f, 1000000000.0f, - ap, apsize, "camera.aim.max_vel"); + auto_tweak::load_param(this->camera.aim.max_vel, 1.0f, 0.01f, + 1000000000.0f, ap, apsize, "camera.aim.max_vel"); } if (init) { this->camera.aim.stick_decel = 720.0f; - auto_tweak::load_param(this->camera.aim.stick_decel, DEG2RAD(1), - 0.01f, 1000000000.0f, - ap, apsize, "camera.aim.stick_decel"); + auto_tweak::load_param(this->camera.aim.stick_decel, DEG2RAD(1), 0.01f, + 1000000000.0f, ap, apsize, + "camera.aim.stick_decel"); } if (init) { this->camera.aim.stick_accel = 360.0f; - auto_tweak::load_param(this->camera.aim.stick_accel, DEG2RAD(1), - 0.01f, 1000000000.0f, - ap, apsize, "camera.aim.stick_accel"); + auto_tweak::load_param(this->camera.aim.stick_accel, DEG2RAD(1), 0.01f, + 1000000000.0f, ap, apsize, + "camera.aim.stick_accel"); } if (init) { this->camera.aim.stick_max_vel = 135.0f; - auto_tweak::load_param(this->camera.aim.stick_max_vel, DEG2RAD(1), - 0.01f, 1000000000.0f, - ap, apsize, "camera.aim.stick_max_vel"); + auto_tweak::load_param(this->camera.aim.stick_max_vel, DEG2RAD(1), 0.01f, + 1000000000.0f, ap, apsize, + "camera.aim.stick_max_vel"); } if (init) { this->camera.aim.turn_speed = 0.2f; - auto_tweak::load_param(this->camera.aim.turn_speed, 1.0f, - 0.001f, 1000000000.0f, - ap, apsize, "camera.aim.turn_speed"); + auto_tweak::load_param(this->camera.aim.turn_speed, 1.0f, 0.001f, + 1000000000.0f, ap, apsize, + "camera.aim.turn_speed"); } if (init) { this->camera.seize.delay = 0.0f; - auto_tweak::load_param(this->camera.seize.delay, 1.0f, - 0.0f, 1000000000.0f, - ap, apsize, "camera.seize.delay"); + auto_tweak::load_param(this->camera.seize.delay, 1.0f, 0.0f, + 1000000000.0f, ap, apsize, "camera.seize.delay"); } if (init) { this->camera.seize.blend_time = 1.5f; - auto_tweak::load_param(this->camera.seize.blend_time, 1.0f, - 0.0f, 1000000000.0f, - ap, apsize, "camera.seize.blend_time"); + auto_tweak::load_param(this->camera.seize.blend_time, 1.0f, 0.0f, + 1000000000.0f, ap, apsize, + "camera.seize.blend_time"); } if (init) { this->camera.seize.fade_dist = 2.0f; - auto_tweak::load_param(this->camera.seize.fade_dist, 1.0f, - 0.0f, 10.0f, ap, - apsize, "camera.seize.fade_dist"); + auto_tweak::load_param(this->camera.seize.fade_dist, 1.0f, 0.0f, 10.0f, + ap, apsize, "camera.seize.fade_dist"); } if (init) { this->camera.seize.hide_dist = 1.0f; - auto_tweak::load_param(this->camera.seize.hide_dist, 1.0f, - 0.0f, 10.0f, ap, - apsize, "camera.seize.hide_dist"); + auto_tweak::load_param(this->camera.seize.hide_dist, 1.0f, 0.0f, 10.0f, + ap, apsize, "camera.seize.hide_dist"); } if (init) { this->camera.seize.fov = 95.0f; - auto_tweak::load_param(this->camera.seize.fov, 1.0f, - 10.0f, 180.0f, ap, + auto_tweak::load_param(this->camera.seize.fov, 1.0f, 10.0f, 180.0f, ap, apsize, "camera.seize.fov"); } if (init) { this->camera.survey.duration = 2.0f; - auto_tweak::load_param(this->camera.survey.duration, 1.0f, - 0.0f, 10.0f, ap, - apsize, "camera.survey.duration"); + auto_tweak::load_param(this->camera.survey.duration, 1.0f, 0.0f, 10.0f, + ap, apsize, "camera.survey.duration"); } if (init) { this->camera.survey.min_duration = 0.25f; - auto_tweak::load_param(this->camera.survey.min_duration, 1.0f, - 0.0f, 10.0f, ap, - apsize, "camera.survey.min_duration"); + auto_tweak::load_param(this->camera.survey.min_duration, 1.0f, 0.0f, + 10.0f, ap, apsize, "camera.survey.min_duration"); } if (init) { this->camera.survey.min_dist = 10.0f; - auto_tweak::load_param(this->camera.survey.min_dist, 1.0f, - 0.0f, 100.0f, ap, - apsize, "camera.survey.min_dist"); + auto_tweak::load_param(this->camera.survey.min_dist, 1.0f, 0.0f, 100.0f, + ap, apsize, "camera.survey.min_dist"); } if (init) { this->camera.survey.cut_dist = 6.0f; - auto_tweak::load_param(this->camera.survey.cut_dist, 1.0f, - 0.0f, 100.0f, ap, - apsize, "camera.survey.cut_dist"); + auto_tweak::load_param(this->camera.survey.cut_dist, 1.0f, 0.0f, 100.0f, + ap, apsize, "camera.survey.cut_dist"); } if (init) { this->camera.survey.drift_dist = 8.0f; - auto_tweak::load_param(this->camera.survey.drift_dist, 1.0f, - 0.0f, 100.0f, ap, - apsize, "camera.survey.drift_dist"); + auto_tweak::load_param(this->camera.survey.drift_dist, 1.0f, 0.0f, 100.0f, + ap, apsize, "camera.survey.drift_dist"); } if (init) { this->camera.survey.drift_softness = 0.1f; - auto_tweak::load_param(this->camera.survey.drift_softness, 1.0f, - 0.0f, 0.5f, ap, apsize, - "camera.survey.drift_softness"); + auto_tweak::load_param(this->camera.survey.drift_softness, 1.0f, 0.0f, + 0.5f, ap, apsize, "camera.survey.drift_softness"); } if (init) { this->camera.survey.jerk_offset = 0.8f; - auto_tweak::load_param(this->camera.survey.jerk_offset, 1.0f, - 0.0f, 2.0f, ap, apsize, - "camera.survey.jerk_offset"); + auto_tweak::load_param(this->camera.survey.jerk_offset, 1.0f, 0.0f, 2.0f, + ap, apsize, "camera.survey.jerk_offset"); } if (init) { this->camera.survey.jerk_deflect = 0.6f; - auto_tweak::load_param(this->camera.survey.jerk_deflect, 1.0f, - 0.0f, 1.0f, ap, apsize, - "camera.survey.jerk_deflect"); + auto_tweak::load_param(this->camera.survey.jerk_deflect, 1.0f, 0.0f, 1.0f, + ap, apsize, "camera.survey.jerk_deflect"); } if (init) { this->camera.restore.control_delay = 0.25f; - auto_tweak::load_param(this->camera.restore.control_delay, 1.0f, - 0.0f, 1.0f, ap, apsize, - "camera.restore.control_delay"); + auto_tweak::load_param(this->camera.restore.control_delay, 1.0f, 0.0f, + 1.0f, ap, apsize, "camera.restore.control_delay"); } if (init) { this->material.env_alpha = 0.5f; - auto_tweak::load_param(this->material.env_alpha, 1.0f, - 0.0f, 1.0f, ap, apsize, - "material.env_alpha"); + auto_tweak::load_param(this->material.env_alpha, 1.0f, 0.0f, 1.0f, ap, + apsize, "material.env_alpha"); } if (init) { this->material.env_coeff = 0.5f; - auto_tweak::load_param(this->material.env_coeff, 1.0f, - 0.0f, 1.0f, ap, apsize, - "material.env_coeff"); + auto_tweak::load_param(this->material.env_coeff, 1.0f, 0.0f, 1.0f, ap, + apsize, "material.env_coeff"); } if (init) { this->material.fresnel_alpha = 0.0f; - auto_tweak::load_param(this->material.fresnel_alpha, 1.0f, - 0.0f, 1.0f, ap, apsize, - "material.fresnel_alpha"); + auto_tweak::load_param(this->material.fresnel_alpha, 1.0f, 0.0f, 1.0f, ap, + apsize, "material.fresnel_alpha"); } if (init) { this->material.fresnel_coeff = 0.75f; - auto_tweak::load_param(this->material.fresnel_coeff, 1.0f, - 0.0f, 1.0f, ap, apsize, - "material.fresnel_coeff"); + auto_tweak::load_param(this->material.fresnel_coeff, 1.0f, 0.0f, 1.0f, ap, + apsize, "material.fresnel_coeff"); } if (init) { this->reticle.dist_min = 3.0f; - auto_tweak::load_param(this->reticle.dist_min, 1.0f, - 1.0f, 10.0f, ap, + auto_tweak::load_param(this->reticle.dist_min, 1.0f, 1.0f, 10.0f, ap, apsize, "reticle.dist_min"); } if (init) { this->reticle.dist_max = 30.0f; - auto_tweak::load_param(this->reticle.dist_max, 1.0f, - 1.0f, 10000.0f, ap, + auto_tweak::load_param(this->reticle.dist_max, 1.0f, 1.0f, 10000.0f, ap, apsize, "reticle.dist_max"); } if (init) { this->reticle.ang_show = 4.0f; - auto_tweak::load_param(this->reticle.ang_show, DEG2RAD(1), - 0.0f, 90.0f, ap, - apsize, "reticle.ang_show"); + auto_tweak::load_param(this->reticle.ang_show, DEG2RAD(1), 0.0f, 90.0f, + ap, apsize, "reticle.ang_show"); } if (init) { this->reticle.ang_hide = 22.5f; - auto_tweak::load_param(this->reticle.ang_hide, DEG2RAD(1), - 0.0f, 90.0f, ap, - apsize, "reticle.ang_hide"); + auto_tweak::load_param(this->reticle.ang_hide, DEG2RAD(1), 0.0f, 90.0f, + ap, apsize, "reticle.ang_hide"); } if (init) { this->reticle.delay_retarget = 0.25f; - auto_tweak::load_param(this->reticle.delay_retarget, 1.0f, - 0.0f, 5.0f, ap, apsize, - "reticle.delay_retarget"); + auto_tweak::load_param(this->reticle.delay_retarget, 1.0f, 0.0f, 5.0f, ap, + apsize, "reticle.delay_retarget"); } if (init) { this->trail.sample_rate = 60.0f; - auto_tweak::load_param(this->trail.sample_rate, 1.0f, - 0.0f, 10000.0f, ap, + auto_tweak::load_param(this->trail.sample_rate, 1.0f, 0.0f, 10000.0f, ap, apsize, "trail.sample_rate"); } if (init) { this->trail.bubble_rate = 60.0f; - auto_tweak::load_param(this->trail.bubble_rate, 1.0f, - 0.0f, 10000.0f, ap, + auto_tweak::load_param(this->trail.bubble_rate, 1.0f, 0.0f, 10000.0f, ap, apsize, "trail.bubble_rate"); } if (init) { this->trail.bubble_emit_radius = 0.5f; - auto_tweak::load_param(this->trail.bubble_emit_radius, 1.0f, - 0.0f, 10.0f, ap, - apsize, "trail.bubble_emit_radius"); + auto_tweak::load_param(this->trail.bubble_emit_radius, 1.0f, 0.0f, 10.0f, + ap, apsize, "trail.bubble_emit_radius"); } if (init) { this->trail.wake_emit_radius = 0.1f; - auto_tweak::load_param(this->trail.wake_emit_radius, 1.0f, - 0.0f, 10.0f, ap, - apsize, "trail.wake_emit_radius"); + auto_tweak::load_param(this->trail.wake_emit_radius, 1.0f, 0.0f, 10.0f, + ap, apsize, "trail.wake_emit_radius"); } if (init) { this->blast.emit = 300; - auto_tweak::load_param(this->blast.emit, 1, 0, 0x3e8, ap, apsize, "blast.emit"); + auto_tweak::load_param(this->blast.emit, 1, 0, 0x3e8, ap, apsize, + "blast.emit"); } if (init) { this->blast.radius = 0.0f; - auto_tweak::load_param(this->blast.radius, 1.0f, - 0.0f, 10.0f, ap, - apsize, "blast.radius"); + auto_tweak::load_param(this->blast.radius, 1.0f, 0.0f, 10.0f, ap, apsize, + "blast.radius"); } if (init) { this->blast.vel = 5.0f; - auto_tweak::load_param(this->blast.vel, 1.0f, - -100000.0f, 100000.0f, - ap, apsize, "blast.vel"); + auto_tweak::load_param(this->blast.vel, 1.0f, -100000.0f, 100000.0f, ap, + apsize, "blast.vel"); } if (init) { this->blast.rand_vel = 0.5f; - auto_tweak::load_param(this->blast.rand_vel, 1.0f, - -100000.0f, 100000.0f, + auto_tweak::load_param(this->blast.rand_vel, 1.0f, -100000.0f, 100000.0f, ap, apsize, "blast.rand_vel"); } if (init) { this->droplet.dist_min = 1.0f; - auto_tweak::load_param(this->droplet.dist_min, 1.0f, - 0.0f, 10.0f, ap, + auto_tweak::load_param(this->droplet.dist_min, 1.0f, 0.0f, 10.0f, ap, apsize, "droplet.dist_min"); } if (init) { this->droplet.dist_max = 2.0f; - auto_tweak::load_param(this->droplet.dist_max, 1.0f, - 0.0f, 10.0f, ap, + auto_tweak::load_param(this->droplet.dist_max, 1.0f, 0.0f, 10.0f, ap, apsize, "droplet.dist_max"); } @@ -2255,106 +2162,91 @@ namespace cruise_bubble if (init) { this->droplet.vel_min = 2.0f; - auto_tweak::load_param(this->droplet.vel_min, 1.0f, - 0.0f, 100000.0f, ap, + auto_tweak::load_param(this->droplet.vel_min, 1.0f, 0.0f, 100000.0f, ap, apsize, "droplet.vel_min"); } if (init) { this->droplet.vel_max = 6.0f; - auto_tweak::load_param(this->droplet.vel_max, 1.0f, - 0.0f, 100000.0f, ap, + auto_tweak::load_param(this->droplet.vel_max, 1.0f, 0.0f, 100000.0f, ap, apsize, "droplet.vel_max"); } if (init) { this->droplet.vel_perturb = 0.25f; - auto_tweak::load_param(this->droplet.vel_perturb, 1.0f, - 0.0f, 100000.0f, ap, - apsize, "droplet.vel_perturb"); + auto_tweak::load_param(this->droplet.vel_perturb, 1.0f, 0.0f, 100000.0f, + ap, apsize, "droplet.vel_perturb"); } if (init) { this->droplet.vel_angle = 60.0f; - auto_tweak::load_param(this->droplet.vel_angle, DEG2RAD(1), - 0.0f, 100000.0f, ap, - apsize, "droplet.vel_angle"); + auto_tweak::load_param(this->droplet.vel_angle, DEG2RAD(1), 0.0f, + 100000.0f, ap, apsize, "droplet.vel_angle"); } if (init) { this->droplet.rot_vel_max = 360.0f; - auto_tweak::load_param(this->droplet.rot_vel_max, DEG2RAD(1), - 0.0f, 100000.0f, ap, - apsize, "droplet.rot_vel_max"); + auto_tweak::load_param(this->droplet.rot_vel_max, DEG2RAD(1), 0.0f, + 100000.0f, ap, apsize, "droplet.rot_vel_max"); } if (init) { this->hud.glow_size = 0.05f; - auto_tweak::load_param(this->hud.glow_size, 1.0f, - 0.001f, 10.0f, ap, + auto_tweak::load_param(this->hud.glow_size, 1.0f, 0.001f, 10.0f, ap, apsize, "hud.glow_size"); } if (init) { this->hud.time_fade = 0.25f; - auto_tweak::load_param(this->hud.time_fade, 1.0f, - 0.001f, 10.0f, ap, + auto_tweak::load_param(this->hud.time_fade, 1.0f, 0.001f, 10.0f, ap, apsize, "hud.time_fade"); } if (init) { this->hud.time_glow = 0.5f; - auto_tweak::load_param(this->hud.time_glow, 1.0f, - 0.001f, 10.0f, ap, + auto_tweak::load_param(this->hud.time_glow, 1.0f, 0.001f, 10.0f, ap, apsize, "hud.time_glow"); } if (init) { this->hud.wind.size = 0.75f; - auto_tweak::load_param(this->hud.wind.size, 1.0f, - 0.0f, 100.0f, ap, + auto_tweak::load_param(this->hud.wind.size, 1.0f, 0.0f, 100.0f, ap, apsize, "hud.wind.size"); } if (init) { this->hud.wind.du = 0.0f; - auto_tweak::load_param(this->hud.wind.du, 1.0f, - -1000000000.0f, - 1000000000.0f, ap, apsize, - "hud.wind.du"); + auto_tweak::load_param(this->hud.wind.du, 1.0f, -1000000000.0f, + 1000000000.0f, ap, apsize, "hud.wind.du"); } if (init) { this->hud.wind.dv = 4.0f; - auto_tweak::load_param(this->hud.wind.dv, 1.0f, - -1000000000.0f, - 1000000000.0f, ap, apsize, - "hud.wind.dv"); + auto_tweak::load_param(this->hud.wind.dv, 1.0f, -1000000000.0f, + 1000000000.0f, ap, apsize, "hud.wind.dv"); } if (init) { this->hud.reticle.size = 0.1f; - auto_tweak::load_param(this->hud.reticle.size, 1.0f, - 0.0f, 100.0f, ap, + auto_tweak::load_param(this->hud.reticle.size, 1.0f, 0.0f, 100.0f, ap, apsize, "hud.reticle.size"); } if (init) { this->hud.target.size = 0.1f; - auto_tweak::load_param(this->hud.target.size, 1.0f, - 0.0f, 100.0f, ap, + auto_tweak::load_param(this->hud.target.size, 1.0f, 0.0f, 100.0f, ap, apsize, "hud.target.size"); } @@ -2368,65 +2260,57 @@ namespace cruise_bubble if (init) { this->hud.timer.font_width = 0.0275f; - auto_tweak::load_param(this->hud.timer.font_width, 1.0f, - 0.001f, 1.0f, ap, + auto_tweak::load_param(this->hud.timer.font_width, 1.0f, 0.001f, 1.0f, ap, apsize, "hud.timer.font_width"); } if (init) { this->hud.timer.font_height = 0.047f; - auto_tweak::load_param(this->hud.timer.font_height, 1.0f, - 0.001f, 1.0f, ap, - apsize, "hud.timer.font_height"); + auto_tweak::load_param(this->hud.timer.font_height, 1.0f, 0.001f, 1.0f, + ap, apsize, "hud.timer.font_height"); } if (init) { this->hud.timer.x = 0.78f; - auto_tweak::load_param(this->hud.timer.x, 1.0f, - 0.0f, 1.0f, ap, apsize, + auto_tweak::load_param(this->hud.timer.x, 1.0f, 0.0f, 1.0f, ap, apsize, "hud.timer.x"); } if (init) { this->hud.timer.y = 0.86f; - auto_tweak::load_param(this->hud.timer.y, 1.0f, - 0.0f, 1.0f, ap, apsize, + auto_tweak::load_param(this->hud.timer.y, 1.0f, 0.0f, 1.0f, ap, apsize, "hud.timer.y"); } if (init) { this->hud.timer.glow_size = 0.01f; - auto_tweak::load_param(this->hud.timer.glow_size, 1.0f, - 0.0f, 10.0f, ap, + auto_tweak::load_param(this->hud.timer.glow_size, 1.0f, 0.0f, 10.0f, ap, apsize, "hud.timer.glow_size"); } if (init) { this->dialog.freq = 1.0f; - auto_tweak::load_param(this->dialog.freq, 1.0f, - 0.0f, 1.0f, ap, apsize, + auto_tweak::load_param(this->dialog.freq, 1.0f, 0.0f, 1.0f, ap, apsize, "dialog.freq"); } if (init) { this->dialog.decay = 0.75f; - auto_tweak::load_param(this->dialog.decay, 1.0f, - 0.0f, 1.0f, ap, apsize, + auto_tweak::load_param(this->dialog.decay, 1.0f, 0.0f, 1.0f, ap, apsize, "dialog.decay"); } if (init) { this->dialog.min_freq = 0.1f; - auto_tweak::load_param(this->dialog.min_freq, 1.0f, - 0.0f, 1.0f, ap, apsize, - "dialog.min_freq"); + auto_tweak::load_param(this->dialog.min_freq, 1.0f, 0.0f, 1.0f, ap, + apsize, "dialog.min_freq"); } if (init) @@ -2581,18 +2465,16 @@ namespace cruise_bubble } shared.astate.player.aim = - xAnimTableNewState(&table, "cruise_bubble_aim", 0x10, 0, 1.0f, NULL, NULL, - 0.0f, NULL, NULL, xAnimDefaultBeforeEnter, NULL, NULL); + xAnimTableNewState(&table, "cruise_bubble_aim", 0x10, 0, 1.0f, NULL, NULL, 0.0f, + NULL, NULL, xAnimDefaultBeforeEnter, NULL, NULL); shared.astate.player.fire = - xAnimTableNewState(&table, "cruise_bubble_fire", 0x20, 0, 1.0f, NULL, - NULL, 0.0f, NULL, NULL, xAnimDefaultBeforeEnter, NULL, - NULL); + xAnimTableNewState(&table, "cruise_bubble_fire", 0x20, 0, 1.0f, NULL, NULL, 0.0f, + NULL, NULL, xAnimDefaultBeforeEnter, NULL, NULL); shared.astate.player.idle = - xAnimTableNewState(&table, "cruise_bubble_idle", 0x10, 0, 1.0f, NULL, - NULL, 0.0f, NULL, NULL, xAnimDefaultBeforeEnter, NULL, - NULL); + xAnimTableNewState(&table, "cruise_bubble_idle", 0x10, 0, 1.0f, NULL, NULL, 0.0f, + NULL, NULL, xAnimDefaultBeforeEnter, NULL, NULL); char* start_from = (char*)xMemPushTemp(0x250); memset(start_from, 0, 0x250); @@ -2608,24 +2490,21 @@ namespace cruise_bubble shared.atran.player.aim = xAnimTableNewTransition(&table, start_from, "cruise_bubble_aim", - (xAnimTransitionConditionalCallback)&check_anim_aim, NULL, 0, 0, - 0.0f, 0.0f, 0, 0, - 0.15f, NULL); + (xAnimTransitionConditionalCallback)&check_anim_aim, NULL, + 0, 0, 0.0f, 0.0f, 0, 0, 0.15f, NULL); shared.atran.player.fire = - xAnimTableNewTransition(&table, "cruise_bubble_aim", "cruise_bubble_fire", NULL, NULL, 0, 0, - 0.0f, 0.0f, 0, 0, - 0.15f, NULL); + xAnimTableNewTransition(&table, "cruise_bubble_aim", "cruise_bubble_fire", NULL, + NULL, 0, 0, 0.0f, 0.0f, 0, 0, 0.15f, NULL); shared.atran.player.idle = - xAnimTableNewTransition(&table, "cruise_bubble_fire", "cruise_bubble_idle", NULL, NULL, - 0x10, 0, 0.0f, 0.0f, 0, 0, - 0.15f, NULL); + xAnimTableNewTransition(&table, "cruise_bubble_fire", "cruise_bubble_idle", NULL, + NULL, 0x10, 0, 0.0f, 0.0f, 0, 0, 0.15f, NULL); shared.atran.player.end = - xAnimTableNewTransition(&table, "cruise_bubble_aim cruise_bubble_fire cruise_bubble_idle", - "Idle01", NULL, NULL, 0, 0, 0.0f, - 0.0f, 0, 0, 0.15f, NULL); + xAnimTableNewTransition(&table, + "cruise_bubble_aim cruise_bubble_fire cruise_bubble_idle", + "Idle01", NULL, NULL, 0, 0, 0.0f, 0.0f, 0, 0, 0.15f, NULL); xMemPopTemp(start_from); } @@ -2633,9 +2512,14 @@ namespace cruise_bubble xAnimTable* cruise_bubble::anim_table() { xAnimTable* table = xAnimTableNew("Cruise Bubble", 0, 0); - shared.astate.missle.fire = xAnimTableNewState(table, "fire", 0x20, 0, 1.0f, NULL, NULL, 0.0f, NULL, NULL, xAnimDefaultBeforeEnter, NULL, NULL); - shared.astate.missle.fly = xAnimTableNewState(table, "fly", 0x10, 0, 1.0f, NULL, NULL, 0.0f, NULL, NULL, xAnimDefaultBeforeEnter, NULL, NULL); - shared.atran.missle.fly = xAnimTableNewTransition(table, "fire", "fly", NULL, NULL, 0x10, 0, 0.0f, 0.0f, 0, 0, 0.15f, NULL); + shared.astate.missle.fire = + xAnimTableNewState(table, "fire", 0x20, 0, 1.0f, NULL, NULL, 0.0f, NULL, NULL, + xAnimDefaultBeforeEnter, NULL, NULL); + shared.astate.missle.fly = + xAnimTableNewState(table, "fly", 0x10, 0, 1.0f, NULL, NULL, 0.0f, NULL, NULL, + xAnimDefaultBeforeEnter, NULL, NULL); + shared.atran.missle.fly = xAnimTableNewTransition( + table, "fire", "fly", NULL, NULL, 0x10, 0, 0.0f, 0.0f, 0, 0, 0.15f, NULL); return table; } @@ -2847,8 +2731,8 @@ namespace cruise_bubble void cruise_bubble::state_player_aim::update_animation(F32 dt) { - F32 r = range_limit(this->yaw_vel * current_tweak->player.aim.anim_delta, - -1.0f, 1.0f); + F32 r = + range_limit(this->yaw_vel * current_tweak->player.aim.anim_delta, -1.0f, 1.0f); xAnimSingle* s = globals.player.ent.model->Anim->Single; s->BilinearLerp[0] = 0.5f * ((1.0f + s->BilinearLerp[0]) + r); } @@ -2866,8 +2750,8 @@ namespace cruise_bubble xMat4x3* mat = &globals.camera.mat; F32 new_yaw; - if (mat->at.x >= -0.00001f && mat->at.x <= 0.00001f && - mat->at.z >= -0.00001f && mat->at.z <= 0.00001f) + if (mat->at.x >= -0.00001f && mat->at.x <= 0.00001f && mat->at.z >= -0.00001f && + mat->at.z <= 0.00001f) { new_yaw = this->yaw; } @@ -2974,8 +2858,7 @@ namespace cruise_bubble cruise_bubble::show_missle(); shared.missle_model->Flags = shared.missle_model->Flags & 0xfffe; shared.missle_model->Alpha = 1.0f; - xAnimPlaySetState(shared.missle_model->Anim->Single, shared.astate.missle.fire, - 0.0f); + xAnimPlaySetState(shared.missle_model->Anim->Single, shared.astate.missle.fire, 0.0f); this->move(); } @@ -3041,7 +2924,8 @@ namespace cruise_bubble missle_record.reset(); missle_record.push_front(missle_record_data(this->last_loc, this->rot.z)); - missle_record.push_front(missle_record_data(cruise_bubble::get_missle_mat()->pos, this->rot.z)); + missle_record.push_front( + missle_record_data(cruise_bubble::get_missle_mat()->pos, this->rot.z)); play_sound(2, 1.0f, &cruise_bubble::get_missle_mat()->pos); signal_event(eEventCruiseFired); @@ -3120,8 +3004,8 @@ namespace cruise_bubble { this->flash_time += dt; - F32 tflash = - current_tweak->missle.fly.flash_interval * (this->life / current_tweak->missle.life); + F32 tflash = current_tweak->missle.fly.flash_interval * + (this->life / current_tweak->missle.life); if (this->flash_time > tflash) { flash_hud(); @@ -3194,8 +3078,8 @@ namespace cruise_bubble if (cruise_bubble::can_damage(hit_ent)) { - damage_entity(*hit_ent, *hit_loc, cruise_bubble::get_missle_mat()->at, *hit_norm, - 0.0f, false); + damage_entity(*hit_ent, *hit_loc, cruise_bubble::get_missle_mat()->at, + *hit_norm, 0.0f, false); return true; } @@ -3223,8 +3107,7 @@ namespace cruise_bubble } F32 tan = xatan2(diff_normalized.x, diff_normalized.z); - F32 mod = - xrmod(PI + (tan - this->rot.x)) - PI; + F32 mod = xrmod(PI + (tan - this->rot.x)) - PI; this->rot.x += mod * current_tweak->missle.collide_twist; this->rot.y += (sin - this->rot.y) * current_tweak->missle.collide_twist; xMat3x3Euler(mat, &this->rot); @@ -3244,8 +3127,8 @@ namespace cruise_bubble return this->hit_test(*hit_loc, *hit_norm, hit_depen, hit_ent); } - U8 cruise_bubble::state_missle_fly::hit_test(xVec3& hit_loc, xVec3& hit_norm, xVec3& hit_depen, - xEnt*& hit_ent) const + U8 cruise_bubble::state_missle_fly::hit_test(xVec3& hit_loc, xVec3& hit_norm, + xVec3& hit_depen, xEnt*& hit_ent) const { xScene* s = globals.sceneCur; xVec3* loc = &get_missle_mat()->pos; @@ -3310,7 +3193,9 @@ namespace cruise_bubble zShrapnelAsset* shrap; // current_tweak loaded into r30 instead of r29. - zFX_SpawnBubbleBlast(&get_missle_mat()->pos, current_tweak->blast.emit, current_tweak->blast.radius, current_tweak->blast.vel, current_tweak->blast.rand_vel); + zFX_SpawnBubbleBlast(&get_missle_mat()->pos, current_tweak->blast.emit, + current_tweak->blast.radius, current_tweak->blast.vel, + current_tweak->blast.rand_vel); xVec3 scale = { 1.0f, 1.0f, 1.0f }; @@ -3329,14 +3214,16 @@ namespace cruise_bubble else { rand = xrand(); - emit_max += (rand / 0x2000) - ((rand / 0x2000) / (emit_min - emit_max)) * (emit_min - emit_max); + emit_max += (rand / 0x2000) - + ((rand / 0x2000) / (emit_min - emit_max)) * (emit_min - emit_max); } - ((state_missle_explode*)(emit_max))->reset_quadrants((S32)current_tweak, current_tweak->droplet.vel_angle); + ((state_missle_explode*)(emit_max)) + ->reset_quadrants((S32)current_tweak, current_tweak->droplet.vel_angle); for (U32 i = 0; i < emit_max; i++) { - // shrap->initCB(shrap, shared.missle_model, NULL, cb_droplet); + // shrap->initCB(shrap, shared.missle_model, NULL, cb_droplet); } } } @@ -3363,11 +3250,23 @@ namespace cruise_bubble rand = xpow(xurand(), 1.0f / 3.0f); - frag->info.projectile.path.initPos = get_missle_mat()->pos + (vx * ((rand * (current_tweak->droplet.dist_max - current_tweak->droplet.dist_min) + current_tweak->droplet.dist_min))); - frag->info.projectile.path.initVel = vx * (((current_tweak->droplet.vel_max - current_tweak->droplet.vel_min) * xurand() + current_tweak->droplet.vel_min)); - frag->info.projectile.path.initVel.x = current_tweak->droplet.vel_perturb * (xurand() - 0.5f) + frag->info.projectile.path.initVel.x; - frag->info.projectile.path.initVel.y = current_tweak->droplet.vel_perturb * (xurand() - 0.5f) + frag->info.projectile.path.initVel.y; - frag->info.projectile.path.initVel.z = current_tweak->droplet.vel_perturb * (xurand() - 0.5f) + frag->info.projectile.path.initVel.z; + frag->info.projectile.path.initPos = + get_missle_mat()->pos + + (vx * ((rand * (current_tweak->droplet.dist_max - current_tweak->droplet.dist_min) + + current_tweak->droplet.dist_min))); + frag->info.projectile.path.initVel = + vx * + (((current_tweak->droplet.vel_max - current_tweak->droplet.vel_min) * xurand() + + current_tweak->droplet.vel_min)); + frag->info.projectile.path.initVel.x = + current_tweak->droplet.vel_perturb * (xurand() - 0.5f) + + frag->info.projectile.path.initVel.x; + frag->info.projectile.path.initVel.y = + current_tweak->droplet.vel_perturb * (xurand() - 0.5f) + + frag->info.projectile.path.initVel.y; + frag->info.projectile.path.initVel.z = + current_tweak->droplet.vel_perturb * (xurand() - 0.5f) + + frag->info.projectile.path.initVel.z; frag->info.projectile.angVel = current_tweak->droplet.rot_vel_max * xurand(); frag->info.projectile.alpha = 0.25f; } @@ -3475,8 +3374,8 @@ namespace cruise_bubble void cruise_bubble::state_camera_aim::stop(F32 dt) { xAccelStop(this->height, this->height_vel, current_tweak->camera.aim.accel, dt); - xAccelStop(this->dist, this->dist_vel, current_tweak->camera.aim.accel, dt); - xAccelStop(this->phi, this->phi_vel, current_tweak->camera.aim.stick_decel, dt); + xAccelStop(this->dist, this->dist_vel, current_tweak->camera.aim.accel, dt); + xAccelStop(this->phi, this->phi_vel, current_tweak->camera.aim.stick_decel, dt); this->phi = xrmod(this->phi); } @@ -3551,8 +3450,7 @@ namespace cruise_bubble capture_camera(); xMat4x3* mat = get_missle_mat(); xCameraMove(&globals.camera, mat->pos); - xCameraRotate(&globals.camera, *mat, 0.0f, 0.0f, - 0.0f); + xCameraRotate(&globals.camera, *mat, 0.0f, 0.0f, 0.0f); xCameraSetFOV(&globals.camera, current_tweak->camera.seize.fov); distort_screen(1.0f); } @@ -3581,9 +3479,9 @@ namespace cruise_bubble xBound bound; get_view_bound(bound); - xGridCheckBound(colls_grid, bound, bound.qcd, targets); + xGridCheckBound(colls_grid, bound, bound.qcd, targets); xGridCheckBound(colls_oso_grid, bound, bound.qcd, targets); - xGridCheckBound(npcs_grid, bound, bound.qcd, targets); + xGridCheckBound(npcs_grid, bound, bound.qcd, targets); lock_hazard_targets(); } @@ -3619,7 +3517,8 @@ namespace cruise_bubble a = (b * (d - c)) + c; } - void cruise_bubble::state_camera_survey::lerp(xVec3& a, F32 b, const xVec3& c, const xVec3& d) const + void cruise_bubble::state_camera_survey::lerp(xVec3& a, F32 b, const xVec3& c, + const xVec3& d) const { lerp(a.x, b, c.x, d.x); lerp(a.y, b, c.y, d.y); @@ -3664,8 +3563,7 @@ namespace cruise_bubble { xVec3 loc = get_player_loc() + start_cam_mat.pos; xCameraMove(&globals.camera, loc); - xCameraRotate(&globals.camera, start_cam_mat, 0.0f, - 0.0f, 0.0f); + xCameraRotate(&globals.camera, start_cam_mat, 0.0f, 0.0f, 0.0f); } if (camera_taken()) @@ -3697,7 +3595,8 @@ namespace cruise_bubble return STATE_CAMERA_RESTORE; } - S32 cruise_bubble::state_camera_attach::cb_lock_targets::operator()(xEnt& ent, xGridBound& bound) + S32 cruise_bubble::state_camera_attach::cb_lock_targets::operator()(xEnt& ent, + xGridBound& bound) { if (!(ent.chkby & 0x10)) {