Working grapple beam

This commit is contained in:
Jack Andersen 2018-06-20 14:57:57 -10:00
parent 73d48c9b41
commit cd3bba2f0e
10 changed files with 85 additions and 31 deletions

View File

@ -735,9 +735,9 @@ void CAnimData::SetAnimation(const CAnimPlaybackParms& parms, bool noTrans)
{
if (parms.GetAnimationId() == x40c_playbackParms.GetAnimationId() ||
(parms.GetSecondAnimationId() == x40c_playbackParms.GetSecondAnimationId() &&
parms.GetBlendFactor() == x40c_playbackParms.GetBlendFactor() &&
parms.GetBlendFactor() != 1.f) ||
parms.GetSecondAnimationId() == -1)
parms.GetSecondAnimationId() != -1) ||
(parms.GetBlendFactor() == x40c_playbackParms.GetBlendFactor() &&
parms.GetBlendFactor() != 1.f))
{
if (x220_29_animationJustStarted)
return;

View File

@ -211,8 +211,7 @@ static zeus::CVector3f ClipRayToPlane(const zeus::CVector3f& a, const zeus::CVec
bool CMetroidAreaCollider::ConvexPolyCollision(const zeus::CPlane* planes, const zeus::CVector3f* verts,
zeus::CAABox& aabb)
{
/* FIXME: HACK: Increasing the size from 20 to 128 to give us more headroom, we should try and trim this back down to a more reasonable size */
rstl::reserved_vector<zeus::CVector3f, 128> vecs[2];
rstl::reserved_vector<zeus::CVector3f, 20> vecs[2];
g_CalledClip += 1;
g_RejectedByClip -= 1;
@ -225,8 +224,8 @@ bool CMetroidAreaCollider::ConvexPolyCollision(const zeus::CPlane* planes, const
int otherVecIdx = 1;
for (int i=0 ; i<6 ; ++i)
{
rstl::reserved_vector<zeus::CVector3f, 128>& vec = vecs[vecIdx];
rstl::reserved_vector<zeus::CVector3f, 128>& otherVec = vecs[otherVecIdx];
rstl::reserved_vector<zeus::CVector3f, 20>& vec = vecs[vecIdx];
rstl::reserved_vector<zeus::CVector3f, 20>& otherVec = vecs[otherVecIdx];
otherVec.clear();
bool inFrontOf = planes[i].pointToPlaneDist(vec.front()) >= 0.f;
@ -235,8 +234,10 @@ bool CMetroidAreaCollider::ConvexPolyCollision(const zeus::CPlane* planes, const
const zeus::CVector3f& b = vec[(j + 1) % vec.size()];
if (inFrontOf)
otherVec.push_back(vec[j]);
if ((planes[i].pointToPlaneDist(b) >= 0.f) ^ inFrontOf)
bool nextInFrontOf = planes[i].pointToPlaneDist(b) >= 0.f;
if (nextInFrontOf ^ inFrontOf)
otherVec.push_back(ClipRayToPlane(vec[j], b, planes[i]));
inFrontOf = nextInFrontOf;
}
if (otherVec.empty())
@ -246,7 +247,7 @@ bool CMetroidAreaCollider::ConvexPolyCollision(const zeus::CPlane* planes, const
otherVecIdx ^= 1;
}
rstl::reserved_vector<zeus::CVector3f, 128>& accumVec = vecs[otherVecIdx ^ 1];
rstl::reserved_vector<zeus::CVector3f, 20>& accumVec = vecs[otherVecIdx ^ 1];
for (const zeus::CVector3f& point : accumVec)
aabb.accumulateBounds(point);

View File

@ -172,7 +172,7 @@ void CCompoundTargetReticle::Update(float dt, const CStateManager& mgr)
xc4_chargeGauge.x0_model.Lock();
else
xc4_chargeGauge.x0_model.Unlock();
if (scan)
if (!scan)
x94_grapple.Lock();
else
x94_grapple.Unlock();
@ -492,12 +492,12 @@ void CCompoundTargetReticle::DrawGrapplePoint(const CScriptGrapplePoint& point,
color = g_tweakTargeting->GetLockedGrapplePointSelectColor();
else
color = g_tweakTargeting->GetGrapplePointSelectColor();
color = zeus::CColor::lerp(color, g_tweakTargeting->GetGrapplePointColor(), t);
color = zeus::CColor::lerp(g_tweakTargeting->GetGrapplePointColor(), color, t);
zeus::CMatrix3f scale(
CalculateClampedScale(orbitPos, 1.f, g_tweakTargeting->GetGrappleClampMin(),
g_tweakTargeting->GetGrappleClampMax(), mgr) *
(1.f - t) * g_tweakTargeting->GetGrappleScale() + t * g_tweakTargeting->GetGrappleSelectScale());
zeus::CTransform modelXf(scale, orbitPos);
((1.f - t) * g_tweakTargeting->GetGrappleScale() + t * g_tweakTargeting->GetGrappleSelectScale()));
zeus::CTransform modelXf(rot * scale, orbitPos);
CGraphics::SetModelMatrix(modelXf);
CModelFlags flags(7, 0, 0, color);
x94_grapple->Draw(flags);

View File

@ -2016,7 +2016,7 @@ CFrontEndUI::CFrontEndUI()
m_touchBar = NewFrontEndUITouchBar();
m_touchBar->SetPhase(CFrontEndUITouchBar::EPhase::None);
//x14_phase = EPhase::ExitFrontEnd;
x14_phase = EPhase::ExitFrontEnd;
}
void CFrontEndUI::StartSlideShow(CArchitectureQueue& queue)

View File

@ -233,9 +233,9 @@ bool CParticleSwoosh::Update(double dt)
timeElem->GetValue(x28_curFrame, time);
x30_curTime += std::max(0.0, dt * time);
while (!x1d0_26_disableUpdate && evalTime < x30_curTime)
while (x1d0_26_forceOneUpdate || evalTime < x30_curTime)
{
x1d0_26_disableUpdate = false;
x1d0_26_forceOneUpdate = false;
x158_curParticle += 1;
if (x158_curParticle >= x15c_swooshes.size())

View File

@ -80,7 +80,7 @@ class CParticleSwoosh : public CParticleGen
{
bool x1d0_24_emitting : 1;
bool x1d0_25_AALP : 1;
bool x1d0_26_disableUpdate : 1;
bool x1d0_26_forceOneUpdate : 1;
bool x1d0_27_renderGaps : 1;
bool x1d0_28_LLRD : 1;
bool x1d0_29_VLS1 : 1;
@ -162,7 +162,7 @@ public:
void DoWarmupUpdate()
{
x1d0_26_disableUpdate = true;
x1d0_26_forceOneUpdate = true;
Update(0.0);
}
@ -170,7 +170,7 @@ public:
{
for (int i=0 ; i<x15c_swooshes.size() ; ++i)
{
x1d0_26_disableUpdate = true;
x1d0_26_forceOneUpdate = true;
Update(0.0);
}
}
@ -189,7 +189,7 @@ public:
{
for (int i=0 ; i<x15c_swooshes.size()-1 ; ++i)
{
x1d0_26_disableUpdate = true;
x1d0_26_forceOneUpdate = true;
Update(0.0);
}
}
@ -218,7 +218,7 @@ public:
for (int i=0 ; i<6 ; ++i)
{
SetTranslation(translation);
x1d0_26_disableUpdate = true;
x1d0_26_forceOneUpdate = true;
Update(0.0);
translation += transInc;
}

View File

@ -28,7 +28,7 @@ CGrappleArm::CGrappleArm(const zeus::CVector3f& scale)
x360_grappleClawDesc(g_SimplePool->GetObj(SObjectTag{FOURCC('PART'), g_tweakGunRes->xb8_grappleClaw})),
x36c_grappleHitDesc(g_SimplePool->GetObj(SObjectTag{FOURCC('PART'), g_tweakGunRes->xbc_grappleHit})),
x378_grappleMuzzleDesc(g_SimplePool->GetObj(SObjectTag{FOURCC('PART'), g_tweakGunRes->xc0_grappleMuzzle})),
x384_grappleSwooshDesc(g_SimplePool->GetObj(SObjectTag{FOURCC('PART'), g_tweakGunRes->xc4_grappleSwoosh})),
x384_grappleSwooshDesc(g_SimplePool->GetObj(SObjectTag{FOURCC('SWHC'), g_tweakGunRes->xc4_grappleSwoosh})),
x390_grappleSegmentGen(std::make_unique<CElementGen>(x354_grappleSegmentDesc)),
x394_grappleClawGen(std::make_unique<CElementGen>(x360_grappleClawDesc)),
x398_grappleHitGen(std::make_unique<CElementGen>(x36c_grappleHitDesc)),
@ -272,6 +272,7 @@ void CGrappleArm::DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node,
case EUserEventType::Projectile:
if (x3b2_27_armMoving)
return;
x3b2_25_beamActive = true;
x398_grappleHitGen = std::make_unique<CElementGen>(x36c_grappleHitDesc);
x39c_grappleMuzzleGen = std::make_unique<CElementGen>(x378_grappleMuzzleDesc);
x338_beamT = 0.f;

View File

@ -3771,8 +3771,10 @@ void CPlayer::ApplyGrappleForces(const CFinalInput& input, CStateManager& mgr, f
{
zeus::CVector3f pointToPlayerFlat = pointToPlayer;
pointToPlayerFlat.z = 0.f;
zeus::CVector3f pointAtPlayerHeight = point->GetTranslation();
pointAtPlayerHeight.z = GetTranslation().z;
zeus::CVector3f playerToGrapplePlane =
point->GetTranslation() + turnRot.transform(pointToPlayerFlat) - GetTranslation();
pointAtPlayerHeight + turnRot.transform(pointToPlayerFlat) - GetTranslation();
if (playerToGrapplePlane.canBeNormalized())
pullVec += playerToGrapplePlane / dt;
}
@ -3876,7 +3878,7 @@ void CPlayer::UpdateGrappleState(const CFinalInput& input, CStateManager& mgr)
}
else
{
if (!g_tweakPlayer->GetGrappleJumpMode() && x3d8_grappleJumpTimeout <= 0.f)
if (g_tweakPlayer->GetGrappleJumpMode() == 0 && x3d8_grappleJumpTimeout <= 0.f)
ApplyGrappleJump(mgr);
BreakGrapple(EPlayerOrbitRequest::StopOrbit, mgr);
}
@ -3946,7 +3948,10 @@ void CPlayer::UpdateGrappleState(const CFinalInput& input, CStateManager& mgr)
break;
}
break;
default:
break;
}
break;
case EGrappleState::None:
x3b8_grappleState = EGrappleState::Firing;
x490_gun->GetGrappleArm().Activate(true);

View File

@ -12,8 +12,7 @@ CScriptGrapplePoint::CScriptGrapplePoint(TUniqueId uid, std::string_view name, c
: CActor(uid, active, name, info, transform, CModelData::CModelDataNull(), CMaterialList(EMaterialTypes::Orbit),
CActorParameters::None(),
kInvalidUniqueId),
xe8_(x34_transform.origin - 0.5f,
x34_transform.origin + 0.5f),
xe8_touchBounds(x34_transform.origin - 0.5f, x34_transform.origin + 0.5f),
x100_parameters(params)
{
}
@ -23,4 +22,47 @@ void CScriptGrapplePoint::Accept(IVisitor& visitor)
visitor.Visit(this);
}
void CScriptGrapplePoint::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr)
{
switch (msg)
{
case EScriptObjectMessage::Activate:
if (!GetActive())
{
AddMaterial(EMaterialTypes::Orbit, mgr);
SetActive(true);
}
break;
case EScriptObjectMessage::Deactivate:
if (GetActive())
{
RemoveMaterial(EMaterialTypes::Orbit, mgr);
SetActive(false);
}
break;
default:
break;
}
}
void CScriptGrapplePoint::Think(float, CStateManager&)
{
// Empty
}
void CScriptGrapplePoint::Render(const CStateManager&) const
{
// Empty
}
std::experimental::optional<zeus::CAABox> CScriptGrapplePoint::GetTouchBounds() const
{
return {xe8_touchBounds};
}
void CScriptGrapplePoint::AddToRenderer(const zeus::CFrustum&, const CStateManager& mgr) const
{
CActor::EnsureRendered(mgr);
}
}

View File

@ -8,13 +8,18 @@ namespace urde
{
class CScriptGrapplePoint : public CActor
{
zeus::CAABox xe8_;
zeus::CAABox xe8_touchBounds;
CGrappleParameters x100_parameters;
public:
CScriptGrapplePoint(TUniqueId uid, std::string_view name, const CEntityInfo& info,
const zeus::CTransform& transform, bool active, const CGrappleParameters& params);
void Accept(IVisitor& visitor);
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
void Think(float, CStateManager&);
void Render(const CStateManager&) const;
std::experimental::optional<zeus::CAABox> GetTouchBounds() const;
void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const;
const CGrappleParameters& GetGrappleParameters() const { return x100_parameters; }
};
}