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

@@ -13,13 +13,11 @@ subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution.
*/
#include "SimpleCloth.h"
#include "btBulletDynamicsCommon.h"
#include "LinearMath/btVector3.h"
#include "LinearMath/btAlignedObjectArray.h"
#include "LinearMath/btAlignedObjectArray.h"
#include "../CommonInterfaces/CommonRigidBodyBase.h"
#include "BulletSoftBody/btSoftRigidDynamicsWorld.h"
@@ -29,21 +27,21 @@ subject to the following restrictions:
struct SimpleClothExample : public CommonRigidBodyBase
{
SimpleClothExample(struct GUIHelperInterface* helper)
:CommonRigidBodyBase(helper)
: CommonRigidBodyBase(helper)
{
}
virtual ~SimpleClothExample(){}
virtual ~SimpleClothExample() {}
virtual void initPhysics();
virtual void renderScene();
void createEmptyDynamicsWorld()
{
m_collisionConfiguration = new btSoftBodyRigidBodyCollisionConfiguration();
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
m_collisionConfiguration = new btSoftBodyRigidBodyCollisionConfiguration();
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
m_broadphase = new btDbvtBroadphase();
m_solver = new btSequentialImpulseConstraintSolver;
m_solver = new btSequentialImpulseConstraintSolver;
m_dynamicsWorld = new btSoftRigidDynamicsWorld(m_dispatcher, m_broadphase, m_solver, m_collisionConfiguration);
m_dynamicsWorld->setGravity(btVector3(0, -10, 0));
@@ -52,22 +50,22 @@ struct SimpleClothExample : public CommonRigidBodyBase
softBodyWorldInfo.m_gravity = m_dynamicsWorld->getGravity();
softBodyWorldInfo.m_sparsesdf.Initialize();
}
virtual btSoftRigidDynamicsWorld* getSoftDynamicsWorld()
virtual btSoftRigidDynamicsWorld* getSoftDynamicsWorld()
{
///just make it a btSoftRigidDynamicsWorld please
///or we will add type checking
return (btSoftRigidDynamicsWorld*) m_dynamicsWorld;
return (btSoftRigidDynamicsWorld*)m_dynamicsWorld;
}
void resetCamera()
{
float dist = 41;
float pitch = -35;
float yaw = 52;
float targetPos[3]={0,0.46,0};
m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
float targetPos[3] = {0, 0.46, 0};
m_guiHelper->resetCamera(dist, yaw, pitch, targetPos[0], targetPos[1], targetPos[2]);
}
void createSoftBody(const btScalar size, const int num_x, const int num_z, const int fixed=1+2);
void createSoftBody(const btScalar size, const int num_x, const int num_z, const int fixed = 1 + 2);
btSoftBodyWorldInfo softBodyWorldInfo;
};
@@ -76,30 +74,29 @@ void SimpleClothExample::initPhysics()
m_guiHelper->setUpAxis(1);
createEmptyDynamicsWorld();
m_guiHelper->createPhysicsDebugDrawer(m_dynamicsWorld);
if (m_dynamicsWorld->getDebugDrawer())
m_dynamicsWorld->getDebugDrawer()->setDebugMode(btIDebugDraw::DBG_DrawWireframe+btIDebugDraw::DBG_DrawContactPoints);
m_dynamicsWorld->getDebugDrawer()->setDebugMode(btIDebugDraw::DBG_DrawWireframe + btIDebugDraw::DBG_DrawContactPoints);
///create a few basic rigid bodies
btBoxShape* groundShape = createBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.)));
btBoxShape* groundShape = createBoxShape(btVector3(btScalar(50.), btScalar(50.), btScalar(50.)));
m_collisionShapes.push_back(groundShape);
btTransform groundTransform;
groundTransform.setIdentity();
groundTransform.setOrigin(btVector3(0,-50,0));
groundTransform.setOrigin(btVector3(0, -50, 0));
{
btScalar mass(0.);
createRigidBody(mass,groundTransform,groundShape, btVector4(0,0,1,1));
createRigidBody(mass, groundTransform, groundShape, btVector4(0, 0, 1, 1));
}
{
const btScalar s=4; //size of cloth patch
const int NUM_X=31; //vertices on X axis
const int NUM_Z=31; //vertices on Z axis
createSoftBody(s,NUM_X, NUM_Z);
const btScalar s = 4; //size of cloth patch
const int NUM_X = 31; //vertices on X axis
const int NUM_Z = 31; //vertices on Z axis
createSoftBody(s, NUM_X, NUM_Z);
}
m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld);
@@ -107,57 +104,45 @@ void SimpleClothExample::initPhysics()
void SimpleClothExample::createSoftBody(const btScalar s,
const int numX,
const int numY,
const int fixed) {
btSoftBody* cloth=btSoftBodyHelpers::CreatePatch(softBodyWorldInfo,
btVector3(-s/2,s+1,0),
btVector3(+s/2,s+1,0),
btVector3(-s/2,s+1,+s),
btVector3(+s/2,s+1,+s),
numX,numY,
fixed,true);
const int numY,
const int fixed)
{
btSoftBody* cloth = btSoftBodyHelpers::CreatePatch(softBodyWorldInfo,
btVector3(-s / 2, s + 1, 0),
btVector3(+s / 2, s + 1, 0),
btVector3(-s / 2, s + 1, +s),
btVector3(+s / 2, s + 1, +s),
numX, numY,
fixed, true);
cloth->getCollisionShape()->setMargin(0.001f);
cloth->getCollisionShape()->setUserPointer((void*)cloth);
cloth->generateBendingConstraints(2,cloth->appendMaterial());
cloth->setTotalMass(10);
cloth->getCollisionShape()->setUserPointer((void*)cloth);
cloth->generateBendingConstraints(2, cloth->appendMaterial());
cloth->setTotalMass(10);
//cloth->m_cfg.citerations = 10;
// cloth->m_cfg.diterations = 10;
// cloth->m_cfg.diterations = 10;
cloth->m_cfg.piterations = 5;
cloth->m_cfg.kDP = 0.005f;
getSoftDynamicsWorld()->addSoftBody(cloth);
}
void SimpleClothExample::renderScene()
{
CommonRigidBodyBase::renderScene();
CommonRigidBodyBase::renderScene();
btSoftRigidDynamicsWorld* softWorld = getSoftDynamicsWorld();
for ( int i=0;i<softWorld->getSoftBodyArray().size();i++)
for (int i = 0; i < softWorld->getSoftBodyArray().size(); i++)
{
btSoftBody* psb = (btSoftBody*)softWorld->getSoftBodyArray()[i];
//if (softWorld->getDebugDrawer() && !(softWorld->getDebugDrawer()->getDebugMode() & (btIDebugDraw::DBG_DrawWireframe)))
{
btSoftBody* psb=(btSoftBody*)softWorld->getSoftBodyArray()[i];
//if (softWorld->getDebugDrawer() && !(softWorld->getDebugDrawer()->getDebugMode() & (btIDebugDraw::DBG_DrawWireframe)))
{
btSoftBodyHelpers::DrawFrame(psb,softWorld->getDebugDrawer());
btSoftBodyHelpers::Draw(psb,softWorld->getDebugDrawer(),softWorld->getDrawFlags());
}
btSoftBodyHelpers::DrawFrame(psb, softWorld->getDebugDrawer());
btSoftBodyHelpers::Draw(psb, softWorld->getDebugDrawer(), softWorld->getDrawFlags());
}
}
}
CommonExampleInterface* ET_SimpleClothCreateFunc(CommonExampleOptions& options)
CommonExampleInterface* ET_SimpleClothCreateFunc(CommonExampleOptions& options)
{
return new SimpleClothExample(options.m_guiHelper);
}