Improve match for CScriptSpecialFunction::Render

This commit is contained in:
Henrique Gemignani Passos Lima 2022-10-03 16:15:34 +03:00
parent 3256933c63
commit 80843df748
No known key found for this signature in database
GPG Key ID: E224F951761145F8
6 changed files with 42 additions and 22 deletions

View File

@ -16,7 +16,7 @@ lbl_803E2B68:
.4byte SetActive__6CActorFb .4byte SetActive__6CActorFb
.4byte PreRender__22CScriptSpecialFunctionFR13CStateManagerRC14CFrustumPlanes .4byte PreRender__22CScriptSpecialFunctionFR13CStateManagerRC14CFrustumPlanes
.4byte AddToRenderer__22CScriptSpecialFunctionFRC14CFrustumPlanesR13CStateManager .4byte AddToRenderer__22CScriptSpecialFunctionFRC14CFrustumPlanesR13CStateManager
.4byte Render__22CScriptSpecialFunctionCFRC13CStateManager .4byte Render__22CScriptSpecialFunctionFR13CStateManager
.4byte CanRenderUnsorted__6CActorCFRC13CStateManager .4byte CanRenderUnsorted__6CActorCFRC13CStateManager
.4byte CalculateRenderBounds__6CActorFv .4byte CalculateRenderBounds__6CActorFv
.4byte HealthInfo__6CActorFR13CStateManager .4byte HealthInfo__6CActorFR13CStateManager
@ -958,8 +958,8 @@ lbl_8014FC98:
/* 8014FCB4 0014CC14 38 21 08 B0 */ addi r1, r1, 0x8b0 /* 8014FCB4 0014CC14 38 21 08 B0 */ addi r1, r1, 0x8b0
/* 8014FCB8 0014CC18 4E 80 00 20 */ blr /* 8014FCB8 0014CC18 4E 80 00 20 */ blr
.global Render__22CScriptSpecialFunctionCFRC13CStateManager .global Render__22CScriptSpecialFunctionFR13CStateManager
Render__22CScriptSpecialFunctionCFRC13CStateManager: Render__22CScriptSpecialFunctionFR13CStateManager:
/* 8014FCBC 0014CC1C 94 21 FE A0 */ stwu r1, -0x160(r1) /* 8014FCBC 0014CC1C 94 21 FE A0 */ stwu r1, -0x160(r1)
/* 8014FCC0 0014CC20 7C 08 02 A6 */ mflr r0 /* 8014FCC0 0014CC20 7C 08 02 A6 */ mflr r0
/* 8014FCC4 0014CC24 90 01 01 64 */ stw r0, 0x164(r1) /* 8014FCC4 0014CC24 90 01 01 64 */ stw r0, 0x164(r1)

View File

@ -67,6 +67,13 @@ public:
CVector3f ClampToBox(const CVector3f& vec) const; CVector3f ClampToBox(const CVector3f& vec) const;
CAABox GetTransformedAABox(const CTransform4f& xf) const; CAABox GetTransformedAABox(const CTransform4f& xf) const;
inline CVector3f GetExtents() const {
// Name is a guess
CVector3f result = max - min;
result *= 0.5f;
return result;
}
const CVector3f& GetMinPoint() const { return min; } const CVector3f& GetMinPoint() const { return min; }
const CVector3f& GetMaxPoint() const { return max; } const CVector3f& GetMaxPoint() const { return max; }

View File

@ -70,7 +70,7 @@ public:
// RotateZ__12CTransform4fFRC9CRelAngle // RotateZ__12CTransform4fFRC9CRelAngle
// Scale__12CTransform4fFf // Scale__12CTransform4fFf
// Scale__12CTransform4fFfff // Scale__12CTransform4fFfff
// Scale__12CTransform4fFRC9CVector3f static CTransform4f Scale(const CVector3f&);
// ScaleBy__12CTransform4fFf // ScaleBy__12CTransform4fFf
// SetRotation__12CTransform4fFRC12CTransform4f // SetRotation__12CTransform4fFRC12CTransform4f
// SetRotation__12CTransform4fFRC9CMatrix3f // SetRotation__12CTransform4fFRC9CMatrix3f

View File

@ -71,7 +71,7 @@ public:
virtual void DrawModelFlat(); virtual void DrawModelFlat();
virtual void SetWireframeFlags(); virtual void SetWireframeFlags();
virtual void SetWorldFog(); virtual void SetWorldFog();
virtual void RenderFogVolume(); virtual void RenderFogVolume(const CColor&, const CAABox&, const TLockedToken<CModel>*, const CSkinnedModel*);
virtual void SetThermal(); virtual void SetThermal();
virtual void SetThermalColdScale(); virtual void SetThermalColdScale();
virtual void DoThermalBlendCold(); virtual void DoThermalBlendCold();

View File

@ -147,6 +147,7 @@ public:
xef4_pendingScreenTex.xc_extent = extent; xef4_pendingScreenTex.xc_extent = extent;
} }
const SOnScreenTex& GetPendingScreenTex() const { return xef4_pendingScreenTex; } const SOnScreenTex& GetPendingScreenTex() const { return xef4_pendingScreenTex; }
float IntegrateVisorFog(float f);
void SetShouldQuitGame(bool should) { xf94_25_quitGame = should; } void SetShouldQuitGame(bool should) { xf94_25_quitGame = should; }
void SetSkipCinematicSpecialFunction(TUniqueId id) { xf38_skipCineSpecialFunc = id; } void SetSkipCinematicSpecialFunction(TUniqueId id) { xf38_skipCineSpecialFunc = id; }

View File

@ -13,10 +13,12 @@
#include "MetroidPrime/ScriptObjects/CScriptPlatform.hpp" #include "MetroidPrime/ScriptObjects/CScriptPlatform.hpp"
#include "MetroidPrime/TCastTo.hpp" #include "MetroidPrime/TCastTo.hpp"
#include "MetaRender/CCubeRenderer.hpp"
#include "Collision/CMaterialFilter.hpp" #include "Collision/CMaterialFilter.hpp"
#include "Kyoto/Audio/CSfxManager.hpp" #include "Kyoto/Audio/CSfxManager.hpp"
#include "Kyoto/Graphics/CGraphics.hpp"
#include "Kyoto/Math/CFrustumPlanes.hpp" #include "Kyoto/Math/CFrustumPlanes.hpp"
#include "Kyoto/Math/CMath.hpp" #include "Kyoto/Math/CMath.hpp"
#include "Kyoto/Math/CRelAngle.hpp" #include "Kyoto/Math/CRelAngle.hpp"
@ -27,14 +29,12 @@
#include "Runtime/w_fmod.h" #include "Runtime/w_fmod.h"
#include "rstl/math.hpp" #include "rstl/math.hpp"
namespace rstl { namespace rstl {
static int string_find(const string& haystack, const string& needle, int) { static int string_find(const string& haystack, const string& needle, int) {
// TODO: proper implementation // TODO: proper implementation
return 0; return 0;
} }
} } // namespace rstl
CScriptSpecialFunction::CScriptSpecialFunction( CScriptSpecialFunction::CScriptSpecialFunction(
TUniqueId uid, const rstl::string& name, const CEntityInfo& info, const CTransform4f& xf, TUniqueId uid, const rstl::string& name, const CEntityInfo& info, const CTransform4f& xf,
@ -847,7 +847,8 @@ void CScriptSpecialFunction::ThinkSpinnerController(float dt, CStateManager& mgr
animData->SetPlaybackRate(1.f); animData->SetPlaybackRate(1.f);
// Redundant copy is needed // Redundant copy is needed
SAdvancementDeltas deltas = plat->UpdateAnimation(dur, mgr, true); SAdvancementDeltas deltas = plat->UpdateAnimation(dur, mgr, true);
plat->SetTransform(x13c_spinnerInitialXf * deltas.xc_rotDelta.BuildTransform4f(deltas.x0_posDelta)); plat->SetTransform(x13c_spinnerInitialXf *
deltas.xc_rotDelta.BuildTransform4f(deltas.x0_posDelta));
} }
} }
} }
@ -926,17 +927,28 @@ void CScriptSpecialFunction::ThinkObjectFollowObject(float, CStateManager& mgr)
void CScriptSpecialFunction::Render(CStateManager& mgr) { void CScriptSpecialFunction::Render(CStateManager& mgr) {
if (xe8_function == kSF_FogVolume) { if (xe8_function == kSF_FogVolume) {
/* TODO if (GetActive()) {
const float z = mgr.IntegrateVisorFog(xfc_float1 * std::sin(CGraphics::GetSecondsMod900())); const float z = mgr.IntegrateVisorFog(
xfc_float1 * CMath::FastSinR(CGraphics::GetSecondsMod900() * x100_float2));
if (z > 0.f) { if (z > 0.f) {
CVector3f max = GetTranslation() + x10c_vector3f; CVector3f translation = GetTranslation();
max.SetZ(max.GetZ() + z); CVector3f min(translation - x10c_vector3f);
const CAABox box(GetTranslation() - x10c_vector3f, max); CVector3f max(translation.GetX() + x10c_vector3f.GetX(),
const CTransform4f modelMtx = CTransform4f::Translate(box.center()) * translation.GetY() + x10c_vector3f.GetY(), 0.0);
CTransform4f::Scale(box.extents()); g_Renderer->SetModelMatrix(modelMtx); max.SetZ(translation.GetZ() + x10c_vector3f.GetZ() + z);
g_Renderer->RenderFogVolume(x118_color, zeus::CAABox(-1.f, 1.f), nullptr, nullptr); CAABox box(min, max);
CVector3f extents(box.GetExtents());
CTransform4f modelMtx =
CTransform4f::Translate(box.GetCenterPoint()) * CTransform4f::Scale(extents);
CVector3f renderMin(-1.f, -1.f, -1.f);
CVector3f renderMax(1.f, 1.f, 1.f);
CAABox renderbox(renderMin, renderMax);
gpRender->SetModelMatrix(modelMtx);
gpRender->RenderFogVolume(x118_color, renderbox, nullptr, nullptr);
}
} }
*/
} else { } else {
CActor::Render(mgr); CActor::Render(mgr);
} }