### OSX GCC, 'dispatch_block_t' has not been declared, invalid typedef2014-11-23

In OSX 10.10 Yosemite the

/usr/include/dispatch/object.h


header file contains code that can be processed by clang but not GCC. The specific error that GCC 4.9 (via homebrew) produces is:

/usr/include/dispatch/object.h:143:15: error: expected unqualified-id before '^' token
typedef void (^dispatch_block_t)(void);
^
/usr/include/dispatch/object.h:143:15: error: expected ')' before '^' token
/usr/include/dispatch/object.h:362:3: error: 'dispatch_block_t' has not been declared
^


The fix:

//Change
typedef void (^dispatch_block_t)(void);
//To
typedef void* dispatch_block_t;


### Clang-format for eclipse and other programs in OSX2014-11-16

clang-format is a program similar to astyle that cleans up and formats C++ code. Currently there is support for integration with Vim, Emacs, BBEdit and Visual studio.

On OSX clang is one of the default compilers supported but the version of clang on OSX does not come with clang-format. There are two options for installing:

### Homebrew:

See related homebrew pull request here

brew tap tcr/tcr
brew install clang-format


### Manual Installation:

With this option you can copy clang-format to your /usr/local/bin directory (or a location located in your path)

Extract and copy clang-format

### Compression of Simulation Data using ZLib2014-11-06

This post will cover a simple way to compress simulation data in memory using ZLib. The goal is to write out compressed data directly without having to deal with binary data formats.

### Setup

I do a lot of rendering with PovRay which means that I need to store comma separated ascii files because that is the only data format supported. The problem is that when I’m saving data for millions of objects the files can become several hundred MB in size.

I propose one solution where all simulation data is stored compressed and a simple program can be used to decompress it and write it out as povray compatible files when needed.

My data is stored in a std::stringstream which I normally stream out to a file. I would like to directly compress this stream and when I need the data, decompress it back into a string.

### ZLib

ZLib is a library that is found on pretty much every platform. Most package managers will have it, windows users can get it here

My build environment uses CMake and adding ZLib is trivial

FIND_PACKAGE(ZLIB)
...
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS}) TARGET_LINK_LIBRARIES(...${ZLIB_LIBRARIES})


### Automated Building of Chrono via Buildbot2014-10-24

This guide will describe how to set up a build environment to compile chrono on several different arm platforms, Arch linux in general, Windows and OSX.

### Hardware/OS

based on an ARM5 architecture: Pogoplug V4

based on an ARM6 architecture: Raspberry Pi

based on an ARM7 architecture: Galaxy Nexus

Intel i7-5960X Running Windows 8.1 and Arch Linux

Intel iMac running OSX 10.9 or 10.10 iMac (20-inch, Early 2009)

### Installing Arch

Installation of arch onto the pogoplug can be done using the guide provided Here

Installation of arch onto the raspberry pi can be done using the guide provided Here

### Using Bullet Only For Collision Detection2014-08-12

Bullet Physics is a great library for adding physics to a game, it can also be used purely as a collision detection tool. I wanted to document the simplest way to set bullet up for collision detection, and then get the contact information back from bullet.

There is nothing special about the code, but I wanted to have it here for my own reference


btCollisionConfiguration* bt_collision_configuration;
btCollisionDispatcher* bt_dispatcher;
btCollisionWorld* bt_collision_world;

double scene_size = 500;
unsigned int max_objects = 16000;

bt_collision_configuration = new btDefaultCollisionConfiguration();
bt_dispatcher = new btCollisionDispatcher(bt_collision_configuration);

btScalar sscene_size = (btScalar) scene_size;
btVector3 worldAabbMin(-sscene_size, -sscene_size, -sscene_size);
btVector3 worldAabbMax(sscene_size, sscene_size, sscene_size);
//This is one type of broadphase, bullet has others that might be faster depending on the application
bt_broadphase = new bt32BitAxisSweep3(worldAabbMin, worldAabbMax, max_objects, 0, true);  // true for disabling raycast accelerator

bt_collision_world = new btCollisionWorld(bt_dispatcher, bt_broadphase, bt_collision_configuration);
//Create two collision objects
btCollisionObject* sphere_A = new btCollisionObject();
btCollisionObject* sphere_B = new btCollisionObject();
//Move each to a specific location
sphere_A->getWorldTransform().setOrigin(btVector3((btScalar) 2, (btScalar) 1.5, (btScalar) 0));
sphere_B->getWorldTransform().setOrigin(btVector3((btScalar) 2, (btScalar) 0, (btScalar) 0));
//Create a sphere with a radius of 1
btSphereShape sphere_shape(1);
//Set the shape of each collision object
sphere_A->setCollisionShape(&sphere_shape);
sphere_B->setCollisionShape(&sphere_shape);
//Add the collision objects to our collision world

//Perform collision detection
bt_collision_world->performDiscreteCollisionDetection();

int numManifolds = bt_collision_world->getDispatcher()->getNumManifolds();
//For each contact manifold
for (int i = 0; i < numManifolds; i++) {
btPersistentManifold* contactManifold = bt_collision_world->getDispatcher()->getManifoldByIndexInternal(i);
btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->getBody0());
btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->getBody1());
contactManifold->refreshContactPoints(obA->getWorldTransform(), obB->getWorldTransform());
int numContacts = contactManifold->getNumContacts();
//For each contact point in that manifold
for (int j = 0; j < numContacts; j++) {
//Get the contact information
btManifoldPoint& pt = contactManifold->getContactPoint(j);
btVector3 ptA = pt.getPositionWorldOnA();
btVector3 ptB = pt.getPositionWorldOnB();
double ptdist = pt.getDistance();
}
}