Moves model flags to ModelAbstract.

Differential Revision: https://code.wildfiregames.com/D5146
This was SVN commit r27880.
This commit is contained in:
Vladislav Belov 2023-10-09 18:37:56 +00:00
parent 6ef27d2ffe
commit e2c5a62a19
8 changed files with 30 additions and 27 deletions

View File

@ -92,7 +92,7 @@ void CModel::CalcBounds()
void CModel::CalcStaticObjectBounds() void CModel::CalcStaticObjectBounds()
{ {
PROFILE2("CalcStaticObjectBounds"); PROFILE2("CalcStaticObjectBounds");
m_pModelDef->GetMaxBounds(nullptr, !(m_Flags & MODELFLAG_NOLOOPANIMATION), m_ObjectBounds); m_pModelDef->GetMaxBounds(nullptr, !(m_Flags & ModelFlag::NO_LOOP_ANIMATION), m_ObjectBounds);
} }
///////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -100,7 +100,7 @@ void CModel::CalcStaticObjectBounds()
void CModel::CalcAnimatedObjectBounds(CSkeletonAnimDef* anim, CBoundingBoxAligned& result) void CModel::CalcAnimatedObjectBounds(CSkeletonAnimDef* anim, CBoundingBoxAligned& result)
{ {
PROFILE2("CalcAnimatedObjectBounds"); PROFILE2("CalcAnimatedObjectBounds");
m_pModelDef->GetMaxBounds(anim, !(m_Flags & MODELFLAG_NOLOOPANIMATION), result); m_pModelDef->GetMaxBounds(anim, !(m_Flags & ModelFlag::NO_LOOP_ANIMATION), result);
} }
///////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -218,7 +218,7 @@ void CModel::ValidatePosition()
ENSURE(m_pModelDef->GetNumBones() == m_Anim->m_AnimDef->GetNumKeys()); ENSURE(m_pModelDef->GetNumBones() == m_Anim->m_AnimDef->GetNumKeys());
m_Anim->m_AnimDef->BuildBoneMatrices(m_AnimTime, m_BoneMatrices, !(m_Flags & MODELFLAG_NOLOOPANIMATION)); m_Anim->m_AnimDef->BuildBoneMatrices(m_AnimTime, m_BoneMatrices, !(m_Flags & ModelFlag::NO_LOOP_ANIMATION));
} }
else if (m_BoneMatrices) else if (m_BoneMatrices)
{ {
@ -265,7 +265,7 @@ void CModel::ValidatePosition()
objectHeight = cmpTerrain->GetExactGroundLevel(objTranslation.X, objTranslation.Z); objectHeight = cmpTerrain->GetExactGroundLevel(objTranslation.X, objTranslation.Z);
// Object height is incorrect for floating objects. We use water height instead. // Object height is incorrect for floating objects. We use water height instead.
if (m_Flags & MODELFLAG_FLOATONWATER) if (m_Flags & ModelFlag::FLOAT_ON_WATER)
{ {
CmpPtr<ICmpWaterManager> cmpWaterManager(m_Simulation, SYSTEM_ENTITY); CmpPtr<ICmpWaterManager> cmpWaterManager(m_Simulation, SYSTEM_ENTITY);
if (cmpWaterManager) if (cmpWaterManager)
@ -337,10 +337,10 @@ bool CModel::SetAnimation(CSkeletonAnim* anim, bool once)
if (anim) if (anim)
{ {
m_Flags &= ~MODELFLAG_NOLOOPANIMATION; m_Flags &= ~ModelFlag::NO_LOOP_ANIMATION;
if (once) if (once)
m_Flags |= MODELFLAG_NOLOOPANIMATION; m_Flags |= ModelFlag::NO_LOOP_ANIMATION;
// Not rigged or animation is not valid. // Not rigged or animation is not valid.
if (!m_BoneMatrices || !anim->m_AnimDef) if (!m_BoneMatrices || !anim->m_AnimDef)
@ -498,7 +498,7 @@ void CModel::AddFlagsRec(int flags)
{ {
m_Flags |= flags; m_Flags |= flags;
if (flags & MODELFLAG_IGNORE_LOS) if (flags & ModelFlag::IGNORE_LOS)
m_Material.AddShaderDefine(str_IGNORE_LOS, str_1); m_Material.AddShaderDefine(str_IGNORE_LOS, str_1);
for (size_t i = 0; i < m_Props.size(); ++i) for (size_t i = 0; i < m_Props.size(); ++i)
@ -508,7 +508,7 @@ void CModel::AddFlagsRec(int flags)
void CModel::RemoveShadowsRec() void CModel::RemoveShadowsRec()
{ {
m_Flags &= ~MODELFLAG_CASTSHADOWS; m_Flags &= ~ModelFlag::CAST_SHADOWS;
m_Material.AddShaderDefine(str_DISABLE_RECEIVE_SHADOWS, str_1); m_Material.AddShaderDefine(str_DISABLE_RECEIVE_SHADOWS, str_1);

View File

@ -34,13 +34,6 @@ class CSkeletonAnim;
class CSkeletonAnimDef; class CSkeletonAnimDef;
class CSimulation2; class CSimulation2;
#define MODELFLAG_CASTSHADOWS (1<<0)
#define MODELFLAG_NOLOOPANIMATION (1<<1)
#define MODELFLAG_SILHOUETTE_DISPLAY (1<<2)
#define MODELFLAG_SILHOUETTE_OCCLUDER (1<<3)
#define MODELFLAG_IGNORE_LOS (1<<4)
#define MODELFLAG_FLOATONWATER (1<<5)
// Holds world information for a particular instance of a model in the game. // Holds world information for a particular instance of a model in the game.
class CModel : public CModelAbstract class CModel : public CModelAbstract
{ {

View File

@ -30,6 +30,16 @@ class CModel;
class CModelDecal; class CModelDecal;
class CModelParticleEmitter; class CModelParticleEmitter;
namespace ModelFlag
{
static constexpr uint32_t CAST_SHADOWS{1 << 0};
static constexpr uint32_t NO_LOOP_ANIMATION{1 << 1};
static constexpr uint32_t SILHOUETTE_DISPLAY{1 << 2};
static constexpr uint32_t SILHOUETTE_OCCLUDER{1 << 3};
static constexpr uint32_t IGNORE_LOS{1 << 4};
static constexpr uint32_t FLOAT_ON_WATER{1 << 5};
} // namespace ModelFlag
/** /**
* Abstract base class for graphical objects that are used by units, * Abstract base class for graphical objects that are used by units,
* or as props attached to other CModelAbstract objects. * or as props attached to other CModelAbstract objects.

View File

@ -260,12 +260,12 @@ bool CObjectEntry::BuildVariation(const std::vector<const std::set<CStr>*>& comp
// Setup flags. // Setup flags.
if (m_Base->m_Properties.m_CastShadows) if (m_Base->m_Properties.m_CastShadows)
{ {
model->SetFlags(model->GetFlags() | MODELFLAG_CASTSHADOWS); model->SetFlags(model->GetFlags() | ModelFlag::CAST_SHADOWS);
} }
if (m_Base->m_Properties.m_FloatOnWater) if (m_Base->m_Properties.m_FloatOnWater)
{ {
model->SetFlags(model->GetFlags() | MODELFLAG_FLOATONWATER); model->SetFlags(model->GetFlags() | ModelFlag::FLOAT_ON_WATER);
} }
return true; return true;

View File

@ -137,7 +137,7 @@ void CUnit::ReloadObject()
newModel->ToCModel()->CopyAnimationFrom(m_Model->ToCModel()); newModel->ToCModel()->CopyAnimationFrom(m_Model->ToCModel());
// Copy flags that belong to this model instance (not those defined by the actor XML) // Copy flags that belong to this model instance (not those defined by the actor XML)
int instanceFlags = (MODELFLAG_SILHOUETTE_DISPLAY|MODELFLAG_SILHOUETTE_OCCLUDER|MODELFLAG_IGNORE_LOS) & m_Model->ToCModel()->GetFlags(); int instanceFlags = (ModelFlag::SILHOUETTE_DISPLAY | ModelFlag::SILHOUETTE_OCCLUDER | ModelFlag::IGNORE_LOS) & m_Model->ToCModel()->GetFlags();
newModel->ToCModel()->AddFlagsRec(instanceFlags); newModel->ToCModel()->AddFlagsRec(instanceFlags);
} }

View File

@ -55,7 +55,7 @@ public:
SPropPoint propPoint{}; SPropPoint propPoint{};
model->AddProp(&propPoint, std::make_unique<CModel>(simulation, material, modeldef), nullptr); model->AddProp(&propPoint, std::make_unique<CModel>(simulation, material, modeldef), nullptr);
model->AddFlagsRec(MODELFLAG_IGNORE_LOS); model->AddFlagsRec(ModelFlag::IGNORE_LOS);
model->RemoveShadowsRec(); model->RemoveShadowsRec();
TS_ASSERT(HasMaterialDefine(model.get(), str_DISABLE_RECEIVE_SHADOWS)); TS_ASSERT(HasMaterialDefine(model.get(), str_DISABLE_RECEIVE_SHADOWS));

View File

@ -325,12 +325,12 @@ void CSceneRenderer::RenderShadowMap(
{ {
PROFILE("render models"); PROFILE("render models");
m->CallModelRenderers(deviceCommandContext, contextCast, cullGroup, MODELFLAG_CASTSHADOWS); m->CallModelRenderers(deviceCommandContext, contextCast, cullGroup, ModelFlag::CAST_SHADOWS);
} }
{ {
PROFILE("render transparent models"); PROFILE("render transparent models");
m->CallTranspModelRenderers(deviceCommandContext, contextCast, cullGroup, MODELFLAG_CASTSHADOWS); m->CallTranspModelRenderers(deviceCommandContext, contextCast, cullGroup, ModelFlag::CAST_SHADOWS);
} }
} }
@ -1028,15 +1028,15 @@ void CSceneRenderer::SubmitNonRecursive(CModel* model)
{ {
m->shadow.AddShadowReceiverBound(model->GetWorldBounds()); m->shadow.AddShadowReceiverBound(model->GetWorldBounds());
if (model->GetFlags() & MODELFLAG_SILHOUETTE_OCCLUDER) if (model->GetFlags() & ModelFlag::SILHOUETTE_OCCLUDER)
m->silhouetteRenderer.AddOccluder(model); m->silhouetteRenderer.AddOccluder(model);
if (model->GetFlags() & MODELFLAG_SILHOUETTE_DISPLAY) if (model->GetFlags() & ModelFlag::SILHOUETTE_DISPLAY)
m->silhouetteRenderer.AddCaster(model); m->silhouetteRenderer.AddCaster(model);
} }
if (CULL_SHADOWS_CASCADE_0 <= m_CurrentCullGroup && m_CurrentCullGroup <= CULL_SHADOWS_CASCADE_3) if (CULL_SHADOWS_CASCADE_0 <= m_CurrentCullGroup && m_CurrentCullGroup <= CULL_SHADOWS_CASCADE_3)
{ {
if (!(model->GetFlags() & MODELFLAG_CASTSHADOWS)) if (!(model->GetFlags() & ModelFlag::CAST_SHADOWS))
return; return;
const int cascade = m_CurrentCullGroup - CULL_SHADOWS_CASCADE_0; const int cascade = m_CurrentCullGroup - CULL_SHADOWS_CASCADE_0;

View File

@ -601,14 +601,14 @@ void CCmpVisualActor::InitModel()
u32 modelFlags = 0; u32 modelFlags = 0;
if (m_SilhouetteDisplay) if (m_SilhouetteDisplay)
modelFlags |= MODELFLAG_SILHOUETTE_DISPLAY; modelFlags |= ModelFlag::SILHOUETTE_DISPLAY;
if (m_SilhouetteOccluder) if (m_SilhouetteOccluder)
modelFlags |= MODELFLAG_SILHOUETTE_OCCLUDER; modelFlags |= ModelFlag::SILHOUETTE_OCCLUDER;
CmpPtr<ICmpVisibility> cmpVisibility(GetEntityHandle()); CmpPtr<ICmpVisibility> cmpVisibility(GetEntityHandle());
if (cmpVisibility && cmpVisibility->GetAlwaysVisible()) if (cmpVisibility && cmpVisibility->GetAlwaysVisible())
modelFlags |= MODELFLAG_IGNORE_LOS; modelFlags |= ModelFlag::IGNORE_LOS;
model.ToCModel()->AddFlagsRec(modelFlags); model.ToCModel()->AddFlagsRec(modelFlags);
} }