This file contains hidden or 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 <functional> | |
/** Combine hash in seed with hash of t1 */ | |
template <typename T1> | |
void hash_combine(size_t& seed, const T1& t1) | |
{ | |
// Combine hashes | |
seed ^= std::hash<T1>()(t1) + 0x9e3779b9 + (seed << 6) + (seed >> 2); | |
} |
This file contains hidden or 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 coment | |
{ | |
class Component | |
{ | |
}; | |
} | |
struct Stuff | |
: public coment::Component |
This file contains hidden or 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
World world; | |
EntityManager& em = *world.getManager<EntityManager>(); | |
ComponentManager& cm = *world.getManager<ComponentManager>(); | |
Entity e = em.createEntity(); | |
auto positionMap = cm.getEntityMap<Position>(); | |
auto velocityMap = cm.getEntityMap<Velocity>(); | |
auto radiusMap = cm.getEntityMap<Radius>(); | |
auto moverMap = cm.getEntityMap<Position, Velocity>(); |
This file contains hidden or 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 F> | |
size_t offset(F T::* ptr) | |
{ | |
T* typePtr = (T*)nullptr; | |
F* memberPtr = &(typePtr->*ptr); | |
uintptr_t offset = (uintptr_t)memberPtr - (uintptr_t)typePtr; | |
return offset; | |
} |
This file contains hidden or 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
Signal<int> sig; | |
sig.connect(staticFunctionTest); | |
sig.connect([](int i){ printf("lambda function test %d\n", i); }); | |
sig.connect(&test, &Test::test); | |
sig.emit(5); |
This file contains hidden or 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 interpolate(vec3 tri[3], vec3 vals[3], vec3 intersection) | |
{ | |
// Calculate barycentric coordinates | |
float one_over_tri_area = 2.0f / length(cross(tri[1] - tri[0], tri[2] - tri[1])); | |
float u = 0.5f * one_over_tri_area * length(cross(tri[1] - intersection, tri[2] - intersection)); | |
float v = 0.5f * one_over_tri_area * length(cross(tri[0] - intersection, tri[2] - intersection)); | |
float w = 0.5f * one_over_tri_area * length(cross(tri[0] - intersection, tri[1] - intersection)); | |
return vals[0] * u + vals[1] * v + vals[2] * w; |
This file contains hidden or 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
#ifndef _INC_WINDOWS | |
struct HINSTANCE__; | |
typedef struct HINSTANCE__ *HINSTANCE; | |
#endif | |
int __stdcall WinMain( | |
HINSTANCE hInstance, | |
HINSTANCE hPrevInstance, | |
char* lpCmdLine, | |
int nCmdShow); |
This file contains hidden or 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 | |
class SomeClass | |
{ | |
public: | |
SomeClass(); | |
~SomeClass(); | |
SomeClass(const SomeClass&); | |
SomeClass& SomeClass(const SomeClass&); |
This file contains hidden or 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
val hexapod = new AssemblyNode { | |
transform.scale(0.1f, 0.1f, 0.1f) | |
// Body | |
children += new AssemblyNode { | |
children += new ModelNode(assets.get("assets/Base.obj")) | |
} | |
// Legs | |
(1 to 6).foreach(i => { |
This file contains hidden or 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
module Main where | |
import Control.Monad.Random.Strict | |
import Data.Array.MArray | |
import Data.Array.IO | |
import Data.Char | |
-- | Swap two elements in an array | |
swap :: (MArray a e m, Ix i) => a i e -> i -> i -> m () | |
swap arr i j = do |
OlderNewer