Code-style consistency improvement:

Apply clang-format-all.sh using the _clang-format file through all the cpp/.h files.
make sure not to apply it to certain serialization structures, since some parser expects the * as part of the name, instead of type.
This commit contains no other changes aside from adding and applying clang-format-all.sh
This commit is contained in:
erwincoumans
2018-09-23 14:17:31 -07:00
parent b73b05e9fb
commit ab8f16961e
1773 changed files with 1081087 additions and 474249 deletions

View File

@@ -18,18 +18,17 @@ subject to the following restrictions:
#include "BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.h"
#include "BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.h"
#include "BulletCollision/CollisionShapes/btBox2dShape.h"
#include "BulletCollision/CollisionShapes/btConvex2dShape.h"
#include "BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h"
///create 125 (5x5x5) dynamic object
#define ARRAY_SIZE_X 5
#define ARRAY_SIZE_Y 5
#define ARRAY_SIZE_Y 5
#define ARRAY_SIZE_Z 1
//maximum number of objects (and allow user to shoot additional boxes)
#define MAX_PROXIES (ARRAY_SIZE_X*ARRAY_SIZE_Y*ARRAY_SIZE_Z + 1024)
#define MAX_PROXIES (ARRAY_SIZE_X * ARRAY_SIZE_Y * ARRAY_SIZE_Z + 1024)
///scaling of the objects (0.1 = 20 centimeter boxes )
#define SCALING 1
@@ -41,9 +40,7 @@ subject to the following restrictions:
///btBulletDynamicsCommon.h is the main Bullet include file, contains most common include files.
#include "btBulletDynamicsCommon.h"
#include <stdio.h> //printf debugging
#include <stdio.h> //printf debugging
#include "LinearMath/btAlignedObjectArray.h"
@@ -58,29 +55,27 @@ class GL_DialogDynamicsWorld;
#include "../CommonInterfaces/CommonRigidBodyBase.h"
class Planar2D : public CommonRigidBodyBase
{
//keep the collision shapes, for deletion/cleanup
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
btBroadphaseInterface* m_broadphase;
btBroadphaseInterface* m_broadphase;
btCollisionDispatcher* m_dispatcher;
btCollisionDispatcher* m_dispatcher;
btConstraintSolver* m_solver;
btConstraintSolver* m_solver;
btDefaultCollisionConfiguration* m_collisionConfiguration;
btConvex2dConvex2dAlgorithm::CreateFunc* m_convexAlgo2d;
btConvex2dConvex2dAlgorithm::CreateFunc* m_convexAlgo2d;
btVoronoiSimplexSolver* m_simplexSolver;
btMinkowskiPenetrationDepthSolver* m_pdSolver;
btBox2dBox2dCollisionAlgorithm::CreateFunc* m_box2dbox2dAlgo;
public:
public:
Planar2D(struct GUIHelperInterface* helper)
:CommonRigidBodyBase(helper)
: CommonRigidBodyBase(helper)
{
}
virtual ~Planar2D()
@@ -88,29 +83,22 @@ class Planar2D : public CommonRigidBodyBase
exitPhysics();
}
void initPhysics();
void initPhysics();
void exitPhysics();
void exitPhysics();
void resetCamera()
{
float dist = 9;
float pitch = -11;
float yaw = 539;
float targetPos[3]={8.6,10.5,-20.6};
m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
float targetPos[3] = {8.6, 10.5, -20.6};
m_guiHelper->resetCamera(dist, yaw, pitch, targetPos[0], targetPos[1], targetPos[2]);
}
};
void Planar2D::initPhysics()
void Planar2D::initPhysics()
{
m_guiHelper->setUpAxis(1);
///collision configuration contains default setup for memory, collision setup
@@ -118,19 +106,18 @@ void Planar2D::initPhysics()
//m_collisionConfiguration->setConvexConvexMultipointIterations();
///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded)
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
m_simplexSolver = new btVoronoiSimplexSolver();
m_pdSolver = new btMinkowskiPenetrationDepthSolver();
m_convexAlgo2d = new btConvex2dConvex2dAlgorithm::CreateFunc(m_simplexSolver,m_pdSolver);
m_convexAlgo2d = new btConvex2dConvex2dAlgorithm::CreateFunc(m_simplexSolver, m_pdSolver);
m_box2dbox2dAlgo = new btBox2dBox2dCollisionAlgorithm::CreateFunc();
m_dispatcher->registerCollisionCreateFunc(CONVEX_2D_SHAPE_PROXYTYPE,CONVEX_2D_SHAPE_PROXYTYPE,m_convexAlgo2d);
m_dispatcher->registerCollisionCreateFunc(BOX_2D_SHAPE_PROXYTYPE,CONVEX_2D_SHAPE_PROXYTYPE,m_convexAlgo2d);
m_dispatcher->registerCollisionCreateFunc(CONVEX_2D_SHAPE_PROXYTYPE,BOX_2D_SHAPE_PROXYTYPE,m_convexAlgo2d);
m_dispatcher->registerCollisionCreateFunc(BOX_2D_SHAPE_PROXYTYPE,BOX_2D_SHAPE_PROXYTYPE,m_box2dbox2dAlgo);
m_dispatcher->registerCollisionCreateFunc(CONVEX_2D_SHAPE_PROXYTYPE, CONVEX_2D_SHAPE_PROXYTYPE, m_convexAlgo2d);
m_dispatcher->registerCollisionCreateFunc(BOX_2D_SHAPE_PROXYTYPE, CONVEX_2D_SHAPE_PROXYTYPE, m_convexAlgo2d);
m_dispatcher->registerCollisionCreateFunc(CONVEX_2D_SHAPE_PROXYTYPE, BOX_2D_SHAPE_PROXYTYPE, m_convexAlgo2d);
m_dispatcher->registerCollisionCreateFunc(BOX_2D_SHAPE_PROXYTYPE, BOX_2D_SHAPE_PROXYTYPE, m_box2dbox2dAlgo);
m_broadphase = new btDbvtBroadphase();
//m_broadphase = new btSimpleBroadphase();
@@ -139,24 +126,22 @@ void Planar2D::initPhysics()
btSequentialImpulseConstraintSolver* sol = new btSequentialImpulseConstraintSolver;
m_solver = sol;
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher, m_broadphase, m_solver, m_collisionConfiguration);
//m_dynamicsWorld->getSolverInfo().m_erp = 1.f;
//m_dynamicsWorld->getSolverInfo().m_numIterations = 4;
m_guiHelper->createPhysicsDebugDrawer(m_dynamicsWorld);
m_dynamicsWorld->setGravity(btVector3(0,-10,0));
m_dynamicsWorld->setGravity(btVector3(0, -10, 0));
///create a few basic rigid bodies
btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(150.),btScalar(50.),btScalar(150.)));
// btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),50);
btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(150.), btScalar(50.), btScalar(150.)));
// btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),50);
m_collisionShapes.push_back(groundShape);
btTransform groundTransform;
groundTransform.setIdentity();
groundTransform.setOrigin(btVector3(0,-43,0));
groundTransform.setOrigin(btVector3(0, -43, 0));
//We can also use DemoApplication::localCreateRigidBody, but for clarity it is provided here:
{
@@ -165,43 +150,40 @@ void Planar2D::initPhysics()
//rigidbody is dynamic if and only if mass is non zero, otherwise static
bool isDynamic = (mass != 0.f);
btVector3 localInertia(0,0,0);
btVector3 localInertia(0, 0, 0);
if (isDynamic)
groundShape->calculateLocalInertia(mass,localInertia);
groundShape->calculateLocalInertia(mass, localInertia);
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
btDefaultMotionState* myMotionState = new btDefaultMotionState(groundTransform);
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,groundShape,localInertia);
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass, myMotionState, groundShape, localInertia);
btRigidBody* body = new btRigidBody(rbInfo);
//add the body to the dynamics world
m_dynamicsWorld->addRigidBody(body);
}
{
//create a few dynamic rigidbodies
// Re-using the same collision is better for memory usage and performance
btScalar u= btScalar(1*SCALING-0.04);
btVector3 points[3] = {btVector3(0,u,0),btVector3(-u,-u,0),btVector3(u,-u,0)};
btConvexShape* childShape0 = new btBoxShape(btVector3(btScalar(SCALING*1),btScalar(SCALING*1),btScalar(0.04)));
btConvexShape* colShape= new btConvex2dShape(childShape0);
btScalar u = btScalar(1 * SCALING - 0.04);
btVector3 points[3] = {btVector3(0, u, 0), btVector3(-u, -u, 0), btVector3(u, -u, 0)};
btConvexShape* childShape0 = new btBoxShape(btVector3(btScalar(SCALING * 1), btScalar(SCALING * 1), btScalar(0.04)));
btConvexShape* colShape = new btConvex2dShape(childShape0);
//btCollisionShape* colShape = new btBox2dShape(btVector3(SCALING*1,SCALING*1,0.04));
btConvexShape* childShape1 = new btConvexHullShape(&points[0].getX(),3);
btConvexShape* colShape2= new btConvex2dShape(childShape1);
btConvexShape* childShape2 = new btCylinderShapeZ(btVector3(btScalar(SCALING*1),btScalar(SCALING*1),btScalar(0.04)));
btConvexShape* colShape3= new btConvex2dShape(childShape2);
btConvexShape* childShape1 = new btConvexHullShape(&points[0].getX(), 3);
btConvexShape* colShape2 = new btConvex2dShape(childShape1);
btConvexShape* childShape2 = new btCylinderShapeZ(btVector3(btScalar(SCALING * 1), btScalar(SCALING * 1), btScalar(0.04)));
btConvexShape* colShape3 = new btConvex2dShape(childShape2);
m_collisionShapes.push_back(colShape);
m_collisionShapes.push_back(colShape);
m_collisionShapes.push_back(colShape2);
m_collisionShapes.push_back(colShape3);
m_collisionShapes.push_back(childShape0);
m_collisionShapes.push_back(childShape1);
m_collisionShapes.push_back(childShape2);
m_collisionShapes.push_back(childShape0);
m_collisionShapes.push_back(childShape1);
m_collisionShapes.push_back(childShape2);
//btUniformScalingShape* colShape = new btUniformScalingShape(convexColShape,1.f);
colShape->setMargin(btScalar(0.03));
@@ -211,95 +193,89 @@ void Planar2D::initPhysics()
btTransform startTransform;
startTransform.setIdentity();
btScalar mass(1.f);
btScalar mass(1.f);
//rigidbody is dynamic if and only if mass is non zero, otherwise static
bool isDynamic = (mass != 0.f);
btVector3 localInertia(0,0,0);
btVector3 localInertia(0, 0, 0);
if (isDynamic)
colShape->calculateLocalInertia(mass,localInertia);
colShape->calculateLocalInertia(mass, localInertia);
// float start_x = START_POS_X - ARRAY_SIZE_X/2;
// float start_y = START_POS_Y;
// float start_z = START_POS_Z - ARRAY_SIZE_Z/2;
// float start_x = START_POS_X - ARRAY_SIZE_X/2;
// float start_y = START_POS_Y;
// float start_z = START_POS_Z - ARRAY_SIZE_Z/2;
btVector3 x(-ARRAY_SIZE_X, 8.0f,-20.f);
btVector3 x(-ARRAY_SIZE_X, 8.0f, -20.f);
btVector3 y;
btVector3 deltaX(SCALING*1, SCALING*2,0.f);
btVector3 deltaY(SCALING*2, 0.0f,0.f);
btVector3 deltaX(SCALING * 1, SCALING * 2, 0.f);
btVector3 deltaY(SCALING * 2, 0.0f, 0.f);
for (int i = 0; i < ARRAY_SIZE_X; ++i)
{
y = x;
for (int j = i; j < ARRAY_SIZE_Y; ++j)
for (int j = i; j < ARRAY_SIZE_Y; ++j)
{
startTransform.setOrigin(y-btVector3(-10,0,0));
startTransform.setOrigin(y - btVector3(-10, 0, 0));
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
btDefaultMotionState* myMotionState = new btDefaultMotionState(startTransform);
btRigidBody::btRigidBodyConstructionInfo rbInfo(0,0,0);
switch (j%3)
{
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
btDefaultMotionState* myMotionState = new btDefaultMotionState(startTransform);
btRigidBody::btRigidBodyConstructionInfo rbInfo(0, 0, 0);
switch (j % 3)
{
#if 1
case 0:
rbInfo = btRigidBody::btRigidBodyConstructionInfo(mass,myMotionState,colShape,localInertia);
rbInfo = btRigidBody::btRigidBodyConstructionInfo(mass, myMotionState, colShape, localInertia);
break;
case 1:
rbInfo = btRigidBody::btRigidBodyConstructionInfo(mass,myMotionState,colShape3,localInertia);
rbInfo = btRigidBody::btRigidBodyConstructionInfo(mass, myMotionState, colShape3, localInertia);
break;
#endif
default:
rbInfo = btRigidBody::btRigidBodyConstructionInfo(mass,myMotionState,colShape2,localInertia);
}
btRigidBody* body = new btRigidBody(rbInfo);
//body->setContactProcessingThreshold(colShape->getContactBreakingThreshold());
body->setActivationState(ISLAND_SLEEPING);
body->setLinearFactor(btVector3(1,1,0));
body->setAngularFactor(btVector3(0,0,1));
rbInfo = btRigidBody::btRigidBodyConstructionInfo(mass, myMotionState, colShape2, localInertia);
}
btRigidBody* body = new btRigidBody(rbInfo);
//body->setContactProcessingThreshold(colShape->getContactBreakingThreshold());
body->setActivationState(ISLAND_SLEEPING);
body->setLinearFactor(btVector3(1, 1, 0));
body->setAngularFactor(btVector3(0, 0, 1));
m_dynamicsWorld->addRigidBody(body);
body->setActivationState(ISLAND_SLEEPING);
m_dynamicsWorld->addRigidBody(body);
body->setActivationState(ISLAND_SLEEPING);
// y += -0.8*deltaY;
// y += -0.8*deltaY;
y += deltaY;
}
x += deltaX;
}
}
m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld);
}
void Planar2D::exitPhysics()
void Planar2D::exitPhysics()
{
//cleanup in the reverse order of creation/initialization
//remove the rigidbodies from the dynamics world and delete them
int i;
if (m_dynamicsWorld)
for (i=m_dynamicsWorld->getNumCollisionObjects()-1; i>=0 ;i--)
{
btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[i];
btRigidBody* body = btRigidBody::upcast(obj);
if (body && body->getMotionState())
for (i = m_dynamicsWorld->getNumCollisionObjects() - 1; i >= 0; i--)
{
delete body->getMotionState();
btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[i];
btRigidBody* body = btRigidBody::upcast(obj);
if (body && body->getMotionState())
{
delete body->getMotionState();
}
m_dynamicsWorld->removeCollisionObject(obj);
delete obj;
}
m_dynamicsWorld->removeCollisionObject( obj );
delete obj;
}
//delete collision shapes
for (int j=0;j<m_collisionShapes.size();j++)
for (int j = 0; j < m_collisionShapes.size(); j++)
{
btCollisionShape* shape = m_collisionShapes[j];
delete shape;
@@ -307,11 +283,11 @@ void Planar2D::exitPhysics()
m_collisionShapes.clear();
delete m_dynamicsWorld;
delete m_solver;
delete m_broadphase;
delete m_dispatcher;
delete m_collisionConfiguration;
@@ -326,13 +302,13 @@ void Planar2D::exitPhysics()
m_broadphase = 0;
m_dispatcher = 0;
m_collisionConfiguration = 0;
m_convexAlgo2d=0;
m_convexAlgo2d = 0;
m_pdSolver = 0;
m_simplexSolver = 0;
m_box2dbox2dAlgo = 0;
}
CommonExampleInterface* Planar2DCreateFunc(struct CommonExampleOptions& options)
CommonExampleInterface* Planar2DCreateFunc(struct CommonExampleOptions& options)
{
return new Planar2D(options.m_guiHelper);
}

View File

@@ -15,7 +15,6 @@ subject to the following restrictions:
#ifndef PLANAR2D_H
#define PLANAR2D_H
class CommonExampleInterface* Planar2DCreateFunc(struct CommonExampleOptions& options);
#endif //BOX2D_DEMO_H
class CommonExampleInterface* Planar2DCreateFunc(struct CommonExampleOptions& options);
#endif //BOX2D_DEMO_H