More CCubeRenderer

This commit is contained in:
Luke Street 2025-01-30 22:00:30 -07:00
parent d39bfb5d2c
commit 23c5d67207
28 changed files with 526 additions and 168 deletions

View File

@ -11959,20 +11959,20 @@ SetModelMatrix__13CCubeRendererFRC12CTransform4f = .text:0x802BDE74; // type:fun
RemoveStaticGeometry__13CCubeRendererFPCQ24rstl58vector<21CMetroidModelInstance,Q24rstl17rmemory_allocator> = .text:0x802BDE98; // type:function size:0x50 scope:global
FindStaticGeometry__13CCubeRendererFPCQ24rstl58vector<21CMetroidModelInstance,Q24rstl17rmemory_allocator> = .text:0x802BDEE8; // type:function size:0x34 scope:global
AddStaticGeometry__13CCubeRendererFPCQ24rstl58vector<21CMetroidModelInstance,Q24rstl17rmemory_allocator>PC12CAreaOctTreei = .text:0x802BDF1C; // type:function size:0x274 scope:global
fn_802BE190 = .text:0x802BE190; // type:function size:0x28
push_back__Q24rstl65list<Q213CCubeRenderer13CAreaListItem,Q24rstl17rmemory_allocator>FRCQ213CCubeRenderer13CAreaListItem = .text:0x802BE190; // type:function size:0x28
fn_802BE1B8 = .text:0x802BE1B8; // type:function size:0x70
fn_802BE228 = .text:0x802BE228; // type:function size:0x84
fn_802BE2AC = .text:0x802BE2AC; // type:function size:0x10C
fn_802BE3B8 = .text:0x802BE3B8; // type:function size:0xAC
__dt__Q213CCubeRenderer13CAreaListItemFv = .text:0x802BE3B8; // type:function size:0xAC
fn_802BE464 = .text:0x802BE464; // type:function size:0x64
fn_802BE4C8 = .text:0x802BE4C8; // type:function size:0xB4
fn_802BE57C = .text:0x802BE57C; // type:function size:0x64
fn_802BE5E0 = .text:0x802BE5E0; // type:function size:0xB8
__dt__13CCubeRendererFv = .text:0x802BE698; // type:function size:0x270 scope:global
fn_802BE908 = .text:0x802BE908; // type:function size:0x1D0
fn_802BEAD8 = .text:0x802BEAD8; // type:function size:0x17C
fn_802BEC54 = .text:0x802BEC54; // type:function size:0x1FC
fn_802BEE50 = .text:0x802BEE50; // type:function size:0x210
LoadThermoPalette__13CCubeRendererFv = .text:0x802BE908; // type:function size:0x1D0
GenerateSphereRampTex__13CCubeRendererFv = .text:0x802BEAD8; // type:function size:0x17C
GenerateFogVolumeRampTex__13CCubeRendererFv = .text:0x802BEC54; // type:function size:0x1FC
GenerateReflectionTex__13CCubeRendererFv = .text:0x802BEE50; // type:function size:0x210
__ct__13CCubeRendererFR12IObjectStoreR10COsContextR10CMemorySysR11CResFactory = .text:0x802BF060; // type:function size:0x304 scope:global
__ct__Q213CCubeRenderer13CAreaListItemFPCQ24rstl58vector<21CMetroidModelInstance,Q24rstl17rmemory_allocator>PC12CAreaOctTreeRCQ24rstl79auto_ptr<Q24rstl60vector<23TCachedToken<8CTexture>,Q24rstl17rmemory_allocator>>RCQ24rstl85auto_ptr<Q24rstl66vector<Q24rstl22auto_ptr<10CCubeModel>,Q24rstl17rmemory_allocator>>i = .text:0x802BF364; // type:function size:0x48 scope:global
Clear__7BucketsFv = .text:0x802BF3AC; // type:function size:0x1F8 scope:global
@ -11986,18 +11986,18 @@ Insert__7BucketsFRC9CVector3fRC6CAABox13EDrawableTypePCvRC6CPlaneUs = .text:0x80
Shutdown__7BucketsFv = .text:0x802BFE5C; // type:function size:0x18 scope:global
Init__7BucketsFv = .text:0x802BFE74; // type:function size:0x164 scope:global
__nw__27TOneStatic<13CCubeRenderer>FUlPCcPCc = .text:0x802BFFD8; // type:function size:0x30 scope:global
fn_802C0008 = .text:0x802C0008; // type:function size:0x2C
fn_802C0034 = .text:0x802C0034; // type:function size:0xC
fn_802C0040 = .text:0x802C0040; // type:function size:0x24
__dl__27TOneStatic<13CCubeRenderer>FPv = .text:0x802C0008; // type:function size:0x2C
GetAllocSpace__27TOneStatic<13CCubeRenderer>Fv = .text:0x802C0034; // type:function size:0xC
ReferenceCount__27TOneStatic<13CCubeRenderer>Fv = .text:0x802C0040; // type:function size:0x24
fn_802C0064 = .text:0x802C0064; // type:function size:0x144
fn_802C01A8 = .text:0x802C01A8; // type:function size:0x16C
fn_802C0314 = .text:0x802C0314; // type:function size:0x94
fn_802C03A8 = .text:0x802C03A8; // type:function size:0x94
do_erase__Q24rstl65list<Q213CCubeRenderer13CAreaListItem,Q24rstl17rmemory_allocator>FPQ34rstl65list<Q213CCubeRenderer13CAreaListItem,Q24rstl17rmemory_allocator>4node = .text:0x802C0314; // type:function size:0x94
__dt__Q24rstl65list<Q213CCubeRenderer13CAreaListItem,Q24rstl17rmemory_allocator>Fv = .text:0x802C03A8; // type:function size:0x94
fn_802C043C = .text:0x802C043C; // type:function size:0xCC
fn_802C0508 = .text:0x802C0508; // type:function size:0xAC
__dt__Q24rstl70list<Q213CCubeRenderer18CFogVolumeListItem,Q24rstl17rmemory_allocator>Fv = .text:0x802C0508; // type:function size:0xAC
fn_802C05B4 = .text:0x802C05B4; // type:function size:0x7C
fn_802C0630 = .text:0x802C0630; // type:function size:0x78
fn_802C06A8 = .text:0x802C06A8; // type:function size:0x108
__dt__Q24rstl60list<Q24rstl18pair<9CVector3f,f>,Q24rstl17rmemory_allocator>Fv = .text:0x802C0630; // type:function size:0x78
reserve__Q24rstl66vector<Q24rstl22auto_ptr<10CCubeModel>,Q24rstl17rmemory_allocator>Fi = .text:0x802C06A8; // type:function size:0x108
fn_802C07B0 = .text:0x802C07B0; // type:function size:0x7C
fn_802C082C = .text:0x802C082C; // type:function size:0x8C
fn_802C08B8 = .text:0x802C08B8; // type:function size:0xDC
@ -14823,7 +14823,7 @@ GetMemInfoFromBlockPtr__14CGameAllocatorCFPCv = .text:0x80352660; // type:functi
fn_80352668 = .text:0x80352668; // type:function size:0xA0
ClearPointGeneratorFunc__13CSkinnedModelFv = .text:0x80352708; // type:function size:0xC scope:global
SetPointGeneratorFunc__13CSkinnedModelFPvPFPvPC9CVector3fPC9CVector3fi_v = .text:0x80352714; // type:function size:0xC scope:global
fn_80352720 = .text:0x80352720; // type:function size:0x20
RemoveDummySkinnedModelRef__13CSkinnedModelFv = .text:0x80352720; // type:function size:0x20
fn_80352740 = .text:0x80352740; // type:function size:0x20
fn_80352760 = .text:0x80352760; // type:function size:0x10C
AllocateStorage__13CSkinnedModelFv = .text:0x8035286C; // type:function size:0x180 scope:global
@ -17730,7 +17730,7 @@ lbl_803D67B4 = .rodata:0x803D67B4; // type:object size:0x40 data:4byte
lbl_803D67F4 = .rodata:0x803D67F4; // type:object size:0x20 data:4byte
lbl_803D6814 = .rodata:0x803D6814; // type:object size:0x18 data:4byte
lbl_803D682C = .rodata:0x803D682C; // type:object size:0x30
lbl_803D685C = .rodata:0x803D685C; // type:object size:0x1C
@stringBase0 = .rodata:0x803D685C; // type:object size:0x1C scope:local data:string_table
lbl_803D6878 = .rodata:0x803D6878; // type:object size:0x8
lbl_803D6880 = .rodata:0x803D6880; // type:object size:0x8
lbl_803D6888 = .rodata:0x803D6888; // type:object size:0x8
@ -17940,7 +17940,7 @@ lbl_803D8D60 = .data:0x803D8D60; // type:object size:0xC
__vt__4IObj = .data:0x803D8D6C; // type:object size:0xC scope:global
__vt__31CObjOwnerDerivedFromIObjUntyped = .data:0x803D8D78; // type:object size:0xC scope:global
__vt__35TObjOwnerDerivedFromIObj<8CTexture> = .data:0x803D8D84; // type:object size:0xC scope:global
lbl_803D8D90 = .data:0x803D8D90; // type:object size:0x10C
__vt__9IRenderer = .data:0x803D8D90; // type:object size:0x10C
__vt__24IArchitectureMessageParm = .data:0x803D8E9C; // type:object size:0xC scope:global
__vt__22CCameraShakerComponent = .data:0x803D8EA8; // type:object size:0x10 scope:global
@28 = .data:0x803D8EB8; // type:object size:0xC scope:local data:4byte
@ -19240,7 +19240,7 @@ sBucketsHolder$4375 = .bss:0x80472A7C; // type:object size:0x64D0 scope:local da
sPlaneObjectDataHolder$4376 = .bss:0x80478F4C; // type:object size:0x208 scope:local data:4byte
sPlaneObjectBucketHolder$4377 = .bss:0x80479154; // type:object size:0x18 scope:local data:4byte
sOptimalPlane$6479 = .bss:0x8047916C; // type:object size:0xC scope:local align:4 data:float
sAllocSpace$9000 = .bss:0x80479178; // type:object size:0x320 scope:local
sAllocSpace$9000 = .bss:0x80479178; // type:object size:0x31C scope:local
normalTable = .bss:0x80479498; // type:object size:0x48 scope:local align:4 data:float
...bss.0 = .bss:0x804794E0; // type:label scope:local
@2493 = .bss:0x804794E0; // type:object size:0xC scope:local

View File

@ -11959,20 +11959,20 @@ SetModelMatrix__13CCubeRendererFRC12CTransform4f = .text:0x802BDF20; // type:fun
RemoveStaticGeometry__13CCubeRendererFPCQ24rstl58vector<21CMetroidModelInstance,Q24rstl17rmemory_allocator> = .text:0x802BDF44; // type:function size:0x50 scope:global
FindStaticGeometry__13CCubeRendererFPCQ24rstl58vector<21CMetroidModelInstance,Q24rstl17rmemory_allocator> = .text:0x802BDF94; // type:function size:0x34 scope:global
AddStaticGeometry__13CCubeRendererFPCQ24rstl58vector<21CMetroidModelInstance,Q24rstl17rmemory_allocator>PC12CAreaOctTreei = .text:0x802BDFC8; // type:function size:0x274 scope:global
fn_802BE190 = .text:0x802BE23C; // type:function size:0x28 scope:global
push_back__Q24rstl65list<Q213CCubeRenderer13CAreaListItem,Q24rstl17rmemory_allocator>FRCQ213CCubeRenderer13CAreaListItem = .text:0x802BE23C; // type:function size:0x28 scope:global
fn_802BE1B8 = .text:0x802BE264; // type:function size:0x70 scope:global
fn_802BE228 = .text:0x802BE2D4; // type:function size:0x84 scope:global
fn_802BE2AC = .text:0x802BE358; // type:function size:0x10C scope:global
fn_802BE3B8 = .text:0x802BE464; // type:function size:0xAC scope:global
__dt__Q213CCubeRenderer13CAreaListItemFv = .text:0x802BE464; // type:function size:0xAC scope:global
fn_802BE464 = .text:0x802BE510; // type:function size:0x64 scope:global
fn_802BE4C8 = .text:0x802BE574; // type:function size:0xB4 scope:global
fn_802BE57C = .text:0x802BE628; // type:function size:0x64 scope:global
fn_802BE5E0 = .text:0x802BE68C; // type:function size:0xB8 scope:global
__dt__13CCubeRendererFv = .text:0x802BE744; // type:function size:0x270 scope:global
fn_802BE908 = .text:0x802BE9B4; // type:function size:0x1D0 scope:global
fn_802BEAD8 = .text:0x802BEB84; // type:function size:0x17C scope:global
fn_802BEC54 = .text:0x802BED00; // type:function size:0x1FC scope:global
fn_802BEE50 = .text:0x802BEEFC; // type:function size:0x210 scope:global
LoadThermoPalette__13CCubeRendererFv = .text:0x802BE9B4; // type:function size:0x1D0 scope:global
GenerateSphereRampTex__13CCubeRendererFv = .text:0x802BEB84; // type:function size:0x17C scope:global
GenerateFogVolumeRampTex__13CCubeRendererFv = .text:0x802BED00; // type:function size:0x1FC scope:global
GenerateReflectionTex__13CCubeRendererFv = .text:0x802BEEFC; // type:function size:0x210 scope:global
__ct__13CCubeRendererFR12IObjectStoreR10COsContextR10CMemorySysR11CResFactory = .text:0x802BF10C; // type:function size:0x304 scope:global
__ct__Q213CCubeRenderer13CAreaListItemFPCQ24rstl58vector<21CMetroidModelInstance,Q24rstl17rmemory_allocator>PC12CAreaOctTreeRCQ24rstl79auto_ptr<Q24rstl60vector<23TCachedToken<8CTexture>,Q24rstl17rmemory_allocator>>RCQ24rstl85auto_ptr<Q24rstl66vector<Q24rstl22auto_ptr<10CCubeModel>,Q24rstl17rmemory_allocator>>i = .text:0x802BF410; // type:function size:0x48 scope:global
Clear__7BucketsFv = .text:0x802BF458; // type:function size:0x1F8 scope:global
@ -11986,18 +11986,18 @@ Insert__7BucketsFRC9CVector3fRC6CAABox13EDrawableTypePCvRC6CPlaneUs = .text:0x80
Shutdown__7BucketsFv = .text:0x802BFF08; // type:function size:0x18 scope:global
Init__7BucketsFv = .text:0x802BFF20; // type:function size:0x164 scope:global
__nw__27TOneStatic<13CCubeRenderer>FUlPCcPCc = .text:0x802C0084; // type:function size:0x30 scope:global
fn_802C0008 = .text:0x802C00B4; // type:function size:0x2C scope:global
fn_802C0034 = .text:0x802C00E0; // type:function size:0xC scope:global
fn_802C0040 = .text:0x802C00EC; // type:function size:0x24 scope:global
__dl__27TOneStatic<13CCubeRenderer>FPv = .text:0x802C00B4; // type:function size:0x2C scope:global
GetAllocSpace__27TOneStatic<13CCubeRenderer>Fv = .text:0x802C00E0; // type:function size:0xC scope:global
ReferenceCount__27TOneStatic<13CCubeRenderer>Fv = .text:0x802C00EC; // type:function size:0x24 scope:global
fn_802C0064 = .text:0x802C0110; // type:function size:0x144 scope:global
fn_802C01A8 = .text:0x802C0254; // type:function size:0x16C scope:global
fn_802C0314 = .text:0x802C03C0; // type:function size:0x94 scope:global
fn_802C03A8 = .text:0x802C0454; // type:function size:0x94 scope:global
do_erase__Q24rstl65list<Q213CCubeRenderer13CAreaListItem,Q24rstl17rmemory_allocator>FPQ34rstl65list<Q213CCubeRenderer13CAreaListItem,Q24rstl17rmemory_allocator>4node = .text:0x802C03C0; // type:function size:0x94 scope:global
__dt__Q24rstl65list<Q213CCubeRenderer13CAreaListItem,Q24rstl17rmemory_allocator>Fv = .text:0x802C0454; // type:function size:0x94 scope:global
fn_802C043C = .text:0x802C04E8; // type:function size:0xCC scope:global
fn_802C0508 = .text:0x802C05B4; // type:function size:0xAC scope:global
__dt__Q24rstl70list<Q213CCubeRenderer18CFogVolumeListItem,Q24rstl17rmemory_allocator>Fv = .text:0x802C05B4; // type:function size:0xAC scope:global
fn_802C05B4 = .text:0x802C0660; // type:function size:0x7C scope:global
fn_802C0630 = .text:0x802C06DC; // type:function size:0x78 scope:global
fn_802C06A8 = .text:0x802C0754; // type:function size:0x108 scope:global
__dt__Q24rstl60list<Q24rstl18pair<9CVector3f,f>,Q24rstl17rmemory_allocator>Fv = .text:0x802C06DC; // type:function size:0x78 scope:global
reserve__Q24rstl66vector<Q24rstl22auto_ptr<10CCubeModel>,Q24rstl17rmemory_allocator>Fi = .text:0x802C0754; // type:function size:0x108 scope:global
fn_802C07B0 = .text:0x802C085C; // type:function size:0x7C scope:global
fn_802C082C = .text:0x802C08D8; // type:function size:0x8C scope:global
fn_802C08B8 = .text:0x802C0964; // type:function size:0xDC scope:global
@ -14823,7 +14823,7 @@ GetMemInfoFromBlockPtr__14CGameAllocatorCFPCv = .text:0x80352764; // type:functi
fn_80352668 = .text:0x8035276C; // type:function size:0xA0 scope:global
ClearPointGeneratorFunc__13CSkinnedModelFv = .text:0x8035280C; // type:function size:0xC scope:global
SetPointGeneratorFunc__13CSkinnedModelFPvPFPvPC9CVector3fPC9CVector3fi_v = .text:0x80352818; // type:function size:0xC scope:global
fn_80352720 = .text:0x80352824; // type:function size:0x20 scope:global
RemoveDummySkinnedModelRef__13CSkinnedModelFv = .text:0x80352824; // type:function size:0x20 scope:global
fn_80352740 = .text:0x80352844; // type:function size:0x20 scope:global
fn_80352760 = .text:0x80352864; // type:function size:0x10C scope:global
AllocateStorage__13CSkinnedModelFv = .text:0x80352970; // type:function size:0x180 scope:global

View File

@ -15,12 +15,12 @@ class CSkinnedModel {
public:
virtual ~CSkinnedModel();
static void ClearPointGeneratorFunc();
TLockedToken< CModel >& Model() { return x4_model; }
const TLockedToken< CModel >& GetModel() const { return x4_model; }
static void SetPointGeneratorFunc(void*, void (*)(void*, const CVector3f*, const CVector3f*, int));
static void ClearPointGeneratorFunc();
static void RemoveDummySkinnedModelRef();
private:
TLockedToken< CModel > x4_model;

View File

@ -72,7 +72,7 @@ public:
rstl::vector<u8>& SaveBuffer() { return xf4_saveBuffer; }
inline CMemoryStreamOut BeginMemoryOut(uint sz) {
xf4_saveBuffer.resize(sz, '\x00');
xf4_saveBuffer.resize(sz);
return CMemoryStreamOut(xf4_saveBuffer.data(), sz);
}
};

View File

@ -12,14 +12,16 @@ class CCubeSurface;
class CCubeModel {
public:
CCubeModel(rstl::vector< CCubeSurface* >* surfaces, rstl::vector< TCachedToken< CTexture > >* textures,
void* materialData, void* positions, void* normals, void* vtxColors, void* floatUvs,
void* shortUvs, const CAABox& aabox, uint visorFlags, bool texturesLoaded, uint idx);
CCubeModel(rstl::vector< void* >* surfaces, rstl::vector< TCachedToken< CTexture > >* textures,
const void* materialData, const void* positions, const void* normals,
const void* vtxColors, const void* floatUvs, const void* shortUvs, const CAABox& aabox,
uchar visorFlags, bool texturesLoaded, uint idx);
static void SetRenderModelBlack(bool v);
static void DisableShadowMaps();
static void EnableShadowMaps(const CTexture*, const CTransform4f&, unsigned char, unsigned char);
static void SetDrawingOccluders(bool);
static void MakeTexturesFromMats(uchar* data, rstl::vector< TCachedToken< CTexture > >& textures,
static void MakeTexturesFromMats(const void* data,
rstl::vector< TCachedToken< CTexture > >& textures,
IObjectStore& store, bool cache);
};

View File

@ -17,7 +17,7 @@ enum EDrawableType {
class CDrawable {
public:
CDrawable(EDrawableType dtype, ushort extraSort, float planeDot, const CAABox& aabb, void* data)
CDrawable(ushort dtype, ushort extraSort, float planeDot, const CAABox& aabb, void* data)
: x0_type(dtype), x2_extraSort(extraSort), x4_data(data), x8_aabb(aabb), x20_viewDist(planeDot) {}
// CDrawable(const CDrawable& other)
// : x0_type(other.x0_type)

View File

@ -221,6 +221,7 @@ public:
bool x0_persp;
float x4_left;
float x8_right;
// TODO: I think top/bottom are flipped
float xc_top;
float x10_bottom;
float x14_near;

View File

@ -37,7 +37,7 @@ public:
private:
rstl::auto_ptr< uchar > x0_data;
uint x4_dataLen;
rstl::vector< CCubeSurface* > x8_surfaces;
rstl::vector< void* > x8_surfaces;
rstl::vector<SShader> x18_matSets;
rstl::single_ptr<CCubeModel> x28_modelInstance;
ushort x2c_currentMatxIdx;

View File

@ -16,8 +16,12 @@ public:
Normalize();
}
}
CUnitVector3f(
const CVector3f& vec);//: CVector3f(vec.IsNonZero() ? vec.AsNormalized() : Zero()) {}
CUnitVector3f(const CVector3f& vec, ENormalize normalize) : CVector3f(vec) {
if (normalize == kN_Yes) {
Normalize();
}
}
CUnitVector3f(const CVector3f& vec); // real? see CPlane::CPlane
// TODO
static CUnitVector3f Forward() {

View File

@ -20,7 +20,7 @@ template < typename T >
class TAverage : rstl::vector< T > {
public:
TAverage() {}
TAverage(int capacity, const T& value);
TAverage(int capacity, const T& value = T());
void AddValue(const T& value);
rstl::optional_object< T > GetAverage() const {

View File

@ -11,7 +11,6 @@
#include "Kyoto/CResFactory.hpp"
#include "Kyoto/Graphics/CColor.hpp"
#include "Kyoto/Graphics/CGraphicsPalette.hpp"
#include "Kyoto/Graphics/CLight.hpp"
#include "Kyoto/Graphics/CTexture.hpp"
#include "Kyoto/IObjectStore.hpp"
#include "Kyoto/Math/CAABox.hpp"
@ -20,6 +19,7 @@
#include "Kyoto/Math/CVector2f.hpp"
#include "Kyoto/Math/CVector3f.hpp"
#include "Kyoto/PVS/CPVSVisSet.hpp"
#include "Kyoto/TOneStatic.hpp"
#include "Kyoto/TToken.hpp"
#include "Kyoto/Text/CFont.hpp"
@ -38,29 +38,29 @@ class CCubeModel;
class CMetroidModelInstance;
class CModel;
class CSkinnedModel;
class CCubeSurface;
class CLight;
class CCubeRenderer : public IRenderer, public IWeaponRenderer {
class CCubeRenderer : public IRenderer, public IWeaponRenderer, public TOneStatic< CCubeRenderer > {
private:
class CAreaListItem {
CAreaListItem(
const rstl::vector< CMetroidModelInstance, rstl::rmemory_allocator >* geometry,
const CAreaOctTree* octTree,
const rstl::auto_ptr< rstl::vector< TCachedToken< CTexture >, rstl::rmemory_allocator > >&
textures,
const rstl::auto_ptr<
rstl::vector< rstl::auto_ptr< CCubeModel >, rstl::rmemory_allocator > >& models,
int areaIdx);
public:
CAreaListItem(const rstl::vector< CMetroidModelInstance >* geometry,
const CAreaOctTree* octTree,
const rstl::auto_ptr< rstl::vector< TCachedToken< CTexture > > >& textures,
const rstl::auto_ptr< rstl::vector< rstl::auto_ptr< CCubeModel > > >& models,
int areaIdx);
~CAreaListItem() {}
private:
const rstl::vector< CMetroidModelInstance, rstl::rmemory_allocator >* x0_geometry;
// private:
const rstl::vector< CMetroidModelInstance >* x0_geometry;
const CAreaOctTree* x4_octTree;
const rstl::auto_ptr< rstl::vector< TCachedToken< CTexture >, rstl::rmemory_allocator > >
x8_textures;
const rstl::auto_ptr< rstl::vector< rstl::auto_ptr< CCubeModel >, rstl::rmemory_allocator > >
xc_models;
const rstl::auto_ptr< rstl::vector< TCachedToken< CTexture > > > x8_textures;
const rstl::auto_ptr< rstl::vector< rstl::auto_ptr< CCubeModel > > > xc_models;
int x18_areaIdx;
rstl::vector< uint > x1c_lightOctreeWords;
};
class CFogVolumeListItem {
CTransform4f x0_xf;
CColor x30_color;
@ -72,11 +72,11 @@ private:
public:
CCubeRenderer(IObjectStore&, COsContext&, CMemorySys&, CResFactory&);
~CCubeRenderer() override;
// TODO types
void AddStaticGeometry() override;
void AddStaticGeometry(const rstl::vector< CMetroidModelInstance >* geometry,
const CAreaOctTree* octTree, int areaIdx) override;
void EnablePVS(const CPVSVisSet& set, int areaIdx) override;
void DisablePVS() override;
void RemoveStaticGeometry() override;
void RemoveStaticGeometry(const rstl::vector< CMetroidModelInstance >* geometry) override;
void DrawUnsortedGeometry(int areaIdx, int mask, int targetMask) override;
void DrawSortedGeometry(int areaIdx, int mask, int targetMask) override;
void DrawStaticGeometry(int areaIdx, int mask, int targetMask) override;
@ -88,10 +88,10 @@ public:
void AddPlaneObject() override;
void AddDrawable(const void* obj, const CVector3f& pos, const CAABox& bounds, int mode,
IRenderer::EDrawableSorting sorting) override;
void SetDrawableCallback(TDrawableCallback cb, void* ctx) override;
void SetWorldViewpoint() override;
void SetPerspective1(float, float, float, float, float) override;
void SetPerspective2() override;
void SetDrawableCallback(TDrawableCallback cb, const void* ctx) override;
void SetWorldViewpoint(const CTransform4f& xf) override;
void SetPerspective(float, float, float, float, float) override;
void SetPerspective(float, float, float, float) override;
rstl::pair< CVector2f, CVector2f > SetViewportOrtho(bool centered, float znear,
float zfar) override;
void SetClippingPlanes(const CFrustumPlanes&) override;
@ -105,10 +105,10 @@ public:
void SetBlendMode_InvertSrc() override;
void SetBlendMode_Replace() override;
void SetBlendMode_AdditiveDestColor() override;
void SetDebugOption() override;
void SetDebugOption(IRenderer::EDebugOption option, int value) override;
void BeginScene() override;
void EndScene() override;
void BeginPrimitive(GXPrimitive prim, int count) override;
void BeginPrimitive(IRenderer::EPrimitiveType prim, int count) override;
void BeginLines(int nverts) override;
void BeginLineStrip(int nverts) override;
void BeginTriangles(int nverts) override;
@ -121,7 +121,7 @@ public:
void EndPrimitive() override;
void SetAmbientColor(const CColor& color) override;
void DrawString() override;
void GetFPS() override;
float GetFPS() override;
void CacheReflection() override;
void DrawSpaceWarp() override;
void DrawThermalModel() override;
@ -144,6 +144,7 @@ public:
void AllocatePhazonSuitMaskTexture();
void SetRequestRGBA6(bool req) { x318_26_requestRGBA6 = req; }
CTexture* GetRealReflection();
private:
CResFactory& x8_factory;
@ -151,16 +152,13 @@ private:
CFont x10_font;
int x18_primVertCount;
rstl::list< CAreaListItem > x1c_areaListItems;
int x34_unk1;
int x38_unk2;
int x3c_unk3;
int x40_unk4;
rstl::vector< CCubeSurface > x34_surfaces;
CFrustumPlanes x44_frustumPlanes;
TDrawableCallback xa8_drawableCallback;
void* xac_drawableCallbackUserData;
const void* xac_drawableCallbackUserData;
CPlane xb0_viewPlane;
uchar xc0_pvsMode;
int xc4_unk5;
uchar xc0_pvsMode; // bool?
int xc4_pvsState;
rstl::optional_object< CPVSVisSet > xc8_pvsVisSet;
int xe0_pvsAreaIdx;
CTexture xe4_blackTex;
@ -196,6 +194,9 @@ private:
void GenerateSphereRampTex();
void LoadThermoPalette();
rstl::list< CCubeRenderer::CAreaListItem >::iterator
FindStaticGeometry(const rstl::vector< CMetroidModelInstance >* geometry);
static CCubeRenderer* sRenderer;
};
CHECK_SIZEOF(CCubeRenderer, 0x31C);

View File

@ -2,44 +2,66 @@
#define _IRENDERER
#include "types.h"
#include <dolphin/gx/GXEnum.h>
#include "rstl/pair.hpp"
#include "rstl/vector.hpp"
#include "Kyoto/TToken.hpp"
class CTransform4f;
class CParticleGen;
class IObjectStore;
class COsContext;
class CMemorySys;
class CResFactory;
class CAABox;
class CAreaOctTree;
class CColor;
class CFrustumPlanes;
class CLight;
class CMemorySys;
class CMetroidModelInstance;
class CModel;
class COsContext;
class CParticleGen;
class CPVSVisSet;
class CResFactory;
class CSkinnedModel;
class CTransform4f;
class CVector2f;
class CVector3f;
class CModel;
class CFrustumPlanes;
class CSkinnedModel;
class CColor;
class CLight;
class CPVSVisSet;
class IObjectStore;
class IRenderer {
public:
typedef void (*TDrawableCallback)(const void*, const void*, int);
enum EDrawableSorting {
kDS_SortedCallback,
kDS_UnsortedCallback,
};
enum EPrimitiveType {
kPT_Quads = GX_QUADS,
kPT_Triangles = GX_TRIANGLES,
kPT_TriangleStrip = GX_TRIANGLESTRIP,
kPT_TriangleFan = GX_TRIANGLEFAN,
kPT_Lines = GX_LINES,
kPT_LineStrip = GX_LINESTRIP,
kPT_Points = GX_POINTS,
};
enum EDebugOption {
kDO_Invalid = -1,
kDO_PVSMode,
kDO_PVSState,
kDO_FogDisabled,
};
virtual ~IRenderer();
// TODO vtable
virtual void AddStaticGeometry();
virtual void AddStaticGeometry(const rstl::vector< CMetroidModelInstance >* geometry,
const CAreaOctTree* octTree, int areaIdx);
virtual void EnablePVS(const CPVSVisSet& set, int areaIdx);
virtual void DisablePVS();
virtual void RemoveStaticGeometry();
virtual void RemoveStaticGeometry(const rstl::vector< CMetroidModelInstance >* geometry);
virtual void DrawUnsortedGeometry(int areaIdx, int mask, int targetMask);
virtual void DrawSortedGeometry(int areaIdx, int mask, int targetMask);
virtual void DrawStaticGeometry(int areaIdx, int mask, int targetMask);
@ -51,10 +73,10 @@ public:
virtual void AddPlaneObject();
virtual void AddDrawable(const void* obj, const CVector3f& pos, const CAABox& bounds, int mode,
IRenderer::EDrawableSorting sorting);
virtual void SetDrawableCallback(TDrawableCallback cb, void* ctx);
virtual void SetWorldViewpoint();
virtual void SetPerspective1(float, float, float, float, float);
virtual void SetPerspective2();
virtual void SetDrawableCallback(TDrawableCallback cb, const void* ctx);
virtual void SetWorldViewpoint(const CTransform4f& xf);
virtual void SetPerspective(float, float, float, float, float);
virtual void SetPerspective(float, float, float, float);
virtual rstl::pair< CVector2f, CVector2f > SetViewportOrtho(bool centered, float znear,
float zfar);
virtual void SetClippingPlanes(const CFrustumPlanes&);
@ -69,10 +91,10 @@ public:
virtual void SetBlendMode_Replace();
virtual void SetBlendMode_AdditiveDestColor();
virtual void SetDebugOption();
virtual void SetDebugOption(IRenderer::EDebugOption option, int value);
virtual void BeginScene();
virtual void EndScene();
virtual void BeginPrimitive(GXPrimitive prim, int count);
virtual void BeginPrimitive(IRenderer::EPrimitiveType prim, int count);
virtual void BeginLines(int nverts);
virtual void BeginLineStrip(int nverts);
virtual void BeginTriangles(int nverts);
@ -85,7 +107,7 @@ public:
virtual void EndPrimitive();
virtual void SetAmbientColor(const CColor& color);
virtual void DrawString();
virtual void GetFPS();
virtual float GetFPS();
virtual void CacheReflection();
virtual void DrawSpaceWarp();
virtual void DrawThermalModel();
@ -94,7 +116,7 @@ public:
virtual void SetWireframeFlags();
virtual void SetWorldFog();
virtual void RenderFogVolume(const CColor&, const CAABox&, const TLockedToken< CModel >*,
const CSkinnedModel*);
const CSkinnedModel*);
virtual void SetThermal();
virtual void SetThermalColdScale();
virtual void DoThermalBlendCold();
@ -103,9 +125,11 @@ public:
virtual void SetGXRegister1Color();
virtual void SetWorldLightFadeLevel();
virtual void Something();
virtual void PrepareDynamicLights(const rstl::vector<CLight>& lights);
virtual void PrepareDynamicLights(const rstl::vector< CLight >& lights);
};
inline IRenderer::~IRenderer() {}
namespace Renderer {
IRenderer* AllocateRenderer(IObjectStore&, COsContext&, CMemorySys&, CResFactory&);
}; // namespace Renderer

View File

@ -20,7 +20,7 @@ enum ESteeringBlendMode {
class CBodyStateCmd {
public:
CBodyStateCmd(EBodyStateCmd cmd) : x4_cmd(cmd) {}
virtual ~CBodyStateCmd(){};
virtual ~CBodyStateCmd() {};
EBodyStateCmd GetCommandId() const { return x4_cmd; }
@ -342,7 +342,10 @@ private:
class CBCCoverCmd : public CBodyStateCmd {
public:
CBCCoverCmd(pas::ECoverDirection dir, const CVector3f& v1, const CVector3f& v2)
: CBodyStateCmd(kBSC_Cover), x8_dir(dir), xc_targetPos(v1), x18_alignDir(v2) {}
: CBodyStateCmd(kBSC_Cover)
, x8_dir(dir)
, xc_targetPos(v1)
, x18_alignDir(v2, CUnitVector3f::kN_No /* ? */) {}
pas::ECoverDirection GetDirection() const { return x8_dir; }
const CVector3f& GetTarget() const { return xc_targetPos; }

View File

@ -22,13 +22,14 @@ class CRipple {
uint x3c_;
public:
CRipple(TUniqueId id, const CVector3f& center, float intensity);
CRipple(TUniqueId id = kInvalidUniqueId, const CVector3f& center = CVector3f::Zero(),
float intensity = 0.f);
TUniqueId GetUniqueId() const { return x0_id; }
float GetTime() const { return x4_time; }
void SetTime(float t) { x4_time = t; }
float GetTimeFalloff() const { return x14_timeFalloff; }
static float kDefaultScale;

View File

@ -9,6 +9,7 @@ class IWeaponRenderer {
public:
virtual ~IWeaponRenderer() = 0;
virtual void AddParticleGen(const CParticleGen& gen) = 0;
static void SetRenderer(IWeaponRenderer* renderer) { sWeaponRenderer = renderer; }
static IWeaponRenderer* GetRenderer() { return sWeaponRenderer; }

View File

@ -11,13 +11,24 @@ public:
CMetroidModelInstance(const void* header, const void* firstGeom, const void* positions,
const void* normals, const void* colors, const void* texCoords,
const void* packedTexCoords, const rstl::vector< void* >& surfaces);
~CMetroidModelInstance() {}
int GetFlags() const { return x0_visorFlags; }
const CAABox& GetBoundingBox() const { return x34_worldAABB; }
const void* GetMaterialPointer() const { return x4c_materialData; }
const rstl::vector< void* >& GetSurfaces() const { return x50_surfaces; }
const void* GetVertexPointer() const { return x60_positions; }
const void* GetNormalPointer() const { return x64_normals; }
const void* GetColorPointer() const { return x68_colors; }
const void* GetTCPointer() const { return x6c_texCoords; }
const void* GetPackedTCPointer() const { return x70_packedTexCoords; }
private:
u32 x0_visorFlags;
int x0_visorFlags;
CTransform4f x4_worldXf;
CAABox x34_worldAABB;
const void* x4c_materialData;
rstl::vector<void*> x50_surfaces;
rstl::vector< void* > x50_surfaces;
const void* x60_positions;
const void* x64_normals;
const void* x68_colors;

View File

@ -159,7 +159,7 @@ list< T, Alloc >::~list() {
node* it = cur;
node* next = cur->get_next();
cur = next;
destroy(it);
destroy(it->get_value());
x0_allocator.deallocate(it);
}
}

View File

@ -53,7 +53,7 @@ public:
~reserved_vector() { clear(); }
void push_back(const T& in) {
construct(&data()[x0_count], in);
construct(data() + x0_count, in);
++x0_count;
}
@ -69,10 +69,12 @@ public:
inline int capacity() const { return N; }
inline T& front() { return data()[0]; }
inline const T& front() const { return data()[0]; }
inline T& back() { return data()[x0_count - 1]; }
inline const T& back() const { return data()[x0_count - 1]; }
inline T& back() { return at(x0_count - 1); }
inline const T& back() const { return at(x0_count - 1); }
inline T& operator[](int idx) { return data()[idx]; }
inline const T& operator[](int idx) const { return data()[idx]; }
inline T& at(int idx) { return data()[idx]; }
inline const T& at(int idx) const { return data()[idx]; }
iterator erase(iterator it) {
if (it >= begin() && it < end()) {
for (iterator j = it; j < end() - 1; ++j) {
@ -84,7 +86,7 @@ public:
return end();
}
void resize(int count, const T& item) {
void resize(int count, const T& item = T()) {
if (size() < count) {
uninitialized_fill_n(end(), count - size(), item);
x0_count = count;

View File

@ -67,7 +67,7 @@ public:
}
void reserve(int size);
void resize(int size, const T& in);
void resize(int size, const T& in = T());
iterator insert(iterator it, const T& value);
template < typename from_iterator >

View File

@ -67,8 +67,7 @@ CModel::CModel(const rstl::auto_ptr< uchar >& data, int length, IObjectStore& st
x8_surfaces.reserve(surfaceCount);
for (int i = 0; i < surfaceCount; ++i) {
x8_surfaces.push_back(
reinterpret_cast< CCubeSurface* >(MemoryFromPartData(&dataCur, &secSizeCur)));
x8_surfaces.push_back(MemoryFromPartData(&dataCur, &secSizeCur));
}
SShader& shader = x18_matSets.front();

View File

@ -1,14 +1,32 @@
#include "MetaRender/CCubeRenderer.hpp"
#include "Kyoto/Animation/CSkinnedModel.hpp"
#include "Kyoto/Graphics/CColor.hpp"
#include "Kyoto/Graphics/CCubeModel.hpp"
#include "Kyoto/Graphics/CCubeSurface.hpp"
#include "Kyoto/Graphics/CDrawable.hpp"
#include "Kyoto/Graphics/CDrawablePlaneObject.hpp"
#include "Kyoto/Graphics/CGX.hpp"
#include "Kyoto/Graphics/CGraphics.hpp"
#include "Kyoto/Graphics/CGraphicsPalette.hpp"
#include "Kyoto/Graphics/CLight.hpp" // IWYU pragma: keep
#include "Kyoto/Graphics/CModelFlags.hpp"
#include "Kyoto/Graphics/CTexture.hpp"
#include "Kyoto/IObjectStore.hpp"
#include "Kyoto/Math/CFrustumPlanes.hpp"
#include "Kyoto/Math/CPlane.hpp"
#include "Kyoto/Math/CTransform4f.hpp"
#include "Kyoto/Math/CUnitVector3f.hpp"
#include "Kyoto/Math/CVector2f.hpp"
#include "Kyoto/Math/CVector3f.hpp"
#include "MetaRender/IRenderer.hpp"
#include "Weapons/IWeaponRenderer.hpp"
#include "WorldFormat/CMetroidModelInstance.hpp"
#include "dolphin/gx/GXEnum.h"
#include "dolphin/gx/GXGeometry.h"
#include "dolphin/gx/GXVert.h"
#include "dolphin/types.h"
#include "rstl/auto_ptr.hpp"
#include "rstl/math.hpp"
#include "rstl/pair.hpp"
#include "rstl/reserved_vector.hpp"
@ -34,7 +52,7 @@ static rstl::reserved_vector< ushort, 8 >* sPlaneObjectBucket;
void Init() {
#define HOLDER(var) \
static uchar var##Holder[sizeof(__typeof__(*var))]; \
static uchar var##Holder[sizeof(__typeof__(*var)) + 4]; \
var = new (var##Holder) std::type_identity< __typeof__(*var) >::type();
HOLDER(sData);
@ -42,7 +60,7 @@ void Init() {
HOLDER(sPlaneObjectData);
HOLDER(sPlaneObjectBucket);
sBuckets->resize(50, BucketHolderType());
sBuckets->resize(50);
sMinMaxDistance = skWorstMinMaxDistance;
}
@ -54,13 +72,14 @@ void Shutdown() {
}
// TODO non-matching
void Insert(const CVector3f& pos, const CAABox& aabb, EDrawableType dtype, const void* data,
void Insert(const CVector3f& pos, const CAABox& aabb, ushort dtype, const void* data,
const CPlane& plane, ushort extraSort) {
if (sData->size() == sData->capacity()) {
return;
}
float dist = plane.GetHeight(pos);
sData->push_back(CDrawable(dtype, extraSort, dist, aabb, const_cast< void* >(data)));
const CDrawable& drawable = CDrawable(dtype, extraSort, dist, aabb, const_cast< void* >(data));
sData->push_back(drawable);
sMinMaxDistance.first = rstl::min_val(dist, sMinMaxDistance.first);
sMinMaxDistance.second = rstl::max_val(dist, sMinMaxDistance.second);
#ifdef __MWERKS__
@ -90,13 +109,9 @@ void Clear() {
} // namespace Buckets
CCubeRenderer::CAreaListItem::CAreaListItem(
const rstl::vector< CMetroidModelInstance, rstl::rmemory_allocator >* geometry,
const CAreaOctTree* octTree,
const rstl::auto_ptr< rstl::vector< TCachedToken< CTexture >, rstl::rmemory_allocator > >&
textures,
const rstl::auto_ptr< rstl::vector< rstl::auto_ptr< CCubeModel >, rstl::rmemory_allocator > >&
models,
int areaIdx)
const rstl::vector< CMetroidModelInstance >* geometry, const CAreaOctTree* octTree,
const rstl::auto_ptr< rstl::vector< TCachedToken< CTexture > > >& textures,
const rstl::auto_ptr< rstl::vector< rstl::auto_ptr< CCubeModel > > >& models, int areaIdx)
: x0_geometry(geometry)
, x4_octTree(octTree)
, x8_textures(textures)
@ -114,12 +129,7 @@ CCubeRenderer::CCubeRenderer(IObjectStore& objStore, COsContext& osContext, CMem
, x10_font(1.f)
, x18_primVertCount(0)
, x1c_areaListItems()
#if NONMATCHING
, x34_unk1(0)
#endif
, x38_unk2(0)
, x3c_unk3(0)
, x40_unk4(0)
, x34_surfaces()
, x44_frustumPlanes(CTransform4f::Identity(), 1.5707964f, 1.f, 1.f, false, 100.f)
, xa8_drawableCallback(nullptr)
#if NONMATCHING
@ -170,3 +180,305 @@ CCubeRenderer::CCubeRenderer(IObjectStore& objStore, COsContext& osContext, CMem
Buckets::Init();
fn_80352740();
}
void CCubeRenderer::GenerateReflectionTex() {
// TODO
}
void CCubeRenderer::GenerateFogVolumeRampTex() {
// TODO
}
void CCubeRenderer::GenerateSphereRampTex() {
// TODO
}
void CCubeRenderer::LoadThermoPalette() {
// TODO
}
CCubeRenderer::~CCubeRenderer() {
sRenderer = nullptr;
Buckets::Shutdown();
CSkinnedModel::RemoveDummySkinnedModelRef();
if (!x314_phazonSuitMask.null()) {
x314_phazonSuitMask->fn_8030E10C();
}
}
void CCubeRenderer::AddStaticGeometry(const rstl::vector< CMetroidModelInstance >* geometry,
const CAreaOctTree* octTree, int areaIdx) {
if (FindStaticGeometry(geometry) == x1c_areaListItems.end()) {
rstl::auto_ptr< rstl::vector< rstl::auto_ptr< CCubeModel > > > models =
rs_new rstl::vector< rstl::auto_ptr< CCubeModel > >();
rstl::auto_ptr< rstl::vector< TCachedToken< CTexture > > > textures =
rs_new rstl::vector< TCachedToken< CTexture > >();
if (!geometry->empty()) {
CCubeModel::MakeTexturesFromMats(geometry->front().GetMaterialPointer(), *textures,
xc_objStore, false);
models->reserve(geometry->size());
for (int i = 0; i < geometry->size(); ++i) {
const CMetroidModelInstance* it = &geometry->at(i);
models->push_back(rs_new CCubeModel(
const_cast< rstl::vector< void* >* >(&it->GetSurfaces()), textures.get(),
it->GetMaterialPointer(), it->GetVertexPointer(), it->GetColorPointer(),
it->GetNormalPointer(), it->GetTCPointer(), it->GetPackedTCPointer(),
it->GetBoundingBox(), it->GetFlags(), false, i));
}
}
x1c_areaListItems.push_back(CAreaListItem(geometry, octTree, textures, models, areaIdx));
GXInvalidateVtxCache();
}
}
rstl::list< CCubeRenderer::CAreaListItem >::iterator
CCubeRenderer::FindStaticGeometry(const rstl::vector< CMetroidModelInstance >* geometry) {
for (AUTO(it, x1c_areaListItems.begin()); it != x1c_areaListItems.end(); ++it) {
if (it->x0_geometry == geometry) {
return it;
}
}
return x1c_areaListItems.end();
}
void CCubeRenderer::RemoveStaticGeometry(const rstl::vector< CMetroidModelInstance >* geometry) {
AUTO(search, FindStaticGeometry(geometry));
if (search != x1c_areaListItems.end()) {
x1c_areaListItems.erase(search);
}
}
void CCubeRenderer::SetModelMatrix(const CTransform4f& xf) { CGraphics::SetModelMatrix(xf); }
// TODO non-matching
void CCubeRenderer::SetWorldViewpoint(const CTransform4f& xf) {
CGraphics::SetViewPointMatrix(xf);
const CUnitVector3f forward(xf.GetColumn(kDY), CUnitVector3f::kN_No);
xb0_viewPlane = CPlane(CVector3f::Dot(forward, xf.GetTranslation()), forward);
}
void CCubeRenderer::BeginScene() {
int width = CGraphics::GetViewport().mWidth;
int height = CGraphics::GetViewport().mHeight;
CGraphics::SetUseVideoFilter(true);
CGraphics::SetViewport(0, 0, width, height);
CGraphics::SetClearColor(CColor(static_cast< uchar >(0), static_cast< uchar >(0),
static_cast< uchar >(0), static_cast< uchar >(0)));
CGraphics::SetCullMode(kCM_Front);
CGraphics::SetDepthWriteMode(true, kE_LEqual, true);
CGraphics::SetBlendMode(kBM_Blend, kBF_SrcAlpha, kBF_InvSrcAlpha, kLO_Clear);
#if NONMATCHING
float aspect = static_cast< float >(width) / static_cast< float >(height);
#else
float aspect = 1.3333334f;
#endif
CGraphics::SetPerspective(75.f, aspect, 1.f, 4096.f);
CGraphics::SetModelMatrix(CTransform4f::Identity());
CGraphics::TickRenderTimings();
if (x310_phazonSuitMaskCountdown != 0) {
--x310_phazonSuitMaskCountdown;
if (x310_phazonSuitMaskCountdown == 0) {
x314_phazonSuitMask->fn_8030E10C();
x314_phazonSuitMask = nullptr;
}
}
x318_27_currentRGBA6 = x318_26_requestRGBA6;
if (!x318_31_persistRGBA6) {
x318_26_requestRGBA6 = false;
}
GXSetPixelFmt(x318_27_currentRGBA6 ? GX_PF_RGBA6_Z24 : GX_PF_RGB8_Z24, GX_ZC_LINEAR);
GXSetAlphaUpdate(GX_TRUE);
GXSetDstAlpha(GX_TRUE, 0);
CGraphics::BeginScene();
}
void CCubeRenderer::EndScene() {
x318_31_persistRGBA6 = !CGraphics::IsBeginSceneClearFb();
CGraphics::EndScene();
if (x2dc_reflectionAge >= 2) {
x14c_reflectionTex = nullptr;
} else {
++x2dc_reflectionAge;
}
}
void CCubeRenderer::AddParticleGen(const CParticleGen& gen) {
// TODO
}
namespace Renderer {
IRenderer* AllocateRenderer(IObjectStore& objStore, COsContext& osContext, CMemorySys& memorySys,
CResFactory& resFactory) {
CCubeRenderer* renderer = rs_new CCubeRenderer(objStore, osContext, memorySys, resFactory);
IWeaponRenderer::SetRenderer(renderer);
return renderer;
}
} // namespace Renderer
void CCubeRenderer::PrimColor(float r, float g, float b, float a) {
x2e0_primColor.Set(r, g, b, a);
}
void CCubeRenderer::PrimColor(const CColor& color) { x2e0_primColor = color; }
void CCubeRenderer::BeginPrimitive(IRenderer::EPrimitiveType type, int nverts) {
const GXVtxDescList vtxDescList[4] = {
{GX_VA_POS, GX_DIRECT},
{GX_VA_NRM, GX_DIRECT},
{GX_VA_CLR0, GX_DIRECT},
{GX_VA_NULL, GX_NONE},
};
CGX::SetChanCtrl(CGX::Channel0, false, GX_SRC_REG, GX_SRC_VTX, GX_LIGHT_NULL, GX_DF_NONE,
GX_AF_NONE);
CGX::SetNumChans(1);
CGX::SetNumTexGens(0);
CGX::SetNumTevStages(1);
CGX::SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0);
CGX::SetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_RASC);
CGX::SetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_RASA);
CGX::SetStandardTevColorAlphaOp(GX_TEVSTAGE0);
x18_primVertCount = nverts;
CGX::SetVtxDescv(vtxDescList);
CGX::Begin(GXPrimitive(type), GX_VTXFMT0, nverts);
}
void CCubeRenderer::BeginLines(int nverts) {
CCubeRenderer::BeginPrimitive(IRenderer::kPT_Lines, nverts);
}
void CCubeRenderer::BeginLineStrip(int nverts) {
CCubeRenderer::BeginPrimitive(IRenderer::kPT_LineStrip, nverts);
}
void CCubeRenderer::BeginTriangles(int nverts) {
CCubeRenderer::BeginPrimitive(IRenderer::kPT_Triangles, nverts);
}
void CCubeRenderer::BeginTriangleStrip(int nverts) {
CCubeRenderer::BeginPrimitive(IRenderer::kPT_TriangleStrip, nverts);
}
void CCubeRenderer::BeginTriangleFan(int nverts) {
CCubeRenderer::BeginPrimitive(IRenderer::kPT_TriangleFan, nverts);
}
void CCubeRenderer::PrimVertex(const CVector3f& vtx) {
--x18_primVertCount;
GXPosition3f32(vtx.GetX(), vtx.GetY(), vtx.GetZ());
GXNormal3f32(x2e4_primNormal.GetX(), x2e4_primNormal.GetY(), x2e4_primNormal.GetZ());
GXColor1u32(x2e0_primColor.GetColor_u32());
}
void CCubeRenderer::PrimNormal(const CVector3f& nrm) { x2e4_primNormal = nrm; }
void CCubeRenderer::EndPrimitive() {
while (x18_primVertCount != 0) {
PrimVertex(CVector3f::Zero());
}
CGX::End();
}
void CCubeRenderer::SetAmbientColor(const CColor& color) { CGraphics::SetAmbientColor(color); }
void CCubeRenderer::SetPerspective(float fovy, float aspect, float znear, float zfar) {
CGraphics::SetPerspective(fovy, aspect, znear, zfar);
}
void CCubeRenderer::SetPerspective(float fovy, float width, float height, float znear, float zfar) {
CGraphics::SetPerspective(fovy, width / height, znear, zfar);
}
rstl::pair< CVector2f, CVector2f > CCubeRenderer::SetViewportOrtho(bool centered, float znear,
float zfar) {
const CViewport& vp = CGraphics::GetViewport();
int vpLeft = vp.mLeft;
int vpTop = vp.mTop;
int vpWidth = vp.mWidth;
int vpHeight = vp.mHeight;
float left = static_cast< float >(centered ? vpLeft - vpWidth / 2 : vpLeft);
float top = static_cast< float >(centered ? vpTop - vpHeight / 2 : vpTop);
float right = static_cast< float >(centered ? vpLeft + vpWidth / 2 : vpLeft + vpWidth);
float bottom = static_cast< float >(centered ? vpTop + vpHeight / 2 : vpTop + vpHeight);
CGraphics::SetOrtho(left, right, bottom, top, znear, zfar);
CGraphics::SetViewPointMatrix(CTransform4f::Identity());
CGraphics::SetModelMatrix(CTransform4f::Identity());
return rstl::pair< CVector2f, CVector2f >(CVector2f(left, top), CVector2f(right, bottom));
}
void CCubeRenderer::SetViewport(int left, int bottom, int width, int height) {
CGraphics::SetViewport(left, bottom, width, height);
CGraphics::SetScissor(left, bottom, width, height);
}
void CCubeRenderer::SetDepthReadWrite(bool read, bool update) {
CGraphics::SetDepthWriteMode(read, kE_LEqual, update);
}
void CCubeRenderer::SetBlendMode_AdditiveAlpha() {
CGraphics::SetBlendMode(kBM_Blend, kBF_SrcAlpha, kBF_One, kLO_Clear);
}
void CCubeRenderer::SetBlendMode_AlphaBlended() {
CGraphics::SetBlendMode(kBM_Blend, kBF_SrcAlpha, kBF_InvSrcAlpha, kLO_Clear);
}
void CCubeRenderer::SetBlendMode_NoColorWrite() {
CGraphics::SetBlendMode(kBM_Blend, kBF_Zero, kBF_One, kLO_Clear);
}
void CCubeRenderer::SetBlendMode_ColorMultiply() {
CGraphics::SetBlendMode(kBM_Blend, kBF_Zero, kBF_SrcColor, kLO_Clear);
}
void CCubeRenderer::SetBlendMode_InvertDst() {
CGraphics::SetBlendMode(kBM_Blend, kBF_InvSrcColor, kBF_Zero, kLO_Clear);
}
void CCubeRenderer::SetBlendMode_InvertSrc() {
CGraphics::SetBlendMode(kBM_Logic, kBF_One, kBF_Zero, kLO_InvCopy);
}
void CCubeRenderer::SetBlendMode_Replace() {
CGraphics::SetBlendMode(kBM_Blend, kBF_One, kBF_Zero, kLO_Clear);
}
void CCubeRenderer::SetBlendMode_AdditiveDestColor() {
CGraphics::SetBlendMode(kBM_Blend, kBF_SrcColor, kBF_One, kLO_Clear);
}
void CCubeRenderer::SetClippingPlanes(const CFrustumPlanes& frustum) {
x44_frustumPlanes = frustum;
}
float CCubeRenderer::GetFPS() { return CGraphics::GetFPS(); }
void CCubeRenderer::SetDrawableCallback(IRenderer::TDrawableCallback cb, const void* ctx) {
xa8_drawableCallback = cb;
xac_drawableCallbackUserData = ctx;
}
void CCubeRenderer::SetDebugOption(IRenderer::EDebugOption option, int value) {
switch (option) {
case IRenderer::kDO_PVSMode:
xc0_pvsMode = value != 0 ? 1 : 0;
break;
case IRenderer::kDO_PVSState:
xc4_pvsState = value;
break;
case IRenderer::kDO_FogDisabled:
x318_28_disableFog = value != 0;
break;
default:
break;
}
}
CTexture* CCubeRenderer::GetRealReflection() {
x2dc_reflectionAge = 0;
if (!x14c_reflectionTex.null()) {
return x14c_reflectionTex.get();
}
return &xe4_blackTex;
}

View File

@ -4,7 +4,7 @@
CFluidUVMotion::CFluidUVMotion(float timeToWrap, float orientation)
: x0_fluidLayers(), x4c_ooTimeToWrap(1.f / timeToWrap), x50_orientation(orientation) {
x0_fluidLayers.resize(kFM_NumLayers, SFluidLayerMotion());
x0_fluidLayers.resize(kFM_NumLayers);
x0_fluidLayers[0] = SFluidLayerMotion(CFluidUVMotion::kFM_Linear, 1000.f);
x0_fluidLayers[1] = SFluidLayerMotion(CFluidUVMotion::kFM_Linear, 3.f);
x0_fluidLayers[2] = SFluidLayerMotion(CFluidUVMotion::kFM_Linear, 5.f, CMath::Deg2Rad(45.f));
@ -15,7 +15,7 @@ CFluidUVMotion::CFluidUVMotion(float timeToWrap, float orientation,
const SFluidLayerMotion& pattern1Layer,
const SFluidLayerMotion& pattern2Layer)
: x0_fluidLayers(), x4c_ooTimeToWrap(1.f / timeToWrap), x50_orientation(orientation) {
x0_fluidLayers.resize(kFM_NumLayers, SFluidLayerMotion());
x0_fluidLayers.resize(kFM_NumLayers);
x0_fluidLayers[0] = colorLayer;
x0_fluidLayers[1] = pattern1Layer;
x0_fluidLayers[2] = pattern2Layer;

View File

@ -12,11 +12,13 @@
#include "rstl/math.hpp"
CGameCubeDoll::CGameCubeDoll()
: x0_model(gpSimplePool->GetObj("CMDL_GameCube"))
, x8_lights(1, CLight::BuildDirectional(CVector3f::Forward(), CColor(0xFFFFFFFF)), rstl::rmemory_allocator())
, x18_actorLights(rs_new CActorLights(8, CVector3f::Zero(), 4, 4, CActorLights::kDefaultPositionUpdateThreshold, false, false, false))
, x8_lights(1, CLight::BuildDirectional(CVector3f::Forward(), CColor(0xFFFFFFFF)),
rstl::rmemory_allocator())
, x18_actorLights(rs_new CActorLights(8, CVector3f::Zero(), 4, 4,
CActorLights::kDefaultPositionUpdateThreshold, false, false,
false))
, x1c_fader(0.0f)
, x20_24_loaded(false) {
x0_model.Lock();
@ -58,7 +60,7 @@ extern float energyball_lbl_805A85E8;
void CGameCubeDoll::Update(float dt) {
if (!CheckLoadComplete())
return;
x1c_fader = rstl::min_val(energyball_lbl_805A85E8, (dt * 2.f) + x1c_fader);
x1c_fader = rstl::min_val(energyball_lbl_805A85E8, (dt * 2.f) + x1c_fader);
UpdateActorLights();
}
@ -68,8 +70,8 @@ void CGameCubeDoll::Draw(float alpha) {
float alphaFader = alpha * x1c_fader;
gpRender->SetPerspective1(55.f, CGraphics::GetViewport().mWidth, CGraphics::GetViewport().mHeight,
0.2f, 4096.f);
gpRender->SetPerspective(55.f, CGraphics::GetViewport().mWidth, CGraphics::GetViewport().mHeight,
0.2f, 4096.f);
CGraphics::SetViewPointMatrix(CTransform4f::Translate(0.f, -2.f, 0.f));
x18_actorLights->ActivateLights();

View File

@ -671,7 +671,7 @@ void CMemoryCardDriver::InitializeFileInfo() {
// CMemoryStreamOut w(fileInfo.BeginMemoryOut(3004));
rstl::vector< u8 >& saveBuffer = fileInfo.SaveBuffer();
saveBuffer.resize(3004, '\x00');
saveBuffer.resize(3004);
CMemoryStreamOut w(saveBuffer.data(), 3004);
SSaveHeader header(0);

View File

@ -10,14 +10,14 @@ CRippleManager::CRippleManager(int maxRipples, float alpha)
}
void CRippleManager::Init(int maxRipples) {
x4_ripples.resize(maxRipples, CRipple(kInvalidUniqueId, CVector3f::Zero(), 0.f));
for (rstl::vector< CRipple >::iterator it = x4_ripples.begin(); it != x4_ripples.end(); ++it) {
x4_ripples.resize(maxRipples);
for (AUTO(it, x4_ripples.begin()); it != x4_ripples.end(); ++it) {
it->SetTime(9999.f);
}
}
void CRippleManager::Update(float dt) {
for (rstl::vector< CRipple >::iterator it = x4_ripples.begin(); it != x4_ripples.end(); ++it) {
for (AUTO(it, x4_ripples.begin()); it != x4_ripples.end(); ++it) {
it->SetTime(it->GetTime() + dt);
if (it->GetTime() < 9999.f) {
it->SetTime(9999.f);
@ -28,8 +28,7 @@ void CRippleManager::Update(float dt) {
float CRippleManager::GetLastRippleDeltaTime(TUniqueId rippler) const {
float res = 9999.f;
for (rstl::vector< CRipple >::const_iterator it = x4_ripples.begin(); it != x4_ripples.end();
++it) {
for (AUTO(it, x4_ripples.begin()); it != x4_ripples.end(); ++it) {
if (rippler == it->GetUniqueId()) {
if (res > it->GetTime()) {
res = it->GetTime();
@ -44,7 +43,7 @@ void CRippleManager::AddRipple(const CRipple& ripple) {
float maxTime = 0.f;
rstl::vector< CRipple >::iterator oldestRipple = x4_ripples.end();
for (rstl::vector< CRipple >::iterator it = x4_ripples.begin(); it != x4_ripples.end(); ++it) {
for (AUTO(it, x4_ripples.begin()); it != x4_ripples.end(); ++it) {
if (it->GetTime() == 9999.0f) {
oldestRipple = it;
break;

View File

@ -172,7 +172,7 @@ CStateManager::CStateManager(const rstl::ncrc_ptr< CScriptMailbox >& mailbox,
gpRender->SetDrawableCallback(RendererDrawCallback, this);
CMemory::SetOutOfMemoryCallback(MemoryAllocatorAllocationFailedCallback, this);
x90c_loaderFuncs.resize(x90c_loaderFuncs.capacity(), nullptr);
x90c_loaderFuncs.resize(x90c_loaderFuncs.capacity());
x90c_loaderFuncs[kST_Trigger] = ScriptLoader::LoadTrigger;
x90c_loaderFuncs[kST_DamageableTrigger] = ScriptLoader::LoadDamageableTrigger;
x90c_loaderFuncs[kST_Actor] = ScriptLoader::LoadActor;

View File

@ -64,17 +64,11 @@ void CWorldShadow::BuildLightShadowTexture(const CStateManager& mgr, TAreaId aid
x68_objPos = centerPoint;
x74_lightPos = light.GetPosition();
CGraphics::SetViewPointMatrix(x4_view);
CFrustumPlanes frumtum(
x4_view,
fov * 0.01745329238474369,
1.0f,
0.1f,
true,
distance + x64_objHalfExtent
);
CFrustumPlanes frumtum(x4_view, fov * 0.01745329238474369, 1.0f, 0.1f, true,
distance + x64_objHalfExtent);
gpRender->SetClippingPlanes(frumtum);
gpRender->SetPerspective1(fov, x0_texture->GetWidth(), x0_texture->GetHeight(), 0.1f,
1000.f);
gpRender->SetPerspective(fov, x0_texture->GetWidth(), x0_texture->GetHeight(), 0.1f,
1000.f);
float backupDepthNear = CGraphics::GetDepthNear();
float backupDepthFar = CGraphics::GetDepthFar();
CGraphics::SetDepthRange(0.f, 1.0f);
@ -130,10 +124,8 @@ void CWorldShadow::BuildLightShadowTexture(const CStateManager& mgr, TAreaId aid
if (motionBlur && x88_blurReset != true) {
CGraphics::SetDepthWriteMode(false, kE_LEqual, false);
CGraphics::SetBlendMode(kBM_Blend, kBF_SrcAlpha,
kBF_InvSrcAlpha, kLO_Clear);
CGraphics::SetAlphaCompare(kAF_Always, 0, kAO_And,
kAF_Always, 0);
CGraphics::SetBlendMode(kBM_Blend, kBF_SrcAlpha, kBF_InvSrcAlpha, kLO_Clear);
CGraphics::SetAlphaCompare(kAF_Always, 0, kAO_And, kAF_Always, 0);
CGraphics::SetTevOp(kTS_Stage0, CGraphics::kEnvModulate);
CGraphics::SetTevOp(kTS_Stage1, CGraphics::kEnvPassthru);
CGraphics::Render2D(*x0_texture, 0, x0_texture->GetWidth() * 2,
@ -144,14 +136,15 @@ void CWorldShadow::BuildLightShadowTexture(const CStateManager& mgr, TAreaId aid
x88_blurReset = false;
GXSetTexCopySrc(0, 448 - x0_texture->GetHeight() * 2, x0_texture->GetWidth() * 2, x0_texture->GetHeight() * 2);
GXSetTexCopySrc(0, 448 - x0_texture->GetHeight() * 2, x0_texture->GetWidth() * 2,
x0_texture->GetHeight() * 2);
GXTexFmt fmt = GX_TF_RGBA8;
if (x0_texture->GetTexelFormat() == 0x7) {
fmt = GX_TF_RGB565;
}
GXSetTexCopyDst(x0_texture->GetWidth(), x0_texture->GetHeight(), fmt, true);
static int unkInt = 0;
void * dest = x0_texture->Lock();
void* dest = x0_texture->Lock();
GXCopyTex(dest, true);
x0_texture->UnLock();

View File

@ -105,6 +105,9 @@ _LITERAL_REPLACEMENTS = [
("EPhazonType::", "kPT_"),
("EChain::", "kC_"),
("EPhase::", "kP_"),
("ERglBlendMode::", "kBM_"),
("ERglBlendFactor::", "kBF_"),
("ERglLogicOp::", "kLO_"),
# CActor
("x34_transform.origin", "GetTranslation()"),