mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2024-12-01 16:31:45 +00:00
Small corrections to dmap
This commit is contained in:
parent
352df659a8
commit
e03ed8769d
10 changed files with 70 additions and 35 deletions
|
@ -29,8 +29,8 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#ifndef __AASBUILD_LOCAL_H__
|
||||
#define __AASBUILD_LOCAL_H__
|
||||
|
||||
#include "..\..\aas\AASFile.h"
|
||||
#include "..\..\aas\AASFile_local.h"
|
||||
#include "../../../aas/AASFile.h"
|
||||
#include "../../../aas/AASFile_local.h"
|
||||
|
||||
#include "Brush.h"
|
||||
#include "BrushBSP.h"
|
||||
|
|
|
@ -29,8 +29,8 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#include "precompiled.h"
|
||||
#pragma hdrstop
|
||||
|
||||
#include "..\..\aas\AASFile.h"
|
||||
#include "..\..\aas\AASFile_local.h"
|
||||
#include "../../../aas/AASFile.h"
|
||||
#include "../../../aas/AASFile_local.h"
|
||||
#include "AASCluster.h"
|
||||
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#include "precompiled.h"
|
||||
#pragma hdrstop
|
||||
|
||||
#include "..\..\aas\AASFile.h"
|
||||
#include "..\..\aas\AASFile_local.h"
|
||||
#include "../../../aas/AASFile.h"
|
||||
#include "../../../aas/AASFile_local.h"
|
||||
#include "AASReach.h"
|
||||
|
||||
#define INSIDEUNITS 2.0f
|
||||
|
|
|
@ -194,8 +194,10 @@ typedef struct tree_s
|
|||
typedef struct
|
||||
{
|
||||
idRenderLightLocal def;
|
||||
char name[MAX_QPATH]; // for naming the shadow volume surface and interactions
|
||||
srfTriangles_t* shadowTris;
|
||||
char name[MAX_QPATH]; // for naming the shadow volume surface and interactions
|
||||
srfTriangles_t* shadowTris;
|
||||
|
||||
idPlane frustumPlanes[6]; // RB: should be calculated after R_DeriveLightData()
|
||||
} mapLight_t;
|
||||
|
||||
#define MAX_GROUP_LIGHTS 16
|
||||
|
@ -398,6 +400,8 @@ bspface_t* MakeStructuralBspFaceList( primitive_t* list );
|
|||
bspface_t* MakeVisibleBspFaceList( primitive_t* list );
|
||||
tree_t* FaceBSP( bspface_t* list );
|
||||
|
||||
node_t* NodeForPoint( node_t* node, const idVec3& origin );
|
||||
|
||||
//=============================================================================
|
||||
|
||||
// surface.cpp
|
||||
|
@ -422,7 +426,7 @@ void FixGlobalTjunctions( uEntity_t* e );
|
|||
|
||||
//=============================================================================
|
||||
|
||||
// optimize.cpp -- trianlge mesh reoptimization
|
||||
// optimize.cpp -- triangle mesh reoptimization
|
||||
|
||||
// the shadow volume optimizer call internal optimizer routines, normal triangles
|
||||
// will just be done by OptimizeEntity()
|
||||
|
|
|
@ -38,7 +38,7 @@ extern int c_nodes;
|
|||
|
||||
void RemovePortalFromNode( uPortal_t* portal, node_t* l );
|
||||
|
||||
node_t* NodeForPoint( node_t* node, idVec3 origin )
|
||||
node_t* NodeForPoint( node_t* node, const idVec3& origin )
|
||||
{
|
||||
float d;
|
||||
|
||||
|
|
|
@ -469,6 +469,16 @@ static void CreateMapLight( const idMapEntity* mapEnt )
|
|||
|
||||
R_DeriveLightData( &light->def );
|
||||
|
||||
// RB begin
|
||||
idRenderMatrix::GetFrustumPlanes( light->frustumPlanes, light->def.baseLightProject, true, true );
|
||||
|
||||
// the DOOM 3 frustum planes point outside the frustum
|
||||
for( int i = 0; i < 6; i++ )
|
||||
{
|
||||
light->frustumPlanes[i] = -light->frustumPlanes[i];
|
||||
}
|
||||
// RB end
|
||||
|
||||
// get the name for naming the shadow surfaces
|
||||
const char* name;
|
||||
|
||||
|
|
|
@ -189,17 +189,19 @@ static bool MatchVert( const idDrawVert* a, const idDrawVert* b )
|
|||
return false;
|
||||
}
|
||||
|
||||
// RB begin
|
||||
// if the normal is 0 (smoothed normals), consider it a match
|
||||
if( a->GetNormal() == idVec3( 0, 0, 0 ) || b->GetNormal() == idVec3( 0, 0, 0 ) )
|
||||
if( a->GetNormal().Length() == 0 && b->GetNormal().Length() == 0 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// otherwise do a dot-product cosine check
|
||||
if( a->GetNormal() * b->GetNormal() < COSINE_EPSILON )
|
||||
if( ( a->GetNormal() * b->GetNormal() ) < COSINE_EPSILON )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// RB end
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -378,18 +378,24 @@ static mapTri_t* FixTriangleAgainstHashVert( const mapTri_t* a, const hashVert_t
|
|||
split.xyz = *v;
|
||||
frac = d / len;
|
||||
|
||||
idVec2 st;
|
||||
st.x = v1->GetTexCoordS() + frac * ( v2->GetTexCoordS() - v1->GetTexCoordS() );
|
||||
st.y = v1->GetTexCoordT() + frac * ( v2->GetTexCoordT() - v1->GetTexCoordT() );
|
||||
split.SetTexCoord( st );
|
||||
// RB begin
|
||||
const idVec2 v1ST = v1->GetTexCoord();
|
||||
const idVec2 v2ST = v2->GetTexCoord();
|
||||
|
||||
split.SetTexCoord( v1ST.x + frac * ( v2ST.x - v1ST.x ),
|
||||
v1ST.y + frac * ( v2ST.y - v1ST.y ) );
|
||||
|
||||
idVec3 splitNormal;
|
||||
idVec3 v1Normal = v1->GetNormal();
|
||||
idVec3 v2Normal = v2->GetNormal();
|
||||
|
||||
splitNormal[0] = v1Normal[0] + frac * ( v2Normal[0] - v1Normal[0] );
|
||||
splitNormal[1] = v1Normal[1] + frac * ( v2Normal[1] - v1Normal[1] );
|
||||
splitNormal[2] = v1Normal[2] + frac * ( v2Normal[2] - v1Normal[2] );
|
||||
splitNormal.Normalize();
|
||||
|
||||
split.SetNormal( splitNormal );
|
||||
// RB end
|
||||
|
||||
// split the tri
|
||||
new1 = CopyMapTri( a );
|
||||
|
@ -405,7 +411,7 @@ static mapTri_t* FixTriangleAgainstHashVert( const mapTri_t* a, const hashVert_t
|
|||
plane1.FromPoints( new1->hashVert[0]->v, new1->hashVert[1]->v, new1->hashVert[2]->v );
|
||||
plane2.FromPoints( new2->hashVert[0]->v, new2->hashVert[1]->v, new2->hashVert[2]->v );
|
||||
|
||||
d = plane1.ToVec4() * plane2.ToVec4();
|
||||
d = plane1.Normal() * plane2.Normal();
|
||||
|
||||
// if the two split triangle's normals don't face the same way,
|
||||
// it should not be split
|
||||
|
|
|
@ -307,19 +307,23 @@ void TriVertsFromOriginal( mapTri_t* tri, const mapTri_t* original )
|
|||
c = idWinding::TriangleArea( tri->v[i].xyz, original->v[0].xyz, original->v[1].xyz ) / denom;
|
||||
|
||||
// regenerate the interpolated values
|
||||
tri->v[i].SetTexCoordS( a * original->v[0].GetTexCoordS()
|
||||
+ b * original->v[1].GetTexCoordS() + c * original->v[2].GetTexCoordS() );
|
||||
tri->v[i].SetTexCoordT( a * original->v[0].GetTexCoordT()
|
||||
+ b * original->v[1].GetTexCoordT() + c * original->v[2].GetTexCoordT() );
|
||||
|
||||
// RB begin
|
||||
const idVec2 aST = original->v[0].GetTexCoord();
|
||||
const idVec2 bST = original->v[1].GetTexCoord();
|
||||
const idVec2 cST = original->v[2].GetTexCoord();
|
||||
|
||||
tri->v[i].SetTexCoord( a * aST.x + b * bST.x + c * cST.x,
|
||||
a * aST.y + b * bST.y + c * cST.y );
|
||||
|
||||
idVec3 normal = tri->v[i].GetNormal();
|
||||
idVec3 tempNormal;
|
||||
for( j = 0 ; j < 3 ; j++ )
|
||||
{
|
||||
normal[j] = a * original->v[0].GetNormal()[j]
|
||||
+ b * original->v[1].GetNormal()[j] + c * original->v[2].GetNormal()[j];
|
||||
tempNormal[j] = a * original->v[0].GetNormal()[j] + b * original->v[1].GetNormal()[j] + c * original->v[2].GetNormal()[j];
|
||||
}
|
||||
normal.Normalize();
|
||||
tri->v[i].SetNormal( normal );
|
||||
tempNormal.Normalize();
|
||||
tri->v[i].SetNormal( tempNormal );
|
||||
// RB end
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -127,14 +127,20 @@ static void TexVecForTri( textureVectors_t* texVec, mapTri_t* tri )
|
|||
d0[0] = b->xyz[0] - a->xyz[0];
|
||||
d0[1] = b->xyz[1] - a->xyz[1];
|
||||
d0[2] = b->xyz[2] - a->xyz[2];
|
||||
d0[3] = b->GetTexCoordS() - a->GetTexCoordS();
|
||||
d0[4] = b->GetTexCoordT() - a->GetTexCoordT();
|
||||
|
||||
// RB begin
|
||||
const idVec2 aST = a->GetTexCoord();
|
||||
const idVec2 bST = b->GetTexCoord();
|
||||
d0[3] = bST.x - aST.x;
|
||||
d0[4] = bST.y - aST.y;
|
||||
|
||||
d1[0] = c->xyz[0] - a->xyz[0];
|
||||
d1[1] = c->xyz[1] - a->xyz[1];
|
||||
d1[2] = c->xyz[2] - a->xyz[2];
|
||||
d1[3] = c->GetTexCoordS() - a->GetTexCoordS();
|
||||
d1[4] = c->GetTexCoordT() - a->GetTexCoordT();
|
||||
|
||||
const idVec2 cST = c->GetTexCoord();
|
||||
d1[3] = cST.x - aST.x;
|
||||
d1[4] = cST.y - aST.y;
|
||||
|
||||
area = d0[3] * d1[4] - d0[4] * d1[3];
|
||||
inva = 1.0 / area;
|
||||
|
@ -144,14 +150,15 @@ static void TexVecForTri( textureVectors_t* texVec, mapTri_t* tri )
|
|||
temp[2] = ( d0[2] * d1[4] - d0[4] * d1[2] ) * inva;
|
||||
temp.Normalize();
|
||||
texVec->v[0].ToVec3() = temp;
|
||||
texVec->v[0][3] = tri->v[0].xyz * texVec->v[0].ToVec3() - tri->v[0].GetTexCoordS();
|
||||
texVec->v[0][3] = tri->v[0].xyz * texVec->v[0].ToVec3() - tri->v[0].GetTexCoord().x;
|
||||
|
||||
temp[0] = ( d0[3] * d1[0] - d0[0] * d1[3] ) * inva;
|
||||
temp[1] = ( d0[3] * d1[1] - d0[1] * d1[3] ) * inva;
|
||||
temp[2] = ( d0[3] * d1[2] - d0[2] * d1[3] ) * inva;
|
||||
temp.Normalize();
|
||||
texVec->v[1].ToVec3() = temp;
|
||||
texVec->v[1][3] = tri->v[0].xyz * texVec->v[0].ToVec3() - tri->v[0].GetTexCoordT();
|
||||
texVec->v[1][3] = tri->v[0].xyz * texVec->v[0].ToVec3() - tri->v[0].GetTexCoord().y;
|
||||
// RB end
|
||||
}
|
||||
|
||||
|
||||
|
@ -825,9 +832,10 @@ static void ClipTriByLight( const mapLight_t* light, const mapTri_t* tri,
|
|||
oldInside = inside;
|
||||
if( oldInside )
|
||||
{
|
||||
// oldInside->Split( light->def.frustum[i], 0, &outside[i], &inside );
|
||||
// delete oldInside;
|
||||
assert( !oldInside );
|
||||
// RB begin
|
||||
oldInside->Split( light->frustumPlanes[i], 0, &outside[i], &inside );
|
||||
delete oldInside;
|
||||
// RB end
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1058,6 +1066,7 @@ void Prelight( uEntity_t* e )
|
|||
end = Sys_Milliseconds();
|
||||
common->Printf( "%5.1f seconds for CarveGroupsByLight\n", ( end - start ) / 1000.0 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue