Add CScriptRipple

Former-commit-id: 44282da01f
This commit is contained in:
Henrique Gemignani Passos Lima 2022-10-16 17:41:14 +03:00
parent b4897e53be
commit 72ddd3ca89
7 changed files with 139 additions and 10 deletions

View File

@ -21201,7 +21201,7 @@ lbl_800D8610:
/* 800D8688 000D55E8 38 81 00 0C */ addi r4, r1, 0xc
/* 800D868C 000D55EC 38 A1 00 1C */ addi r5, r1, 0x1c
/* 800D8690 000D55F0 38 E1 00 10 */ addi r7, r1, 0x10
/* 800D8694 000D55F4 48 09 CA 65 */ bl "__ct__13CScriptRippleF9TUniqueIdRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>RC11CEntityInfoRC9CVector3fbffff"
/* 800D8694 000D55F4 48 09 CA 65 */ bl "__ct__13CScriptRippleF9TUniqueIdRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>RC11CEntityInfoRC9CVector3fbf"
/* 800D8698 000D55F8 7C 7E 1B 78 */ mr r30, r3
lbl_800D869C:
/* 800D869C 000D55FC 38 61 00 1C */ addi r3, r1, 0x1c

View File

@ -3,8 +3,8 @@
.section .data
.balign 8
.global lbl_803E3E28
lbl_803E3E28:
.global __vt__13CScriptRipple
__vt__13CScriptRipple:
# ROM: 0x3E0E28
.4byte 0
.4byte 0
@ -141,9 +141,9 @@ __dt__13CScriptRippleFv:
/* 801750AC 0017200C 93 C1 00 08 */ stw r30, 8(r1)
/* 801750B0 00172010 7C 7E 1B 79 */ or. r30, r3, r3
/* 801750B4 00172014 41 82 00 28 */ beq lbl_801750DC
/* 801750B8 00172018 3C A0 80 3E */ lis r5, lbl_803E3E28@ha
/* 801750B8 00172018 3C A0 80 3E */ lis r5, __vt__13CScriptRipple@ha
/* 801750BC 0017201C 38 80 00 00 */ li r4, 0
/* 801750C0 00172020 38 05 3E 28 */ addi r0, r5, lbl_803E3E28@l
/* 801750C0 00172020 38 05 3E 28 */ addi r0, r5, __vt__13CScriptRipple@l
/* 801750C4 00172024 90 1E 00 00 */ stw r0, 0(r30)
/* 801750C8 00172028 4B ED C1 AD */ bl __dt__7CEntityFv
/* 801750CC 0017202C 7F E0 07 35 */ extsh. r0, r31
@ -159,8 +159,8 @@ lbl_801750DC:
/* 801750F0 00172050 38 21 00 10 */ addi r1, r1, 0x10
/* 801750F4 00172054 4E 80 00 20 */ blr
.global "__ct__13CScriptRippleF9TUniqueIdRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>RC11CEntityInfoRC9CVector3fbffff"
"__ct__13CScriptRippleF9TUniqueIdRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>RC11CEntityInfoRC9CVector3fbffff":
.global "__ct__13CScriptRippleF9TUniqueIdRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>RC11CEntityInfoRC9CVector3fbf"
"__ct__13CScriptRippleF9TUniqueIdRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>RC11CEntityInfoRC9CVector3fbf":
/* 801750F8 00172058 94 21 FF D0 */ stwu r1, -0x30(r1)
/* 801750FC 0017205C 7C 08 02 A6 */ mflr r0
/* 80175100 00172060 90 01 00 34 */ stw r0, 0x34(r1)
@ -180,8 +180,8 @@ lbl_801750DC:
/* 80175138 00172098 38 81 00 08 */ addi r4, r1, 8
/* 8017513C 0017209C 4B ED C1 E9 */ bl "__ct__7CEntityF9TUniqueIdRC11CEntityInfobRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>"
/* 80175140 001720A0 C0 02 A1 70 */ lfs f0, lbl_805ABE90@sda21(r2)
/* 80175144 001720A4 3C 60 80 3E */ lis r3, lbl_803E3E28@ha
/* 80175148 001720A8 38 03 3E 28 */ addi r0, r3, lbl_803E3E28@l
/* 80175144 001720A4 3C 60 80 3E */ lis r3, __vt__13CScriptRipple@ha
/* 80175148 001720A8 38 03 3E 28 */ addi r0, r3, __vt__13CScriptRipple@l
/* 8017514C 001720AC FC 1F 00 40 */ fcmpo cr0, f31, f0
/* 80175150 001720B0 90 1E 00 00 */ stw r0, 0(r30)
/* 80175154 001720B4 4C 41 13 82 */ cror 2, 1, 2
@ -215,4 +215,3 @@ lbl_805ABE90:
# ROM: 0x3F8730
.4byte 0
.4byte 0

View File

@ -0,0 +1,36 @@
#ifndef _CFLUIDPLANE
#define _CFLUIDPLANE
#include "MetroidPrime/TGameTypes.hpp"
#include "Kyoto/Math/CVector3f.hpp"
class CScriptWater;
class CStateManager;
class CFluidPlaneCPURender {
public:
struct SPatchInfo {};
struct SRippleInfo {};
struct SHFieldSample {};
};
class CFluidPlane {
public:
virtual ~CFluidPlane();
virtual void AddRipple(float mag, TUniqueId rippler, const CVector3f& center, CScriptWater& water,
CStateManager& mgr);
virtual void AddRipple(float intensity, TUniqueId rippler, const CVector3f& center,
const CVector3f& velocity, const CScriptWater& water, CStateManager& mgr,
const CVector3f& upVec);
protected:
virtual void RenderStripWithRipples(const CFluidPlaneCPURender::SHFieldSample& heights,
const unsigned char& flags, float curY, int startYDiv,
const CFluidPlaneCPURender::SPatchInfo& info);
};
#endif // _CFLUIDPLANE

View File

@ -0,0 +1,11 @@
#ifndef _CFLUIDPLANECPU
#define _CFLUIDPLANECPU
#include "MetroidPrime/CFluidPlane.hpp"
class CFluidPlaneCPU : public CFluidPlane {
public:
};
#endif // _CFLUIDPLANECPU

View File

@ -0,0 +1,21 @@
#ifndef _CSCRIPTRIPPLE
#define _CSCRIPTRIPPLE
#include "MetroidPrime/CEntity.hpp"
#include "Kyoto/Math/CVector3f.hpp"
class CScriptRipple : public CEntity {
float x34_magnitude;
CVector3f x38_center;
public:
CScriptRipple(TUniqueId, const rstl::string&, const CEntityInfo&, const CVector3f&, bool, float);
~CScriptRipple();
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override;
void Think(float, CStateManager&) override;
void Accept(IVisitor&) override;
};
#endif // _CSCRIPTRIPPLE

View File

@ -0,0 +1,18 @@
#ifndef _CSCRIPTWATER
#define _CSCRIPTWATER
#include "types.h"
#include "rstl/single_ptr.hpp"
class CFluidPlaneCPU;
class CScriptWater {
uchar x0_pad[0x1b4];
rstl::single_ptr<CFluidPlaneCPU> x1b4_fluidPlane;
public:
CFluidPlaneCPU& FluidPlane() { return *x1b4_fluidPlane; }
};
#endif // _CSCRIPTWATER

View File

@ -0,0 +1,44 @@
#include "MetroidPrime/ScriptObjects/CScriptRipple.hpp"
#include "MetroidPrime/CFluidPlaneCPU.hpp"
#include "MetroidPrime/CStateManager.hpp"
#include "MetroidPrime/ScriptObjects/CScriptWater.hpp"
CScriptRipple::CScriptRipple(TUniqueId uid, const rstl::string& name, const CEntityInfo& info,
const CVector3f& vec, bool active, float f1)
: CEntity(uid, info, active, name), x34_magnitude(f1 >= 0.f ? f1 : 0.5f), x38_center(vec) {}
CScriptRipple::~CScriptRipple() {}
void CScriptRipple::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) {
switch (msg) {
case (kSM_Play):
if (!GetActive()) {
return;
}
rstl::vector< SConnection >::const_iterator conn = x20_conns.begin();
for (; conn != x20_conns.end(); ++conn) {
if (conn->x0_state != kSS_Active || conn->x4_msg != kSM_Next) {
continue;
}
const CStateManager::TIdListResult& search = mgr.GetIdListForScript(conn->x8_objId);
if (search.first != search.second) {
if (CScriptWater* water =
TCastToPtr< CScriptWater >(mgr.ObjectById(search.first->second))) {
water->FluidPlane().AddRipple(x34_magnitude, GetUniqueId(), x38_center, *water, mgr);
}
}
}
break;
default:
CEntity::AcceptScriptMsg(msg, uid, mgr);
break;
}
}
void CScriptRipple::Think(float, CStateManager&) override {}
void CScriptRipple::Accept(IVisitor& visitor) { visitor.Visit(*this); }