Skip to content

Commit

Permalink
Finish matching zEntTrigger (#319)
Browse files Browse the repository at this point in the history
`xMat3x3RMulVec` and `xSphereHitsVCircle` need to be inlined, but that
is a mission for another PR.
  • Loading branch information
tgsm authored Jul 15, 2024
1 parent 7dcf22c commit b0938f0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def Rel(lib_name: str, objects: List[Object]) -> Dict[str, Any]:
Object(NonMatching, "SB/Game/zEntPickup.cpp"),
Object(NonMatching, "SB/Game/zEntPlayer.cpp"),
Object(NonMatching, "SB/Game/zEntSimpleObj.cpp"),
Object(NonMatching, "SB/Game/zEntTrigger.cpp"),
Object(Matching, "SB/Game/zEntTrigger.cpp", extra_cflags=["-sym on"]),
Object(Matching, "SB/Game/zEnv.cpp"),
Object(Matching, "SB/Game/zEvent.cpp"),
Object(Matching, "SB/Game/zFeet.cpp"),
Expand Down
22 changes: 9 additions & 13 deletions src/SB/Game/zEntTrigger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

#include "xEvent.h"

extern F32 _670;
extern F32 _671_0;
extern F32 _746_1;

void zEntTriggerInit(void* ent, void* asset)
{
zEntTriggerInit((zEntTrigger*)ent, (xEntAsset*)asset);
Expand All @@ -29,15 +25,15 @@ void zEntTriggerInit(zEntTrigger* ent, xEntAsset* asset)

xVec3Sub(&var_20, &var_20, &asset->pos);
xVec3Sub(&var_2C, &var_2C, &asset->pos);
xVec3Lerp(&var_38, &var_2C, &var_20, _670);
xVec3Lerp(&var_38, &var_2C, &var_20, 0.5f);

xMat3x3RMulVec(&var_38, &ent->triggerMatrix, &var_38);

xVec3Add(&ent->triggerMatrix.pos, &var_38, &asset->pos);

ent->triggerBox.lower.x = _671_0 * (var_20.x - var_2C.x);
ent->triggerBox.lower.y = _671_0 * (var_20.y - var_2C.y);
ent->triggerBox.lower.z = _671_0 * (var_20.z - var_2C.z);
ent->triggerBox.lower.x = -0.5f * (var_20.x - var_2C.x);
ent->triggerBox.lower.y = -0.5f * (var_20.y - var_2C.y);
ent->triggerBox.lower.z = -0.5f * (var_20.z - var_2C.z);
ent->triggerBox.upper.x = -ent->triggerBox.lower.x;
ent->triggerBox.upper.y = -ent->triggerBox.lower.y;
ent->triggerBox.upper.z = -ent->triggerBox.lower.z;
Expand Down Expand Up @@ -101,7 +97,7 @@ void zEntTriggerUpdate(zEntTrigger* trig, xScene*, F32)
xMat4x3Tolocal(&xformVec, &trig->triggerMatrix, chkPos);
iBoxIsectVec(&trig->triggerBox, &xformVec, &isect);

collide = (isect.penned <= _746_1);
collide = (isect.penned <= 0.0f);

break;
}
Expand All @@ -115,7 +111,7 @@ void zEntTriggerUpdate(zEntTrigger* trig, xScene*, F32)

iSphereIsectVec(&sphere, chkPos, &isect);

collide = (isect.penned <= _746_1);
collide = (isect.penned <= 0.0f);

break;
}
Expand All @@ -130,7 +126,7 @@ void zEntTriggerUpdate(zEntTrigger* trig, xScene*, F32)

iCylinderIsectVec(&cylinder, chkPos, &isect);

collide = (isect.penned <= _746_1);
collide = (isect.penned <= 0.0f);

break;
}
Expand All @@ -144,7 +140,7 @@ void zEntTriggerUpdate(zEntTrigger* trig, xScene*, F32)

iSphereIsectVec(&sphere, chkPos, &isect);

collide = (isect.penned <= _746_1);
collide = (isect.penned <= 0.0f);

break;
}
Expand Down Expand Up @@ -240,7 +236,7 @@ bool zEntTriggerHitsSphere(const zEntTrigger& trig, const xSphere& o, const xVec

tasset = zEntTriggerAsset(trig);

if (tasset->flags & 0x1 && dir.dot(tasset->direction) <= _746_1)
if (tasset->flags & 0x1 && dir.dot(tasset->direction) <= 0.0f)
{
return false;
}
Expand Down

0 comments on commit b0938f0

Please sign in to comment.