Lots of bug fixes

This commit is contained in:
Jack Andersen 2019-03-12 17:46:20 -10:00
parent 52b36795ac
commit 99b1a8ef49
21 changed files with 109 additions and 96 deletions

View File

@ -218,18 +218,18 @@ struct HealthInfo : BigDNA {
struct LightParameters : BigDNA {
AT_DECL_DNA_YAML
Value<atUint32> propertyCount;
Value<bool> unknown1;
Value<float> unknown2;
Value<bool> castShadow;
Value<float> shadowScale;
Value<atUint32> shadowTesselation;
Value<float> unknown3;
Value<float> unknown4;
Value<atVec4f> noLightsAmbient; // CColor
Value<float> shadowAlpha;
Value<float> maxShadowHeight;
Value<atVec4f> ambientColor; // CColor
Value<bool> makeLights;
Value<atUint32> worldLightingOptions;
Value<atUint32> lightRecalculationOptions;
Value<atVec3f> actorPosBias;
Value<atUint32> maxDynamicLights;
Value<atUint32> maxAreaLights;
Value<atUint32> lightRecalculation;
Value<atVec3f> lightingPositionOffset;
Value<atUint32> numDynamicLights;
Value<atUint32> numAreaLights;
Value<bool> ambientChannelOverflow;
Value<atUint32> layerIndex;
};

View File

@ -9,9 +9,9 @@ struct RandomRelay : IScriptObject {
AT_DECL_DNA_YAML
AT_DECL_DNAV
String<-1> name;
Value<atUint32> unknown1;
Value<atUint32> unknown2;
Value<bool> unknown3;
Value<bool> unknown4;
Value<atUint32> sendSetSize;
Value<atUint32> sendSetVariance;
Value<bool> percentSize;
Value<bool> active;
};
} // namespace DataSpec::DNAMP1

View File

@ -117,7 +117,7 @@ void CBodyController::FaceDirection3D(const zeus::CVector3f& v0, const zeus::CVe
zeus::CUnitVector3f uv0 = v0;
zeus::CUnitVector3f uv1 = v1;
float dot = uv0.dot(uv1);
if (std::fabs(dot - 1.f) > 0.00001f) {
if (std::fabs(dot - 1.f) >= 0.00001f) {
if (dot < -0.9999f) {
zeus::CQuaternion rot =
zeus::CQuaternion::fromAxisAngle(act->GetTransform().basis[2], zeus::degToRad(dt * x2fc_turnSpeed));

View File

@ -136,8 +136,6 @@ pas::EAnimationState CBSProjectileAttack::GetBodyStateTransition(float dt, CBody
return pas::EAnimationState::KnockBack;
if (bc.GetCommandMgr().GetCmd(EBodyStateCmd::Locomotion))
return pas::EAnimationState::Locomotion;
if (bc.GetCommandMgr().GetCmd(EBodyStateCmd::Generate))
return pas::EAnimationState::Generate;
if (bc.IsAnimationOver() || bc.GetCommandMgr().GetCmd(EBodyStateCmd::NextState))
return pas::EAnimationState::Locomotion;
return pas::EAnimationState::Invalid;

View File

@ -51,7 +51,7 @@ zeus::CVector3f CSteeringBehaviors::Separation(const CPhysicsActor& actor, const
if (!posDiff.canBeNormalized())
return actor.GetTransform().frontVector();
return (1.f - (posDiff.magSquared() / (separation * separation))) * posDiff;
return (1.f - (posDiff.magSquared() / (separation * separation))) * posDiff.normalized();
}
zeus::CVector3f CSteeringBehaviors::Alignment(const CPhysicsActor& actor, rstl::reserved_vector<TUniqueId, 1024>& list,

View File

@ -233,10 +233,10 @@ void CTexturedQuadFilter::drawCropped(const zeus::CColor& color, float uvScale)
float yBias = CGraphics::g_CroppedViewport.x8_top / float(g_Viewport.xc_height);
Vert verts[4] = {
{{-1.0, -1.0, 0.f}, {xBias * uvScale, yBias * uvScale}},
{{-1.0, 1.0, 0.f}, {xBias * uvScale, (yBias + yFac) * uvScale}},
{{1.0, -1.0, 0.f}, {(xBias + xFac) * uvScale, yBias * uvScale}},
{{1.0, 1.0, 0.f}, {(xBias + xFac) * uvScale, (yBias + yFac) * uvScale}},
{{-1.f, -1.f, 0.f}, {xBias * uvScale, yBias * uvScale}},
{{-1.f, 1.f, 0.f}, {xBias * uvScale, (yBias + yFac) * uvScale}},
{{1.f, -1.f, 0.f}, {(xBias + xFac) * uvScale, yBias * uvScale}},
{{1.f, 1.f, 0.f}, {(xBias + xFac) * uvScale, (yBias + yFac) * uvScale}},
};
m_vbo->load(verts, sizeof(verts));

View File

@ -37,7 +37,7 @@ void CFaceplateDecoration::Draw(CStateManager& stateMgr) {
if (xc_ready && m_texFilter) {
zeus::CColor color = zeus::skWhite;
color.a() = stateMgr.GetPlayer().GetVisorSteam().GetAlpha();
m_texFilter->draw(color, 1.f);
m_texFilter->DrawFilter(EFilterShape::FullscreenQuarters, color, 1.f);
}
}

View File

@ -71,6 +71,7 @@ CFrontEndUI::SNewFileSelectFrame::SNewFileSelectFrame(CSaveGameScreen* sui, u32
}
void CFrontEndUI::SNewFileSelectFrame::FinishedLoading() {
x1c_loadedFrame->Reset();
x1c_loadedFrame->SetAspectConstraint(1.78f);
x20_tablegroup_fileselect = static_cast<CGuiTableGroup*>(x1c_loadedFrame->FindWidget("tablegroup_fileselect"));

View File

@ -46,6 +46,7 @@ bool CMessageScreen::Update(float dt, float blurAmt) {
x70_blurAmt = blurAmt;
if (!x18_loadedMsgScreen && xc_msgScreen.IsLoaded() && x0_msg.IsLoaded()) {
x18_loadedMsgScreen = xc_msgScreen.GetObj();
x18_loadedMsgScreen->Reset();
x1c_textpane_message = static_cast<CGuiTextPane*>(x18_loadedMsgScreen->FindWidget("textpane_message"));
x20_basewidget_top = x18_loadedMsgScreen->FindWidget("basewidget_top");
x24_basewidget_center = x18_loadedMsgScreen->FindWidget("basewidget_center");

View File

@ -42,8 +42,10 @@ CSamusHud::CSamusHud(CStateManager& stateMgr)
x72c_camZTweaks[i] = 0.5f * i - 8.f;
x264_loadedFrmeHelmet = x258_frmeHelmet.GetObj();
x264_loadedFrmeHelmet->Reset();
x264_loadedFrmeHelmet->SetMaxAspect(1.78f);
x274_loadedFrmeBaseHud = x268_frmeBaseHud.GetObj();
x274_loadedFrmeBaseHud->Reset();
x274_loadedFrmeBaseHud->SetMaxAspect(1.78f);
x2a0_helmetIntf = std::make_unique<CHudHelmetInterface>(*x264_loadedFrmeHelmet);

View File

@ -889,7 +889,7 @@ void CElementGen::RenderModels(const CActorLights* actorLights) {
}
zeus::CTransform orient = zeus::CTransform();
if (desc->x45_25_x31_27_PMOO)
if (!desc->x45_25_x31_27_PMOO)
orient = x1d8_orientation;
orient = orient * x22c_globalOrientation;

View File

@ -153,7 +153,7 @@ void CParticleElectric::UpdateLine(int idx, int frame) {
void CParticleElectric::UpdateElectricalEffects() {
for (auto it = x3e8_electricManagers.begin(); it != x3e8_electricManagers.end();) {
CParticleElectricManager& elec = *it;
if (elec.x4_slif < 1) {
if (elec.x4_slif <= 1) {
x1bc_allocated[elec.x0_idx] = false;
if (elec.x10_gpsmIdx != -1)
x400_gpsmGenerators[elec.x10_gpsmIdx]->SetParticleEmission(false);
@ -373,6 +373,7 @@ void CParticleElectric::CreateNewParticles(int count) {
gen.SetTranslation(scale * x420_calculatedVerts.front());
gen.SetParticleEmission(true);
elec.x10_gpsmIdx = k;
break;
}
}
}
@ -386,6 +387,7 @@ void CParticleElectric::CreateNewParticles(int count) {
gen.SetTranslation(scale * x420_calculatedVerts.back());
gen.SetParticleEmission(true);
elec.x14_epsmIdx = k;
break;
}
}
}

View File

@ -1632,7 +1632,8 @@ void CPlayerGun::UpdateGunIdle(bool inStrikeCooldown, float camBobT, float dt, C
(x2f4_fireButtonStates & 0x3) == 0 && x32c_chargePhase == EChargePhase::NotCharging && !x832_29_lockedOn &&
(x2f8_stateFlags & 0x8) != 0x8 && x364_gunStrikeCoolTimer <= 0.f &&
player.GetPlayerMovementState() == CPlayer::EPlayerMovementState::OnGround && !player.IsInFreeLook() &&
!player.GetFreeLookStickState() && x304_ == 0 && std::fabs(player.GetAngularVelocityOR().angle()) <= 0.1f &&
!player.GetFreeLookStickState() && player.GetOrbitState() == CPlayer::EPlayerOrbitState::NoOrbit &&
std::fabs(player.GetAngularVelocityOR().angle()) <= 0.1f &&
camBobT <= 0.01f && !mgr.GetCameraManager()->IsInCinematicCamera() &&
player.GetGunHolsterState() == CPlayer::EGunHolsterState::Drawn &&
player.GetGrappleState() == CPlayer::EGrappleState::None && !x834_30_inBigStrike && !x835_25_inPhazonBeam);
@ -1933,7 +1934,7 @@ void CPlayerGun::Update(float grappleSwingT, float cameraBobT, float dt, CStateM
UpdateAuxWeapons(advDt, beamTargetXf, mgr);
DoUserAnimEvents(advDt, mgr);
if (x304_ == 1 && GetTargetId(mgr) != kInvalidUniqueId) {
if (player.GetOrbitState() == CPlayer::EPlayerOrbitState::OrbitObject && GetTargetId(mgr) != kInvalidUniqueId) {
if (!x832_29_lockedOn && !x832_26_comboFiring && (x2f8_stateFlags & 0x10) != 0x10) {
x832_29_lockedOn = true;
x6a0_motionState.SetState(CMotionState::EMotionState::LockOn);

View File

@ -65,7 +65,7 @@ void CExplosion::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CSt
void CExplosion::Think(float dt, CStateManager& mgr) {
if (xe4_28_transformDirty) {
xe8_particleGen->SetGlobalTranslation(GetTranslation());
xe8_particleGen->SetGlobalOrientation(GetTransform().getRotation());
xe8_particleGen->SetOrientation(GetTransform().getRotation());
xe4_28_transformDirty = false;
}
xe8_particleGen->Update(dt);

View File

@ -952,7 +952,8 @@ void CPatterned::GenerateDeathExplosion(CStateManager& mgr) {
CEntityInfo(GetAreaIdAlways(), CEntity::NullConnectionList), "", xf, 1,
zeus::skOne3f, zeus::skWhite);
mgr.AddObject(explo);
} else if (x530_deathExplosionElectric) {
}
if (x530_deathExplosionElectric) {
zeus::CTransform xf(GetTransform());
xf.origin = GetTransform() * (x64_modelData->GetScale() * x514_deathExplosionOffset);
CExplosion* explo = new CExplosion(*x530_deathExplosionElectric, mgr.AllocateUniqueId(), true,

View File

@ -5472,7 +5472,7 @@ void CPlayer::Touch(CActor& actor, CStateManager& mgr) {
void CPlayer::CVisorSteam::SetSteam(float targetAlpha, float alphaInDur, float alphaOutDur, CAssetId txtr,
bool affectsThermal) {
if (x1c_txtr.IsValid() || targetAlpha > x10_nextTargetAlpha) {
if (!x1c_txtr.IsValid() || targetAlpha > x10_nextTargetAlpha) {
x10_nextTargetAlpha = targetAlpha;
x14_nextAlphaInDur = alphaInDur;
x18_nextAlphaOutDur = alphaOutDur;
@ -5484,9 +5484,9 @@ void CPlayer::CVisorSteam::SetSteam(float targetAlpha, float alphaInDur, float a
CAssetId CPlayer::CVisorSteam::GetTextureId() const { return xc_tex; }
void CPlayer::CVisorSteam::Update(float dt) {
if (!x1c_txtr.IsValid())
if (!x1c_txtr.IsValid()) {
x0_curTargetAlpha = 0.f;
else {
} else {
x0_curTargetAlpha = x10_nextTargetAlpha;
x4_curAlphaInDur = x14_nextAlphaInDur;
x8_curAlphaOutDur = x18_nextAlphaOutDur;
@ -5494,16 +5494,18 @@ void CPlayer::CVisorSteam::Update(float dt) {
}
x1c_txtr.Reset();
if ((x20_alpha - x0_curTargetAlpha) < 0.000009999f || std::fabs(x20_alpha) > 0.000009999f)
if (zeus::close_enough(x20_alpha, x0_curTargetAlpha) && zeus::close_enough(x20_alpha, 0.f))
return;
if (x20_alpha > x0_curTargetAlpha) {
if (x24_delayTimer <= 0.f) {
x20_alpha -= dt / x8_curAlphaOutDur;
x20_alpha = std::min(x20_alpha, x0_curTargetAlpha);
if (x20_alpha < x0_curTargetAlpha)
x20_alpha = x0_curTargetAlpha;
} else {
x24_delayTimer = x0_curTargetAlpha - dt;
x24_delayTimer = zeus::max(0.f, x24_delayTimer);
x24_delayTimer -= dt;
if (x24_delayTimer < 0.f)
x24_delayTimer = 0.f;
}
return;
}

View File

@ -815,6 +815,7 @@ void CScriptGunTurret::ProcessTargettingState(EStateMsg msg, CStateManager& mgr,
}
zeus::CVector3f diffVec = x404_targetPosition - GetTranslation();
diffVec.z() = 0.f;
if (diffVec.canBeNormalized()) {
zeus::CVector3f normDiff = diffVec.normalized();
float angDif = zeus::CVector3f::getAngleDiff(normDiff, GetTransform().frontVector());

View File

@ -3,12 +3,12 @@
#include "TCastTo.hpp"
namespace urde {
CScriptRandomRelay::CScriptRandomRelay(TUniqueId uid, std::string_view name, const CEntityInfo& info, s32 connCount,
s32 variance, bool clamp, bool active)
CScriptRandomRelay::CScriptRandomRelay(TUniqueId uid, std::string_view name, const CEntityInfo& info, s32 sendSetSize,
s32 sendSetVariance, bool percentSize, bool active)
: CEntity(uid, info, active, name)
, x34_connectionCount((clamp && connCount > 100) ? 100 : connCount)
, x38_variance(variance)
, x3c_clamp(clamp) {}
, x34_sendSetSize((percentSize && sendSetSize > 100) ? 100 : sendSetSize)
, x38_sendSetVariance(sendSetVariance)
, x3c_percentSize(percentSize) {}
void CScriptRandomRelay::Accept(IVisitor& visitor) { visitor.Visit(this); }
@ -27,27 +27,36 @@ void CScriptRandomRelay::SendLocalScriptMsgs(EScriptObjectState state, CStateMan
return;
}
#if 0
std::vector<std::pair<CEntity*, EScriptObjectMessage>> objs;
objs.reserve(10);
for (const SConnection& conn : x20_conns)
{
auto list = stateMgr.GetIdListForScript(conn.x8_objId);
auto it = list.first;
for (; it != list.second; ++it)
{
CEntity* ent = stateMgr.ObjectById(it->second);
if (ent && ent->GetActive())
objs.emplace_back(ent, conn.x4_msg);
}
std::vector<std::pair<CEntity*, EScriptObjectMessage>> objs;
objs.reserve(10);
for (const SConnection& conn : x20_conns) {
auto list = stateMgr.GetIdListForScript(conn.x8_objId);
for (auto it = list.first; it != list.second; ++it) {
CEntity* ent = stateMgr.ObjectById(it->second);
if (ent && ent->GetActive())
objs.emplace_back(ent, conn.x4_msg);
}
}
u32 r0 = x34_connectionCount;
if (x3c_clamp)
r0 = u32(0.5 + (float(x34_connectionCount) / 100.f));
s32 targetSetSize = x34_sendSetSize;
if (x3c_percentSize)
targetSetSize = s32(0.5f + (float(x34_sendSetSize * objs.size()) / 100.f));
targetSetSize += s32(float(x38_sendSetVariance) * 2.f * stateMgr.GetActiveRandom()->Float()) - x38_sendSetVariance;
targetSetSize = zeus::clamp(0, targetSetSize, 64);
float fVariance = float(x38_variance) * (2.f * stateMgr.GetActiveRandom()->Float());
while (objs.size() > targetSetSize) {
s32 randomRemoveIdx = s32(stateMgr.GetActiveRandom()->Float() * float(objs.size()) * 0.99f);
auto it = objs.begin();
for (s32 i = 0; i < randomRemoveIdx; ++i) {
++it;
if (it == objs.end())
break;
}
if (it != objs.end())
objs.erase(it);
}
#endif
for (const auto& o : objs)
stateMgr.SendScriptMsg(o.first, GetUniqueId(), o.second);
}
} // namespace urde

View File

@ -4,12 +4,13 @@
namespace urde {
class CScriptRandomRelay : public CEntity {
u32 x34_connectionCount;
u32 x38_variance;
bool x3c_clamp;
s32 x34_sendSetSize;
s32 x38_sendSetVariance;
bool x3c_percentSize;
public:
CScriptRandomRelay(TUniqueId, std::string_view, const CEntityInfo&, s32, s32, bool, bool);
CScriptRandomRelay(TUniqueId uid, std::string_view name, const CEntityInfo& info, s32 sendSetSize,
s32 sendSetVariance, bool percentSize, bool active);
void Accept(IVisitor& visitor);
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr);

View File

@ -953,12 +953,12 @@ CEntity* ScriptLoader::LoadRandomRelay(CStateManager& mgr, CInputStream& in, int
if (!EnsurePropertyCount(propCount, 5, "RandomRelay"))
return nullptr;
std::string name = mgr.HashInstanceName(in);
u32 w1 = in.readUint32Big();
u32 w2 = in.readUint32Big();
bool b1 = in.readBool();
bool b2 = in.readBool();
u32 sendSetSize = in.readUint32Big();
u32 sendSetVariance = in.readUint32Big();
bool percentSize = in.readBool();
bool active = in.readBool();
return new CScriptRandomRelay(mgr.AllocateUniqueId(), name, info, w1, w2, b1, b2);
return new CScriptRandomRelay(mgr.AllocateUniqueId(), name, info, sendSetSize, sendSetVariance, percentSize, active);
}
CEntity* ScriptLoader::LoadRelay(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) {
@ -2033,7 +2033,7 @@ CEntity* ScriptLoader::LoadDebrisExtended(CStateManager& mgr, CInputStream& in,
CScriptDebris::EOrientationType particle2Or = CScriptDebris::EOrientationType(in.readUint32Big());
CAssetId particle3 = in.readUint32Big();
zeus::CVector3f particle3Scale = zeus::CVector3f::ReadBig(in);
zeus::CVector3f particle3Scale = zeus::CVector3f::ReadBig(in); /* Not actually used, go figure */
CScriptDebris::EOrientationType particle3Or = CScriptDebris::EOrientationType(in.readUint32Big());
bool solid = in.readBool();
@ -2051,7 +2051,7 @@ CEntity* ScriptLoader::LoadDebrisExtended(CStateManager& mgr, CInputStream& in,
downwardSpeed, localOffset, particle1, particle1Scale, particle1GlobalTranslation,
deferDeleteTillParticle1Done, particle1Or, particle2, particle2Scale,
particle2GlobalTranslation, deferDeleteTillParticle2Done, particle2Or, particle3,
particle3Scale, particle3Or, solid, dieOnProjectile, noBounce, active);
particle2Scale, particle3Or, solid, dieOnProjectile, noBounce, active);
}
CEntity* ScriptLoader::LoadSteam(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) {

View File

@ -221,15 +221,13 @@ struct VertToFrag
ivec2 Lookup8BPP(in vec2 uv, in float randOff)
{
float bx;
float rx = modf(uv.x / 8.0, bx) * 8.0;
float by;
float ry = modf(uv.y / 4.0, by) * 4.0;
float bidx = by * 80.0 + bx;
float addr = bidx * 32.0 + ry * 8.0 + rx + randOff;
float y;
float x = modf(addr / 1024.0, y) * 1024.0;
return ivec2(x, y);
int bx = int(uv.x) >> 3;
int rx = int(uv.x) & 0x7;
int by = int(uv.y) >> 2;
int ry = int(uv.y) & 0x3;
int bidx = by * 128 + bx;
int addr = bidx * 32 + ry * 8 + rx + int(randOff);
return ivec2(addr & 0x3ff, addr >> 10);
}
SBINDING(0) in VertToFrag vtf;
@ -254,15 +252,13 @@ struct VertToFrag
static int3 Lookup8BPP(float2 uv, float randOff)
{
float bx;
float rx = modf(uv.x / 8.0, bx) * 8.0;
float by;
float ry = modf(uv.y / 4.0, by) * 4.0;
float bidx = by * 80.0 + bx;
float addr = bidx * 32.0 + ry * 8.0 + rx + randOff;
float y;
float x = modf(addr / 1024.0, y) * 1024.0;
return int3(x, y, 0);
int bx = int(uv.x) >> 3;
int rx = int(uv.x) & 0x7;
int by = int(uv.y) >> 2;
int ry = int(uv.y) & 0x3;
int bidx = by * 128 + bx;
int addr = bidx * 32 + ry * 8 + rx + int(randOff);
return int3(addr & 0x3ff, addr >> 10, 0);
}
Texture2D tex : register(t0);
@ -286,15 +282,13 @@ struct VertToFrag
static uint2 Lookup8BPP(float2 uv, float randOff)
{
float bx;
float rx = modf(uv.x / 8.0, bx) * 8.0;
float by;
float ry = modf(uv.y / 4.0, by) * 4.0;
float bidx = by * 80.0 + bx;
float addr = bidx * 32.0 + ry * 8.0 + rx + randOff;
float y;
float x = modf(addr / 1024.0, y) * 1024.0;
return uint2(x, y);
int bx = int(uv.x) >> 3;
int rx = int(uv.x) & 0x7;
int by = int(uv.y) >> 2;
int ry = int(uv.y) & 0x3;
int bidx = by * 128 + bx;
int addr = bidx * 32 + ry * 8 + rx + int(randOff);
return uint2(addr & 0x3ff, addr >> 10);
}
fragment float4 fmain(VertToFrag vtf [[ stage_in ]],