MergeMetaTriangles: epsilon compare st, improves merging imprecise sts, e.g. for nonplanar surfaces after q3map_tcgen or just brush face texture projection

This commit is contained in:
Garux 2021-09-03 06:23:40 +03:00
parent d113eed245
commit bafb339c09
2 changed files with 20 additions and 1 deletions

View File

@ -123,6 +123,25 @@ inline Element float_mod( const Element& self, const ModulusElement& modulus ){
}
template<typename Element, typename OtherElement>
inline bool vector2_equal( const BasicVector2<Element>& self, const BasicVector2<OtherElement>& other ){
return self.x() == other.x() && self.y() == other.y();
}
template<typename Element, typename OtherElement>
inline bool operator==( const BasicVector2<Element>& self, const BasicVector2<OtherElement>& other ){
return vector2_equal( self, other );
}
template<typename Element, typename OtherElement>
inline bool operator!=( const BasicVector2<Element>& self, const BasicVector2<OtherElement>& other ){
return !vector2_equal( self, other );
}
template<typename Element, typename OtherElement, typename Epsilon>
inline bool vector2_equal_epsilon( const BasicVector2<Element>& self, const BasicVector2<OtherElement>& other, Epsilon epsilon ){
return float_equal_epsilon( self.x(), other.x(), epsilon )
&& float_equal_epsilon( self.y(), other.y(), epsilon );
}
template<typename Element, typename OtherElement>
inline BasicVector2<Element> vector2_added( const BasicVector2<Element>& self, const BasicVector2<OtherElement>& other ){
return BasicVector2<Element>(

View File

@ -1297,7 +1297,7 @@ int AddMetaVertToSurface( mapDrawSurface_t *ds, const bspDrawVert_t& dv1, const
( *coincident )++;
/* compare texture coordinates and color */
if ( dv1.st[ 0 ] != dv2.st[ 0 ] || dv1.st[ 1 ] != dv2.st[ 1 ] ) {
if ( !vector2_equal_epsilon( dv1.st, dv2.st, 1e-4f ) ) {
continue;
}
if ( dv1.color[ 0 ].alpha() != dv2.color[ 0 ].alpha() ) {