mirror of
https://github.com/nillerusr/source-engine.git
synced 2025-01-27 23:34:31 +00:00
some things
This commit is contained in:
parent
403b060ef9
commit
faa452222e
@ -4,10 +4,8 @@
|
|||||||
//
|
//
|
||||||
//===========================================================================//
|
//===========================================================================//
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
#include <eh.h>
|
|
||||||
#include "appframework/AppFramework.h"
|
#include "appframework/AppFramework.h"
|
||||||
#include "ihammer.h"
|
#include "IHammer.h"
|
||||||
#include "tier0/dbg.h"
|
#include "tier0/dbg.h"
|
||||||
#include "vstdlib/cvar.h"
|
#include "vstdlib/cvar.h"
|
||||||
#include "filesystem.h"
|
#include "filesystem.h"
|
||||||
@ -17,12 +15,21 @@
|
|||||||
#include "datacache/idatacache.h"
|
#include "datacache/idatacache.h"
|
||||||
#include "datacache/imdlcache.h"
|
#include "datacache/imdlcache.h"
|
||||||
#include "vphysics_interface.h"
|
#include "vphysics_interface.h"
|
||||||
#include "vgui/ivgui.h"
|
#include "vgui/IVGui.h"
|
||||||
#include "vgui/ISurface.h"
|
#include "vgui/ISurface.h"
|
||||||
#include "inputsystem/iinputsystem.h"
|
#include "inputsystem/iinputsystem.h"
|
||||||
#include "tier0/icommandline.h"
|
#include "tier0/icommandline.h"
|
||||||
#include "p4lib/ip4.h"
|
#include "p4lib/ip4.h"
|
||||||
|
|
||||||
|
#ifdef USE_SDL
|
||||||
|
# include <SDL.h>
|
||||||
|
# include <SDL_version.h>
|
||||||
|
# ifndef _WIN32
|
||||||
|
# define MB_OK 0
|
||||||
|
# define MB_ICONSTOP 0
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Global systems
|
// Global systems
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -129,6 +136,16 @@ void CHammerApp::Destroy()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if defined( USE_SDL ) && !defined( _WIN32 )
|
||||||
|
|
||||||
|
int MessageBox( HWND hWnd, const char *message, const char *header, unsigned uType )
|
||||||
|
{
|
||||||
|
SDL_ShowSimpleMessageBox( 0, header, message, GetAssertDialogParent() );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
SpewRetval_t HammerSpewFunc( SpewType_t type, tchar const *pMsg )
|
SpewRetval_t HammerSpewFunc( SpewType_t type, tchar const *pMsg )
|
||||||
|
49
hammer_launcher/wscript
Normal file
49
hammer_launcher/wscript
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#! /usr/bin/env python
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
from waflib import Utils
|
||||||
|
import os
|
||||||
|
|
||||||
|
top = '.'
|
||||||
|
PROJECT_NAME = 'hammer_launcher'
|
||||||
|
|
||||||
|
def options(opt):
|
||||||
|
# stub
|
||||||
|
return
|
||||||
|
|
||||||
|
def configure(conf):
|
||||||
|
return
|
||||||
|
|
||||||
|
def build(bld):
|
||||||
|
if bld.env.DEST_OS == 'android':
|
||||||
|
return
|
||||||
|
|
||||||
|
source = ['main.cpp']
|
||||||
|
includes = [
|
||||||
|
'../public',
|
||||||
|
'../public/tier0',
|
||||||
|
'../public/tier1',
|
||||||
|
] + bld.env.INCLUDES_SDL2
|
||||||
|
defines = []
|
||||||
|
libs = ['tier0', 'appframework', 'tier1', 'vstdlib', 'SDL2']
|
||||||
|
|
||||||
|
if bld.env.DEST_OS != 'win32':
|
||||||
|
libs += [ 'DL', 'LOG' ]
|
||||||
|
else:
|
||||||
|
libs += ['USER32', 'SHELL32']
|
||||||
|
source += ['hammer_launcher.rc']
|
||||||
|
|
||||||
|
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()
|
||||||
|
)
|
||||||
|
|
@ -112,7 +112,7 @@ void CDbgLogger::Init(const char *logfile)
|
|||||||
#ifdef GIT_COMMIT_HASH
|
#ifdef GIT_COMMIT_HASH
|
||||||
fprintf(file, ">>> Engine(arch:%s commit:" GIT_COMMIT_HASH ") started at %s\n", GetProcessorArchName(), szTime);
|
fprintf(file, ">>> Engine(arch:%s commit:" GIT_COMMIT_HASH ") started at %s\n", GetProcessorArchName(), szTime);
|
||||||
#else
|
#else
|
||||||
fprintf(file, ">>> Engine(arch:%s) started at %s\n", GetProcessorArchName(), szTime);
|
fprintf(file, ">>> Engine(arch:%s version:" REL_VERSION ") started at %s\n", GetProcessorArchName(), szTime);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef GNUC
|
#ifdef GNUC
|
||||||
|
@ -16,6 +16,8 @@ def configure(conf):
|
|||||||
conf.define('WAF_LDFLAGS', conf.env.LINKFLAGS)
|
conf.define('WAF_LDFLAGS', conf.env.LINKFLAGS)
|
||||||
conf.define('TIER0_DLL_EXPORT',1)
|
conf.define('TIER0_DLL_EXPORT',1)
|
||||||
# conf.define('NO_HOOK_MALLOC',1)
|
# conf.define('NO_HOOK_MALLOC',1)
|
||||||
|
conf.define('GIT_COMMIT_HASH', conf.env.GIT_VERSION)
|
||||||
|
conf.define('REL_VERSION', conf.env.REL_VERSION)
|
||||||
|
|
||||||
def build(bld):
|
def build(bld):
|
||||||
source = [
|
source = [
|
||||||
|
@ -49,7 +49,7 @@ void LoadMaterialSystemInterface( CreateInterfaceFn fileSystemFactory )
|
|||||||
|
|
||||||
if (!g_pMaterialSystem->Init( "shaderapiempty" DLL_EXT_STRING, 0, fileSystemFactory ))
|
if (!g_pMaterialSystem->Init( "shaderapiempty" DLL_EXT_STRING, 0, fileSystemFactory ))
|
||||||
{
|
{
|
||||||
Error( "Could not start the empty shader (shaderapiempty)!" );
|
Error( "Could not start the empty shader (shaderapiempty)!\n" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
346
utils/vbsp/disp_ivp.cpp
Normal file
346
utils/vbsp/disp_ivp.cpp
Normal file
@ -0,0 +1,346 @@
|
|||||||
|
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||||
|
//
|
||||||
|
// Purpose:
|
||||||
|
//
|
||||||
|
//=============================================================================//
|
||||||
|
#include "vbsp.h"
|
||||||
|
#include "disp_vbsp.h"
|
||||||
|
#include "builddisp.h"
|
||||||
|
#include "disp_common.h"
|
||||||
|
#include "ivp.h"
|
||||||
|
#include "disp_vbsp.h"
|
||||||
|
#include "vphysics_interface.h"
|
||||||
|
#include "vphysics/virtualmesh.h"
|
||||||
|
#include "utlrbtree.h"
|
||||||
|
#include "tier1/utlbuffer.h"
|
||||||
|
#include "materialpatch.h"
|
||||||
|
|
||||||
|
struct disp_grid_t
|
||||||
|
{
|
||||||
|
int gridIndex;
|
||||||
|
CUtlVector<int> dispList;
|
||||||
|
};
|
||||||
|
|
||||||
|
static CUtlVector<disp_grid_t> gDispGridList;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
disp_grid_t &FindOrInsertGrid( int gridIndex )
|
||||||
|
{
|
||||||
|
// linear search is slow, but only a few grids will be present
|
||||||
|
for ( int i = gDispGridList.Count()-1; i >= 0; i-- )
|
||||||
|
{
|
||||||
|
if ( gDispGridList[i].gridIndex == gridIndex )
|
||||||
|
{
|
||||||
|
return gDispGridList[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int index = gDispGridList.AddToTail();
|
||||||
|
gDispGridList[index].gridIndex = gridIndex;
|
||||||
|
|
||||||
|
// must be empty
|
||||||
|
Assert( gDispGridList[index].dispList.Count() == 0 );
|
||||||
|
|
||||||
|
return gDispGridList[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
// UNDONE: Tune these or adapt them to map size or triangle count?
|
||||||
|
#define DISP_GRID_SIZEX 4096
|
||||||
|
#define DISP_GRID_SIZEY 4096
|
||||||
|
#define DISP_GRID_SIZEZ 8192
|
||||||
|
|
||||||
|
int Disp_GridIndex( CCoreDispInfo *pDispInfo )
|
||||||
|
{
|
||||||
|
// quick hash the center into the grid and put the whole terrain in that grid
|
||||||
|
Vector mins, maxs;
|
||||||
|
pDispInfo->GetNode(0)->GetBoundingBox( mins, maxs );
|
||||||
|
Vector center;
|
||||||
|
center = 0.5 * (mins + maxs);
|
||||||
|
// make sure it's positive
|
||||||
|
center += Vector(MAX_COORD_INTEGER,MAX_COORD_INTEGER,MAX_COORD_INTEGER);
|
||||||
|
int gridX = center.x / DISP_GRID_SIZEX;
|
||||||
|
int gridY = center.y / DISP_GRID_SIZEY;
|
||||||
|
int gridZ = center.z / DISP_GRID_SIZEZ;
|
||||||
|
|
||||||
|
gridX &= 0xFF;
|
||||||
|
gridY &= 0xFF;
|
||||||
|
gridZ &= 0xFF;
|
||||||
|
return MAKEID( gridX, gridY, gridZ, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddToGrid( int gridIndex, int dispIndex )
|
||||||
|
{
|
||||||
|
disp_grid_t &grid = FindOrInsertGrid( gridIndex );
|
||||||
|
grid.dispList.AddToTail( dispIndex );
|
||||||
|
}
|
||||||
|
|
||||||
|
MaterialSystemMaterial_t GetMatIDFromDisp( mapdispinfo_t *pMapDisp )
|
||||||
|
{
|
||||||
|
texinfo_t *pTexInfo = &texinfo[pMapDisp->face.texinfo];
|
||||||
|
dtexdata_t *pTexData = GetTexData( pTexInfo->texdata );
|
||||||
|
MaterialSystemMaterial_t matID = FindOriginalMaterial( TexDataStringTable_GetString( pTexData->nameStringTableID ), NULL, true );
|
||||||
|
return matID;
|
||||||
|
}
|
||||||
|
|
||||||
|
// adds all displacement faces as a series of convex objects
|
||||||
|
// UNDONE: Only add the displacements for this model?
|
||||||
|
void Disp_AddCollisionModels( CUtlVector<CPhysCollisionEntry *> &collisionList, dmodel_t *pModel, int contentsMask)
|
||||||
|
{
|
||||||
|
int dispIndex;
|
||||||
|
|
||||||
|
// Add each displacement to the grid hash
|
||||||
|
for ( dispIndex = 0; dispIndex < g_CoreDispInfos.Count(); dispIndex++ )
|
||||||
|
{
|
||||||
|
CCoreDispInfo *pDispInfo = g_CoreDispInfos[ dispIndex ];
|
||||||
|
mapdispinfo_t *pMapDisp = &mapdispinfo[ dispIndex ];
|
||||||
|
|
||||||
|
// not solid for this pass
|
||||||
|
if ( !(pMapDisp->contents & contentsMask) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
int gridIndex = Disp_GridIndex( pDispInfo );
|
||||||
|
AddToGrid( gridIndex, dispIndex );
|
||||||
|
}
|
||||||
|
|
||||||
|
// now make a polysoup for the terrain in each grid
|
||||||
|
for ( int grid = 0; grid < gDispGridList.Count(); grid++ )
|
||||||
|
{
|
||||||
|
int triCount = 0;
|
||||||
|
CPhysPolysoup *pTerrainPhysics = physcollision->PolysoupCreate();
|
||||||
|
|
||||||
|
// iterate the displacements in this grid
|
||||||
|
for ( int listIndex = 0; listIndex < gDispGridList[grid].dispList.Count(); listIndex++ )
|
||||||
|
{
|
||||||
|
dispIndex = gDispGridList[grid].dispList[listIndex];
|
||||||
|
CCoreDispInfo *pDispInfo = g_CoreDispInfos[ dispIndex ];
|
||||||
|
mapdispinfo_t *pMapDisp = &mapdispinfo[ dispIndex ];
|
||||||
|
|
||||||
|
// Get the material id.
|
||||||
|
MaterialSystemMaterial_t matID = GetMatIDFromDisp( pMapDisp );
|
||||||
|
|
||||||
|
// Build a triangle list. This shares the tesselation code with the engine.
|
||||||
|
CUtlVector<unsigned short> indices;
|
||||||
|
CVBSPTesselateHelper helper;
|
||||||
|
helper.m_pIndices = &indices;
|
||||||
|
helper.m_pActiveVerts = pDispInfo->GetAllowedVerts().Base();
|
||||||
|
helper.m_pPowerInfo = pDispInfo->GetPowerInfo();
|
||||||
|
|
||||||
|
::TesselateDisplacement( &helper );
|
||||||
|
|
||||||
|
Assert( indices.Count() > 0 );
|
||||||
|
Assert( indices.Count() % 3 == 0 ); // Make sure indices are a multiple of 3.
|
||||||
|
int nTriCount = indices.Count() / 3;
|
||||||
|
triCount += nTriCount;
|
||||||
|
if ( triCount >= 65536 )
|
||||||
|
{
|
||||||
|
// don't put more than 64K tris in any single collision model
|
||||||
|
CPhysCollide *pCollide = physcollision->ConvertPolysoupToCollide( pTerrainPhysics, false );
|
||||||
|
if ( pCollide )
|
||||||
|
{
|
||||||
|
collisionList.AddToTail( new CPhysCollisionEntryStaticMesh( pCollide, NULL ) );
|
||||||
|
}
|
||||||
|
// Throw this polysoup away and start over for the remaining triangles
|
||||||
|
physcollision->PolysoupDestroy( pTerrainPhysics );
|
||||||
|
pTerrainPhysics = physcollision->PolysoupCreate();
|
||||||
|
triCount = nTriCount;
|
||||||
|
}
|
||||||
|
Vector tmpVerts[3];
|
||||||
|
for ( int iTri = 0; iTri < nTriCount; ++iTri )
|
||||||
|
{
|
||||||
|
float flAlphaTotal = 0.0f;
|
||||||
|
for ( int iTriVert = 0; iTriVert < 3; ++iTriVert )
|
||||||
|
{
|
||||||
|
pDispInfo->GetVert( indices[iTri*3+iTriVert], tmpVerts[iTriVert] );
|
||||||
|
flAlphaTotal += pDispInfo->GetAlpha( indices[iTri*3+iTriVert] );
|
||||||
|
}
|
||||||
|
|
||||||
|
int nProp = g_SurfaceProperties[texinfo[pMapDisp->face.texinfo].texdata];
|
||||||
|
if ( flAlphaTotal > DISP_ALPHA_PROP_DELTA )
|
||||||
|
{
|
||||||
|
int nProp2 = GetSurfaceProperties2( matID, "surfaceprop2" );
|
||||||
|
if ( nProp2 != -1 )
|
||||||
|
{
|
||||||
|
nProp = nProp2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int nMaterialIndex = RemapWorldMaterial( nProp );
|
||||||
|
physcollision->PolysoupAddTriangle( pTerrainPhysics, tmpVerts[0], tmpVerts[1], tmpVerts[2], nMaterialIndex );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// convert the whole grid's polysoup to a collide and store in the collision list
|
||||||
|
CPhysCollide *pCollide = physcollision->ConvertPolysoupToCollide( pTerrainPhysics, false );
|
||||||
|
if ( pCollide )
|
||||||
|
{
|
||||||
|
collisionList.AddToTail( new CPhysCollisionEntryStaticMesh( pCollide, NULL ) );
|
||||||
|
}
|
||||||
|
// now that we have the collide, we're done with the soup
|
||||||
|
physcollision->PolysoupDestroy( pTerrainPhysics );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class CDispMeshEvent : public IVirtualMeshEvent
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CDispMeshEvent( unsigned short *pIndices, int indexCount, CCoreDispInfo *pDispInfo );
|
||||||
|
virtual void GetVirtualMesh( void *userData, virtualmeshlist_t *pList );
|
||||||
|
virtual void GetWorldspaceBounds( void *userData, Vector *pMins, Vector *pMaxs );
|
||||||
|
virtual void GetTrianglesInSphere( void *userData, const Vector ¢er, float radius, virtualmeshtrianglelist_t *pList );
|
||||||
|
|
||||||
|
CUtlVector<Vector> m_verts;
|
||||||
|
unsigned short *m_pIndices;
|
||||||
|
int m_indexCount;
|
||||||
|
};
|
||||||
|
|
||||||
|
CDispMeshEvent::CDispMeshEvent( unsigned short *pIndices, int indexCount, CCoreDispInfo *pDispInfo )
|
||||||
|
{
|
||||||
|
m_pIndices = pIndices;
|
||||||
|
m_indexCount = indexCount;
|
||||||
|
int maxIndex = 0;
|
||||||
|
for ( int i = 0; i < indexCount; i++ )
|
||||||
|
{
|
||||||
|
if ( pIndices[i] > maxIndex )
|
||||||
|
{
|
||||||
|
maxIndex = pIndices[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for ( int i = 0; i < indexCount/2; i++ )
|
||||||
|
{
|
||||||
|
V_swap( pIndices[i], pIndices[(indexCount-i)-1] );
|
||||||
|
}
|
||||||
|
int count = maxIndex + 1;
|
||||||
|
m_verts.SetCount( count );
|
||||||
|
for ( int i = 0; i < count; i++ )
|
||||||
|
{
|
||||||
|
m_verts[i] = pDispInfo->GetVert(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDispMeshEvent::GetVirtualMesh( void *userData, virtualmeshlist_t *pList )
|
||||||
|
{
|
||||||
|
Assert(userData==((void *)this));
|
||||||
|
pList->pVerts = m_verts.Base();
|
||||||
|
pList->indexCount = m_indexCount;
|
||||||
|
pList->triangleCount = m_indexCount/3;
|
||||||
|
pList->vertexCount = m_verts.Count();
|
||||||
|
pList->surfacePropsIndex = 0; // doesn't matter here, reset at runtime
|
||||||
|
pList->pHull = NULL;
|
||||||
|
int indexMax = ARRAYSIZE(pList->indices);
|
||||||
|
int indexCount = min(m_indexCount, indexMax);
|
||||||
|
Assert(m_indexCount < indexMax);
|
||||||
|
Q_memcpy( pList->indices, m_pIndices, sizeof(*m_pIndices) * indexCount );
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDispMeshEvent::GetWorldspaceBounds( void *userData, Vector *pMins, Vector *pMaxs )
|
||||||
|
{
|
||||||
|
Assert(userData==((void *)this));
|
||||||
|
ClearBounds( *pMins, *pMaxs );
|
||||||
|
for ( int i = 0; i < m_verts.Count(); i++ )
|
||||||
|
{
|
||||||
|
AddPointToBounds( m_verts[i], *pMins, *pMaxs );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDispMeshEvent::GetTrianglesInSphere( void *userData, const Vector ¢er, float radius, virtualmeshtrianglelist_t *pList )
|
||||||
|
{
|
||||||
|
Assert(userData==((void *)this));
|
||||||
|
pList->triangleCount = m_indexCount/3;
|
||||||
|
int indexMax = ARRAYSIZE(pList->triangleIndices);
|
||||||
|
int indexCount = min(m_indexCount, indexMax);
|
||||||
|
Assert(m_indexCount < MAX_VIRTUAL_TRIANGLES*3);
|
||||||
|
Q_memcpy( pList->triangleIndices, m_pIndices, sizeof(*m_pIndices) * indexCount );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Disp_BuildVirtualMesh( int contentsMask )
|
||||||
|
{
|
||||||
|
CUtlVector<CPhysCollide *> virtualMeshes;
|
||||||
|
virtualMeshes.EnsureCount( g_CoreDispInfos.Count() );
|
||||||
|
for ( int i = 0; i < g_CoreDispInfos.Count(); i++ )
|
||||||
|
{
|
||||||
|
CCoreDispInfo *pDispInfo = g_CoreDispInfos[ i ];
|
||||||
|
mapdispinfo_t *pMapDisp = &mapdispinfo[ i ];
|
||||||
|
|
||||||
|
virtualMeshes[i] = NULL;
|
||||||
|
// not solid for this pass
|
||||||
|
if ( !(pMapDisp->contents & contentsMask) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Build a triangle list. This shares the tesselation code with the engine.
|
||||||
|
CUtlVector<unsigned short> indices;
|
||||||
|
CVBSPTesselateHelper helper;
|
||||||
|
helper.m_pIndices = &indices;
|
||||||
|
helper.m_pActiveVerts = pDispInfo->GetAllowedVerts().Base();
|
||||||
|
helper.m_pPowerInfo = pDispInfo->GetPowerInfo();
|
||||||
|
|
||||||
|
::TesselateDisplacement( &helper );
|
||||||
|
|
||||||
|
// validate the collision data
|
||||||
|
if ( 1 )
|
||||||
|
{
|
||||||
|
int triCount = indices.Count() / 3;
|
||||||
|
for ( int j = 0; j < triCount; j++ )
|
||||||
|
{
|
||||||
|
int index = j * 3;
|
||||||
|
Vector v0 = pDispInfo->GetVert( indices[index+0] );
|
||||||
|
Vector v1 = pDispInfo->GetVert( indices[index+1] );
|
||||||
|
Vector v2 = pDispInfo->GetVert( indices[index+2] );
|
||||||
|
if ( v0 == v1 || v1 == v2 || v2 == v0 )
|
||||||
|
{
|
||||||
|
Warning( "Displacement %d has bad geometry near %.2f %.2f %.2f\n", i, v0.x, v0.y, v0.z );
|
||||||
|
texinfo_t *pTexInfo = &texinfo[pMapDisp->face.texinfo];
|
||||||
|
dtexdata_t *pTexData = GetTexData( pTexInfo->texdata );
|
||||||
|
const char *pMatName = TexDataStringTable_GetString( pTexData->nameStringTableID );
|
||||||
|
|
||||||
|
Error( "Can't compile displacement physics, exiting. Texture is %s\n", pMatName );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
CDispMeshEvent meshHandler( indices.Base(), indices.Count(), pDispInfo );
|
||||||
|
virtualmeshparams_t params;
|
||||||
|
params.buildOuterHull = true;
|
||||||
|
params.pMeshEventHandler = &meshHandler;
|
||||||
|
params.userData = &meshHandler;
|
||||||
|
virtualMeshes[i] = physcollision->CreateVirtualMesh( params );
|
||||||
|
}
|
||||||
|
unsigned int totalSize = 0;
|
||||||
|
CUtlBuffer buf;
|
||||||
|
dphysdisp_t header;
|
||||||
|
header.numDisplacements = g_CoreDispInfos.Count();
|
||||||
|
buf.PutObjects( &header );
|
||||||
|
|
||||||
|
CUtlVector<char> dispBuf;
|
||||||
|
for ( int i = 0; i < header.numDisplacements; i++ )
|
||||||
|
{
|
||||||
|
if ( virtualMeshes[i] )
|
||||||
|
{
|
||||||
|
unsigned int testSize = physcollision->CollideSize( virtualMeshes[i] );
|
||||||
|
totalSize += testSize;
|
||||||
|
buf.PutShort( testSize );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buf.PutShort( -1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for ( int i = 0; i < header.numDisplacements; i++ )
|
||||||
|
{
|
||||||
|
if ( virtualMeshes[i] )
|
||||||
|
{
|
||||||
|
unsigned int testSize = physcollision->CollideSize( virtualMeshes[i] );
|
||||||
|
dispBuf.RemoveAll();
|
||||||
|
dispBuf.EnsureCount(testSize);
|
||||||
|
|
||||||
|
unsigned int outSize = physcollision->CollideWrite( dispBuf.Base(), virtualMeshes[i], false );
|
||||||
|
Assert( outSize == testSize );
|
||||||
|
buf.Put( dispBuf.Base(), outSize );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_PhysDispSize = totalSize + sizeof(dphysdisp_t) + (sizeof(unsigned short) * header.numDisplacements);
|
||||||
|
Assert( buf.TellMaxPut() == g_PhysDispSize );
|
||||||
|
g_PhysDispSize = buf.TellMaxPut();
|
||||||
|
g_pPhysDisp = new byte[g_PhysDispSize];
|
||||||
|
Q_memcpy( g_pPhysDisp, buf.Base(), g_PhysDispSize );
|
||||||
|
}
|
||||||
|
|
@ -67,4 +67,6 @@ bool HasDispInfo( mapbrush_t *pBrush );
|
|||||||
// Computes the bounds for a disp info
|
// Computes the bounds for a disp info
|
||||||
void ComputeDispInfoBounds( int dispinfo, Vector& mins, Vector& maxs );
|
void ComputeDispInfoBounds( int dispinfo, Vector& mins, Vector& maxs );
|
||||||
|
|
||||||
|
extern void Disp_AddCollisionModels( CUtlVector<CPhysCollisionEntry *> &collisionList, dmodel_t *pModel, int contentsMask );
|
||||||
|
extern void Disp_BuildVirtualMesh( int contentsMask );
|
||||||
#endif // VBSP_DISPINFO_H
|
#endif // VBSP_DISPINFO_H
|
||||||
|
1652
utils/vbsp/ivp.cpp
Normal file
1652
utils/vbsp/ivp.cpp
Normal file
File diff suppressed because it is too large
Load Diff
75
utils/vbsp/ivp.h
Normal file
75
utils/vbsp/ivp.h
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||||
|
//
|
||||||
|
// Purpose:
|
||||||
|
//
|
||||||
|
//=============================================================================//
|
||||||
|
|
||||||
|
#ifndef IVP_H
|
||||||
|
#define IVP_H
|
||||||
|
#ifdef _WIN32
|
||||||
|
#pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "utlvector.h"
|
||||||
|
|
||||||
|
class CPhysCollide;
|
||||||
|
class CTextBuffer;
|
||||||
|
class IPhysicsCollision;
|
||||||
|
extern IPhysicsCollision *physcollision;
|
||||||
|
|
||||||
|
// a list of all of the materials in the world model
|
||||||
|
extern int RemapWorldMaterial( int materialIndexIn );
|
||||||
|
|
||||||
|
class CPhysCollisionEntry
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CPhysCollisionEntry( CPhysCollide *pCollide );
|
||||||
|
|
||||||
|
virtual void WriteToTextBuffer( CTextBuffer *pTextBuffer, int modelIndex, int collideIndex ) = 0;
|
||||||
|
virtual void DumpCollide( CTextBuffer *pTextBuffer, int modelIndex, int collideIndex ) = 0;
|
||||||
|
|
||||||
|
unsigned int GetCollisionBinarySize();
|
||||||
|
unsigned int WriteCollisionBinary( char *pDest );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void DumpCollideFileName( const char *pName, int modelIndex, CTextBuffer *pTextBuffer );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
CPhysCollide *m_pCollide;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CPhysCollisionEntryStaticMesh : public CPhysCollisionEntry
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CPhysCollisionEntryStaticMesh( CPhysCollide *pCollide, const char *pMaterialName );
|
||||||
|
|
||||||
|
virtual void WriteToTextBuffer( CTextBuffer *pTextBuffer, int modelIndex, int collideIndex );
|
||||||
|
virtual void DumpCollide( CTextBuffer *pTextBuffer, int modelIndex, int collideIndex );
|
||||||
|
|
||||||
|
private:
|
||||||
|
const char *m_pMaterial;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class CTextBuffer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CTextBuffer( void );
|
||||||
|
~CTextBuffer( void );
|
||||||
|
inline int GetSize( void ) { return m_buffer.Count(); }
|
||||||
|
inline char *GetData( void ) { return m_buffer.Base(); }
|
||||||
|
|
||||||
|
void WriteText( const char *pText );
|
||||||
|
void WriteIntKey( const char *pKeyName, int outputData );
|
||||||
|
void WriteStringKey( const char *pKeyName, const char *outputData );
|
||||||
|
void WriteFloatKey( const char *pKeyName, float outputData );
|
||||||
|
void WriteFloatArrayKey( const char *pKeyName, const float *outputData, int count );
|
||||||
|
|
||||||
|
void CopyStringQuotes( const char *pString );
|
||||||
|
void Terminate( void );
|
||||||
|
private:
|
||||||
|
void CopyData( const char *pData, int len );
|
||||||
|
CUtlVector<char> m_buffer;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // IVP_H
|
@ -931,7 +931,7 @@ void WriteBSP (node_t *headnode, face_t *pLeafFaceList )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// EmitWaterVolumesForBSP( &dmodels[nummodels], headnode );
|
EmitWaterVolumesForBSP( &dmodels[nummodels], headnode );
|
||||||
qprintf ("%5i nodes with faces\n", c_facenodes);
|
qprintf ("%5i nodes with faces\n", c_facenodes);
|
||||||
qprintf ("%5i nodes without faces\n", c_nofaces);
|
qprintf ("%5i nodes without faces\n", c_nofaces);
|
||||||
qprintf ("%5i faces\n", numfaces-oldfaces);
|
qprintf ("%5i faces\n", numfaces-oldfaces);
|
||||||
@ -1257,7 +1257,7 @@ void EndBSPFile (void)
|
|||||||
OverlayTransition_EmitOverlayFaces();
|
OverlayTransition_EmitOverlayFaces();
|
||||||
|
|
||||||
// phys collision needs dispinfo to operate (needs to generate phys collision for displacement surfs)
|
// phys collision needs dispinfo to operate (needs to generate phys collision for displacement surfs)
|
||||||
// EmitPhysCollision();
|
EmitPhysCollision();
|
||||||
|
|
||||||
// We can't calculate this properly until vvis (since we need vis to do this), so we set
|
// We can't calculate this properly until vvis (since we need vis to do this), so we set
|
||||||
// to zero everywhere by default.
|
// to zero everywhere by default.
|
||||||
|
@ -24,8 +24,10 @@ def build(bld):
|
|||||||
'detail.cpp',
|
'detail.cpp',
|
||||||
'detailobjects.cpp',
|
'detailobjects.cpp',
|
||||||
'disp_vbsp.cpp',
|
'disp_vbsp.cpp',
|
||||||
|
'disp_ivp.cpp',
|
||||||
'faces.cpp',
|
'faces.cpp',
|
||||||
'glfile.cpp',
|
'glfile.cpp',
|
||||||
|
'ivp.cpp',
|
||||||
'leakfile.cpp',
|
'leakfile.cpp',
|
||||||
'map.cpp',
|
'map.cpp',
|
||||||
'manifest.cpp',
|
'manifest.cpp',
|
||||||
|
33
wscript
33
wscript
@ -8,7 +8,7 @@ from waflib import Logs, Context, Configure
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
VERSION = '1.0'
|
VERSION = '1.17'
|
||||||
APPNAME = 'source-engine'
|
APPNAME = 'source-engine'
|
||||||
top = '.'
|
top = '.'
|
||||||
|
|
||||||
@ -174,29 +174,26 @@ def define_platform(conf):
|
|||||||
if conf.options.ALLOW64:
|
if conf.options.ALLOW64:
|
||||||
conf.define('PLATFORM_64BITS', 1)
|
conf.define('PLATFORM_64BITS', 1)
|
||||||
|
|
||||||
conf.env.projects = ['base']
|
conf.env.targets = projects['base']
|
||||||
conf.env.targets = []
|
|
||||||
if conf.options.DEDICATED:
|
if conf.options.DEDICATED:
|
||||||
conf.env.DEDICATED = True
|
conf.env.DEDICATED = True
|
||||||
conf.env.projects += ['dedicated']
|
conf.env.targets += projects['dedicated']
|
||||||
conf.options.SDL = False
|
conf.options.SDL = False
|
||||||
conf.define('DEDICATED', 1)
|
conf.define('DEDICATED', 1)
|
||||||
|
|
||||||
if conf.options.LAUNCHER:
|
if conf.options.LAUNCHER:
|
||||||
conf.env.projects += ['main']
|
conf.env.targets += projects['main']
|
||||||
conf.env.GL = conf.options.GL or conf.options.TOGLES
|
conf.env.GL = conf.options.GL or conf.options.TOGLES
|
||||||
if conf.options.TOGLES:
|
if conf.options.TOGLES:
|
||||||
conf.env.TOGLES = True
|
conf.env.TOGLES = True
|
||||||
conf.env.targets += ['togles']
|
|
||||||
conf.env.append_unique('DEFINES', ['TOGLES'])
|
conf.env.append_unique('DEFINES', ['TOGLES'])
|
||||||
if conf.env.GL:
|
if conf.env.GL:
|
||||||
if not conf.env.TOGLES:
|
|
||||||
conf.env.targets += ['togl']
|
|
||||||
conf.env.append_unique('DEFINES', [
|
conf.env.append_unique('DEFINES', [
|
||||||
'DX_TO_GL_ABSTRACTION',
|
'DX_TO_GL_ABSTRACTION',
|
||||||
'GL_GLEXT_PROTOTYPES',
|
'GL_GLEXT_PROTOTYPES',
|
||||||
'BINK_VIDEO'
|
'BINK_VIDEO'
|
||||||
])
|
])
|
||||||
|
conf.env.targets += ['togles' if conf.env.TOGLES else 'togl']
|
||||||
|
|
||||||
if conf.options.SDL:
|
if conf.options.SDL:
|
||||||
conf.env.SDL = True
|
conf.env.SDL = True
|
||||||
@ -204,11 +201,11 @@ def define_platform(conf):
|
|||||||
|
|
||||||
if conf.options.TESTS:
|
if conf.options.TESTS:
|
||||||
conf.env.TESTS = True
|
conf.env.TESTS = True
|
||||||
conf.env.projects += ['tests']
|
conf.env.targets += projects['tests']
|
||||||
conf.define('UNITTESTS', 1)
|
conf.define('UNITTESTS', 1)
|
||||||
|
|
||||||
if conf.options.UTILS:
|
if conf.options.UTILS:
|
||||||
conf.env.projects += ['utils']
|
conf.env.targets += projects['utils']
|
||||||
|
|
||||||
if conf.env.DEST_OS == 'win32' and not conf.env.TESTS:
|
if conf.env.DEST_OS == 'win32' and not conf.env.TESTS:
|
||||||
conf.env.targets += ['utils/bzip2']
|
conf.env.targets += ['utils/bzip2']
|
||||||
@ -458,7 +455,8 @@ def configure(conf):
|
|||||||
conf.load('mm_hook')
|
conf.load('mm_hook')
|
||||||
|
|
||||||
define_platform(conf)
|
define_platform(conf)
|
||||||
conf.define('GIT_COMMIT_HASH', conf.env.GIT_VERSION)
|
conf.env.targets = set(conf.env.targets)
|
||||||
|
conf.env.REL_VERSION = VERSION
|
||||||
|
|
||||||
conf.env.BIT32_MANDATORY = not conf.options.ALLOW64
|
conf.env.BIT32_MANDATORY = not conf.options.ALLOW64
|
||||||
if conf.env.BIT32_MANDATORY:
|
if conf.env.BIT32_MANDATORY:
|
||||||
@ -612,21 +610,16 @@ def configure(conf):
|
|||||||
conf.env.CC.insert(0, 'ccache')
|
conf.env.CC.insert(0, 'ccache')
|
||||||
conf.env.CXX.insert(0, 'ccache')
|
conf.env.CXX.insert(0, 'ccache')
|
||||||
|
|
||||||
for proj in conf.env.projects:
|
conf.add_subproject(conf.env.targets)
|
||||||
conf.add_subproject(projects[proj])
|
|
||||||
for targ in conf.env.targets:
|
|
||||||
conf.add_subproject(targ)
|
|
||||||
|
|
||||||
def build(bld):
|
def build(bld):
|
||||||
os.environ["CCACHE_DIR"] = os.path.abspath('.ccache/'+bld.env.COMPILER_CC+'/'+bld.env.DEST_OS+'/'+bld.env.DEST_CPU)
|
if not os.environ.get('CCACHE_DIR'):
|
||||||
|
os.environ['CCACHE_DIR'] = os.path.abspath('.ccache/'+bld.env.COMPILER_CC+'/'+bld.env.DEST_OS+'/'+bld.env.DEST_CPU)
|
||||||
|
|
||||||
if bld.env.DEST_OS in ['win32', 'android']:
|
if bld.env.DEST_OS in ['win32', 'android']:
|
||||||
sdl_name = 'SDL2.dll' if bld.env.DEST_OS == 'win32' else 'libSDL2.so'
|
sdl_name = 'SDL2.dll' if bld.env.DEST_OS == 'win32' else 'libSDL2.so'
|
||||||
sdl_path = os.path.join('lib', bld.env.DEST_OS, bld.env.DEST_CPU, sdl_name)
|
sdl_path = os.path.join('lib', bld.env.DEST_OS, bld.env.DEST_CPU, sdl_name)
|
||||||
bld.install_files(bld.env.LIBDIR, [sdl_path])
|
bld.install_files(bld.env.LIBDIR, [sdl_path])
|
||||||
|
|
||||||
for proj in bld.env.projects:
|
bld.add_subproject(bld.env.targets)
|
||||||
bld.add_subproject(projects[proj])
|
|
||||||
for targ in bld.env.targets:
|
|
||||||
bld.add_subproject(targ)
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user