Using the automator service method described below is only necessary if you would like to be able to use clang-format for any program using a system wide keyboard shortcut.
Installation
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:
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.
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.
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;btBroadphaseInterface*bt_broadphase;btCollisionWorld*bt_collision_world;doublescene_size=500;unsignedintmax_objects=16000;bt_collision_configuration=newbtDefaultCollisionConfiguration();bt_dispatcher=newbtCollisionDispatcher(bt_collision_configuration);btScalarsscene_size=(btScalar)scene_size;btVector3worldAabbMin(-sscene_size,-sscene_size,-sscene_size);btVector3worldAabbMax(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=newbt32BitAxisSweep3(worldAabbMin,worldAabbMax,max_objects,0,true);// true for disabling raycast accelerator
bt_collision_world=newbtCollisionWorld(bt_dispatcher,bt_broadphase,bt_collision_configuration);//Create two collision objects
btCollisionObject*sphere_A=newbtCollisionObject();btCollisionObject*sphere_B=newbtCollisionObject();//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=newbtSphereShape(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
bt_collision_world->addCollisionObject(sphere_A);bt_collision_world->addCollisionObject(sphere_B);//Perform collision detection
bt_collision_world->performDiscreteCollisionDetection();intnumManifolds=bt_collision_world->getDispatcher()->getNumManifolds();//For each contact manifold
for(inti=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());intnumContacts=contactManifold->getNumContacts();//For each contact point in that manifold
for(intj=0;j<numContacts;j++){//Get the contact information
btManifoldPoint&pt=contactManifold->getContactPoint(j);btVector3ptA=pt.getPositionWorldOnA();btVector3ptB=pt.getPositionWorldOnB();doubleptdist=pt.getDistance();}}