aboutsummaryrefslogtreecommitdiff
path: root/mp/src/utils/vbsp/normals.cpp
blob: 3a910cb6116f0470c553bcdea5e4a555dd741362 (plain) (blame)
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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//
//=============================================================================//
#include "bsplib.h"
#include "vbsp.h"


void SaveVertexNormals( void )
{
	int i, j;
	dface_t *f;
	texinfo_t	*tex;


	g_numvertnormalindices = 0;
	g_numvertnormals = 0;

	for( i = 0 ;i<numfaces ; i++ )
	{
		f = &dfaces[i];
		tex = &texinfo[f->texinfo];

		for( j = 0; j < f->numedges; j++ )
		{
			if( g_numvertnormalindices == MAX_MAP_VERTNORMALINDICES )
			{
				Error( "g_numvertnormalindices == MAX_MAP_VERTNORMALINDICES (%d)", MAX_MAP_VERTNORMALINDICES );
			}
			
			g_vertnormalindices[g_numvertnormalindices] = g_numvertnormals;
			g_numvertnormalindices++;
		}

		// Add this face plane's normal.
		// Note: this doesn't do an exhaustive vertex normal match because the vrad does it.
		// The result is that a little extra memory is wasted coming out of vbsp, but it
		// goes away after vrad.
		if( g_numvertnormals == MAX_MAP_VERTNORMALS )
		{
			Error( "g_numvertnormals == MAX_MAP_VERTNORMALS (%d)", MAX_MAP_VERTNORMALS );
		}

		g_vertnormals[g_numvertnormals] = dplanes[f->planenum].normal;
		g_numvertnormals++;
	}
}