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 ObjectType> | |
string TYPE_NAME() | |
{ | |
// determine type name from typeid | |
// note - if this ever failes, we can always go constexpr route, i.e | |
// constexpr static const char * TYPE_NAME() { return "ClassNameHere"; }; | |
// and maybe even try to parse __FUNCTION__ inside of it somehow | |
regex REG_class_name ( "N\\d*war\\d*(.+)E" ); | |
smatch what; | |
if ( !regex_match( string(typeid(ObjectType).name()), what, REG_class_name) ) |
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
#include <iostream> | |
#include <vector> | |
#include <functional> | |
#include <initializer_list> | |
#include <string> | |
using namespace std; | |
template <typename TT> | |
class RArray : protected vector<TT> |
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
class Report | |
{ | |
public: | |
Report() { cout << "Report();" << endl; } | |
Report(const Report & ) { cout << "Report(const & Report);" << endl; }; | |
Report(Report &&) { cout << "Report(&&);" << endl; } | |
Report & operator = (const Report &) { cout << "Report::=(const Report &);" << endl; return *this; }; | |
}; | |
template <typename Tc, typename T> |
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
class Report | |
{ | |
public: | |
Report() : i_am_dead(false) { cout << " Report();" << endl; } | |
Report(const Report & ) { cout << " Report(const Report&);" << endl; }; | |
Report(Report && h) { cout << " Report(&&);" << endl; h.i_am_dead = true; } | |
Report & operator = (const Report&) { cout << " Report::=(const Report&);" << endl; return *this; }; | |
~Report() { cout << " ~Report() i_am_dead=" << i_am_dead << endl; } | |
bool i_am_dead; | |
}; |
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
#include <iostream> | |
#include <vector> | |
#include <functional> | |
#include <initializer_list> | |
#define USE_EMPLACE 1 | |
#define USE_UREF 1 | |
using namespace std; |
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
vec3 finalColor = vec3( 0.0 ); | |
float steps = 0.0; | |
int initialSteps = max ( 4, g_Steps / 3 ); | |
int maxEstSteps = 32; | |
float factor = max ( 1.0, length(g_light_color.rgb)/length(vec3(1.0)) ); | |
float tolerance = 1.0 / ( (g_Steps * 4.0 + initialSteps) * factor ); | |
// do initial steps | |
for ( int i=0; i<initialSteps; ++i ) |
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
vec3 finalColor = vec3( 0.0 ); | |
float steps = 0.0; | |
int initialSteps = max ( 4, g_Steps / 3 ); | |
int maxEstSteps = 32; | |
float kFactor = 2.0 / g_Steps; | |
// do initial steps | |
for ( int i=0; i<initialSteps; ++i ) |
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
/////////////////////////////////////////// | |
// parse library_visual_scenes (nodes) here | |
void importDaeNodeArray ( const pugi::xpath_node_set & nodes, vector<NodePtr> & outNodes, const WeakNodePtr & parent ) | |
{ | |
using namespace pugi; | |
if ( nodes.size()==0 ) | |
return; | |
outNodes.resize(nodes.size()); | |
for ( unsigned int ni=0; ni<nodes.size(); ni++ ) |
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
mat3 cotangent_frame( vec3 N, vec3 p, vec2 uv ) | |
{ | |
// get edge vectors of the pixel triangle | |
vec3 dp1 = dFdx( p ); | |
vec3 dp2 = dFdy( p ); | |
vec2 duv1 = dFdx( uv ); | |
vec2 duv2 = dFdy( uv ); | |
// solve the linear system | |
vec3 dp2perp = cross( dp2, N ); |
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
// this will split the work between all available threads | |
// if chunk_count is -1, default number of chunks will be computed | |
void JobQue::parallel_for ( int from, int to, const JobChunk & chunk, int chunk_count, int step ) | |
{ | |
if ( from >= to ) | |
return; | |
// so the idea here is that if say 1 thread is busy | |
// we don't pay 2x time. smaller chunks are more evenly distributed | |
if ( chunk_count==-1 ) | |
chunk_count = mThreadCount * 4; |