1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $Workfile: $
// $Date: $
// $NoKeywords: $
//=============================================================================//
#ifndef IDISPINFO_H
#define IDISPINFO_H
#ifdef _WIN32
#pragma once
#endif
//=============================================================================
#include <assert.h>
#include "bspfile.h"
#include "mathlib/vmatrix.h"
#include "dispnode.h"
#include "builddisp.h"
#include "utlvector.h"
#include "engine/ishadowmgr.h"
#include "getintersectingsurfaces_struct.h"
#include "surfacehandle.h"
#include "ivrenderview.h"
struct model_t;
struct Ray_t;
struct RayDispOutput_t;
struct decal_t;
class CMeshBuilder;
//-----------------------------------------------------------------------------
// Handle to decals + shadows on displacements
//-----------------------------------------------------------------------------
typedef unsigned short DispDecalHandle_t;
enum
{
DISP_DECAL_HANDLE_INVALID = (DispDecalHandle_t)~0
};
typedef unsigned short DispShadowHandle_t;
enum
{
DISP_SHADOW_HANDLE_INVALID = (DispShadowHandle_t)~0
};
//-----------------------------------------------------------------------------
// Displacement interface to the engine (and WorldCraft?)
//-----------------------------------------------------------------------------
abstract_class IDispInfo
{
public:
virtual ~IDispInfo() {}
// Builds a list of displacement triangles intersecting the sphere.
virtual void GetIntersectingSurfaces( GetIntersectingSurfaces_Struct *pStruct ) = 0;
virtual void RenderWireframeInLightmapPage( int pageId ) = 0;
virtual void GetBoundingBox( Vector &bbMin, Vector &bbMax ) = 0;
// Get and set the parent surfaces.
virtual void SetParent( SurfaceHandle_t surfID ) = 0;
virtual SurfaceHandle_t GetParent() = 0;
// Add dynamic lights to the lightmap for this surface.
virtual void AddDynamicLights( struct dlight_t *pLights, unsigned int lightMask ) = 0;
// Compute the mask for the lights hitting this surface.
virtual unsigned int ComputeDynamicLightMask( struct dlight_t *pLights ) = 0;
// Add and remove decals.
// flSize is like the radius of the decal so the decal isn't put on any disp faces it's too far away from.
virtual DispDecalHandle_t NotifyAddDecal( decal_t *pDecal, float flSize ) = 0;
virtual void NotifyRemoveDecal( DispDecalHandle_t h ) = 0;
virtual DispShadowHandle_t AddShadowDecal( ShadowHandle_t shadowHandle ) = 0;
virtual void RemoveShadowDecal( DispShadowHandle_t handle ) = 0;
// Compute shadow fragments for a particular shadow, return the vertex + index count of all fragments
virtual bool ComputeShadowFragments( DispShadowHandle_t h, int& vertexCount, int& indexCount ) = 0;
// Tag the surface and check if it's tagged. You can untag all the surfaces
// with DispInfo_ClearAllTags. Note: it just uses a frame counter to track the
// tag state so it's really really fast to call ClearAllTags (just increments
// a variable 99.999% of the time).
virtual bool GetTag() = 0;
virtual void SetTag() = 0;
// Cast a ray against this surface
virtual bool TestRay( Ray_t const& ray, float start, float end, float& dist, Vector2D* lightmapUV, Vector2D* textureUV ) = 0;
// Computes the texture + lightmap coordinate given a displacement uv
virtual void ComputeLightmapAndTextureCoordinate( RayDispOutput_t const& uv, Vector2D* luv, Vector2D* tuv ) = 0;
};
// ----------------------------------------------------------------------------- //
// Adds shadow rendering data to a particular mesh builder
// The function will return the new base index
// ----------------------------------------------------------------------------- //
int DispInfo_AddShadowsToMeshBuilder( CMeshBuilder& meshBuilder,
DispShadowHandle_t h, int baseIndex );
typedef void* HDISPINFOARRAY;
// Init and shutdown for the material system (references global, materials).
void DispInfo_InitMaterialSystem();
void DispInfo_ShutdownMaterialSystem();
// Use these to manage a list of IDispInfos.
HDISPINFOARRAY DispInfo_CreateArray( int nElements );
void DispInfo_DeleteArray( HDISPINFOARRAY hArray );
IDispInfo* DispInfo_IndexArray( HDISPINFOARRAY hArray, int iElement );
int DispInfo_ComputeIndex( HDISPINFOARRAY hArray, IDispInfo* pInfo );
// Clear the tags for all displacements in the array.
void DispInfo_ClearAllTags( HDISPINFOARRAY hArray );
// Call this to render a list of displacements.
// If bOrtho is true, then no backface removal is done on dispinfos.
void DispInfo_RenderList( int nSortGroup, SurfaceHandle_t *pList, int listCount, bool bOrtho, unsigned long flags, ERenderDepthMode DepthMode );
// This should be called from Map_LoadDisplacements (while the map file is open).
// It loads the displacement data from the file and prepares the displacements for rendering.
//
// bRestoring is set to true when just restoring the data from the mapfile
// (ie: displacements already are initialized but need new static buffers).
bool DispInfo_LoadDisplacements( model_t *pWorld, bool bRestoring );
// Deletes all the static vertex buffers.
void DispInfo_ReleaseMaterialSystemObjects( model_t *pWorld );
#endif // IDISPINFO_H
|