random tweaks

This commit is contained in:
Garux 2021-03-04 16:11:00 +03:00
parent b68cbfd78b
commit 902fb46938
22 changed files with 87 additions and 153 deletions

View File

@ -23,6 +23,7 @@
#define INCLUDED_DRAGPLANES_H #define INCLUDED_DRAGPLANES_H
#include "selectable.h" #include "selectable.h"
#include "cullable.h"
#include "selectionlib.h" #include "selectionlib.h"
#include "math/aabb.h" #include "math/aabb.h"
#include "math/line.h" #include "math/line.h"
@ -46,41 +47,7 @@ inline Vector3 translation_from_local( const Vector3& translation, const Matrix4
) )
); );
} }
#if 0
namespace{
// https://www.gamedev.net/forums/topic/230443-initializing-array-member-objects-in-c/?page=2
class ObservedSelectables6x {
ObservedSelectable m_selectable0, m_selectable1, m_selectable2, m_selectable3, m_selectable4, m_selectable5;
// array of 6 pointers to ObservedSelectable members of ObservedSelectables6x
static ObservedSelectable ObservedSelectables6x::* const array[6];
public:
ObservedSelectables6x( const SelectionChangeCallback& onchanged ) :
m_selectable0( onchanged ),
m_selectable1( onchanged ),
m_selectable2( onchanged ),
m_selectable3( onchanged ),
m_selectable4( onchanged ),
m_selectable5( onchanged ) {
}
ObservedSelectable& operator[]( std::size_t idx ) {
return this->*array[idx];
}
const ObservedSelectable& operator[]( std::size_t idx ) const {
return this->*array[idx];
}
};
// Parse this
ObservedSelectable ObservedSelectables6x::* const ObservedSelectables6x::array[6] = { &ObservedSelectables6x::m_selectable0,
&ObservedSelectables6x::m_selectable1,
&ObservedSelectables6x::m_selectable2,
&ObservedSelectables6x::m_selectable3,
&ObservedSelectables6x::m_selectable4,
&ObservedSelectables6x::m_selectable5 };
} //namespace
#endif
class DragPlanes class DragPlanes
{ {
@ -387,10 +354,7 @@ Matrix4 evaluateTransform( const Vector3& translation ) const {
class ScaleRadius { class ScaleRadius {
ObservedSelectable m_selectable; ObservedSelectable m_selectable;
public: public:
static Matrix4& m_model() { static inline Matrix4 m_model;
static Matrix4 model;
return model;
}
ScaleRadius( const SelectionChangeCallback& onchanged ) : ScaleRadius( const SelectionChangeCallback& onchanged ) :
m_selectable( onchanged ) { m_selectable( onchanged ) {
@ -402,7 +366,7 @@ public:
m_selectable.setSelected( selected ); m_selectable.setSelected( selected );
} }
void selectPlanes( Selector& selector, SelectionTest& test, const PlaneCallback& selectedPlaneCallback ) { void selectPlanes( Selector& selector, SelectionTest& test, const PlaneCallback& selectedPlaneCallback ) {
m_model() = test.getVolume().GetModelview(); m_model = test.getVolume().GetModelview();
Selector_add( selector, m_selectable ); Selector_add( selector, m_selectable );
selectedPlaneCallback( Plane3( 2, 0, 0, 0 ) ); selectedPlaneCallback( Plane3( 2, 0, 0, 0 ) );
} }
@ -410,7 +374,7 @@ public:
const float len = vector3_length( translation ); const float len = vector3_length( translation );
if( len == 0 ) if( len == 0 )
return 0; return 0;
Vector3 tra = matrix4_transformed_direction( m_model(), translation ); Vector3 tra = matrix4_transformed_direction( m_model, translation );
vector3_normalise( tra ); vector3_normalise( tra );
return tra[0] * len; return tra[0] * len;
} }

View File

@ -1319,11 +1319,10 @@ public:
namespace {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// check FBO completeness // check FBO completeness
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
bool checkFramebufferStatus() { inline bool checkFramebufferStatus() {
// check FBO status // check FBO status
GLenum status = glCheckFramebufferStatus( GL_FRAMEBUFFER ); GLenum status = glCheckFramebufferStatus( GL_FRAMEBUFFER );
switch( status ) { switch( status ) {
@ -1365,7 +1364,6 @@ bool checkFramebufferStatus() {
} }
} }
} //namespace
class FBO class FBO
{ {

View File

@ -269,11 +269,8 @@ winding_t *BaseWindingForPlane( vec3_t normal, vec_t dist ){
================== ==================
*/ */
winding_t *CopyWinding( winding_t *w ){ winding_t *CopyWinding( winding_t *w ){
int size; winding_t *c = AllocWinding( w->numpoints );
winding_t *c; const size_t size = (size_t)( (winding_t *)0 )->p[w->numpoints];
c = AllocWinding( w->numpoints );
size = (int)( (winding_t *)0 )->p[w->numpoints];
memcpy( c, w, size ); memcpy( c, w, size );
return c; return c;
} }

View File

@ -318,12 +318,9 @@ node_t *AllocNode( void ){
================ ================
*/ */
bspbrush_t *AllocBrush( int numsides ){ bspbrush_t *AllocBrush( int numsides ){
bspbrush_t *bb; const size_t size = (size_t)&( ( (bspbrush_t *)0 )->sides[numsides] );
int c; bspbrush_t *bb = malloc( size );
memset( bb, 0, size );
c = (int)&( ( (bspbrush_t *)0 )->sides[numsides] );
bb = malloc( c );
memset( bb, 0, c );
if ( numthreads == 1 ) { if ( numthreads == 1 ) {
c_active_brushes++; c_active_brushes++;
} }
@ -373,16 +370,12 @@ void FreeBrushList( bspbrush_t *brushes ){
================== ==================
*/ */
bspbrush_t *CopyBrush( bspbrush_t *brush ){ bspbrush_t *CopyBrush( bspbrush_t *brush ){
bspbrush_t *newbrush; const size_t size = (size_t)&( ( (bspbrush_t *)0 )->sides[brush->numsides] );
int size;
int i;
size = (int)&( ( (bspbrush_t *)0 )->sides[brush->numsides] ); bspbrush_t *newbrush = AllocBrush( brush->numsides );
newbrush = AllocBrush( brush->numsides );
memcpy( newbrush, brush, size ); memcpy( newbrush, brush, size );
for ( i = 0 ; i < brush->numsides ; i++ ) for ( int i = 0 ; i < brush->numsides ; i++ )
{ {
if ( brush->sides[i].winding ) { if ( brush->sides[i].winding ) {
newbrush->sides[i].winding = CopyWinding( brush->sides[i].winding ); newbrush->sides[i].winding = CopyWinding( brush->sides[i].winding );

View File

@ -75,15 +75,12 @@ void PlaneFromWinding( winding_t *w, plane_t *plane ){
================== ==================
*/ */
winding_t *NewWinding( int points ){ winding_t *NewWinding( int points ){
winding_t *w;
int size;
if ( points > MAX_POINTS_ON_WINDING ) { if ( points > MAX_POINTS_ON_WINDING ) {
Error( "NewWinding: %i points", points ); Error( "NewWinding: %i points", points );
} }
size = (int)( (winding_t *)0 )->points[points]; const size_t size = (size_t)( (winding_t *)0 )->points[points];
w = malloc( size ); winding_t *w = malloc( size );
memset( w, 0, size ); memset( w, 0, size );
return w; return w;

View File

@ -87,7 +87,7 @@ void MakeTnode( int nodenum ){
void MakeTnodes( dmodel_t *bm ){ void MakeTnodes( dmodel_t *bm ){
// 32 byte align the structs // 32 byte align the structs
tnodes = malloc( ( numnodes + 1 ) * sizeof( tnode_t ) ); tnodes = malloc( ( numnodes + 1 ) * sizeof( tnode_t ) );
tnodes = (tnode_t *)( ( (int)tnodes + 31 ) & ~31 ); tnodes = (tnode_t *)( ( (size_t)tnodes + 31 ) & ~31 );
tnode_p = tnodes; tnode_p = tnodes;
MakeTnode( 0 ); MakeTnode( 0 );

View File

@ -650,7 +650,7 @@ void Cmd_Mip( void ){
// //
// dword align the size // dword align the size
// //
while ( (int)lump_p & 3 ) while ( (size_t)lump_p & 3 )
*lump_p++ = 0; *lump_p++ = 0;
// //

View File

@ -86,48 +86,48 @@ static struct
tokenType_t token; tokenType_t token;
} Keywords[] = } Keywords[] =
{ {
"model", TK_MODEL, { "model", TK_MODEL },
"mesh", TK_MESH, { "mesh", TK_MESH },
"vertices", TK_VERTICES, { "vertices", TK_VERTICES },
"edges", TK_EDGES, { "edges", TK_EDGES },
"position", TK_POSITION, { "position", TK_POSITION },
"polygons", TK_POLYGONS, { "polygons", TK_POLYGONS },
"nodes", TK_NODES, { "nodes", TK_NODES },
"rotation", TK_ROTATION, { "rotation", TK_ROTATION },
"scaling", TK_SCALING, { "scaling", TK_SCALING },
"translation", TK_TRANSLATION, { "translation", TK_TRANSLATION },
"vertex", TK_VERTEX, { "vertex", TK_VERTEX },
"HRCH", TK_HRCH, { "HRCH", TK_HRCH },
"Softimage", TK_SOFTIMAGE, { "Softimage", TK_SOFTIMAGE },
"material", TK_MATERIAL, { "material", TK_MATERIAL },
"spline", TK_SPLINE, { "spline", TK_SPLINE },
"Named", TK_C_NAMED, { "Named", TK_C_NAMED },
"object", TK_OBJECT, { "object", TK_OBJECT },
"Tri", TK_C_TRI, { "Tri", TK_C_TRI },
"Vertices", TK_C_VERTICES, { "Vertices", TK_C_VERTICES },
"Faces", TK_C_FACES, { "Faces", TK_C_FACES },
"Vertex", TK_C_VERTEX, { "Vertex", TK_C_VERTEX },
"list", TK_LIST, { "list", TK_LIST },
"Face", TK_C_FACE, { "Face", TK_C_FACE },
"Hexen", TK_C_HEXEN, { "Hexen", TK_C_HEXEN },
"Triangles", TK_C_TRIANGLES, { "Triangles", TK_C_TRIANGLES },
"Version", TK_C_VERSION, { "Version", TK_C_VERSION },
"faces", TK_FACES, { "faces", TK_FACES },
"face", TK_FACE, { "face", TK_FACE },
"origin", TK_ORIGIN, { "origin", TK_ORIGIN },
"DK_clusters", TK_CLUSTERS, { "DK_clusters", TK_CLUSTERS },
"DK_cluster_ncvs", TK_NUM_CLUSTER_VERTICES, { "DK_cluster_ncvs", TK_NUM_CLUSTER_VERTICES },
"name", TK_NAME, { "name", TK_NAME },
"DK_cluster_name", TK_CLUSTER_NAME, { "DK_cluster_name", TK_CLUSTER_NAME },
"DK_cluster_state", TK_CLUSTER_STATE, { "DK_cluster_state", TK_CLUSTER_STATE },
"actor_data", TK_ACTOR_DATA, { "actor_data", TK_ACTOR_DATA },
"uvTexture", TK_UVTEXTURE, { "uvTexture", TK_UVTEXTURE },
NULL, -1 { NULL, -1 }
}; };
static char *TokenNames[] = static char *TokenNames[] =

View File

@ -227,7 +227,7 @@ static void WriteModelFile( FILE *modelouthandle ){
byte buffer[MAX_FM_VERTS * 4 + 128]; byte buffer[MAX_FM_VERTS * 4 + 128];
float v; float v;
IntListNode_t *current, *toFree; IntListNode_t *current, *toFree;
qboolean framesWritten = false; int framesWritten = 0;
size_t temp,size = 0; size_t temp,size = 0;
// probably should do this dynamically one of these days // probably should do this dynamically one of these days
@ -465,7 +465,7 @@ static void WriteModelFile( FILE *modelouthandle ){
} }
if ( !num_groups ) { // joints are stored with regular verts for compressed models if ( !num_groups ) { // joints are stored with regular verts for compressed models
framesWritten = true; framesWritten = 1;
temp = sizeof( int ); // change this to a byte temp = sizeof( int ); // change this to a byte
memcpy( data + size, &framesWritten, temp ); memcpy( data + size, &framesWritten, temp );

View File

@ -1555,7 +1555,6 @@ void GrabJointedFrame( char *frame ){
void GrabGlobals( char *frame ){ void GrabGlobals( char *frame ){
char file1[1024]; char file1[1024];
char *framefile; char *framefile;
frame_t *fr;
framefile = FindFrameFile( frame ); framefile = FindFrameFile( frame );
@ -1566,7 +1565,7 @@ void GrabGlobals( char *frame ){
printf( "grabbing %s\n", file1 ); printf( "grabbing %s\n", file1 );
fr = &g_frames[model.num_frames - 1]; // last frame read in //frame_t *fr = &g_frames[model.num_frames - 1]; // last frame read in
LoadGlobals( file1 ); LoadGlobals( file1 );
} }

View File

@ -856,7 +856,6 @@ void GrabSkeletalFrame( char *frame ){
void GrabModelTransform( char *frame ){ void GrabModelTransform( char *frame ){
char file1[1024]; char file1[1024];
char *framefile; char *framefile;
fmframe_t *fr;
framefile = FindFrameFile( frame ); framefile = FindFrameFile( frame );
@ -867,7 +866,7 @@ void GrabModelTransform( char *frame ){
// printf ("grabbing %s\n", file1); // printf ("grabbing %s\n", file1);
fr = &g_frames[fmheader.num_frames - 1]; // last frame read in //fmframe_t *fr = &g_frames[fmheader.num_frames - 1]; // last frame read in
LoadModelTransform( file1 ); LoadModelTransform( file1 );
} }

View File

@ -63,6 +63,12 @@ struct MinMax___
return point.x() >= mins.x() && point.y() >= mins.y() && point.z() >= mins.z() return point.x() >= mins.x() && point.y() >= mins.y() && point.z() >= mins.z()
&& point.x() <= maxs.x() && point.y() <= maxs.y() && point.z() <= maxs.z(); && point.x() <= maxs.x() && point.y() <= maxs.y() && point.z() <= maxs.z();
} }
// true, if point is within the bounds expanded by epsilon
template<typename U, typename E>
bool test( const BasicVector3<U>& point, const E epsilon ) const {
return point.x() >= mins.x() - epsilon && point.y() >= mins.y() - epsilon && point.z() >= mins.z() - epsilon
&& point.x() <= maxs.x() + epsilon && point.y() <= maxs.y() + epsilon && point.z() <= maxs.z() + epsilon;
}
// true, if there is an intersection // true, if there is an intersection
template<typename U> template<typename U>
bool test( const MinMax___<U>& other ) const { bool test( const MinMax___<U>& other ) const {
@ -166,6 +172,7 @@ template<typename P, typename V>
bool PlaneFromPoints( Plane3___<P>& plane, const BasicVector3<V>& p0, const BasicVector3<V>& p1, const BasicVector3<V>& p2 ) { bool PlaneFromPoints( Plane3___<P>& plane, const BasicVector3<V>& p0, const BasicVector3<V>& p1, const BasicVector3<V>& p2 ) {
plane.normal() = vector3_cross( p2 - p0, p1 - p0 ); plane.normal() = vector3_cross( p2 - p0, p1 - p0 );
if ( VectorNormalize( plane.normal() ) == 0 ) { if ( VectorNormalize( plane.normal() ) == 0 ) {
plane.dist() = 0;
return false; return false;
} }

View File

@ -247,8 +247,7 @@ int pk3BSPMain( int argc, char **argv ){
/* extract map name */ /* extract map name */
const CopiedString nameOFmap( PathFilename( source ) ); const CopiedString nameOFmap( PathFilename( source ) );
bool drawsurfSHs[numBSPShaders]; bool drawsurfSHs[numBSPShaders] = { 0 };
memset( drawsurfSHs, 0, sizeof( drawsurfSHs ) );
for ( i = 0; i < numBSPDrawSurfaces; ++i ){ for ( i = 0; i < numBSPDrawSurfaces; ++i ){
drawsurfSHs[ bspDrawSurfaces[i].shaderNum ] = true; drawsurfSHs[ bspDrawSurfaces[i].shaderNum ] = true;
@ -920,8 +919,7 @@ int repackBSPMain( int argc, char **argv ){
/* extract map name */ /* extract map name */
const CopiedString nameOFmap( PathFilename( source ) ); const CopiedString nameOFmap( PathFilename( source ) );
bool drawsurfSHs[numBSPShaders]; bool drawsurfSHs[numBSPShaders] = { 0 };
memset( drawsurfSHs, 0, sizeof( drawsurfSHs ) );
for ( i = 0; i < numBSPDrawSurfaces; ++i ){ for ( i = 0; i < numBSPDrawSurfaces; ++i ){
drawsurfSHs[ bspDrawSurfaces[i].shaderNum ] = true; drawsurfSHs[ bspDrawSurfaces[i].shaderNum ] = true;

View File

@ -210,8 +210,8 @@ int AnalyzeBSP( int argc, char **argv ){
lump = (byte*) header + offset; lump = (byte*) header + offset;
lumpInt = LittleLong( (int) *( (int*) lump ) ); lumpInt = LittleLong( (int) *( (int*) lump ) );
lumpFloat = LittleFloat( (float) *( (float*) lump ) ); lumpFloat = LittleFloat( (float) *( (float*) lump ) );
memcpy( lumpString, (char*) lump, ( (size_t)length < sizeof( lumpString ) ? (size_t)length : sizeof( lumpString ) - 1 ) ); memcpy( lumpString, (char*) lump, std::min( (size_t)length, std::size( lumpString ) - 1 ) );
lumpString[ sizeof( lumpString ) - 1 ] = '\0'; lumpString[ std::size( lumpString ) - 1 ] = '\0';
/* print basic lump info */ /* print basic lump info */
Sys_Printf( "Lump: %d\n", i ); Sys_Printf( "Lump: %d\n", i );

View File

@ -736,7 +736,7 @@ static void ProjectDecalOntoTriangles( decalProjector_t *dp, mapDrawSurface_t *d
*/ */
void MakeEntityDecals( entity_t *e ){ void MakeEntityDecals( entity_t *e ){
int i, j, k, f, fOld, start; int i, j, f, fOld, start;
decalProjector_t dp; decalProjector_t dp;
mapDrawSurface_t *ds; mapDrawSurface_t *ds;
Vector3 identityAxis[ 3 ] = { g_vector3_axis_x, g_vector3_axis_y, g_vector3_axis_z }; Vector3 identityAxis[ 3 ] = { g_vector3_axis_x, g_vector3_axis_y, g_vector3_axis_z };
@ -780,12 +780,7 @@ void MakeEntityDecals( entity_t *e ){
} }
/* bounds check */ /* bounds check */
for ( k = 0; k < 3; k++ ) if ( !ds->minmax.test( dp.center, dp.radius ) ) {
if ( ds->minmax.mins[ k ] >= ( dp.center[ k ] + dp.radius ) ||
ds->minmax.maxs[ k ] <= ( dp.center[ k ] - dp.radius ) ) {
break;
}
if ( k < 3 ) {
continue; continue;
} }

View File

@ -632,8 +632,8 @@ int FogForBounds( const MinMax& minmax, float epsilon ){
brush_t *brush = mapFogs[ i ].brush; brush_t *brush = mapFogs[ i ].brush;
/* get bounds */ /* get bounds */
const MinMax fogMinmax( brush->minmax.mins - Vector3( epsilon, epsilon, epsilon ), const MinMax fogMinmax( brush->minmax.mins - Vector3().set( epsilon ),
brush->minmax.maxs + Vector3( epsilon, epsilon, epsilon ) ); brush->minmax.maxs + Vector3().set( epsilon ) );
/* check against bounds */ /* check against bounds */
if( !minmax.test( fogMinmax ) ){ if( !minmax.test( fogMinmax ) ){
continue; /* no overlap */ continue; /* no overlap */

View File

@ -1239,11 +1239,7 @@ void MapRawLightmap( int rawLightmapNum ){
{ {
info = &surfaceInfos[ lightSurfaces[ lm->firstLightSurface + n ] ]; info = &surfaceInfos[ lightSurfaces[ lm->firstLightSurface + n ] ];
minmax.extend( info->minmax ); minmax.extend( info->minmax );
MinMax minmax2 = info->minmax; if( info->minmax.test( origin, info->sampleSize + 2 ) ){
const float TOL = info->sampleSize + 2;
minmax2.mins -= Vector3( TOL, TOL, TOL );
minmax2.maxs += Vector3( TOL, TOL, TOL );
if( minmax2.test( origin ) ){
break; break;
} }
} }

View File

@ -1279,7 +1279,7 @@ void StitchSurfaceLightmaps( void ){
sampleSize = 0.5f * std::min( a->actualSampleSize, b->actualSampleSize ); sampleSize = 0.5f * std::min( a->actualSampleSize, b->actualSampleSize );
/* test bounding box */ /* test bounding box */
if ( !MinMax( b->minmax.mins - Vector3().set( sampleSize ), b->minmax.maxs + Vector3().set( sampleSize ) ).test( origin ) ) { if ( !b->minmax.test( origin, sampleSize ) ) {
continue; continue;
} }
@ -2386,7 +2386,6 @@ void StoreSurfaceLightmaps( bool fastAllocate ){
int style, lightmapNum, lightmapNum2; int style, lightmapNum, lightmapNum2;
float samples, occludedSamples; float samples, occludedSamples;
Vector3 sample, occludedSample, dirSample; Vector3 sample, occludedSample, dirSample;
MinMax colorMinmax;
byte *lb; byte *lb;
int numUsed, numTwins, numTwinLuxels, numStored; int numUsed, numTwins, numTwinLuxels, numStored;
float lmx, lmy, efficiency; float lmx, lmy, efficiency;
@ -2576,7 +2575,7 @@ void StoreSurfaceLightmaps( bool fastAllocate ){
/* setup */ /* setup */
lm->used = 0; lm->used = 0;
colorMinmax.clear(); MinMax colorMinmax;
/* clean up and store into bsp luxels */ /* clean up and store into bsp luxels */
for ( y = 0; y < lm->h; y++ ) for ( y = 0; y < lm->h; y++ )

View File

@ -385,7 +385,6 @@ void PatchMapDrawSurfs( entity_t *e ){
mapDrawSurface_t *ds; mapDrawSurface_t *ds;
int patchCount, groupCount; int patchCount, groupCount;
bspDrawVert_t *v1, *v2; bspDrawVert_t *v1, *v2;
MinMax bounds;
byte *bordering; byte *bordering;
parseMesh_t *meshes[ MAX_MAP_DRAW_SURFS ]; parseMesh_t *meshes[ MAX_MAP_DRAW_SURFS ];
@ -461,8 +460,7 @@ void PatchMapDrawSurfs( entity_t *e ){
GrowGroup_r( scan, i, patchCount, meshes, bordering, group ); GrowGroup_r( scan, i, patchCount, meshes, bordering, group );
/* bound them */ /* bound them */
MinMax bounds;
bounds.clear();
for ( j = 0; j < patchCount; j++ ) for ( j = 0; j < patchCount; j++ )
{ {
if ( group[ j ] ) { if ( group[ j ] ) {

View File

@ -175,7 +175,6 @@ void PrintPortal( portal_t *p ){
*/ */
#define SIDESPACE 8 #define SIDESPACE 8
void MakeHeadnodePortals( tree_t *tree ){ void MakeHeadnodePortals( tree_t *tree ){
Vector3 bounds[2];
int i, j, n; int i, j, n;
portal_t *p, *portals[6]; portal_t *p, *portals[6];
plane_t bplanes[6]; plane_t bplanes[6];
@ -184,13 +183,10 @@ void MakeHeadnodePortals( tree_t *tree ){
node = tree->headnode; node = tree->headnode;
// pad with some space so there will never be null volume leafs // pad with some space so there will never be null volume leafs
for ( i = 0 ; i < 3 ; i++ ) const MinMax bounds( tree->minmax.mins - Vector3().set( SIDESPACE ),
{ tree->minmax.maxs + Vector3().set( SIDESPACE ) );
bounds[0][i] = tree->minmax.mins[i] - SIDESPACE; if ( !bounds.valid() ) {
bounds[1][i] = tree->minmax.maxs[i] + SIDESPACE; Error( "Backwards tree volume" );
if ( bounds[0][i] >= bounds[1][i] ) {
Error( "Backwards tree volume" );
}
} }
tree->outside_node.planenum = PLANENUM_LEAF; tree->outside_node.planenum = PLANENUM_LEAF;
@ -210,12 +206,12 @@ void MakeHeadnodePortals( tree_t *tree ){
memset( pl, 0, sizeof( *pl ) ); memset( pl, 0, sizeof( *pl ) );
if ( j ) { if ( j ) {
pl->normal()[i] = -1; pl->normal()[i] = -1;
pl->dist() = -bounds[j][i]; pl->dist() = -bounds.maxs[i];
} }
else else
{ {
pl->normal()[i] = 1; pl->normal()[i] = 1;
pl->dist() = bounds[j][i]; pl->dist() = bounds.mins[i];
} }
p->plane = *pl; p->plane = *pl;
p->winding = BaseWindingForPlane( pl->plane ); p->winding = BaseWindingForPlane( pl->plane );

View File

@ -1330,7 +1330,7 @@ void SubdivideFaceSurfaces( entity_t *e, tree_t *tree ){
range = std::max( ds->texRange[ 0 ], ds->texRange[ 1 ] ); range = std::max( ds->texRange[ 0 ], ds->texRange[ 1 ] );
size = ds->minmax.maxs[ 0 ] - ds->minmax.mins[ 0 ]; size = ds->minmax.maxs[ 0 ] - ds->minmax.mins[ 0 ];
for ( j = 1; j < 3; j++ ) for ( j = 1; j < 3; j++ )
size = std::max( size, ds->minmax.maxs[ j ] - ds->minmax.mins[ j ] ); value_maximize( size, ds->minmax.maxs[ j ] - ds->minmax.mins[ j ] );
subdivisions = ( size / range ) * texRange; subdivisions = ( size / range ) * texRange;
subdivisions = ceil( subdivisions / 2 ) * 2; subdivisions = ceil( subdivisions / 2 ) * 2;
for ( j = 1; j < 8; j++ ) for ( j = 1; j < 8; j++ )

View File

@ -1374,11 +1374,9 @@ static int AddMetaTriangleToSurface( mapDrawSurface_t *ds, metaTriangle_t *tri,
if ( metaMaxBBoxDistance >= 0 && ds->numIndexes > 0 ) { if ( metaMaxBBoxDistance >= 0 && ds->numIndexes > 0 ) {
const MinMax minmax( ds->minmax.mins - Vector3().set( metaMaxBBoxDistance ), if( !ds->minmax.test( metaVerts[ tri->indexes[ 0 ] ].xyz, metaMaxBBoxDistance )
ds->minmax.maxs + Vector3().set( metaMaxBBoxDistance ) ); && !ds->minmax.test( metaVerts[ tri->indexes[ 1 ] ].xyz, metaMaxBBoxDistance )
if( !minmax.test( metaVerts[ tri->indexes[ 0 ] ].xyz ) && !ds->minmax.test( metaVerts[ tri->indexes[ 2 ] ].xyz, metaMaxBBoxDistance ) )
&& !minmax.test( metaVerts[ tri->indexes[ 1 ] ].xyz )
&& !minmax.test( metaVerts[ tri->indexes[ 2 ] ].xyz ) )
return 0; return 0;
} }