summaryrefslogtreecommitdiff
path: root/mdlobjects/dmelodlist.cpp
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /mdlobjects/dmelodlist.cpp
downloadarchived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.tar.xz
archived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.zip
Diffstat (limited to 'mdlobjects/dmelodlist.cpp')
-rw-r--r--mdlobjects/dmelodlist.cpp81
1 files changed, 81 insertions, 0 deletions
diff --git a/mdlobjects/dmelodlist.cpp b/mdlobjects/dmelodlist.cpp
new file mode 100644
index 0000000..6de00f6
--- /dev/null
+++ b/mdlobjects/dmelodlist.cpp
@@ -0,0 +1,81 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Dme version of a hitbox
+//
+//===========================================================================//
+
+#include "mdlobjects/dmelodlist.h"
+#include "datamodel/dmelementfactoryhelper.h"
+#include "mdlobjects/dmelod.h"
+
+// memdbgon must be the last include file in a .cpp file!!!
+#include "tier0/memdbgon.h"
+
+
+//-----------------------------------------------------------------------------
+// Expose this class to the scene database
+//-----------------------------------------------------------------------------
+IMPLEMENT_ELEMENT_FACTORY( DmeLODList, CDmeLODList );
+
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+void CDmeLODList::OnConstruction()
+{
+ m_LODs.Init( this, "lods" );
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CDmeLODList::OnDestruction()
+{
+}
+
+
+//-----------------------------------------------------------------------------
+// Returns the number of LODs in this body part, can be 0
+//-----------------------------------------------------------------------------
+int CDmeLODList::LODCount() const
+{
+ return m_LODs.Count();
+}
+
+
+//-----------------------------------------------------------------------------
+// Returns the root LOD. This is the one with the switch metric 0
+//-----------------------------------------------------------------------------
+CDmeLOD* CDmeLODList::GetRootLOD()
+{
+ int nCount = m_LODs.Count();
+ int nMinIndex = -1;
+ float flMinMetric = FLT_MAX;
+ for ( int i = 0; i < nCount; ++i )
+ {
+ if ( m_LODs[i]->m_flSwitchMetric < flMinMetric )
+ {
+ nMinIndex = i;
+ flMinMetric = m_LODs[i]->m_flSwitchMetric;
+ if ( flMinMetric == 0.0f )
+ break;
+ }
+ }
+ return ( nMinIndex >= 0 ) ? m_LODs[nMinIndex] : NULL;
+}
+
+
+//-----------------------------------------------------------------------------
+// Returns the shadow LOD
+//-----------------------------------------------------------------------------
+CDmeLOD* CDmeLODList::GetShadowLOD()
+{
+ int nCount = m_LODs.Count();
+ for ( int i = 0; i < nCount; ++i )
+ {
+ if ( m_LODs[i]->m_bIsShadowLOD )
+ return m_LODs[i];
+ }
+ return NULL;
+}