This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
reference_triangle operator[] ( std::size_t idx ) { | |
switch ( topology ) { | |
case PrimitiveTopology::TriangleList: | |
idx /= 3; | |
return reference_triangle( vertices[ indices[ idx ] ], vertices[ indices[ idx + 1 ] ], vertices[ indices[ idx + 2 ] ] ); | |
break; | |
case PrimitiveTopology::TriangleStrip: | |
idx += 2; | |
return reference_triangle( vertices[ indices[ idx ] ], vertices[ indices[ idx - 1 ] ], vertices[ indices[ idx - 2 ] ] ); | |
break; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
namespace Furrovine { | |
#ifdef _MSC_VER | |
#define unreachable __assume( 0 ) | |
#elif _GCC_VER | |
#define unreachable __builtin_unreachable( ) | |
#else | |
#error Define unreachable for this platform |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename TString, typename ...Tn> | |
inline typename unqualified<TString>::type Format( TString&& format, Tn&&... argn ) { | |
typedef typename unqualified<TString>::type string_t; | |
const static ulword arg_count = sizeof...( Tn ); | |
if ( arg_count < 1 ) { | |
return std::forward<TString>( format ); | |
} | |
std::array<string_t, sizeof...( Tn )> convertedvalues = { | |
Convert::ToString( std::forward<Tn>( argn ) )... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename T> | |
Fur::optional<RHit<T>> intersect( const Fur::TRay3<T>& ray, const RSphere<T>& target ) { | |
Fur::TVector3<T> ray2sphere = target.position - ray.Origin; | |
T dist = ray2sphere.Dot( ray.Direction ); | |
T ray2spheresquared = ray2sphere.Dot( ray2sphere ); | |
T radiussquared = Radius * Radius; | |
if ( dist < 0 | |
&& ray2spheresquared > radiussquared ) { | |
return nullopt; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float4x4 ViewProjection; | |
texture Tex0; | |
sampler Texture0; | |
void ImageVertex ( inout float4 position : SV_Position, | |
inout float4 color : COLOR0, | |
inout float2 tex : TEXCOORD0 ) { | |
position = mul(position, ViewProjection); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename T, typename TValue, typename TIntermediate = double> | |
T color_normalize( TValue value, TValue valuemax = color_limits<TValue>::max( ), TValue valuemin = color_limits<TValue>::max( ), T max = color_limits<T>::max( ), T min = color_limits<T>::min( ) ) { | |
TIntermediate valuerange = static_cast<TIntermediate>( value - valuemin ) / static_cast<TIntermediate>( valuemax ); | |
return static_cast<T>( valuerange * ( max - min ) ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename T, ulword n, typename Tw> | |
RVector<T, n> lerp( const RVector<T, n>& from, const RVector<T, n>& towards, Tw weight ) { | |
weight = Mathema<Tw>::MiniMax( weight, static_cast<Tw>( 0 ), static_cast<Tw>( 1 ) ); | |
Tw affweight = 1.0f - weight; | |
RVector<T, n> r; | |
for ( ulword i = 0; i < n; ++i ) { | |
r[ i ] = static_cast<T>( from[i] * weight + affweight * towards[i] ); | |
} | |
return r; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace foo { | |
struct bar { | |
bar(qux a, | |
quux b); | |
int xxx; | |
double yyy; | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
struct adder { | |
template <typename Tl, typename Tr> | |
auto operator()( Tl&& left, Tr&& right ) | |
-> decltype( left + right ) { | |
return left + right; | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace sol { | |
template <typename... Tn> | |
struct constructors { }; | |
template <typename T> | |
class lua_class { | |
public: | |
static const std::string classname; | |
static const std::string meta; |