Skip to content

Instantly share code, notes, and snippets.

View CedricGuillemet's full-sized avatar

Cedric Guillemet CedricGuillemet

View GitHub Profile
@CedricGuillemet
CedricGuillemet / gist:4978020
Created February 18, 2013 15:00
super hash function by Paul Hsieh
// Fast Hash
#if !defined (get16bits)
#define get16bits(d) ((((uint32)(((const uint8 *)(d))[1])) << 8)\
+(uint32)(((const uint8 *)(d))[0]) )
#endif
//
// super hash function by Paul Hsieh
//
@CedricGuillemet
CedricGuillemet / YAP.h
Last active December 17, 2020 01:02
Yet Another Profiler
#pragma once
/*
_____.___. __ __ .__
\__ | | ____ _/ |_ _____ ____ ____ _/ |_ | |__ ____ _______
/ | |_/ __ \ \ __\ \__ \ / \ / _ \ \ __\| | \ _/ __ \ \_ __ \
\____ |\ ___/ | | / __ \_| | \( <_> ) | | | Y \\ ___/ | | \/
/ ______| \___ > |__| (____ /|___| / \____/ |__| |___| / \___ > |__|
\/ \/ \/ \/ \/ \/
__________ _____ .__ .__
class A
{
public:
void method(int a, int b) const
{
printf("0x%x %d - %d \n", this, a, b);
}
};
class B
void computeForce(TileSheetNode& node, TileSheetNode& childNode, bool keepClose)
{
float dist = distance(node.mPos, childNode.mPos);
if (dist < 0.01f)
{
return;
}
float idealDist = node.mRadius + childNode.mRadius;
vec_t dir = normalized(node.mPos - childNode.mPos);
//Expose c++ class
newDSLClass(); // global
endClass();
newDSLClass("Health");
member("Life", OFFSETOF(Health.Life"), DSL::Int_t);
endClass();
newDSLClass("Entity");
member("Pos", OFFSETOF(Entity.Pos), DSL::vec4_t);
member("health", OFFSETOF(entity.health", "Health");
#include "ImApp.h"
inline void SpawnDust(EntityManager& manager, Entity& entity)
{
if (/*!entity.mStunned &&*/ entity.mCatchedBy != -1)
return;
float vel = zmax(entity.mVel, entity.mGroupForce.length());
if (vel < FLT_EPSILON)
float val(vec2 p)
{
return step(length(p-vec2(0.2,0.7)), 0.2);
//return texture(iChannel0, src).r;
}
float GetTh(vec2 src, float sz)
{
float p = val(src);
float pul = val(src + vec2(-sz, sz));
mkdir emscripten
cd emscripten
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
emsdk install latest
emsdk activate latest
#include <stdio.h>
int main()
{
printf("Hello world from the cpp side!\n");
return 0;
}
emcc helloworld.c -o helloworld.html