Fix for issue 1007
_clang-format file and applied to HelloWorld.cpp usage: clang-format -style=file -i examples/HelloWorld/HelloWorld.cpp THere are still some issues with clang-format and its style
This commit is contained in:
90
_clang-format
Normal file
90
_clang-format
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
# BasedOnStyle: Google
|
||||||
|
AccessModifierOffset: -1
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
AlignConsecutiveAssignments: false
|
||||||
|
AlignConsecutiveDeclarations: false
|
||||||
|
AlignEscapedNewlinesLeft: true
|
||||||
|
AlignOperands: true
|
||||||
|
AlignTrailingComments: true
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: true
|
||||||
|
AllowShortBlocksOnASingleLine: false
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: All
|
||||||
|
AllowShortIfStatementsOnASingleLine: true
|
||||||
|
AllowShortLoopsOnASingleLine: true
|
||||||
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: true
|
||||||
|
AlwaysBreakTemplateDeclarations: true
|
||||||
|
BinPackArguments: true
|
||||||
|
BinPackParameters: true
|
||||||
|
BraceWrapping:
|
||||||
|
AfterClass: false
|
||||||
|
AfterControlStatement: false
|
||||||
|
AfterEnum: false
|
||||||
|
AfterFunction: false
|
||||||
|
AfterNamespace: false
|
||||||
|
AfterObjCDeclaration: false
|
||||||
|
AfterStruct: false
|
||||||
|
AfterUnion: false
|
||||||
|
BeforeCatch: false
|
||||||
|
BeforeElse: false
|
||||||
|
IndentBraces: false
|
||||||
|
BreakBeforeBinaryOperators: None
|
||||||
|
BreakBeforeBraces: Allman
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakConstructorInitializersBeforeComma: false
|
||||||
|
ColumnLimit: 0
|
||||||
|
CommentPragmas: '^ IWYU pragma:'
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||||
|
ConstructorInitializerIndentWidth: 4
|
||||||
|
ContinuationIndentWidth: 4
|
||||||
|
Cpp11BracedListStyle: true
|
||||||
|
DerivePointerAlignment: true
|
||||||
|
DisableFormat: false
|
||||||
|
ExperimentalAutoDetectBinPacking: false
|
||||||
|
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
|
||||||
|
IncludeCategories:
|
||||||
|
- Regex: '^<.*\.h>'
|
||||||
|
Priority: 1
|
||||||
|
- Regex: '^<.*'
|
||||||
|
Priority: 2
|
||||||
|
- Regex: '.*'
|
||||||
|
Priority: 3
|
||||||
|
IndentCaseLabels: true
|
||||||
|
IndentWidth: 4
|
||||||
|
IndentWrappedFunctionNames: false
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||||
|
MacroBlockBegin: ''
|
||||||
|
MacroBlockEnd: ''
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
NamespaceIndentation: None
|
||||||
|
ObjCBlockIndentWidth: 2
|
||||||
|
ObjCSpaceAfterProperty: false
|
||||||
|
ObjCSpaceBeforeProtocolList: false
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 1
|
||||||
|
PenaltyBreakComment: 300
|
||||||
|
PenaltyBreakFirstLessLess: 120
|
||||||
|
PenaltyBreakString: 1000
|
||||||
|
PenaltyExcessCharacter: 1000000
|
||||||
|
PenaltyReturnTypeOnItsOwnLine: 200
|
||||||
|
PointerAlignment: Left
|
||||||
|
ReflowComments: false
|
||||||
|
SortIncludes: false
|
||||||
|
SpaceAfterCStyleCast: false
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesBeforeTrailingComments: 2
|
||||||
|
SpacesInAngles: false
|
||||||
|
SpacesInContainerLiterals: true
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
Standard: Auto
|
||||||
|
TabWidth: 4
|
||||||
|
UseTab: Always
|
||||||
|
...
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ int main(int argc, char** argv)
|
|||||||
btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
|
btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
|
||||||
|
|
||||||
///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded)
|
///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded)
|
||||||
btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration);
|
btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration);
|
||||||
|
|
||||||
///btDbvtBroadphase is a good general purpose broadphase. You can also try out btAxis3Sweep.
|
///btDbvtBroadphase is a good general purpose broadphase. You can also try out btAxis3Sweep.
|
||||||
btBroadphaseInterface* overlappingPairCache = new btDbvtBroadphase();
|
btBroadphaseInterface* overlappingPairCache = new btDbvtBroadphase();
|
||||||
@@ -38,9 +38,9 @@ int main(int argc, char** argv)
|
|||||||
///the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded)
|
///the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded)
|
||||||
btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver;
|
btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver;
|
||||||
|
|
||||||
btDiscreteDynamicsWorld* dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,overlappingPairCache,solver,collisionConfiguration);
|
btDiscreteDynamicsWorld* dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher, overlappingPairCache, solver, collisionConfiguration);
|
||||||
|
|
||||||
dynamicsWorld->setGravity(btVector3(0,-10,0));
|
dynamicsWorld->setGravity(btVector3(0, -10, 0));
|
||||||
|
|
||||||
///-----initialization_end-----
|
///-----initialization_end-----
|
||||||
|
|
||||||
@@ -48,39 +48,37 @@ int main(int argc, char** argv)
|
|||||||
//make sure to re-use collision shapes among rigid bodies whenever possible!
|
//make sure to re-use collision shapes among rigid bodies whenever possible!
|
||||||
btAlignedObjectArray<btCollisionShape*> collisionShapes;
|
btAlignedObjectArray<btCollisionShape*> collisionShapes;
|
||||||
|
|
||||||
|
|
||||||
///create a few basic rigid bodies
|
///create a few basic rigid bodies
|
||||||
|
|
||||||
//the ground is a cube of side 100 at position y = -56.
|
//the ground is a cube of side 100 at position y = -56.
|
||||||
//the sphere will hit it at y = -6, with center at -5
|
//the sphere will hit it at y = -6, with center at -5
|
||||||
{
|
{
|
||||||
btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.)));
|
btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.), btScalar(50.), btScalar(50.)));
|
||||||
|
|
||||||
collisionShapes.push_back(groundShape);
|
collisionShapes.push_back(groundShape);
|
||||||
|
|
||||||
btTransform groundTransform;
|
btTransform groundTransform;
|
||||||
groundTransform.setIdentity();
|
groundTransform.setIdentity();
|
||||||
groundTransform.setOrigin(btVector3(0,-56,0));
|
groundTransform.setOrigin(btVector3(0, -56, 0));
|
||||||
|
|
||||||
btScalar mass(0.);
|
btScalar mass(0.);
|
||||||
|
|
||||||
//rigidbody is dynamic if and only if mass is non zero, otherwise static
|
//rigidbody is dynamic if and only if mass is non zero, otherwise static
|
||||||
bool isDynamic = (mass != 0.f);
|
bool isDynamic = (mass != 0.f);
|
||||||
|
|
||||||
btVector3 localInertia(0,0,0);
|
btVector3 localInertia(0, 0, 0);
|
||||||
if (isDynamic)
|
if (isDynamic)
|
||||||
groundShape->calculateLocalInertia(mass,localInertia);
|
groundShape->calculateLocalInertia(mass, localInertia);
|
||||||
|
|
||||||
//using motionstate is optional, it provides interpolation capabilities, and only synchronizes 'active' objects
|
//using motionstate is optional, it provides interpolation capabilities, and only synchronizes 'active' objects
|
||||||
btDefaultMotionState* myMotionState = new btDefaultMotionState(groundTransform);
|
btDefaultMotionState* myMotionState = new btDefaultMotionState(groundTransform);
|
||||||
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,groundShape,localInertia);
|
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass, myMotionState, groundShape, localInertia);
|
||||||
btRigidBody* body = new btRigidBody(rbInfo);
|
btRigidBody* body = new btRigidBody(rbInfo);
|
||||||
|
|
||||||
//add the body to the dynamics world
|
//add the body to the dynamics world
|
||||||
dynamicsWorld->addRigidBody(body);
|
dynamicsWorld->addRigidBody(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
//create a dynamic rigidbody
|
//create a dynamic rigidbody
|
||||||
|
|
||||||
@@ -92,37 +90,34 @@ int main(int argc, char** argv)
|
|||||||
btTransform startTransform;
|
btTransform startTransform;
|
||||||
startTransform.setIdentity();
|
startTransform.setIdentity();
|
||||||
|
|
||||||
btScalar mass(1.f);
|
btScalar mass(1.f);
|
||||||
|
|
||||||
//rigidbody is dynamic if and only if mass is non zero, otherwise static
|
//rigidbody is dynamic if and only if mass is non zero, otherwise static
|
||||||
bool isDynamic = (mass != 0.f);
|
bool isDynamic = (mass != 0.f);
|
||||||
|
|
||||||
btVector3 localInertia(0,0,0);
|
btVector3 localInertia(0, 0, 0);
|
||||||
if (isDynamic)
|
if (isDynamic)
|
||||||
colShape->calculateLocalInertia(mass,localInertia);
|
colShape->calculateLocalInertia(mass, localInertia);
|
||||||
|
|
||||||
startTransform.setOrigin(btVector3(2,10,0));
|
startTransform.setOrigin(btVector3(2, 10, 0));
|
||||||
|
|
||||||
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
|
|
||||||
btDefaultMotionState* myMotionState = new btDefaultMotionState(startTransform);
|
|
||||||
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,colShape,localInertia);
|
|
||||||
btRigidBody* body = new btRigidBody(rbInfo);
|
|
||||||
|
|
||||||
dynamicsWorld->addRigidBody(body);
|
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
|
||||||
|
btDefaultMotionState* myMotionState = new btDefaultMotionState(startTransform);
|
||||||
|
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass, myMotionState, colShape, localInertia);
|
||||||
|
btRigidBody* body = new btRigidBody(rbInfo);
|
||||||
|
|
||||||
|
dynamicsWorld->addRigidBody(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Do some simulation
|
||||||
|
|
||||||
/// Do some simulation
|
|
||||||
|
|
||||||
|
|
||||||
///-----stepsimulation_start-----
|
///-----stepsimulation_start-----
|
||||||
for (i=0;i<150;i++)
|
for (i = 0; i < 150; i++)
|
||||||
{
|
{
|
||||||
dynamicsWorld->stepSimulation(1.f/60.f,10);
|
dynamicsWorld->stepSimulation(1.f / 60.f, 10);
|
||||||
|
|
||||||
//print positions of all objects
|
//print positions of all objects
|
||||||
for (int j=dynamicsWorld->getNumCollisionObjects()-1; j>=0 ;j--)
|
for (int j = dynamicsWorld->getNumCollisionObjects() - 1; j >= 0; j--)
|
||||||
{
|
{
|
||||||
btCollisionObject* obj = dynamicsWorld->getCollisionObjectArray()[j];
|
btCollisionObject* obj = dynamicsWorld->getCollisionObjectArray()[j];
|
||||||
btRigidBody* body = btRigidBody::upcast(obj);
|
btRigidBody* body = btRigidBody::upcast(obj);
|
||||||
@@ -130,23 +125,23 @@ int main(int argc, char** argv)
|
|||||||
if (body && body->getMotionState())
|
if (body && body->getMotionState())
|
||||||
{
|
{
|
||||||
body->getMotionState()->getWorldTransform(trans);
|
body->getMotionState()->getWorldTransform(trans);
|
||||||
|
}
|
||||||
} else
|
else
|
||||||
{
|
{
|
||||||
trans = obj->getWorldTransform();
|
trans = obj->getWorldTransform();
|
||||||
}
|
}
|
||||||
printf("world pos object %d = %f,%f,%f\n",j,float(trans.getOrigin().getX()),float(trans.getOrigin().getY()),float(trans.getOrigin().getZ()));
|
printf("world pos object %d = %f,%f,%f\n", j, float(trans.getOrigin().getX()), float(trans.getOrigin().getY()), float(trans.getOrigin().getZ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///-----stepsimulation_end-----
|
///-----stepsimulation_end-----
|
||||||
|
|
||||||
//cleanup in the reverse order of creation/initialization
|
//cleanup in the reverse order of creation/initialization
|
||||||
|
|
||||||
///-----cleanup_start-----
|
///-----cleanup_start-----
|
||||||
|
|
||||||
//remove the rigidbodies from the dynamics world and delete them
|
//remove the rigidbodies from the dynamics world and delete them
|
||||||
for (i=dynamicsWorld->getNumCollisionObjects()-1; i>=0 ;i--)
|
for (i = dynamicsWorld->getNumCollisionObjects() - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
btCollisionObject* obj = dynamicsWorld->getCollisionObjectArray()[i];
|
btCollisionObject* obj = dynamicsWorld->getCollisionObjectArray()[i];
|
||||||
btRigidBody* body = btRigidBody::upcast(obj);
|
btRigidBody* body = btRigidBody::upcast(obj);
|
||||||
@@ -154,12 +149,12 @@ int main(int argc, char** argv)
|
|||||||
{
|
{
|
||||||
delete body->getMotionState();
|
delete body->getMotionState();
|
||||||
}
|
}
|
||||||
dynamicsWorld->removeCollisionObject( obj );
|
dynamicsWorld->removeCollisionObject(obj);
|
||||||
delete obj;
|
delete obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
//delete collision shapes
|
//delete collision shapes
|
||||||
for (int j=0;j<collisionShapes.size();j++)
|
for (int j = 0; j < collisionShapes.size(); j++)
|
||||||
{
|
{
|
||||||
btCollisionShape* shape = collisionShapes[j];
|
btCollisionShape* shape = collisionShapes[j];
|
||||||
collisionShapes[j] = 0;
|
collisionShapes[j] = 0;
|
||||||
@@ -183,4 +178,3 @@ int main(int argc, char** argv)
|
|||||||
//next line is optional: it will be cleared by the destructor when the array goes out of scope
|
//next line is optional: it will be cleared by the destructor when the array goes out of scope
|
||||||
collisionShapes.clear();
|
collisionShapes.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user