Fix player dynamic collision

This commit is contained in:
Jack Andersen 2018-02-07 20:18:27 -10:00
parent 2fee221871
commit ae6797f24b
16 changed files with 120 additions and 106 deletions

View File

@ -15,24 +15,24 @@ struct Actor : IScriptObject
Value<atVec3f> scale SO_SCALE_SPECPROP(); Value<atVec3f> scale SO_SCALE_SPECPROP();
Value<atVec3f> collisionExtent SO_COLLISION_EXTENT_SPECPROP(); Value<atVec3f> collisionExtent SO_COLLISION_EXTENT_SPECPROP();
Value<atVec3f> collisionOffset SO_COLLISION_OFFSET_SPECPROP(); Value<atVec3f> collisionOffset SO_COLLISION_OFFSET_SPECPROP();
Value<float> unknown2; Value<float> mass;
Value<float> unknown3; Value<float> zMomentum;
HealthInfo healthInfo; HealthInfo healthInfo;
DamageVulnerability damageVulnerability; DamageVulnerability damageVulnerability;
UniqueID32 model; UniqueID32 model;
AnimationParameters animationParameters; AnimationParameters animationParameters;
ActorParameters actorParameters; ActorParameters actorParameters;
Value<bool> unkown4; Value<bool> looping;
Value<bool> unkown5; Value<bool> snow;
Value<bool> unkown6; Value<bool> solid;
Value<bool> unkown7; Value<bool> cameraPassthrough;
Value<bool> unkown8; Value<bool> active;
Value<atUint32> unknown9; Value<atUint32> shaderIdx;
Value<float> unknown10; Value<float> xrayAlpha;
Value<bool> unknown11; Value<bool> noThermalHotZ;
Value<bool> unknown12; Value<bool> castsShadow;
Value<bool> unknown13; Value<bool> scaleAdvancementDelta;
Value<bool> unknown14; Value<bool> materialFlag54;
void addCMDLRigPairs(PAKRouter<PAKBridge>& pakRouter, void addCMDLRigPairs(PAKRouter<PAKBridge>& pakRouter,
std::unordered_map<UniqueID32, std::pair<UniqueID32, UniqueID32>>& addTo) const std::unordered_map<UniqueID32, std::pair<UniqueID32, UniqueID32>>& addTo) const

View File

@ -206,7 +206,7 @@ CStateManager::CStateManager(const std::weak_ptr<CRelayTracker>& relayTracker,
x90c_loaderFuncs[int(EScriptObjectType::ShadowProjector)] = ScriptLoader::LoadShadowProjector; x90c_loaderFuncs[int(EScriptObjectType::ShadowProjector)] = ScriptLoader::LoadShadowProjector;
x90c_loaderFuncs[int(EScriptObjectType::EnergyBall)] = ScriptLoader::LoadEnergyBall; x90c_loaderFuncs[int(EScriptObjectType::EnergyBall)] = ScriptLoader::LoadEnergyBall;
//CGameCollision::InitCollision(); CGameCollision::InitCollision();
ControlMapper::ResetCommandFilters(); ControlMapper::ResetCommandFilters();
x8f0_shadowTex = g_SimplePool->GetObj("DefaultShadow"); x8f0_shadowTex = g_SimplePool->GetObj("DefaultShadow");
} }
@ -734,7 +734,7 @@ void CStateManager::DrawWorld() const
for (TUniqueId id : x86c_stateManagerContainer->xf370_) for (TUniqueId id : x86c_stateManagerContainer->xf370_)
if (const CActor* ent = static_cast<const CActor*>(GetObjectById(id))) if (const CActor* ent = static_cast<const CActor*>(GetObjectById(id)))
if (!thermal || ent->xe6_27_renderVisorFlags & 0x1) if (!thermal || ent->xe6_27_thermalVisorFlags & 0x1)
ent->Render(*this); ent->Render(*this);
bool morphingPlayerVisible = false; bool morphingPlayerVisible = false;
@ -772,9 +772,9 @@ void CStateManager::DrawWorld() const
continue; continue;
} }
} }
if (!thermal || actor->xe6_27_renderVisorFlags & 0x1) if (!thermal || actor->xe6_27_thermalVisorFlags & 0x1)
actor->AddToRenderer(frustum, *this); actor->AddToRenderer(frustum, *this);
if (thermal && actor->xe6_27_renderVisorFlags & 0x2) if (thermal && actor->xe6_27_thermalVisorFlags & 0x2)
thermalActorArr[thermalActorCount++] = actor.GetPtr(); thermalActorArr[thermalActorCount++] = actor.GetPtr();
} }
} }
@ -810,7 +810,7 @@ void CStateManager::DrawWorld() const
CGraphics::SetDepthRange(DEPTH_SCREEN_ACTORS, DEPTH_GUN); CGraphics::SetDepthRange(DEPTH_SCREEN_ACTORS, DEPTH_GUN);
for (TUniqueId id : x86c_stateManagerContainer->xf39c_renderLast) for (TUniqueId id : x86c_stateManagerContainer->xf39c_renderLast)
if (const CActor* actor = static_cast<const CActor*>(GetObjectById(id))) if (const CActor* actor = static_cast<const CActor*>(GetObjectById(id)))
if (actor->xe6_27_renderVisorFlags & 0x1) if (actor->xe6_27_thermalVisorFlags & 0x1)
actor->Render(*this); actor->Render(*this);
CGraphics::SetDepthRange(DEPTH_WORLD, DEPTH_FAR); CGraphics::SetDepthRange(DEPTH_WORLD, DEPTH_FAR);
} }
@ -819,7 +819,7 @@ void CStateManager::DrawWorld() const
for (TUniqueId id : x86c_stateManagerContainer->xf370_) for (TUniqueId id : x86c_stateManagerContainer->xf370_)
if (const CActor* actor = static_cast<const CActor*>(GetObjectById(id))) if (const CActor* actor = static_cast<const CActor*>(GetObjectById(id)))
if (actor->xe6_27_renderVisorFlags & 0x2) if (actor->xe6_27_thermalVisorFlags & 0x2)
actor->Render(*this); actor->Render(*this);
for (int i=areaCount-1 ; i>=0 ; --i) for (int i=areaCount-1 ; i>=0 ; --i)
@ -882,7 +882,7 @@ void CStateManager::DrawWorld() const
CGraphics::SetDepthRange(DEPTH_SCREEN_ACTORS, DEPTH_GUN); CGraphics::SetDepthRange(DEPTH_SCREEN_ACTORS, DEPTH_GUN);
for (TUniqueId id : x86c_stateManagerContainer->xf39c_renderLast) for (TUniqueId id : x86c_stateManagerContainer->xf39c_renderLast)
if (const CActor* actor = static_cast<const CActor*>(GetObjectById(id))) if (const CActor* actor = static_cast<const CActor*>(GetObjectById(id)))
if (actor->xe6_27_renderVisorFlags & 0x2) if (actor->xe6_27_thermalVisorFlags & 0x2)
actor->Render(*this); actor->Render(*this);
CGraphics::SetDepthRange(DEPTH_WORLD, DEPTH_FAR); CGraphics::SetDepthRange(DEPTH_WORLD, DEPTH_FAR);
} }

View File

@ -587,14 +587,16 @@ bool CGameCollision::DetectCollision_Cached_Moving(const CStateManager& mgr, CAr
const zeus::CVector3f& dir, const zeus::CVector3f& dir,
TUniqueId& idOut, CCollisionInfo& infoOut, double& d) TUniqueId& idOut, CCollisionInfo& infoOut, double& d)
{ {
bool ret = false;
idOut = kInvalidUniqueId; idOut = kInvalidUniqueId;
if (!filter.GetExcludeList().HasMaterial(EMaterialTypes::NoStaticCollision)) if (!filter.GetExcludeList().HasMaterial(EMaterialTypes::NoStaticCollision))
{
if (CGameCollision::DetectStaticCollision_Cached_Moving(mgr, cache, prim, xf, filter, dir, infoOut, d)) if (CGameCollision::DetectStaticCollision_Cached_Moving(mgr, cache, prim, xf, filter, dir, infoOut, d))
return true; ret = true;
}
return CGameCollision::DetectDynamicCollisionMoving(prim, xf, nearList, dir, idOut, infoOut, d, mgr); if (CGameCollision::DetectDynamicCollisionMoving(prim, xf, nearList, dir, idOut, infoOut, d, mgr))
ret = true;
return ret;
} }
bool CGameCollision::DetectStaticCollision(const CStateManager& mgr, const CCollisionPrimitive& prim, bool CGameCollision::DetectStaticCollision(const CStateManager& mgr, const CCollisionPrimitive& prim,
@ -604,6 +606,7 @@ bool CGameCollision::DetectStaticCollision(const CStateManager& mgr, const CColl
if (prim.GetPrimType() == FOURCC('OBTG')) if (prim.GetPrimType() == FOURCC('OBTG'))
return false; return false;
bool ret = false;
if (prim.GetPrimType() == FOURCC('AABX')) if (prim.GetPrimType() == FOURCC('AABX'))
{ {
zeus::CAABox aabb = prim.CalculateAABox(xf); zeus::CAABox aabb = prim.CalculateAABox(xf);
@ -612,7 +615,7 @@ bool CGameCollision::DetectStaticCollision(const CStateManager& mgr, const CColl
if (CMetroidAreaCollider::AABoxCollisionCheck( if (CMetroidAreaCollider::AABoxCollisionCheck(
*area.GetPostConstructed()->x0_collision, aabb, filter, *area.GetPostConstructed()->x0_collision, aabb, filter,
prim.GetMaterial(), list)) prim.GetMaterial(), list))
return true; ret = true;
} }
} }
else if (prim.GetPrimType() == FOURCC('SPHR')) else if (prim.GetPrimType() == FOURCC('SPHR'))
@ -625,7 +628,7 @@ bool CGameCollision::DetectStaticCollision(const CStateManager& mgr, const CColl
if (CMetroidAreaCollider::SphereCollisionCheck( if (CMetroidAreaCollider::SphereCollisionCheck(
*area.GetPostConstructed()->x0_collision, aabb, xfSphere, *area.GetPostConstructed()->x0_collision, aabb, xfSphere,
prim.GetMaterial(), filter, list)) prim.GetMaterial(), filter, list))
return true; ret = true;
} }
} }
else if (prim.GetPrimType() == FOURCC('ABSH')) else if (prim.GetPrimType() == FOURCC('ABSH'))
@ -633,7 +636,7 @@ bool CGameCollision::DetectStaticCollision(const CStateManager& mgr, const CColl
// Combination AABB / Sphere cut from game // Combination AABB / Sphere cut from game
} }
return false; return ret;
} }
bool CGameCollision::DetectStaticCollision_Cached(const CStateManager& mgr, CAreaCollisionCache& cache, bool CGameCollision::DetectStaticCollision_Cached(const CStateManager& mgr, CAreaCollisionCache& cache,
@ -643,6 +646,7 @@ bool CGameCollision::DetectStaticCollision_Cached(const CStateManager& mgr, CAre
if (prim.GetPrimType() == FOURCC('OBTG')) if (prim.GetPrimType() == FOURCC('OBTG'))
return false; return false;
bool ret = false;
zeus::CAABox calcAABB = prim.CalculateAABox(xf); zeus::CAABox calcAABB = prim.CalculateAABox(xf);
if (!calcAABB.inside(cache.GetCacheBounds())) if (!calcAABB.inside(cache.GetCacheBounds()))
{ {
@ -660,7 +664,7 @@ bool CGameCollision::DetectStaticCollision_Cached(const CStateManager& mgr, CAre
for (CMetroidAreaCollider::COctreeLeafCache& leafCache : cache) for (CMetroidAreaCollider::COctreeLeafCache& leafCache : cache)
if (CMetroidAreaCollider::AABoxCollisionCheck_Cached(leafCache, calcAABB, filter, if (CMetroidAreaCollider::AABoxCollisionCheck_Cached(leafCache, calcAABB, filter,
prim.GetMaterial(), list)) prim.GetMaterial(), list))
return true; ret = true;
} }
else if (prim.GetPrimType() == FOURCC('SPHR')) else if (prim.GetPrimType() == FOURCC('SPHR'))
{ {
@ -669,14 +673,14 @@ bool CGameCollision::DetectStaticCollision_Cached(const CStateManager& mgr, CAre
for (CMetroidAreaCollider::COctreeLeafCache& leafCache : cache) for (CMetroidAreaCollider::COctreeLeafCache& leafCache : cache)
if (CMetroidAreaCollider::SphereCollisionCheck_Cached(leafCache, calcAABB, xfSphere, if (CMetroidAreaCollider::SphereCollisionCheck_Cached(leafCache, calcAABB, xfSphere,
prim.GetMaterial(), filter, list)) prim.GetMaterial(), filter, list))
return true; ret = true;
} }
else if (prim.GetPrimType() == FOURCC('ABSH')) else if (prim.GetPrimType() == FOURCC('ABSH'))
{ {
// Combination AABB / Sphere cut from game // Combination AABB / Sphere cut from game
} }
return false; return ret;
} }
bool CGameCollision::DetectStaticCollision_Cached_Moving(const CStateManager& mgr, CAreaCollisionCache& cache, bool CGameCollision::DetectStaticCollision_Cached_Moving(const CStateManager& mgr, CAreaCollisionCache& cache,
@ -782,7 +786,6 @@ bool CGameCollision::DetectDynamicCollisionMoving(const CCollisionPrimitive& pri
infoOut = info; infoOut = info;
dOut = d; dOut = d;
idOut = actor->GetUniqueId(); idOut = actor->GetUniqueId();
return true;
} }
} }
} }

View File

@ -1178,8 +1178,8 @@ bool MovingSphereAABox(const zeus::CSphere& sphere, const zeus::CAABox& aabb, co
bool AABox_AABox_Moving(const zeus::CAABox& aabb0, const zeus::CAABox& aabb1, const zeus::CVector3f& dir, bool AABox_AABox_Moving(const zeus::CAABox& aabb0, const zeus::CAABox& aabb1, const zeus::CVector3f& dir,
double& d, zeus::CVector3f& point, zeus::CVector3f& normal) double& d, zeus::CVector3f& point, zeus::CVector3f& normal)
{ {
zeus::CVector3d vecMin(DBL_MIN); zeus::CVector3d vecMin(-FLT_MAX);
zeus::CVector3d vecMax(DBL_MAX); zeus::CVector3d vecMax(FLT_MAX);
for (int i=0 ; i<3 ; ++i) for (int i=0 ; i<3 ; ++i)
{ {
@ -1221,10 +1221,10 @@ bool AABox_AABox_Moving(const zeus::CAABox& aabb0, const zeus::CAABox& aabb1, co
if (vecMin[2] > vecMin[maxAxis]) if (vecMin[2] > vecMin[maxAxis])
maxAxis = 2; maxAxis = 2;
float minMax = std::min(std::min(vecMax[2], vecMax[1]), vecMax[0]); double minMax = std::min(std::min(vecMax[2], vecMax[1]), vecMax[0]);
if (vecMin[maxAxis] > minMax) if (vecMin[maxAxis] > minMax)
return false; return false;
d = minMax; d = vecMin[maxAxis];
normal = zeus::CVector3f::skZero; normal = zeus::CVector3f::skZero;
normal[maxAxis] = dir[maxAxis] > 0.f ? -1.f : 1.f; normal[maxAxis] = dir[maxAxis] > 0.f ? -1.f : 1.f;

View File

@ -48,6 +48,18 @@ struct CModelFlags
0x8: depth greater 0x8: depth greater
0x10: depth non-inclusive 0x10: depth non-inclusive
*/ */
bool operator==(const CModelFlags& other) const
{
return x0_blendMode == other.x0_blendMode && x1_matSetIdx == other.x1_matSetIdx &&
x2_flags == other.x2_flags && x4_color == other.x4_color;
}
bool operator!=(const CModelFlags& other) const
{
return x0_blendMode != other.x0_blendMode || x1_matSetIdx != other.x1_matSetIdx ||
x2_flags != other.x2_flags || x4_color != other.x4_color;
}
}; };
/* urde addition: doesn't require hacky stashing of /* urde addition: doesn't require hacky stashing of

View File

@ -14,7 +14,7 @@ CEnergyProjectile::CEnergyProjectile(bool active, const TToken<CWeaponDescriptio
x2ec_dir(xf.basis[1]), x2f8_mag(x2ec_dir.magnitude()), x2ec_dir(xf.basis[1]), x2f8_mag(x2ec_dir.magnitude()),
x2fc_camShake(CCameraShakeData::BuildProjectileCameraShake(0.5f, 0.75f)) x2fc_camShake(CCameraShakeData::BuildProjectileCameraShake(0.5f, 0.75f))
{ {
xe6_27_renderVisorFlags = 2; xe6_27_thermalVisorFlags = 2;
} }
} }

View File

@ -47,7 +47,7 @@ CActor::CActor(TUniqueId uid, bool active, std::string_view name, const CEntityI
xe5_28_callTouch = true; xe5_28_callTouch = true;
xe5_29_globalTimeProvider = params.x58_24_; xe5_29_globalTimeProvider = params.x58_24_;
xe5_30_ = params.x58_26_; xe5_30_ = params.x58_26_;
xe6_27_renderVisorFlags = u8(params.x58_25_thermalHeat ? 2 : 1); xe6_27_thermalVisorFlags = u8(params.x58_25_thermalHeat ? 2 : 1);
xe6_29_prePostParticles = true; xe6_29_prePostParticles = true;
xe6_31_targetableVisorFlags = params.GetVisorParameters().GetMask(); xe6_31_targetableVisorFlags = params.GetVisorParameters().GetMask();
xe7_27_enableRender = true; xe7_27_enableRender = true;

View File

@ -67,7 +67,7 @@ protected:
bool xe5_30_ : 1; bool xe5_30_ : 1;
bool xe5_31_pointGeneratorParticles : 1; bool xe5_31_pointGeneratorParticles : 1;
u8 xe6_24_fluidCounter : 3; u8 xe6_24_fluidCounter : 3;
u8 xe6_27_renderVisorFlags : 2; // 1: thermal cold, 2: thermal hot u8 xe6_27_thermalVisorFlags : 2; // 1: thermal cold, 2: thermal hot
bool xe6_29_prePostParticles : 1; bool xe6_29_prePostParticles : 1;
bool xe6_30_enablePitchBend : 1; bool xe6_30_enablePitchBend : 1;
u8 xe6_31_targetableVisorFlags : 4; u8 xe6_31_targetableVisorFlags : 4;

View File

@ -16,7 +16,7 @@ CExplosion::CExplosion(const TLockedToken<CGenDescription>& particle, TUniqueId
xf4_24_ = flags & 0x4; xf4_24_ = flags & 0x4;
xf4_25_ = true; xf4_25_ = true;
xf4_26_ = flags & 0x8; xf4_26_ = flags & 0x8;
xe6_27_renderVisorFlags = flags & 0x1 ? 1 : 2; xe6_27_thermalVisorFlags = flags & 0x1 ? 1 : 2;
xe8_particleGen->SetGlobalTranslation(xf.origin); xe8_particleGen->SetGlobalTranslation(xf.origin);
xe8_particleGen->SetOrientation(xf.getRotation()); xe8_particleGen->SetOrientation(xf.getRotation());
xe8_particleGen->SetGlobalScale(scale); xe8_particleGen->SetGlobalScale(scale);

View File

@ -75,11 +75,11 @@ zeus::CAABox CPhysicsActor::GetMotionVolume(float dt) const
float up = GetStepUpHeight(); float up = GetStepUpHeight();
up = zeus::max(up, 0.f); up = zeus::max(up, 0.f);
aabox.accumulateBounds(aabox.max + up); aabox.accumulateBounds(aabox.max + zeus::CVector3f(0.5f, 0.5f, up + 1.f));
float down = GetStepDownHeight(); float down = GetStepDownHeight();
down = zeus::max(down, 0.f); down = zeus::max(down, 0.f);
aabox.accumulateBounds(aabox.min + down); aabox.accumulateBounds(aabox.min - zeus::CVector3f(0.5f, 0.5f, down + 1.5f));
return aabox; return aabox;
} }
@ -194,7 +194,7 @@ void CPhysicsActor::MoveToOR(const zeus::CVector3f& trans, float d)
ComputeDerivedQuantities(); ComputeDerivedQuantities();
} }
void CPhysicsActor::sub_8011B098(const zeus::CVector3f& trans, float d) void CPhysicsActor::MoveToInOneFrameWR(const zeus::CVector3f& trans, float d)
{ {
x18c_moveImpulse += xe8_mass * (trans - x34_transform.origin) * (1.f / d); x18c_moveImpulse += xe8_mass * (trans - x34_transform.origin) * (1.f / d);
} }

View File

@ -170,7 +170,7 @@ public:
void MoveInOneFrameOR(const zeus::CVector3f& trans, float d); void MoveInOneFrameOR(const zeus::CVector3f& trans, float d);
void RotateToOR(const zeus::CQuaternion& q, float d); void RotateToOR(const zeus::CQuaternion& q, float d);
void MoveToOR(const zeus::CVector3f& trans, float d); void MoveToOR(const zeus::CVector3f& trans, float d);
void sub_8011B098(const zeus::CVector3f& v1, float d); void MoveToInOneFrameWR(const zeus::CVector3f& v1, float d);
void MoveToWR(const zeus::CVector3f& trans, float d); void MoveToWR(const zeus::CVector3f& trans, float d);
zeus::CAxisAngle GetRotateToORAngularMomentumWR(const zeus::CQuaternion& q, float d) const; zeus::CAxisAngle GetRotateToORAngularMomentumWR(const zeus::CQuaternion& q, float d) const;
zeus::CVector3f GetMoveToORImpulseWR(const zeus::CVector3f& trans, float d) const; zeus::CVector3f GetMoveToORImpulseWR(const zeus::CVector3f& trans, float d) const;

View File

@ -14,24 +14,25 @@ namespace urde
CScriptActor::CScriptActor(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf, CScriptActor::CScriptActor(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
CModelData&& mData, const zeus::CAABox& aabb, float mass, float zMomentum, CModelData&& mData, const zeus::CAABox& aabb, float mass, float zMomentum,
const CMaterialList& matList, const CHealthInfo& hInfo, const CDamageVulnerability& dVuln, const CMaterialList& matList, const CHealthInfo& hInfo, const CDamageVulnerability& dVuln,
const CActorParameters& actParms, bool looping, bool active, u32 w1, float f3, bool b2, const CActorParameters& actParms, bool looping, bool active, u32 shaderIdx, float xrayAlpha,
bool castsShadow, bool b4, bool b5) bool noThermalHotZ, bool castsShadow, bool scaleAdvancementDelta, bool materialFlag54)
: CPhysicsActor(uid, active, name, info, xf, std::move(mData), matList, aabb, SMoverData(mass), actParms, 0.3f, 0.1f) : CPhysicsActor(uid, active, name, info, xf, std::move(mData), matList, aabb, SMoverData(mass), actParms, 0.3f, 0.1f)
, x258_initialHealth(hInfo) , x258_initialHealth(hInfo)
, x260_currentHealth(hInfo) , x260_currentHealth(hInfo)
, x268_damageVulnerability(dVuln) , x268_damageVulnerability(dVuln)
, x2d8_(w1) , x2d8_shaderIdx(shaderIdx)
, x2dc_xrayAlpha(f3) , x2dc_xrayAlpha(xrayAlpha)
, x2e2_24_(b2)
, x2e2_25_dead(false)
, x2e2_26_animating(true)
, x2e2_27_(std::fabs(1.f - f3) > 0.00001)
, x2e2_28_(false)
, x2e2_29_((x2e2_24_ && x2e2_25_dead && x2d8_ != 0))
, x2e2_30_transposeRotate(b4)
, x2e2_31_(b5)
, x2e3_24_cameraMoveIntoAlpha(false)
{ {
x2e2_24_noThermalHotZ = noThermalHotZ;
x2e2_25_dead = false;
x2e2_26_animating = true;
x2e2_27_xrayAlphaEnabled = !zeus::close_enough(1.f, xrayAlpha);
x2e2_28_inXrayAlpha = false;
x2e2_29_processModelFlags = (x2e2_27_xrayAlphaEnabled || x2e2_24_noThermalHotZ || x2d8_shaderIdx != 0);
x2e2_30_scaleAdvancementDelta = scaleAdvancementDelta;
x2e2_31_materialFlag54 = materialFlag54;
x2e3_24_cameraMoveIntoAlpha = false;
if (x64_modelData && (x64_modelData->HasAnimData() || x64_modelData->HasNormalModel()) && castsShadow) if (x64_modelData && (x64_modelData->HasAnimData() || x64_modelData->HasNormalModel()) && castsShadow)
CreateShadow(true); CreateShadow(true);
@ -77,7 +78,7 @@ void CScriptActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSta
} }
} }
if (x2e2_31_) if (x2e2_31_materialFlag54)
CActor::AddMaterial(EMaterialTypes::Unknown54, mgr); CActor::AddMaterial(EMaterialTypes::Unknown54, mgr);
} }
@ -100,7 +101,7 @@ void CScriptActor::Think(float dt, CStateManager& mgr)
{ {
x2e2_26_animating = true; x2e2_26_animating = true;
if (x2e2_30_transposeRotate) if (x2e2_30_scaleAdvancementDelta)
MoveToOR( MoveToOR(
x34_transform.rotate(x64_modelData->GetScale() * x34_transform.transposeRotate(deltas.x0_posDelta)), x34_transform.rotate(x64_modelData->GetScale() * x34_transform.transposeRotate(deltas.x0_posDelta)),
dt); dt);
@ -131,42 +132,35 @@ void CScriptActor::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum)
if (xe4_30_outOfFrustum && TCastToPtr<CCinematicCamera>(mgr.GetCameraManager()->GetCurrentCamera(mgr))) if (xe4_30_outOfFrustum && TCastToPtr<CCinematicCamera>(mgr.GetCameraManager()->GetCurrentCamera(mgr)))
xe4_30_outOfFrustum = false; xe4_30_outOfFrustum = false;
if (xe4_30_outOfFrustum && !x2e2_29_ && !x2e2_27_) if (!xe4_30_outOfFrustum && x2e2_29_processModelFlags)
{ {
zeus::CColor col(1.f, 1.f, x2dc_xrayAlpha); if (x2e2_27_xrayAlphaEnabled)
if (mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::XRay)
{ {
xb4_drawFlags.x0_blendMode = 5; zeus::CColor col(1.f, x2dc_xrayAlpha);
xb4_drawFlags.x1_matSetIdx = 0; CModelFlags xrayFlags(5, 0, 3, col);
xb4_drawFlags.x2_flags = 3; if (mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::XRay)
xb4_drawFlags.x4_color = col;
x2e2_28_ = true;
}
else if (x2e2_28_)
{
x2e2_28_ = false;
if (xb4_drawFlags.x0_blendMode != 5 && xb4_drawFlags.x1_matSetIdx != 0 &&
xb4_drawFlags.x2_flags != 3 && xb4_drawFlags.x4_color != col)
{ {
xb4_drawFlags.x0_blendMode = 5; xb4_drawFlags = xrayFlags;
xb4_drawFlags.x1_matSetIdx = 0; x2e2_28_inXrayAlpha = true;
xb4_drawFlags.x2_flags = 3; }
xb4_drawFlags.x4_color = col; else if (x2e2_28_inXrayAlpha)
{
x2e2_28_inXrayAlpha = false;
if (xb4_drawFlags == xrayFlags)
xb4_drawFlags = CModelFlags(0, 0, 3, zeus::CColor::skWhite);
} }
} }
if (!x2e2_24_ && xe6_27_renderVisorFlags == 2 && if (x2e2_24_noThermalHotZ && xe6_27_thermalVisorFlags == 2)
mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::XRay)
{ {
xb4_drawFlags.x2_flags &= ~3; if (mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::Thermal)
} xb4_drawFlags.x2_flags &= ~3; // Disable Z test/update
else else
{ xb4_drawFlags.x2_flags |= 3; // Enable Z test/update
xb4_drawFlags.x2_flags |= 3;
} }
if (x2d8_ != 0) if (x2d8_shaderIdx != 0)
xb4_drawFlags.x1_matSetIdx = 0; xb4_drawFlags.x1_matSetIdx = u8(x2d8_shaderIdx);
} }
if (mgr.GetObjectById(x2e0_triggerId) == nullptr) if (mgr.GetObjectById(x2e0_triggerId) == nullptr)
@ -187,7 +181,7 @@ zeus::CAABox CScriptActor::GetSortingBounds(const CStateManager& mgr) const
EWeaponCollisionResponseTypes EWeaponCollisionResponseTypes
CScriptActor::GetCollisionResponseType(const zeus::CVector3f& v1, const zeus::CVector3f& v2, const CScriptActor::GetCollisionResponseType(const zeus::CVector3f& v1, const zeus::CVector3f& v2, const
CWeaponMode& wMode, int w) const CWeaponMode& wMode, int w) const
{ {
const CDamageVulnerability* dVuln = GetDamageVulnerability(); const CDamageVulnerability* dVuln = GetDamageVulnerability();
if (dVuln->GetVulnerability(wMode, false) == EVulnerability::Reflect) if (dVuln->GetVulnerability(wMode, false) == EVulnerability::Reflect)
@ -206,5 +200,8 @@ rstl::optional_object<zeus::CAABox> CScriptActor::GetTouchBounds() const
return {}; return {};
} }
void CScriptActor::Touch(CActor&, CStateManager&) {} void CScriptActor::Touch(CActor&, CStateManager&)
{
// Empty
}
} }

View File

@ -16,23 +16,25 @@ protected:
CDamageVulnerability x268_damageVulnerability; CDamageVulnerability x268_damageVulnerability;
float x2d0_alphaMax; float x2d0_alphaMax;
float x2d4_alphaMin; float x2d4_alphaMin;
s32 x2d8_; s32 x2d8_shaderIdx;
float x2dc_xrayAlpha; float x2dc_xrayAlpha;
TUniqueId x2e0_triggerId = kInvalidUniqueId; TUniqueId x2e0_triggerId = kInvalidUniqueId;
bool x2e2_24_ : 1; bool x2e2_24_noThermalHotZ : 1;
bool x2e2_25_dead : 1; bool x2e2_25_dead : 1;
bool x2e2_26_animating : 1; bool x2e2_26_animating : 1;
bool x2e2_27_ : 1; bool x2e2_27_xrayAlphaEnabled : 1;
bool x2e2_28_ : 1; bool x2e2_28_inXrayAlpha : 1;
bool x2e2_29_ : 1; bool x2e2_29_processModelFlags : 1;
bool x2e2_30_transposeRotate : 1; bool x2e2_30_scaleAdvancementDelta : 1;
bool x2e2_31_ : 1; bool x2e2_31_materialFlag54 : 1;
bool x2e3_24_cameraMoveIntoAlpha : 1; bool x2e3_24_cameraMoveIntoAlpha : 1;
public: public:
CScriptActor(TUniqueId, std::string_view, const CEntityInfo&, const zeus::CTransform&, CModelData&&, CScriptActor(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
const zeus::CAABox& aabb, float, float, const CMaterialList& matList, const CHealthInfo&, CModelData&& mData, const zeus::CAABox& aabb, float mass, float zMomentum,
const CDamageVulnerability&, const CActorParameters&, bool, bool, u32, float, bool, bool, bool, bool); const CMaterialList& matList, const CHealthInfo& hInfo, const CDamageVulnerability& dVuln,
const CActorParameters& actParms, bool looping, bool active, u32 shaderIdx, float xrayAlpha,
bool noThermalHotZ, bool castsShadow, bool scaleAdvancementDelta, bool materialFlag54);
void Accept(IVisitor& visitor); void Accept(IVisitor& visitor);
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&); void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
void Think(float, CStateManager&); void Think(float, CStateManager&);

View File

@ -16,7 +16,7 @@ CScriptVisorFlare::CScriptVisorFlare(TUniqueId uid, std::string_view name, const
CMaterialList(EMaterialTypes::NoStepLogic), CActorParameters::None(), kInvalidUniqueId), CMaterialList(EMaterialTypes::NoStepLogic), CActorParameters::None(), kInvalidUniqueId),
xe8_flare(blendMode, b1, f1, f2, f3, w1, w2, flares) xe8_flare(blendMode, b1, f1, f2, f3, w1, w2, flares)
{ {
xe6_27_renderVisorFlags = 2; xe6_27_thermalVisorFlags = 2;
} }
void CScriptVisorFlare::Accept(IVisitor& visitor) void CScriptVisorFlare::Accept(IVisitor& visitor)

View File

@ -88,7 +88,7 @@ CScriptWater::CScriptWater(CStateManager& mgr, TUniqueId uid, std::string_view n
x90_actorLights->SetFindNearestDynamicLights(true); x90_actorLights->SetFindNearestDynamicLights(true);
x148_24_detectCamera = true; x148_24_detectCamera = true;
CalculateRenderBounds(); CalculateRenderBounds();
xe6_27_renderVisorFlags = u8(thermalCold ? 2 : 1); xe6_27_thermalVisorFlags = u8(thermalCold ? 2 : 1);
if (!x30_24_active) if (!x30_24_active)
{ {
x2bc_alpha = 0.f; x2bc_alpha = 0.f;

View File

@ -397,12 +397,12 @@ CEntity* ScriptLoader::LoadActor(CStateManager& mgr, CInputStream& in, int propC
bool solid = in.readBool(); bool solid = in.readBool();
bool cameraPassthrough = in.readBool(); bool cameraPassthrough = in.readBool();
bool active = in.readBool(); bool active = in.readBool();
u32 w2 = in.readUint32Big(); u32 shaderIdx = in.readUint32Big();
float f3 = in.readFloatBig(); float xrayAlpha = in.readFloatBig();
bool b6 = in.readBool(); bool noThermalHotZ = in.readBool();
bool castsShadow = in.readBool(); bool castsShadow = in.readBool();
bool xposeRotate = in.readBool(); bool scaleAdvancementDelta = in.readBool();
bool b9 = in.readBool(); bool materialFlag54 = in.readBool();
FourCC animType = g_ResFactory->GetResourceTypeById(aParms.GetACSFile()); FourCC animType = g_ResFactory->GetResourceTypeById(aParms.GetACSFile());
if (!g_ResFactory->GetResourceTypeById(staticId) && !animType) if (!g_ResFactory->GetResourceTypeById(staticId) && !animType)
@ -430,8 +430,8 @@ CEntity* ScriptLoader::LoadActor(CStateManager& mgr, CInputStream& in, int propC
aabb = data.GetBounds(head.x10_transform.getRotation()); aabb = data.GetBounds(head.x10_transform.getRotation());
return new CScriptActor(mgr.AllocateUniqueId(), head.x0_name, info, head.x10_transform, std::move(data), aabb, mass, return new CScriptActor(mgr.AllocateUniqueId(), head.x0_name, info, head.x10_transform, std::move(data), aabb, mass,
zMomentum, list, hInfo, dVuln, actParms, looping, active, w2, f3, b6, castsShadow, zMomentum, list, hInfo, dVuln, actParms, looping, active, shaderIdx, xrayAlpha,
xposeRotate, b9); noThermalHotZ, castsShadow, scaleAdvancementDelta, materialFlag54);
} }
CEntity* ScriptLoader::LoadWaypoint(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) CEntity* ScriptLoader::LoadWaypoint(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)