WIP studiomdl port

This commit is contained in:
Er2 2023-05-11 21:08:32 +03:00
parent 88f4cfa22e
commit 403b060ef9
27 changed files with 302 additions and 538 deletions

View File

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

View File

@ -1025,10 +1025,12 @@ void CDmeFilmClip::OnElementUnserialized( )
// Backward compat conversion
// If this is an older file with an overlay attribute, strip it out into materialoverlay
CDmAttribute *pOverlayAttribute = GetAttribute( "overlay" );
CDmAttribute *pOverlayAlphaAttribute;
const char *pName;
if ( !pOverlayAttribute )
goto cleanUp;
const char *pName = pOverlayAttribute->GetValueString();
pName = pOverlayAttribute->GetValueString();
if ( !pName || !pName[0] )
goto cleanUp;
@ -1041,7 +1043,7 @@ void CDmeFilmClip::OnElementUnserialized( )
m_MaterialOverlayEffect->SetOverlayEffect( pName );
// If this is an older file with an overlayalpha attribute, strip it out into materialoverlay
CDmAttribute *pOverlayAlphaAttribute = GetAttribute( "overlayalpha" );
pOverlayAlphaAttribute = GetAttribute( "overlayalpha" );
if ( pOverlayAlphaAttribute )
{
float alpha = pOverlayAlphaAttribute->GetValue<float>();

View File

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

View File

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

View File

@ -759,6 +759,7 @@ Quaternion Add( const Quaternion& v1, const Quaternion& v2 )
IMPLEMENT_ABSTRACT_ELEMENT( DmeLogLayer, CDmeLogLayer );
/*
IMPLEMENT_ELEMENT_FACTORY( DmeIntLogLayer, CDmeIntLogLayer );
IMPLEMENT_ELEMENT_FACTORY( DmeFloatLogLayer, CDmeFloatLogLayer );
IMPLEMENT_ELEMENT_FACTORY( DmeBoolLogLayer, CDmeBoolLogLayer );
@ -770,6 +771,7 @@ IMPLEMENT_ELEMENT_FACTORY( DmeQAngleLogLayer, CDmeQAngleLogLayer );
IMPLEMENT_ELEMENT_FACTORY( DmeQuaternionLogLayer, CDmeQuaternionLogLayer );
IMPLEMENT_ELEMENT_FACTORY( DmeVMatrixLogLayer, CDmeVMatrixLogLayer );
IMPLEMENT_ELEMENT_FACTORY( DmeStringLogLayer, CDmeStringLogLayer );
*/
//-----------------------------------------------------------------------------
// explicit template instantiation
@ -789,6 +791,7 @@ template class CDmeTypedLogLayer<CUtlString>;
IMPLEMENT_ABSTRACT_ELEMENT( DmeCurveInfo, CDmeCurveInfo );
/*
IMPLEMENT_ELEMENT_FACTORY( DmeIntCurveInfo, CDmeIntCurveInfo );
IMPLEMENT_ELEMENT_FACTORY( DmeFloatCurveInfo, CDmeFloatCurveInfo );
IMPLEMENT_ELEMENT_FACTORY( DmeBoolCurveInfo, CDmeBoolCurveInfo );
@ -800,6 +803,7 @@ IMPLEMENT_ELEMENT_FACTORY( DmeQAngleCurveInfo, CDmeQAngleCurveInfo );
IMPLEMENT_ELEMENT_FACTORY( DmeQuaternionCurveInfo, CDmeQuaternionCurveInfo );
IMPLEMENT_ELEMENT_FACTORY( DmeVMatrixCurveInfo, CDmeVMatrixCurveInfo );
IMPLEMENT_ELEMENT_FACTORY( DmeStringCurveInfo, CDmeStringCurveInfo );
*/
//-----------------------------------------------------------------------------
// explicit template instantiation
@ -822,6 +826,7 @@ template class CDmeTypedCurveInfo<CUtlString>;
//-----------------------------------------------------------------------------
IMPLEMENT_ABSTRACT_ELEMENT( DmeLog, CDmeLog );
/*
IMPLEMENT_ELEMENT_FACTORY( DmeIntLog, CDmeIntLog );
IMPLEMENT_ELEMENT_FACTORY( DmeFloatLog, CDmeFloatLog );
IMPLEMENT_ELEMENT_FACTORY( DmeBoolLog, CDmeBoolLog );
@ -833,6 +838,7 @@ IMPLEMENT_ELEMENT_FACTORY( DmeQAngleLog, CDmeQAngleLog );
IMPLEMENT_ELEMENT_FACTORY( DmeQuaternionLog, CDmeQuaternionLog );
IMPLEMENT_ELEMENT_FACTORY( DmeVMatrixLog, CDmeVMatrixLog );
IMPLEMENT_ELEMENT_FACTORY( DmeStringLog, CDmeStringLog );
*/
//-----------------------------------------------------------------------------
@ -854,6 +860,7 @@ template class CDmeTypedLog<CUtlString>;
//-----------------------------------------------------------------------------
// instantiate and initialize static vars
//-----------------------------------------------------------------------------
/*
float CDmeIntLog::s_defaultThreshold = 0.0f;
float CDmeFloatLog::s_defaultThreshold = 0.0f;
float CDmeBoolLog::s_defaultThreshold = 0.0f;
@ -865,6 +872,7 @@ float CDmeQAngleLog::s_defaultThreshold = 0.0f;
float CDmeQuaternionLog::s_defaultThreshold = 0.0f;
float CDmeVMatrixLog::s_defaultThreshold = 0.0f;
float CDmeStringLog::s_defaultThreshold = 0.0f;
*/
void CDmeLogLayer::OnConstruction()

View File

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

View File

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

95
movieobjects/wscript Executable file
View File

@ -0,0 +1,95 @@
#! /usr/bin/env python
# encoding: utf-8
# vim: noexpandtab
from waflib import Utils
import os
top = '.'
PROJECT_NAME = 'movieobjects'
def options(opt):
# stub
return
def configure(conf):
return
def build(bld):
source = [
'dmeanimationlist.cpp',
'dmeanimationset.cpp',
'dmeattachment.cpp',
'dmebalancetostereocalculatoroperator.cpp',
'dmebookmark.cpp',
'dmecamera.cpp',
'dmechannel.cpp',
'dmeclip.cpp',
'dmecombinationoperator.cpp',
'dmedag.cpp',
'dmedccmakefile.cpp',
'dmeeditortypedictionary.cpp',
'dmeexpressionoperator.cpp',
'dmefaceset.cpp',
'dmegamemodel.cpp',
'dmegamemodelinput.cpp',
'dmeinput.cpp',
'dmejoint.cpp',
'dmekeyboardinput.cpp',
'dmelight.cpp',
# 'dmelog.cpp',
'dmemakefile.cpp',
'dmemakefileutils.cpp',
'dmematerial.cpp',
'dmematerialoverlayfxclip.cpp',
'dmemdl.cpp',
'dmemdlmakefile.cpp',
# 'dmemesh.cpp',
'dmemodel.cpp',
'dmemorphoperator.cpp',
'dmemouseinput.cpp',
'dmeoperator.cpp',
'dmepackoperators.cpp',
'dmeparticlesystemdefinition.cpp',
'dmephonememapping.cpp',
'dmeselection.cpp',
'dmeshape.cpp',
'dmesound.cpp',
'dmetimeframe.cpp',
'dmetimeselection.cpp',
'dmetrack.cpp',
'dmetrackgroup.cpp',
'dmetransform.cpp',
'dmetransforminput.cpp',
'dmetransformlist.cpp',
'dmetransformoperator.cpp',
'dmeunpackoperators.cpp',
'dmevertexdata.cpp',
'dmobjserializer.cpp',
'movieobjects_interfaces.cpp',
'../public/phonemeconverter.cpp',
]
includes = [
'.',
'../public',
'../public/tier0',
'../public/tier1',
]
defines = []
libs = []
bld.stlib(
source = source,
target = PROJECT_NAME,
name = PROJECT_NAME,
features = 'c cxx',
includes = includes,
defines = defines,
use = libs,
subsystem = bld.env.MSVC_SUBSYSTEM,
idx = bld.get_taskgen_count()
)

View File

@ -54,19 +54,11 @@ void AppShutdown( CAppSystemGroup *pAppSystemGroup );
{ \
return AppMain( hInstance, hPrevInstance, lpCmdLine, nCmdShow, &_globalVarName ); \
}
#elif defined( OSX )
#elif defined( POSIX )
#define DEFINE_WINDOWED_APPLICATION_OBJECT_GLOBALVAR( _globalVarName ) \
int main( int argc, char **argv ) \
{ \
extern int ValveCocoaMain( int argc, char **argv, CAppSystemGroup *pAppSystemGroup ); \
return ValveCocoaMain( argc, argv, &_globalVarName ); \
}
#elif defined( LINUX ) || defined(PLATFORM_BSD)
#define DEFINE_WINDOWED_APPLICATION_OBJECT_GLOBALVAR( _globalVarName ) \
int main( int argc, char **argv ) \
{ \
extern int ValveLinuxWindowedMain( int argc, char **argv, CAppSystemGroup *pAppSystemGroup ); \
return ValveLinuxWindowedMain( argc, argv, &_globalVarName ); \
return AppMain( argc, argv, &_globalVarName ); \
}
#else
#error

View File

@ -13,6 +13,7 @@
#include "datamodel/dmelement.h"
#include "datamodel/dmattribute.h"
#include "datamodel/dmattributevar.h"
#include "movieobjects/dmeclip.h"
#include "movieobjects/dmephonememapping.h"
#include "movieobjects/timeutils.h"
#include "movieobjects/proceduralpresets.h"

View File

@ -11,6 +11,7 @@
#endif
#include "datamodel/dmelement.h"
#include "datamodel/dmelementfactoryhelper.h"
#include "datamodel/dmattribute.h"
#include "datamodel/dmattributevar.h"
#include "datamodel/dmehandle.h"

View File

@ -404,7 +404,7 @@ protected:
template< class T >
class CDmeTypedCurveInfo : public CDmeCurveInfo
{
DEFINE_ELEMENT( CDmeTypedCurveInfo, CDmeCurveInfo );
// DEFINE_ELEMENT( CDmeTypedCurveInfo, CDmeCurveInfo );
public:
// For "faceposer" style left/right edges, this controls whether interpolators try to mimic faceposer left/right edge behavior
@ -447,7 +447,7 @@ template< class T > class CDmeTypedLog;
template< class T >
class CDmeTypedLogLayer : public CDmeLogLayer
{
DEFINE_ELEMENT( CDmeTypedLogLayer, CDmeLogLayer );
// DEFINE_ELEMENT( CDmeTypedLogLayer, CDmeLogLayer );
public:
virtual void CopyLayer( const CDmeLogLayer *src );
@ -529,7 +529,7 @@ protected:
template< class T >
class CDmeTypedLog : public CDmeLog
{
DEFINE_ELEMENT( CDmeTypedLog, CDmeLog );
// DEFINE_ELEMENT( CDmeTypedLog, CDmeLog );
public:
@ -836,7 +836,7 @@ template<> void CDmeTypedLogLayer< Vector >::GetValueUsingCurveInfoSkippingKey(
template<> void CDmeTypedLogLayer< Quaternion >::GetValueUsingCurveInfo( DmeTime_t time, 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> void CDmeTypedLogLayer< T >::CurveSimplify_R( float thresholdSqr, int startPoint, int endPoint, CDmeTypedLogLayer< T > *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< Color >::CurveSimplify_R( float thresholdSqr, int startPoint, int endPoint, CDmeTypedLogLayer< Color > *output );

View File

@ -11,11 +11,10 @@
#endif
#include "datamodel/dmelement.h"
#include "dme_controls/RecordingState.h"
#include "movieobjects/timeutils.h"
#include "movieobjects/dmetimeselectiontimes.h"
enum RecordingState_t;
class CDmeTimeSelection : public CDmElement
{
DEFINE_ELEMENT( CDmeTimeSelection, CDmElement );

View File

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

View File

@ -1,98 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#include <windows.h>
#include <STDIO.H>
int
ReadBmpFile(
char* szFile,
unsigned char** ppbPalette,
unsigned char** ppbBits,
int *pwidth,
int *pheight)
{
int rc = 0;
FILE *pfile = NULL;
BITMAPFILEHEADER bmfh;
BITMAPINFOHEADER bmih;
RGBQUAD rgrgbPalette[256];
ULONG cbPalBytes;
ULONG cbBmpBits;
BYTE* pbBmpBits;
// Bogus parameter check
if (!(ppbPalette != NULL && ppbBits != NULL))
{ rc = -1000; goto GetOut; }
// File exists?
if ((pfile = fopen(szFile, "rb")) == NULL)
{ rc = -1; goto GetOut; }
// Read file header
if (fread(&bmfh, sizeof bmfh, 1/*count*/, pfile) != 1)
{ rc = -2; goto GetOut; }
// Bogus file header check
if (!(bmfh.bfReserved1 == 0 && bmfh.bfReserved2 == 0))
{ rc = -2000; goto GetOut; }
// Read info header
if (fread(&bmih, sizeof bmih, 1/*count*/, pfile) != 1)
{ rc = -3; goto GetOut; }
// Bogus info header check
if (!(bmih.biSize == sizeof bmih && bmih.biPlanes == 1))
{ rc = -3000; goto GetOut; }
// Bogus bit depth? Only 8-bit supported.
if (bmih.biBitCount != 8)
{ rc = -4; goto GetOut; }
// Bogus compression? Only non-compressed supported.
if (bmih.biCompression != BI_RGB)
{ rc = -5; goto GetOut; }
// Figure out how many entires are actually in the table
if (bmih.biClrUsed == 0)
{
cbPalBytes = (1 << bmih.biBitCount) * sizeof( RGBQUAD );
}
else
{
cbPalBytes = bmih.biClrUsed * sizeof( RGBQUAD );
}
// Read palette (256 entries)
if (fread(rgrgbPalette, cbPalBytes, 1/*count*/, pfile) != 1)
{ rc = -6; goto GetOut; }
// Read bitmap bits (remainder of file)
cbBmpBits = bmfh.bfSize - ftell(pfile);
pbBmpBits = (BYTE *)malloc(cbBmpBits);
if (fread(pbBmpBits, cbBmpBits, 1/*count*/, pfile) != 1)
{ rc = -7; goto GetOut; }
// Set output parameters
*ppbPalette = (BYTE *)malloc(sizeof rgrgbPalette);
memcpy(*ppbPalette, rgrgbPalette, cbPalBytes);
*ppbBits = pbBmpBits;
*pwidth = bmih.biWidth;
*pheight = bmih.biHeight;
printf("w %d h %d s %d\n",bmih.biWidth, bmih.biHeight, cbBmpBits );
GetOut:
if (pfile) fclose(pfile);
return rc;
}

View File

@ -1142,6 +1142,7 @@ int Load_DMX( s_source_t *pSource )
CDmeDag *pSkeleton = pRoot->GetValueElement< CDmeDag >( "skeleton" );
CDmeModel *pModel = pRoot->GetValueElement< CDmeModel >( "model" );
CDmeCombinationOperator *pCombinationOperator = pRoot->GetValueElement< CDmeCombinationOperator >( "combinationOperator" );
CDmeAnimationList *pAnimationList;
if ( !pSkeleton )
goto dmxError;
@ -1175,7 +1176,7 @@ int Load_DMX( s_source_t *pSource )
AddCombination( pSource, pCombinationOperator );
}
CDmeAnimationList *pAnimationList = pRoot->GetValueElement< CDmeAnimationList >( "animationList" );
pAnimationList = pRoot->GetValueElement< CDmeAnimationList >( "animationList" );
if ( pAnimationList )
{
LoadAnimations( pSource, pAnimationList, g_currentscale, boneMap );

View File

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

View File

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

View File

@ -17,7 +17,7 @@
//#define IGNORE_BONES
#define NVTRISTRIP
//#define NVTRISTRIP
#define EMIT_TRILISTS
@ -28,12 +28,11 @@
#include "cmdlib.h"
#include "studio.h"
#include "studiomdl.h"
#include "HardwareMatrixState.h"
#include "HardwareVertexCache.h"
#include "hardwarematrixstate.h"
#include "hardwarevertexcache.h"
#include "optimize.h"
#include <malloc.h>
#include <nvtristrip.h>
#include "FileBuffer.h"
//#include "nvtristrip.h"
#include "filebuffer.h"
#include "tier1/utlvector.h"
#include "materialsystem/imaterial.h"
#include "tier1/utllinkedlist.h"
@ -352,7 +351,7 @@ private:
// Memory optimize the strip data
void PostProcessStripGroup( mstudiomodel_t *pStudioModel, mstudiomesh_t *pStudioMesh, StripGroup_t *pStripGroup );
void COptimizedModel::ZeroNumBones( void );
void ZeroNumBones( void );
//
// 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
pStudioHdr->pVertexBase = (void *)pVvdHdr;
pStudioHdr->pIndexBase = (void *)pVtxHdr;
pStudioHdr->SetVertexBase((void *)pVvdHdr);
pStudioHdr->SetIndexBase((void *)pVtxHdr);
g_pStudioRender->LoadModel( pStudioHdr, pVtxHdr, &studioHWData );

View File

@ -12,22 +12,23 @@
// models/<scriptname>.mdl.
//
#ifdef _WIN32
#pragma warning( disable : 4244 )
#pragma warning( disable : 4237 )
#pragma warning( disable : 4305 )
#include <windows.h>
#include <direct.h>
#undef GetCurrentDirectory
#include <Shlwapi.h> // PathCanonicalize
#pragma comment( lib, "shlwapi" )
#endif
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <math.h>
#include <direct.h>
#include "istudiorender.h"
#include "filesystem_tools.h"
#include "tier2/fileutils.h"
@ -45,9 +46,9 @@
#include "bspflags.h"
#include "tier0/icommandline.h"
#include "utldict.h"
#include "tier1/utlsortvector.h"
#include "tier1/UtlSortVector.h"
#include "bitvec.h"
#include "appframework/appframework.h"
#include "appframework/AppFramework.h"
#include "datamodel/idatamodel.h"
#include "materialsystem/materialsystem_config.h"
#include "vstdlib/cvar.h"
@ -67,6 +68,10 @@
#include "perfstats.h"
#include "worldsize.h"
#ifdef POSIX
#define _stat stat
#endif
bool g_collapse_bones = false;
bool g_collapse_bones_aggressive = false;
bool g_quiet = false;
@ -195,6 +200,7 @@ void EnsureDependencyFileCheckedIn( const char *pFileName )
if ( g_bNoP4 )
return;
#ifdef _WIN32
char pFullPath[MAX_PATH];
if ( !GetGlobalFilePath( pFileName, pFullPath, sizeof(pFullPath) ) )
{
@ -206,6 +212,7 @@ void EnsureDependencyFileCheckedIn( const char *pFileName )
char bufCanonicalPath[ MAX_PATH ] = {0};
PathCanonicalize( bufCanonicalPath, pFullPath );
CP4AutoAddFile p4_add_dep_file( bufCanonicalPath );
#endif
}
void StudioMdl_ScriptLoadedCallback( char const *pFilenameLoaded, char const *pIncludedFromFileName, int nIncludeLineNumber )
@ -385,15 +392,17 @@ SpewRetval_t MdlSpewOutputFunc( SpewType_t type, char const *pMsg )
{
MdlWarning( "%s", pMsg );
}
#if 0
else
{
return CmdLib_SpewOutputFunc( type, pMsg );
}
#endif
return SPEW_CONTINUE;
}
#ifdef _WIN32
#ifndef _DEBUG
void MdlHandleCrash( const char *pMessage, bool bAssert )
@ -471,6 +480,7 @@ void MdlExceptionFilter( unsigned long code )
TerminateProcess( GetCurrentProcess(), 1 );
}
#endif
#endif
/*
@ -490,7 +500,7 @@ void *kalloc( int num, int size )
nMemSize += 511;
void *ptr = malloc( nMemSize );
memset( ptr, 0, nMemSize );
ptr = (byte *)((int)((byte *)ptr + 511) & ~511);
ptr = (byte *)((size_t)((byte *)ptr + 511) & ~511);
return ptr;
}
@ -2297,9 +2307,11 @@ int Option_Activity( s_sequence_t *psequence )
int Option_ActivityModifier( s_sequence_t *psequence )
{
#if 0
GetToken(false);
V_strcpy_safe( psequence->activitymodifier[ psequence->numactivitymodifiers++ ].name, token );
#endif
return 0;
}
@ -8366,7 +8378,7 @@ bool GetGlobalFilePath( const char *pSrc, char *pFullPath, int nMaxLen )
struct _stat 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 );
return true;
@ -8377,7 +8389,7 @@ bool GetGlobalFilePath( const char *pSrc, char *pFullPath, int nMaxLen )
struct _stat 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 );
return true;
@ -9463,6 +9475,7 @@ void UsageAndExit()
);
}
#ifdef _WIN32
#ifndef _DEBUG
LONG __stdcall VExceptionFilter( struct _EXCEPTION_POINTERS *ExceptionInfo )
@ -9471,6 +9484,7 @@ LONG __stdcall VExceptionFilter( struct _EXCEPTION_POINTERS *ExceptionInfo )
return EXCEPTION_EXECUTE_HANDLER; // (never gets here anyway)
}
#endif
#endif
/*
==============
@ -9545,8 +9559,10 @@ bool CStudioMDLApp::Create()
MathLib_Init( 2.2f, 2.2f, 0.0f, 2.0f, false, false, false, false );
#ifdef _WIN32
#ifndef _DEBUG
SetUnhandledExceptionFilter( VExceptionFilter );
#endif
#endif
if ( CommandLine()->ParmCount() == 1 )

View File

@ -130,9 +130,9 @@ public:
template< typename T >
inline T& CUtlVectorAuto<T>::operator[]( int i )
{
EnsureCount( i + 1 );
this->EnsureCount( i + 1 );
Assert( IsValidIndex(i) );
return Base()[i];
return this->Base()[i];
}
// --------------------------------------------------------------------

View File

@ -1,350 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
// tristrip - convert triangle list into tristrips and fans
#pragma warning( disable : 4244 )
#pragma warning( disable : 4237 )
#pragma warning( disable : 4305 )
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include "cmdlib.h"
#include "lbmlib.h"
#include "scriplib.h"
#include "mathlib/mathlib.h"
#include "..\..\engine\studio.h"
#include "studiomdl.h"
int used[MAXSTUDIOTRIANGLES];
// the command list holds counts and s/t values that are valid for
// every frame
short commands[MAXSTUDIOTRIANGLES * 13];
int numcommands;
// all frames will have their vertexes rearranged and expanded
// so they are in the order expected by the command list
int allverts, alltris;
int stripverts[MAXSTUDIOTRIANGLES+2];
int striptris[MAXSTUDIOTRIANGLES+2];
int stripcount;
int neighbortri[MAXSTUDIOTRIANGLES][3];
int neighboredge[MAXSTUDIOTRIANGLES][3];
s_trianglevert_t (*triangles)[3];
s_mesh_t *pmesh;
void FindNeighbor (int starttri, int startv)
{
s_trianglevert_t m1, m2;
int j;
s_trianglevert_t *last, *check;
int k;
// used[starttri] |= (1 << startv);
last = &triangles[starttri][0];
m1 = last[(startv+1)%3];
m2 = last[(startv+0)%3];
for (j=starttri+1, check=&triangles[starttri+1][0] ; j<pmesh->numtris ; j++, check += 3)
{
if (used[j] == 7)
continue;
for (k=0 ; k<3 ; k++)
{
if (memcmp(&check[k],&m1,sizeof(m1)))
continue;
if (memcmp(&check[ (k+1)%3 ],&m2,sizeof(m2)))
continue;
neighbortri[starttri][startv] = j;
neighboredge[starttri][startv] = k;
neighbortri[j][k] = starttri;
neighboredge[j][k] = startv;
used[starttri] |= (1 << startv);
used[j] |= (1 << k);
return;
}
}
}
/*
================
StripLength
================
*/
int StripLength (int starttri, int startv)
{
int j;
int k;
used[starttri] = 2;
stripverts[0] = (startv)%3;
stripverts[1] = (startv+1)%3;
stripverts[2] = (startv+2)%3;
striptris[0] = starttri;
striptris[1] = starttri;
striptris[2] = starttri;
stripcount = 3;
while( 1 )
{
if (stripcount & 1)
{
j = neighbortri[starttri][(startv+1)%3];
k = neighboredge[starttri][(startv+1)%3];
}
else
{
j = neighbortri[starttri][(startv+2)%3];
k = neighboredge[starttri][(startv+2)%3];
}
if (j == -1 || used[j])
goto done;
stripverts[stripcount] = (k+2)%3;
striptris[stripcount] = j;
stripcount++;
used[j] = 2;
starttri = j;
startv = k;
}
done:
// clear the temp used flags
for (j=0 ; j<pmesh->numtris ; j++)
if (used[j] == 2)
used[j] = 0;
return stripcount;
}
/*
===========
FanLength
===========
*/
int FanLength (int starttri, int startv)
{
int j;
int k;
used[starttri] = 2;
stripverts[0] = (startv)%3;
stripverts[1] = (startv+1)%3;
stripverts[2] = (startv+2)%3;
striptris[0] = starttri;
striptris[1] = starttri;
striptris[2] = starttri;
stripcount = 3;
while( 1 )
{
j = neighbortri[starttri][(startv+2)%3];
k = neighboredge[starttri][(startv+2)%3];
if (j == -1 || used[j])
goto done;
stripverts[stripcount] = (k+2)%3;
striptris[stripcount] = j;
stripcount++;
used[j] = 2;
starttri = j;
startv = k;
}
done:
// clear the temp used flags
for (j=0 ; j<pmesh->numtris ; j++)
if (used[j] == 2)
used[j] = 0;
return stripcount;
}
/*
================
BuildTris
Generate a list of trifans or strips
for the model, which holds for all frames
================
*/
int numcommandnodes;
int BuildTris (s_trianglevert_t (*x)[3], s_mesh_t *y, byte **ppdata )
{
int i, j, k, m;
int startv;
int len, bestlen, besttype;
int bestverts[MAXSTUDIOTRIANGLES];
int besttris[MAXSTUDIOTRIANGLES];
int peak[MAXSTUDIOTRIANGLES];
int type;
int total = 0;
long t;
int maxlen;
triangles = x;
pmesh = y;
t = time( NULL );
for (i=0 ; i<pmesh->numtris ; i++)
{
neighbortri[i][0] = neighbortri[i][1] = neighbortri[i][2] = -1;
used[i] = 0;
peak[i] = pmesh->numtris;
}
// printf("finding neighbors\n");
for (i=0 ; i<pmesh->numtris; i++)
{
for (k = 0; k < 3; k++)
{
if (used[i] & (1 << k))
continue;
FindNeighbor( i, k );
}
// printf("%d", used[i] );
}
// printf("\n");
//
// build tristrips
//
numcommandnodes = 0;
numcommands = 0;
memset (used, 0, sizeof(used));
for (i=0 ; i<pmesh->numtris ;)
{
// pick an unused triangle and start the trifan
if (used[i])
{
i++;
continue;
}
maxlen = 9999;
bestlen = 0;
m = 0;
for (k = i; k < pmesh->numtris && bestlen < 127; k++)
{
int localpeak = 0;
if (used[k])
continue;
if (peak[k] <= bestlen)
continue;
m++;
for (type = 0 ; type < 2 ; type++)
{
for (startv =0 ; startv < 3 ; startv++)
{
if (type == 1)
len = FanLength (k, startv);
else
len = StripLength (k, startv);
if (len > 127)
{
// skip these, they are too long to encode
}
else if (len > bestlen)
{
besttype = type;
bestlen = len;
for (j=0 ; j<bestlen ; j++)
{
besttris[j] = striptris[j];
bestverts[j] = stripverts[j];
}
// printf("%d %d\n", k, bestlen );
}
if (len > localpeak)
localpeak = len;
}
}
peak[k] = localpeak;
if (localpeak == maxlen)
break;
}
total += (bestlen - 2);
// printf("%d (%d) %d\n", bestlen, pmesh->numtris - total, i );
maxlen = bestlen;
// mark the tris on the best strip as used
for (j=0 ; j<bestlen ; j++)
used[besttris[j]] = 1;
if (besttype == 1)
commands[numcommands++] = -bestlen;
else
commands[numcommands++] = bestlen;
for (j=0 ; j<bestlen ; j++)
{
s_trianglevert_t *tri;
tri = &triangles[besttris[j]][bestverts[j]];
commands[numcommands++] = tri->vertindex;
commands[numcommands++] = tri->normindex;
commands[numcommands++] = tri->s;
commands[numcommands++] = tri->t;
}
// printf("%d ", bestlen - 2 );
numcommandnodes++;
if (t != time(NULL))
{
printf("%2d%%\r", (total * 100) / pmesh->numtris );
t = time(NULL);
}
}
commands[numcommands++] = 0; // end of list marker
*ppdata = (byte *)commands;
// printf("%d %d %d\n", numcommandnodes, numcommands, pmesh->numtris );
return numcommands * sizeof( short );
}

View File

@ -10,12 +10,14 @@
// write.c: writes a studio .mdl file
//
#ifdef _WIN32
#pragma warning( disable : 4244 )
#pragma warning( disable : 4237 )
#pragma warning( disable : 4305 )
#include <io.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
@ -64,11 +66,11 @@ static byte *pBlockStart;
#undef ALIGN4
#undef ALIGN16
#undef ALIGN32
#define ALIGN4( a ) a = (byte *)((int)((byte *)a + 3) & ~ 3)
#define ALIGN16( a ) a = (byte *)((int)((byte *)a + 15) & ~ 15)
#define ALIGN32( a ) a = (byte *)((int)((byte *)a + 31) & ~ 31)
#define ALIGN64( a ) a = (byte *)((int)((byte *)a + 63) & ~ 63)
#define ALIGN512( a ) a = (byte *)((int)((byte *)a + 511) & ~ 511)
#define ALIGN4( a ) a = (byte *)((size_t)((byte *)a + 3) & ~ 3)
#define ALIGN16( a ) a = (byte *)((size_t)((byte *)a + 15) & ~ 15)
#define ALIGN32( a ) a = (byte *)((size_t)((byte *)a + 31) & ~ 31)
#define ALIGN64( a ) a = (byte *)((size_t)((byte *)a + 63) & ~ 63)
#define ALIGN512( a ) a = (byte *)((size_t)((byte *)a + 511) & ~ 511)
// make sure kalloc aligns to maximum alignment size
#define FILEBUFFER (8 * 1024 * 1024)
@ -1736,12 +1738,12 @@ static void WriteBoneTransforms( studiohdr2_t *phdr, mstudiobone_t *pBone )
pLinearBone->numbones = g_numbones;
#define WRITE_BONE_BLOCK( type, srcfield, dest, destindex ) \
type *##dest = (type *)pData; \
pLinearBone->##destindex = pData - (byte *)pLinearBone; \
pData += g_numbones * sizeof( *##dest ); \
type *dest = (type *)pData; \
pLinearBone->destindex = pData - (byte *)pLinearBone; \
pData += g_numbones * sizeof( *dest ); \
ALIGN4( pData ); \
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, parent, pParent, parentindex );
@ -1881,7 +1883,7 @@ static void WriteVertices( studiohdr_t *phdr )
// save vertices
ALIGN16( pData );
cur = (int)pData;
cur = (size_t)pData;
mstudiovertex_t *pVert = (mstudiovertex_t *)pData;
pData += pLodData->numvertices * sizeof( mstudiovertex_t );
for (j = 0; j < pLodData->numvertices; j++)
@ -1908,7 +1910,7 @@ static void WriteVertices( studiohdr_t *phdr )
if (!g_quiet)
{
printf( "vertices %7d bytes (%d vertices)\n", (int)(pData - cur), pLodData->numvertices );
printf( "vertices %7d bytes (%d vertices)\n", (size_t)(pData - cur), pLodData->numvertices );
}
}
@ -1925,7 +1927,7 @@ static void WriteVertices( studiohdr_t *phdr )
// save tangent space S
ALIGN4( pData );
cur = (int)pData;
cur = (size_t)pData;
Vector4D *ptangents = (Vector4D *)pData;
pData += pLodData->numvertices * sizeof( Vector4D );
for (j = 0; j < pLodData->numvertices; j++)
@ -1939,7 +1941,7 @@ static void WriteVertices( studiohdr_t *phdr )
if (!g_quiet)
{
printf( "tangents %7d bytes (%d vertices)\n", (int)(pData - cur), pLodData->numvertices );
printf( "tangents %7d bytes (%d vertices)\n", (size_t)(pData - cur), pLodData->numvertices );
}
}
@ -2060,7 +2062,7 @@ static void WriteModel( studiohdr_t *phdr )
mstudiovertanim_t *pvertanim;
s_vertanim_t *pvanim;
int cur = (int)pData;
int cur = (size_t)pData;
// vertex data is written to external file, offsets kept internal
// track expected external base to store proper offsets
@ -2362,9 +2364,9 @@ static void WriteModel( studiohdr_t *phdr )
if( !g_quiet )
{
printf("ik/pose %7d bytes\n", (int)(pData - cur) );
printf("ik/pose %7d bytes\n", (size_t)(pData - cur) );
}
cur = (int)pData;
cur = (size_t)pData;
const float flVertAnimFixedPointScale = ComputeVertAnimFixedPointScale( phdr );
@ -2424,15 +2426,15 @@ static void WriteModel( studiohdr_t *phdr )
// set expected base offsets to external data
ALIGN16( externalVertexIndex );
pmodel[i].vertexindex = (int)externalVertexIndex;
pmodel[i].vertexindex = (size_t)externalVertexIndex;
externalVertexIndex += pmodel[i].numvertices * sizeof(mstudiovertex_t);
// set expected base offsets to external data
ALIGN4( externalTangentsIndex );
pmodel[i].tangentsindex = (int)externalTangentsIndex;
pmodel[i].tangentsindex = (size_t)externalTangentsIndex;
externalTangentsIndex += pmodel[i].numvertices * sizeof( Vector4D );
cur = (int)pData;
cur = (size_t)pData;
// save eyeballs
mstudioeyeball_t *peyeball;
@ -2470,11 +2472,11 @@ static void WriteModel( studiohdr_t *phdr )
if ( !g_quiet )
{
printf("eyeballs %7d bytes (%d eyeballs)\n", (int)(pData - cur), g_model[i]->numeyeballs );
printf("eyeballs %7d bytes (%d eyeballs)\n", (size_t)(pData - cur), g_model[i]->numeyeballs );
}
// move flexes into individual meshes
cur = (int)pData;
cur = (size_t)pData;
for (m = 0; m < pmodel[i].nummeshes; m++)
{
int numflexkeys[MAXSTUDIOFLEXKEYS];
@ -2581,9 +2583,9 @@ static void WriteModel( studiohdr_t *phdr )
if( !g_quiet )
{
printf("flexes %7d bytes (%d flexes)\n", (int)(pData - cur), g_numflexkeys );
printf("flexes %7d bytes (%d flexes)\n", (size_t)(pData - cur), g_numflexkeys );
}
cur = (int)pData;
cur = (size_t)pData;
}
@ -3188,7 +3190,7 @@ typedef struct
lodMeshInfo_t lodMeshInfo;
} vertexPool_t;
#define ALIGN(b,s) (((unsigned int)(b)+(s)-1)&~((s)-1))
#define ALIGN(b,s) (((size_t)(b)+(s)-1)&~((s)-1))
//-----------------------------------------------------------------------------
// FindVertexOffsets

93
utils/studiomdl/wscript Normal file
View File

@ -0,0 +1,93 @@
#! /usr/bin/env python
# encoding: utf-8
# vim: noexpandtab
from waflib import Utils
import os
top = '.'
PROJECT_NAME = 'studiomdl'
def options(opt):
# stub
return
def configure(conf):
conf.define('PROTECTED_THINGS_DISABLE', 1)
return
def build(bld):
source = [
'UnifyLODs.cpp',
'checkuv.cpp',
'collisionmodel.cpp',
'dmxsupport.cpp',
'hardwarematrixstate.cpp',
'hardwarevertexcache.cpp',
'mrmsupport.cpp',
'objsupport.cpp',
'optimize.cpp',
'perfstats.cpp',
'simplify.cpp',
'studiomdl.cpp',
'v1support.cpp',
'write.cpp',
'../common/cmdlib.cpp',
'../common/filesystem_tools.cpp',
'../common/physdll.cpp',
'../common/scriplib.cpp',
'../../filesystem/linux_support.cpp',
'../../public/filesystem_helpers.cpp',
'../../public/filesystem_init.cpp',
'../../public/bone_setup.cpp',
'../../public/collisionutils.cpp',
'../../public/interpolatortypes.cpp',
'../../public/mdlobjects/mdlobjects.cpp',
'../../public/movieobjects/movieobjects_compiletools.cpp',
'../../public/studio.cpp',
'../../common/studiobyteswap.cpp',
]
includes = [
'.',
'../common',
'../../public',
'../../public/tier0',
'../../public/tier1',
'../../public/tier2',
'../../public/tier3',
'../../public/vstdlib',
]
defines = []
libs = [
'tier0', 'tier1', 'tier2', 'tier3',
'appframework',
'datamodel',
'dmserializers',
'mathlib',
'mdlobjects',
'movieobjects',
# 'nvtristrip',
'vstdlib',
]
if bld.env.DEST_OS == 'win32':
libs += ['USER32']
install_path = bld.env.BINDIR
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()
)

2
waf vendored
View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# encoding: latin-1
# Thomas Nagy, 2005-2018
#

17
wscript
View File

@ -123,6 +123,8 @@ projects={
'fgdlib',
'raytrace',
'vphysics',
'movieobjects',
# 'hammer_launcher',
'ivp/havana',
'ivp/havana/havok/hk_base',
'ivp/havana/havok/hk_math',
@ -131,17 +133,18 @@ projects={
'materialsystem',
'materialsystem/shaderapiempty',
'materialsystem/shaderlib',
'utils/vtex',
'utils/lzma',
'utils/bsppack',
'utils/lzma',
# 'utils/studiomdl',
'utils/vbsp',
'utils/vbspinfo',
'utils/xbox/xbspinfo',
'utils/vvis',
'utils/vvis_launcher',
'utils/vpk',
'utils/vrad',
'utils/vrad_launcher',
'utils/vbsp',
'utils/vpk',
'utils/vtex',
'utils/vvis',
'utils/vvis_launcher',
'utils/xbox/xbspinfo',
],
}