CGuiFrame & Model fixes; CModel::Draw impl; Document CModelFlags bits

This commit is contained in:
Luke Street 2022-03-05 19:26:52 -05:00
parent b3daf4a527
commit 6c3e74b93e
25 changed files with 135 additions and 192 deletions

View File

@ -48,7 +48,7 @@ void CCubeMaterial::SetCurrent(const CModelFlags& flags, const CCubeSurface& sur
}
u32 texCount = SBig(*reinterpret_cast<const u32*>(materialDataCur + 4));
if ((flags.x2_flags & 4) != 0) { // render without texture lock
if (flags.x2_flags & CModelFlagBits::NoTextureLock) {
materialDataCur += (2 + texCount) * 4;
} else {
materialDataCur += 8;
@ -259,16 +259,16 @@ void CCubeMaterial::SetupBlendMode(u32 blendFactors, const CModelFlags& flags, b
aurora::gfx::set_blend_mode(ERglBlendMode::Blend, newSrcFactor, newDstFactor, ERglLogicOp::Clear);
}
void CCubeMaterial::HandleDepth(u16 modelFlags, CCubeMaterialFlags matFlags) {
void CCubeMaterial::HandleDepth(CModelFlagsFlags modelFlags, CCubeMaterialFlags matFlags) {
ERglEnum func = ERglEnum::Never;
if ((modelFlags & 0x1) == 0) {
if (!(modelFlags & CModelFlagBits::DepthTest)) {
func = ERglEnum::Always;
} else if ((modelFlags & 0x8) != 0) {
func = (modelFlags & 0x10) != 0 ? ERglEnum::Greater : ERglEnum::GEqual;
} else if (modelFlags & CModelFlagBits::DepthGreater) {
func = modelFlags & CModelFlagBits::DepthNonInclusive ? ERglEnum::Greater : ERglEnum::GEqual;
} else {
func = (modelFlags & 0x10) != 0 ? ERglEnum::Less : ERglEnum::LEqual;
func = modelFlags & CModelFlagBits::DepthNonInclusive ? ERglEnum::Less : ERglEnum::LEqual;
}
bool depthWrite = (modelFlags & 0x2) != 0 && matFlags & CCubeMaterialFlagBits::fDepthWrite;
bool depthWrite = modelFlags & CModelFlagBits::DepthUpdate && matFlags & CCubeMaterialFlagBits::fDepthWrite;
aurora::gfx::set_depth_mode(true, func, depthWrite);
}

View File

@ -7,12 +7,12 @@
#include "CToken.hpp"
#include "GCNTypes.hpp"
#include "Graphics/CTexture.hpp"
#include "Graphics/CModel.hpp"
#include "IObjectStore.hpp"
namespace metaforce {
class CCubeModel;
class CCubeSurface;
struct CModelFlags;
enum class CCubeMaterialFlagBits : u32 {
fKonstValues = 0x8,
@ -93,7 +93,7 @@ private:
void SetCurrentBlack();
static void SetupBlendMode(u32 blendFactors, const CModelFlags& flags, bool alphaTest);
static void HandleDepth(u16 modelFlags, CCubeMaterialFlags matFlags);
static void HandleDepth(CModelFlagsFlags modelFlags, CCubeMaterialFlags matFlags);
static u32 HandleColorChannels(u32 chanCount, u32 firstChan);
static void HandleTev(u32 tevCur, const u8* materialDataCur, const u32* texMapTexCoordFlags, bool shadowMapsEnabled);
static u32 HandleAnimatedUV(const u32* uvAnim, u32 texMtx, u32 pttTexMtx);

View File

@ -377,7 +377,7 @@ u32 CCubeRenderer::GetFPS() { return CGraphics::GetFPS(); }
void CCubeRenderer::CacheReflection(IRenderer::TReflectionCallback cb, void* ctx, bool clearAfter) {}
void CCubeRenderer::DrawSpaceWarp(const zeus::CVector3f& pt, float strength) {}
void CCubeRenderer::DrawThermalModel(const CModel& model, const zeus::CColor& multCol, const zeus::CColor& addCol,
TVectorRef positions, TVectorRef normals, CModelFlags flags) {}
TVectorRef positions, TVectorRef normals, const CModelFlags& flags) {}
void CCubeRenderer::DrawModelDisintegrate(const CModel& model, const CTexture& tex, const zeus::CColor& color,
TVectorRef positions, TVectorRef normals) {}
void CCubeRenderer::DrawModelFlat(const CModel& model, const CModelFlags& flags, bool unsortedOnly) {}

View File

@ -179,7 +179,7 @@ public:
void CacheReflection(TReflectionCallback cb, void* ctx, bool clearAfter) override;
void DrawSpaceWarp(const zeus::CVector3f& pt, float strength) override;
void DrawThermalModel(const CModel& model, const zeus::CColor& multCol, const zeus::CColor& addCol,
TVectorRef positions, TVectorRef normals, CModelFlags flags) override;
TVectorRef positions, TVectorRef normals, const CModelFlags& flags) override;
void DrawModelDisintegrate(const CModel& model, const CTexture& tex, const zeus::CColor& color, TVectorRef positions,
TVectorRef normals) override;
void DrawModelFlat(const CModel& model, const CModelFlags& flags, bool unsortedOnly) override;

View File

@ -249,12 +249,28 @@ void CModel::Touch(u32 matIdx) {
}
}
void CModel::Draw(CModelFlags flags) const {}
void CModel::Draw(CModelFlags flags) {
if (flags.x2_flags & CModelFlagBits::DrawNormal) {
x28_modelInst->DrawNormal(nullptr, nullptr, ESurfaceSelection::All);
}
CCubeMaterial::ResetCachedMaterials();
MoveToThisFrameList();
VerifyCurrentShader(flags.x1_matSetIdx);
x28_modelInst->Draw(flags);
}
void CModel::Draw(TVectorRef positions, TVectorRef normals, CModelFlags flags) {}
void CModel::Draw(TVectorRef positions, TVectorRef normals, const CModelFlags& flags) {
if (flags.x2_flags & CModelFlagBits::DrawNormal) {
x28_modelInst->DrawNormal(positions, normals, ESurfaceSelection::All);
}
CCubeMaterial::ResetCachedMaterials();
MoveToThisFrameList();
VerifyCurrentShader(flags.x1_matSetIdx);
x28_modelInst->Draw(positions, normals, flags);
}
void CModel::DrawSortedParts(CModelFlags flags) {
if ((flags.x2_flags & 0x20) != 0) {
if (flags.x2_flags & CModelFlagBits::DrawNormal) {
x28_modelInst->DrawNormal(nullptr, nullptr, ESurfaceSelection::Sorted);
}
CCubeMaterial::ResetCachedMaterials();
@ -264,7 +280,7 @@ void CModel::DrawSortedParts(CModelFlags flags) {
}
void CModel::DrawUnsortedParts(CModelFlags flags) {
if ((flags.x2_flags & 0x20) != 0) {
if (flags.x2_flags & CModelFlagBits::DrawNormal) {
x28_modelInst->DrawNormal(nullptr, nullptr, ESurfaceSelection::Unsorted);
}
CCubeMaterial::ResetCachedMaterials();

View File

@ -13,6 +13,17 @@ namespace metaforce {
class CCubeSurface;
class CCubeMaterial;
enum class CModelFlagBits : u16 {
DepthTest = 0x1,
DepthUpdate = 0x2,
NoTextureLock = 0x4,
DepthGreater = 0x8,
DepthNonInclusive = 0x10,
DrawNormal = 0x20,
Unknown1 = 0x40,
};
using CModelFlagsFlags = Flags<CModelFlagBits>;
struct CModelFlags {
/**
* 2: add color
@ -22,14 +33,7 @@ struct CModelFlags {
*/
u8 x0_blendMode = 0;
u8 x1_matSetIdx = 0;
/**
* 0x1: depth equal
* 0x2: depth update
* 0x4: render without texture lock
* 0x8: depth greater
* 0x10: depth non-inclusive
*/
u16 x2_flags = 0;
CModelFlagsFlags x2_flags{};
/**
* Set into kcolor slot specified by material
*/
@ -38,6 +42,8 @@ struct CModelFlags {
constexpr CModelFlags() = default;
constexpr CModelFlags(u8 blendMode, u8 shadIdx, u16 flags, const zeus::CColor& col)
: x0_blendMode(blendMode), x1_matSetIdx(shadIdx), x2_flags(flags), x4_color(col) {}
constexpr CModelFlags(u8 blendMode, u8 shadIdx, CModelFlagsFlags flags, const zeus::CColor& col)
: x0_blendMode(blendMode), x1_matSetIdx(shadIdx), x2_flags(flags), x4_color(col) {}
bool operator==(const CModelFlags& other) const {
return x0_blendMode == other.x0_blendMode && x1_matSetIdx == other.x1_matSetIdx && x2_flags == other.x2_flags &&
@ -92,8 +98,8 @@ public:
void RemoveFromList();
void VerifyCurrentShader(u32 matIdx);
void Touch(u32 matIdx);
void Draw(CModelFlags flags) const;
void Draw(TVectorRef positions, TVectorRef normals, CModelFlags flags);
void Draw(CModelFlags flags);
void Draw(TVectorRef positions, TVectorRef normals, const CModelFlags& flags);
void DrawSortedParts(CModelFlags flags);
void DrawUnsortedParts(CModelFlags flags);
bool IsLoaded(u32 matIdx);

View File

@ -87,7 +87,7 @@ public:
virtual void CacheReflection(TReflectionCallback cb, void* ctx, bool clearAfter) = 0;
virtual void DrawSpaceWarp(const zeus::CVector3f& pt, float strength) = 0;
virtual void DrawThermalModel(const CModel& model, const zeus::CColor& multCol, const zeus::CColor& addCol,
TVectorRef positions, TVectorRef normals, CModelFlags flags) = 0;
TVectorRef positions, TVectorRef normals, const CModelFlags& flags) = 0;
virtual void DrawModelDisintegrate(const CModel& model, const CTexture& tex, const zeus::CColor& color,
TVectorRef positions, TVectorRef normals) = 0;
virtual void DrawModelFlat(const CModel& model, const CModelFlags& flags, bool unsortedOnly) = 0;

View File

@ -502,7 +502,7 @@ void CCompoundTargetReticle::Draw(const CStateManager& mgr, bool hideLockon) {
}
void CCompoundTargetReticle::DrawGrapplePoint(const CScriptGrapplePoint& point, float t, const CStateManager& mgr,
const zeus::CMatrix3f& rot, bool zEqual) const {
const zeus::CMatrix3f& rot, bool zEqual) {
zeus::CVector3f orbitPos = point.GetOrbitPosition(mgr);
zeus::CColor color;
@ -524,7 +524,7 @@ void CCompoundTargetReticle::DrawGrapplePoint(const CScriptGrapplePoint& point,
}
void CCompoundTargetReticle::DrawGrappleGroup(const zeus::CMatrix3f& rot, const CStateManager& mgr,
bool hideLockon) const {
bool hideLockon) {
if (x28_noDrawTicks > 0) {
return;
}
@ -569,7 +569,7 @@ void CCompoundTargetReticle::DrawGrappleGroup(const zeus::CMatrix3f& rot, const
}
}
void CCompoundTargetReticle::DrawCurrLockOnGroup(const zeus::CMatrix3f& rot, const CStateManager& mgr) const {
void CCompoundTargetReticle::DrawCurrLockOnGroup(const zeus::CMatrix3f& rot, const CStateManager& mgr) {
if (x28_noDrawTicks > 0) {
return;
}
@ -677,7 +677,7 @@ void CCompoundTargetReticle::DrawCurrLockOnGroup(const zeus::CMatrix3f& rot, con
1.f / x10c_currGroupInterp.GetFactor() * g_tweakTargeting->GetOuterBeamSquaresScale());
zeus::CMatrix3f outerBeamXf = rot * scale;
for (int i = 0; i < 9; ++i) {
const SOuterItemInfo& info = xe0_outerBeamIconSquares[i];
SOuterItemInfo& info = xe0_outerBeamIconSquares[i];
if (info.x0_model.IsLoaded()) {
zeus::CTransform modelXf(lockBreakXf * outerBeamXf * zeus::CMatrix3f::RotateY(info.x10_rotAng),
x10c_currGroupInterp.GetTargetPositionWorld());
@ -925,7 +925,7 @@ void CCompoundTargetReticle::DrawNextLockOnGroup(const zeus::CMatrix3f& rot, con
}
}
void CCompoundTargetReticle::DrawOrbitZoneGroup(const zeus::CMatrix3f& rot, const CStateManager& mgr) const {
void CCompoundTargetReticle::DrawOrbitZoneGroup(const zeus::CMatrix3f& rot, const CStateManager& mgr) {
if (x28_noDrawTicks > 0) {
return;
}

View File

@ -133,7 +133,7 @@ private:
SScanReticuleRenderer m_scanRetRenderer;
void DrawGrapplePoint(const CScriptGrapplePoint& point, float t, const CStateManager& mgr, const zeus::CMatrix3f& rot,
bool zEqual) const;
bool zEqual);
public:
explicit CCompoundTargetReticle(const CStateManager&);
@ -146,10 +146,10 @@ public:
void UpdateNextLockOnGroup(float, const CStateManager&);
void UpdateOrbitZoneGroup(float, const CStateManager&);
void Draw(const CStateManager&, bool hideLockon);
void DrawGrappleGroup(const zeus::CMatrix3f& rot, const CStateManager&, bool) const;
void DrawCurrLockOnGroup(const zeus::CMatrix3f& rot, const CStateManager&) const;
void DrawGrappleGroup(const zeus::CMatrix3f& rot, const CStateManager&, bool);
void DrawCurrLockOnGroup(const zeus::CMatrix3f& rot, const CStateManager&);
void DrawNextLockOnGroup(const zeus::CMatrix3f& rot, const CStateManager&);
void DrawOrbitZoneGroup(const zeus::CMatrix3f& rot, const CStateManager&) const;
void DrawOrbitZoneGroup(const zeus::CMatrix3f& rot, const CStateManager&);
void UpdateTargetParameters(CTargetReticleRenderState&, const CStateManager&);
float CalculateRadiusWorld(const CActor&, const CStateManager&) const;
zeus::CVector3f CalculatePositionWorld(const CActor&, const CStateManager&) const;

View File

@ -45,42 +45,36 @@ void CGuiFrame::SortDrawOrder() {
}
void CGuiFrame::EnableLights(u32 lights) const {
std::vector<CLight> lightsOut;
lightsOut.reserve(m_indexedLights.size() + 1);
CGraphics::DisableAllLights();
zeus::CColor ambColor(zeus::skBlack);
ERglLight lightId = ERglLight::Zero;
int idx = 0;
int enabledLights = 0;
for (CGuiLight* light : m_indexedLights) {
if (!light || !light->GetIsVisible()) {
if (light == nullptr || !light->GetIsVisible()) {
++reinterpret_cast<std::underlying_type_t<ERglLight>&>(lightId);
++idx;
continue;
}
if ((lights & (1 << idx)) != 0) {
// const zeus::CColor& geomCol = light->GetGeometryColor();
// if (geomCol.r || geomCol.g || geomCol.b)
//{
// CGraphics::LoadLight(lightId, light->BuildLight());
lightsOut.push_back(light->BuildLight());
CGraphics::EnableLight(lightId);
//}
const zeus::CColor& geomCol = light->GetGeometryColor();
if (geomCol.r() != 0.f || geomCol.g() != 0.f || geomCol.b() != 0.f) {
CGraphics::LoadLight(lightId, light->BuildLight());
CGraphics::EnableLight(lightId);
}
// accumulate ambient color
ambColor += light->GetAmbientLightColor();
++enabledLights;
}
++reinterpret_cast<std::underlying_type_t<ERglLight>&>(lightId);
++idx;
}
if (lightsOut.empty()) {
// CGraphics::SetAmbientColor(zeus::skWhite);
lightsOut.push_back(CLight::BuildLocalAmbient(zeus::skZero3f, zeus::skWhite));
if (enabledLights == 0) {
CGraphics::SetAmbientColor(zeus::skWhite);
} else {
// CGraphics::SetAmbientColor(ambColor);
lightsOut.push_back(CLight::BuildLocalAmbient(zeus::skZero3f, ambColor));
CGraphics::SetAmbientColor(ambColor);
}
// TODO model.ActivateLights(lightsOut);
}
void CGuiFrame::DisableLights() const { CGraphics::DisableAllLights(); }

View File

@ -10,9 +10,9 @@ namespace metaforce {
CGuiModel::CGuiModel(const CGuiWidgetParms& parms, CSimplePool* sp, CAssetId modelId, u32 lightMask, bool flag)
: CGuiWidget(parms), xc8_modelId(modelId), xcc_lightMask(lightMask) {
if (!flag || !modelId.IsValid() || parms.x0_frame->GetGuiSys().GetUsageMode() == CGuiSys::EUsageMode::Two)
if (!flag || !modelId.IsValid() || parms.x0_frame->GetGuiSys().GetUsageMode() == CGuiSys::EUsageMode::Two) {
return;
}
xb8_model = sp->GetObj({SBIG('CMDL'), modelId});
}
@ -23,23 +23,17 @@ bool CGuiModel::GetIsFinishedLoadingWidgetSpecific() {
if (!xb8_model.IsLoaded()) {
return false;
}
//xb8_model->GetInstance().Touch(0);
return true; //xb8_model->IsLoaded(0);
xb8_model->Touch(0);
return xb8_model->IsLoaded(0);
}
void CGuiModel::Touch() {
return;
CModel* const model = xb8_model.GetObj();
if (model == nullptr) {
return;
if (CModel* const model = xb8_model.GetObj()) {
model->Touch(0);
}
model->Touch(0);
}
void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) {
return;
CGraphics::SetModelMatrix(x34_worldXF);
if (!xb8_model) {
return;
@ -48,7 +42,7 @@ void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) {
return;
}
CModel* const model = xb8_model.GetObj();
if (!model) {
if (model == nullptr) {
return;
}
@ -56,58 +50,48 @@ void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) {
SCOPED_GRAPHICS_DEBUG_GROUP(fmt::format(FMT_STRING("CGuiModel::Draw {}"), m_name).c_str(), zeus::skCyan);
zeus::CColor moduCol = xa8_color2;
moduCol.a() *= parms.x0_alphaMod;
// TODO xb0_frame->EnableLights(xcc_lightMask, model->GetInstance());
// if (xb6_29_cullFaces)
// CGraphics::SetCullMode(ERglCullMode::Front);
xb0_frame->EnableLights(xcc_lightMask);
if (xb6_29_cullFaces) {
CGraphics::SetCullMode(ERglCullMode::Front);
}
switch (xac_drawFlags) {
case EGuiModelDrawFlags::Shadeless: {
CModelFlags flags(0, 0, 3, zeus::skWhite);
// flags.m_extendedShader = EExtendedShader::Flat;
constexpr CModelFlags flags(0, 0, 3, zeus::skWhite);
model->Draw(flags);
break;
}
case EGuiModelDrawFlags::Opaque: {
CModelFlags flags(1, 0, 3, moduCol);
// flags.m_extendedShader = EExtendedShader::Lighting;
model->Draw(flags);
break;
}
case EGuiModelDrawFlags::Alpha: {
CModelFlags flags(5, 0, (u32(xb7_24_depthWrite) << 1) | u32(xb6_31_depthTest), moduCol);
// flags.m_noCull = !xb6_29_cullFaces;
// flags.m_noZWrite = !xb7_24_depthWrite;
model->Draw(flags);
break;
}
case EGuiModelDrawFlags::Additive: {
CModelFlags flags(7, 0, (u32(xb7_24_depthWrite) << 1) | u32(xb6_31_depthTest), moduCol);
// flags.m_noCull = !xb6_29_cullFaces;
// flags.m_noZWrite = !xb7_24_depthWrite;
// flags.m_depthGreater = xb6_30_depthGreater;
model->Draw(flags);
break;
}
case EGuiModelDrawFlags::AlphaAdditiveOverdraw: {
CModelFlags flags(5, 0, xb6_31_depthTest, moduCol);
// flags.m_noCull = !xb6_29_cullFaces;
// flags.m_noZWrite = !xb7_24_depthWrite;
const CModelFlags flags(5, 0, (u32(xb6_30_depthGreater) << 4) | u32(xb6_31_depthTest), moduCol);
model->Draw(flags);
flags.x0_blendMode = 7;
flags.x1_matSetIdx = 0;
flags.x2_flags = (u32(xb7_24_depthWrite) << 1) | u32(xb6_31_depthTest);
flags.x4_color = moduCol;
// flags.m_noCull = !xb6_29_cullFaces;
model->Draw(flags);
const CModelFlags overdrawFlags(
8, 0, (u32(xb6_30_depthGreater) << 4) | (u32(xb7_24_depthWrite) << 1) | u32(xb6_31_depthTest), moduCol);
model->Draw(overdrawFlags);
break;
}
default:
break;
}
// if (xb6_29_cullFaces)
// CGraphics::SetCullMode(ERglCullMode::None);
if (xb6_29_cullFaces) {
CGraphics::SetCullMode(ERglCullMode::None);
}
xb0_frame->DisableLights();
}
@ -115,15 +99,16 @@ void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) {
}
bool CGuiModel::TestCursorHit(const zeus::CMatrix4f& vp, const zeus::CVector2f& point) const {
if (!xb8_model || !xb8_model.IsLoaded())
if (!xb8_model || !xb8_model.IsLoaded()) {
return false;
}
return xb8_model->GetAABB().projectedPointTest(vp * x34_worldXF.toMatrix4f(), point);
}
std::shared_ptr<CGuiWidget> CGuiModel::Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp) {
CGuiWidgetParms parms = ReadWidgetHeader(frame, in);
CAssetId model = in.Get<CAssetId>();
auto model = in.Get<CAssetId>();
in.ReadLong();
u32 lightMask = in.ReadLong();

View File

@ -66,7 +66,7 @@ void COrbitPointMarker::Update(float dt, const CStateManager& mgr) {
}
}
void COrbitPointMarker::Draw(const CStateManager& mgr) const {
void COrbitPointMarker::Draw(const CStateManager& mgr) {
if ((x1c_lastFreeOrbit || x20_interpTimer > 0.f) && g_tweakTargeting->DrawOrbitPoint() &&
x28_orbitPointModel.IsLoaded()) {
SCOPED_GRAPHICS_DEBUG_GROUP("COrbitPointMarker::Draw", zeus::skCyan);

View File

@ -24,6 +24,6 @@ public:
COrbitPointMarker();
bool CheckLoadComplete() const;
void Update(float dt, const CStateManager& mgr);
void Draw(const CStateManager& mgr) const;
void Draw(const CStateManager& mgr);
};
} // namespace metaforce

View File

@ -56,7 +56,7 @@ int CPlayerVisor::FindCachedInactiveScanTarget(TUniqueId uid) const {
return -1;
}
bool CPlayerVisor::DrawScanObjectIndicators(const CStateManager& mgr) const {
bool CPlayerVisor::DrawScanObjectIndicators(const CStateManager& mgr) {
if (!x124_scanIconNoncritical.IsLoaded() || !x130_scanIconCritical.IsLoaded())
return false;
if (!x114_scanShield.IsLoaded())
@ -89,7 +89,7 @@ bool CPlayerVisor::DrawScanObjectIndicators(const CStateManager& mgr) const {
if (!act->GetMaterialList().HasMaterial(EMaterialTypes::Scannable))
continue;
const CScannableObjectInfo* scanInfo = act->GetScannableObjectInfo();
const CModel* useModel;
CModel* useModel;
const zeus::CColor* useColor;
const zeus::CColor* useDimColor;
if (scanInfo->IsImportant()) {

View File

@ -67,7 +67,7 @@ class CPlayerVisor {
int FindEmptyInactiveScanTarget() const;
int FindCachedInactiveScanTarget(TUniqueId uid) const;
bool DrawScanObjectIndicators(const CStateManager& mgr) const;
bool DrawScanObjectIndicators(const CStateManager& mgr);
void UpdateScanObjectIndicators(const CStateManager& mgr, float dt);
void UpdateScanWindow(float dt, const CStateManager& mgr);
EScanWindowState GetDesiredScanWindowState(const CStateManager& mgr) const;

View File

@ -59,9 +59,7 @@ void CAtomicAlpha::Render(CStateManager& mgr) {
GetTransform() * GetScaledLocatorTransform(bomb.x0_locatorName) *
zeus::CTransform::Scale(
std::min(1.f, std::max(0.f, bomb.x14_scaleTime - x570_bombReappearDelay) / x570_bombReappearDelay));
CModelFlags flags;
flags.x2_flags = 1 | 2;
flags.x4_color = zeus::skWhite;
CModelFlags flags{0, 0, 3, zeus::skWhite};
x690_bombModel.Render(mgr, locatorXf, x90_actorLights.get(), flags);
}
}

View File

@ -617,9 +617,9 @@ void CRidley::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) {
CPlayerState::EPlayerVisor r28 = mgr.GetPlayerState()->GetActiveVisor(mgr);
bool atLastMat = GetModelData()->GetNumMaterialSets() == (matSet + 1);
if (r28 == CPlayerState::EPlayerVisor::Thermal && atLastMat) {
xb4_drawFlags.x2_flags |= 0x40;
xb4_drawFlags.x2_flags |= CModelFlagBits::Unknown1;
} else {
xb4_drawFlags.x2_flags &= 0x40;
xb4_drawFlags.x2_flags &= CModelFlagBits::Unknown1;
}
xb4_drawFlags.x1_matSetIdx = matSet;

View File

@ -108,10 +108,7 @@ void CSeedling::Think(float dt, CStateManager& mgr) {
void CSeedling::Render(CStateManager& mgr) {
if (x400_25_alive && x6bc_spikeData) {
const size_t index = x722_24_renderOnlyClusterA ? 0 : size_t(x722_25_curNeedleCluster);
CModelFlags flags;
flags.x2_flags = 3;
flags.x4_color = zeus::skWhite;
CModelFlags flags{0, 0, 3, zeus::skWhite};
for (const auto& sv : skNeedleLocators[index]) {
x6bc_spikeData->Render(mgr, GetLctrTransform(sv), x90_actorLights.get(), flags);
}

View File

@ -157,7 +157,7 @@ void CDecal::RenderQuad(CQuadDecal& decal, const SQuadDescr& desc) const {
}
void CDecal::RenderMdl() {
const CDecalDescription& desc = *x0_description;
CDecalDescription& desc = *x0_description;
zeus::CColor color = zeus::skWhite;
zeus::CVector3f dmop;
zeus::CTransform rotXf;

View File

@ -149,11 +149,13 @@ void CScriptActor::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum)
if (x2e2_24_noThermalHotZ && xe6_27_thermalVisorFlags == 2) {
if (mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::Thermal) {
xb4_drawFlags.x2_flags &= ~3; // Disable Z test/update
// xb4_drawFlags.m_noZTest = true;
// Disable Z test/update
xb4_drawFlags.x2_flags &= CModelFlagBits::DepthTest;
xb4_drawFlags.x2_flags &= CModelFlagBits::DepthUpdate;
} else {
xb4_drawFlags.x2_flags |= 3; // Enable Z test/update
// xb4_drawFlags.m_noZTest = false;
// Enable Z test/update
xb4_drawFlags.x2_flags |= CModelFlagBits::DepthTest;
xb4_drawFlags.x2_flags |= CModelFlagBits::DepthUpdate;
}
}

View File

@ -109,83 +109,38 @@ void CScriptColorModulate::Think(float dt, CStateManager& mgr) {
}
CModelFlags CScriptColorModulate::CalculateFlags(const zeus::CColor& col) const {
CModelFlags ret;
if (x54_28_depthBackwards) {
if (x48_blendMode == EBlendMode::Alpha) {
ret.x0_blendMode = 5;
ret.x1_matSetIdx = 0;
ret.x2_flags = x54_26_depthCompare << 0 | x54_27_depthUpdate << 1 | 0x8;
ret.x4_color = col;
return {5, 0, static_cast<u16>(x54_26_depthCompare << 0 | x54_27_depthUpdate << 1 | 0x8), col};
} else if (x48_blendMode == EBlendMode::Additive) {
ret.x0_blendMode = 7;
ret.x1_matSetIdx = 0;
ret.x2_flags = x54_26_depthCompare << 0 | x54_27_depthUpdate << 1 | 0x8;
ret.x4_color = col;
return {7, 0, static_cast<u16>(x54_26_depthCompare << 0 | x54_27_depthUpdate << 1 | 0x8), col};
} else if (x48_blendMode == EBlendMode::Additive2) {
ret.x0_blendMode = 8;
ret.x1_matSetIdx = 0;
ret.x2_flags = x54_26_depthCompare << 0 | x54_27_depthUpdate << 1 | 0x8;
ret.x4_color = col;
return {8, 0, static_cast<u16>(x54_26_depthCompare << 0 | x54_27_depthUpdate << 1 | 0x8), col};
} else if (x48_blendMode == EBlendMode::Opaque) {
ret.x0_blendMode = 1;
ret.x1_matSetIdx = 0;
ret.x2_flags = x54_26_depthCompare << 0 | x54_27_depthUpdate << 1 | 0x8;
ret.x4_color = col;
return {1, 0, static_cast<u16>(x54_26_depthCompare << 0 | x54_27_depthUpdate << 1 | 0x8), col};
} else if (x48_blendMode == EBlendMode::OpaqueAdd) {
ret.x0_blendMode = 2;
ret.x1_matSetIdx = 0;
ret.x2_flags = x54_26_depthCompare << 0 | x54_27_depthUpdate << 1 | 0x8;
// ret.addColor = col;
} else {
ret.x2_flags = 3;
ret.x4_color = zeus::skWhite;
return {2, 0, static_cast<u16>(x54_26_depthCompare << 0 | x54_27_depthUpdate << 1 | 0x8), col};
}
} else {
if (x48_blendMode == EBlendMode::Alpha) {
if (col == zeus::skWhite) {
ret.x0_blendMode = 0;
ret.x1_matSetIdx = 0;
ret.x2_flags = x54_26_depthCompare << 0 | x54_27_depthUpdate << 1;
ret.x4_color = zeus::skWhite;
} else {
ret.x0_blendMode = 5;
ret.x1_matSetIdx = 0;
ret.x2_flags = x54_26_depthCompare << 0 | x54_27_depthUpdate << 1;
ret.x4_color = col;
}
} else if (x48_blendMode == EBlendMode::Additive) {
ret.x0_blendMode = 7;
ret.x1_matSetIdx = 0;
ret.x2_flags = x54_26_depthCompare << 0 | x54_27_depthUpdate << 1;
ret.x4_color = col;
} else if (x48_blendMode == EBlendMode::Additive2) {
ret.x0_blendMode = 8;
ret.x1_matSetIdx = 0;
ret.x2_flags = x54_26_depthCompare << 0 | x54_27_depthUpdate << 1;
ret.x4_color = col;
} else if (x48_blendMode == EBlendMode::Opaque) {
if (col == zeus::skWhite) {
ret.x0_blendMode = 0;
ret.x1_matSetIdx = 0;
ret.x2_flags = x54_26_depthCompare << 0 | x54_27_depthUpdate << 1;
ret.x4_color = zeus::skWhite;
} else {
ret.x0_blendMode = 1;
ret.x1_matSetIdx = 0;
ret.x2_flags = x54_26_depthCompare << 0 | x54_27_depthUpdate << 1;
ret.x4_color = col;
}
} else if (x48_blendMode == EBlendMode::OpaqueAdd) {
ret.x0_blendMode = 2;
ret.x1_matSetIdx = 0;
ret.x2_flags = x54_26_depthCompare << 0 | x54_27_depthUpdate << 1;
// ret.addColor = col;
} else if (x48_blendMode == EBlendMode::Alpha) {
if (col == zeus::skWhite) {
return {0, 0, static_cast<u16>(x54_26_depthCompare << 0 | x54_27_depthUpdate << 1), zeus::skWhite};
} else {
ret.x2_flags = 3;
ret.x4_color = zeus::skWhite;
return {5, 0, static_cast<u16>(x54_26_depthCompare << 0 | x54_27_depthUpdate << 1), col};
}
} else if (x48_blendMode == EBlendMode::Additive) {
return {7, 0, static_cast<u16>(x54_26_depthCompare << 0 | x54_27_depthUpdate << 1), col};
} else if (x48_blendMode == EBlendMode::Additive2) {
return {8, 0, static_cast<u16>(x54_26_depthCompare << 0 | x54_27_depthUpdate << 1), col};
} else if (x48_blendMode == EBlendMode::Opaque) {
if (col == zeus::skWhite) {
return {0, 0, static_cast<u16>(x54_26_depthCompare << 0 | x54_27_depthUpdate << 1), zeus::skWhite};
} else {
return {1, 0, static_cast<u16>(x54_26_depthCompare << 0 | x54_27_depthUpdate << 1), col};
}
} else if (x48_blendMode == EBlendMode::OpaqueAdd) {
return {2, 0, static_cast<u16>(x54_26_depthCompare << 0 | x54_27_depthUpdate << 1), col};
}
return ret;
return {0, 0, 3, zeus::skWhite};
}
void CScriptColorModulate::SetTargetFlags(CStateManager& stateMgr, const CModelFlags& flags) {

View File

@ -539,10 +539,7 @@ void CScriptGunTurret::Render(CStateManager& mgr) {
if (x4a4_extensionModel && x4f8_extensionT > 0.f) {
zeus::CTransform xf = GetTransform();
xf.origin = x4fc_extensionOffset + (x4f4_extensionRange * 0.5f * zeus::skDown);
CModelFlags flags;
flags.x2_flags = 3;
flags.x1_matSetIdx = 0;
flags.x4_color = zeus::skWhite;
CModelFlags flags{0, 0, 3, zeus::skWhite};
x4a4_extensionModel->Render(mgr, xf, x90_actorLights.get(), flags);
}
}

View File

@ -38,9 +38,7 @@ CScriptPickup::CScriptPickup(TUniqueId uid, std::string_view name, const CEntity
}
if (x278_delayTimer != 0.f) {
xb4_drawFlags = CModelFlags(5, 0, 3, zeus::CColor(1.f, 1.f, 1.f, 0.f));
xb4_drawFlags.x2_flags &= 0xFFFC;
xb4_drawFlags.x2_flags |= 1;
xb4_drawFlags = CModelFlags(5, 0, 1, zeus::CColor(1.f, 1.f, 1.f, 0.f));
}
}
@ -66,9 +64,7 @@ void CScriptPickup::Think(float dt, CStateManager& mgr) {
if (x268_fadeInTime != 0.f) {
if (x270_curTime < x268_fadeInTime) {
drawFlags = CModelFlags(5, 0, 3, zeus::CColor(1.f, x270_curTime / x268_fadeInTime));
drawFlags.x2_flags &= 0xFFFC;
drawFlags.x2_flags |= 1;
drawFlags = CModelFlags(5, 0, 1, zeus::CColor(1.f, x270_curTime / x268_fadeInTime));
} else {
x268_fadeInTime = 0.f;
}
@ -80,9 +76,7 @@ void CScriptPickup::Think(float dt, CStateManager& mgr) {
alpha = (x26c_lifeTime - x270_curTime) * 0.5f;
}
drawFlags = CModelFlags(5, 0, 3, zeus::CColor(1.f, alpha));
drawFlags.x2_flags &= 0xFFFC;
drawFlags.x2_flags |= 1;
drawFlags = CModelFlags(5, 0, 1, zeus::CColor(1.f, alpha));
}
xb4_drawFlags = drawFlags;

View File

@ -654,8 +654,8 @@ void CWorld::TouchSky() {
xb4_skyboxOverride.value()->Touch(0);
}
void CWorld::DrawSky(const zeus::CTransform& xf) const {
const CModel* model;
void CWorld::DrawSky(const zeus::CTransform& xf) {
CModel* model;
if (xa4_skyboxWorldLoaded)
model = xa4_skyboxWorldLoaded->GetObj();
else if (xb4_skyboxOverride)
@ -674,7 +674,6 @@ void CWorld::DrawSky(const zeus::CTransform& xf) const {
CGraphics::SetDepthRange(DEPTH_SKY, DEPTH_FAR);
CModelFlags flags(0, 0, 1, zeus::skWhite);
// flags.m_noZWrite = true;
model->Draw(flags);
CGraphics::SetDepthRange(DEPTH_WORLD, DEPTH_FAR);

View File

@ -227,7 +227,7 @@ public:
void Update(float dt);
void PreRender();
void TouchSky();
void DrawSky(const zeus::CTransform& xf) const;
void DrawSky(const zeus::CTransform& xf);
void StopGlobalSound(u16 id);
bool HasGlobalSound(u16 id) const;
void AddGlobalSound(const CSfxHandle& hnd);