Skip to content

Commit

Permalink
apply clang-format (on Mac, slightly different than running it on Win…
Browse files Browse the repository at this point in the history
…dows)
  • Loading branch information
Erwin Coumans committed Sep 30, 2018
1 parent 5bcd437 commit 42ae4e8
Show file tree
Hide file tree
Showing 15 changed files with 87 additions and 117 deletions.
Empty file modified clang-format-all.sh
100644 → 100755
Empty file.
27 changes: 11 additions & 16 deletions examples/ExampleBrowser/OpenGLGuiHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ void OpenGLGuiHelper::setVisualizerFlag(int flag, int enable)
getRenderInterface()->setPlaneReflectionShapeIndex(enable);
}
if (m_data->m_visualizerFlagCallback)
(m_data->m_visualizerFlagCallback)(flag, enable!=0);
(m_data->m_visualizerFlagCallback)(flag, enable != 0);
}

void OpenGLGuiHelper::resetCamera(float camDist, float yaw, float pitch, float camPosX, float camPosY, float camPosZ)
Expand Down Expand Up @@ -1071,16 +1071,13 @@ void OpenGLGuiHelper::setProjectiveTexture(bool useProjectiveTexture)
m_data->m_glApp->m_renderer->setProjectiveTexture(useProjectiveTexture);
}


void OpenGLGuiHelper::copyCameraImageData(const float viewMatrix[16], const float projectionMatrix[16],
unsigned char* pixelsRGBA, int rgbaBufferSizeInPixels,
float* depthBuffer, int depthBufferSizeInPixels,
int* segmentationMaskBuffer, int segmentationMaskBufferSizeInPixels,
int startPixelIndex, int destinationWidth,
int destinationHeight, int* numPixelsCopied)
{


int sourceWidth = btMin(destinationWidth, (int)(m_data->m_glApp->m_window->getWidth() * m_data->m_glApp->m_window->getRetinaScale()));
int sourceHeight = btMin(destinationHeight, (int)(m_data->m_glApp->m_window->getHeight() * m_data->m_glApp->m_window->getRetinaScale()));
m_data->m_glApp->setViewport(sourceWidth, sourceHeight);
Expand All @@ -1104,7 +1101,7 @@ void OpenGLGuiHelper::copyCameraImageData(const float viewMatrix[16], const floa
BT_PROFILE("renderScene");
getRenderInterface()->renderScene();
}

{
BT_PROFILE("copy pixels");
btAlignedObjectArray<unsigned char> sourceRgbaPixelBuffer;
Expand Down Expand Up @@ -1164,7 +1161,7 @@ void OpenGLGuiHelper::copyCameraImageData(const float viewMatrix[16], const floa
BT_PROFILE("renderScene");
getRenderInterface()->renderSceneInternal(B3_SEGMENTATION_MASK_RENDERMODE);
}

{
BT_PROFILE("copy pixels");
btAlignedObjectArray<unsigned char> sourceRgbaPixelBuffer;
Expand All @@ -1176,7 +1173,7 @@ void OpenGLGuiHelper::copyCameraImageData(const float viewMatrix[16], const floa
BT_PROFILE("getScreenPixelsSegmentationMask");
m_data->m_glApp->getScreenPixels(&(sourceRgbaPixelBuffer[0]), sourceRgbaPixelBuffer.size(), &sourceDepthBuffer[0], sizeof(float) * sourceDepthBuffer.size());
}
m_data->m_segmentationMaskBuffer.resize(destinationWidth * destinationHeight,-1);
m_data->m_segmentationMaskBuffer.resize(destinationWidth * destinationHeight, -1);

//rescale and flip
{
Expand All @@ -1196,11 +1193,12 @@ void OpenGLGuiHelper::copyCameraImageData(const float viewMatrix[16], const floa
if (segmentationMaskBuffer)
{
float depth = sourceDepthBuffer[sourceDepthIndex];
if (depth<1)
if (depth < 1)
{
int segMask = sourceRgbaPixelBuffer[sourcePixelIndex + 0]+256*(sourceRgbaPixelBuffer[sourcePixelIndex + 1])+256*256*(sourceRgbaPixelBuffer[sourcePixelIndex + 2]);
int segMask = sourceRgbaPixelBuffer[sourcePixelIndex + 0] + 256 * (sourceRgbaPixelBuffer[sourcePixelIndex + 1]) + 256 * 256 * (sourceRgbaPixelBuffer[sourcePixelIndex + 2]);
m_data->m_segmentationMaskBuffer[i + j * destinationWidth] = segMask;
} else
}
else
{
m_data->m_segmentationMaskBuffer[i + j * destinationWidth] = -1;
}
Expand All @@ -1211,7 +1209,6 @@ void OpenGLGuiHelper::copyCameraImageData(const float viewMatrix[16], const floa
}
}


getRenderInterface()->setActiveCamera(oldCam);

if (1)
Expand All @@ -1222,8 +1219,6 @@ void OpenGLGuiHelper::copyCameraImageData(const float viewMatrix[16], const floa
getRenderInterface()->updateCamera(dg.upAxis);
m_data->m_glApp->m_window->startRendering();
}


}
if (pixelsRGBA)
{
Expand Down Expand Up @@ -1254,8 +1249,8 @@ void OpenGLGuiHelper::copyCameraImageData(const float viewMatrix[16], const floa
if (numPixelsCopied)
*numPixelsCopied = numRequestedPixels;
}
m_data->m_glApp->setViewport(-1,-1);

m_data->m_glApp->setViewport(-1, -1);
}

struct MyConvertPointerSizeT
Expand Down Expand Up @@ -1346,7 +1341,7 @@ void OpenGLGuiHelper::computeSoftBodyVertices(btCollisionShape* collisionShape,
b3Assert(collisionShape->getUserPointer());
btSoftBody* psb = (btSoftBody*)collisionShape->getUserPointer();
gfxVertices.resize(psb->m_faces.size() * 3);

for (int i = 0; i < psb->m_faces.size(); i++) // Foreach face
{
for (int k = 0; k < 3; k++) // Foreach vertex on a face
Expand Down
53 changes: 26 additions & 27 deletions examples/OpenGLWindow/SimpleOpenGL3App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,23 @@ struct SimpleInternalData
int m_customViewPortWidth;
int m_customViewPortHeight;
SimpleInternalData()
:m_fontTextureId(0),
m_largeFontTextureId(0),
m_fontStash(0),
m_fontStash2(0),
m_renderCallbacks(0),
m_renderCallbacks2(0),
m_droidRegular(0),
m_droidRegular2(0),
m_frameDumpPngFileName(0),
m_ffmpegFile(0),
m_renderTexture(0),
m_userPointer(0),
m_upAxis(0),
m_customViewPortWidth(-1),
m_customViewPortHeight(-1)
{
}
: m_fontTextureId(0),
m_largeFontTextureId(0),
m_fontStash(0),
m_fontStash2(0),
m_renderCallbacks(0),
m_renderCallbacks2(0),
m_droidRegular(0),
m_droidRegular2(0),
m_frameDumpPngFileName(0),
m_ffmpegFile(0),
m_renderTexture(0),
m_userPointer(0),
m_upAxis(0),
m_customViewPortWidth(-1),
m_customViewPortHeight(-1)
{
}
};

static SimpleOpenGL3App* gApp = 0;
Expand Down Expand Up @@ -308,7 +308,6 @@ SimpleOpenGL3App::SimpleOpenGL3App(const char* title, int width, int height, boo
gApp = this;

m_data = new SimpleInternalData;


if (windowType == 0)
{
Expand Down Expand Up @@ -925,24 +924,24 @@ SimpleOpenGL3App::~SimpleOpenGL3App()
delete m_data;
}


void SimpleOpenGL3App::setViewport(int width, int height)
{
m_data->m_customViewPortWidth=width;
m_data->m_customViewPortHeight=height;
if (width>=0)
m_data->m_customViewPortWidth = width;
m_data->m_customViewPortHeight = height;
if (width >= 0)
{
glViewport(0,0,width,height);
} else
glViewport(0, 0, width, height);
}
else
{
glViewport(0,0,m_window->getRetinaScale()*m_instancingRenderer->getScreenWidth(),m_window->getRetinaScale()*m_instancingRenderer->getScreenHeight());
glViewport(0, 0, m_window->getRetinaScale() * m_instancingRenderer->getScreenWidth(), m_window->getRetinaScale() * m_instancingRenderer->getScreenHeight());
}
}

void SimpleOpenGL3App::getScreenPixels(unsigned char* rgbaBuffer, int bufferSizeInBytes, float* depthBuffer, int depthBufferSizeInBytes)
{
int width = m_data->m_customViewPortWidth>=0? m_data->m_customViewPortWidth : (int)m_window->getRetinaScale() * m_instancingRenderer->getScreenWidth();
int height = m_data->m_customViewPortHeight >=0? m_data->m_customViewPortHeight: (int)m_window->getRetinaScale() * m_instancingRenderer->getScreenHeight();
int width = m_data->m_customViewPortWidth >= 0 ? m_data->m_customViewPortWidth : (int)m_window->getRetinaScale() * m_instancingRenderer->getScreenWidth();
int height = m_data->m_customViewPortHeight >= 0 ? m_data->m_customViewPortHeight : (int)m_window->getRetinaScale() * m_instancingRenderer->getScreenHeight();

b3Assert((width * height * 4) == bufferSizeInBytes);
if ((width * height * 4) == bufferSizeInBytes)
Expand Down
49 changes: 20 additions & 29 deletions examples/SharedMemory/PhysicsServerCommandProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1726,7 +1726,6 @@ struct PhysicsServerCommandProcessorInternalData
}
#endif //ENABLE_STATIC_GRPC_PLUGIN


#ifdef STATIC_EGLRENDERER_PLUGIN
{
bool initPlugin = false;
Expand All @@ -1735,15 +1734,12 @@ struct PhysicsServerCommandProcessorInternalData
}
#endif //STATIC_EGLRENDERER_PLUGIN


#ifndef SKIP_STATIC_TINYRENDERER_PLUGIN
{
int renderPluginId = m_pluginManager.registerStaticLinkedPlugin("tinyRendererPlugin", initPlugin_tinyRendererPlugin, exitPlugin_tinyRendererPlugin, executePluginCommand_tinyRendererPlugin, 0, 0, getRenderInterface_tinyRendererPlugin, 0, 0);
m_pluginManager.selectPluginRenderer(renderPluginId);
}
#endif


}

m_vrControllerEvents.init();
Expand Down Expand Up @@ -2743,30 +2739,27 @@ bool PhysicsServerCommandProcessor::processImportedObjects(const char* fileName,
if (mb)
mb->setUserIndex2(bodyUniqueId);



if (mb)
{
bodyHandle->m_multiBody = mb;

m_data->m_sdfRecentLoadedBodies.push_back(bodyUniqueId);


int segmentationMask = bodyUniqueId;

{
int graphicsIndex = -1;
if (mb->getBaseCollider())
{
graphicsIndex = mb->getBaseCollider()->getUserIndex();
}
if (graphicsIndex>=0)
if (graphicsIndex >= 0)
{
if (m_data->m_graphicsIndexToSegmentationMask.size()<(graphicsIndex+1))
if (m_data->m_graphicsIndexToSegmentationMask.size() < (graphicsIndex + 1))
{
m_data->m_graphicsIndexToSegmentationMask.resize(graphicsIndex+1);
m_data->m_graphicsIndexToSegmentationMask.resize(graphicsIndex + 1);
}
m_data->m_graphicsIndexToSegmentationMask[graphicsIndex]= segmentationMask;
m_data->m_graphicsIndexToSegmentationMask[graphicsIndex] = segmentationMask;
}
}

Expand Down Expand Up @@ -2811,20 +2804,20 @@ bool PhysicsServerCommandProcessor::processImportedObjects(const char* fileName,
int graphicsIndex = -1;
if (mb->getLinkCollider(i))
{
graphicsIndex = mb->getLinkCollider(i)->getUserIndex();
graphicsIndex = mb->getLinkCollider(i)->getUserIndex();
}
if (graphicsIndex>=0)
if (graphicsIndex >= 0)
{
int linkIndex = i;
if (m_data->m_graphicsIndexToSegmentationMask.size()<(graphicsIndex+1))
if (m_data->m_graphicsIndexToSegmentationMask.size() < (graphicsIndex + 1))
{
m_data->m_graphicsIndexToSegmentationMask.resize(graphicsIndex+1);
m_data->m_graphicsIndexToSegmentationMask.resize(graphicsIndex + 1);
}
int segmentationMask = bodyUniqueId + ((linkIndex + 1) << 24);
m_data->m_graphicsIndexToSegmentationMask[graphicsIndex]= segmentationMask;
m_data->m_graphicsIndexToSegmentationMask[graphicsIndex] = segmentationMask;
}
}

std::string* jointName = new std::string(u2b.getJointName(urdfLinkIndex).c_str());
m_data->m_strings.push_back(jointName);

Expand Down Expand Up @@ -2860,13 +2853,13 @@ bool PhysicsServerCommandProcessor::processImportedObjects(const char* fileName,
{
graphicsIndex = rb->getUserIndex();
}
if (graphicsIndex>=0)
if (graphicsIndex >= 0)
{
if (m_data->m_graphicsIndexToSegmentationMask.size()<(graphicsIndex+1))
if (m_data->m_graphicsIndexToSegmentationMask.size() < (graphicsIndex + 1))
{
m_data->m_graphicsIndexToSegmentationMask.resize(graphicsIndex+1);
m_data->m_graphicsIndexToSegmentationMask.resize(graphicsIndex + 1);
}
m_data->m_graphicsIndexToSegmentationMask[graphicsIndex]= segmentationMask;
m_data->m_graphicsIndexToSegmentationMask[graphicsIndex] = segmentationMask;
}
}

Expand Down Expand Up @@ -3524,9 +3517,9 @@ bool PhysicsServerCommandProcessor::processRequestCameraImageCommand(const struc
this->m_data->m_guiHelper->setProjectiveTexture(false);
}

if ((flags & (ER_SEGMENTATION_MASK_OBJECT_AND_LINKINDEX + ER_SEGMENTATION_MASK))==0)
if ((flags & (ER_SEGMENTATION_MASK_OBJECT_AND_LINKINDEX + ER_SEGMENTATION_MASK)) == 0)
{
segmentationMaskBuffer=0;
segmentationMaskBuffer = 0;
}
m_data->m_guiHelper->copyCameraImageData(viewMat,
projMat, pixelRGBA, numRequestedPixels,
Expand All @@ -3540,11 +3533,11 @@ bool PhysicsServerCommandProcessor::processRequestCameraImageCommand(const struc

if (segmentationMaskBuffer)
{
for (int i=0;i<numPixelsCopied;i++)
for (int i = 0; i < numPixelsCopied; i++)
{
int graphicsSegMask = segmentationMaskBuffer[i];
int segMask = -1;
if ((graphicsSegMask >= 0) && (graphicsSegMask<m_data->m_graphicsIndexToSegmentationMask.size()))
if ((graphicsSegMask >= 0) && (graphicsSegMask < m_data->m_graphicsIndexToSegmentationMask.size()))
{
segMask = m_data->m_graphicsIndexToSegmentationMask[graphicsSegMask];
}
Expand All @@ -3557,10 +3550,8 @@ bool PhysicsServerCommandProcessor::processRequestCameraImageCommand(const struc
}
segmentationMaskBuffer[i] = segMask;
}

}


handled = true;
m_data->m_guiHelper->debugDisplayCameraImageData(viewMat,
projMat, pixelRGBA, numRequestedPixels,
Expand Down Expand Up @@ -5767,7 +5758,7 @@ bool PhysicsServerCommandProcessor::processSendDesiredStateCommand(const struct
}
}
} //fi
//break;
//break;
}
}
} //if (body && body->m_rigidBody)
Expand Down
2 changes: 1 addition & 1 deletion examples/SharedMemory/SharedMemoryPublic.h
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ enum EnumRendererAuxFlags
{
ER_SEGMENTATION_MASK_OBJECT_AND_LINKINDEX = 1,
ER_USE_PROJECTIVE_TEXTURE = 2,
ER_SEGMENTATION_MASK=4,
ER_SEGMENTATION_MASK = 4,
};

///flags to pick the IK solver and other options
Expand Down
Loading

0 comments on commit 42ae4e8

Please sign in to comment.