mirror of https://github.com/PrimeDecomp/prime.git
parent
38253107a6
commit
9bdce565df
|
@ -16,7 +16,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
float GetTime() const { return x0_t; }
|
float GetTime() const { return x0_t; }
|
||||||
bool IsValid() const { return x20_valid == kI_Valid; }
|
bool IsValid() const { return x20_valid != kI_Invalid; }
|
||||||
// TODO: figure out what's going on here
|
// TODO: figure out what's going on here
|
||||||
bool IsInvalid() const { return x20_valid == kI_Invalid; }
|
bool IsInvalid() const { return x20_valid == kI_Invalid; }
|
||||||
// GetPlane__14CRayCastResultCFv
|
// GetPlane__14CRayCastResultCFv
|
||||||
|
|
|
@ -10,13 +10,11 @@ namespace CCast {
|
||||||
inline uchar ToUint8(register float in) {
|
inline uchar ToUint8(register float in) {
|
||||||
uchar a;
|
uchar a;
|
||||||
register uchar* ptr = &a;
|
register uchar* ptr = &a;
|
||||||
register uchar r;
|
|
||||||
|
|
||||||
asm {
|
asm {
|
||||||
psq_st in, 0(ptr), 1, OS_FASTCAST_U8
|
psq_st in, 0(ptr), 1, OS_FASTCAST_U8
|
||||||
lbz r, 0(ptr)
|
|
||||||
}
|
}
|
||||||
return r;
|
return *ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline float ToReal32(register const uchar& in) {
|
inline float ToReal32(register const uchar& in) {
|
||||||
|
|
|
@ -16,7 +16,7 @@ class CInputStream;
|
||||||
class CColor {
|
class CColor {
|
||||||
public:
|
public:
|
||||||
CColor() { Set(255, 0, 255); }
|
CColor() { Set(255, 0, 255); }
|
||||||
CColor(uint col) : mRgba(col) {}
|
CColor(uint col) { Set(col); }
|
||||||
CColor(CInputStream& in);
|
CColor(CInputStream& in);
|
||||||
CColor(float r, float g, float b, float a = 1.f);
|
CColor(float r, float g, float b, float a = 1.f);
|
||||||
CColor(uchar r, uchar g, uchar b, uchar a = 255) {
|
CColor(uchar r, uchar g, uchar b, uchar a = 255) {
|
||||||
|
@ -33,6 +33,7 @@ public:
|
||||||
mB = b;
|
mB = b;
|
||||||
mA = a;
|
mA = a;
|
||||||
}
|
}
|
||||||
|
void Set(uint col) { mRgba = col; }
|
||||||
void Get(float& r, float& g, float& b, float& a) const;
|
void Get(float& r, float& g, float& b, float& a) const;
|
||||||
void Get(float& r, float& g, float& b) const;
|
void Get(float& r, float& g, float& b) const;
|
||||||
// TODO check. Maybe this calls SetAlpha(uchar)?
|
// TODO check. Maybe this calls SetAlpha(uchar)?
|
||||||
|
@ -52,9 +53,16 @@ public:
|
||||||
uchar GetBlueu8() const { return mB; }
|
uchar GetBlueu8() const { return mB; }
|
||||||
uchar GetAlphau8() const { return mA; }
|
uchar GetAlphau8() const { return mA; }
|
||||||
ushort ToRGB5A3() const;
|
ushort ToRGB5A3() const;
|
||||||
|
uint GetColor_u32() const { return mRgba; }
|
||||||
|
const GXColor& GetGXColor() const { return *reinterpret_cast< const GXColor* >(this); }
|
||||||
|
|
||||||
|
CColor WithAlphaOf(float a) const { return CColor((mRgba & ~0xff) | CCast::ToUint8(a * 255.f)); }
|
||||||
|
CColor WithAlphaModulatedBy(float a) const {
|
||||||
|
return CColor((mRgba & ~0xff) | CCast::ToUint8(a * static_cast< float >(mA)));
|
||||||
|
}
|
||||||
|
|
||||||
// TODO check
|
// TODO check
|
||||||
static GXColor ToGX(uint c) { return *reinterpret_cast< const GXColor* >(&c); }
|
static GXColor ToGX(uint c) { return *reinterpret_cast< const GXColor* >(&c); }
|
||||||
uint GetColor_u32() const { return mRgba; }
|
|
||||||
|
|
||||||
static const CColor& Black();
|
static const CColor& Black();
|
||||||
static const CColor& White();
|
static const CColor& White();
|
||||||
|
|
|
@ -180,6 +180,8 @@ public:
|
||||||
float GetThermalColdScale1() const { return xf24_thermColdScale1; }
|
float GetThermalColdScale1() const { return xf24_thermColdScale1; }
|
||||||
float GetThermalColdScale2() const { return xf28_thermColdScale2; }
|
float GetThermalColdScale2() const { return xf28_thermColdScale2; }
|
||||||
void SetThermalColdScale2(float s) { xf28_thermColdScale2 = s; }
|
void SetThermalColdScale2(float s) { xf28_thermColdScale2 = s; }
|
||||||
|
// TODO ?
|
||||||
|
void AddThermalColdScale2(float s) { xf28_thermColdScale2 += s; }
|
||||||
|
|
||||||
bool IsGeneratingObject() const { return xf94_26_generatingObject; }
|
bool IsGeneratingObject() const { return xf94_26_generatingObject; }
|
||||||
void SetIsGeneratingObject(bool gen) { xf94_26_generatingObject = gen; }
|
void SetIsGeneratingObject(bool gen) { xf94_26_generatingObject = gen; }
|
||||||
|
|
|
@ -23,7 +23,7 @@ typedef union {
|
||||||
} PPCWGPipe;
|
} PPCWGPipe;
|
||||||
|
|
||||||
#ifdef __MWERKS__
|
#ifdef __MWERKS__
|
||||||
volatile PPCWGPipe GXWGFifo : GXFIFO_ADDR;
|
/*volatile*/ PPCWGPipe GXWGFifo : GXFIFO_ADDR;
|
||||||
#else
|
#else
|
||||||
#define GXWGFifo (*(volatile PPCWGPipe*)GXFIFO_ADDR)
|
#define GXWGFifo (*(volatile PPCWGPipe*)GXFIFO_ADDR)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -57,54 +57,50 @@ CVisorFlare::CVisorFlare(EBlendMode blendMode, bool b1, float f1, float f2, floa
|
||||||
, x30_w2(w2) {}
|
, x30_w2(w2) {}
|
||||||
|
|
||||||
void CVisorFlare::Update(float dt, const CVector3f& pos, const CActor* act, CStateManager& mgr) {
|
void CVisorFlare::Update(float dt, const CVector3f& pos, const CActor* act, CStateManager& mgr) {
|
||||||
const CPlayerState::EPlayerVisor visor = mgr.GetPlayerState()->GetCurrentVisor();
|
CPlayerState::EPlayerVisor visor = mgr.GetPlayerState()->GetCurrentVisor();
|
||||||
|
|
||||||
if ((visor == CPlayerState::kPV_Combat || (x2c_w1 != 1 && visor == CPlayerState::kPV_Thermal)) &&
|
if ((visor == CPlayerState::kPV_Combat || (x2c_w1 != 1 && visor == CPlayerState::kPV_Thermal)) &&
|
||||||
mgr.GetPlayer()->GetMorphballTransitionState() == CPlayer::kMS_Unmorphed) {
|
mgr.GetPlayer()->GetMorphballTransitionState() == CPlayer::kMS_Unmorphed) {
|
||||||
|
|
||||||
CVector3f camPos = mgr.GetCameraManager()->GetCurrentCamera(mgr)->GetTranslation();
|
CVector3f camPos = mgr.GetCameraManager()->GetCurrentCamera(mgr)->GetTranslation();
|
||||||
CVector3f camDiff = pos - camPos;
|
CVector3f camDiff = pos - camPos;
|
||||||
const float mag = camDiff.Magnitude();
|
float mag = camDiff.Magnitude();
|
||||||
camDiff = camDiff * (1.f / mag);
|
camDiff *= (1.f / mag);
|
||||||
|
|
||||||
bool rayCastIsValid;
|
CMaterialFilter nearMaterialList = CMaterialFilter::MakeInclude(CMaterialList(kMT_Occluder));
|
||||||
|
|
||||||
{
|
|
||||||
const CMaterialFilter& nearMaterialList =
|
|
||||||
CMaterialFilter::MakeInclude(CMaterialList(kMT_Occluder));
|
|
||||||
TEntityList nearVec;
|
TEntityList nearVec;
|
||||||
mgr.BuildNearList(nearVec, camPos, camDiff, mag, nearMaterialList, act);
|
mgr.BuildNearList(nearVec, camPos, camDiff, mag, nearMaterialList, act);
|
||||||
|
|
||||||
const CMaterialFilter& rayMaterialList = CMaterialFilter::MakeIncludeExclude(
|
CMaterialFilter rayMaterialList = CMaterialFilter::MakeIncludeExclude(
|
||||||
CMaterialList(kMT_Solid), CMaterialList(kMT_SeeThrough));
|
CMaterialList(kMT_Solid), CMaterialList(kMT_SeeThrough));
|
||||||
TUniqueId id(kInvalidUniqueId);
|
TUniqueId id(kInvalidUniqueId);
|
||||||
rayCastIsValid =
|
CRayCastResult result =
|
||||||
mgr.RayWorldIntersection(id, camPos, camDiff, mag, rayMaterialList, nearVec).IsValid();
|
mgr.RayWorldIntersection(id, camPos, camDiff, mag, rayMaterialList, nearVec);
|
||||||
}
|
nearVec.clear();
|
||||||
|
|
||||||
if (!rayCastIsValid) {
|
if (result.IsValid()) {
|
||||||
x28_ -= dt;
|
|
||||||
} else {
|
|
||||||
x28_ += dt;
|
x28_ += dt;
|
||||||
|
} else {
|
||||||
|
x28_ -= dt;
|
||||||
}
|
}
|
||||||
x28_ = rstl::max_val(x18_f1, rstl::min_val(x28_, 0.f));
|
x28_ = rstl::max_val(rstl::max_val(0.f, x28_), x18_f1);
|
||||||
|
|
||||||
const CGameCamera* curCam = mgr.GetCameraManager()->GetCurrentCamera(mgr);
|
const CGameCamera* curCam = mgr.GetCameraManager()->GetCurrentCamera(mgr);
|
||||||
const CVector3f cameraForward = curCam->GetTransform().GetForward();
|
CVector3f cameraForward = curCam->GetTransform().GetColumn(kDY);
|
||||||
x24_ = 1.f - (x28_ / x18_f1);
|
CVector3f dir = pos - curCam->GetTranslation();
|
||||||
|
x24_ = 1.f - x28_ / x18_f1;
|
||||||
|
|
||||||
const CVector3f dir = (pos - curCam->GetTranslation()).AsNormalized();
|
float dot = CVector3f::Dot(dir.AsNormalized(), cameraForward);
|
||||||
float dot = CVector3f::Dot(dir, cameraForward);
|
|
||||||
x24_ *= rstl::max_val(0.f, 1.f - (x1c_f2 * 4.f * (1.f - dot)));
|
x24_ *= rstl::max_val(0.f, 1.f - (x1c_f2 * 4.f * (1.f - dot)));
|
||||||
|
|
||||||
if (x2c_w1 == 2) {
|
if (x2c_w1 == 2) {
|
||||||
mgr.SetThermalColdScale2(mgr.GetThermalColdScale2() + x24_);
|
mgr.AddThermalColdScale2(x24_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CVisorFlare::Render(const CVector3f& inPos, const CStateManager& mgr) const {
|
void CVisorFlare::Render(const CVector3f& inPos, const CStateManager& mgr) const {
|
||||||
if (close_enough(x28_, x18_f1, 1.0E-5f) ||
|
if (close_enough(x28_, x18_f1) ||
|
||||||
mgr.GetPlayer()->GetMorphballTransitionState() != CPlayer::kMS_Unmorphed) {
|
mgr.GetPlayer()->GetMorphballTransitionState() != CPlayer::kMS_Unmorphed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -126,15 +122,15 @@ void CVisorFlare::Render(const CVector3f& inPos, const CStateManager& mgr) const
|
||||||
gpRender->SetDepthReadWrite(false, false);
|
gpRender->SetDepthReadWrite(false, false);
|
||||||
const CGameCamera* cam = mgr.GetCameraManager()->GetCurrentCamera(mgr);
|
const CGameCamera* cam = mgr.GetCameraManager()->GetCurrentCamera(mgr);
|
||||||
CVector3f camPos = cam->GetTranslation();
|
CVector3f camPos = cam->GetTranslation();
|
||||||
CVector3f inPosCopy(inPos);
|
CVector3f inPosCopy = inPos;
|
||||||
|
|
||||||
CTransform4f viewMatrix = CGraphics::GetViewMatrix();
|
CTransform4f viewMatrix = CGraphics::GetViewMatrix();
|
||||||
const CVector3f invPos = viewMatrix.GetInverse() * inPosCopy;
|
const CVector3f invPos = viewMatrix.GetInverse() * inPosCopy;
|
||||||
const CVector3f invPos2 = viewMatrix * CVector3f(-invPos.GetX(), invPos.GetY(), -invPos.GetZ());
|
const CVector3f invPos2 = viewMatrix * CVector3f(-invPos.GetX(), invPos.GetY(), -invPos.GetZ());
|
||||||
CVector3f camFront = cam->GetTransform().GetForward();
|
CVector3f camFront = cam->GetTransform().GetForward();
|
||||||
if (!close_enough(x24_, 0.f, 1.0E-5f)) {
|
if (!close_enough(x24_, 0.f)) {
|
||||||
float acos = 0.f;
|
float acos = 0.f;
|
||||||
if (!close_enough(x20_f3, 0.f, 1.0E-5f)) {
|
if (!close_enough(x20_f3, 0.f)) {
|
||||||
CVector3f camDist(
|
CVector3f camDist(
|
||||||
CVector3f(inPosCopy.GetX() - camPos.GetX(), inPosCopy.GetY() - camPos.GetY(), 0.f)
|
CVector3f(inPosCopy.GetX() - camPos.GetX(), inPosCopy.GetY() - camPos.GetY(), 0.f)
|
||||||
.AsNormalized());
|
.AsNormalized());
|
||||||
|
@ -148,10 +144,8 @@ void CVisorFlare::Render(const CVector3f& inPos, const CStateManager& mgr) const
|
||||||
SetupRenderState(mgr);
|
SetupRenderState(mgr);
|
||||||
for (rstl::vector< CFlareDef >::const_iterator item = x4_flareDefs.begin();
|
for (rstl::vector< CFlareDef >::const_iterator item = x4_flareDefs.begin();
|
||||||
item != x4_flareDefs.end(); ++item) {
|
item != x4_flareDefs.end(); ++item) {
|
||||||
|
CVector3f origin = CVector3f::Lerp(inPosCopy, invPos2, item->GetPosition());
|
||||||
const float itemPos = item->GetPosition();
|
CTransform4f modelMatrix = CTransform4f::LookAt(origin, camPos);
|
||||||
const CVector3f origin = inPosCopy * (1.f - itemPos) + invPos2 * itemPos;
|
|
||||||
CTransform4f modelMatrix(CTransform4f::LookAt(origin, camPos));
|
|
||||||
gpRender->SetModelMatrix(modelMatrix);
|
gpRender->SetModelMatrix(modelMatrix);
|
||||||
float scale = 0.5f * x24_ * item->GetScale();
|
float scale = 0.5f * x24_ * item->GetScale();
|
||||||
if (x14_b1) {
|
if (x14_b1) {
|
||||||
|
@ -161,7 +155,8 @@ void CVisorFlare::Render(const CVector3f& inPos, const CStateManager& mgr) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (item->GetTexture().IsLoaded()) {
|
if (item->GetTexture().IsLoaded()) {
|
||||||
item->GetTexture()->Load(GX_TEXMAP0, CTexture::kCM_Repeat);
|
TToken< CTexture > tok = item->GetTexture();
|
||||||
|
tok->Load(GX_TEXMAP0, CTexture::kCM_Repeat);
|
||||||
float f1;
|
float f1;
|
||||||
if (close_enough(acos, 0.f)) {
|
if (close_enough(acos, 0.f)) {
|
||||||
f1 = 0.f;
|
f1 = 0.f;
|
||||||
|
@ -182,31 +177,23 @@ void CVisorFlare::Render(const CVector3f& inPos, const CStateManager& mgr) const
|
||||||
|
|
||||||
void CVisorFlare::DrawDirect(const CColor& color, float f1, float f2) const {
|
void CVisorFlare::DrawDirect(const CColor& color, float f1, float f2) const {
|
||||||
CColor kcolor = color;
|
CColor kcolor = color;
|
||||||
kcolor.SetAlpha(kcolor.GetAlpha() * x24_);
|
kcolor.SetAlpha(kcolor.GetRed() * x24_);
|
||||||
CGX::SetTevKColor(GX_KCOLOR0, *reinterpret_cast< const GXColor* >(&kcolor));
|
CGX::SetTevKColor(GX_KCOLOR0, kcolor.GetGXColor());
|
||||||
CGX::Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, 4);
|
CGX::Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, 4);
|
||||||
GXPosition3f32(f1 - f2, 0.f, f2 + f1);
|
GXPosition3f32(f1 - f2, 0.f, f2 + f1);
|
||||||
GXTexCoord2f32(0.f, 1.f);
|
GXTexCoord2f32(0.f, 1.f);
|
||||||
GXPosition3f32(f2 + f1, 0.f, f2 - f1);
|
GXPosition3f32(f1 + f2, 0.f, f2 - f1);
|
||||||
GXTexCoord2f32(1.f, 1.f);
|
GXTexCoord2f32(1.f, 1.f);
|
||||||
GXPosition3f32(-(f2 - f1), 0.f, -(f2 - f1));
|
GXPosition3f32(-(f1 + f2), 0.f, -(f2 - f1));
|
||||||
GXTexCoord2f32(0.f, 0.f);
|
GXTexCoord2f32(0.f, 0.f);
|
||||||
GXPosition3f32(-f1 + f2, 0.f, -f2 - f1);
|
GXPosition3f32(-f1 + f2, 0.f, -f2 - f1);
|
||||||
GXTexCoord2f32(1.f, 0.f);
|
GXTexCoord2f32(1.f, 0.f);
|
||||||
CGX::End();
|
CGX::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
// fake but close
|
|
||||||
static inline CColor ModulateAlpha(const CColor& color, float alphaMod) {
|
|
||||||
uchar a = CCast::ToUint8(static_cast< float >(color.GetAlphau8()) * alphaMod);
|
|
||||||
CColor result = color;
|
|
||||||
result.SetAlpha(a);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CVisorFlare::DrawStreamed(const CColor& color, float f1, float f2) const {
|
void CVisorFlare::DrawStreamed(const CColor& color, float f1, float f2) const {
|
||||||
CGraphics::StreamBegin(kP_TriangleStrip);
|
CGraphics::StreamBegin(kP_TriangleStrip);
|
||||||
CGraphics::StreamColor(ModulateAlpha(color, x24_));
|
CGraphics::StreamColor(color.WithAlphaModulatedBy(x24_));
|
||||||
CGraphics::StreamTexcoord(0.f, 1.f);
|
CGraphics::StreamTexcoord(0.f, 1.f);
|
||||||
CGraphics::StreamVertex(f1 - f2, 0.f, f2 + f1);
|
CGraphics::StreamVertex(f1 - f2, 0.f, f2 + f1);
|
||||||
CGraphics::StreamTexcoord(1.f, 1.f);
|
CGraphics::StreamTexcoord(1.f, 1.f);
|
||||||
|
|
|
@ -24,12 +24,6 @@ void CFaceplateDecoration::Update(float dt, const CStateManager& stateMgr) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// fake but close
|
|
||||||
static inline CColor ChangeAlpha(CColor color, float alpha) {
|
|
||||||
color.SetAlpha(CCast::ToUint8(alpha * 255.f));
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CFaceplateDecoration::Draw(const CStateManager& stateMgr) const {
|
void CFaceplateDecoration::Draw(const CStateManager& stateMgr) const {
|
||||||
if (x4_tex.valid() && x4_tex->IsLoaded()) {
|
if (x4_tex.valid() && x4_tex->IsLoaded()) {
|
||||||
CTexture* texture = TToken< CTexture >(*x4_tex).GetT();
|
CTexture* texture = TToken< CTexture >(*x4_tex).GetT();
|
||||||
|
@ -37,7 +31,7 @@ void CFaceplateDecoration::Draw(const CStateManager& stateMgr) const {
|
||||||
if (!close_enough(alpha, 0.f)) {
|
if (!close_enough(alpha, 0.f)) {
|
||||||
CCameraFilterPass::DrawFilter(CCameraFilterPass::kFT_Blend,
|
CCameraFilterPass::DrawFilter(CCameraFilterPass::kFT_Blend,
|
||||||
CCameraFilterPass::kFS_FullscreenQuarters,
|
CCameraFilterPass::kFS_FullscreenQuarters,
|
||||||
ChangeAlpha(CColor::White(), alpha), texture, 1.f);
|
CColor::White().WithAlphaOf(alpha), texture, 1.f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue