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,34 +13,30 @@ subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution.
*/
#include "InclinedPlane.h"
#include "btBulletDynamicsCommon.h"
#include "LinearMath/btVector3.h"
#include "LinearMath/btAlignedObjectArray.h"
#include "LinearMath/btAlignedObjectArray.h"
#include "../CommonInterfaces/CommonRigidBodyBase.h"
#include "../CommonInterfaces/CommonParameterInterface.h"
static btScalar gTilt = 20.0f/180.0f*SIMD_PI; // tilt the ramp 20 degrees
static btScalar gTilt = 20.0f / 180.0f * SIMD_PI; // tilt the ramp 20 degrees
static btScalar gRampFriction = 1; // set ramp friction to 1
static btScalar gRampFriction = 1; // set ramp friction to 1
static btScalar gRampRestitution = 0; // set ramp restitution to 0 (no restitution)
static btScalar gRampRestitution = 0; // set ramp restitution to 0 (no restitution)
static btScalar gBoxFriction = 1; // set box friction to 1
static btScalar gBoxFriction = 1; // set box friction to 1
static btScalar gBoxRestitution = 0; // set box restitution to 0
static btScalar gBoxRestitution = 0; // set box restitution to 0
static btScalar gSphereFriction = 1; // set sphere friction to 1
static btScalar gSphereFriction = 1; // set sphere friction to 1
static btScalar gSphereRollingFriction = 1; // set sphere rolling friction to 1
static btScalar gSphereSpinningFriction = 0.3; // set sphere spinning friction to 0.3
static btScalar gSphereRollingFriction = 1; // set sphere rolling friction to 1
static btScalar gSphereSpinningFriction = 0.3; // set sphere spinning friction to 0.3
static btScalar gSphereRestitution = 0; // set sphere restitution to 0
static btScalar gSphereRestitution = 0; // set sphere restitution to 0
// handles for changes
static btRigidBody* ramp = NULL;
@@ -50,10 +46,10 @@ static btRigidBody* gSphere = NULL;
struct InclinedPlaneExample : public CommonRigidBodyBase
{
InclinedPlaneExample(struct GUIHelperInterface* helper)
:CommonRigidBodyBase(helper)
: CommonRigidBodyBase(helper)
{
}
virtual ~InclinedPlaneExample(){}
virtual ~InclinedPlaneExample() {}
virtual void initPhysics();
virtual void resetScene();
virtual void renderScene();
@@ -64,12 +60,9 @@ struct InclinedPlaneExample : public CommonRigidBodyBase
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 onBoxFrictionChanged(float friction, void* userPtr);
@@ -88,112 +81,109 @@ void onRampRestitutionChanged(float restitution, void* userPtr);
void InclinedPlaneExample::initPhysics()
{
{ // create slider to change the ramp tilt
SliderParams slider("Ramp Tilt", &gTilt);
slider.m_minVal = 0;
slider.m_maxVal = SIMD_PI / 2.0f;
slider.m_clampToNotches = false;
slider.m_callback = onRampInclinationChanged;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider);
}
{ // create slider to change the ramp tilt
SliderParams slider("Ramp Tilt",&gTilt);
slider.m_minVal=0;
slider.m_maxVal=SIMD_PI/2.0f;
slider.m_clampToNotches = false;
slider.m_callback = onRampInclinationChanged;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider);
}
{ // create slider to change the ramp friction
SliderParams slider("Ramp Friction", &gRampFriction);
slider.m_minVal = 0;
slider.m_maxVal = 10;
slider.m_clampToNotches = false;
slider.m_callback = onRampFrictionChanged;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider);
}
{ // create slider to change the ramp friction
SliderParams slider("Ramp Friction",&gRampFriction);
slider.m_minVal=0;
slider.m_maxVal=10;
slider.m_clampToNotches = false;
slider.m_callback = onRampFrictionChanged;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider);
}
{ // create slider to change the ramp restitution
SliderParams slider("Ramp Restitution", &gRampRestitution);
slider.m_minVal = 0;
slider.m_maxVal = 1;
slider.m_clampToNotches = false;
slider.m_callback = onRampRestitutionChanged;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider);
}
{ // create slider to change the ramp restitution
SliderParams slider("Ramp Restitution",&gRampRestitution);
slider.m_minVal=0;
slider.m_maxVal=1;
slider.m_clampToNotches = false;
slider.m_callback = onRampRestitutionChanged;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider);
}
{ // create slider to change the box friction
SliderParams slider("Box Friction", &gBoxFriction);
slider.m_minVal = 0;
slider.m_maxVal = 10;
slider.m_clampToNotches = false;
slider.m_callback = onBoxFrictionChanged;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider);
}
{ // create slider to change the box friction
SliderParams slider("Box Friction",&gBoxFriction);
slider.m_minVal=0;
slider.m_maxVal=10;
slider.m_clampToNotches = false;
slider.m_callback = onBoxFrictionChanged;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider);
}
{ // create slider to change the box restitution
SliderParams slider("Box Restitution", &gBoxRestitution);
slider.m_minVal = 0;
slider.m_maxVal = 1;
slider.m_clampToNotches = false;
slider.m_callback = onBoxRestitutionChanged;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider);
}
{ // create slider to change the box restitution
SliderParams slider("Box Restitution",&gBoxRestitution);
slider.m_minVal=0;
slider.m_maxVal=1;
slider.m_clampToNotches = false;
slider.m_callback = onBoxRestitutionChanged;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider);
}
{ // create slider to change the sphere friction
SliderParams slider("Sphere Friction", &gSphereFriction);
slider.m_minVal = 0;
slider.m_maxVal = 10;
slider.m_clampToNotches = false;
slider.m_callback = onSphereFrictionChanged;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider);
}
{ // create slider to change the sphere friction
SliderParams slider("Sphere Friction",&gSphereFriction);
slider.m_minVal=0;
slider.m_maxVal=10;
slider.m_clampToNotches = false;
slider.m_callback = onSphereFrictionChanged;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider);
}
{ // create slider to change the sphere rolling friction
SliderParams slider("Sphere Rolling Friction", &gSphereRollingFriction);
slider.m_minVal = 0;
slider.m_maxVal = 10;
slider.m_clampToNotches = false;
slider.m_callback = onSphereRestitutionChanged;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider);
}
{ // create slider to change the sphere rolling friction
SliderParams slider("Sphere Rolling Friction",&gSphereRollingFriction);
slider.m_minVal=0;
slider.m_maxVal=10;
slider.m_clampToNotches = false;
slider.m_callback = onSphereRestitutionChanged;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider);
}
{ // create slider to change the sphere rolling friction
SliderParams slider("Sphere Spinning", &gSphereSpinningFriction);
slider.m_minVal = 0;
slider.m_maxVal = 2;
slider.m_clampToNotches = false;
slider.m_callback = onSphereRestitutionChanged;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider);
}
{ // create slider to change the sphere rolling friction
SliderParams slider("Sphere Spinning",&gSphereSpinningFriction);
slider.m_minVal=0;
slider.m_maxVal=2;
slider.m_clampToNotches = false;
slider.m_callback = onSphereRestitutionChanged;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider);
}
{ // create slider to change the sphere restitution
SliderParams slider("Sphere Restitution", &gSphereRestitution);
slider.m_minVal = 0;
slider.m_maxVal = 1;
slider.m_clampToNotches = false;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider);
}
{ // create slider to change the sphere restitution
SliderParams slider("Sphere Restitution",&gSphereRestitution);
slider.m_minVal=0;
slider.m_maxVal=1;
slider.m_clampToNotches = false;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider);
}
m_guiHelper->setUpAxis(1); // set Y axis as up axis
m_guiHelper->setUpAxis(1); // set Y axis as up axis
createEmptyDynamicsWorld();
// create debug drawer
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 static ground
btBoxShape* groundShape = createBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.)));
{ // create a static ground
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));
}
{ //create a static inclined plane
btBoxShape* inclinedPlaneShape = createBoxShape(btVector3(btScalar(20.),btScalar(1.),btScalar(10.)));
{ //create a static inclined plane
btBoxShape* inclinedPlaneShape = createBoxShape(btVector3(btScalar(20.), btScalar(1.), btScalar(10.)));
m_collisionShapes.push_back(inclinedPlaneShape);
btTransform startTransform;
@@ -201,24 +191,23 @@ void InclinedPlaneExample::initPhysics()
// position the inclined plane above ground
startTransform.setOrigin(btVector3(
btScalar(0),
btScalar(15),
btScalar(0)));
btScalar(0),
btScalar(15),
btScalar(0)));
btQuaternion incline;
incline.setRotation(btVector3(0,0,1),gTilt);
incline.setRotation(btVector3(0, 0, 1), gTilt);
startTransform.setRotation(incline);
btScalar mass(0.);
ramp = createRigidBody(mass,startTransform,inclinedPlaneShape);
ramp = createRigidBody(mass, startTransform, inclinedPlaneShape);
ramp->setFriction(gRampFriction);
ramp->setRestitution(gRampRestitution);
}
{ //create a cube above the inclined plane
btBoxShape* boxShape = createBoxShape(btVector3(1, 1, 1));
{ //create a cube above the inclined plane
btBoxShape* boxShape = createBoxShape(btVector3(1,1,1));
m_collisionShapes.push_back(boxShape);
btTransform startTransform;
@@ -230,13 +219,13 @@ void InclinedPlaneExample::initPhysics()
btVector3(btScalar(0), btScalar(20), btScalar(2)));
gBox = createRigidBody(boxMass, startTransform, boxShape);
gBox->forceActivationState(DISABLE_DEACTIVATION); // to prevent the box on the ramp from disabling
gBox->forceActivationState(DISABLE_DEACTIVATION); // to prevent the box on the ramp from disabling
gBox->setFriction(gBoxFriction);
gBox->setRestitution(gBoxRestitution);
}
{ //create a sphere above the inclined plane
btSphereShape* sphereShape = new btSphereShape(btScalar(1));
{ //create a sphere above the inclined plane
btSphereShape* sphereShape = new btSphereShape(btScalar(1));
m_collisionShapes.push_back(sphereShape);
@@ -249,19 +238,19 @@ void InclinedPlaneExample::initPhysics()
btVector3(btScalar(0), btScalar(20), btScalar(4)));
gSphere = createRigidBody(sphereMass, startTransform, sphereShape);
gSphere->forceActivationState(DISABLE_DEACTIVATION); // to prevent the sphere on the ramp from disabling
gSphere->forceActivationState(DISABLE_DEACTIVATION); // to prevent the sphere on the ramp from disabling
gSphere->setFriction(gSphereFriction);
gSphere->setRestitution(gSphereRestitution);
gSphere->setRollingFriction(gSphereRollingFriction);
gSphere->setSpinningFriction(gSphereSpinningFriction);
}
m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld);
}
void InclinedPlaneExample::resetScene() {
{ //reset a cube above the inclined plane
void InclinedPlaneExample::resetScene()
{
{ //reset a cube above the inclined plane
btTransform startTransform;
startTransform.setIdentity();
@@ -276,7 +265,7 @@ void InclinedPlaneExample::resetScene() {
gBox->clearForces();
}
{ //reset a sphere above the inclined plane
{ //reset a sphere above the inclined plane
btTransform startTransform;
startTransform.setIdentity();
@@ -297,60 +286,70 @@ void InclinedPlaneExample::stepSimulation(float deltaTime)
{
m_dynamicsWorld->stepSimulation(deltaTime);
}
}
void InclinedPlaneExample::renderScene()
{
CommonRigidBodyBase::renderScene();
}
bool InclinedPlaneExample::keyboardCallback(int key, int state) {
// b3Printf("Key pressed: %d in state %d \n",key,state);
bool InclinedPlaneExample::keyboardCallback(int key, int state)
{
// b3Printf("Key pressed: %d in state %d \n",key,state);
switch (key) {
case 32 /*ASCII for space*/: {
resetScene();
break;
}
switch (key)
{
case 32 /*ASCII for space*/:
{
resetScene();
break;
}
}
return false;
}
// GUI parameter modifiers
void onBoxFrictionChanged(float friction, void*){
if(gBox){
void onBoxFrictionChanged(float friction, void*)
{
if (gBox)
{
gBox->setFriction(friction);
// b3Printf("Friction of box changed to %f",friction );
// b3Printf("Friction of box changed to %f",friction );
}
}
void onBoxRestitutionChanged(float restitution, void*){
if(gBox){
void onBoxRestitutionChanged(float restitution, void*)
{
if (gBox)
{
gBox->setRestitution(restitution);
//b3Printf("Restitution of box changed to %f",restitution);
}
}
void onSphereFrictionChanged(float friction, void*){
if(gSphere){
void onSphereFrictionChanged(float friction, void*)
{
if (gSphere)
{
gSphere->setFriction(friction);
//b3Printf("Friction of sphere changed to %f",friction );
}
}
void onSphereRestitutionChanged(float restitution, void*){
if(gSphere){
void onSphereRestitutionChanged(float restitution, void*)
{
if (gSphere)
{
gSphere->setRestitution(restitution);
//b3Printf("Restitution of sphere changed to %f",restitution);
}
}
void onRampInclinationChanged(float inclination, void*){
if(ramp){
void onRampInclinationChanged(float inclination, void*)
{
if (ramp)
{
btTransform startTransform;
startTransform.setIdentity();
@@ -359,29 +358,32 @@ void onRampInclinationChanged(float inclination, void*){
btVector3(btScalar(0), btScalar(15), btScalar(0)));
btQuaternion incline;
incline.setRotation(btVector3(0,0,1),gTilt);
incline.setRotation(btVector3(0, 0, 1), gTilt);
startTransform.setRotation(incline);
ramp->setWorldTransform(startTransform);
//b3Printf("Inclination of ramp changed to %f",inclination );
}
}
void onRampFrictionChanged(float friction, void*){
if(ramp){
void onRampFrictionChanged(float friction, void*)
{
if (ramp)
{
ramp->setFriction(friction);
//b3Printf("Friction of ramp changed to %f \n",friction );
}
}
void onRampRestitutionChanged(float restitution, void*){
if(ramp){
void onRampRestitutionChanged(float restitution, void*)
{
if (ramp)
{
ramp->setRestitution(restitution);
//b3Printf("Restitution of ramp changed to %f \n",restitution);
}
}
CommonExampleInterface* ET_InclinedPlaneCreateFunc(CommonExampleOptions& options)
CommonExampleInterface* ET_InclinedPlaneCreateFunc(CommonExampleOptions& options)
{
return new InclinedPlaneExample(options.m_guiHelper);
}