mirror of
https://github.com/Garux/netradiant-custom.git
synced 2026-09-28 00:00:03 +02:00
use std::fabs to avoid conversion to double
This commit is contained in:
@@ -147,7 +147,7 @@ int DBrush::PointPosition( vec3_t pnt ){
|
||||
if ( dist > MAX_ROUND_ERROR ) {
|
||||
return POINT_OUT_BRUSH; // if point is in front of plane, it CANT be in the brush
|
||||
}
|
||||
else if ( fabs( dist ) < MAX_ROUND_ERROR ) {
|
||||
else if ( std::fabs( dist ) < MAX_ROUND_ERROR ) {
|
||||
state = POINT_ON_BRUSH; // if point is ON plane point is either ON the brush
|
||||
}
|
||||
// or outside it, it can no longer be in it
|
||||
@@ -628,7 +628,7 @@ DPlane* DBrush::HasPlaneInverted( DPlane *chkPlane ){
|
||||
for ( DPlane *plane : faceList )
|
||||
{
|
||||
if ( *plane != *chkPlane ) {
|
||||
if ( fabs( plane->_d + chkPlane->_d ) < 0.1 ) {
|
||||
if ( std::fabs( plane->_d + chkPlane->_d ) < 0.1f ) {
|
||||
return plane;
|
||||
}
|
||||
}
|
||||
@@ -839,7 +839,7 @@ int DBrush::FindPointsForPlane( DPlane* plane, DPoint** pnts, int maxpnts ) {
|
||||
|
||||
for ( DPoint *point : pointList )
|
||||
{
|
||||
if ( fabs( plane->DistanceToPoint( point->_pnt ) ) < MAX_ROUND_ERROR ) {
|
||||
if ( std::fabs( plane->DistanceToPoint( point->_pnt ) ) < MAX_ROUND_ERROR ) {
|
||||
pnts[numpnts] = point;
|
||||
numpnts++;
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ bool DPlane::IsRedundant( std::list<DPoint*>& pointList ){
|
||||
|
||||
for ( const auto *point : pointList )
|
||||
{
|
||||
if ( fabs( DistanceToPoint( point->_pnt ) ) < MAX_ROUND_ERROR ) {
|
||||
if ( std::fabs( DistanceToPoint( point->_pnt ) ) < MAX_ROUND_ERROR ) {
|
||||
cnt++;
|
||||
}
|
||||
|
||||
@@ -117,11 +117,11 @@ bool DPlane::IsRedundant( std::list<DPoint*>& pointList ){
|
||||
bool DPlane::operator ==( const DPlane& other ) const {
|
||||
vec3_t chk;
|
||||
VectorSubtract( other.normal, normal, chk );
|
||||
if ( fabs( VectorLength( chk ) ) > MAX_ROUND_ERROR ) {
|
||||
if ( std::fabs( VectorLength( chk ) ) > MAX_ROUND_ERROR ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( fabs( other._d - _d ) > MAX_ROUND_ERROR ) {
|
||||
if ( std::fabs( other._d - _d ) > MAX_ROUND_ERROR ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ bool DPlane::operator ==( const DPlane& other ) const {
|
||||
bool DPlane::operator !=( DPlane& other ){
|
||||
vec3_t chk;
|
||||
VectorAdd( other.normal, normal, chk );
|
||||
if ( fabs( VectorLength( chk ) ) > MAX_ROUND_ERROR ) {
|
||||
if ( std::fabs( VectorLength( chk ) ) > MAX_ROUND_ERROR ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ DWinding DPlane::BaseWindingForPlane() const {
|
||||
x = -1;
|
||||
for ( i = 0; i < 3; ++i )
|
||||
{
|
||||
v = fabs( normal[i] );
|
||||
v = std::fabs( normal[i] );
|
||||
if ( v > max ) {
|
||||
x = i;
|
||||
max = v;
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
bool DPoint::operator ==( vec3_t other ){
|
||||
vec3_t test;
|
||||
VectorSubtract( other, _pnt, test );
|
||||
if ( fabs( VectorLength( test ) ) > MAX_ROUND_ERROR ) {
|
||||
if ( std::fabs( VectorLength( test ) ) > MAX_ROUND_ERROR ) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -46,11 +46,11 @@ void ClampFloat( float* p ){
|
||||
return;
|
||||
}
|
||||
|
||||
if ( fabs( *p - ceil( *p ) ) < MAX_ROUND_ERROR ) {
|
||||
if ( std::fabs( *p - ceil( *p ) ) < MAX_ROUND_ERROR ) {
|
||||
*p = static_cast<float>( ceil( *p ) );
|
||||
}
|
||||
|
||||
if ( fabs( *p - floor( *p ) ) < MAX_ROUND_ERROR ) {
|
||||
if ( std::fabs( *p - floor( *p ) ) < MAX_ROUND_ERROR ) {
|
||||
*p = static_cast<float>( floor( *p ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -781,7 +781,7 @@ void BuildApertureDoors( scene::Instance& brushinstance, const class ApertureDoo
|
||||
|
||||
AddFaceWithTexture( b, r1.data(), r2.data(), r2_.data(), rs.innerTextureTrim.get(), false );
|
||||
|
||||
if( double dot = fabs( vector3_dot( vector3_normalised( rot2 - cent ), vector3_normalised( r2 - cent ) ) ); dot < mindot ){
|
||||
if( double dot = std::fabs( vector3_dot( vector3_normalised( rot2 - cent ), vector3_normalised( r2 - cent ) ) ); dot < mindot ){
|
||||
mindot = dot;
|
||||
r = r2;
|
||||
}
|
||||
@@ -901,7 +901,7 @@ void BuildApertureDoors( scene::Instance& brushinstance, const class ApertureDoo
|
||||
// const double speed = rs.speed / sin( ( c_pi - acos( vector3_dot( vector3_normalised( rot2 - cent ), vector3_normalised( rot1 - cent ) ) ) ) / 2 );
|
||||
Node_getEntity( door )->setKeyValue( "speed", float2string( speed ) );
|
||||
|
||||
const DoubleVector3 abs_dir( fabs( dir[0] ), fabs( dir[1] ), fabs( dir[2] ) );
|
||||
const DoubleVector3 abs_dir( std::fabs( dir[0] ), std::fabs( dir[1] ), std::fabs( dir[2] ) );
|
||||
const auto fullDistance = vector3_dot( abs_dir, DoubleVector3( 2 ) + bounds.extents * 2 ); //there is +2 to bounds in engine somewhere 🧩
|
||||
// distance = DotProduct( abs_movedir, size ) - lip; // game code
|
||||
// VectorMA( ent->pos1, distance, ent->movedir, ent->pos2 );
|
||||
|
||||
@@ -45,10 +45,10 @@ public:
|
||||
return other.m_indirect; //m_distance < other.m_distance;
|
||||
}
|
||||
else if( m_indirect && other.m_indirect ){
|
||||
if( fabs( m_distance - other.m_distance ) > 1e-3f /*0.00002f*/ ){
|
||||
if( std::fabs( m_distance - other.m_distance ) > 1e-3f /*0.00002f*/ ){
|
||||
return m_distance < other.m_distance;
|
||||
}
|
||||
else if( fabs( m_depth - other.m_depth ) > 1e-6f ){
|
||||
else if( std::fabs( m_depth - other.m_depth ) > 1e-6f ){
|
||||
return m_depth < other.m_depth;
|
||||
}
|
||||
else{
|
||||
|
||||
+6
-5
@@ -99,14 +99,14 @@ public:
|
||||
&& vector3_dot( planes[i].normal(), closest_point - corners[indices[index + 1]] ) > 0
|
||||
&& vector3_dot( planes[i].normal(), closest_point - corners[indices[index + 2]] ) > 0
|
||||
&& vector3_dot( planes[i].normal(), closest_point - corners[indices[index + 3]] ) > 0 ) {
|
||||
const double dot = fabs( vector3_dot( planes[i].normal(), viewdir ) );
|
||||
const double dot = std::fabs( vector3_dot( planes[i].normal(), viewdir ) );
|
||||
const double diff = bestDot - dot;
|
||||
if( diff > 0.03 ){
|
||||
bestDot = dot;
|
||||
iselect[0] = i;
|
||||
iselect[1] = -1;
|
||||
}
|
||||
else if( fabs( diff ) <= 0.03 && !test.getVolume().fill() ){ // select only plane in camera
|
||||
else if( std::fabs( diff ) <= 0.03 && !test.getVolume().fill() ){ // select only plane in camera
|
||||
iselect[1] = i;
|
||||
}
|
||||
}
|
||||
@@ -223,7 +223,7 @@ public:
|
||||
if( aabb.extents[i / 8] != 0.f && matrix4_clip_line_by_nearplane( test.getVolume().GetViewMatrix(), line ) == 2 ){
|
||||
const Vector3 point_new = line_closest_point( line, g_vector3_identity );
|
||||
const float dist_new = vector3_length_squared( point_new );
|
||||
const float dot_new = fabs( vector3_dot( vector3_normalised( point_new ), vector3_normalised( line.end - line.start ) ) );
|
||||
const float dot_new = std::fabs( vector3_dot( vector3_normalised( point_new ), vector3_normalised( line.end - line.start ) ) );
|
||||
//effective epsilon is rather big: optimized 32 bit build is using doubles implicitly (floats might be straightly checked for equality); same code in brush.h is cool with way smaller epsilon
|
||||
if( planeData.m_dist - dist_new > 1e-2f // new dist noticeably smaller
|
||||
|| ( float_equal_epsilon( dist_new, planeData.m_dist, 1e-2f ) && dot_new < dot ) ){ // or ambiguous case. Resolve it by dot comparison
|
||||
@@ -251,8 +251,9 @@ public:
|
||||
assign_plane( plane2 );
|
||||
}
|
||||
}
|
||||
else if( some_extent_zero || fabs( vector3_length_squared( line.end - line.start ) ) > 1e-3 ){
|
||||
if( fabs( vector3_dot( plane1.normal(), test.getVolume().getViewDir() ) ) < fabs( vector3_dot( plane2.normal(), test.getVolume().getViewDir() ) ) ){
|
||||
else if( some_extent_zero || std::fabs( vector3_length_squared( line.end - line.start ) ) > 1e-3 ){
|
||||
if( std::fabs( vector3_dot( plane1.normal(), test.getVolume().getViewDir() ) )
|
||||
< std::fabs( vector3_dot( plane2.normal(), test.getVolume().getViewDir() ) ) ){
|
||||
if( aabb.extents[adjacent_planes[i] / 2] == 0 ) /* select the other, if zero bound */
|
||||
assign_plane( plane2 );
|
||||
else
|
||||
|
||||
+23
-23
@@ -71,18 +71,18 @@ class AABBExtend
|
||||
{
|
||||
public:
|
||||
static void apply( AABB& aabb, const Vector3& point ){
|
||||
float displacement = point[Index] - aabb.origin[Index];
|
||||
float half_difference = static_cast<float>( 0.5 * ( fabs( displacement ) - aabb.extents[Index] ) );
|
||||
const float displacement = point[Index] - aabb.origin[Index];
|
||||
const float half_difference = 0.5f * ( std::fabs( displacement ) - aabb.extents[Index] );
|
||||
if ( half_difference > 0.0f ) {
|
||||
aabb.origin[Index] += ( displacement >= 0.0f ) ? half_difference : -half_difference;
|
||||
aabb.extents[Index] += half_difference;
|
||||
}
|
||||
}
|
||||
static void apply( AABB& aabb, const AABB& other ){
|
||||
float displacement = other.origin[Index] - aabb.origin[Index];
|
||||
float difference = other.extents[Index] - aabb.extents[Index];
|
||||
if ( fabs( displacement ) > fabs( difference ) ) {
|
||||
float half_difference = static_cast<float>( 0.5 * ( fabs( displacement ) + difference ) );
|
||||
const float displacement = other.origin[Index] - aabb.origin[Index];
|
||||
const float difference = other.extents[Index] - aabb.extents[Index];
|
||||
if ( std::fabs( displacement ) > std::fabs( difference ) ) {
|
||||
float half_difference = 0.5f * ( std::fabs( displacement ) + difference );
|
||||
if ( half_difference > 0.0f ) {
|
||||
aabb.origin[Index] += ( displacement >= 0.0f ) ? half_difference : -half_difference;
|
||||
aabb.extents[Index] += half_difference;
|
||||
@@ -136,7 +136,7 @@ inline void aabb_extend_by_vec3( AABB& aabb, const Vector3& extension ){
|
||||
|
||||
template<size_t Index>
|
||||
inline bool aabb_intersects_point_dimension( const AABB& aabb, const Vector3& point ){
|
||||
return fabs( point[Index] - aabb.origin[Index] ) < aabb.extents[Index];
|
||||
return std::fabs( point[Index] - aabb.origin[Index] ) < aabb.extents[Index];
|
||||
}
|
||||
|
||||
inline bool aabb_intersects_point( const AABB& aabb, const Vector3& point ){
|
||||
@@ -147,7 +147,7 @@ inline bool aabb_intersects_point( const AABB& aabb, const Vector3& point ){
|
||||
|
||||
template<size_t Index>
|
||||
inline bool aabb_intersects_aabb_dimension( const AABB& aabb, const AABB& other ){
|
||||
return fabs( other.origin[Index] - aabb.origin[Index] ) < ( aabb.extents[Index] + other.extents[Index] );
|
||||
return std::fabs( other.origin[Index] - aabb.origin[Index] ) < ( aabb.extents[Index] + other.extents[Index] );
|
||||
}
|
||||
|
||||
inline bool aabb_intersects_aabb( const AABB& aabb, const AABB& other ){
|
||||
@@ -159,9 +159,9 @@ inline bool aabb_intersects_aabb( const AABB& aabb, const AABB& other ){
|
||||
inline unsigned int aabb_classify_plane( const AABB& aabb, const Plane3& plane ){
|
||||
double distance_origin = vector3_dot( plane.normal(), aabb.origin ) + plane.dist();
|
||||
|
||||
if ( fabs( distance_origin ) < ( fabs( plane.a * aabb.extents[0] )
|
||||
+ fabs( plane.b * aabb.extents[1] )
|
||||
+ fabs( plane.c * aabb.extents[2] ) ) ) {
|
||||
if ( std::fabs( distance_origin ) < ( std::fabs( plane.a * aabb.extents[0] )
|
||||
+ std::fabs( plane.b * aabb.extents[1] )
|
||||
+ std::fabs( plane.c * aabb.extents[2] ) ) ) {
|
||||
return 1; // partially inside
|
||||
}
|
||||
else if ( distance_origin < 0 ) {
|
||||
@@ -173,9 +173,9 @@ inline unsigned int aabb_classify_plane( const AABB& aabb, const Plane3& plane )
|
||||
inline unsigned int aabb_oriented_classify_plane( const AABB& aabb, const Matrix4& transform, const Plane3& plane ){
|
||||
double distance_origin = vector3_dot( plane.normal(), aabb.origin ) + plane.dist();
|
||||
|
||||
if ( fabs( distance_origin ) < ( fabs( aabb.extents[0] * vector3_dot( plane.normal(), transform.x().vec3() ) )
|
||||
+ fabs( aabb.extents[1] * vector3_dot( plane.normal(), transform.y().vec3() ) )
|
||||
+ fabs( aabb.extents[2] * vector3_dot( plane.normal(), transform.z().vec3() ) ) ) ) {
|
||||
if ( std::fabs( distance_origin ) < ( std::fabs( aabb.extents[0] * vector3_dot( plane.normal(), transform.x().vec3() ) )
|
||||
+ std::fabs( aabb.extents[1] * vector3_dot( plane.normal(), transform.y().vec3() ) )
|
||||
+ std::fabs( aabb.extents[2] * vector3_dot( plane.normal(), transform.z().vec3() ) ) ) ) {
|
||||
return 1; // partially inside
|
||||
}
|
||||
else if ( distance_origin < 0 ) {
|
||||
@@ -259,15 +259,15 @@ inline AABB aabb_for_oriented_aabb( const AABB& aabb, const Matrix4& transform )
|
||||
return AABB(
|
||||
matrix4_transformed_point( transform, aabb.origin ),
|
||||
Vector3(
|
||||
static_cast<float>( fabs( transform[0] * aabb.extents[0] )
|
||||
+ fabs( transform[4] * aabb.extents[1] )
|
||||
+ fabs( transform[8] * aabb.extents[2] ) ),
|
||||
static_cast<float>( fabs( transform[1] * aabb.extents[0] )
|
||||
+ fabs( transform[5] * aabb.extents[1] )
|
||||
+ fabs( transform[9] * aabb.extents[2] ) ),
|
||||
static_cast<float>( fabs( transform[2] * aabb.extents[0] )
|
||||
+ fabs( transform[6] * aabb.extents[1] )
|
||||
+ fabs( transform[10] * aabb.extents[2] ) )
|
||||
std::fabs( transform[0] * aabb.extents[0] )
|
||||
+ std::fabs( transform[4] * aabb.extents[1] )
|
||||
+ std::fabs( transform[8] * aabb.extents[2] ),
|
||||
std::fabs( transform[1] * aabb.extents[0] )
|
||||
+ std::fabs( transform[5] * aabb.extents[1] )
|
||||
+ std::fabs( transform[9] * aabb.extents[2] ),
|
||||
std::fabs( transform[2] * aabb.extents[0] )
|
||||
+ std::fabs( transform[6] * aabb.extents[1] )
|
||||
+ std::fabs( transform[10] * aabb.extents[2] )
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
+6
-6
@@ -449,9 +449,9 @@ inline Frustum frustum_inverse_transformed( const Frustum& frustum, const Matrix
|
||||
|
||||
inline bool viewproj_test_point( const Matrix4& viewproj, const Vector3& point ){
|
||||
Vector4 hpoint( matrix4_transformed_vector4( viewproj, Vector4( point, 1.0f ) ) );
|
||||
if ( fabs( hpoint[0] ) < fabs( hpoint[3] )
|
||||
&& fabs( hpoint[1] ) < fabs( hpoint[3] )
|
||||
&& fabs( hpoint[2] ) < fabs( hpoint[3] ) ) {
|
||||
if ( std::fabs( hpoint[0] ) < std::fabs( hpoint[3] )
|
||||
&& std::fabs( hpoint[1] ) < std::fabs( hpoint[3] )
|
||||
&& std::fabs( hpoint[2] ) < std::fabs( hpoint[3] ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -548,9 +548,9 @@ inline double plane_distance_to_point( const Plane3& plane, const Vector3& point
|
||||
}
|
||||
|
||||
inline double plane_distance_to_oriented_extents( const Plane3& plane, const Vector3& extents, const Matrix4& orientation ){
|
||||
return fabs( extents[0] * vector3_dot( plane.normal(), orientation.x().vec3() ) )
|
||||
+ fabs( extents[1] * vector3_dot( plane.normal(), orientation.y().vec3() ) )
|
||||
+ fabs( extents[2] * vector3_dot( plane.normal(), orientation.z().vec3() ) );
|
||||
return std::fabs( extents[0] * vector3_dot( plane.normal(), orientation.x().vec3() ) )
|
||||
+ std::fabs( extents[1] * vector3_dot( plane.normal(), orientation.y().vec3() ) )
|
||||
+ std::fabs( extents[2] * vector3_dot( plane.normal(), orientation.z().vec3() ) );
|
||||
}
|
||||
|
||||
/// \brief Return false if \p aabb with \p orientation is partially or completely outside \p plane.
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ inline Segment segment_for_startend( const Vector3& start, const Vector3& end ){
|
||||
inline unsigned int segment_classify_plane( const Segment& segment, const Plane3& plane ){
|
||||
double distance_origin = vector3_dot( plane.normal(), segment.origin ) + plane.dist();
|
||||
|
||||
if ( fabs( distance_origin ) < fabs( vector3_dot( plane.normal(), segment.extents ) ) ) {
|
||||
if ( std::fabs( distance_origin ) < std::fabs( vector3_dot( plane.normal(), segment.extents ) ) ) {
|
||||
return 1; // partially inside
|
||||
}
|
||||
else if ( distance_origin < 0 ) {
|
||||
|
||||
+4
-4
@@ -976,7 +976,7 @@ inline Vector3 matrix4_get_rotation_euler_xyz( const Matrix4& self ){
|
||||
double a = asin( -self[2] );
|
||||
double ca = cos( a );
|
||||
|
||||
if ( fabs( ca ) > 0.005 ) { // Gimbal lock?
|
||||
if ( std::fabs( ca ) > 0.005 ) { // Gimbal lock?
|
||||
return Vector3(
|
||||
static_cast<float>( atan2( self[6] / ca, self[10] / ca ) ),
|
||||
static_cast<float>( a ),
|
||||
@@ -1004,7 +1004,7 @@ inline Vector3 matrix4_get_rotation_euler_yxz( const Matrix4& self ){
|
||||
double a = asin( self[6] );
|
||||
double ca = cos( a );
|
||||
|
||||
if ( fabs( ca ) > 0.005 ) { // Gimbal lock?
|
||||
if ( std::fabs( ca ) > 0.005 ) { // Gimbal lock?
|
||||
return Vector3(
|
||||
static_cast<float>( a ),
|
||||
static_cast<float>( atan2( -self[2] / ca, self[10] / ca ) ),
|
||||
@@ -1032,7 +1032,7 @@ inline Vector3 matrix4_get_rotation_euler_zxy( const Matrix4& self ){
|
||||
double a = asin( -self[9] );
|
||||
double ca = cos( a );
|
||||
|
||||
if ( fabs( ca ) > 0.005 ) { // Gimbal lock?
|
||||
if ( std::fabs( ca ) > 0.005 ) { // Gimbal lock?
|
||||
return Vector3(
|
||||
static_cast<float>( a ),
|
||||
static_cast<float>( atan2( self[8] / ca, self[10] / ca ) ),
|
||||
@@ -1060,7 +1060,7 @@ inline Vector3 matrix4_get_rotation_euler_zyx( const Matrix4& self ){
|
||||
double a = asin( self[8] );
|
||||
double ca = cos( a );
|
||||
|
||||
if ( fabs( ca ) > 0.005 ) { // Gimbal lock?
|
||||
if ( std::fabs( ca ) > 0.005 ) { // Gimbal lock?
|
||||
return Vector3(
|
||||
static_cast<float>( atan2( -self[9] / ca, self[10] / ca ) ),
|
||||
static_cast<float>( a ),
|
||||
|
||||
@@ -182,7 +182,7 @@ const double c_half_sqrt2 = 0.70710678118654752440084436210485;
|
||||
const float c_half_sqrt2f = static_cast<float>( c_half_sqrt2 );
|
||||
|
||||
inline bool quaternion_component_is_90( float component ){
|
||||
return ( fabs( component ) - c_half_sqrt2 ) < 0.001;
|
||||
return ( std::fabs( component ) - c_half_sqrt2 ) < 0.001;
|
||||
}
|
||||
|
||||
inline Matrix4 matrix4_rotation_for_quaternion_quantised( const Quaternion& quaternion ){
|
||||
|
||||
+5
-5
@@ -35,7 +35,7 @@
|
||||
/// \brief Returns true if \p self is equal to other \p other within \p epsilon.
|
||||
template<typename Element, typename OtherElement>
|
||||
inline bool float_equal_epsilon( const Element& self, const OtherElement& other, const Element& epsilon ){
|
||||
return fabs( other - self ) < epsilon;
|
||||
return std::fabs( other - self ) < epsilon;
|
||||
}
|
||||
|
||||
/// \brief Returns the value midway between \p self and \p other.
|
||||
@@ -553,14 +553,14 @@ inline Vector3 vector3_for_spherical( double theta, double phi ){
|
||||
|
||||
template<typename Element>
|
||||
inline std::size_t vector3_max_abs_component_index( const BasicVector3<Element>& self ){
|
||||
const std::size_t maxi = ( fabs( self[1] ) > fabs( self[0] ) )? 1 : 0;
|
||||
return ( fabs( self[2] ) > fabs( self[maxi] ) )? 2 : maxi;;
|
||||
const std::size_t maxi = ( std::fabs( self[1] ) > std::fabs( self[0] ) )? 1 : 0;
|
||||
return ( std::fabs( self[2] ) > std::fabs( self[maxi] ) )? 2 : maxi;;
|
||||
}
|
||||
|
||||
template<typename Element>
|
||||
inline std::size_t vector3_min_abs_component_index( const BasicVector3<Element>& self ){
|
||||
const std::size_t mini = ( fabs( self[1] ) < fabs( self[0] ) )? 1 : 0;
|
||||
return ( fabs( self[2] ) < fabs( self[mini] ) )? 2 : mini;
|
||||
const std::size_t mini = ( std::fabs( self[1] ) < std::fabs( self[0] ) )? 1 : 0;
|
||||
return ( std::fabs( self[2] ) < std::fabs( self[mini] ) )? 2 : mini;
|
||||
}
|
||||
|
||||
template<typename Element>
|
||||
|
||||
+6
-6
@@ -1184,11 +1184,11 @@ inline void ArbitraryMeshTriangle_calcTangents( const ArbitraryMeshVertex& a, co
|
||||
)
|
||||
);
|
||||
|
||||
if ( fabs( cross.x() ) > 0.000001f ) {
|
||||
if ( std::fabs( cross.x() ) > 0.000001f ) {
|
||||
s.x() = -cross.y() / cross.x();
|
||||
}
|
||||
|
||||
if ( fabs( cross.x() ) > 0.000001f ) {
|
||||
if ( std::fabs( cross.x() ) > 0.000001f ) {
|
||||
t.x() = -cross.z() / cross.x();
|
||||
}
|
||||
}
|
||||
@@ -1207,11 +1207,11 @@ inline void ArbitraryMeshTriangle_calcTangents( const ArbitraryMeshVertex& a, co
|
||||
)
|
||||
);
|
||||
|
||||
if ( fabs( cross.x() ) > 0.000001f ) {
|
||||
if ( std::fabs( cross.x() ) > 0.000001f ) {
|
||||
s.y() = -cross.y() / cross.x();
|
||||
}
|
||||
|
||||
if ( fabs( cross.x() ) > 0.000001f ) {
|
||||
if ( std::fabs( cross.x() ) > 0.000001f ) {
|
||||
t.y() = -cross.z() / cross.x();
|
||||
}
|
||||
}
|
||||
@@ -1230,11 +1230,11 @@ inline void ArbitraryMeshTriangle_calcTangents( const ArbitraryMeshVertex& a, co
|
||||
)
|
||||
);
|
||||
|
||||
if ( fabs( cross.x() ) > 0.000001f ) {
|
||||
if ( std::fabs( cross.x() ) > 0.000001f ) {
|
||||
s.z() = -cross.y() / cross.x();
|
||||
}
|
||||
|
||||
if ( fabs( cross.x() ) > 0.000001f ) {
|
||||
if ( std::fabs( cross.x() ) > 0.000001f ) {
|
||||
t.z() = -cross.z() / cross.x();
|
||||
}
|
||||
}
|
||||
|
||||
+11
-11
@@ -171,8 +171,8 @@ void light_draw_radius_fill( const Vector3& origin, const std::array<float, 3>&
|
||||
|
||||
|
||||
void cartesian( const double Long, const double Lat, float cart[3] ) {
|
||||
cart[0] = cos( Long ) * fabs( cos( Lat ) );
|
||||
cart[1] = sin( Long ) * fabs( cos( Lat ) );
|
||||
cart[0] = cos( Long ) * std::fabs( cos( Lat ) );
|
||||
cart[1] = sin( Long ) * std::fabs( cos( Lat ) );
|
||||
cart[2] = sin( Lat );
|
||||
}
|
||||
|
||||
@@ -1604,15 +1604,15 @@ public:
|
||||
return aabb_intersects_aabb( other, AABB(
|
||||
bounds.origin,
|
||||
Vector3(
|
||||
static_cast<float>( fabs( m_rotation[0] * bounds.extents[0] )
|
||||
+ fabs( m_rotation[3] * bounds.extents[1] )
|
||||
+ fabs( m_rotation[6] * bounds.extents[2] ) ),
|
||||
static_cast<float>( fabs( m_rotation[1] * bounds.extents[0] )
|
||||
+ fabs( m_rotation[4] * bounds.extents[1] )
|
||||
+ fabs( m_rotation[7] * bounds.extents[2] ) ),
|
||||
static_cast<float>( fabs( m_rotation[2] * bounds.extents[0] )
|
||||
+ fabs( m_rotation[5] * bounds.extents[1] )
|
||||
+ fabs( m_rotation[8] * bounds.extents[2] ) )
|
||||
std::fabs( m_rotation[0] * bounds.extents[0] )
|
||||
+ std::fabs( m_rotation[3] * bounds.extents[1] )
|
||||
+ std::fabs( m_rotation[6] * bounds.extents[2] ),
|
||||
std::fabs( m_rotation[1] * bounds.extents[0] )
|
||||
+ std::fabs( m_rotation[4] * bounds.extents[1] )
|
||||
+ std::fabs( m_rotation[7] * bounds.extents[2] ),
|
||||
std::fabs( m_rotation[2] * bounds.extents[0] )
|
||||
+ std::fabs( m_rotation[5] * bounds.extents[1] )
|
||||
+ std::fabs( m_rotation[8] * bounds.extents[2] )
|
||||
)
|
||||
) );
|
||||
}
|
||||
|
||||
@@ -199,9 +199,9 @@ public:
|
||||
if ( dir[i] < 0 ){
|
||||
hack[i] *= -1.f;
|
||||
}
|
||||
if ( fabs( dir[i] ) > max ){
|
||||
if ( std::fabs( dir[i] ) > max ){
|
||||
maxI = i;
|
||||
max = fabs( dir[i] );
|
||||
max = std::fabs( dir[i] );
|
||||
}
|
||||
}
|
||||
hack[maxI] *= -1.f;
|
||||
|
||||
+8
-8
@@ -72,8 +72,8 @@ const unsigned int BRUSH_DETAIL_MASK = ( 1 << BRUSH_DETAIL_FLAG );
|
||||
#define Update_move_planepts_vertex 0
|
||||
|
||||
inline bool texdef_sane( const texdef_t& texdef ){
|
||||
return fabs( texdef.shift[0] ) < ( 1 << 16 )
|
||||
&& fabs( texdef.shift[1] ) < ( 1 << 16 );
|
||||
return std::fabs( texdef.shift[0] ) < ( 1 << 16 )
|
||||
&& std::fabs( texdef.shift[1] ) < ( 1 << 16 );
|
||||
}
|
||||
|
||||
inline void Winding_DrawWireframe( const Winding& winding ){
|
||||
@@ -164,7 +164,7 @@ inline float vector3_max_abs_component( const Vector3& vec3 ){
|
||||
}
|
||||
|
||||
inline void edge_snap( Vector3& edge, double snap ){
|
||||
float scale = static_cast<float>( ceil( fabs( snap / vector3_max_abs_component( edge ) ) ) );
|
||||
const float scale = ceil( std::fabs( snap / vector3_max_abs_component( edge ) ) );
|
||||
if ( scale > 0.0f ) {
|
||||
vector3_scale( edge, scale );
|
||||
}
|
||||
@@ -3175,7 +3175,7 @@ public:
|
||||
if( matrix4_clip_line_by_nearplane( test.getVolume().GetViewMatrix(), line ) == 2 ){
|
||||
const Vector3 point_new = line_closest_point( line, g_vector3_identity );
|
||||
const float dist_new = vector3_length_squared( point_new );
|
||||
const float dot_new = fabs( vector3_dot( vector3_normalised( point_new ), vector3_normalised( line.end - line.start ) ) );
|
||||
const float dot_new = std::fabs( vector3_dot( vector3_normalised( point_new ), vector3_normalised( line.end - line.start ) ) );
|
||||
if( planeData.m_dist - dist_new > 1e-6f // new dist noticeably smaller
|
||||
|| ( float_equal_epsilon( dist_new, planeData.m_dist, 1e-6f ) && dot_new < dot ) ){ // or ambiguous case. Resolve it by dot comparison
|
||||
const Plane3& plane1 = m_faceInstances[faceVertex.getFace()].getFace().plane3();
|
||||
@@ -3195,8 +3195,8 @@ public:
|
||||
else if( plane3_distance_to_point( plane2, test.getVolume().getViewer() ) <= 0 )
|
||||
assign_plane( plane2 );
|
||||
}
|
||||
else if( fabs( vector3_length_squared( line.end - line.start ) ) > 1e-3 ){
|
||||
if( fabs( vector3_dot( plane1.normal(), test.getVolume().getViewDir() ) ) < fabs( vector3_dot( plane2.normal(), test.getVolume().getViewDir() ) ) )
|
||||
else if( std::fabs( vector3_length_squared( line.end - line.start ) ) > 1e-3 ){
|
||||
if( std::fabs( vector3_dot( plane1.normal(), test.getVolume().getViewDir() ) ) < std::fabs( vector3_dot( plane2.normal(), test.getVolume().getViewDir() ) ) )
|
||||
assign_plane( plane1 );
|
||||
else
|
||||
assign_plane( plane2 );
|
||||
@@ -3832,14 +3832,14 @@ public:
|
||||
if( !fi.trySelectPlane( test ) ){
|
||||
continue;
|
||||
}
|
||||
const double dot = fabs( vector3_dot( fi.getFace().plane3().normal(), viewdir ) );
|
||||
const double dot = std::fabs( vector3_dot( fi.getFace().plane3().normal(), viewdir ) );
|
||||
const double diff = bestDot - dot;
|
||||
if( diff > 0.03 ){
|
||||
bestDot = dot;
|
||||
bestInstances.clear();
|
||||
bestInstances.push_back( &fi );
|
||||
}
|
||||
else if( fabs( diff ) <= 0.03 ){
|
||||
else if( std::fabs( diff ) <= 0.03 ){
|
||||
bestInstances.push_back( &fi );
|
||||
}
|
||||
}
|
||||
|
||||
+12
-12
@@ -145,7 +145,7 @@ inline void Texdef_toTransform( const TextureProjection& projection, float width
|
||||
|
||||
// handles degenerate cases, just in case library atan2 doesn't
|
||||
inline double arctangent_yx( double y, double x ){
|
||||
if ( fabs( x ) > 1.0E-6 ) {
|
||||
if ( std::fabs( x ) > 1.0E-6 ) {
|
||||
return atan2( y, x );
|
||||
}
|
||||
else if ( y > 0 ) {
|
||||
@@ -366,7 +366,7 @@ void Texdef_Assign( texdef_t& td, const float* hShift, const float* vShift, cons
|
||||
td.shift[1] = *vShift;
|
||||
}
|
||||
if( hScale ){
|
||||
if( fabs( *hScale ) > 1e-5 ){
|
||||
if( std::fabs( *hScale ) > 1e-5f ){
|
||||
td.scale[0] = *hScale;
|
||||
}
|
||||
else{
|
||||
@@ -374,7 +374,7 @@ void Texdef_Assign( texdef_t& td, const float* hShift, const float* vShift, cons
|
||||
}
|
||||
}
|
||||
if( vScale ){
|
||||
if( fabs( *vScale ) > 1e-5 ){
|
||||
if( std::fabs( *vScale ) > 1e-5f ){
|
||||
td.scale[1] = *vScale;
|
||||
}
|
||||
else{
|
||||
@@ -394,13 +394,13 @@ void Texdef_Shift( texdef_t& td, float s, float t ){
|
||||
}
|
||||
|
||||
void Texdef_Scale( texdef_t& td, float s, float t ){
|
||||
if( fabs( td.scale[0] + s ) > 1e-5 ){
|
||||
if( std::fabs( td.scale[0] + s ) > 1e-5f ){
|
||||
td.scale[0] += s;
|
||||
}
|
||||
else{
|
||||
td.scale[0] = -td.scale[0];
|
||||
}
|
||||
if( fabs( td.scale[1] + t ) > 1e-5 ){
|
||||
if( std::fabs( td.scale[1] + t ) > 1e-5f ){
|
||||
td.scale[1] += t;
|
||||
}
|
||||
else{
|
||||
@@ -567,8 +567,8 @@ void EmitBrushPrimitTextureCoordinates( face_t * f, Winding * w ){
|
||||
// check we compute the same ST as the traditional texture computation used before
|
||||
float S = f->brushprimit_texdef.coords[0][0] * x + f->brushprimit_texdef.coords[0][1] * y + f->brushprimit_texdef.coords[0][2];
|
||||
float T = f->brushprimit_texdef.coords[1][0] * x + f->brushprimit_texdef.coords[1][1] * y + f->brushprimit_texdef.coords[1][2];
|
||||
if ( fabs( S - w.point_at( i )[3] ) > 1e-2 || fabs( T - w.point_at( i )[4] ) > 1e-2 ) {
|
||||
if ( fabs( S - w.point_at( i )[3] ) > 1e-4 || fabs( T - w.point_at( i )[4] ) > 1e-4 ) {
|
||||
if ( std::fabs( S - w.point_at( i )[3] ) > 1e-2 || std::fabs( T - w.point_at( i )[4] ) > 1e-2 ) {
|
||||
if ( std::fabs( S - w.point_at( i )[3] ) > 1e-4 || std::fabs( T - w.point_at( i )[4] ) > 1e-4 ) {
|
||||
globalWarningStream() << "Warning : precision loss in brush -> brush primitive texture computation\n";
|
||||
}
|
||||
else{
|
||||
@@ -745,7 +745,7 @@ void ComputeBest2DVector( Vector3& v, Vector3& X, Vector3& Y, int &x, int &y ){
|
||||
double sx,sy;
|
||||
sx = vector3_dot( v, X );
|
||||
sy = vector3_dot( v, Y );
|
||||
if ( fabs( sy ) > fabs( sx ) ) {
|
||||
if ( std::fabs( sy ) > std::fabs( sx ) ) {
|
||||
x = 0;
|
||||
if ( sy > 0.0 ) {
|
||||
y = 1;
|
||||
@@ -1067,10 +1067,10 @@ void BPTexdef_Scale( brushprimit_texdef_t& bp_td, float s, float t ){
|
||||
|
||||
float scaleS = -1.f;
|
||||
float scaleT = -1.f;
|
||||
if( fabs( texdef.scale[0] + s ) > 1e-5 ){
|
||||
if( std::fabs( texdef.scale[0] + s ) > 1e-5f ){
|
||||
scaleS = texdef.scale[0] / ( texdef.scale[0] + s );
|
||||
}
|
||||
if( fabs( texdef.scale[1] + t ) > 1e-5 ){
|
||||
if( std::fabs( texdef.scale[1] + t ) > 1e-5f ){
|
||||
scaleT = texdef.scale[1] / ( texdef.scale[1] + t );
|
||||
}
|
||||
bp_td.coords[0][0] *= scaleS;
|
||||
@@ -1116,7 +1116,7 @@ void BPTexdef_Assign( brushprimit_texdef_t& bp_td, const float* hShift, const fl
|
||||
}
|
||||
if( hScale ){
|
||||
float scaleS = -1.f;
|
||||
if( fabs( *hScale ) > 1e-5 ){
|
||||
if( std::fabs( *hScale ) > 1e-5f ){
|
||||
scaleS = texdef.scale[0] / *hScale;
|
||||
}
|
||||
bp_td.coords[0][0] *= scaleS;
|
||||
@@ -1124,7 +1124,7 @@ void BPTexdef_Assign( brushprimit_texdef_t& bp_td, const float* hShift, const fl
|
||||
}
|
||||
if( vScale ){
|
||||
float scaleT = -1.f;
|
||||
if( fabs( *vScale ) > 1e-5 ){
|
||||
if( std::fabs( *vScale ) > 1e-5f ){
|
||||
scaleT = texdef.scale[1] / *vScale;
|
||||
}
|
||||
bp_td.coords[1][0] *= scaleT;
|
||||
|
||||
@@ -166,11 +166,11 @@ inline void ComputeAxisBase( const BasicVector3<Element>& normal, BasicVector3<O
|
||||
float RotY, RotZ;
|
||||
// do some cleaning
|
||||
/*
|
||||
if ( fabs( normal[0] ) < 1e-6 )
|
||||
if ( std::fabs( normal[0] ) < 1e-6 )
|
||||
normal[0] = 0.0f;
|
||||
if ( fabs( normal[1] ) < 1e-6 )
|
||||
if ( std::fabs( normal[1] ) < 1e-6 )
|
||||
normal[1] = 0.0f;
|
||||
if ( fabs( normal[2] ) < 1e-6 )
|
||||
if ( std::fabs( normal[2] ) < 1e-6 )
|
||||
normal[2] = 0.0f;
|
||||
*/
|
||||
RotY = -atan2( normal[2], sqrt( normal[1] * normal[1] + normal[0] * normal[0] ) );
|
||||
|
||||
+5
-5
@@ -600,9 +600,9 @@ public:
|
||||
const DoubleVector3& n2 = b->getPlane().plane3().normal();
|
||||
const ProjectionAxis p1 = projectionaxis_for_normal( n1 );
|
||||
const ProjectionAxis p2 = projectionaxis_for_normal( n2 );
|
||||
return float_equal_epsilon( fabs( n1[ p1 ] ), fabs( n2[ p2 ] ), c_PLANE_NORMAL_EPSILON )
|
||||
return float_equal_epsilon( std::fabs( n1[ p1 ] ), std::fabs( n2[ p2 ] ), c_PLANE_NORMAL_EPSILON )
|
||||
? p1 > p2 // Z > Y > X
|
||||
: fabs( n1[ p1 ] ) > fabs( n2[ p2 ] ); // or most axial
|
||||
: std::fabs( n1[ p1 ] ) > std::fabs( n2[ p2 ] ); // or most axial
|
||||
} );
|
||||
|
||||
auto it = faces.cbegin(), found = it; // traverse projections and craft more fortunate splits order in non trivial cases
|
||||
@@ -627,10 +627,10 @@ public:
|
||||
const ProjectionAxis p2 = projectionaxis_for_normal( n2 );
|
||||
if( p1 == p2 // same projection
|
||||
&& n1[p1] * n2[p2] < 0 // opposite projection facing
|
||||
&& ( fabs( n2[p2] ) > bestmax + c_PLANE_NORMAL_EPSILON // definitely better proj direction
|
||||
|| ( fabs( n2[p2] ) > bestmax - c_PLANE_NORMAL_EPSILON // or similar proj direction
|
||||
&& ( std::fabs( n2[p2] ) > bestmax + c_PLANE_NORMAL_EPSILON // definitely better proj direction
|
||||
|| ( std::fabs( n2[p2] ) > bestmax - c_PLANE_NORMAL_EPSILON // or similar proj direction
|
||||
&& vector3_dot( n1, n2 ) < bestdot ) ) ){ // + more opposing normal direction
|
||||
bestmax = fabs( n2[p2] );
|
||||
bestmax = std::fabs( n2[p2] );
|
||||
bestdot = vector3_dot( n1, n2 );
|
||||
more = face;
|
||||
}
|
||||
|
||||
+17
-17
@@ -670,9 +670,9 @@ void Patch::CapTexture(){
|
||||
vector3_add( normal, tmp );
|
||||
}
|
||||
}
|
||||
normal[0] = fabs( normal[0] );
|
||||
normal[1] = fabs( normal[1] );
|
||||
normal[2] = fabs( normal[2] );
|
||||
normal[0] = std::fabs( normal[0] );
|
||||
normal[1] = std::fabs( normal[1] );
|
||||
normal[2] = std::fabs( normal[2] );
|
||||
|
||||
ProjectTexture( texture_axis( normal ) );
|
||||
#else
|
||||
@@ -711,7 +711,7 @@ void Patch::NaturalTexture(){
|
||||
for ( std::size_t h = 0; h < m_height; ++h, pHeight += m_width )
|
||||
{
|
||||
const double length = tex + ( vector3_length( pHeight->m_vertex - ( pHeight + 1 )->m_vertex ) / texSize );
|
||||
if ( fabs( length ) > fabs( texBest ) ) { // comparing abs values supports possible negative Texdef_getDefaultTextureScale()
|
||||
if ( std::fabs( length ) > std::fabs( texBest ) ) { // comparing abs values supports possible negative Texdef_getDefaultTextureScale()
|
||||
texBest = length;
|
||||
}
|
||||
}
|
||||
@@ -744,7 +744,7 @@ void Patch::NaturalTexture(){
|
||||
for ( std::size_t w = 0; w < m_width; ++w, ++pWidth )
|
||||
{
|
||||
const double length = tex + ( vector3_length( pWidth->m_vertex - ( pWidth + m_width )->m_vertex ) / texSize );
|
||||
if ( fabs( length ) > fabs( texBest ) ) {
|
||||
if ( std::fabs( length ) > std::fabs( texBest ) ) {
|
||||
texBest = length;
|
||||
}
|
||||
}
|
||||
@@ -2431,7 +2431,7 @@ inline void tangents_remove_degenerate( Vector3 tangents[6], Vector2 textureTang
|
||||
}
|
||||
|
||||
void bestTangents00( unsigned int degenerateFlags, double dot, double length, std::size_t& index0, std::size_t& index1 ){
|
||||
if ( fabs( dot + length ) < 0.001 ) { // opposing direction = degenerate
|
||||
if ( std::fabs( dot + length ) < 0.001 ) { // opposing direction = degenerate
|
||||
if ( !( degenerateFlags & DEGEN_1a ) ) { // if this tangent is degenerate we cannot use it
|
||||
index0 = 2;
|
||||
index1 = 0;
|
||||
@@ -2446,7 +2446,7 @@ void bestTangents00( unsigned int degenerateFlags, double dot, double length, st
|
||||
index1 = 0;
|
||||
}
|
||||
}
|
||||
else if ( fabs( dot - length ) < 0.001 ) { // same direction = degenerate
|
||||
else if ( std::fabs( dot - length ) < 0.001 ) { // same direction = degenerate
|
||||
if ( degenerateFlags & DEGEN_0b ) {
|
||||
index0 = 0;
|
||||
index1 = 1;
|
||||
@@ -2460,7 +2460,7 @@ void bestTangents00( unsigned int degenerateFlags, double dot, double length, st
|
||||
}
|
||||
|
||||
void bestTangents01( unsigned int degenerateFlags, double dot, double length, std::size_t& index0, std::size_t& index1 ){
|
||||
if ( fabs( dot - length ) < 0.001 ) { // same direction = degenerate
|
||||
if ( std::fabs( dot - length ) < 0.001 ) { // same direction = degenerate
|
||||
if ( !( degenerateFlags & DEGEN_1a ) ) { // if this tangent is degenerate we cannot use it
|
||||
index0 = 2;
|
||||
index1 = 1;
|
||||
@@ -2475,7 +2475,7 @@ void bestTangents01( unsigned int degenerateFlags, double dot, double length, st
|
||||
index1 = 1;
|
||||
}
|
||||
}
|
||||
else if ( fabs( dot + length ) < 0.001 ) { // opposing direction = degenerate
|
||||
else if ( std::fabs( dot + length ) < 0.001 ) { // opposing direction = degenerate
|
||||
if ( degenerateFlags & DEGEN_2b ) {
|
||||
index0 = 4;
|
||||
index1 = 0;
|
||||
@@ -2489,7 +2489,7 @@ void bestTangents01( unsigned int degenerateFlags, double dot, double length, st
|
||||
}
|
||||
|
||||
void bestTangents10( unsigned int degenerateFlags, double dot, double length, std::size_t& index0, std::size_t& index1 ){
|
||||
if ( fabs( dot - length ) < 0.001 ) { // same direction = degenerate
|
||||
if ( std::fabs( dot - length ) < 0.001 ) { // same direction = degenerate
|
||||
if ( !( degenerateFlags & DEGEN_1b ) ) { // if this tangent is degenerate we cannot use it
|
||||
index0 = 3;
|
||||
index1 = 4;
|
||||
@@ -2504,7 +2504,7 @@ void bestTangents10( unsigned int degenerateFlags, double dot, double length, st
|
||||
index1 = 4;
|
||||
}
|
||||
}
|
||||
else if ( fabs( dot + length ) < 0.001 ) { // opposing direction = degenerate
|
||||
else if ( std::fabs( dot + length ) < 0.001 ) { // opposing direction = degenerate
|
||||
if ( degenerateFlags & DEGEN_0a ) {
|
||||
index0 = 1;
|
||||
index1 = 5;
|
||||
@@ -2518,7 +2518,7 @@ void bestTangents10( unsigned int degenerateFlags, double dot, double length, st
|
||||
}
|
||||
|
||||
void bestTangents11( unsigned int degenerateFlags, double dot, double length, std::size_t& index0, std::size_t& index1 ){
|
||||
if ( fabs( dot + length ) < 0.001 ) { // opposing direction = degenerate
|
||||
if ( std::fabs( dot + length ) < 0.001 ) { // opposing direction = degenerate
|
||||
if ( !( degenerateFlags & DEGEN_1b ) ) { // if this tangent is degenerate we cannot use it
|
||||
index0 = 3;
|
||||
index1 = 5;
|
||||
@@ -2533,7 +2533,7 @@ void bestTangents11( unsigned int degenerateFlags, double dot, double length, st
|
||||
index1 = 5;
|
||||
}
|
||||
}
|
||||
else if ( fabs( dot - length ) < 0.001 ) { // same direction = degenerate
|
||||
else if ( std::fabs( dot - length ) < 0.001 ) { // same direction = degenerate
|
||||
if ( degenerateFlags & DEGEN_2a ) {
|
||||
index0 = 5;
|
||||
index1 = 4;
|
||||
@@ -3111,8 +3111,8 @@ void Patch::createThickenedOpposite( const Patch& sourcePatch,
|
||||
}
|
||||
else{
|
||||
// If two column + two row tangents are available, take the length-corrected average
|
||||
if ( ( fabs( colTangent[1][0] ) + fabs( colTangent[1][1] ) + fabs( colTangent[1][2] ) ) > 0 &&
|
||||
( fabs( rowTangent[1][0] ) + fabs( rowTangent[1][1] ) + fabs( rowTangent[1][2] ) ) > 0 )
|
||||
if ( ( std::fabs( colTangent[1][0] ) + std::fabs( colTangent[1][1] ) + std::fabs( colTangent[1][2] ) ) > 0 &&
|
||||
( std::fabs( rowTangent[1][0] ) + std::fabs( rowTangent[1][1] ) + std::fabs( rowTangent[1][2] ) ) > 0 )
|
||||
{
|
||||
// Two column normals to calculate
|
||||
Vector3 normal1 = vector3_normalised( vector3_cross( rowTangent[0], colTangent[0] ) );
|
||||
@@ -3125,7 +3125,7 @@ void Patch::createThickenedOpposite( const Patch& sourcePatch,
|
||||
globalOutputStream() << normal << '\n';*/
|
||||
}
|
||||
// If two column tangents are available, take the length-corrected average
|
||||
else if ( ( fabs( colTangent[1][0] ) + fabs( colTangent[1][1] ) + fabs( colTangent[1][2] ) ) > 0)
|
||||
else if ( ( std::fabs( colTangent[1][0] ) + std::fabs( colTangent[1][1] ) + std::fabs( colTangent[1][2] ) ) > 0)
|
||||
{
|
||||
// Two column normals to calculate
|
||||
Vector3 normal1 = vector3_normalised( vector3_cross( rowTangent[0], colTangent[0] ) );
|
||||
@@ -3140,7 +3140,7 @@ void Patch::createThickenedOpposite( const Patch& sourcePatch,
|
||||
else
|
||||
{
|
||||
// One column tangent available, maybe we have a second rowtangent?
|
||||
if ( ( fabs( rowTangent[1][0] ) + fabs( rowTangent[1][1] ) + fabs( rowTangent[1][2] ) ) > 0)
|
||||
if ( ( std::fabs( rowTangent[1][0] ) + std::fabs( rowTangent[1][1] ) + std::fabs( rowTangent[1][2] ) ) > 0)
|
||||
{
|
||||
// Two row normals to calculate
|
||||
Vector3 normal1 = vector3_normalised( vector3_cross( rowTangent[0], colTangent[0] ) );
|
||||
|
||||
@@ -1129,7 +1129,7 @@ public:
|
||||
bool valid() const {
|
||||
return !( !std::isfinite( m_local2tex[0] ) //nan
|
||||
|| !std::isfinite( m_tex2local[0] ) //nan
|
||||
|| fabs( vector3_dot( m_plane.normal(), m_tex2local.z().vec3() ) ) < 1e-6 //projected along face
|
||||
|| std::fabs( vector3_dot( m_plane.normal(), m_tex2local.z().vec3() ) ) < 1e-6 //projected along face
|
||||
|| vector3_length_squared( m_tex2local.x().vec3() ) < .01 //srsly scaled down, limit at max 10 textures per world unit
|
||||
|| vector3_length_squared( m_tex2local.y().vec3() ) < .01
|
||||
|| vector3_length_squared( m_tex2local.x().vec3() ) > 1e9 //very upscaled or product of nearly nan
|
||||
|
||||
+3
-3
@@ -628,7 +628,7 @@ inline Quaternion quaternion_for_axis90( axis_t axis, sign_t sign ){
|
||||
}
|
||||
|
||||
void Select_RotateAxis( int axis, float deg ){
|
||||
if ( fabs( deg ) == 90.f ) {
|
||||
if ( std::fabs( deg ) == 90.f ) {
|
||||
GlobalSelectionSystem().rotateSelected( quaternion_for_axis90( (axis_t)axis, ( deg > 0 ) ? eSignPositive : eSignNegative ), true );
|
||||
}
|
||||
else
|
||||
@@ -1457,11 +1457,11 @@ void Texdef_Rotate( float angle ){
|
||||
// these are actually {Anti,}Clockwise in BP mode only (AP/220 - 50/50)
|
||||
// TODO is possible to make really {Anti,}Clockwise
|
||||
void Texdef_RotateClockwise(){
|
||||
Texdef_Rotate( static_cast<float>( -fabs( g_si_globals.rotate ) ) );
|
||||
Texdef_Rotate( -std::fabs( g_si_globals.rotate ) );
|
||||
}
|
||||
|
||||
void Texdef_RotateAntiClockwise(){
|
||||
Texdef_Rotate( static_cast<float>( fabs( g_si_globals.rotate ) ) );
|
||||
Texdef_Rotate( std::fabs( g_si_globals.rotate ) );
|
||||
}
|
||||
|
||||
void Texdef_Scale( float x, float y ){
|
||||
|
||||
+67
-67
@@ -277,7 +277,7 @@ public:
|
||||
}
|
||||
void Construct( const Matrix4& device2manip, const DeviceVector device_point, const AABB& bounds, const Vector3& transform_origin ) override {
|
||||
const float dot = vector3_dot( m_axis, m_view->fill()? vector3_normalised( m_view->getViewer() - transform_origin ) : m_view->getViewDir() );
|
||||
m_plane_way = fabs( dot ) > 0.1;
|
||||
m_plane_way = std::fabs( dot ) > 0.1f;
|
||||
|
||||
if( m_plane_way ){
|
||||
m_origin = transform_origin;
|
||||
@@ -325,12 +325,12 @@ void aabb_snap_translation( Vector3& move, const AABB& bounds ){
|
||||
const Vector3 mins( bounds.origin - bounds.extents );
|
||||
// globalOutputStream() << "move: " << move << '\n';
|
||||
for( std::size_t i = 0; i < 3; ++i ){
|
||||
if( fabs( move[i] ) > 1e-2f ){
|
||||
if( std::fabs( move[i] ) > 1e-2f ){
|
||||
const float snapto1 = float_snapped( maxs[i] + move[i], GetSnapGridSize() );
|
||||
const float snapto2 = float_snapped( mins[i] + move[i], GetSnapGridSize() );
|
||||
|
||||
const float dist1 = fabs( fabs( maxs[i] + move[i] ) - fabs( snapto1 ) );
|
||||
const float dist2 = fabs( fabs( mins[i] + move[i] ) - fabs( snapto2 ) );
|
||||
const float dist1 = std::fabs( std::fabs( maxs[i] + move[i] ) - std::fabs( snapto1 ) );
|
||||
const float dist2 = std::fabs( std::fabs( mins[i] + move[i] ) - std::fabs( snapto2 ) );
|
||||
|
||||
// globalOutputStream() << "maxs[i] + move[i]: " << maxs[i] + move[i] << " snapto1: " << snapto1 << " dist1: " << dist1 << '\n';
|
||||
// globalOutputStream() << "mins[i] + move[i]: " << mins[i] + move[i] << " snapto2: " << snapto2 << " dist2: " << dist2 << '\n';
|
||||
@@ -539,7 +539,7 @@ public:
|
||||
float bestDist = FLT_MAX;
|
||||
for( size_t axis : { 0, 1, 2 } )
|
||||
for( int sign : { -1, 1 } )
|
||||
if( const float dist = fabs( m_0[axis] - ( m_bounds.origin[axis] + std::copysign( m_bounds.extents[axis], sign ) ) ); dist < bestDist ){
|
||||
if( const float dist = std::fabs( m_0[axis] - ( m_bounds.origin[axis] + std::copysign( m_bounds.extents[axis], sign ) ) ); dist < bestDist ){
|
||||
bestDist = dist;
|
||||
m_roatateAxis = axis;
|
||||
m_rotateSign = sign;
|
||||
@@ -829,14 +829,14 @@ public:
|
||||
if( g_modifiers.shift() ){ // snap 2 axes equally
|
||||
float bestscale = ignore_axis != 0 ? scale[0] : scale[1];
|
||||
for( std::size_t i = ignore_axis != 0 ? 1 : 2; i < 3; ++i ){
|
||||
if( ignore_axis != i && fabs( scale[i] ) < fabs( bestscale ) ){
|
||||
if( ignore_axis != i && std::fabs( scale[i] ) < std::fabs( bestscale ) ){
|
||||
bestscale = scale[i];
|
||||
}
|
||||
//globalOutputStream() << "bestscale: " << bestscale << '\n';
|
||||
}
|
||||
for( std::size_t i = 0; i < 3; ++i ){
|
||||
if( ignore_axis != i ){
|
||||
scale[i] = ( scale[i] < 0.f ) ? -fabs( bestscale ) : fabs( bestscale );
|
||||
scale[i] = ( scale[i] < 0.f ) ? -std::fabs( bestscale ) : fabs( bestscale );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -939,7 +939,7 @@ public:
|
||||
return;
|
||||
|
||||
if( g_modifiers.shift() || g_modifiers.ctrl() ){ // square or cube
|
||||
const float squaresize = std::max( fabs( diff.x() ), fabs( diff.y() ) );
|
||||
const float squaresize = std::max( std::fabs( diff.x() ), std::fabs( diff.y() ) );
|
||||
diff.x() = diff.x() > 0? squaresize : -squaresize; //square
|
||||
diff.y() = diff.y() > 0? squaresize : -squaresize;
|
||||
if( g_modifiers.ctrl() && !g_modifiers.alt() ) //cube
|
||||
@@ -1057,7 +1057,7 @@ public:
|
||||
|
||||
vector3_snap( current, GetSnapGridSize() );
|
||||
|
||||
const float offset = fabs( m_planeSelected.normal()[m_axisZ] ) * std::copysign(
|
||||
const float offset = std::fabs( m_planeSelected.normal()[m_axisZ] ) * std::copysign(
|
||||
std::max( static_cast<double>( GetGridSize() ), vector3_length( current ) ),
|
||||
vector3_dot( current, m_planeSelected.normal() ) );
|
||||
|
||||
@@ -2433,7 +2433,7 @@ public:
|
||||
}
|
||||
|
||||
bool manipulator_show_axis( const Pivot2World& pivot, const Vector3& axis ){
|
||||
return fabs( vector3_dot( pivot.m_axis_screen, axis ) ) < 0.95;
|
||||
return std::fabs( vector3_dot( pivot.m_axis_screen, axis ) ) < 0.95;
|
||||
}
|
||||
|
||||
void render( Renderer& renderer, const VolumeTest& volume, const Matrix4& pivot2world ) override {
|
||||
@@ -2998,7 +2998,7 @@ public:
|
||||
m_pivot2world = matrix4_translation_for_vec3( origin );
|
||||
}
|
||||
/* set radius */
|
||||
if( fabs( vector3_dot( m_pivot.m_axis_screen, g_vector3_axes[i] ) ) < 0.2 ){
|
||||
if( std::fabs( vector3_dot( m_pivot.m_axis_screen, g_vector3_axes[i] ) ) < 0.2 ){
|
||||
Vector3 origin = matrix4_get_translation_vec3( m_pivot2world );
|
||||
Vector3 point = m_bounds_draw.origin + m_point.m_point.vertex * m_bounds_draw.extents;
|
||||
const Matrix4 inv = matrix4_affine_inverse( m_pivot.m_worldSpace );
|
||||
@@ -4655,10 +4655,10 @@ public:
|
||||
m_viewdir = ( viewdir[maxi] > 0 )? g_vector3_axes[maxi] : -g_vector3_axes[maxi];
|
||||
}
|
||||
void viewdir_fixup(){
|
||||
if( fabs( vector3_length( m_points[1].m_point - m_points[0].m_point ) ) > 1e-3 //two non coincident points
|
||||
&& fabs( vector3_dot( m_viewdir, vector3_normalised( m_points[1].m_point - m_points[0].m_point ) ) ) > 0.999 ){ //on axis = m_viewdir
|
||||
if( std::fabs( vector3_length( m_points[1].m_point - m_points[0].m_point ) ) > 1e-3 //two non coincident points
|
||||
&& std::fabs( vector3_dot( m_viewdir, vector3_normalised( m_points[1].m_point - m_points[0].m_point ) ) ) > 0.999 ){ //on axis = m_viewdir
|
||||
viewdir_set( m_view->getViewDir() );
|
||||
if( fabs( vector3_dot( m_viewdir, vector3_normalised( m_points[1].m_point - m_points[0].m_point ) ) ) > 0.999 ){
|
||||
if( std::fabs( vector3_dot( m_viewdir, vector3_normalised( m_points[1].m_point - m_points[0].m_point ) ) ) > 0.999 ){
|
||||
const Matrix4 screen2world( matrix4_full_inverse( m_view->GetViewMatrix() ) );
|
||||
Vector3 p[2];
|
||||
for( std::size_t i = 0; i < 2; ++i ){
|
||||
@@ -4677,7 +4677,7 @@ public:
|
||||
const std::size_t maxi = vector3_max_abs_component_index( plane.normal() );
|
||||
if( plane3_valid( plane )
|
||||
&& aabb_valid( m_bounds )
|
||||
&& fabs( plane.normal()[maxi] ) > 0.999 ){ //axial plane
|
||||
&& std::fabs( plane.normal()[maxi] ) > 0.999 ){ //axial plane
|
||||
const double anchor = plane.normal()[maxi] * plane.dist();
|
||||
if( anchor > m_bounds.origin[maxi] ){
|
||||
if( ( anchor - ( m_bounds.origin[maxi] + m_bounds.extents[maxi] ) ) > -0.1 )
|
||||
@@ -5230,7 +5230,7 @@ private:
|
||||
bool projection_valid() const {
|
||||
return !( !std::isfinite( m_local2tex[0] ) //nan
|
||||
|| !std::isfinite( m_tex2local[0] ) //nan
|
||||
|| fabs( vector3_dot( m_plane.normal(), m_tex2local.z().vec3() ) ) < 1e-6 //projected along face
|
||||
|| std::fabs( vector3_dot( m_plane.normal(), m_tex2local.z().vec3() ) ) < 1e-6 //projected along face
|
||||
|| vector3_length_squared( m_tex2local.x().vec3() ) < .01 //srsly scaled down, limit at max 10 textures per world unit
|
||||
|| vector3_length_squared( m_tex2local.y().vec3() ) < .01
|
||||
|| vector3_length_squared( m_tex2local.x().vec3() ) > 1e9 //very upscaled or product of nearly nan
|
||||
@@ -5319,7 +5319,7 @@ private:
|
||||
p1 = &m_patch->ctrlAt( m_patchHeight - 1, col );
|
||||
p2 = distW0 > distW1? &m_patch->ctrlAt( row, 0 ) : &m_patch->ctrlAt( row, m_patchWidth - 1 );
|
||||
v0 = m_patch->localAABB().origin
|
||||
+ hDir * vector3_dot( m_patch->localAABB().extents, Vector3( fabs( hDir.x() ), fabs( hDir.y() ), fabs( hDir.z() ) ) ) * 1.1
|
||||
+ hDir * vector3_dot( m_patch->localAABB().extents, Vector3( std::fabs( hDir.x() ), std::fabs( hDir.y() ), std::fabs( hDir.z() ) ) ) * 1.1
|
||||
+ wDir * ( distW0 - wLength / 2 );
|
||||
v1 = v0 + hDir * hLength;
|
||||
v2 = v0 + hDir * distH0 + ( distW0 > distW1? ( wDir * -distW0 ) : ( wDir * distW1 ) );
|
||||
@@ -5329,7 +5329,7 @@ private:
|
||||
p1 = &m_patch->ctrlAt( row, m_patchWidth - 1 );
|
||||
p2 = distH0 > distH1? &m_patch->ctrlAt( 0, col ) : &m_patch->ctrlAt( m_patchHeight - 1, col );
|
||||
v0 = m_patch->localAABB().origin
|
||||
+ wDir * vector3_dot( m_patch->localAABB().extents, Vector3( fabs( wDir.x() ), fabs( wDir.y() ), fabs( wDir.z() ) ) ) * 1.1
|
||||
+ wDir * vector3_dot( m_patch->localAABB().extents, Vector3( std::fabs( wDir.x() ), std::fabs( wDir.y() ), std::fabs( wDir.z() ) ) ) * 1.1
|
||||
+ hDir * ( distH0 - hLength / 2 );
|
||||
v1 = v0 + wDir * wLength;
|
||||
v2 = v0 + wDir * distW0 + ( distH0 > distH1? ( hDir * -distH0 ) : ( hDir * distH1 ) );
|
||||
@@ -5700,7 +5700,7 @@ V line center| - - tex U center - -
|
||||
vector4_projected( matrix4_transformed_vector4( screen2world, BasicVector4<double>( 0, 0, 1, 1 ) ) ) );
|
||||
const DoubleVector3 hit = ray_intersect_plane( ray, m_plane );
|
||||
const Vector3 uvhit = matrix4_transformed_point( m_faceLocal2tex, hit );
|
||||
if( fabs( vector3_dot( ray.direction, m_plane.normal() ) ) > 1e-6
|
||||
if( std::fabs( vector3_dot( ray.direction, m_plane.normal() ) ) > 1e-6
|
||||
&& !m_Ulines.m_lines.empty()
|
||||
&& !m_Vlines.m_lines.empty()
|
||||
&& matrix4_transformed_vector4( view.GetViewMatrix(), Vector4( hit, 1 ) ).w() > 0 ){
|
||||
@@ -6005,26 +6005,26 @@ public:
|
||||
float snapToU = 0;
|
||||
float snapToV = 0;
|
||||
for( std::vector<PointVertex>::const_iterator i = m_Ulines.m_lines.begin(); i != m_Ulines.m_lines.end(); ++++i ){
|
||||
const float dist = fabs( ( *i ).vertex.y() - uv_origin.y() );
|
||||
const float dist = std::fabs( ( *i ).vertex.y() - uv_origin.y() );
|
||||
if( dist < bestDistU ){
|
||||
bestDistU = dist;
|
||||
snapToU = ( *i ).vertex.y();
|
||||
}
|
||||
}
|
||||
for( std::vector<PointVertex>::const_iterator i = m_Vlines.m_lines.begin(); i != m_Vlines.m_lines.end(); ++++i ){
|
||||
const float dist = fabs( ( *i ).vertex.x() - uv_origin.x() );
|
||||
const float dist = std::fabs( ( *i ).vertex.x() - uv_origin.x() );
|
||||
if( dist < bestDistV ){
|
||||
bestDistV = dist;
|
||||
snapToV = ( *i ).vertex.x();
|
||||
}
|
||||
}
|
||||
forEachUVPoint( [&]( const Vector3& point ){
|
||||
const float distU = fabs( point.y() - uv_origin.y() );
|
||||
const float distU = std::fabs( point.y() - uv_origin.y() );
|
||||
if( distU < bestDistU ){
|
||||
bestDistU = distU;
|
||||
snapToU = point.y();
|
||||
}
|
||||
const float distV = fabs( point.x() - uv_origin.x() );
|
||||
const float distV = std::fabs( point.x() - uv_origin.x() );
|
||||
if( distV < bestDistV ){
|
||||
bestDistV = distV;
|
||||
snapToV = point.x();
|
||||
@@ -6055,14 +6055,14 @@ public:
|
||||
float bestDist = FLT_MAX;
|
||||
float snapTo = 0;
|
||||
for( std::vector<PointVertex>::const_iterator i = m_Ulines.m_lines.begin(); i != m_Ulines.m_lines.end(); ++++i ){
|
||||
const float dist = fabs( ( *i ).vertex.y() - uv_origin.y() );
|
||||
const float dist = std::fabs( ( *i ).vertex.y() - uv_origin.y() );
|
||||
if( dist < bestDist ){
|
||||
bestDist = dist;
|
||||
snapTo = ( *i ).vertex.y();
|
||||
}
|
||||
}
|
||||
forEachUVPoint( [&]( const Vector3& point ){
|
||||
const float dist = fabs( point.y() - uv_origin.y() );
|
||||
const float dist = std::fabs( point.y() - uv_origin.y() );
|
||||
if( dist < bestDist ){
|
||||
bestDist = dist;
|
||||
snapTo = point.y();
|
||||
@@ -6087,14 +6087,14 @@ public:
|
||||
float bestDist = FLT_MAX;
|
||||
float snapTo = 0;
|
||||
for( std::vector<PointVertex>::const_iterator i = m_Vlines.m_lines.begin(); i != m_Vlines.m_lines.end(); ++++i ){
|
||||
const float dist = fabs( ( *i ).vertex.x() - uv_origin.x() );
|
||||
const float dist = std::fabs( ( *i ).vertex.x() - uv_origin.x() );
|
||||
if( dist < bestDist ){
|
||||
bestDist = dist;
|
||||
snapTo = ( *i ).vertex.x();
|
||||
}
|
||||
}
|
||||
forEachUVPoint( [&]( const Vector3& point ){
|
||||
const float dist = fabs( point.x() - uv_origin.x() );
|
||||
const float dist = std::fabs( point.x() - uv_origin.x() );
|
||||
if( dist < bestDist ){
|
||||
bestDist = dist;
|
||||
snapTo = point.x();
|
||||
@@ -6194,13 +6194,13 @@ public:
|
||||
forEachEdge( [&]( const Vector3& point0, const Vector3& point1 ){
|
||||
Vector3 vec( point1 - point0 );
|
||||
constrain_to_axis( vec, m_tex2local.z().vec3() );
|
||||
const float dotU = fabs( vector3_dot( uvec, vec ) );
|
||||
const float dotU = std::fabs( vector3_dot( uvec, vec ) );
|
||||
if( dotU > bestDot ){
|
||||
bestDot = dotU;
|
||||
bestTo = vector3_dot( uvec, vec ) > 0? vec : -vec;
|
||||
V = false;
|
||||
}
|
||||
const float dotV = fabs( vector3_dot( vvec, vec ) );
|
||||
const float dotV = std::fabs( vector3_dot( vvec, vec ) );
|
||||
if( dotV > bestDot ){
|
||||
bestDot = dotV;
|
||||
bestTo = vector3_dot( vvec, vec ) > 0? vec : -vec;
|
||||
@@ -6241,7 +6241,7 @@ public:
|
||||
float bestDist = FLT_MAX;
|
||||
float snapTo = 0;
|
||||
forEachUVPoint( [&]( const Vector3& point ){
|
||||
const float dist = fabs( point.y() - uv_current.y() );
|
||||
const float dist = std::fabs( point.y() - uv_current.y() );
|
||||
if( dist < bestDist ){
|
||||
bestDist = dist;
|
||||
snapTo = point.y();
|
||||
@@ -6254,7 +6254,7 @@ public:
|
||||
result.y() = ( result.y() - uv_origin.y() ) / ( uv_start.y() - uv_origin.y() );
|
||||
|
||||
if( snap )
|
||||
result.x() = fabs( result.y() );
|
||||
result.x() = std::fabs( result.y() );
|
||||
|
||||
/* prevent scaling to 0, limit at max 10 textures per world unit */
|
||||
if( vector3_length_squared( m_tex2local.y().vec3() * result.y() ) < .01 )
|
||||
@@ -6281,7 +6281,7 @@ public:
|
||||
float bestDist = FLT_MAX;
|
||||
float snapTo = 0;
|
||||
forEachUVPoint( [&]( const Vector3& point ){
|
||||
const float dist = fabs( point.x() - uv_current.x() );
|
||||
const float dist = std::fabs( point.x() - uv_current.x() );
|
||||
if( dist < bestDist ){
|
||||
bestDist = dist;
|
||||
snapTo = point.x();
|
||||
@@ -6294,7 +6294,7 @@ public:
|
||||
result.x() = ( result.x() - uv_origin.x() ) / ( uv_start.x() - uv_origin.x() );
|
||||
|
||||
if( snap )
|
||||
result.y() = fabs( result.x() );
|
||||
result.y() = std::fabs( result.x() );
|
||||
|
||||
/* prevent scaling to 0, limit at max 10 textures per world unit */
|
||||
if( vector3_length_squared( m_tex2local.x().vec3() * result.x() ) < .01 )
|
||||
@@ -6325,12 +6325,12 @@ public:
|
||||
float bestDistV = FLT_MAX;
|
||||
float snapToV = 0;
|
||||
forEachUVPoint( [&]( const Vector3& point ){
|
||||
const float distU = fabs( point.y() - uv_current.y() );
|
||||
const float distU = std::fabs( point.y() - uv_current.y() );
|
||||
if( distU < bestDistU ){
|
||||
bestDistU = distU;
|
||||
snapToU = point.y();
|
||||
}
|
||||
const float distV = fabs( point.x() - uv_current.x() );
|
||||
const float distV = std::fabs( point.x() - uv_current.x() );
|
||||
if( distV < bestDistV ){
|
||||
bestDistV = distV;
|
||||
snapToV = point.x();
|
||||
@@ -6349,7 +6349,7 @@ public:
|
||||
result.x() = ( result.x() - uv_origin.x() ) / ( uv_start.x() - uv_origin.x() );
|
||||
|
||||
if( snap ){
|
||||
const std::size_t best = fabs( result.x() ) > fabs( result.y() )? 0 : 1;
|
||||
const std::size_t best = std::fabs( result.x() ) > std::fabs( result.y() )? 0 : 1;
|
||||
result[( best + 1 ) % 2] = std::copysign( result[best], result[( best + 1 ) % 2] );
|
||||
}
|
||||
|
||||
@@ -6383,8 +6383,8 @@ public:
|
||||
float bestDist = FLT_MAX;
|
||||
Vector3 bestTo;
|
||||
const auto snap_to_edge = [&]( const Vector3 edge ){
|
||||
if( fabs( edge.y() ) > 1e-5 ){ // don't snap so, that one axis = the other
|
||||
const float dist = fabs( edge.x() * uv_y_measure_dist / edge.y() - skewed.x() * uv_y_measure_dist / skewed.y() );
|
||||
if( std::fabs( edge.y() ) > 1e-5f ){ // don't snap so, that one axis = the other
|
||||
const float dist = std::fabs( edge.x() * uv_y_measure_dist / edge.y() - skewed.x() * uv_y_measure_dist / skewed.y() );
|
||||
if( dist < bestDist ){
|
||||
bestDist = dist;
|
||||
bestTo = edge;
|
||||
@@ -6433,8 +6433,8 @@ public:
|
||||
float bestDist = FLT_MAX;
|
||||
Vector3 bestTo;
|
||||
const auto snap_to_edge = [&]( const Vector3 edge ){
|
||||
if( fabs( edge.x() ) > 1e-5 ){ // don't snap so, that one axis = the other
|
||||
const float dist = fabs( edge.y() * uv_x_measure_dist / edge.x() - skewed.y() * uv_x_measure_dist / skewed.x() );
|
||||
if( std::fabs( edge.x() ) > 1e-5f ){ // don't snap so, that one axis = the other
|
||||
const float dist = std::fabs( edge.y() * uv_x_measure_dist / edge.x() - skewed.y() * uv_x_measure_dist / skewed.x() );
|
||||
if( dist < bestDist ){
|
||||
bestDist = dist;
|
||||
bestTo = edge;
|
||||
@@ -6484,15 +6484,15 @@ public:
|
||||
const auto functor = [&]( const Vector3& point ){
|
||||
for( auto it = m_Ulines.m_lines.cbegin(); it != m_Ulines.m_lines.cend(); ++++it ){
|
||||
const float dist = point.y() - ( ( *it ).vertex.y() + uvmove.y() );
|
||||
if( fabs( dist ) < bestDistU ){
|
||||
bestDistU = fabs( dist );
|
||||
if( std::fabs( dist ) < bestDistU ){
|
||||
bestDistU = std::fabs( dist );
|
||||
snapMoveU = uvmove.y() + dist;
|
||||
}
|
||||
}
|
||||
for( auto it = m_Vlines.m_lines.cbegin(); it != m_Vlines.m_lines.cend(); ++++it ){
|
||||
const float dist = point.x() - ( ( *it ).vertex.x() + uvmove.x() );
|
||||
if( fabs( dist ) < bestDistV ){
|
||||
bestDistV = fabs( dist );
|
||||
if( std::fabs( dist ) < bestDistV ){
|
||||
bestDistV = std::fabs( dist );
|
||||
snapMoveV = uvmove.x() + dist;
|
||||
}
|
||||
}
|
||||
@@ -6509,8 +6509,8 @@ public:
|
||||
}
|
||||
|
||||
if( snap ){
|
||||
auto& smaller = fabs( uvmove.x() * vector3_length( m_faceTex2local.x().vec3() ) ) <
|
||||
fabs( uvmove.y() * vector3_length( m_faceTex2local.y().vec3() ) )? result.x() : result.y();
|
||||
auto& smaller = std::fabs( uvmove.x() * vector3_length( m_faceTex2local.x().vec3() ) ) <
|
||||
std::fabs( uvmove.y() * vector3_length( m_faceTex2local.y().vec3() ) )? result.x() : result.y();
|
||||
smaller = 0;
|
||||
}
|
||||
|
||||
@@ -6548,30 +6548,30 @@ public:
|
||||
for( std::size_t index : indices ){
|
||||
for( std::vector<PointVertex>::const_iterator i = m_Ulines.m_lines.begin(); i != m_Ulines.m_lines.end(); ++++i ){
|
||||
const float dist = m_patchCtrl[index].m_texcoord.y() + uvmove.y() - ( *i ).vertex.y();
|
||||
if( fabs( dist ) < bestDistU ){
|
||||
bestDistU = fabs( dist );
|
||||
if( std::fabs( dist ) < bestDistU ){
|
||||
bestDistU = std::fabs( dist );
|
||||
snapMoveU = uvmove.y() - dist;
|
||||
}
|
||||
}
|
||||
for( std::vector<PointVertex>::const_iterator i = m_Vlines.m_lines.begin(); i != m_Vlines.m_lines.end(); ++++i ){
|
||||
const float dist = m_patchCtrl[index].m_texcoord.x() + uvmove.x() - ( *i ).vertex.x();
|
||||
if( fabs( dist ) < bestDistV ){
|
||||
bestDistV = fabs( dist );
|
||||
if( std::fabs( dist ) < bestDistV ){
|
||||
bestDistV = std::fabs( dist );
|
||||
snapMoveV = uvmove.x() - dist;
|
||||
}
|
||||
}
|
||||
const Vector3 origin = matrix4_transformed_point( m_faceLocal2tex, m_origin );
|
||||
{
|
||||
const float dist = m_patchCtrl[index].m_texcoord.y() + uvmove.y() - origin.y();
|
||||
if( fabs( dist ) < bestDistU ){
|
||||
bestDistU = fabs( dist );
|
||||
if( std::fabs( dist ) < bestDistU ){
|
||||
bestDistU = std::fabs( dist );
|
||||
snapMoveU = uvmove.y() - dist;
|
||||
}
|
||||
}
|
||||
{
|
||||
const float dist = m_patchCtrl[index].m_texcoord.x() + uvmove.x() - origin.x();
|
||||
if( fabs( dist ) < bestDistV ){
|
||||
bestDistV = fabs( dist );
|
||||
if( std::fabs( dist ) < bestDistV ){
|
||||
bestDistV = std::fabs( dist );
|
||||
snapMoveV = uvmove.x() - dist;
|
||||
}
|
||||
}
|
||||
@@ -6586,8 +6586,8 @@ public:
|
||||
}
|
||||
|
||||
if( snap ){
|
||||
auto& smaller = fabs( uvmove.x() * vector3_length( m_faceTex2local.x().vec3() ) ) <
|
||||
fabs( uvmove.y() * vector3_length( m_faceTex2local.y().vec3() ) )? result.x() : result.y();
|
||||
auto& smaller = std::fabs( uvmove.x() * vector3_length( m_faceTex2local.x().vec3() ) ) <
|
||||
std::fabs( uvmove.y() * vector3_length( m_faceTex2local.y().vec3() ) )? result.x() : result.y();
|
||||
smaller = 0;
|
||||
}
|
||||
|
||||
@@ -6689,18 +6689,18 @@ public:
|
||||
|
||||
if( g_modifiers.shift() ){ // snap to axis
|
||||
for ( std::size_t i = 0; i < 3; ++i ){
|
||||
if( fabs( current[i] ) >= fabs( current[( i + 1 ) % 3] ) ){
|
||||
current[( i + 1 ) % 3] = 0.f;
|
||||
if( std::fabs( current[i] ) >= std::fabs( current[( i + 1 ) % 3] ) ){
|
||||
current[( i + 1 ) % 3] = 0;
|
||||
}
|
||||
else{
|
||||
current[i] = 0.f;
|
||||
current[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool set[3] = { true, true, true };
|
||||
for ( std::size_t i = 0; i < 3; ++i ){
|
||||
if( fabs( current[i] ) < 1e-3f ){
|
||||
if( std::fabs( current[i] ) < 1e-3f ){
|
||||
set[i] = false;
|
||||
}
|
||||
}
|
||||
@@ -7283,7 +7283,7 @@ public:
|
||||
|
||||
void SelectPoint( const View& view, const DeviceVector device_point, const DeviceVector device_epsilon, RadiantSelectionSystem::EModifier modifier, bool face ){
|
||||
//globalOutputStream() << device_point[0] << " " << device_point[1] << '\n';
|
||||
ASSERT_MESSAGE( fabs( device_point[0] ) <= 1.f && fabs( device_point[1] ) <= 1.f, "point-selection error" );
|
||||
ASSERT_MESSAGE( std::fabs( device_point[0] ) <= 1.f && std::fabs( device_point[1] ) <= 1.f, "point-selection error" );
|
||||
|
||||
if ( modifier == eReplace ) {
|
||||
deselectComponentsOrAll( face );
|
||||
@@ -7400,7 +7400,7 @@ public:
|
||||
|
||||
RadiantSelectionSystem::EModifier
|
||||
SelectPoint_InitPaint( const View& view, const DeviceVector device_point, const DeviceVector device_epsilon, bool face ){
|
||||
ASSERT_MESSAGE( fabs( device_point[0] ) <= 1.f && fabs( device_point[1] ) <= 1.f, "point-selection error" );
|
||||
ASSERT_MESSAGE( std::fabs( device_point[0] ) <= 1.f && std::fabs( device_point[1] ) <= 1.f, "point-selection error" );
|
||||
#if defined ( DEBUG_SELECTION )
|
||||
g_render_clipped.destroy();
|
||||
#endif
|
||||
@@ -8135,19 +8135,19 @@ void RadiantSelectionSystem::setCustomTransformOrigin( const Vector3& origin, co
|
||||
for( std::size_t i = 0; i < 3; ++i ){
|
||||
float value = origin[i];
|
||||
if( set[i] ){
|
||||
float bestsnapDist = fabs( m_bounds.origin[i] - value );
|
||||
float bestsnapDist = std::fabs( m_bounds.origin[i] - value );
|
||||
float bestsnapTo = m_bounds.origin[i];
|
||||
float othersnapDist = fabs( m_bounds.origin[i] + m_bounds.extents[i] - value );
|
||||
float othersnapDist = std::fabs( m_bounds.origin[i] + m_bounds.extents[i] - value );
|
||||
if( othersnapDist < bestsnapDist ){
|
||||
bestsnapDist = othersnapDist;
|
||||
bestsnapTo = m_bounds.origin[i] + m_bounds.extents[i];
|
||||
}
|
||||
othersnapDist = fabs( m_bounds.origin[i] - m_bounds.extents[i] - value );
|
||||
othersnapDist = std::fabs( m_bounds.origin[i] - m_bounds.extents[i] - value );
|
||||
if( othersnapDist < bestsnapDist ){
|
||||
bestsnapDist = othersnapDist;
|
||||
bestsnapTo = m_bounds.origin[i] - m_bounds.extents[i];
|
||||
}
|
||||
othersnapDist = fabs( float_snapped( value, GetSnapGridSize() ) - value );
|
||||
othersnapDist = std::fabs( float_snapped( value, GetSnapGridSize() ) - value );
|
||||
if( othersnapDist < bestsnapDist ){
|
||||
bestsnapDist = othersnapDist;
|
||||
bestsnapTo = float_snapped( value, GetSnapGridSize() );
|
||||
@@ -8679,7 +8679,7 @@ public:
|
||||
if( move > m_moveEpsilon )
|
||||
return true;
|
||||
const DeviceVector devicePosition( device( position ) );
|
||||
const float currentMove = std::max( fabs( devicePosition.x() - moveStart.x() ), fabs( devicePosition.y() - moveStart.y() ) );
|
||||
const float currentMove = std::max( std::fabs( devicePosition.x() - moveStart.x() ), std::fabs( devicePosition.y() - moveStart.y() ) );
|
||||
move = std::max( move, currentMove );
|
||||
// globalOutputStream() << move << " move\n";
|
||||
return move > m_moveEpsilon;
|
||||
|
||||
+1
-1
@@ -121,7 +121,7 @@ public:
|
||||
m_viewport = g_matrix4_identity;
|
||||
m_viewport[0] = float( width / 2 );
|
||||
m_viewport[5] = float( height / 2 );
|
||||
if ( fabs( m_projection[11] ) > 0.0000001 ) {
|
||||
if ( std::fabs( m_projection[11] ) > 0.0000001f ) {
|
||||
m_viewport[10] = m_projection[0] * m_viewport[0];
|
||||
}
|
||||
else{
|
||||
|
||||
+1
-1
@@ -129,7 +129,7 @@ void Winding_createInfinite( FixedWinding& winding, const Plane3& plane, double
|
||||
int x = -1;
|
||||
for ( int i = 0; i < 3; ++i )
|
||||
{
|
||||
double d = fabs( plane.normal()[i] );
|
||||
double d = std::fabs( plane.normal()[i] );
|
||||
if ( d > max ) {
|
||||
x = i;
|
||||
max = d;
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ enum ProjectionAxis
|
||||
const float ProjectionAxisEpsilon = static_cast<float>( 0.0001 );
|
||||
|
||||
inline bool projectionaxis_better( float axis, float other ){
|
||||
return fabs( axis ) > fabs( other ) + ProjectionAxisEpsilon;
|
||||
return std::fabs( axis ) > std::fabs( other ) + ProjectionAxisEpsilon;
|
||||
}
|
||||
|
||||
/// \brief Texture axis precedence: Z > X > Y
|
||||
|
||||
@@ -650,7 +650,7 @@ void XYWnd_OrientCamera( XYWnd* xywnd, int x, int y, CamWnd& camwnd ){
|
||||
if( angles[CAMERA_YAW] < 0 )
|
||||
angles[CAMERA_YAW] += 360;
|
||||
if ( nAngle == CAMERA_PITCH ){
|
||||
if( fabs( angles[CAMERA_PITCH] ) > 90 ){
|
||||
if( std::fabs( angles[CAMERA_PITCH] ) > 90 ){
|
||||
angles[CAMERA_PITCH] = ( angles[CAMERA_PITCH] > 0 ) ? ( -angles[CAMERA_PITCH] + 180 ) : ( -angles[CAMERA_PITCH] - 180 );
|
||||
if( viewtype == YZ ){
|
||||
if( angles[CAMERA_YAW] < 180 ){
|
||||
@@ -726,7 +726,7 @@ void XYWnd::NewBrushDrag( int x, int y, bool square, bool cube ){
|
||||
}
|
||||
|
||||
if( square || cube ){
|
||||
const float squaresize = std::max( fabs( maxs[nDim1] - mins[nDim1] ), fabs( maxs[nDim2] - mins[nDim2] ) );
|
||||
const float squaresize = std::max( std::fabs( maxs[nDim1] - mins[nDim1] ), std::fabs( maxs[nDim2] - mins[nDim2] ) );
|
||||
for( auto i : { nDim1, nDim2 } )
|
||||
maxs[i] = mins[i] + std::copysign( squaresize, maxs[i] - mins[i] );
|
||||
if( cube ){
|
||||
|
||||
@@ -149,7 +149,7 @@ winding_accu_t BaseWindingForPlaneAccu( const Plane3& plane ){
|
||||
|
||||
x = -1;
|
||||
for ( i = 0; i < 3; ++i ) {
|
||||
v = fabs( plane.normal()[i] );
|
||||
v = std::fabs( plane.normal()[i] );
|
||||
if ( v > max ) {
|
||||
x = i;
|
||||
max = v;
|
||||
@@ -245,7 +245,7 @@ winding_t BaseWindingForPlane( const Plane3f& plane ){
|
||||
x = -1;
|
||||
for ( i = 0; i < 3; ++i )
|
||||
{
|
||||
v = fabs( plane.normal()[i] );
|
||||
v = std::fabs( plane.normal()[i] );
|
||||
if ( v > max ) {
|
||||
x = i;
|
||||
max = v;
|
||||
@@ -658,7 +658,7 @@ void CheckWinding( const winding_t& w ){
|
||||
}
|
||||
|
||||
// check the point is on the face plane
|
||||
if ( fabs( plane3_distance_to_point( faceplane, p1 ) ) > ON_EPSILON ) {
|
||||
if ( std::fabs( plane3_distance_to_point( faceplane, p1 ) ) > ON_EPSILON ) {
|
||||
Error( "CheckWinding: point off plane" );
|
||||
}
|
||||
|
||||
|
||||
@@ -233,14 +233,14 @@ inline void ComputeAxisBase( const BasicVector3<Element>& normal, BasicVector3<O
|
||||
}
|
||||
#else
|
||||
/* do some cleaning */
|
||||
if ( fabs( normal[ 0 ] ) < 1e-6 ) {
|
||||
normal[ 0 ] = 0.0f;
|
||||
if ( std::fabs( normal[ 0 ] ) < 1e-6 ) {
|
||||
normal[ 0 ] = 0;
|
||||
}
|
||||
if ( fabs( normal[ 1 ] ) < 1e-6 ) {
|
||||
normal[ 1 ] = 0.0f;
|
||||
if ( std::fabs( normal[ 1 ] ) < 1e-6 ) {
|
||||
normal[ 1 ] = 0;
|
||||
}
|
||||
if ( fabs( normal[ 2 ] ) < 1e-6 ) {
|
||||
normal[ 2 ] = 0.0f;
|
||||
if ( std::fabs( normal[ 2 ] ) < 1e-6 ) {
|
||||
normal[ 2 ] = 0;
|
||||
}
|
||||
|
||||
/* compute the two rotations around y and z to rotate x to normal */
|
||||
|
||||
@@ -107,7 +107,7 @@ Vector3 SnapWeldVector( const Vector3& a, const Vector3& b ){
|
||||
}
|
||||
|
||||
/* use nearest */
|
||||
else if ( fabs( ai - a[ i ] ) < fabs( bi - b[ i ] ) ) {
|
||||
else if ( std::fabs( ai - a[ i ] ) < std::fabs( bi - b[ i ] ) ) {
|
||||
out[ i ] = a[ i ];
|
||||
}
|
||||
else{
|
||||
@@ -116,7 +116,7 @@ Vector3 SnapWeldVector( const Vector3& a, const Vector3& b ){
|
||||
|
||||
/* snap */
|
||||
const float outi = std::rint( out[ i ] );
|
||||
if ( fabs( outi - out[ i ] ) <= SNAP_EPSILON ) {
|
||||
if ( std::fabs( outi - out[ i ] ) <= SNAP_EPSILON ) {
|
||||
out[ i ] = outi;
|
||||
}
|
||||
}
|
||||
@@ -147,8 +147,8 @@ static DoubleVector3 SnapWeldVectorAccu( const DoubleVector3& a, const DoubleVec
|
||||
{
|
||||
const double ai = std::rint( a[i] );
|
||||
const double bi = std::rint( b[i] );
|
||||
const double ad = fabs( ai - a[i] );
|
||||
const double bd = fabs( bi - b[i] );
|
||||
const double ad = std::fabs( ai - a[i] );
|
||||
const double bd = std::fabs( bi - b[i] );
|
||||
|
||||
if ( ad < bd ) {
|
||||
if ( ad < SNAP_EPSILON ) {
|
||||
|
||||
@@ -420,7 +420,7 @@ int ScaleBSPMain( Args& args ){
|
||||
if ( a == -1 || a == -2 ) { // z scale
|
||||
axis = 2;
|
||||
}
|
||||
else if ( fabs( sin( degrees_to_radians( a ) ) ) < 0.707 ) {
|
||||
else if ( std::fabs( sin( degrees_to_radians( a ) ) ) < 0.707 ) {
|
||||
axis = 0;
|
||||
}
|
||||
else{
|
||||
|
||||
@@ -397,7 +397,7 @@ static void ConvertBrush( FILE *f, const bspModel_t& model, int bspBrushNum, con
|
||||
/* recheck and fix winding points, fails occur somehow */
|
||||
int match = 0;
|
||||
for ( const Vector3& p : buildSide.winding ){
|
||||
if ( fabs( plane3_distance_to_point( buildPlane.plane, p ) ) < distanceEpsilon ) {
|
||||
if ( std::fabs( plane3_distance_to_point( buildPlane.plane, p ) ) < distanceEpsilon ) {
|
||||
pts[ match ] = p;
|
||||
match++;
|
||||
/* got 3 fine points? */
|
||||
|
||||
@@ -83,7 +83,7 @@ static bool MakeTextureMatrix( decalProjector_t *dp, const Plane3f& projection,
|
||||
|
||||
/* calculate barycentric basis for the triangle */
|
||||
bb = ( b->st[ 0 ] - a->st[ 0 ] ) * ( c->st[ 1 ] - a->st[ 1 ] ) - ( c->st[ 0 ] - a->st[ 0 ] ) * ( b->st[ 1 ] - a->st[ 1 ] );
|
||||
if ( fabs( bb ) < 0.00000001 ) {
|
||||
if ( std::fabs( bb ) < 0.00000001 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ static bool MakeTextureMatrix( decalProjector_t *dp, const Plane3f& projection,
|
||||
for ( i = 0; i < 2; ++i )
|
||||
for ( j = 0; j < 3; ++j )
|
||||
dp->texMat[ i ][ j ] = lengths[ i ] != 0.0 ? ( axis[ i ][ j ] / lengths[ i ] ) : 0.0;
|
||||
//% dp->texMat[ i ][ j ] = fabs( vecs[ i ][ j ] ) > 0.0 ? ( 1.0 / vecs[ i ][ j ] ) : 0.0;
|
||||
//% dp->texMat[ i ][ j ] = std::fabs( vecs[ i ][ j ] ) > 0.0 ? ( 1.0 / vecs[ i ][ j ] ) : 0.0;
|
||||
//% dp->texMat[ i ][ j ] = axis[ i ][ j ] > 0.0 ? ( 1.0 / axis[ i ][ j ] ) : 0.0;
|
||||
|
||||
/* calculalate translation component */
|
||||
@@ -177,15 +177,15 @@ static bool MakeTextureMatrix( decalProjector_t *dp, const Plane3f& projection,
|
||||
/* walk deltas */
|
||||
for ( k = 0; k < 3; ++k )
|
||||
{
|
||||
if ( fabs( deltas[ k ][ j ] ) > delta &&
|
||||
fabs( texDeltas[ k ][ i ] ) > texDelta ) {
|
||||
if ( std::fabs( deltas[ k ][ j ] ) > delta &&
|
||||
std::fabs( texDeltas[ k ][ i ] ) > texDelta ) {
|
||||
delta = deltas[ k ][ j ];
|
||||
texDelta = texDeltas[ k ][ i ];
|
||||
}
|
||||
}
|
||||
|
||||
/* set texture matrix component */
|
||||
if ( fabs( delta ) > 0.0 ) {
|
||||
if ( std::fabs( delta ) > 0.0 ) {
|
||||
dp->texMat[ i ][ j ] = texDelta / delta;
|
||||
}
|
||||
else{
|
||||
@@ -447,7 +447,7 @@ void ProcessDecals(){
|
||||
};
|
||||
/* planar? (nuking this optimization as it doesn't work on non-rectangular quads) */
|
||||
if ( 0 && PlaneFromPoints( plane, dv[ 0 ]->xyz, dv[ 1 ]->xyz, dv[ 2 ]->xyz ) &&
|
||||
fabs( plane3_distance_to_point( plane, dv[ 1 ]->xyz ) ) <= PLANAR_EPSILON ) {
|
||||
std::fabs( plane3_distance_to_point( plane, dv[ 1 ]->xyz ) ) <= PLANAR_EPSILON ) {
|
||||
/* make a quad projector */
|
||||
MakeDecalProjector( p.shaderInfo, projection, distance, 4, dv );
|
||||
}
|
||||
|
||||
@@ -697,7 +697,7 @@ void RadLightForPatch( int num, int lightmapNum, rawLightmap_t *lm, const shader
|
||||
Plane3f plane;
|
||||
bool planar = PlaneFromPoints( plane, dv[ 0 ]->xyz, dv[ 1 ]->xyz, dv[ 2 ]->xyz );
|
||||
if ( planar ) {
|
||||
if ( fabs( plane3_distance_to_point( plane, dv[ 1 ]->xyz ) ) > PLANAR_EPSILON ) {
|
||||
if ( std::fabs( plane3_distance_to_point( plane, dv[ 1 ]->xyz ) ) > PLANAR_EPSILON ) {
|
||||
planar = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -521,13 +521,13 @@ static void FilterTraceWindingIntoNodes_r( traceWinding_t *tw, int nodeNum ){
|
||||
reverse = plane3_flipped( plane2 );
|
||||
|
||||
/* front only */
|
||||
if ( vector3_dot( plane1.normal(), plane2.normal() ) > 0.999f && fabs( plane1.dist() - plane2.dist() ) < 0.001f ) {
|
||||
if ( vector3_dot( plane1.normal(), plane2.normal() ) > 0.999f && std::fabs( plane1.dist() - plane2.dist() ) < 0.001f ) {
|
||||
FilterTraceWindingIntoNodes_r( tw, node->children[ 0 ] );
|
||||
return;
|
||||
}
|
||||
|
||||
/* back only */
|
||||
if ( vector3_dot( plane1.normal(), reverse.normal() ) > 0.999f && fabs( plane1.dist() - reverse.dist() ) < 0.001f ) {
|
||||
if ( vector3_dot( plane1.normal(), reverse.normal() ) > 0.999f && std::fabs( plane1.dist() - reverse.dist() ) < 0.001f ) {
|
||||
FilterTraceWindingIntoNodes_r( tw, node->children[ 1 ] );
|
||||
return;
|
||||
}
|
||||
@@ -1282,7 +1282,7 @@ static bool TraceTriangle( traceInfo_t *ti, traceTriangle_t *tt, trace_t *trace
|
||||
det = vector3_dot( tt->edge1, pvec );
|
||||
|
||||
/* the non-culling branch */
|
||||
if ( fabs( det ) < COPLANAR_EPSILON ) {
|
||||
if ( std::fabs( det ) < COPLANAR_EPSILON ) {
|
||||
return false;
|
||||
}
|
||||
invDet = 1.0f / det;
|
||||
|
||||
@@ -583,7 +583,7 @@ bool CalcTangentVectors( const std::array<const bspDrawVert_t *, numVerts>& dv,
|
||||
|
||||
/* calculate barycentric basis for the triangle */
|
||||
bb = ( dv[ 1 ]->st[ 0 ] - dv[ 0 ]->st[ 0 ] ) * ( dv[ 2 ]->st[ 1 ] - dv[ 0 ]->st[ 1 ] ) - ( dv[ 2 ]->st[ 0 ] - dv[ 0 ]->st[ 0 ] ) * ( dv[ 1 ]->st[ 1 ] - dv[ 0 ]->st[ 1 ] );
|
||||
if ( fabs( bb ) < 0.00000001f ) {
|
||||
if ( std::fabs( bb ) < 0.00000001f ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1116,7 +1116,7 @@ static bool MapQuad( rawLightmap_t *lm, const surfaceInfo_t *info, const QuadRef
|
||||
}
|
||||
|
||||
/* 4th point must fall on the plane */
|
||||
if ( fabs( plane3_distance_to_point( plane, quad[ 3 ]->xyz ) ) > QUAD_PLANAR_EPSILON ) {
|
||||
if ( std::fabs( plane3_distance_to_point( plane, quad[ 3 ]->xyz ) ) > QUAD_PLANAR_EPSILON ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -696,9 +696,9 @@ static bool AddSurfaceToRawLightmap( int num, rawLightmap_t& lm ){
|
||||
origin = lm.minmax.mins;
|
||||
|
||||
/* make absolute axis */
|
||||
faxis[ 0 ] = fabs( lm.axis[ 0 ] );
|
||||
faxis[ 1 ] = fabs( lm.axis[ 1 ] );
|
||||
faxis[ 2 ] = fabs( lm.axis[ 2 ] );
|
||||
faxis[ 0 ] = std::fabs( lm.axis[ 0 ] );
|
||||
faxis[ 1 ] = std::fabs( lm.axis[ 1 ] );
|
||||
faxis[ 2 ] = std::fabs( lm.axis[ 2 ] );
|
||||
|
||||
/* clear out lightmap vectors */
|
||||
memset( vecs, 0, sizeof( vecs ) );
|
||||
@@ -1392,7 +1392,7 @@ static bool CompareBSPLuxels( rawLightmap_t *a, int aNum, rawLightmap_t *b, int
|
||||
/* compare (fixme: take into account perceptual differences) */
|
||||
Vector3 diff = aLuxel - bLuxel;
|
||||
for( int i = 0; i < 3; ++i )
|
||||
diff[i] = fabs( diff[i] );
|
||||
diff[i] = std::fabs( diff[i] );
|
||||
delta += vector3_dot( diff, Vector3( LUXEL_COLOR_FRAC ) );
|
||||
|
||||
/* is the change too high? */
|
||||
|
||||
+18
-18
@@ -67,10 +67,10 @@ bool PlaneEqual( const plane_t& p, const Plane3f& plane ){
|
||||
// (the epsilons may be zero). We want to use '<' instead of '<=' to be
|
||||
// consistent with the true meaning of "epsilon", and also because other
|
||||
// parts of the code uses this inequality.
|
||||
if ( ( p.dist() == plane.dist() || fabs( p.dist() - plane.dist() ) < de ) &&
|
||||
( p.normal()[0] == plane.normal()[0] || fabs( p.normal()[0] - plane.normal()[0] ) < ne ) &&
|
||||
( p.normal()[1] == plane.normal()[1] || fabs( p.normal()[1] - plane.normal()[1] ) < ne ) &&
|
||||
( p.normal()[2] == plane.normal()[2] || fabs( p.normal()[2] - plane.normal()[2] ) < ne ) ) {
|
||||
if ( ( p.dist() == plane.dist() || std::fabs( p.dist() - plane.dist() ) < de ) &&
|
||||
( p.normal()[0] == plane.normal()[0] || std::fabs( p.normal()[0] - plane.normal()[0] ) < ne ) &&
|
||||
( p.normal()[1] == plane.normal()[1] || std::fabs( p.normal()[1] - plane.normal()[1] ) < ne ) &&
|
||||
( p.normal()[2] == plane.normal()[2] || std::fabs( p.normal()[2] - plane.normal()[2] ) < ne ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ bool PlaneEqual( const plane_t& p, const Plane3f& plane ){
|
||||
*/
|
||||
|
||||
inline void AddPlaneToHash( plane_t& p ){
|
||||
const int hash = ( PLANE_HASHES - 1 ) & (int) fabs( p.dist() );
|
||||
const int hash = ( PLANE_HASHES - 1 ) & (int) std::fabs( p.dist() );
|
||||
|
||||
p.hash_chain = planehash[hash];
|
||||
planehash[hash] = &p - mapplanes.data() + 1;
|
||||
@@ -152,16 +152,16 @@ static bool SnapNormal( Vector3& normal ){
|
||||
//they cause precision errors
|
||||
|
||||
|
||||
if ( ( normal[0] != 0.0 || normal[1] != 0.0 ) && fabs( normal[0] ) < 0.00025 && fabs( normal[1] ) < 0.00025){
|
||||
normal[0] = normal[1] = 0.0;
|
||||
if ( ( normal[0] != 0 || normal[1] != 0 ) && std::fabs( normal[0] ) < 0.00025f && std::fabs( normal[1] ) < 0.00025f ){
|
||||
normal[0] = normal[1] = 0;
|
||||
adjusted = true;
|
||||
}
|
||||
else if ( ( normal[0] != 0.0 || normal[2] != 0.0 ) && fabs( normal[0] ) < 0.00025 && fabs( normal[2] ) < 0.00025){
|
||||
normal[0] = normal[2] = 0.0;
|
||||
else if ( ( normal[0] != 0 || normal[2] != 0 ) && std::fabs( normal[0] ) < 0.00025f && std::fabs( normal[2] ) < 0.00025f ){
|
||||
normal[0] = normal[2] = 0;
|
||||
adjusted = true;
|
||||
}
|
||||
else if ( ( normal[2] != 0.0 || normal[1] != 0.0 ) && fabs( normal[2] ) < 0.00025 && fabs( normal[1] ) < 0.00025){
|
||||
normal[2] = normal[1] = 0.0;
|
||||
else if ( ( normal[2] != 0 || normal[1] != 0 ) && std::fabs( normal[2] ) < 0.00025f && std::fabs( normal[1] ) < 0.00025f ){
|
||||
normal[2] = normal[1] = 0;
|
||||
adjusted = true;
|
||||
}
|
||||
|
||||
@@ -237,12 +237,12 @@ static bool SnapNormal( Vector3& normal ){
|
||||
|
||||
for ( i = 0; i < 3; ++i )
|
||||
{
|
||||
if ( fabs( normal[ i ] - 1 ) < normalEpsilon ) {
|
||||
if ( std::fabs( normal[ i ] - 1 ) < normalEpsilon ) {
|
||||
normal.set( 0 );
|
||||
normal[ i ] = 1;
|
||||
return true;
|
||||
}
|
||||
if ( fabs( normal[ i ] - -1 ) < normalEpsilon ) {
|
||||
if ( std::fabs( normal[ i ] - -1 ) < normalEpsilon ) {
|
||||
normal.set( 0 );
|
||||
normal[ i ] = -1;
|
||||
return true;
|
||||
@@ -290,7 +290,7 @@ static void SnapPlane( Plane3f& plane ){
|
||||
// solve so that we can better engineer it (I'm not saying that SnapPlane()
|
||||
// should be removed altogether). Fix all this snapping code at some point!
|
||||
|
||||
if ( fabs( plane.dist() - std::rint( plane.dist() ) ) < distanceEpsilon ) {
|
||||
if ( std::fabs( plane.dist() - std::rint( plane.dist() ) ) < distanceEpsilon ) {
|
||||
plane.dist() = std::rint( plane.dist() );
|
||||
}
|
||||
}
|
||||
@@ -343,7 +343,7 @@ int FindFloatPlane( const Plane3f& inplane, int numPoints, const Vector3 *points
|
||||
SnapPlane( plane );
|
||||
#endif
|
||||
/* hash the plane */
|
||||
const int hash = ( PLANE_HASHES - 1 ) & (int) fabs( plane.dist() );
|
||||
const int hash = ( PLANE_HASHES - 1 ) & (int) std::fabs( plane.dist() );
|
||||
|
||||
/* search the border bins as well */
|
||||
for ( int i = -1; i <= 1; ++i )
|
||||
@@ -370,7 +370,7 @@ int FindFloatPlane( const Plane3f& inplane, int numPoints, const Vector3 *points
|
||||
// very small when world coordinates extend to 2^16. Making the
|
||||
// dot product here in 64 bit land will not really help the situation
|
||||
// because the error will already be carried in dist.
|
||||
const double d = fabs( plane3_distance_to_point( p.plane, points[ j ] ) );
|
||||
const double d = std::fabs( plane3_distance_to_point( p.plane, points[ j ] ) );
|
||||
if ( d != 0.0 && d >= distanceEpsilon ) {
|
||||
break; // Point is too far from plane.
|
||||
}
|
||||
@@ -411,7 +411,7 @@ int FindFloatPlane( const Plane3f& inplane, int numPoints, const Vector3 *points
|
||||
/* ydnar: test supplied points against this plane */
|
||||
for ( j = 0; j < numPoints; ++j )
|
||||
{
|
||||
if ( fabs( plane3_distance_to_point( p->plane, points[ j ] ) ) > distanceEpsilon ) {
|
||||
if ( std::fabs( plane3_distance_to_point( p->plane, points[ j ] ) ) > distanceEpsilon ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -632,7 +632,7 @@ void AddBrushBevels(){
|
||||
/* handle bevel surfaceflags */
|
||||
for ( const side_t& side : sides ) {
|
||||
for ( const Vector3& point : side.winding ) {
|
||||
if ( fabs( plane.dist() - point[axis] ) < .1f ) {
|
||||
if ( std::fabs( plane.dist() - point[axis] ) < .1f ) {
|
||||
s.surfaceFlags |= ( side.surfaceFlags & surfaceFlagsMask );
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -375,7 +375,7 @@ inline void nonax_clip_dbg( const Plane3f (&p)[3] ){
|
||||
for ( int j = 0; j < 3; ++j ){
|
||||
for ( int k = 0; k < 3; ++k ){
|
||||
const Vector3& n = p[j].normal();
|
||||
if ( fabs( n[k] ) < 0.00025 && n[k] != 0 ){
|
||||
if ( std::fabs( n[k] ) < 0.00025f && n[k] != 0 ){
|
||||
Sys_Printf( "nonax nrm %6.17f %6.17f %6.17f\n", n[0], n[1], n[2] );
|
||||
}
|
||||
}
|
||||
@@ -513,8 +513,8 @@ static void ClipModel( int spawnFlags, float clipDepth, shaderInfo_t& si, const
|
||||
bool snpd = false;
|
||||
for ( j = 0; j < 3; ++j )
|
||||
{
|
||||
if ( fabs( plane.normal()[j] ) < 0.00025 && fabs( plane.normal()[( j + 1) % 3] ) < 0.00025
|
||||
&& ( plane.normal()[j] != 0.0 || plane.normal()[( j + 1 ) % 3] != 0.0 ) ){
|
||||
if ( std::fabs( plane.normal()[j] ) < 0.00025f && std::fabs( plane.normal()[( j + 1) % 3] ) < 0.00025f
|
||||
&& ( plane.normal()[j] != 0 || plane.normal()[( j + 1 ) % 3] != 0 ) ){
|
||||
const Vector3 cnt = ( points[0] + points[1] + points[2] ) / 3.0;
|
||||
points[0][( j + 2 ) % 3] = points[1][( j + 2 ) % 3] = points[2][( j + 2 ) % 3] = cnt[( j + 2 ) % 3];
|
||||
snpd = true;
|
||||
@@ -528,7 +528,7 @@ static void ClipModel( int spawnFlags, float clipDepth, shaderInfo_t& si, const
|
||||
const Vector3 nrm = VectorNormalized( points[j] - points[( j + 1 ) % 3] );
|
||||
for ( k = 0; k < 3; ++k )
|
||||
{
|
||||
if ( nrm[k] != 0.0 && fabs( nrm[k] ) < 0.00025 ){
|
||||
if ( nrm[k] != 0 && std::fabs( nrm[k] ) < 0.00025f ){
|
||||
//Sys_Printf( "b4(%6.6f %6.6f %6.6f)(%6.6f %6.6f %6.6f)\n", points[j][0], points[j][1], points[j][2], points[(j+1)%3][0], points[(j+1)%3][1], points[(j+1)%3][2] );
|
||||
points[j][k] = points[( j + 1 ) % 3][k] = ( points[j][k] + points[( j + 1 ) % 3][k] ) / 2.0;
|
||||
//Sys_Printf( "sn(%6.6f %6.6f %6.6f)(%6.6f %6.6f %6.6f)\n", points[j][0], points[j][1], points[j][2], points[(j+1)%3][0], points[(j+1)%3][1], points[(j+1)%3][2] );
|
||||
@@ -545,8 +545,8 @@ static void ClipModel( int spawnFlags, float clipDepth, shaderInfo_t& si, const
|
||||
//vector-is-close-to-be-on-axis check again, happens after previous code sometimes
|
||||
for ( j = 0; j < 3; ++j )
|
||||
{
|
||||
if ( fabs( plane.normal()[j] ) < 0.00025 && fabs( plane.normal()[( j + 1 ) % 3] ) < 0.00025
|
||||
&& ( plane.normal()[j] != 0.0 || plane.normal()[( j + 1 ) % 3] != 0.0 ) ){
|
||||
if ( std::fabs( plane.normal()[j] ) < 0.00025f && std::fabs( plane.normal()[( j + 1 ) % 3] ) < 0.00025f
|
||||
&& ( plane.normal()[j] != 0 || plane.normal()[( j + 1 ) % 3] != 0 ) ){
|
||||
const Vector3 cnt = ( points[0] + points[1] + points[2] ) / 3.0;
|
||||
points[0][( j + 2 ) % 3] = points[1][( j + 2 ) % 3] = points[2][( j + 2 ) % 3] = cnt[( j + 2 ) % 3];
|
||||
PlaneFromPoints( plane, points );
|
||||
@@ -557,7 +557,7 @@ static void ClipModel( int spawnFlags, float clipDepth, shaderInfo_t& si, const
|
||||
//snap single snappable normal components
|
||||
for ( j = 0; j < 3; ++j )
|
||||
{
|
||||
if ( plane.normal()[j] != 0 && fabs( plane.normal()[j] ) < 0.00005 ){
|
||||
if ( plane.normal()[j] != 0 && std::fabs( plane.normal()[j] ) < 0.00005f ){
|
||||
plane.normal()[j] = 0;
|
||||
snpd = true;
|
||||
}
|
||||
@@ -592,7 +592,7 @@ static void ClipModel( int spawnFlags, float clipDepth, shaderInfo_t& si, const
|
||||
if ( spf == ( ePyramidaClip | eAxialBackplane ) ){ // pyramid with 3 of 4 sides axial (->small bsp)
|
||||
|
||||
for ( j = 0; j < 3; ++j )
|
||||
if ( fabs( plane.normal()[j] ) < 0.05 && fabs( plane.normal()[( j + 1 ) % 3] ) < 0.05 ) //no way, close to lay on two axes
|
||||
if ( std::fabs( plane.normal()[j] ) < 0.05f && std::fabs( plane.normal()[( j + 1 ) % 3] ) < 0.05f ) //no way, close to lay on two axes
|
||||
goto default_CLIPMODEL;
|
||||
|
||||
// best axial normal
|
||||
@@ -774,7 +774,7 @@ static void ClipModel( int spawnFlags, float clipDepth, shaderInfo_t& si, const
|
||||
snpd = false;
|
||||
for ( k = 0; k < 3; ++k )
|
||||
{
|
||||
if ( fabs( p[j].normal()[k] ) < 0.00025 && p[j].normal()[k] != 0.0 ){
|
||||
if ( std::fabs( p[j].normal()[k] ) < 0.00025f && p[j].normal()[k] != 0 ){
|
||||
p[j].normal()[k] = 0.0;
|
||||
snpd = true;
|
||||
}
|
||||
@@ -831,7 +831,7 @@ static void ClipModel( int spawnFlags, float clipDepth, shaderInfo_t& si, const
|
||||
snpd = false;
|
||||
for ( k = 0; k < 3; ++k )
|
||||
{
|
||||
if ( fabs( p[j].normal()[k] ) < 0.00025 && p[j].normal()[k] != 0.0 ){
|
||||
if ( std::fabs( p[j].normal()[k] ) < 0.00025f && p[j].normal()[k] != 0 ){
|
||||
//Sys_Printf( "init plane %6.8f %6.8f %6.8f %6.8f\n", p[j].a, p[j].b, p[j].c, p[j].d );
|
||||
p[j].normal()[k] = 0.0;
|
||||
snpd = true;
|
||||
@@ -864,7 +864,7 @@ static void ClipModel( int spawnFlags, float clipDepth, shaderInfo_t& si, const
|
||||
snpd = false;
|
||||
for ( k = 0; k < 3; ++k )
|
||||
{
|
||||
if ( fabs( p[j].normal()[k] ) < 0.00025 && p[j].normal()[k] != 0.0 ){
|
||||
if ( std::fabs( p[j].normal()[k] ) < 0.00025f && p[j].normal()[k] != 0 ){
|
||||
//Sys_Printf( "init plane %6.8f %6.8f %6.8f %6.8f\n", p[j].a, p[j].b, p[j].c, p[j].d );
|
||||
p[j].normal()[k] = 0.0;
|
||||
snpd = true;
|
||||
@@ -903,15 +903,15 @@ static void ClipModel( int spawnFlags, float clipDepth, shaderInfo_t& si, const
|
||||
PlaneFromPoints( p[2], points[0], points[2], cnt ) ) {
|
||||
|
||||
//check for dangerous planes
|
||||
while( ( ( p[0].a != 0.0 || p[0].b != 0.0 ) && fabs( p[0].a ) < 0.00025 && fabs( p[0].b ) < 0.00025 ) ||
|
||||
( ( p[0].a != 0.0 || p[0].c != 0.0 ) && fabs( p[0].a ) < 0.00025 && fabs( p[0].c ) < 0.00025 ) ||
|
||||
( ( p[0].c != 0.0 || p[0].b != 0.0 ) && fabs( p[0].c ) < 0.00025 && fabs( p[0].b ) < 0.00025 ) ||
|
||||
( ( p[1].a != 0.0 || p[1].b != 0.0 ) && fabs( p[1].a ) < 0.00025 && fabs( p[1].b ) < 0.00025 ) ||
|
||||
( ( p[1].a != 0.0 || p[1].c != 0.0 ) && fabs( p[1].a ) < 0.00025 && fabs( p[1].c ) < 0.00025 ) ||
|
||||
( ( p[1].c != 0.0 || p[1].b != 0.0 ) && fabs( p[1].c ) < 0.00025 && fabs( p[1].b ) < 0.00025 ) ||
|
||||
( ( p[2].a != 0.0 || p[2].b != 0.0 ) && fabs( p[2].a ) < 0.00025 && fabs( p[2].b ) < 0.00025 ) ||
|
||||
( ( p[2].a != 0.0 || p[2].c != 0.0 ) && fabs( p[2].a ) < 0.00025 && fabs( p[2].c ) < 0.00025 ) ||
|
||||
( ( p[2].c != 0.0 || p[2].b != 0.0 ) && fabs( p[2].c ) < 0.00025 && fabs( p[2].b ) < 0.00025 ) ) {
|
||||
while( ( ( p[0].a != 0 || p[0].b != 0 ) && std::fabs( p[0].a ) < 0.00025f && std::fabs( p[0].b ) < 0.00025f ) ||
|
||||
( ( p[0].a != 0 || p[0].c != 0 ) && std::fabs( p[0].a ) < 0.00025f && std::fabs( p[0].c ) < 0.00025f ) ||
|
||||
( ( p[0].c != 0 || p[0].b != 0 ) && std::fabs( p[0].c ) < 0.00025f && std::fabs( p[0].b ) < 0.00025f ) ||
|
||||
( ( p[1].a != 0 || p[1].b != 0 ) && std::fabs( p[1].a ) < 0.00025f && std::fabs( p[1].b ) < 0.00025f ) ||
|
||||
( ( p[1].a != 0 || p[1].c != 0 ) && std::fabs( p[1].a ) < 0.00025f && std::fabs( p[1].c ) < 0.00025f ) ||
|
||||
( ( p[1].c != 0 || p[1].b != 0 ) && std::fabs( p[1].c ) < 0.00025f && std::fabs( p[1].b ) < 0.00025f ) ||
|
||||
( ( p[2].a != 0 || p[2].b != 0 ) && std::fabs( p[2].a ) < 0.00025f && std::fabs( p[2].b ) < 0.00025f ) ||
|
||||
( ( p[2].a != 0 || p[2].c != 0 ) && std::fabs( p[2].a ) < 0.00025f && std::fabs( p[2].c ) < 0.00025f ) ||
|
||||
( ( p[2].c != 0 || p[2].b != 0 ) && std::fabs( p[2].c ) < 0.00025f && std::fabs( p[2].b ) < 0.00025f ) ) {
|
||||
cnt -= plane.normal() * 0.1f;
|
||||
// Sys_Printf( "shifting pyramid point\n" );
|
||||
PlaneFromPoints( p[0], points[1], points[0], cnt );
|
||||
|
||||
@@ -52,7 +52,7 @@ int num_solidfaces;
|
||||
}
|
||||
|
||||
inline void WriteFloat( FILE *f, float v ){
|
||||
if ( fabs( v - std::rint( v ) ) < 0.001 ) {
|
||||
if ( std::fabs( v - std::rint( v ) ) < 0.001f ) {
|
||||
fprintf( f, "%li ", std::lrint( v ) );
|
||||
}
|
||||
else{
|
||||
|
||||
@@ -286,9 +286,9 @@ Vector3 CalcLightmapAxis( const Vector3& normal ){
|
||||
}
|
||||
|
||||
/* get absolute normal */
|
||||
const Vector3 absolute( fabs( normal[ 0 ] ),
|
||||
fabs( normal[ 1 ] ),
|
||||
fabs( normal[ 2 ] ) );
|
||||
const Vector3 absolute( std::fabs( normal[ 0 ] ),
|
||||
std::fabs( normal[ 1 ] ),
|
||||
std::fabs( normal[ 2 ] ) );
|
||||
|
||||
/* test and return */
|
||||
if ( absolute[ 2 ] > absolute[ 0 ] - 0.0001f && absolute[ 2 ] > absolute[ 1 ] - 0.0001f ) {
|
||||
@@ -401,10 +401,10 @@ void ClassifySurface( mapDrawSurface_t& ds ){
|
||||
for ( const bspDrawVert_t& vert : Span( ds.verts, ds.numVerts ) )
|
||||
{
|
||||
/* point-plane test */
|
||||
if ( fabs( plane3_distance_to_point( plane, vert.xyz ) ) > PLANAR_EPSILON ) {
|
||||
if ( std::fabs( plane3_distance_to_point( plane, vert.xyz ) ) > PLANAR_EPSILON ) {
|
||||
//% if( ds.planeNum >= 0 )
|
||||
//% {
|
||||
//% Sys_Warning( "Planar surface marked unplanar (%f > %f)\n", fabs( dist ), PLANAR_EPSILON );
|
||||
//% Sys_Warning( "Planar surface marked unplanar (%f > %f)\n", std::fabs( dist ), PLANAR_EPSILON );
|
||||
//% ds.verts[ i ].color[ 0 ][ 0 ] = ds.verts[ i ].color[ 0 ][ 2 ] = 0;
|
||||
//% }
|
||||
ds.planar = false;
|
||||
@@ -921,7 +921,7 @@ mapDrawSurface_t *DrawSurfaceForMesh( const entity_t& e, parseMesh_t& p, mesh_t
|
||||
}
|
||||
|
||||
/* point-plane test */
|
||||
if ( fabs( plane3_distance_to_point( plane, mesh->verts[ i ].xyz ) ) > EQUAL_EPSILON ) {
|
||||
if ( std::fabs( plane3_distance_to_point( plane, mesh->verts[ i ].xyz ) ) > EQUAL_EPSILON ) {
|
||||
planar = false;
|
||||
}
|
||||
}
|
||||
@@ -1740,10 +1740,10 @@ static int FilterWindingIntoTree_r( winding_t& w, mapDrawSurface_t& ds, node_t *
|
||||
const Plane3f reverse = plane3_flipped( plane2 );
|
||||
|
||||
/* compare planes */
|
||||
if ( vector3_dot( plane1.normal(), plane2.normal() ) > 0.999f && fabs( plane1.dist() - plane2.dist() ) < 0.001f ) {
|
||||
if ( vector3_dot( plane1.normal(), plane2.normal() ) > 0.999f && std::fabs( plane1.dist() - plane2.dist() ) < 0.001f ) {
|
||||
return FilterWindingIntoTree_r( w, ds, node->children[ 0 ] );
|
||||
}
|
||||
if ( vector3_dot( plane1.normal(), reverse.normal() ) > 0.999f && fabs( plane1.dist() - reverse.dist() ) < 0.001f ) {
|
||||
if ( vector3_dot( plane1.normal(), reverse.normal() ) > 0.999f && std::fabs( plane1.dist() - reverse.dist() ) < 0.001f ) {
|
||||
return FilterWindingIntoTree_r( w, ds, node->children[ 1 ] );
|
||||
}
|
||||
#else
|
||||
|
||||
@@ -1037,7 +1037,7 @@ void FixMetaTJunctions(){
|
||||
const Vector3 pt = metaVerts[ j ].xyz;
|
||||
|
||||
/* determine if point lies in the triangle's plane */
|
||||
if ( fabs( plane3_distance_to_point( plane, pt ) ) > TJ_PLANE_EPSILON ) {
|
||||
if ( std::fabs( plane3_distance_to_point( plane, pt ) ) > TJ_PLANE_EPSILON ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1056,12 +1056,12 @@ void FixMetaTJunctions(){
|
||||
for ( k = 0; k < 3; ++k )
|
||||
{
|
||||
/* ignore bogus edges */
|
||||
if ( fabs( edges[ k ].kingpinLength ) < TJ_EDGE_EPSILON ) {
|
||||
if ( std::fabs( edges[ k ].kingpinLength ) < TJ_EDGE_EPSILON ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* determine if point lies on the edge */
|
||||
if ( fabs( plane3_distance_to_point( edges[ k ].plane, pt ) ) > TJ_EDGE_EPSILON ) {
|
||||
if ( std::fabs( plane3_distance_to_point( edges[ k ].plane, pt ) ) > TJ_EDGE_EPSILON ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ static int AddEdge( bspDrawVert_t& dv1, bspDrawVert_t& dv2, bool createNonAxial
|
||||
}
|
||||
|
||||
if ( !createNonAxial ) {
|
||||
if ( fabs( dir[0] + dir[1] + dir[2] ) != 1.0 ) {
|
||||
if ( std::fabs( dir[0] + dir[1] + dir[2] ) != 1.f ) {
|
||||
originalEdges.push_back( originalEdge_t{ .length = d, .dv1 = &dv1, .dv2 = &dv2 } );
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -530,10 +530,10 @@ static fixedWinding_t *TryMergeWinding( fixedWinding_t *f1, fixedWinding_t *f2,
|
||||
p4 = &f2->points[( j + 1 ) % f2->numpoints];
|
||||
for ( k = 0; k < 3; ++k )
|
||||
{
|
||||
if ( fabs( ( *p1 )[k] - ( *p4 )[k] ) > 0.1 ) { //EQUAL_EPSILON) //ME
|
||||
if ( std::fabs( ( *p1 )[k] - ( *p4 )[k] ) > 0.1f ) { //EQUAL_EPSILON) //ME
|
||||
break;
|
||||
}
|
||||
if ( fabs( ( *p2 )[k] - ( *p3 )[k] ) > 0.1 ) { //EQUAL_EPSILON) //ME
|
||||
if ( std::fabs( ( *p2 )[k] - ( *p3 )[k] ) > 0.1f ) { //EQUAL_EPSILON) //ME
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user