Add modified source code in idlib

This commit is contained in:
LegendGuard 2023-07-26 18:49:00 +02:00 committed by GitHub
parent b1176b99fb
commit f9ca75f475
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 131 additions and 0 deletions

View file

@ -32,6 +32,26 @@ If you have questions concerning this license or the applicable additional terms
idBounds bounds_zero( vec3_zero, vec3_zero );
/*
============
Zeroth
idBounds::GetMaxs
============
*/
idVec3 idBounds::GetMaxs( void ) const {
return idVec3( b[1] );
}
/*
============
Zeroth
idBounds::GetMins
============
*/
idVec3 idBounds::GetMins( void ) const {
return idVec3( b[0] );
}
/*
============
idBounds::GetRadius

View file

@ -68,6 +68,12 @@ public:
idVec3 GetCenter( void ) const; // returns center of bounds
float GetRadius( void ) const; // returns the radius relative to the bounds origin
// HEXEN : Zeroth
public:
idVec3 GetMaxs( void ) const;
idVec3 GetMins( void ) const;
float GetRadius( const idVec3 &center ) const; // returns the radius relative to the given center
float GetVolume( void ) const; // returns the volume of the bounds
bool IsCleared( void ) const; // returns true if bounds are inside out

View file

@ -117,6 +117,10 @@ public:
type * Ptr( void ); // returns a pointer to the list
const type * Ptr( void ) const; // returns a pointer to the list
type & Alloc( void ); // returns reference to a new data element at the end of the list
// HEXEN : Zeroth
int New( void ); // append element
int Append( const type & obj ); // append element
int Append( const idList<type> &other ); // append list
int AddUnique( const type & obj ); // add unique element
@ -128,6 +132,7 @@ public:
bool RemoveIndex( int index ); // remove the element at the given index
bool Remove( const type & obj ); // remove the element
void Sort( cmp_t *compare = ( cmp_t * )&idListSortCompare<type> );
void Shuffle( void );
void SortSubSection( int startIndex, int endIndex, cmp_t *compare = ( cmp_t * )&idListSortCompare<type> );
void Swap( idList<type> &other ); // swap the contents of the lists
void DeleteContents( bool clear ); // delete the contents of the list
@ -676,6 +681,37 @@ ID_INLINE int idList<type>::Append( type const & obj ) {
return num - 1;
}
/*
================
Zeroth
idList<type>::New
Increases the size of the list by one element.
if it is a pointer, user is responsible for NULL'ing it.
Returns the index of the new element.
================
*/
template< class type >
ID_INLINE int idList<type>::New( void ) {
if ( !list ) {
Resize( granularity );
}
if ( num == size ) {
int newsize;
if ( granularity == 0 ) { // this is a hack to fix our memset classes
granularity = 16;
}
newsize = size + granularity;
Resize( newsize - newsize % granularity );
}
list[ num ] = *(new type);
num++;
return num - 1;
}
/*
================
@ -917,6 +953,29 @@ ID_INLINE void idList<type>::Sort( cmp_t *compare ) {
qsort( ( void * )list, ( size_t )num, sizeof( type ), vCompare );
}
/*
================
HEXEN
idList<type>::Shuffle
================
*/
template< class type >
ID_INLINE void idList<type>::Shuffle( void ) {
if ( !list ) {
return;
}
int i, rnd;
type tmp;
for ( i = 0; i < num; i++ ) {
rnd = rand() % num;
tmp = list[rnd];
list[rnd] = list[i];
list[i] = tmp;
}
}
/*
================
idList<type>::SortSubSection

View file

@ -201,6 +201,12 @@ public:
static int FloatHash( const float *array, const int numFloats );
/*
// HEXEN : Zeroth
static idVec3 Vec45CtrClock( idVec3 vec );
static idVec3 Vec45Cloc( idVec3 vec );
*/
static const float PI; // pi
static const float TWO_PI; // pi * 2
static const float HALF_PI; // pi / 2
@ -929,4 +935,28 @@ ID_INLINE int idMath::FloatHash( const float *array, const int numFloats ) {
return hash;
}
#if 0
// HEXEN : Zeroth
ID_INLINE idVec3 idMath::Vec45CtrClock( idVec3 vec ) {
idVec3 perpVec;
// perpendicular vector to forward, counterclockwise
perpVec.x = -vec.y;
perpVec.y = vec.x;
perpVec.z = 0;
return perpVec;
}
#endif
#if 0
// HEXEN : Zeroth
ID_INLINE idVec3 idMath::Vec45Clock( idVec3 vec ) {
idVec3 perpVec;
// perpendicular vector to forward, clockwise
perpVec_x = vec.y;
perpVec_y = -vec.x;
perpVec_z = 0;
return perpVec;
}
#endif
#endif /* !__MATH_MATH_H__ */

View file

@ -294,6 +294,18 @@ void idVec3::ProjectSelfOntoSphere( const float radius ) {
}
}
/*
=============
Zeroth
toAngle
=============
*/
float idVec3::toAngle( idVec3 B) {
// return the angle in degrees between two idVec3s
idVec3 Bn = B; Bn.Normalize();
idVec3 An = *this; An.Normalize();
return RAD2DEG( idMath::ACos( An * Bn ) );
}
//===============================================================

View file

@ -389,6 +389,10 @@ public:
void Lerp( const idVec3 &v1, const idVec3 &v2, const float l );
void SLerp( const idVec3 &v1, const idVec3 &v2, const float l );
// HEXEN : Zeroth
public:
float toAngle( idVec3 B ); // return the angle in degrees between two idVec3s
};
extern idVec3 vec3_origin;