Start to port studiomdl to linux

This commit is contained in:
Kamay Xutax 2024-09-08 02:58:46 +02:00
parent 3050c5331d
commit 95e31cd2c8
49 changed files with 1023 additions and 788 deletions

View file

@ -2062,45 +2062,6 @@ void CDmAttribute::OnChanged( bool bArrayCountChanged, bool bIsTopological )
} }
} }
//-----------------------------------------------------------------------------
// Type conversion related methods
//-----------------------------------------------------------------------------
template< class T > bool CDmAttribute::IsTypeConvertable() const
{
return ( CDmAttributeInfo< T >::ATTRIBUTE_TYPE == GetType() );
}
template<> bool CDmAttribute::IsTypeConvertable<bool>() const
{
DmAttributeType_t type = GetType();
return ( type == AT_BOOL || type == AT_INT || type == AT_FLOAT );
}
template<> bool CDmAttribute::IsTypeConvertable<int>() const
{
DmAttributeType_t type = GetType();
return ( type == AT_INT || type == AT_BOOL || type == AT_FLOAT );
}
template<> bool CDmAttribute::IsTypeConvertable<float>() const
{
DmAttributeType_t type = GetType();
return ( type == AT_FLOAT || type == AT_INT || type == AT_BOOL );
}
template<> bool CDmAttribute::IsTypeConvertable<QAngle>() const
{
DmAttributeType_t type = GetType();
return ( type == AT_QANGLE || type == AT_QUATERNION );
}
template<> bool CDmAttribute::IsTypeConvertable<Quaternion>() const
{
DmAttributeType_t type = GetType();
return ( type == AT_QUATERNION || type == AT_QANGLE);
}
template< class T > void CDmAttribute::CopyData( const T& value ) template< class T > void CDmAttribute::CopyData( const T& value )
{ {
*reinterpret_cast< T* >( m_pData ) = value; *reinterpret_cast< T* >( m_pData ) = value;

View file

@ -14,7 +14,7 @@
#include "dmserializers.h" #include "dmserializers.h"
#include "dmserializers/idmserializers.h" #include "dmserializers/idmserializers.h"
#include "appframework/iappsystem.h" #include "appframework/IAppSystem.h"
#include "filesystem.h" #include "filesystem.h"
#include "datamodel/idatamodel.h" #include "datamodel/idatamodel.h"
#include "datamodel/dmelementfactoryhelper.h" #include "datamodel/dmelementfactoryhelper.h"

50
dmserializers/wscript Executable file
View file

@ -0,0 +1,50 @@
#! /usr/bin/env python
# encoding: utf-8
from waflib import Utils
import os
import vpc_parser
top = '.'
PROJECT_NAME = 'dmserializers'
def options(opt):
# stub
return
def configure(conf):
return
def build(bld):
dmserializers_vpc = vpc_parser.parse_vpcs( bld.env, ['dmserializers.vpc'], '..' )
source = dmserializers_vpc["sources"]
includes = dmserializers_vpc["includes"]
includes += [
'../public',
'../public/tier0',
'../public/tier1',
'../public/tier2',
'../public/tier3',
]
defines = dmserializers_vpc["defines"]
libs = ['tier0','tier1','tier2','tier3']
if bld.env.DEST_OS == 'android':
libs += ['ANDROID_SUPPORT']
install_path = bld.env.LIBDIR
bld.stlib(
source = source,
target = PROJECT_NAME,
name = PROJECT_NAME,
features = 'c cxx',
includes = includes,
defines = defines,
use = libs,
install_path = install_path,
subsystem = bld.env.MSVC_SUBSYSTEM,
idx = bld.get_taskgen_count()
)

View file

@ -267,9 +267,9 @@ def build(bld):
] + bld.env.INCLUDES_SDL2 ] + bld.env.INCLUDES_SDL2
defines_dx9 = ['STDSHADER_DX9_DLL_EXPORT', 'FAST_MATERIALVAR_ACCESS'] defines_dx9 = ['STDSHADER_DX9_DLL_EXPORT', 'FAST_MATERIALVAR_ACCESS']
defines_dx8 = ['STDSHADER_DX8_DLL_EXPORT', 'FAST_MATERIALVAR_ACCESS'] # defines_dx8 = ['STDSHADER_DX8_DLL_EXPORT', 'FAST_MATERIALVAR_ACCESS']
defines_dx7 = ['STDSHADER_DX7_DLL_EXPORT', 'FAST_MATERIALVAR_ACCESS'] # defines_dx7 = ['STDSHADER_DX7_DLL_EXPORT', 'FAST_MATERIALVAR_ACCESS']
defines_dx6 = ['STDSHADER_DX6_DLL_EXPORT', 'FAST_MATERIALVAR_ACCESS'] # defines_dx6 = ['STDSHADER_DX6_DLL_EXPORT', 'FAST_MATERIALVAR_ACCESS']
defines_dbg = ['STDSHADER_DBG_DLL_EXPORT', 'FAST_MATERIALVAR_ACCESS'] defines_dbg = ['STDSHADER_DBG_DLL_EXPORT', 'FAST_MATERIALVAR_ACCESS']
libs = ['tier0','shaderlib','tier1','mathlib'] libs = ['tier0','shaderlib','tier1','mathlib']
@ -292,31 +292,31 @@ def build(bld):
idx = bld.get_taskgen_count() idx = bld.get_taskgen_count()
) )
bld.shlib( # bld.shlib(
source = source_dx8, # source = source_dx8,
target = PROJECT_NAME + 'dx8', # target = PROJECT_NAME + 'dx8',
name = PROJECT_NAME + 'dx8', # name = PROJECT_NAME + 'dx8',
features = 'c cxx', # features = 'c cxx',
includes = includes, # includes = includes,
defines = defines_dx8, # defines = defines_dx8,
use = libs, # use = libs,
install_path = install_path, # install_path = install_path,
subsystem = bld.env.MSVC_SUBSYSTEM, # subsystem = bld.env.MSVC_SUBSYSTEM,
idx = bld.get_taskgen_count() # idx = bld.get_taskgen_count()
) # )
bld.shlib( # bld.shlib(
source = source_dx7, # source = source_dx7,
target = PROJECT_NAME + 'dx7', # target = PROJECT_NAME + 'dx7',
name = PROJECT_NAME + 'dx7', # name = PROJECT_NAME + 'dx7',
features = 'c cxx', # features = 'c cxx',
includes = includes, # includes = includes,
defines = defines_dx7, # defines = defines_dx7,
use = libs, # use = libs,
install_path = install_path, # install_path = install_path,
subsystem = bld.env.MSVC_SUBSYSTEM, # subsystem = bld.env.MSVC_SUBSYSTEM,
idx = bld.get_taskgen_count() # idx = bld.get_taskgen_count()
) # )
# TODO_ENHANCED(xutaxkamay): # TODO_ENHANCED(xutaxkamay):
# bld.shlib( # bld.shlib(

View file

@ -7,7 +7,7 @@
// Valve includes // Valve includes
#include "datamodel/dmelementfactoryhelper.h" #include "datamodel/dmelementfactoryhelper.h"
#include "mdlobjects/dmeBoneFlexDriver.h" #include "mdlobjects/dmeboneflexdriver.h"
// memdbgon must be the last include file in a .cpp file!!! // memdbgon must be the last include file in a .cpp file!!!

50
mdlobjects/wscript Executable file
View file

@ -0,0 +1,50 @@
#! /usr/bin/env python
# encoding: utf-8
from waflib import Utils
import os
import vpc_parser
top = '.'
PROJECT_NAME = 'mdlobjects'
def options(opt):
# stub
return
def configure(conf):
return
def build(bld):
mdlobjects_vpc = vpc_parser.parse_vpcs( bld.env, ['mdlobjects.vpc'], '..' )
source = mdlobjects_vpc["sources"]
includes = mdlobjects_vpc["includes"]
includes += [
'../public',
'../public/tier0',
'../public/tier1',
'../public/tier2',
'../public/tier3',
]
defines = mdlobjects_vpc["defines"]
libs = ['tier0','tier1','tier2','tier3']
if bld.env.DEST_OS == 'android':
libs += ['ANDROID_SUPPORT']
install_path = bld.env.LIBDIR
bld.stlib(
source = source,
target = PROJECT_NAME,
name = PROJECT_NAME,
features = 'c cxx',
includes = includes,
defines = defines,
use = libs,
install_path = install_path,
subsystem = bld.env.MSVC_SUBSYSTEM,
idx = bld.get_taskgen_count()
)

View file

@ -10,7 +10,7 @@
#include "datamodel/dmelementfactoryhelper.h" #include "datamodel/dmelementfactoryhelper.h"
#include "datamodel/dmehandle.h" #include "datamodel/dmehandle.h"
#include "phonemeconverter.h" #include "phonemeconverter.h"
#include "tier1/utlstringmap.h" #include "tier1/UtlStringMap.h"
#include "tier2/tier2.h" #include "tier2/tier2.h"
#include "filesystem.h" #include "filesystem.h"
#include "studio.h" #include "studio.h"
@ -602,7 +602,7 @@ bool CDmePresetGroup::ExportToTXT( const char *pFileName, CDmeAnimationSet *pAni
#ifdef ALIGN4 #ifdef ALIGN4
#undef ALIGN4 #undef ALIGN4
#endif // #ifdef ALIGN4 #endif // #ifdef ALIGN4
#define ALIGN4( a ) a = (byte *)((int)((byte *)a + 3) & ~ 3) #define ALIGN4( a ) a = (byte *)((uintptr_t)((byte *)a + 3) & ~ 3)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View file

@ -1015,6 +1015,13 @@ void CDmeFilmClip::OnElementUnserialized( )
} }
} }
auto cleanUp = [&]()
{
// Always strip out the old overlay attribute
RemoveAttribute( "overlay" );
RemoveAttribute( "overlayalpha" );
};
// this conversion code went in on 10/31/2005 // this conversion code went in on 10/31/2005
// I'm hoping we don't care about any files that old - if we ever hit this, we should move this code into an unserialization converter // I'm hoping we don't care about any files that old - if we ever hit this, we should move this code into an unserialization converter
Assert( !HasAttribute( "overlay" ) && !HasAttribute( "overlayalpha" ) ); Assert( !HasAttribute( "overlay" ) && !HasAttribute( "overlayalpha" ) );
@ -1026,11 +1033,17 @@ void CDmeFilmClip::OnElementUnserialized( )
// If this is an older file with an overlay attribute, strip it out into materialoverlay // If this is an older file with an overlay attribute, strip it out into materialoverlay
CDmAttribute *pOverlayAttribute = GetAttribute( "overlay" ); CDmAttribute *pOverlayAttribute = GetAttribute( "overlay" );
if ( !pOverlayAttribute ) if ( !pOverlayAttribute )
goto cleanUp; {
cleanUp();
return;
}
const char *pName = pOverlayAttribute->GetValueString(); const char *pName = pOverlayAttribute->GetValueString();
if ( !pName || !pName[0] ) if ( !pName || !pName[0] )
goto cleanUp; {
cleanUp();
return;
}
// If we don't yet have a material overlay, create one // If we don't yet have a material overlay, create one
if ( m_MaterialOverlayEffect.GetElement() == NULL ) if ( m_MaterialOverlayEffect.GetElement() == NULL )
@ -1048,10 +1061,6 @@ void CDmeFilmClip::OnElementUnserialized( )
m_MaterialOverlayEffect->SetAlpha( alpha ); m_MaterialOverlayEffect->SetAlpha( alpha );
} }
cleanUp:
// Always strip out the old overlay attribute
RemoveAttribute( "overlay" );
RemoveAttribute( "overlayalpha" );
} }
} }

View file

@ -6,7 +6,7 @@
#include "movieobjects/dmefaceset.h" #include "movieobjects/dmefaceset.h"
#include "movieobjects/dmematerial.h" #include "movieobjects/dmematerial.h"
#include "tier0/dbg.h" #include "tier0/dbg.h"
#include "UtlBuffer.h" #include "utlbuffer.h"
#include "datamodel/dmelementfactoryhelper.h" #include "datamodel/dmelementfactoryhelper.h"
// memdbgon must be the last include file in a .cpp file!!! // memdbgon must be the last include file in a .cpp file!!!

View file

@ -8,8 +8,8 @@
#include "movieobjects_interfaces.h" #include "movieobjects_interfaces.h"
#include "datamodel/dmelementfactoryhelper.h" #include "datamodel/dmelementfactoryhelper.h"
#include "vgui/iinput.h" #include "vgui/IInput.h"
#include "vgui/keycode.h" #include "vgui/KeyCode.h"
#include "tier3/tier3.h" #include "tier3/tier3.h"
#include "tier0/dbg.h" #include "tier0/dbg.h"

View file

@ -590,12 +590,6 @@ CUtlString ScaleValue( const CUtlString& value, float scale )
return value; return value;
} }
template< class T >
float LengthOf( const T& value )
{
return value;
}
template<> template<>
float LengthOf( const bool& value ) float LengthOf( const bool& value )
{ {
@ -659,12 +653,6 @@ float LengthOf( const QAngle& value )
return value.Length(); return value.Length();
} }
template< class T >
T Subtract( const T& v1, const T& v2 )
{
return v1 - v2;
}
template<> template<>
bool Subtract( const bool& v1, const bool& v2 ) bool Subtract( const bool& v1, const bool& v2 )
{ {
@ -758,18 +746,17 @@ Quaternion Add( const Quaternion& v1, const Quaternion& v2 )
} }
IMPLEMENT_ABSTRACT_ELEMENT( DmeLogLayer, CDmeLogLayer ); IMPLEMENT_ABSTRACT_ELEMENT( DmeLogLayer, CDmeLogLayer );
IMPLEMENT_ELEMENT_FACTORY_T( DmeIntLogLayer, CDmeIntLogLayer );
IMPLEMENT_ELEMENT_FACTORY( DmeIntLogLayer, CDmeIntLogLayer ); IMPLEMENT_ELEMENT_FACTORY_T( DmeFloatLogLayer, CDmeFloatLogLayer );
IMPLEMENT_ELEMENT_FACTORY( DmeFloatLogLayer, CDmeFloatLogLayer ); IMPLEMENT_ELEMENT_FACTORY_T( DmeBoolLogLayer, CDmeBoolLogLayer );
IMPLEMENT_ELEMENT_FACTORY( DmeBoolLogLayer, CDmeBoolLogLayer ); IMPLEMENT_ELEMENT_FACTORY_T( DmeColorLogLayer, CDmeColorLogLayer );
IMPLEMENT_ELEMENT_FACTORY( DmeColorLogLayer, CDmeColorLogLayer ); IMPLEMENT_ELEMENT_FACTORY_T( DmeVector2LogLayer, CDmeVector2LogLayer );
IMPLEMENT_ELEMENT_FACTORY( DmeVector2LogLayer, CDmeVector2LogLayer ); IMPLEMENT_ELEMENT_FACTORY_T( DmeVector3LogLayer, CDmeVector3LogLayer );
IMPLEMENT_ELEMENT_FACTORY( DmeVector3LogLayer, CDmeVector3LogLayer ); IMPLEMENT_ELEMENT_FACTORY_T( DmeVector4LogLayer, CDmeVector4LogLayer );
IMPLEMENT_ELEMENT_FACTORY( DmeVector4LogLayer, CDmeVector4LogLayer ); IMPLEMENT_ELEMENT_FACTORY_T( DmeQAngleLogLayer, CDmeQAngleLogLayer );
IMPLEMENT_ELEMENT_FACTORY( DmeQAngleLogLayer, CDmeQAngleLogLayer ); IMPLEMENT_ELEMENT_FACTORY_T( DmeQuaternionLogLayer, CDmeQuaternionLogLayer );
IMPLEMENT_ELEMENT_FACTORY( DmeQuaternionLogLayer, CDmeQuaternionLogLayer ); IMPLEMENT_ELEMENT_FACTORY_T( DmeVMatrixLogLayer, CDmeVMatrixLogLayer );
IMPLEMENT_ELEMENT_FACTORY( DmeVMatrixLogLayer, CDmeVMatrixLogLayer ); IMPLEMENT_ELEMENT_FACTORY_T( DmeStringLogLayer, CDmeStringLogLayer );
IMPLEMENT_ELEMENT_FACTORY( DmeStringLogLayer, CDmeStringLogLayer );
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// explicit template instantiation // explicit template instantiation
@ -789,17 +776,17 @@ template class CDmeTypedLogLayer<CUtlString>;
IMPLEMENT_ABSTRACT_ELEMENT( DmeCurveInfo, CDmeCurveInfo ); IMPLEMENT_ABSTRACT_ELEMENT( DmeCurveInfo, CDmeCurveInfo );
IMPLEMENT_ELEMENT_FACTORY( DmeIntCurveInfo, CDmeIntCurveInfo ); IMPLEMENT_ELEMENT_FACTORY_T( DmeIntCurveInfo, CDmeIntCurveInfo );
IMPLEMENT_ELEMENT_FACTORY( DmeFloatCurveInfo, CDmeFloatCurveInfo ); IMPLEMENT_ELEMENT_FACTORY_T( DmeFloatCurveInfo, CDmeFloatCurveInfo );
IMPLEMENT_ELEMENT_FACTORY( DmeBoolCurveInfo, CDmeBoolCurveInfo ); IMPLEMENT_ELEMENT_FACTORY_T( DmeBoolCurveInfo, CDmeBoolCurveInfo );
IMPLEMENT_ELEMENT_FACTORY( DmeColorCurveInfo, CDmeColorCurveInfo ); IMPLEMENT_ELEMENT_FACTORY_T( DmeColorCurveInfo, CDmeColorCurveInfo );
IMPLEMENT_ELEMENT_FACTORY( DmeVector2CurveInfo, CDmeVector2CurveInfo ); IMPLEMENT_ELEMENT_FACTORY_T( DmeVector2CurveInfo, CDmeVector2CurveInfo );
IMPLEMENT_ELEMENT_FACTORY( DmeVector3CurveInfo, CDmeVector3CurveInfo ); IMPLEMENT_ELEMENT_FACTORY_T( DmeVector3CurveInfo, CDmeVector3CurveInfo );
IMPLEMENT_ELEMENT_FACTORY( DmeVector4CurveInfo, CDmeVector4CurveInfo ); IMPLEMENT_ELEMENT_FACTORY_T( DmeVector4CurveInfo, CDmeVector4CurveInfo );
IMPLEMENT_ELEMENT_FACTORY( DmeQAngleCurveInfo, CDmeQAngleCurveInfo ); IMPLEMENT_ELEMENT_FACTORY_T( DmeQAngleCurveInfo, CDmeQAngleCurveInfo );
IMPLEMENT_ELEMENT_FACTORY( DmeQuaternionCurveInfo, CDmeQuaternionCurveInfo ); IMPLEMENT_ELEMENT_FACTORY_T( DmeQuaternionCurveInfo, CDmeQuaternionCurveInfo );
IMPLEMENT_ELEMENT_FACTORY( DmeVMatrixCurveInfo, CDmeVMatrixCurveInfo ); IMPLEMENT_ELEMENT_FACTORY_T( DmeVMatrixCurveInfo, CDmeVMatrixCurveInfo );
IMPLEMENT_ELEMENT_FACTORY( DmeStringCurveInfo, CDmeStringCurveInfo ); IMPLEMENT_ELEMENT_FACTORY_T( DmeStringCurveInfo, CDmeStringCurveInfo );
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// explicit template instantiation // explicit template instantiation
@ -822,17 +809,17 @@ template class CDmeTypedCurveInfo<CUtlString>;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
IMPLEMENT_ABSTRACT_ELEMENT( DmeLog, CDmeLog ); IMPLEMENT_ABSTRACT_ELEMENT( DmeLog, CDmeLog );
IMPLEMENT_ELEMENT_FACTORY( DmeIntLog, CDmeIntLog ); IMPLEMENT_ELEMENT_FACTORY_T( DmeIntLog, CDmeIntLog );
IMPLEMENT_ELEMENT_FACTORY( DmeFloatLog, CDmeFloatLog ); IMPLEMENT_ELEMENT_FACTORY_T( DmeFloatLog, CDmeFloatLog );
IMPLEMENT_ELEMENT_FACTORY( DmeBoolLog, CDmeBoolLog ); IMPLEMENT_ELEMENT_FACTORY_T( DmeBoolLog, CDmeBoolLog );
IMPLEMENT_ELEMENT_FACTORY( DmeColorLog, CDmeColorLog ); IMPLEMENT_ELEMENT_FACTORY_T( DmeColorLog, CDmeColorLog );
IMPLEMENT_ELEMENT_FACTORY( DmeVector2Log, CDmeVector2Log ); IMPLEMENT_ELEMENT_FACTORY_T( DmeVector2Log, CDmeVector2Log );
IMPLEMENT_ELEMENT_FACTORY( DmeVector3Log, CDmeVector3Log ); IMPLEMENT_ELEMENT_FACTORY_T( DmeVector3Log, CDmeVector3Log );
IMPLEMENT_ELEMENT_FACTORY( DmeVector4Log, CDmeVector4Log ); IMPLEMENT_ELEMENT_FACTORY_T( DmeVector4Log, CDmeVector4Log );
IMPLEMENT_ELEMENT_FACTORY( DmeQAngleLog, CDmeQAngleLog ); IMPLEMENT_ELEMENT_FACTORY_T( DmeQAngleLog, CDmeQAngleLog );
IMPLEMENT_ELEMENT_FACTORY( DmeQuaternionLog, CDmeQuaternionLog ); IMPLEMENT_ELEMENT_FACTORY_T( DmeQuaternionLog, CDmeQuaternionLog );
IMPLEMENT_ELEMENT_FACTORY( DmeVMatrixLog, CDmeVMatrixLog ); IMPLEMENT_ELEMENT_FACTORY_T( DmeVMatrixLog, CDmeVMatrixLog );
IMPLEMENT_ELEMENT_FACTORY( DmeStringLog, CDmeStringLog ); IMPLEMENT_ELEMENT_FACTORY_T( DmeStringLog, CDmeStringLog );
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -854,17 +841,17 @@ template class CDmeTypedLog<CUtlString>;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// instantiate and initialize static vars // instantiate and initialize static vars
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
float CDmeIntLog::s_defaultThreshold = 0.0f; template<> float CDmeIntLog::s_defaultThreshold = 0.0f;
float CDmeFloatLog::s_defaultThreshold = 0.0f; template<> float CDmeFloatLog::s_defaultThreshold = 0.0f;
float CDmeBoolLog::s_defaultThreshold = 0.0f; template<> float CDmeBoolLog::s_defaultThreshold = 0.0f;
float CDmeColorLog::s_defaultThreshold = 0.0f; template<> float CDmeColorLog::s_defaultThreshold = 0.0f;
float CDmeVector2Log::s_defaultThreshold = 0.0f; template<> float CDmeVector2Log::s_defaultThreshold = 0.0f;
float CDmeVector3Log::s_defaultThreshold = 0.0f; template<> float CDmeVector3Log::s_defaultThreshold = 0.0f;
float CDmeVector4Log::s_defaultThreshold = 0.0f; template<> float CDmeVector4Log::s_defaultThreshold = 0.0f;
float CDmeQAngleLog::s_defaultThreshold = 0.0f; template<> float CDmeQAngleLog::s_defaultThreshold = 0.0f;
float CDmeQuaternionLog::s_defaultThreshold = 0.0f; template<> float CDmeQuaternionLog::s_defaultThreshold = 0.0f;
float CDmeVMatrixLog::s_defaultThreshold = 0.0f; template<> float CDmeVMatrixLog::s_defaultThreshold = 0.0f;
float CDmeStringLog::s_defaultThreshold = 0.0f; template<> float CDmeStringLog::s_defaultThreshold = 0.0f;
void CDmeLogLayer::OnConstruction() void CDmeLogLayer::OnConstruction()
@ -1835,42 +1822,6 @@ void CDmeTypedLogLayer<T>::RemoveRedundantKeys( float threshold )
} }
// Implementation of Douglas-Peucker curve simplification routine (hacked to only care about error against original curve (sort of 1D)
template< class T >
void CDmeTypedLogLayer< T >::CurveSimplify_R( float thresholdSqr, int startPoint, int endPoint, CDmeTypedLogLayer< T > *output )
{
if ( endPoint <= startPoint + 1 )
{
return;
}
int maxPoint = startPoint;
float maxDistanceSqr = 0.0f;
for ( int i = startPoint + 1 ; i < endPoint; ++i )
{
DmeTime_t keyTime = GetKeyTime( i );
T check = GetKeyValue( i );
T check2 = output->GetValue( keyTime );
T dist = Subtract( check, check2 );
float distSqr = LengthOf( dist ) * LengthOf( dist );
if ( distSqr < maxDistanceSqr )
continue;
maxPoint = i;
maxDistanceSqr = distSqr;
}
if ( maxDistanceSqr > thresholdSqr )
{
output->InsertKey( GetKeyTime( maxPoint ), GetKeyValue( maxPoint ) );
CurveSimplify_R( thresholdSqr, startPoint, maxPoint, output );
CurveSimplify_R( thresholdSqr, maxPoint, endPoint, output );
}
}
template<> void CDmeTypedLogLayer< bool >::CurveSimplify_R( float thresholdSqr, int startPoint, int endPoint, CDmeTypedLogLayer< bool > *output ) {}; template<> void CDmeTypedLogLayer< bool >::CurveSimplify_R( float thresholdSqr, int startPoint, int endPoint, CDmeTypedLogLayer< bool > *output ) {};
template<> void CDmeTypedLogLayer< int >::CurveSimplify_R( float thresholdSqr, int startPoint, int endPoint, CDmeTypedLogLayer< int > *output ) {}; template<> void CDmeTypedLogLayer< int >::CurveSimplify_R( float thresholdSqr, int startPoint, int endPoint, CDmeTypedLogLayer< int > *output ) {};
template<> void CDmeTypedLogLayer< Color >::CurveSimplify_R( float thresholdSqr, int startPoint, int endPoint, CDmeTypedLogLayer< Color > *output ) {}; template<> void CDmeTypedLogLayer< Color >::CurveSimplify_R( float thresholdSqr, int startPoint, int endPoint, CDmeTypedLogLayer< Color > *output ) {};
@ -2564,8 +2515,8 @@ void CDmeTypedLogLayer< T >::CopyPartialLayer( const CDmeLogLayer *src, DmeTime_
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Creates a log of a specific type // Creates a log of a specific type
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template< class T > template< typename T >
CDmeLogLayer *CreateLayer< T >( CDmeTypedLog< T > *pOwnerLog ) CDmeLogLayer *CreateLayer( CDmeTypedLog< T > *pOwnerLog )
{ {
DmFileId_t fileid = pOwnerLog ? pOwnerLog->GetFileId() : DMFILEID_INVALID; DmFileId_t fileid = pOwnerLog ? pOwnerLog->GetFileId() : DMFILEID_INVALID;
CDmeLogLayer *layer = NULL; CDmeLogLayer *layer = NULL;
@ -4530,39 +4481,6 @@ int CDmeTypedLog< T >::FindKeyWithinTolerance( DmeTime_t nTime, DmeTime_t nToler
return GetLayer( bestLayer )->FindKeyWithinTolerance( nTime, nTolerance ); return GetLayer( bestLayer )->FindKeyWithinTolerance( nTime, nTolerance );
} }
//-----------------------------------------------------------------------------
// tests whether two values differ by more than the threshold
//-----------------------------------------------------------------------------
template<>
bool CDmeTypedLog< Vector >::ValuesDiffer( const Vector& a, const Vector& b ) const
{
return a.DistToSqr( b ) > m_threshold * m_threshold;
}
template<>
bool CDmeTypedLog< QAngle >::ValuesDiffer( const QAngle& a, const QAngle& b ) const
{
return ( a - b ).LengthSqr() > m_threshold * m_threshold;
}
template<>
bool CDmeTypedLog< Quaternion >::ValuesDiffer( const Quaternion& a, const Quaternion& b ) const
{
return QuaternionAngleDiff( a, b ) > m_threshold;
}
template<>
bool CDmeTypedLog< float >::ValuesDiffer( const float& a, const float& b ) const
{
return fabs( a - b ) > m_threshold;
}
template< class T >
bool CDmeTypedLog< T >::ValuesDiffer( const T& a, const T& b ) const
{
return a != b;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Sets a key, removes all keys after this time // Sets a key, removes all keys after this time
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -4708,7 +4626,7 @@ void CDmeTypedLog< T >::GetValue( DmeTime_t time, CDmAttribute *pAttr, uint inde
} }
template< class T > template< class T >
void CDmeTypedLog< T >::GetValueSkippingTopmostLayer( DmeTime_t time, CDmAttribute *pAttr, uint index = 0 ) const void CDmeTypedLog< T >::GetValueSkippingTopmostLayer( DmeTime_t time, CDmAttribute *pAttr, uint index ) const
{ {
CUtlVector< int > layers; CUtlVector< int > layers;
FindLayersForTime( time, layers ); FindLayersForTime( time, layers );

View file

@ -2777,86 +2777,6 @@ void CDmeMesh::ComputeAllCorrectedPositionsFromActualPositions()
} }
//-----------------------------------------------------------------------------
// There's no guarantee that fields are added in any order, nor that only
// standard fields exist...
//-----------------------------------------------------------------------------
template < class T_t >
void CDmeMesh::AddCorrectedDelta(
CDmrArray< T_t > &baseDataArray,
const CUtlVector< int > &baseIndices,
const DeltaComputation_t &deltaComputation,
const char *pFieldName,
float weight,
const CDmeSingleIndexedComponent *pMask )
{
const CUtlVector< T_t > &baseData( baseDataArray.Get() );
const int nData( baseData.Count() );
T_t *pData( reinterpret_cast< T_t * >( alloca( nData * sizeof( T_t ) ) ) );
Q_memcpy( pData, baseData.Base(), nData * sizeof( T_t ) );
CDmeVertexDeltaData *pDelta( GetDeltaState( deltaComputation.m_nDeltaIndex ) );
const int deltaFieldIndex( pDelta->FindFieldIndex( pFieldName ) );
if ( deltaFieldIndex < 0 )
return;
AddDelta( pDelta, pData, nData, deltaFieldIndex, weight, pMask );
const CUtlVector< int > &depDeltas( deltaComputation.m_DependentDeltas );
const int nDepDeltas( depDeltas.Count() );
for ( int j( 0 ); j < nDepDeltas; ++j )
{
pDelta = GetDeltaState( depDeltas[ j ] );
int depFieldIndex = pDelta->FindFieldIndex( pFieldName );
if ( depFieldIndex < 0 )
continue;
AddDelta( pDelta, pData, nData, depFieldIndex, weight, pMask );
}
baseDataArray.CopyArray( pData, nData );
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
template < class T_t >
void CDmeMesh::AddCorrectedDelta(
CUtlVector< T_t > &baseData,
const CUtlVector< int > &baseIndices,
const DeltaComputation_t &deltaComputation,
const char *pFieldName,
float weight,
const CDmeSingleIndexedComponent *pMask )
{
const int nData( baseData.Count() );
CDmeVertexDeltaData *pDelta( GetDeltaState( deltaComputation.m_nDeltaIndex ) );
const int deltaFieldIndex( pDelta->FindFieldIndex( pFieldName ) );
if ( deltaFieldIndex < 0 )
return;
AddDelta( pDelta, baseData.Base(), nData, deltaFieldIndex, weight, pMask );
const CUtlVector< int > &depDeltas( deltaComputation.m_DependentDeltas );
const int nDepDeltas( depDeltas.Count() );
for ( int j( 0 ); j < nDepDeltas; ++j )
{
pDelta = GetDeltaState( depDeltas[ j ] );
int depFieldIndex = pDelta->FindFieldIndex( pFieldName );
if ( depFieldIndex < 0 )
continue;
AddDelta( pDelta, baseData.Base(), nData, depFieldIndex, weight, pMask );
}
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// There's no guarantee that fields are added in any order, nor that only // There's no guarantee that fields are added in any order, nor that only
// standard fields exist... // standard fields exist...
@ -2961,18 +2881,30 @@ bool CDmeMesh::SetBaseStateToDelta( const CDmeVertexDeltaData *pDelta, CDmeVerte
switch ( pBaseData->GetType() ) switch ( pBaseData->GetType() )
{ {
case AT_FLOAT_ARRAY: case AT_FLOAT_ARRAY:
AddCorrectedDelta( CDmrArray< float >( pBaseData ), baseIndices, compList[ i ], baseFieldName ); {
break; CDmrArray< float > array1( pBaseData );
case AT_COLOR_ARRAY: AddCorrectedDelta( array1, baseIndices, compList[i], baseFieldName );
AddCorrectedDelta( CDmrArray< Vector >( pBaseData ), baseIndices, compList[ i ], baseFieldName ); break;
break; }
case AT_VECTOR2_ARRAY: case AT_COLOR_ARRAY:
AddCorrectedDelta( CDmrArray< Vector2D >( pBaseData ), baseIndices, compList[ i ], baseFieldName ); {
break; CDmrArray< Vector > array2( pBaseData );
case AT_VECTOR3_ARRAY: AddCorrectedDelta( array2, baseIndices, compList[i], baseFieldName );
AddCorrectedDelta( CDmrArray< Vector >( pBaseData ), baseIndices, compList[ i ], baseFieldName ); break;
break; }
case AT_VECTOR2_ARRAY:
{
CDmrArray< Vector2D > array3( pBaseData );
AddCorrectedDelta( array3, baseIndices, compList[i], baseFieldName );
break;
}
case AT_VECTOR3_ARRAY:
{
CDmrArray< Vector > array4( pBaseData );
AddCorrectedDelta( array4, baseIndices, compList[i], baseFieldName );
break;
}
default: default:
break; break;
} }
@ -3828,21 +3760,31 @@ bool CDmeMesh::AddMaskedDelta(
switch ( pBaseData->GetType() ) switch ( pBaseData->GetType() )
{ {
case AT_FLOAT_ARRAY: case AT_FLOAT_ARRAY:
AddRawDelta( pDelta, CDmrArray< float >( pBaseData ), baseFieldIndex, weight, pMask ); {
break; CDmrArray< float > array( pBaseData );
case AT_COLOR_ARRAY: AddRawDelta( pDelta, array, baseFieldIndex, weight, pMask );
// TODO: Color is missing some algebraic operators break;
// AddRawDelta( pDelta, CDmrArray< Color >( pBaseData ), baseFieldIndex, weight, pMask ); }
break; case AT_COLOR_ARRAY:
case AT_VECTOR2_ARRAY: // TODO: Color is missing some algebraic operators
AddRawDelta( pDelta, CDmrArray< Vector2D >( pBaseData ), baseFieldIndex, weight, pMask ); // AddRawDelta( pDelta, CDmrArray< Color >( pBaseData ), baseFieldIndex, weight, pMask
break; //);
case AT_VECTOR3_ARRAY: break;
AddRawDelta( pDelta, CDmrArray< Vector >( pBaseData ), baseFieldIndex, weight, pMask ); case AT_VECTOR2_ARRAY:
break; {
default: CDmrArray< Vector2D > array( pBaseData );
break; AddRawDelta( pDelta, array, baseFieldIndex, weight, pMask );
break;
}
case AT_VECTOR3_ARRAY:
{
CDmrArray< Vector > array( pBaseData );
AddRawDelta( pDelta, array, baseFieldIndex, weight, pMask );
break;
}
default:
break;
} }
break; break;
} }
@ -3917,18 +3859,30 @@ bool CDmeMesh::AddCorrectedMaskedDelta(
switch ( pBaseData->GetType() ) switch ( pBaseData->GetType() )
{ {
case AT_FLOAT_ARRAY: case AT_FLOAT_ARRAY:
AddCorrectedDelta( CDmrArray< float >( pBaseData ), baseIndices, compList[ i ], baseFieldName, weight, pMask ); {
break; CDmrArray< float > array1( pBaseData );
case AT_COLOR_ARRAY: AddCorrectedDelta( array1, baseIndices, compList[i], baseFieldName, weight, pMask );
AddCorrectedDelta( CDmrArray< Vector >( pBaseData ), baseIndices, compList[ i ], baseFieldName, weight, pMask ); break;
break; }
case AT_VECTOR2_ARRAY: case AT_COLOR_ARRAY:
AddCorrectedDelta( CDmrArray< Vector2D >( pBaseData ), baseIndices, compList[ i ], baseFieldName, weight, pMask ); {
break; CDmrArray< Vector > array2( pBaseData );
case AT_VECTOR3_ARRAY: AddCorrectedDelta( array2, baseIndices, compList[i], baseFieldName, weight, pMask );
AddCorrectedDelta( CDmrArray< Vector >( pBaseData ), baseIndices, compList[ i ], baseFieldName, weight, pMask ); break;
break; }
case AT_VECTOR2_ARRAY:
{
CDmrArray< Vector2D > array3( pBaseData );
AddCorrectedDelta( array3, baseIndices, compList[i], baseFieldName, weight, pMask );
break;
}
case AT_VECTOR3_ARRAY:
{
CDmrArray< Vector > array4( pBaseData );
AddCorrectedDelta( array4, baseIndices, compList[i], baseFieldName, weight, pMask );
break;
}
default: default:
break; break;
} }
@ -3941,135 +3895,6 @@ bool CDmeMesh::AddCorrectedMaskedDelta(
} }
//-----------------------------------------------------------------------------
// Interpolates between two arrays of values and stores the result in a
// CDmrArray.
//
// result = ( ( 1 - weight ) * a ) + ( weight * b )
//
//-----------------------------------------------------------------------------
template< class T_t >
bool CDmeMesh::InterpMaskedData(
CDmrArray< T_t > &aData,
const CUtlVector< T_t > &bData,
float weight,
const CDmeSingleIndexedComponent *pMask ) const
{
const int nDst = aData.Count();
if ( bData.Count() != nDst )
return false;
// The wacky way of writing these expression is because Vector4D is missing operators
// And this probably works better because of fewer temporaries
T_t a;
T_t b;
if ( pMask )
{
// With a weight mask
float vWeight;
for ( int i = 0; i < nDst; ++i )
{
if ( pMask->GetWeight( i, vWeight ) )
{
vWeight *= weight; // Specifically not clamping
a = aData.Get( i );
a *= ( 1.0f - vWeight );
b = bData[ i ];
b *= vWeight;
b += a;
aData.Set( i, b );
}
}
}
else
{
// Without a weight mask
const float oneMinusWeight( 1.0f - weight );
for ( int i = 0; i < nDst; ++i )
{
a = aData.Get( i );
a *= oneMinusWeight;
b = bData[ i ];
b *= weight;
b += a;
aData.Set( i, b );
}
}
return true;
}
//-----------------------------------------------------------------------------
// Interpolates between two CDmeVertexData's
//
// paData = ( ( 1 - weight ) * a ) + ( weight * b )
//-----------------------------------------------------------------------------
bool CDmeMesh::InterpMaskedData(
CDmeVertexData *paData,
const CDmeVertexData *pbData,
float weight,
const CDmeSingleIndexedComponent *pMask ) const
{
if ( !paData || !pbData || paData == pbData )
return false;
const int naField = paData->FieldCount();
const int nbField = pbData->FieldCount();
for ( int i = 0; i < naField; ++i )
{
const CUtlString &aFieldName( paData->FieldName( i ) );
for ( int j = 0; j < nbField; ++j )
{
const CUtlString &bFieldName( pbData->FieldName( j ) );
if ( aFieldName != bFieldName )
continue;
const FieldIndex_t aFieldIndex( paData->FindFieldIndex( aFieldName ) );
const FieldIndex_t bFieldIndex( pbData->FindFieldIndex( bFieldName ) );
if ( aFieldIndex < 0 || bFieldIndex < 0 )
break;
CDmAttribute *paAttr( paData->GetVertexData( aFieldIndex ) );
const CDmAttribute *pbAttr( pbData->GetVertexData( bFieldIndex ) );
if ( paAttr->GetType() != pbAttr->GetType() )
break;
if ( paData->GetVertexIndexData( aFieldIndex ).Count() != pbData->GetVertexIndexData( bFieldIndex ).Count() )
break;
switch ( paAttr->GetType() )
{
case AT_FLOAT_ARRAY:
InterpMaskedData( CDmrArray< float >( paAttr ), CDmrArrayConst< float >( pbAttr ).Get(), weight, pMask );
break;
case AT_COLOR_ARRAY:
InterpMaskedData( CDmrArray< Vector4D >( paAttr ), CDmrArrayConst< Vector4D >( pbAttr ).Get(), weight, pMask );
break;
case AT_VECTOR2_ARRAY:
InterpMaskedData( CDmrArray< Vector2D >( paAttr ), CDmrArrayConst< Vector2D >( pbAttr ).Get(), weight, pMask );
break;
case AT_VECTOR3_ARRAY:
InterpMaskedData( CDmrArray< Vector >( paAttr ), CDmrArrayConst< Vector >( pbAttr ).Get(), weight, pMask );
break;
default:
break;
}
break;
}
}
return true;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Interpolates between the specified VertexData and the specified Delta // Interpolates between the specified VertexData and the specified Delta
// If pBase is NULL it will become the current state // If pBase is NULL it will become the current state
@ -4152,22 +3977,22 @@ bool CDmeMesh::InterpMaskedDelta(
{ {
case AT_FLOAT_ARRAY: case AT_FLOAT_ARRAY:
floatData = CDmrArrayConst< float >( pBindData ).Get(); floatData = CDmrArrayConst< float >( pBindData ).Get();
AddCorrectedDelta( floatData, bindIndices, compList[ i ], baseFieldName ); AddCorrectedDelta( floatData, bindIndices, compList[ i ], baseFieldName, weight, pMask );
InterpMaskedData( CDmrArray< float >( pDstBaseData ), floatData, weight, pMask ); InterpMaskedData( CDmrArray< float >( pDstBaseData ), floatData, weight, pMask );
break; break;
case AT_COLOR_ARRAY: case AT_COLOR_ARRAY:
vector4DData = CDmrArrayConst< Vector4D >( pBindData ).Get(); vector4DData = CDmrArrayConst< Vector4D >( pBindData ).Get();
AddCorrectedDelta( vector4DData, bindIndices, compList[ i ], baseFieldName ); AddCorrectedDelta( vector4DData, bindIndices, compList[ i ], baseFieldName, weight, pMask );
InterpMaskedData( CDmrArray< Vector4D >( pDstBaseData ), vector4DData, weight, pMask ); InterpMaskedData( CDmrArray< Vector4D >( pDstBaseData ), vector4DData, weight, pMask );
break; break;
case AT_VECTOR2_ARRAY: case AT_VECTOR2_ARRAY:
vector2DData = CDmrArrayConst< Vector2D >( pBindData ).Get(); vector2DData = CDmrArrayConst< Vector2D >( pBindData ).Get();
AddCorrectedDelta( vector2DData, bindIndices, compList[ i ], baseFieldName ); AddCorrectedDelta( vector2DData, bindIndices, compList[ i ], baseFieldName, weight, pMask );
InterpMaskedData( CDmrArray< Vector2D >( pDstBaseData ), vector2DData, weight, pMask ); InterpMaskedData( CDmrArray< Vector2D >( pDstBaseData ), vector2DData, weight, pMask );
break; break;
case AT_VECTOR3_ARRAY: case AT_VECTOR3_ARRAY:
vectorData = CDmrArrayConst< Vector >( pBindData ).Get(); vectorData = CDmrArrayConst< Vector >( pBindData ).Get();
AddCorrectedDelta( vectorData, bindIndices, compList[ i ], baseFieldName ); AddCorrectedDelta( vectorData, bindIndices, compList[ i ], baseFieldName, weight, pMask );
InterpMaskedData( CDmrArray< Vector >( pDstBaseData ), vectorData, weight, pMask ); InterpMaskedData( CDmrArray< Vector >( pDstBaseData ), vectorData, weight, pMask );
break; break;
default: default:
@ -4664,11 +4489,19 @@ bool CDmeMesh::SetBaseStateToDeltas( CDmeVertexData *pPassedBase /*= NULL */ )
switch ( pDstAttr->GetType() ) switch ( pDstAttr->GetType() )
{ {
case AT_FLOAT_ARRAY: case AT_FLOAT_ARRAY:
SetBaseDataToDeltas( pBind, nStandardField, CDmrArrayConst< float >( pSrcAttr ), CDmrArray< float >( pDstAttr ), bDoStereo, false ); {
CDmrArrayConst< float > array( pSrcAttr );
CDmrArray< float > array2( pDstAttr );
SetBaseDataToDeltas( pBind, nStandardField, array, array2, bDoStereo, false );
break; break;
}
case AT_VECTOR3_ARRAY: case AT_VECTOR3_ARRAY:
SetBaseDataToDeltas( pBind, nStandardField, CDmrArrayConst< Vector >( pSrcAttr ), CDmrArray< Vector >( pDstAttr ), bDoStereo, false ); {
CDmrArrayConst< Vector > array( pSrcAttr );
CDmrArray< Vector > array2( pDstAttr );
SetBaseDataToDeltas( pBind, nStandardField, array, array2, bDoStereo, false );
break; break;
}
default: default:
Assert( 0 ); Assert( 0 );
break; break;

View file

@ -8,8 +8,8 @@
#include "movieobjects_interfaces.h" #include "movieobjects_interfaces.h"
#include "datamodel/dmelementfactoryhelper.h" #include "datamodel/dmelementfactoryhelper.h"
#include "vgui/iinput.h" #include "vgui/IInput.h"
#include "vgui/ipanel.h" #include "vgui/IPanel.h"
#include "tier3/tier3.h" #include "tier3/tier3.h"
#include "tier0/dbg.h" #include "tier0/dbg.h"

View file

@ -12,9 +12,9 @@
#include "tier1/utlbuffer.h" #include "tier1/utlbuffer.h"
#include "tier1/convar.h" #include "tier1/convar.h"
#include "particles/particles.h" #include "particles/particles.h"
#include "dme_controls/attributeintchoicepanel.h" #include "dme_controls/AttributeIntChoicePanel.h"
#include "dme_controls/attributeboolchoicepanel.h" #include "dme_controls/AttributeBoolChoicePanel.h"
#include "dme_controls/attributestringchoicepanel.h" #include "dme_controls/AttributeStringChoicePanel.h"
// memdbgon must be the last include file in a .cpp file!!! // memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h" #include "tier0/memdbgon.h"

View file

@ -10,7 +10,6 @@
#include "movieobjects/dmecombinationoperator.h" #include "movieobjects/dmecombinationoperator.h"
#include "movieobjects/dmemodel.h" #include "movieobjects/dmemodel.h"
#include "movieobjects/dmedag.h" #include "movieobjects/dmedag.h"
#include "movieobjects/dmemesh.h"
#include "movieobjects/dmefaceset.h" #include "movieobjects/dmefaceset.h"
#include "movieobjects/dmematerial.h" #include "movieobjects/dmematerial.h"
#include "movieobjects/dmevertexdata.h" #include "movieobjects/dmevertexdata.h"
@ -19,7 +18,7 @@
#include "tier1/utlstack.h" #include "tier1/utlstack.h"
#include "tier2/p4helpers.h" #include "tier2/p4helpers.h"
#include "tier1/utlstring.h" #include "tier1/utlstring.h"
#include "tier1/utlstringmap.h" #include "tier1/UtlStringMap.h"
#include "tier1/utlbuffer.h" #include "tier1/utlbuffer.h"
#include "tier1/fmtstr.h" #include "tier1/fmtstr.h"
#include "filesystem.h" #include "filesystem.h"
@ -436,7 +435,7 @@ void RemoveUnusedData(
const char *pFieldName, const char *pFieldName,
int *pIndices, int *pIndices,
int nIndicesCount, int nIndicesCount,
CDmrGenericArray &data ) CDmrGenericArray &&data )
{ {
const int nDataCount = data.Count(); const int nDataCount = data.Count();
@ -1403,8 +1402,8 @@ bool CDmMeshUtils::Merge( CDmeMesh *pSrcMesh, CDmElement *pRoot )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template < class T_t > template < class T_t >
void AppendData( void AppendData(
const CDmrArrayConst< T_t > &srcData, const CDmrArrayConst< T_t > &&srcData,
CDmrArray< T_t > &dstData, CDmrArray< T_t > &&dstData,
const matrix3x4_t *pMat = NULL ) const matrix3x4_t *pMat = NULL )
{ {
const int nSrcCount = srcData.Count(); const int nSrcCount = srcData.Count();
@ -1420,8 +1419,8 @@ void AppendData(
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template <> template <>
void AppendData( void AppendData(
const CDmrArrayConst< Vector > &srcData, const CDmrArrayConst< Vector > &&srcData,
CDmrArray< Vector > &dstData, CDmrArray< Vector > &&dstData,
const matrix3x4_t *pMat ) const matrix3x4_t *pMat )
{ {
const int nSrcCount = srcData.Count(); const int nSrcCount = srcData.Count();

View file

@ -5,12 +5,7 @@
//============================================================================= //=============================================================================
// Because we use STL
#pragma warning( disable: 4530 )
// Standard includes // Standard includes
#include <io.h>
#include <algorithm> #include <algorithm>
#include <deque> #include <deque>
#include <fstream> #include <fstream>
@ -526,8 +521,8 @@ bool CQcData::GetQcData(
if ( sFileBase0.Length() > 0 && sFilePath.Length() > 0 ) if ( sFileBase0.Length() > 0 && sFilePath.Length() > 0 )
{ {
struct _finddata_t qcFile; CUtlString qcFile;
long hFile; FileFindHandle_t hFile;
CUtlVector< CUtlString > tokens; CUtlVector< CUtlString > tokens;
@ -536,12 +531,16 @@ bool CQcData::GetQcData(
CUtlString sQcGlob = sFilePath; CUtlString sQcGlob = sFilePath;
sQcGlob += "*.qc"; sQcGlob += "*.qc";
if ( ( hFile = _findfirst( sQcGlob.Get(), &qcFile ) ) != -1L ) const auto found = g_pFullFileSystem->FindFirst( sQcGlob.Get(), &hFile );
if ( found )
{ {
qcFile = found;
/* Find the rest of the .qc files */ /* Find the rest of the .qc files */
do { do {
CUtlString sQcFile = sFilePath; CUtlString sQcFile = sFilePath;
sQcFile += qcFile.name; sQcFile += qcFile;
std::ifstream ifs( sQcFile.Get() ); std::ifstream ifs( sQcFile.Get() );
std::string buf; std::string buf;
@ -550,13 +549,22 @@ bool CQcData::GetQcData(
{ {
if ( V_stristr( buf.c_str(), sFileBase0.Get() ) || V_stristr( buf.c_str(), sFileBase1.Get() ) ) if ( V_stristr( buf.c_str(), sFileBase0.Get() ) || V_stristr( buf.c_str(), sFileBase1.Get() ) )
{ {
_findclose( hFile ); g_pFullFileSystem->FindClose( hFile );
return ParseQc( smdPath, sQcFile ); return ParseQc( smdPath, sQcFile );
} }
} }
} while( _findnext( hFile, &qcFile ) == 0 );
_findclose( hFile ); const auto next = g_pFullFileSystem->FindNext( hFile );
if ( !next )
{
break;
}
qcFile = next;
} while( true );
g_pFullFileSystem->FindClose( hFile );
} }
} }
} }

View file

@ -76,7 +76,6 @@ $Project "Movieobjects"
$File "movieobjects_interfaces.cpp" $File "movieobjects_interfaces.cpp"
$File "$SRCDIR\common\movieobjects\timeutils.cpp" $File "$SRCDIR\common\movieobjects\timeutils.cpp"
$File "dmedrawsettings.cpp" $File "dmedrawsettings.cpp"
$File "dmmeshutils.cpp"
$File "dmmeshcomp.cpp" $File "dmmeshcomp.cpp"
$File "dmeeyeposition.cpp" $File "dmeeyeposition.cpp"
$File "dmeeyeball.cpp" $File "dmeeyeball.cpp"

50
movieobjects/wscript Executable file
View file

@ -0,0 +1,50 @@
#! /usr/bin/env python
# encoding: utf-8
from waflib import Utils
import os
import vpc_parser
top = '.'
PROJECT_NAME = 'movieobjects'
def options(opt):
# stub
return
def configure(conf):
return
def build(bld):
movieobjects_vpc = vpc_parser.parse_vpcs( bld.env, ['movieobjects.vpc'], '..' )
source = movieobjects_vpc["sources"]
includes = movieobjects_vpc["includes"]
includes += [
'../public',
'../public/tier0',
'../public/tier1',
'../public/tier2',
'../public/tier3',
]
defines = movieobjects_vpc["defines"]
libs = ['tier0','tier1','tier2','tier3']
if bld.env.DEST_OS == 'android':
libs += ['ANDROID_SUPPORT']
install_path = bld.env.LIBDIR
bld.stlib(
source = source,
target = PROJECT_NAME,
name = PROJECT_NAME,
features = 'c cxx',
includes = includes,
defines = defines,
use = libs,
install_path = install_path,
subsystem = bld.env.MSVC_SUBSYSTEM,
idx = bld.get_taskgen_count()
)

View file

@ -204,7 +204,7 @@ private:
// Called by elements after unserialization of their attributes is complete // Called by elements after unserialization of their attributes is complete
void OnUnserializationFinished(); void OnUnserializationFinished();
template< class T > bool IsTypeConvertable() const; template< class T > bool inline IsTypeConvertable() const;
template< class T > bool ShouldModify( const T& src ); template< class T > bool ShouldModify( const T& src );
template< class T > void CopyData( const T& src ); template< class T > void CopyData( const T& src );
template< class T > void CopyDataOut( T& dest ) const; template< class T > void CopyDataOut( T& dest ) const;
@ -228,7 +228,45 @@ private:
template< class T > friend class CDmArrayAttributeOp; template< class T > friend class CDmArrayAttributeOp;
}; };
//-----------------------------------------------------------------------------
// Type conversion related methods
//-----------------------------------------------------------------------------
template< class T > inline bool CDmAttribute::IsTypeConvertable() const
{
return ( CDmAttributeInfo< T >::ATTRIBUTE_TYPE == GetType() );
}
template<> inline bool CDmAttribute::IsTypeConvertable<bool>() const
{
DmAttributeType_t type = GetType();
return ( type == AT_BOOL || type == AT_INT || type == AT_FLOAT );
}
template<> inline bool CDmAttribute::IsTypeConvertable<int>() const
{
DmAttributeType_t type = GetType();
return ( type == AT_INT || type == AT_BOOL || type == AT_FLOAT );
}
template<> inline bool CDmAttribute::IsTypeConvertable<float>() const
{
DmAttributeType_t type = GetType();
return ( type == AT_FLOAT || type == AT_INT || type == AT_BOOL );
}
template<> inline bool CDmAttribute::IsTypeConvertable<QAngle>() const
{
DmAttributeType_t type = GetType();
return ( type == AT_QANGLE || type == AT_QUATERNION );
}
template<> inline bool CDmAttribute::IsTypeConvertable<Quaternion>() const
{
DmAttributeType_t type = GetType();
return ( type == AT_QUATERNION || type == AT_QANGLE);
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Inline methods // Inline methods
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View file

@ -461,13 +461,13 @@ class CDmaArray : public CDmaDecorator< T, CDmaArrayBase< T, CDmaDataInternal< C
public: public:
const CDmaArray<T>& operator=( const CDmaArray<T> &val ) const CDmaArray<T>& operator=( const CDmaArray<T> &val )
{ {
CopyArray( val.Base(), val.Count() ); this->CopyArray( val.Base(), val.Count() );
return *this; return *this;
} }
template< class C > const CDmaArray<T>& operator=( const C &val ) template< class C > const CDmaArray<T>& operator=( const C &val )
{ {
CopyArray( val.Base(), val.Count() ); this->CopyArray( val.Base(), val.Count() );
return *this; return *this;
} }
@ -493,13 +493,13 @@ class CDmrArray : public CDmrDecorator< T, CDmaArrayBase< T, CDmaDataExternal< C
public: public:
const CDmrArray<T>& operator=( const CDmrArray<T> &val ) const CDmrArray<T>& operator=( const CDmrArray<T> &val )
{ {
CopyArray( val.Base(), val.Count() ); this->CopyArray( val.Base(), val.Count() );
return *this; return *this;
} }
template< class C > const CDmrArray<T>& operator=( const C &val ) template< class C > const CDmrArray<T>& operator=( const C &val )
{ {
CopyArray( val.Base(), val.Count() ); this->CopyArray( val.Base(), val.Count() );
return *this; return *this;
} }
}; };
@ -513,13 +513,13 @@ class CDmaStringArray : public CDmaDecorator< CUtlString, CDmaStringArrayBase< C
public: public:
const CDmaStringArray& operator=( const CDmaStringArray &val ) const CDmaStringArray& operator=( const CDmaStringArray &val )
{ {
CopyArray( val.Base(), val.Count() ); this->CopyArray( val.Base(), val.Count() );
return *this; return *this;
} }
template< class C > const CDmaStringArray& operator=( const C &val ) template< class C > const CDmaStringArray& operator=( const C &val )
{ {
CopyArray( val.Base(), val.Count() ); this->CopyArray( val.Base(), val.Count() );
return *this; return *this;
} }
@ -538,13 +538,13 @@ public:
const CDmrStringArray& operator=( const CDmrStringArray &val ) const CDmrStringArray& operator=( const CDmrStringArray &val )
{ {
CopyArray( val.Base(), val.Count() ); this->CopyArray( val.Base(), val.Count() );
return *this; return *this;
} }
template< class C > const CDmrStringArray& operator=( const C &val ) template< class C > const CDmrStringArray& operator=( const C &val )
{ {
CopyArray( val.Base(), val.Count() ); this->CopyArray( val.Base(), val.Count() );
return *this; return *this;
} }
}; };
@ -588,14 +588,14 @@ public:
template< typename C > CDmaElementArray<E>& operator=( const C &val ) template< typename C > CDmaElementArray<E>& operator=( const C &val )
{ {
CopyArray( val.Base(), val.Count() ); this->CopyArray( val.Base(), val.Count() );
return *this; return *this;
} }
// NOTE: The copy operator= must be defined in addition to the generic one // NOTE: The copy operator= must be defined in addition to the generic one
const CDmaElementArray<E>& operator=( const CDmaElementArray<E> &val ) const CDmaElementArray<E>& operator=( const CDmaElementArray<E> &val )
{ {
CopyArray( val.Base(), val.Count() ); this->CopyArray( val.Base(), val.Count() );
return *this; return *this;
} }
@ -734,14 +734,14 @@ public:
template< typename C > CDmrElementArray<T>& operator=( const C &val ) template< typename C > CDmrElementArray<T>& operator=( const C &val )
{ {
CopyArray( val.Base(), val.Count() ); this->CopyArray( val.Base(), val.Count() );
return *this; return *this;
} }
// NOTE: The copy operator= must be defined in addition to the generic one // NOTE: The copy operator= must be defined in addition to the generic one
const CDmrElementArray<T>& operator=( const CDmrElementArray<T> &val ) const CDmrElementArray<T>& operator=( const CDmrElementArray<T> &val )
{ {
CopyArray( val.Base(), val.Count() ); this->CopyArray( val.Base(), val.Count() );
return *this; return *this;
} }
}; };

View file

@ -157,6 +157,18 @@ private:
CDmElementFactoryHelper g_##className##_Helper( #lookupName, &g_##className##_Factory, true ); \ CDmElementFactoryHelper g_##className##_Helper( #lookupName, &g_##className##_Factory, true ); \
className *g_##className##LinkerHack = NULL; className *g_##className##LinkerHack = NULL;
#define IMPLEMENT_ELEMENT_FACTORY_T( lookupName, className ) \
template<> IMPLEMENT_ELEMENT( className ) \
CDmElementFactory< className > g_##className##_Factory( #lookupName ); \
CDmElementFactoryHelper g_##className##_Helper( #lookupName, &g_##className##_Factory, true ); \
className *g_##className##LinkerHack = NULL;
#define IMPLEMENT_ABSTRACT_ELEMENT_T( lookupName, className ) \
template<> IMPLEMENT_ELEMENT( className ) \
CDmAbstractElementFactory< className > g_##className##_Factory; \
CDmElementFactoryHelper g_##className##_Helper( #lookupName, &g_##className##_Factory, true ); \
className *g_##className##LinkerHack = NULL;
#else #else
#define IMPLEMENT_ELEMENT_FACTORY( lookupName, className ) \ #define IMPLEMENT_ELEMENT_FACTORY( lookupName, className ) \
@ -171,6 +183,18 @@ private:
CDmElementFactoryHelper g_##className##_Helper( #lookupName, &g_##className##_Factory, false ); \ CDmElementFactoryHelper g_##className##_Helper( #lookupName, &g_##className##_Factory, false ); \
className *g_##className##LinkerHack = NULL; className *g_##className##LinkerHack = NULL;
#define IMPLEMENT_ELEMENT_FACTORY_T( lookupName, className ) \
template<> IMPLEMENT_ELEMENT( className ) \
CDmElementFactory< className > g_##className##_Factory( #lookupName ); \
CDmElementFactoryHelper g_##className##_Helper( #lookupName, &g_##className##_Factory, false ); \
className *g_##className##LinkerHack = NULL;
#define IMPLEMENT_ABSTRACT_ELEMENT_T( lookupName, className ) \
template<> IMPLEMENT_ELEMENT( className ) \
CDmAbstractElementFactory< className > g_##className##_Factory; \
CDmElementFactoryHelper g_##className##_Helper( #lookupName, &g_##className##_Factory, false ); \
className *g_##className##LinkerHack = NULL;
#endif #endif

View file

@ -13,7 +13,7 @@
#include "tier0/basetypes.h" #include "tier0/basetypes.h"
#include "tier1/utlstringmap.h" #include "tier1/UtlStringMap.h"
#include "vgui_controls/EditablePanel.h" #include "vgui_controls/EditablePanel.h"
#include "datamodel/dmelement.h" #include "datamodel/dmelement.h"
#include "datamodel/dmehandle.h" #include "datamodel/dmehandle.h"

View file

@ -10,6 +10,7 @@
#pragma once #pragma once
#endif #endif
#include "dmeoperator.h"
#include "datamodel/dmelement.h" #include "datamodel/dmelement.h"
#include "datamodel/dmattribute.h" #include "datamodel/dmattribute.h"
#include "datamodel/dmattributevar.h" #include "datamodel/dmattributevar.h"

View file

@ -18,6 +18,7 @@
#include "materialsystem/MaterialSystemUtil.h" #include "materialsystem/MaterialSystemUtil.h"
#include "tier1/utlmap.h" #include "tier1/utlmap.h"
#include "movieobjects/timeutils.h" #include "movieobjects/timeutils.h"
#include "datamodel/dmelementfactoryhelper.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View file

@ -401,7 +401,7 @@ protected:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// CDmeTypedCurveInfo - implementation class for all logs // CDmeTypedCurveInfo - implementation class for all logs
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template< class T > template< class T2 >
class CDmeTypedCurveInfo : public CDmeCurveInfo class CDmeTypedCurveInfo : public CDmeCurveInfo
{ {
DEFINE_ELEMENT( CDmeTypedCurveInfo, CDmeCurveInfo ); DEFINE_ELEMENT( CDmeTypedCurveInfo, CDmeCurveInfo );
@ -411,29 +411,29 @@ public:
void SetUseEdgeInfo( bool state ); void SetUseEdgeInfo( bool state );
bool IsUsingEdgeInfo() const; bool IsUsingEdgeInfo() const;
void SetEdgeInfo( int edge, bool active, const T& val, int curveType ); void SetEdgeInfo( int edge, bool active, const T2& val, int curveType );
void GetEdgeInfo( int edge, bool& active, T& val, int& curveType ) const; void GetEdgeInfo( int edge, bool& active, T2& val, int& curveType ) const;
void SetDefaultEdgeZeroValue( const T& val ); void SetDefaultEdgeZeroValue( const T2& val );
const T& GetDefaultEdgeZeroValue() const; const T2& GetDefaultEdgeZeroValue() const;
void SetRightEdgeTime( DmeTime_t time ); void SetRightEdgeTime( DmeTime_t time );
DmeTime_t GetRightEdgeTime() const; DmeTime_t GetRightEdgeTime() const;
bool IsEdgeActive( int edge ) const; bool IsEdgeActive( int edge ) const;
void GetEdgeValue( int edge, T& value ) const; void GetEdgeValue( int edge, T2& value ) const;
int GetEdgeCurveType( int edge ) const; int GetEdgeCurveType( int edge ) const;
void GetZeroValue( int side, T& val ) const; void GetZeroValue( int side, T2& val ) const;
protected: protected:
CDmaVar< bool > m_bUseEdgeInfo; CDmaVar< bool > m_bUseEdgeInfo;
// Array of 2 for left/right edges... // Array of 2 for left/right edges...
CDmaVar< bool > m_bEdgeActive[ 2 ]; CDmaVar< bool > m_bEdgeActive[ 2 ];
CDmaVar< T > m_EdgeValue[ 2 ]; CDmaVar< T2 > m_EdgeValue[ 2 ];
CDmaVar< int > m_EdgeCurveType[ 2 ]; CDmaVar< int > m_EdgeCurveType[ 2 ];
CDmaVar< int > m_RightEdgeTime; CDmaVar< int > m_RightEdgeTime;
CDmaVar< T > m_DefaultEdgeValue; CDmaVar< T2 > m_DefaultEdgeValue;
}; };
@ -444,7 +444,7 @@ template< class T > class CDmeTypedLog;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// CDmeTypedLogLayer - implementation class for all logs // CDmeTypedLogLayer - implementation class for all logs
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template< class T > template< class T2 >
class CDmeTypedLogLayer : public CDmeLogLayer class CDmeTypedLogLayer : public CDmeLogLayer
{ {
DEFINE_ELEMENT( CDmeTypedLogLayer, CDmeLogLayer ); DEFINE_ELEMENT( CDmeTypedLogLayer, CDmeLogLayer );
@ -456,22 +456,22 @@ public:
virtual void InsertKeyFromLayer( DmeTime_t keyTime, const CDmeLogLayer *src, DmeTime_t srcKeyTime ); virtual void InsertKeyFromLayer( DmeTime_t keyTime, const CDmeLogLayer *src, DmeTime_t srcKeyTime );
// Finds a key within tolerance, or adds one. Unlike SetKey, this will *not* delete keys after the specified time // Finds a key within tolerance, or adds one. Unlike SetKey, this will *not* delete keys after the specified time
int FindOrAddKey( DmeTime_t nTime, DmeTime_t nTolerance, const T& value, int curveType = CURVE_DEFAULT ); int FindOrAddKey( DmeTime_t nTime, DmeTime_t nTolerance, const T2& value, int curveType = CURVE_DEFAULT );
// Sets a key, removes all keys after this time // Sets a key, removes all keys after this time
void SetKey( DmeTime_t time, const T& value, int curveType = CURVE_DEFAULT ); void SetKey( DmeTime_t time, const T2& value, int curveType = CURVE_DEFAULT );
// This inserts a key using the current values to construct the proper value for the time // This inserts a key using the current values to construct the proper value for the time
virtual int InsertKeyAtTime( DmeTime_t nTime, int curveType = CURVE_DEFAULT ); virtual int InsertKeyAtTime( DmeTime_t nTime, int curveType = CURVE_DEFAULT );
void SetKeyValue( int nKey, const T& value ); void SetKeyValue( int nKey, const T2& value );
const T& GetValue( DmeTime_t time ) const; const T2& GetValue( DmeTime_t time ) const;
const T& GetKeyValue( int nKeyIndex ) const; const T2& GetKeyValue( int nKeyIndex ) const;
const T& GetValueSkippingKey( int nKeyToSkip ) const; const T2& GetValueSkippingKey( int nKeyToSkip ) const;
// This inserts a key. Unlike SetKey, this will *not* delete keys after the specified time // This inserts a key. Unlike SetKey, this will *not* delete keys after the specified time
int InsertKey( DmeTime_t nTime, const T& value, int curveType = CURVE_DEFAULT ); int InsertKey( DmeTime_t nTime, const T2& value, int curveType = CURVE_DEFAULT );
// inherited from CDmeLog // inherited from CDmeLog
virtual void ClearKeys(); virtual void ClearKeys();
@ -492,41 +492,41 @@ public:
void RemoveKeys( DmeTime_t starttime ); void RemoveKeys( DmeTime_t starttime );
// curve info helpers // curve info helpers
const CDmeTypedCurveInfo< T > *GetTypedCurveInfo() const; const CDmeTypedCurveInfo< T2 > *GetTypedCurveInfo() const;
CDmeTypedCurveInfo< T > *GetTypedCurveInfo(); CDmeTypedCurveInfo< T2 > *GetTypedCurveInfo();
bool IsUsingEdgeInfo() const; bool IsUsingEdgeInfo() const;
void GetEdgeInfo( int edge, bool& active, T& val, int& curveType ) const; void GetEdgeInfo( int edge, bool& active, T2& val, int& curveType ) const;
const T& GetDefaultEdgeZeroValue() const; const T2& GetDefaultEdgeZeroValue() const;
DmeTime_t GetRightEdgeTime() const; DmeTime_t GetRightEdgeTime() const;
void SetOwnerLog( CDmeLog *owner ); void SetOwnerLog( CDmeLog *owner );
CDmeTypedLog< T > *GetTypedOwnerLog(); CDmeTypedLog< T2 > *GetTypedOwnerLog();
const CDmeTypedLog< T > *GetTypedOwnerLog() const; const CDmeTypedLog< T2 > *GetTypedOwnerLog() const;
protected: protected:
int GetEdgeCurveType( int edge ) const; int GetEdgeCurveType( int edge ) const;
void GetZeroValue( int side, T& val ) const; void GetZeroValue( int side, T2& val ) const;
void GetValueUsingCurveInfo( DmeTime_t time, T& out ) const; void GetValueUsingCurveInfo( DmeTime_t time, T2& out ) const;
void GetValueUsingCurveInfoSkippingKey( int nKeyToSkip, T& out ) const; void GetValueUsingCurveInfoSkippingKey( int nKeyToSkip, T2& out ) const;
void GetBoundedSample( int keyindex, DmeTime_t& time, T& val, int& curveType ) const; void GetBoundedSample( int keyindex, DmeTime_t& time, T2& val, int& curveType ) const;
void CurveSimplify_R( float thresholdSqr, int startPoint, int endPoint, CDmeTypedLogLayer< T > *output ); void CurveSimplify_R( float thresholdSqr, int startPoint, int endPoint, CDmeTypedLogLayer< T2 > *output );
friend CDmeTypedLog< T >; friend CDmeTypedLog< T2 >;
protected: protected:
CDmaArray< T > m_values; CDmaArray< T2 > m_values;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// CDmeTypedLog - implementation class for all logs // CDmeTypedLog - implementation class for all logs
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template< class T > template< class T2 >
class CDmeTypedLog : public CDmeLog class CDmeTypedLog : public CDmeLog
{ {
DEFINE_ELEMENT( CDmeTypedLog, CDmeLog ); DEFINE_ELEMENT( CDmeTypedLog, CDmeLog );
@ -535,10 +535,10 @@ public:
virtual void OnAttributeArrayElementAdded( CDmAttribute *pAttribute, int nFirstElem, int nLastElem ); virtual void OnAttributeArrayElementAdded( CDmAttribute *pAttribute, int nFirstElem, int nLastElem );
CDmeTypedLogLayer< T > *GetLayer( int index ); CDmeTypedLogLayer< T2 > *GetLayer( int index );
const CDmeTypedLogLayer< T > *GetLayer( int index ) const; const CDmeTypedLogLayer< T2 > *GetLayer( int index ) const;
void StampKeyAtHead( DmeTime_t tHeadPosition, DmeTime_t tPreviousHeadPosition, const DmeLog_TimeSelection_t& params, const T& value ); void StampKeyAtHead( DmeTime_t tHeadPosition, DmeTime_t tPreviousHeadPosition, const DmeLog_TimeSelection_t& params, const T2& value );
void StampKeyAtHead( DmeTime_t tHeadPosition, DmeTime_t tPreviousHeadPosition, const DmeLog_TimeSelection_t& params, const CDmAttribute *pAttr, uint index = 0 ); void StampKeyAtHead( DmeTime_t tHeadPosition, DmeTime_t tPreviousHeadPosition, const DmeLog_TimeSelection_t& params, const CDmAttribute *pAttr, uint index = 0 );
void FinishTimeSelection( DmeTime_t tHeadPosition, DmeLog_TimeSelection_t& params ); // in attached, timeadvancing mode, we need to blend out of the final sample over the fadeout interval void FinishTimeSelection( DmeTime_t tHeadPosition, DmeLog_TimeSelection_t& params ); // in attached, timeadvancing mode, we need to blend out of the final sample over the fadeout interval
void FilterUsingTimeSelection( IUniformRandomStream *random, float flScale, const DmeLog_TimeSelection_t& params, int filterType, bool bResample, bool bApplyFalloff, const CDmeLogLayer *baseLayer, CDmeLogLayer *writeLayer ); void FilterUsingTimeSelection( IUniformRandomStream *random, float flScale, const DmeLog_TimeSelection_t& params, int filterType, bool bResample, bool bApplyFalloff, const CDmeLogLayer *baseLayer, CDmeLogLayer *writeLayer );
@ -556,19 +556,19 @@ public:
virtual void BuildNormalizedLayer( CDmeTypedLogLayer< float > *target ); virtual void BuildNormalizedLayer( CDmeTypedLogLayer< float > *target );
// Finds a key within tolerance, or adds one. Unlike SetKey, this will *not* delete keys after the specified time // Finds a key within tolerance, or adds one. Unlike SetKey, this will *not* delete keys after the specified time
int FindOrAddKey( DmeTime_t nTime, DmeTime_t nTolerance, const T& value, int curveType = CURVE_DEFAULT ); int FindOrAddKey( DmeTime_t nTime, DmeTime_t nTolerance, const T2& value, int curveType = CURVE_DEFAULT );
// Sets a key, removes all keys after this time // Sets a key, removes all keys after this time
void SetKey( DmeTime_t time, const T& value, int curveType = CURVE_DEFAULT ); void SetKey( DmeTime_t time, const T2& value, int curveType = CURVE_DEFAULT );
int InsertKeyAtTime( DmeTime_t nTime, int curveType = CURVE_DEFAULT ); int InsertKeyAtTime( DmeTime_t nTime, int curveType = CURVE_DEFAULT );
bool ValuesDiffer( const T& a, const T& b ) const; inline bool ValuesDiffer( const T2& a, const T2& b ) const;
const T& GetValue( DmeTime_t time ) const; const T2& GetValue( DmeTime_t time ) const;
const T& GetValueSkippingTopmostLayer( DmeTime_t time ) const; const T2& GetValueSkippingTopmostLayer( DmeTime_t time ) const;
const T& GetKeyValue( int nKeyIndex ) const; const T2& GetKeyValue( int nKeyIndex ) const;
// This inserts a key. Unlike SetKey, this will *not* delete keys after the specified time // This inserts a key. Unlike SetKey, this will *not* delete keys after the specified time
int InsertKey( DmeTime_t nTime, const T& value, int curveType = CURVE_DEFAULT ); int InsertKey( DmeTime_t nTime, const T2& value, int curveType = CURVE_DEFAULT );
// inherited from CDmeLog // inherited from CDmeLog
virtual void ClearKeys(); virtual void ClearKeys();
@ -601,8 +601,8 @@ public:
virtual CDmeLogLayer *RemoveLayer( int iLayer ); virtual CDmeLogLayer *RemoveLayer( int iLayer );
// curve info helpers // curve info helpers
const CDmeTypedCurveInfo< T > *GetTypedCurveInfo() const; const CDmeTypedCurveInfo< T2 > *GetTypedCurveInfo() const;
CDmeTypedCurveInfo< T > *GetTypedCurveInfo(); CDmeTypedCurveInfo< T2 > *GetTypedCurveInfo();
virtual CDmeCurveInfo *GetOrCreateCurveInfo(); virtual CDmeCurveInfo *GetOrCreateCurveInfo();
virtual void SetCurveInfo( CDmeCurveInfo *pCurveInfo ); virtual void SetCurveInfo( CDmeCurveInfo *pCurveInfo );
@ -610,39 +610,36 @@ public:
void SetUseEdgeInfo( bool state ); void SetUseEdgeInfo( bool state );
bool IsUsingEdgeInfo() const; bool IsUsingEdgeInfo() const;
void SetEdgeInfo( int edge, bool active, const T& val, int curveType ); void SetEdgeInfo( int edge, bool active, const T2& val, int curveType );
void GetEdgeInfo( int edge, bool& active, T& val, int& curveType ) const; void GetEdgeInfo( int edge, bool& active, T2& val, int& curveType ) const;
void SetDefaultEdgeZeroValue( const T& val ); void SetDefaultEdgeZeroValue( const T2& val );
const T& GetDefaultEdgeZeroValue() const; const T2& GetDefaultEdgeZeroValue() const;
void SetRightEdgeTime( DmeTime_t time ); void SetRightEdgeTime( DmeTime_t time );
DmeTime_t GetRightEdgeTime() const; DmeTime_t GetRightEdgeTime() const;
bool IsEdgeActive( int edge ) const; bool IsEdgeActive( int edge ) const;
void GetEdgeValue( int edge, T& value ) const; void GetEdgeValue( int edge, T2& value ) const;
int GetEdgeCurveType( int edge ) const; int GetEdgeCurveType( int edge ) const;
void GetZeroValue( int side, T& val ) const; void GetZeroValue( int side, T2& val ) const;
T ClampValue( const T& value ); T2 ClampValue( const T2& value );
void SetDefaultValue( const T& value ); void SetDefaultValue( const T2& value );
const T& GetDefaultValue() const; const T2& GetDefaultValue() const;
bool HasDefaultValue() const; bool HasDefaultValue() const;
void ClearDefaultValue(); void ClearDefaultValue();
static void SetDefaultValueThreshold( float thresh );
static float GetDefaultValueThreshold();
static float s_defaultThreshold; static float s_defaultThreshold;
protected: protected:
void RemoveKeys( DmeTime_t starttime ); void RemoveKeys( DmeTime_t starttime );
void _StampKeyAtHeadResample( DmeTime_t tHeadPosition, const DmeLog_TimeSelection_t & params, const T& value, bool bSkipToHead, bool bClearPreviousKeys ); void _StampKeyAtHeadResample( DmeTime_t tHeadPosition, const DmeLog_TimeSelection_t & params, const T2& value, bool bSkipToHead, bool bClearPreviousKeys );
void _StampKeyAtHeadFilteredByTimeSelection( DmeTime_t tHeadPosition, DmeTime_t tPreviousHeadPosition, const DmeLog_TimeSelection_t & params, const T& value ); void _StampKeyAtHeadFilteredByTimeSelection( DmeTime_t tHeadPosition, DmeTime_t tPreviousHeadPosition, const DmeLog_TimeSelection_t & params, const T2& value );
void _StampKeyFilteredByTimeSelection( CDmeTypedLogLayer< T > *pWriteLayer, DmeTime_t t, const DmeLog_TimeSelection_t &params, const T& value, bool bForce = false ); void _StampKeyFilteredByTimeSelection( CDmeTypedLogLayer< T2 > *pWriteLayer, DmeTime_t t, const DmeLog_TimeSelection_t &params, const T2& value, bool bForce = false );
protected: protected:
// this really only makes sense for some of our subclasses, basically those which have float data // this really only makes sense for some of our subclasses, basically those which have float data
@ -650,9 +647,41 @@ protected:
float m_threshold; float m_threshold;
CDmaVar< bool > m_UseDefaultValue; CDmaVar< bool > m_UseDefaultValue;
CDmaVar< T > m_DefaultValue; CDmaVar< T2 > m_DefaultValue;
}; };
//-----------------------------------------------------------------------------
// tests whether two values differ by more than the threshold
//-----------------------------------------------------------------------------
template<>
inline bool CDmeTypedLog< Vector >::ValuesDiffer( const Vector& a, const Vector& b ) const
{
return a.DistToSqr( b ) > m_threshold * m_threshold;
}
template<>
inline bool CDmeTypedLog< QAngle >::ValuesDiffer( const QAngle& a, const QAngle& b ) const
{
return ( a - b ).LengthSqr() > m_threshold * m_threshold;
}
template<>
inline bool CDmeTypedLog< Quaternion >::ValuesDiffer( const Quaternion& a, const Quaternion& b ) const
{
return QuaternionAngleDiff( a, b ) > m_threshold;
}
template<>
inline bool CDmeTypedLog< float >::ValuesDiffer( const float& a, const float& b ) const
{
return fabs( a - b ) > m_threshold;
}
template< class T >
inline bool CDmeTypedLog< T >::ValuesDiffer( const T& a, const T& b ) const
{
return a != b;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Template methods // Template methods
@ -686,18 +715,6 @@ DmAttributeType_t CDmeTypedLog<T>::GetDataType() const
return CDmAttributeInfo< T >::AttributeType(); return CDmAttributeInfo< T >::AttributeType();
} }
template< class T >
void CDmeTypedLog<T>::SetDefaultValueThreshold( float thresh )
{
s_defaultThreshold = thresh;
}
template< class T >
float CDmeTypedLog<T>::GetDefaultValueThreshold()
{
return s_defaultThreshold;
}
template< class T > template< class T >
void CDmeTypedLog<T>::SetValueThreshold( float thresh ) void CDmeTypedLog<T>::SetValueThreshold( float thresh )
{ {
@ -836,7 +853,54 @@ template<> void CDmeTypedLogLayer< Vector >::GetValueUsingCurveInfoSkippingKey(
template<> void CDmeTypedLogLayer< Quaternion >::GetValueUsingCurveInfo( DmeTime_t time, Quaternion& out ) const; template<> void CDmeTypedLogLayer< Quaternion >::GetValueUsingCurveInfo( DmeTime_t time, Quaternion& out ) const;
template<> void CDmeTypedLogLayer< Quaternion >::GetValueUsingCurveInfoSkippingKey( int nKeyToSkip, Quaternion& out ) const; template<> void CDmeTypedLogLayer< Quaternion >::GetValueUsingCurveInfoSkippingKey( int nKeyToSkip, Quaternion& out ) const;
template<class T> void CDmeTypedLogLayer< T >::CurveSimplify_R( float thresholdSqr, int startPoint, int endPoint, CDmeTypedLogLayer< T > *output ); template< class T >
T Subtract( const T& v1, const T& v2 )
{
return v1 - v2;
}
template< class T >
float LengthOf( const T& value )
{
return value;
}
// Implementation of Douglas-Peucker curve simplification routine (hacked to only care about error against original curve (sort of 1D)
template< class T >
void CDmeTypedLogLayer< T >::CurveSimplify_R( float thresholdSqr, int startPoint, int endPoint, CDmeTypedLogLayer< T > *output )
{
if ( endPoint <= startPoint + 1 )
{
return;
}
int maxPoint = startPoint;
float maxDistanceSqr = 0.0f;
for ( int i = startPoint + 1 ; i < endPoint; ++i )
{
DmeTime_t keyTime = GetKeyTime( i );
T check = GetKeyValue( i );
T check2 = output->GetValue( keyTime );
T dist = Subtract( check, check2 );
float distSqr = LengthOf( dist ) * LengthOf( dist );
if ( distSqr < maxDistanceSqr )
continue;
maxPoint = i;
maxDistanceSqr = distSqr;
}
if ( maxDistanceSqr > thresholdSqr )
{
output->InsertKey( GetKeyTime( maxPoint ), GetKeyValue( maxPoint ) );
CurveSimplify_R( thresholdSqr, startPoint, maxPoint, output );
CurveSimplify_R( thresholdSqr, maxPoint, endPoint, output );
}
}
template<> void CDmeTypedLogLayer< bool >::CurveSimplify_R( float thresholdSqr, int startPoint, int endPoint, CDmeTypedLogLayer< bool > *output ); template<> void CDmeTypedLogLayer< bool >::CurveSimplify_R( float thresholdSqr, int startPoint, int endPoint, CDmeTypedLogLayer< bool > *output );
template<> void CDmeTypedLogLayer< int >::CurveSimplify_R( float thresholdSqr, int startPoint, int endPoint, CDmeTypedLogLayer< int > *output ); template<> void CDmeTypedLogLayer< int >::CurveSimplify_R( float thresholdSqr, int startPoint, int endPoint, CDmeTypedLogLayer< int > *output );
template<> void CDmeTypedLogLayer< Color >::CurveSimplify_R( float thresholdSqr, int startPoint, int endPoint, CDmeTypedLogLayer< Color > *output ); template<> void CDmeTypedLogLayer< Color >::CurveSimplify_R( float thresholdSqr, int startPoint, int endPoint, CDmeTypedLogLayer< Color > *output );

View file

@ -17,6 +17,25 @@
#include "mathlib/vector.h" #include "mathlib/vector.h"
#include "tier1/utllinkedlist.h" #include "tier1/utllinkedlist.h"
#include "Color.h" #include "Color.h"
#include "movieobjects/dmevertexdata.h"
#include "movieobjects/dmefaceset.h"
#include "movieobjects/dmematerial.h"
#include "movieobjects/dmetransform.h"
#include "movieobjects/dmemodel.h"
#include "movieobjects/dmecombinationoperator.h"
#include "movieobjects/dmeselection.h"
#include "movieobjects/dmedrawsettings.h"
#include "movieobjects/dmmeshcomp.h"
#include "tier3/tier3.h"
#include "tier1/KeyValues.h"
#include "tier0/dbg.h"
#include "datamodel/dmelementfactoryhelper.h"
#include "materialsystem/imaterialsystem.h"
#include "materialsystem/imorph.h"
#include "materialsystem/imesh.h"
#include "materialsystem/imaterialvar.h"
#include "istudiorender.h"
#include "studio.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -331,21 +350,84 @@ private:
static void ComputeCorrectedPositionsFromActualPositions( const CUtlVector< int > &deltaStateList, int nPositionCount, Vector *pPositions ); static void ComputeCorrectedPositionsFromActualPositions( const CUtlVector< int > &deltaStateList, int nPositionCount, Vector *pPositions );
template < class T_t > void AddCorrectedDelta( //-----------------------------------------------------------------------------
// There's no guarantee that fields are added in any order, nor that only
// standard fields exist...
//-----------------------------------------------------------------------------
template < class T_t >
void AddCorrectedDelta(
CDmrArray< T_t > &baseDataArray, CDmrArray< T_t > &baseDataArray,
const CUtlVector< int > &baseIndices, const CUtlVector< int > &baseIndices,
const DeltaComputation_t &deltaComputation, const DeltaComputation_t &deltaComputation,
const char *pFieldName, const char *pFieldName,
float weight = 1.0f, float weight = 1.0f,
const CDmeSingleIndexedComponent *pMask = NULL ); const CDmeSingleIndexedComponent *pMask = NULL )
{
const CUtlVector< T_t > &baseData( baseDataArray.Get() );
const int nData( baseData.Count() );
T_t *pData( reinterpret_cast< T_t * >( alloca( nData * sizeof( T_t ) ) ) );
Q_memcpy( pData, baseData.Base(), nData * sizeof( T_t ) );
template < class T_t > void AddCorrectedDelta( CDmeVertexDeltaData *pDelta( GetDeltaState( deltaComputation.m_nDeltaIndex ) );
const int deltaFieldIndex( pDelta->FindFieldIndex( pFieldName ) );
if ( deltaFieldIndex < 0 )
return;
AddDelta( pDelta, pData, nData, deltaFieldIndex, weight, pMask );
const CUtlVector< int > &depDeltas( deltaComputation.m_DependentDeltas );
const int nDepDeltas( depDeltas.Count() );
for ( int j( 0 ); j < nDepDeltas; ++j )
{
pDelta = GetDeltaState( depDeltas[ j ] );
int depFieldIndex = pDelta->FindFieldIndex( pFieldName );
if ( depFieldIndex < 0 )
continue;
AddDelta( pDelta, pData, nData, depFieldIndex, weight, pMask );
}
baseDataArray.CopyArray( pData, nData );
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
template < class T_t >
void AddCorrectedDelta(
CUtlVector< T_t > &baseData, CUtlVector< T_t > &baseData,
const CUtlVector< int > &baseIndices, const CUtlVector< int > &baseIndices,
const DeltaComputation_t &deltaComputation, const DeltaComputation_t &deltaComputation,
const char *pFieldName, const char *pFieldName,
float weight = 1.0f, float weight = 1.0f,
const CDmeSingleIndexedComponent *pMask = NULL ); const CDmeSingleIndexedComponent *pMask = NULL )
{
const int nData( baseData.Count() );
CDmeVertexDeltaData *pDelta( GetDeltaState( deltaComputation.m_nDeltaIndex ) );
const int deltaFieldIndex( pDelta->FindFieldIndex( pFieldName ) );
if ( deltaFieldIndex < 0 )
return;
AddDelta( pDelta, baseData.Base(), nData, deltaFieldIndex, weight, pMask );
const CUtlVector< int > &depDeltas( deltaComputation.m_DependentDeltas );
const int nDepDeltas( depDeltas.Count() );
for ( int j( 0 ); j < nDepDeltas; ++j )
{
pDelta = GetDeltaState( depDeltas[ j ] );
int depFieldIndex = pDelta->FindFieldIndex( pFieldName );
if ( depFieldIndex < 0 )
continue;
AddDelta( pDelta, baseData.Base(), nData, depFieldIndex, weight, pMask );
}
}
// Add the delta into the vertex data state weighted by the weight and masked by the weight map // Add the delta into the vertex data state weighted by the weight and masked by the weight map
bool AddCorrectedMaskedDelta( bool AddCorrectedMaskedDelta(
@ -422,18 +504,134 @@ private:
bool CreateDeltaFieldFromBaseField( CDmeVertexData::StandardFields_t nStandardFieldIndex, const CDmrArrayConst< Vector2D > &baseArray, const CDmrArrayConst< Vector2D > &bindArray, CDmeVertexDeltaData *pDelta ); bool CreateDeltaFieldFromBaseField( CDmeVertexData::StandardFields_t nStandardFieldIndex, const CDmrArrayConst< Vector2D > &baseArray, const CDmrArrayConst< Vector2D > &bindArray, CDmeVertexDeltaData *pDelta );
bool CreateDeltaFieldFromBaseField( CDmeVertexData::StandardFields_t nStandardFieldIndex, const CDmrArrayConst< Vector > &baseArray, const CDmrArrayConst< Vector > &bindArray, CDmeVertexDeltaData *pDelta ); bool CreateDeltaFieldFromBaseField( CDmeVertexData::StandardFields_t nStandardFieldIndex, const CDmrArrayConst< Vector > &baseArray, const CDmrArrayConst< Vector > &bindArray, CDmeVertexDeltaData *pDelta );
template< class T_t > bool InterpMaskedData(
CDmrArray< T_t > &aData, //-----------------------------------------------------------------------------
// Interpolates between two arrays of values and stores the result in a
// CDmrArray.
//
// result = ( ( 1 - weight ) * a ) + ( weight * b )
//
//-----------------------------------------------------------------------------
template< class T_t >
bool InterpMaskedData(
CDmrArray< T_t > &&aData,
const CUtlVector< T_t > &bData, const CUtlVector< T_t > &bData,
float weight, float weight,
const CDmeSingleIndexedComponent *pMask ) const; const CDmeSingleIndexedComponent *pMask ) const
{
const int nDst = aData.Count();
// Interpolate between the current state and the specified delta by the specified percentage masked by the selection if ( bData.Count() != nDst )
return false;
// The wacky way of writing these expression is because Vector4D is missing operators
// And this probably works better because of fewer temporaries
T_t a;
T_t b;
if ( pMask )
{
// With a weight mask
float vWeight;
for ( int i = 0; i < nDst; ++i )
{
if ( pMask->GetWeight( i, vWeight ) )
{
vWeight *= weight; // Specifically not clamping
a = aData.Get( i );
a *= ( 1.0f - vWeight );
b = bData[ i ];
b *= vWeight;
b += a;
aData.Set( i, b );
}
}
}
else
{
// Without a weight mask
const float oneMinusWeight( 1.0f - weight );
for ( int i = 0; i < nDst; ++i )
{
a = aData.Get( i );
a *= oneMinusWeight;
b = bData[ i ];
b *= weight;
b += a;
aData.Set( i, b );
}
}
return true;
}
//-----------------------------------------------------------------------------
// Interpolates between two CDmeVertexData's
//
// paData = ( ( 1 - weight ) * a ) + ( weight * b )
//-----------------------------------------------------------------------------
bool InterpMaskedData( bool InterpMaskedData(
CDmeVertexData *paData, CDmeVertexData *paData,
const CDmeVertexData *pbData, const CDmeVertexData *pbData,
float weight, float weight,
const CDmeSingleIndexedComponent *pMask ) const; const CDmeSingleIndexedComponent *pMask ) const
{
if ( !paData || !pbData || paData == pbData )
return false;
const int naField = paData->FieldCount();
const int nbField = pbData->FieldCount();
for ( int i = 0; i < naField; ++i )
{
const CUtlString &aFieldName( paData->FieldName( i ) );
for ( int j = 0; j < nbField; ++j )
{
const CUtlString &bFieldName( pbData->FieldName( j ) );
if ( aFieldName != bFieldName )
continue;
const FieldIndex_t aFieldIndex( paData->FindFieldIndex( aFieldName ) );
const FieldIndex_t bFieldIndex( pbData->FindFieldIndex( bFieldName ) );
if ( aFieldIndex < 0 || bFieldIndex < 0 )
break;
CDmAttribute *paAttr( paData->GetVertexData( aFieldIndex ) );
const CDmAttribute *pbAttr( pbData->GetVertexData( bFieldIndex ) );
if ( paAttr->GetType() != pbAttr->GetType() )
break;
if ( paData->GetVertexIndexData( aFieldIndex ).Count() != pbData->GetVertexIndexData( bFieldIndex ).Count() )
break;
switch ( paAttr->GetType() )
{
case AT_FLOAT_ARRAY:
InterpMaskedData( CDmrArray< float >( paAttr ), CDmrArrayConst< float >( pbAttr ).Get(), weight, pMask );
break;
case AT_COLOR_ARRAY:
InterpMaskedData( CDmrArray< Vector4D >( paAttr ), CDmrArrayConst< Vector4D >( pbAttr ).Get(), weight, pMask );
break;
case AT_VECTOR2_ARRAY:
InterpMaskedData( CDmrArray< Vector2D >( paAttr ), CDmrArrayConst< Vector2D >( pbAttr ).Get(), weight, pMask );
break;
case AT_VECTOR3_ARRAY:
InterpMaskedData( CDmrArray< Vector >( paAttr ), CDmrArrayConst< Vector >( pbAttr ).Get(), weight, pMask );
break;
default:
break;
}
break;
}
}
return true;
}
// Find the closest vertex in the specified selection to the passed vertex in the specified base state, if the passed base state is NULL is the current base state // Find the closest vertex in the specified selection to the passed vertex in the specified base state, if the passed base state is NULL is the current base state
int ClosestSelectedVertex( int vIndex, CDmeSingleIndexedComponent *pSelection, const CDmeVertexData *pPassedBase = NULL ) const; int ClosestSelectedVertex( int vIndex, CDmeSingleIndexedComponent *pSelection, const CDmeVertexData *pPassedBase = NULL ) const;

View file

@ -14,7 +14,7 @@
#include "movieobjects/timeutils.h" #include "movieobjects/timeutils.h"
#include "movieobjects/dmetimeselectiontimes.h" #include "movieobjects/dmetimeselectiontimes.h"
enum RecordingState_t; #include "dme_controls/RecordingState.h"
class CDmeTimeSelection : public CDmElement class CDmeTimeSelection : public CDmElement
{ {

View file

@ -16,6 +16,7 @@
#include "datamodel/dmattributevar.h" #include "datamodel/dmattributevar.h"
#include "datamodel/dmehandle.h" #include "datamodel/dmehandle.h"
#include "movieobjects/timeutils.h" #include "movieobjects/timeutils.h"
#include "movieobjects/dmeclip.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -24,8 +25,6 @@
class CDmeClip; class CDmeClip;
class CDmeFilmClip; class CDmeFilmClip;
class CDmeTrack; class CDmeTrack;
enum DmeClipType_t;
enum DmeClipSkipFlag_t;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View file

@ -12,13 +12,22 @@
#pragma once #pragma once
#endif #endif
#include "dmemesh.h"
#include "movieobjects/dmeanimationset.h"
#include "movieobjects/dmecombinationoperator.h"
#include "movieobjects/dmemodel.h"
#include "movieobjects/dmedag.h"
#include "movieobjects/dmefaceset.h"
#include "movieobjects/dmematerial.h"
#include "movieobjects/dmevertexdata.h" #include "movieobjects/dmevertexdata.h"
#include "movieobjects/dmmeshcomp.h" // TODO: This has to be included before dmmeshutils.h
#include "tier1/utlstack.h"
#include "tier2/p4helpers.h"
#include "tier1/utlstring.h" #include "tier1/utlstring.h"
#include "tier1/UtlStringMap.h" #include "tier1/UtlStringMap.h"
#include "tier1/utlvector.h" #include "tier1/utlbuffer.h"
#include "tier1/fmtstr.h"
class CDmeMesh; #include "filesystem.h"
class CDmMeshComp::CEdge;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -179,7 +188,7 @@ inline bool CDmMeshFaceIt::GetVertexData(
if ( IsDone() ) if ( IsDone() )
return false; return false;
CDmeVertexData *pBase = pPassedBase ? pPassedBase : m_pMesh->GetCurrentBaseState(); auto *pBase = pPassedBase ? pPassedBase : m_pMesh->GetCurrentBaseState();
if ( !pBase ) if ( !pBase )
return false; return false;
@ -187,7 +196,7 @@ inline bool CDmMeshFaceIt::GetVertexData(
if ( nFieldIndex < 0 ) if ( nFieldIndex < 0 )
return false; return false;
CDmAttribute *pDataAttr = pBase->GetVertexData( nFieldIndex ); auto *pDataAttr = pBase->GetVertexData( nFieldIndex );
if ( pDataAttr->GetType() != CDmAttributeInfo< CUtlVector< T_t > >().AttributeType() ) if ( pDataAttr->GetType() != CDmAttributeInfo< CUtlVector< T_t > >().AttributeType() )
return false; return false;

View file

@ -19,6 +19,7 @@
#include "tier1/utlbuffer.h" #include "tier1/utlbuffer.h"
#include "tier1/utlstring.h" #include "tier1/utlstring.h"
#include "tier1/utlvector.h" #include "tier1/utlvector.h"
#include "utlmap.h"
@ -123,7 +124,7 @@ protected:
int &nId, int &nId,
int &nParentId ) const; int &nParentId ) const;
CDmElement *CDmSmdSerializer::ReadSMD( CDmElement *ReadSMD(
CUtlBuffer &inUtlBuf, CUtlBuffer &inUtlBuf,
DmFileId_t nDmFileId, DmFileId_t nDmFileId,
const char *pszFilename, const char *pszFilename,

View file

@ -1216,7 +1216,7 @@ int CScriptLib::GetFileList( const char* pDirPath, const char* pPattern, CUtlVec
FIND_DATA findData; FIND_DATA findData;
Q_FixSlashes( fullPath ); Q_FixSlashes( fullPath );
void *h = FindFirstFile( fullPath, &findData ); void *h = FindFirstFile( fullPath, &findData );
if ( (int)h == -1 ) if ( (uintptr_t)h == -1 )
{ {
return 0; return 0;
} }

View file

@ -11,7 +11,7 @@
#include "tier0/memdbgon.h" #include "tier0/memdbgon.h"
#include "filesystem.h" #include "filesystem.h"
#include "icommandline.h" #include "icommandline.h"
#include "tier1/utlstringmap.h" #include "tier1/UtlStringMap.h"
#include "tier1/strtools.h" #include "tier1/strtools.h"
#include "tier1/utlmap.h" #include "tier1/utlmap.h"
#include "tier2/fileutils.h" #include "tier2/fileutils.h"

View file

@ -11,7 +11,7 @@
#include "tier2/tier2.h" #include "tier2/tier2.h"
#include "tier0/memdbgon.h" #include "tier0/memdbgon.h"
#include "filesystem.h" #include "filesystem.h"
#include "tier1/utlstringmap.h" #include "tier1/UtlStringMap.h"
#include "tier1/strtools.h" #include "tier1/strtools.h"
#include "tier1/utlmap.h" #include "tier1/utlmap.h"
#include "bitmap/float_bm.h" #include "bitmap/float_bm.h"

View file

@ -1,8 +1,5 @@
#include "nvtristripobjects.h"
#pragma warning( disable : 4786 4018 4530 ) #include "nvtristrip.h"
#include "NvTriStripObjects.h"
#include "NvTriStrip.h"
#include <assert.h> #include <assert.h>
static inline unsigned short AsUShort( int nValue ) static inline unsigned short AsUShort( int nValue )

View file

@ -1,10 +1,7 @@
#pragma warning( disable : 4786 4018 4530 )
#include <assert.h> #include <assert.h>
#include <set> #include <set>
#include "NvTriStripObjects.h" #include "nvtristripobjects.h"
#include "VertexCache.h" #include "vertexcache.h"
#include "tier0/platform.h" #include "tier0/platform.h"
#define CACHE_INEFFICIENCY 6 #define CACHE_INEFFICIENCY 6
@ -1107,7 +1104,7 @@ void NvStripifier::Stripify(const WordVec &in_indices, const int in_cacheSize,
int numSamples = 10; int numSamples = 10;
//the cache size, clamped to one //the cache size, clamped to one
cacheSize = max(1, in_cacheSize - CACHE_INEFFICIENCY); cacheSize = std::max(1, in_cacheSize - CACHE_INEFFICIENCY);
minStripLength = in_minStripLength; //this is the strip size threshold below which we dump the strip into a list minStripLength = in_minStripLength; //this is the strip size threshold below which we dump the strip into a list

View file

@ -3,10 +3,18 @@
#define NV_TRISTRIP_OBJECTS_H #define NV_TRISTRIP_OBJECTS_H
#include <assert.h> #include <assert.h>
#include <windows.h>
#include <vector> #include <vector>
#include <list> #include <list>
#include "VertexCache.h" #include <cstdint>
#include <iostream>
#include <string.h>
#include <math.h>
#include "vertexcache.h"
#define NULL nullptr
typedef uint32_t UINT;
typedef uint16_t WORD;
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// //

50
utils/nvtristriplib/wscript Executable file
View file

@ -0,0 +1,50 @@
#! /usr/bin/env python
# encoding: utf-8
from waflib import Utils
import os
import vpc_parser
top = '.'
PROJECT_NAME = 'nvtristriplib'
def options(opt):
# stub
return
def configure(conf):
return
def build(bld):
source = ['nvtristripobjects.cpp', 'nvtristrip.cpp']
includes = [
'../../public',
'../../public/tier0',
'../../public/tier1',
'../../public/tier2',
'../../public/tier3',
]
defines = []
install_path = bld.env.LIBDIR
libs = ['tier0','tier1','tier2','tier3']
if bld.env.DEST_OS == 'android':
libs += ['ANDROID_SUPPORT']
install_path = bld.env.LIBDIR
bld.stlib(
source = source,
target = PROJECT_NAME,
name = PROJECT_NAME,
features = 'c cxx',
includes = includes,
defines = defines,
use = libs,
install_path = install_path,
subsystem = bld.env.MSVC_SUBSYSTEM,
idx = bld.get_taskgen_count()
)

View file

@ -21,7 +21,7 @@
#include "tier2/p4helpers.h" #include "tier2/p4helpers.h"
#include "p4lib/ip4.h" #include "p4lib/ip4.h"
#include "tier1/utlbuffer.h" #include "tier1/utlbuffer.h"
#include "tier1/utlstringmap.h" #include "tier1/UtlStringMap.h"
#include "datamodel/dmelement.h" #include "datamodel/dmelement.h"
#ifdef _DEBUG #ifdef _DEBUG

View file

@ -109,7 +109,7 @@ static void WriteOBJ( const char *pszFilename, const s_source_t *pSource )
for ( int j = 0; j < m.numfaces; ++j ) for ( int j = 0; j < m.numfaces; ++j )
{ {
const s_face_t &f = pSource->face[m.faceoffset + j]; const s_face_t &f = pSource->face[m.faceoffset + j];
fprintf( pFile, "f %d/%d/%d %d/%d/%d %d/%d/%d\n", fprintf( pFile, "f %li/%li/%li %li/%li/%li %li/%li/%li\n",
f.a, f.a, f.a, f.a, f.a, f.a,
f.b, f.b, f.b, f.b, f.b, f.b,
f.c, f.c, f.c ); f.c, f.c, f.c );

View file

@ -1138,18 +1138,25 @@ int Load_DMX( s_source_t *pSource )
// Load model info // Load model info
LoadModelInfo( pRoot, pFullPath ); LoadModelInfo( pRoot, pFullPath );
auto dwError = [&]()
{
fileId = pRoot->GetFileId();
g_pDataModel->RemoveFileId( fileId );
return 0;
};
// Extract out the skeleton // Extract out the skeleton
CDmeDag *pSkeleton = pRoot->GetValueElement< CDmeDag >( "skeleton" ); CDmeDag *pSkeleton = pRoot->GetValueElement< CDmeDag >( "skeleton" );
CDmeModel *pModel = pRoot->GetValueElement< CDmeModel >( "model" ); CDmeModel *pModel = pRoot->GetValueElement< CDmeModel >( "model" );
CDmeCombinationOperator *pCombinationOperator = pRoot->GetValueElement< CDmeCombinationOperator >( "combinationOperator" ); CDmeCombinationOperator *pCombinationOperator = pRoot->GetValueElement< CDmeCombinationOperator >( "combinationOperator" );
if ( !pSkeleton ) if ( !pSkeleton )
goto dmxError; return dwError();
// BoneRemap[bone index in file] == bone index in studiomdl // BoneRemap[bone index in file] == bone index in studiomdl
BoneTransformMap_t boneMap; BoneTransformMap_t boneMap;
pSource->numbones = LoadSkeleton( pSkeleton, pModel, pSource->localBone, boneMap ); pSource->numbones = LoadSkeleton( pSkeleton, pModel, pSource->localBone, boneMap );
if ( pSource->numbones == 0 ) if ( pSource->numbones == 0 )
goto dmxError; return dwError();
LoadAttachments( pSkeleton, pSkeleton, pSource ); LoadAttachments( pSkeleton, pSkeleton, pSource );
@ -1162,7 +1169,7 @@ int Load_DMX( s_source_t *pSource )
} }
LoadBindPose( pModel, g_currentscale, boneMap.m_pBoneRemap, pSource ); LoadBindPose( pModel, g_currentscale, boneMap.m_pBoneRemap, pSource );
if ( !LoadMeshes( pModel, g_currentscale, boneMap.m_pBoneRemap, pSource ) ) if ( !LoadMeshes( pModel, g_currentscale, boneMap.m_pBoneRemap, pSource ) )
goto dmxError; return dwError();
UnifyIndices( pSource ); UnifyIndices( pSource );
BuildVertexAnimations( pSource ); BuildVertexAnimations( pSource );
@ -1184,11 +1191,6 @@ int Load_DMX( s_source_t *pSource )
fileId = pRoot->GetFileId(); fileId = pRoot->GetFileId();
g_pDataModel->RemoveFileId( fileId ); g_pDataModel->RemoveFileId( fileId );
return 1; return 1;
dmxError:
fileId = pRoot->GetFileId();
g_pDataModel->RemoveFileId( fileId );
return 0;
} }

View file

@ -5,8 +5,7 @@
// $NoKeywords: $ // $NoKeywords: $
//=============================================================================// //=============================================================================//
#include <windows.h> #include "hardwarematrixstate.h"
#include "HardwareMatrixState.h"
#include <limits.h> #include <limits.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -197,7 +196,7 @@ void CHardwareMatrixState::DumpState( void )
return; return;
//#endif //#endif
OutputDebugString( "DumpState\n:" ); printf( "DumpState\n:" );
for( i = 0; i < m_NumMatrices; i++ ) for( i = 0; i < m_NumMatrices; i++ )
{ {
if( m_matrixState[i].allocated ) if( m_matrixState[i].allocated )
@ -207,7 +206,7 @@ void CHardwareMatrixState::DumpState( void )
m_matrixState[i].allocated ? "true " : "false", m_matrixState[i].allocated ? "true " : "false",
m_matrixState[i].lastUsageID, m_matrixState[i].lastUsageID,
m_matrixState[i].globalMatrixID ); m_matrixState[i].globalMatrixID );
OutputDebugString( buf ); printf( buf );
} }
} }
} }

View file

@ -7,7 +7,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include "HardwareVertexCache.h" #include "hardwarevertexcache.h"
CHardwareVertexCache::CHardwareVertexCache() CHardwareVertexCache::CHardwareVertexCache()
{ {

View file

@ -28,12 +28,12 @@
#include "cmdlib.h" #include "cmdlib.h"
#include "studio.h" #include "studio.h"
#include "studiomdl.h" #include "studiomdl.h"
#include "HardwareMatrixState.h" #include "hardwarematrixstate.h"
#include "HardwareVertexCache.h" #include "hardwarevertexcache.h"
#include "optimize.h" #include "optimize.h"
#include <malloc.h> #include <malloc.h>
#include <nvtristrip.h> #include <nvtristrip.h>
#include "FileBuffer.h" #include "filebuffer.h"
#include "tier1/utlvector.h" #include "tier1/utlvector.h"
#include "materialsystem/imaterial.h" #include "materialsystem/imaterial.h"
#include "tier1/utllinkedlist.h" #include "tier1/utllinkedlist.h"
@ -352,7 +352,7 @@ private:
// Memory optimize the strip data // Memory optimize the strip data
void PostProcessStripGroup( mstudiomodel_t *pStudioModel, mstudiomesh_t *pStudioMesh, StripGroup_t *pStripGroup ); void PostProcessStripGroup( mstudiomodel_t *pStudioModel, mstudiomesh_t *pStudioMesh, StripGroup_t *pStripGroup );
void COptimizedModel::ZeroNumBones( void ); void ZeroNumBones( void );
// //
// Methods associated with writing VTX files // Methods associated with writing VTX files

View file

@ -202,8 +202,8 @@ void SpewPerfStats( studiohdr_t *pStudioHdr, const char *pFilename, unsigned int
} }
// studio render will request these through cache interface // studio render will request these through cache interface
pStudioHdr->pVertexBase = (void *)pVvdHdr; pStudioHdr->SetVertexBase( (void *)pVvdHdr );
pStudioHdr->pIndexBase = (void *)pVtxHdr; pStudioHdr->SetIndexBase( (void *)pVtxHdr );
g_pStudioRender->LoadModel( pStudioHdr, pVtxHdr, &studioHWData ); g_pStudioRender->LoadModel( pStudioHdr, pVtxHdr, &studioHWData );

View file

@ -13,21 +13,24 @@
// //
#include "dbg.h"
#include <cstdlib>
#pragma warning( disable : 4244 ) #pragma warning( disable : 4244 )
#pragma warning( disable : 4237 ) #pragma warning( disable : 4237 )
#pragma warning( disable : 4305 ) #pragma warning( disable : 4305 )
#include <windows.h>
#undef GetCurrentDirectory #undef GetCurrentDirectory
#include <Shlwapi.h> // PathCanonicalize #ifdef _WIN32
#pragma comment( lib, "shlwapi" ) #else
#include <sys/types.h>
#include <sys/stat.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <math.h> #include <math.h>
#include <direct.h>
#include "istudiorender.h" #include "istudiorender.h"
#include "filesystem_tools.h" #include "filesystem_tools.h"
#include "tier2/fileutils.h" #include "tier2/fileutils.h"
@ -45,9 +48,9 @@
#include "bspflags.h" #include "bspflags.h"
#include "tier0/icommandline.h" #include "tier0/icommandline.h"
#include "utldict.h" #include "utldict.h"
#include "tier1/utlsortvector.h" #include "tier1/UtlSortVector.h"
#include "bitvec.h" #include "bitvec.h"
#include "appframework/appframework.h" #include "appframework/AppFramework.h"
#include "datamodel/idatamodel.h" #include "datamodel/idatamodel.h"
#include "materialsystem/materialsystem_config.h" #include "materialsystem/materialsystem_config.h"
#include "vstdlib/cvar.h" #include "vstdlib/cvar.h"
@ -203,8 +206,7 @@ void EnsureDependencyFileCheckedIn( const char *pFileName )
} }
Q_FixSlashes( pFullPath ); Q_FixSlashes( pFullPath );
char bufCanonicalPath[ MAX_PATH ] = {0}; auto bufCanonicalPath = canonicalize_file_name( pFullPath );
PathCanonicalize( bufCanonicalPath, pFullPath );
CP4AutoAddFile p4_add_dep_file( bufCanonicalPath ); CP4AutoAddFile p4_add_dep_file( bufCanonicalPath );
} }
@ -342,7 +344,7 @@ void MdlWarning( const char *fmt, ... )
if (g_bNoWarnings || g_maxWarnings == 0) if (g_bNoWarnings || g_maxWarnings == 0)
return; return;
WORD old = SetConsoleTextColor( 1, 1, 0, 1 ); // WORD old = SetConsoleTextColor( 1, 1, 0, 1 );
if (g_quiet) if (g_quiet)
{ {
@ -372,7 +374,7 @@ void MdlWarning( const char *fmt, ... )
printf("suppressing further warnings...\n"); printf("suppressing further warnings...\n");
} }
RestoreConsoleTextColor( old ); // RestoreConsoleTextColor( old );
} }
SpewRetval_t MdlSpewOutputFunc( SpewType_t type, char const *pMsg ) SpewRetval_t MdlSpewOutputFunc( SpewType_t type, char const *pMsg )
@ -387,92 +389,13 @@ SpewRetval_t MdlSpewOutputFunc( SpewType_t type, char const *pMsg )
} }
else else
{ {
return CmdLib_SpewOutputFunc( type, pMsg ); printf( pMsg );
return SPEW_ABORT;
} }
return SPEW_CONTINUE; return SPEW_CONTINUE;
} }
#ifndef _DEBUG
void MdlHandleCrash( const char *pMessage, bool bAssert )
{
static LONG crashHandlerCount = 0;
if ( InterlockedIncrement( &crashHandlerCount ) == 1 )
{
MdlError( "'%s' (assert: %d)\n", pMessage, bAssert );
}
InterlockedDecrement( &crashHandlerCount );
}
// This is called if we crash inside our crash handler. It just terminates the process immediately.
LONG __stdcall MdlSecondExceptionFilter( struct _EXCEPTION_POINTERS *ExceptionInfo )
{
TerminateProcess( GetCurrentProcess(), 2 );
return EXCEPTION_EXECUTE_HANDLER; // (never gets here anyway)
}
void MdlExceptionFilter( unsigned long code )
{
// This is called if we crash inside our crash handler. It just terminates the process immediately.
SetUnhandledExceptionFilter( MdlSecondExceptionFilter );
//DWORD code = ExceptionInfo->ExceptionRecord->ExceptionCode;
#define ERR_RECORD( name ) { name, #name }
struct
{
int code;
char *pReason;
} errors[] =
{
ERR_RECORD( EXCEPTION_ACCESS_VIOLATION ),
ERR_RECORD( EXCEPTION_ARRAY_BOUNDS_EXCEEDED ),
ERR_RECORD( EXCEPTION_BREAKPOINT ),
ERR_RECORD( EXCEPTION_DATATYPE_MISALIGNMENT ),
ERR_RECORD( EXCEPTION_FLT_DENORMAL_OPERAND ),
ERR_RECORD( EXCEPTION_FLT_DIVIDE_BY_ZERO ),
ERR_RECORD( EXCEPTION_FLT_INEXACT_RESULT ),
ERR_RECORD( EXCEPTION_FLT_INVALID_OPERATION ),
ERR_RECORD( EXCEPTION_FLT_OVERFLOW ),
ERR_RECORD( EXCEPTION_FLT_STACK_CHECK ),
ERR_RECORD( EXCEPTION_FLT_UNDERFLOW ),
ERR_RECORD( EXCEPTION_ILLEGAL_INSTRUCTION ),
ERR_RECORD( EXCEPTION_IN_PAGE_ERROR ),
ERR_RECORD( EXCEPTION_INT_DIVIDE_BY_ZERO ),
ERR_RECORD( EXCEPTION_INT_OVERFLOW ),
ERR_RECORD( EXCEPTION_INVALID_DISPOSITION ),
ERR_RECORD( EXCEPTION_NONCONTINUABLE_EXCEPTION ),
ERR_RECORD( EXCEPTION_PRIV_INSTRUCTION ),
ERR_RECORD( EXCEPTION_SINGLE_STEP ),
ERR_RECORD( EXCEPTION_STACK_OVERFLOW ),
ERR_RECORD( EXCEPTION_ACCESS_VIOLATION ),
};
int nErrors = sizeof( errors ) / sizeof( errors[0] );
{
int i;
for ( i=0; i < nErrors; i++ )
{
if ( errors[i].code == code )
MdlHandleCrash( errors[i].pReason, true );
}
if ( i == nErrors )
{
MdlHandleCrash( "Unknown reason", true );
}
}
TerminateProcess( GetCurrentProcess(), 1 );
}
#endif
/* /*
================= =================
================= =================
@ -490,7 +413,7 @@ void *kalloc( int num, int size )
nMemSize += 511; nMemSize += 511;
void *ptr = malloc( nMemSize ); void *ptr = malloc( nMemSize );
memset( ptr, 0, nMemSize ); memset( ptr, 0, nMemSize );
ptr = (byte *)((int)((byte *)ptr + 511) & ~511); ptr = (byte *)((uintptr_t)((byte *)ptr + 511) & ~511);
return ptr; return ptr;
} }
@ -2294,16 +2217,6 @@ int Option_Activity( s_sequence_t *psequence )
return 0; return 0;
} }
int Option_ActivityModifier( s_sequence_t *psequence )
{
GetToken(false);
V_strcpy_safe( psequence->activitymodifier[ psequence->numactivitymodifiers++ ].name, token );
return 0;
}
/* /*
=============== ===============
=============== ===============
@ -4159,10 +4072,6 @@ int ParseSequence( s_sequence_t *pseq, bool isAppend )
{ {
Option_Activity( pseq ); Option_Activity( pseq );
} }
else if (stricmp("activitymodifier", token ) == 0)
{
Option_ActivityModifier( pseq );
}
else if (strnicmp( token, "ACT_", 4 ) == 0) else if (strnicmp( token, "ACT_", 4 ) == 0)
{ {
UnGetToken( ); UnGetToken( );
@ -8364,9 +8273,9 @@ bool GetGlobalFilePath( const char *pSrc, char *pFullPath, int nMaxLen )
V_strcpy_safe( tmp, CmdLib_GetBasePath( i ) ); V_strcpy_safe( tmp, CmdLib_GetBasePath( i ) );
V_strcat_safe( tmp, pFileName + nPathLength ); V_strcat_safe( tmp, pFileName + nPathLength );
struct _stat buf; struct stat buf;
int rt = _stat( tmp, &buf ); int rt = stat( tmp, &buf );
if ( rt != -1 && ( buf.st_size > 0 ) && ( ( buf.st_mode & _S_IFDIR ) == 0 ) ) if ( rt != -1 && ( buf.st_size > 0 ) && ( ( buf.st_mode & S_IFDIR ) == 0 ) )
{ {
Q_strncpy( pFullPath, tmp, nMaxLen ); Q_strncpy( pFullPath, tmp, nMaxLen );
return true; return true;
@ -8375,9 +8284,9 @@ bool GetGlobalFilePath( const char *pSrc, char *pFullPath, int nMaxLen )
return false; return false;
} }
struct _stat buf; struct stat buf;
int rt = _stat( pFileName, &buf ); int rt = stat( pFileName, &buf );
if ( rt != -1 && ( buf.st_size > 0 ) && ( ( buf.st_mode & _S_IFDIR ) == 0 ) ) if ( rt != -1 && ( buf.st_size > 0 ) && ( ( buf.st_mode & S_IFDIR ) == 0 ) )
{ {
Q_strncpy( pFullPath, pFileName, nMaxLen ); Q_strncpy( pFullPath, pFileName, nMaxLen );
return true; return true;
@ -9463,15 +9372,6 @@ void UsageAndExit()
); );
} }
#ifndef _DEBUG
LONG __stdcall VExceptionFilter( struct _EXCEPTION_POINTERS *ExceptionInfo )
{
MdlExceptionFilter( ExceptionInfo->ExceptionRecord->ExceptionCode );
return EXCEPTION_EXECUTE_HANDLER; // (never gets here anyway)
}
#endif
/* /*
============== ==============
main main
@ -9539,16 +9439,12 @@ int main( int argc, char **argv )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool CStudioMDLApp::Create() bool CStudioMDLApp::Create()
{ {
InstallSpewFunction(); // InstallSpewFunction();
// override the default spew function // override the default spew function
SpewOutputFunc( MdlSpewOutputFunc ); SpewOutputFunc( MdlSpewOutputFunc );
MathLib_Init( 2.2f, 2.2f, 0.0f, 2.0f, false, false, false, false ); MathLib_Init( 2.2f, 2.2f, 0.0f, 2.0f, false, false, false, false );
#ifndef _DEBUG
SetUnhandledExceptionFilter( VExceptionFilter );
#endif
if ( CommandLine()->ParmCount() == 1 ) if ( CommandLine()->ParmCount() == 1 )
{ {
UsageAndExit(); UsageAndExit();

View file

@ -23,6 +23,7 @@
#include "studio.h" #include "studio.h"
#include "datamodel/dmelementhandle.h" #include "datamodel/dmelementhandle.h"
#include "checkuv.h" #include "checkuv.h"
#include "datamodel/dmelementfactoryhelper.h"
struct LodScriptData_t; struct LodScriptData_t;
struct s_flexkey_t; struct s_flexkey_t;
@ -130,9 +131,9 @@ public:
template< typename T > template< typename T >
inline T& CUtlVectorAuto<T>::operator[]( int i ) inline T& CUtlVectorAuto<T>::operator[]( int i )
{ {
EnsureCount( i + 1 ); this->EnsureCount( i + 1 );
Assert( IsValidIndex(i) ); Assert( IsValidIndex(i) );
return Base()[i]; return this->Base()[i];
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------

View file

@ -15,7 +15,6 @@
#pragma warning( disable : 4305 ) #pragma warning( disable : 4305 )
#include <io.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -64,11 +63,11 @@ static byte *pBlockStart;
#undef ALIGN4 #undef ALIGN4
#undef ALIGN16 #undef ALIGN16
#undef ALIGN32 #undef ALIGN32
#define ALIGN4( a ) a = (byte *)((int)((byte *)a + 3) & ~ 3) #define ALIGN4( a ) a = (byte *)((uintptr_t)((byte *)a + 3) & ~ 3)
#define ALIGN16( a ) a = (byte *)((int)((byte *)a + 15) & ~ 15) #define ALIGN16( a ) a = (byte *)((uintptr_t)((byte *)a + 15) & ~ 15)
#define ALIGN32( a ) a = (byte *)((int)((byte *)a + 31) & ~ 31) #define ALIGN32( a ) a = (byte *)((uintptr_t)((byte *)a + 31) & ~ 31)
#define ALIGN64( a ) a = (byte *)((int)((byte *)a + 63) & ~ 63) #define ALIGN64( a ) a = (byte *)((uintptr_t)((byte *)a + 63) & ~ 63)
#define ALIGN512( a ) a = (byte *)((int)((byte *)a + 511) & ~ 511) #define ALIGN512( a ) a = (byte *)((uintptr_t)((byte *)a + 511) & ~ 511)
// make sure kalloc aligns to maximum alignment size // make sure kalloc aligns to maximum alignment size
#define FILEBUFFER (8 * 1024 * 1024) #define FILEBUFFER (8 * 1024 * 1024)
@ -1736,12 +1735,12 @@ static void WriteBoneTransforms( studiohdr2_t *phdr, mstudiobone_t *pBone )
pLinearBone->numbones = g_numbones; pLinearBone->numbones = g_numbones;
#define WRITE_BONE_BLOCK( type, srcfield, dest, destindex ) \ #define WRITE_BONE_BLOCK( type, srcfield, dest, destindex ) \
type *##dest = (type *)pData; \ type *dest = (type *)pData; \
pLinearBone->##destindex = pData - (byte *)pLinearBone; \ pLinearBone->destindex = pData - (byte *)pLinearBone; \
pData += g_numbones * sizeof( *##dest ); \ pData += g_numbones * sizeof( *dest ); \
ALIGN4( pData ); \ ALIGN4( pData ); \
for ( int i = 0; i < g_numbones; i++) \ for ( int i = 0; i < g_numbones; i++) \
dest##[i] = pBone[i].##srcfield; dest[i] = pBone[i].srcfield;
WRITE_BONE_BLOCK( int, flags, pFlags, flagsindex ); WRITE_BONE_BLOCK( int, flags, pFlags, flagsindex );
WRITE_BONE_BLOCK( int, parent, pParent, parentindex ); WRITE_BONE_BLOCK( int, parent, pParent, parentindex );
@ -1823,10 +1822,10 @@ static void WriteVertices( studiohdr_t *phdr )
char fileName[MAX_PATH]; char fileName[MAX_PATH];
byte *pStart; byte *pStart;
byte *pData; byte *pData;
int i; uintptr_t i;
int j; uintptr_t j;
int k; uintptr_t k;
int cur; uintptr_t cur;
if (!g_nummodelsbeforeLOD) if (!g_nummodelsbeforeLOD)
return; return;
@ -1881,7 +1880,7 @@ static void WriteVertices( studiohdr_t *phdr )
// save vertices // save vertices
ALIGN16( pData ); ALIGN16( pData );
cur = (int)pData; cur = (uintptr_t)pData;
mstudiovertex_t *pVert = (mstudiovertex_t *)pData; mstudiovertex_t *pVert = (mstudiovertex_t *)pData;
pData += pLodData->numvertices * sizeof( mstudiovertex_t ); pData += pLodData->numvertices * sizeof( mstudiovertex_t );
for (j = 0; j < pLodData->numvertices; j++) for (j = 0; j < pLodData->numvertices; j++)
@ -1908,7 +1907,7 @@ static void WriteVertices( studiohdr_t *phdr )
if (!g_quiet) if (!g_quiet)
{ {
printf( "vertices %7d bytes (%d vertices)\n", (int)(pData - cur), pLodData->numvertices ); printf( "vertices %7d bytes (%d vertices)\n", (uintptr_t)(pData - cur), pLodData->numvertices );
} }
} }
@ -1925,7 +1924,7 @@ static void WriteVertices( studiohdr_t *phdr )
// save tangent space S // save tangent space S
ALIGN4( pData ); ALIGN4( pData );
cur = (int)pData; cur = (uintptr_t)pData;
Vector4D *ptangents = (Vector4D *)pData; Vector4D *ptangents = (Vector4D *)pData;
pData += pLodData->numvertices * sizeof( Vector4D ); pData += pLodData->numvertices * sizeof( Vector4D );
for (j = 0; j < pLodData->numvertices; j++) for (j = 0; j < pLodData->numvertices; j++)
@ -1939,7 +1938,7 @@ static void WriteVertices( studiohdr_t *phdr )
if (!g_quiet) if (!g_quiet)
{ {
printf( "tangents %7d bytes (%d vertices)\n", (int)(pData - cur), pLodData->numvertices ); printf( "tangents %7d bytes (%d vertices)\n", (uintptr_t)(pData - cur), pLodData->numvertices );
} }
} }
@ -2053,14 +2052,14 @@ float ComputeVertAnimFixedPointScale( studiohdr_t *pStudioHdr )
static void WriteModel( studiohdr_t *phdr ) static void WriteModel( studiohdr_t *phdr )
{ {
int i, j, k, m; uintptr_t i, j, k, m;
mstudiobodyparts_t *pbodypart; mstudiobodyparts_t *pbodypart;
mstudiomodel_t *pmodel; mstudiomodel_t *pmodel;
s_source_t *psource; s_source_t *psource;
mstudiovertanim_t *pvertanim; mstudiovertanim_t *pvertanim;
s_vertanim_t *pvanim; s_vertanim_t *pvanim;
int cur = (int)pData; uintptr_t cur = (uintptr_t)pData;
// vertex data is written to external file, offsets kept internal // vertex data is written to external file, offsets kept internal
// track expected external base to store proper offsets // track expected external base to store proper offsets
@ -2362,9 +2361,9 @@ static void WriteModel( studiohdr_t *phdr )
if( !g_quiet ) if( !g_quiet )
{ {
printf("ik/pose %7d bytes\n", (int)(pData - cur) ); printf("ik/pose %7d bytes\n", (uintptr_t)(pData - cur) );
} }
cur = (int)pData; cur = (uintptr_t)pData;
const float flVertAnimFixedPointScale = ComputeVertAnimFixedPointScale( phdr ); const float flVertAnimFixedPointScale = ComputeVertAnimFixedPointScale( phdr );
@ -2424,15 +2423,15 @@ static void WriteModel( studiohdr_t *phdr )
// set expected base offsets to external data // set expected base offsets to external data
ALIGN16( externalVertexIndex ); ALIGN16( externalVertexIndex );
pmodel[i].vertexindex = (int)externalVertexIndex; pmodel[i].vertexindex = (uintptr_t)externalVertexIndex;
externalVertexIndex += pmodel[i].numvertices * sizeof(mstudiovertex_t); externalVertexIndex += pmodel[i].numvertices * sizeof(mstudiovertex_t);
// set expected base offsets to external data // set expected base offsets to external data
ALIGN4( externalTangentsIndex ); ALIGN4( externalTangentsIndex );
pmodel[i].tangentsindex = (int)externalTangentsIndex; pmodel[i].tangentsindex = (uintptr_t)externalTangentsIndex;
externalTangentsIndex += pmodel[i].numvertices * sizeof( Vector4D ); externalTangentsIndex += pmodel[i].numvertices * sizeof( Vector4D );
cur = (int)pData; cur = (uintptr_t)pData;
// save eyeballs // save eyeballs
mstudioeyeball_t *peyeball; mstudioeyeball_t *peyeball;
@ -2470,11 +2469,11 @@ static void WriteModel( studiohdr_t *phdr )
if ( !g_quiet ) if ( !g_quiet )
{ {
printf("eyeballs %7d bytes (%d eyeballs)\n", (int)(pData - cur), g_model[i]->numeyeballs ); printf("eyeballs %7d bytes (%d eyeballs)\n", (uintptr_t)(pData - cur), g_model[i]->numeyeballs );
} }
// move flexes into individual meshes // move flexes into individual meshes
cur = (int)pData; cur = (uintptr_t)pData;
for (m = 0; m < pmodel[i].nummeshes; m++) for (m = 0; m < pmodel[i].nummeshes; m++)
{ {
int numflexkeys[MAXSTUDIOFLEXKEYS]; int numflexkeys[MAXSTUDIOFLEXKEYS];
@ -2581,9 +2580,9 @@ static void WriteModel( studiohdr_t *phdr )
if( !g_quiet ) if( !g_quiet )
{ {
printf("flexes %7d bytes (%d flexes)\n", (int)(pData - cur), g_numflexkeys ); printf("flexes %7d bytes (%d flexes)\n", (uintptr_t)(pData - cur), g_numflexkeys );
} }
cur = (int)pData; cur = (uintptr_t)pData;
} }
@ -3188,7 +3187,7 @@ typedef struct
lodMeshInfo_t lodMeshInfo; lodMeshInfo_t lodMeshInfo;
} vertexPool_t; } vertexPool_t;
#define ALIGN(b,s) (((unsigned int)(b)+(s)-1)&~((s)-1)) #define ALIGN(b,s) (((uintptr_t)(b)+(s)-1)&~((s)-1))
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// FindVertexOffsets // FindVertexOffsets

69
utils/studiomdl/wscript Executable file
View file

@ -0,0 +1,69 @@
#! /usr/bin/env python
# encoding: utf-8
from waflib import Utils
import os
import vpc_parser
top = '.'
PROJECT_NAME = 'studiomdl'
def options(opt):
# stub
return
def configure(conf):
return
def build(bld):
studiomdl_vpc = vpc_parser.parse_vpcs( bld.env, ['studiomdl.vpc'], '../..' )
source = studiomdl_vpc["sources"]
includes = studiomdl_vpc["includes"]
includes += [
'../../public',
'../../public/tier0',
'../../public/tier1',
'../../public/tier2',
'../../public/tier3'
]
defines = studiomdl_vpc["defines"]
libs = [
'appframework',
'datamodel',
'dmserializers'
'dmxloader',
'filesystem',
'movieobjects',
'mdlobjects',
'nvtristriplib',
'tier0',
'tier1',
'tier2',
'tier3',
'matsys_controls',
'mathlib',
'vstdlib',
'choreoobjects',
'steam_api',
'bitmap',
'vtf',
'ZLIB'
]
install_path = bld.env.LIBDIR
bld(
source = source,
target = PROJECT_NAME,
name = PROJECT_NAME,
features = 'c cxx cxxprogram',
includes = includes,
defines = defines,
use = libs,
install_path = install_path,
subsystem = bld.env.MSVC_SUBSYSTEM,
idx = bld.get_taskgen_count()
)

View file

@ -51,6 +51,7 @@ projects={
'datacache', 'datacache',
'datamodel', 'datamodel',
'dmxloader', 'dmxloader',
'dmserializers',
'engine', 'engine',
'engine/voice_codecs/minimp3', 'engine/voice_codecs/minimp3',
'filesystem', 'filesystem',
@ -65,12 +66,15 @@ projects={
'ivp/ivp_physics', 'ivp/ivp_physics',
'launcher', 'launcher',
'launcher_main', 'launcher_main',
'utils/studiomdl',
'materialsystem', 'materialsystem',
# 'materialsystem/shaderapiempty', # 'materialsystem/shaderapiempty',
'materialsystem/shaderapidx9', 'materialsystem/shaderapidx9',
'materialsystem/shaderlib', 'materialsystem/shaderlib',
'materialsystem/stdshaders', 'materialsystem/stdshaders',
'mathlib', 'mathlib',
'movieobjects',
'mdlobjects',
'particles', 'particles',
'scenefilecache', 'scenefilecache',
'serverbrowser', 'serverbrowser',
@ -91,6 +95,7 @@ projects={
'vpklib', 'vpklib',
'vstdlib', 'vstdlib',
'vtf', 'vtf',
'utils/nvtristriplib',
'utils/vtex', 'utils/vtex',
'unicode', 'unicode',
'video' 'video'