[ Launch: mustache phase ] 6708324 by slembcke[ Launch: i wish this was a mustache emporium ] 6707845 by gelicia[ Launch: i wish this was a mustache emporium ] 6690695 by gelicia
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 <stdlib.h> | |
#include "png.h" | |
extern long image_memory(int numbytes, void *data_ptr); | |
extern void throw_error(char *filename, char *error); | |
#define PNG_SIG_BYTES 8 | |
static void |
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
const NSUInteger testCount = 1000000; | |
{ | |
GLKMatrix4 m = M; // Initialized from a global to prevent constant folding when inlining. | |
CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); | |
for (NSUInteger i = 0; i < testCount; i++) { | |
m = GLKMatrix4Multiply(m, m); | |
} | |
NSLog(@"time GLKit: %f", CFAbsoluteTimeGetCurrent() - t); | |
M = m; // Need to save the value of m to avoid it being optimized away |
[ Launch: XOR Triangles ] 6402424 by slembcke
[ Launch: xor squares ] 6386076 by slembcke[ Launch: Lissajous ] 6384402 by gelicia[ Launch: Lissajous ] 6378631 by slembcke
[ Launch: xor circles ] 6385454 by slembcke
[ Launch: Lissajous ] 6378631 by slembcke
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
// Old slice code: | |
cpVect centroid = cpCentroidForPoly(clippedCount, clipped); | |
cpFloat mass = cpAreaForPoly(clippedCount, clipped)*DENSITY; | |
cpFloat moment = cpMomentForPoly(mass, clippedCount, clipped, cpvneg(centroid)); | |
cpBody *new_body = cpSpaceAddBody(space, cpBodyNew(mass, moment)); | |
cpBodySetPos(new_body, centroid); | |
cpBodySetVel(new_body, cpBodyGetVelAtWorldPoint(body, centroid)); | |
cpBodySetAngVel(new_body, cpBodyGetAngVel(body)); | |
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
// Basically in C you only get a single return value, | |
// but there are ways around that. | |
// The first, and more common method is to return things using references. | |
// Pass pointers to the output variables, and write the output values to them. | |
// While it's common, a lot of people think it's a really bad practice (self included). | |
void ReturnMultiple1(int a, int b, int *outX, int *outY) | |
{ | |
// Write to the output variables. |
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
{ | |
cpVect a = cpvmult(cpvforangle(0.0), 1.0); | |
cpVect b = cpvmult(cpvforangle(1.0), 1.0); | |
cpVect c = a; | |
cpVect v = cpvslerp(a, b, 0.0); | |
GHAssertLessThan(cpvdist(v, c), (cpFloat)1e-5, nil); | |
} | |
{ | |
cpVect a = cpvmult(cpvforangle(0.0), 1.0); |