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

@@ -10,7 +10,6 @@
#include "../CommonInterfaces/CommonRenderInterface.h"
#include "../CommonInterfaces/CommonParameterInterface.h"
struct TestCanvasInterface2 : public Common2dCanvasInterface
{
@@ -19,53 +18,49 @@ struct TestCanvasInterface2 : public Common2dCanvasInterface
int m_height;
TestCanvasInterface2(b3AlignedObjectArray<unsigned char>& texelsRGB, int width, int height)
:
m_texelsRGB(texelsRGB),
m_width(width),
m_height(height)
: m_texelsRGB(texelsRGB),
m_width(width),
m_height(height)
{
}
virtual ~TestCanvasInterface2()
{}
virtual int createCanvas(const char* canvasName, int width, int height,int posX,int posY)
virtual ~TestCanvasInterface2()
{
}
virtual int createCanvas(const char* canvasName, int width, int height, int posX, int posY)
{
return 0;
}
virtual void destroyCanvas(int canvasId)
{
}
virtual void setPixel(int canvasId, int x, int y, unsigned char red, unsigned char green,unsigned char blue, unsigned char alpha)
virtual void setPixel(int canvasId, int x, int y, unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha)
{
if (x>=0 && x<m_width && y>=0 && y<m_height)
if (x >= 0 && x < m_width && y >= 0 && y < m_height)
{
m_texelsRGB[(x+y*m_width)*3+0] = red;
m_texelsRGB[(x+y*m_width)*3+1] = green;
m_texelsRGB[(x+y*m_width)*3+2] = blue;
m_texelsRGB[(x + y * m_width) * 3 + 0] = red;
m_texelsRGB[(x + y * m_width) * 3 + 1] = green;
m_texelsRGB[(x + y * m_width) * 3 + 2] = blue;
}
}
virtual void getPixel(int canvasId, int x, int y, unsigned char& red, unsigned char& green,unsigned char& blue, unsigned char& alpha)
virtual void getPixel(int canvasId, int x, int y, unsigned char& red, unsigned char& green, unsigned char& blue, unsigned char& alpha)
{
if (x>=0 && x<m_width && y>=0 && y<m_height)
if (x >= 0 && x < m_width && y >= 0 && y < m_height)
{
red = m_texelsRGB[(x+y*m_width)*3+0];
green = m_texelsRGB[(x+y*m_width)*3+1];
blue = m_texelsRGB[(x+y*m_width)*3+2];
red = m_texelsRGB[(x + y * m_width) * 3 + 0];
green = m_texelsRGB[(x + y * m_width) * 3 + 1];
blue = m_texelsRGB[(x + y * m_width) * 3 + 2];
}
}
virtual void refreshImageData(int canvasId)
{
}
};
struct TinyVRGuiInternalData
{
CommonRenderInterface* m_renderer;
CommonRenderInterface* m_renderer;
b3AlignedObjectArray<unsigned char> m_texelsRGB;
TestCanvasInterface2* m_testCanvas;
@@ -75,23 +70,20 @@ struct TinyVRGuiInternalData
int m_gfxObjectId;
TinyVRGuiInternalData()
:m_renderer(0),
m_testCanvas(0),
m_timeSeries(0),
m_src(-1),
m_textureId(-1),
m_gfxObjectId(-1)
: m_renderer(0),
m_testCanvas(0),
m_timeSeries(0),
m_src(-1),
m_textureId(-1),
m_gfxObjectId(-1)
{
}
};
TinyVRGui::TinyVRGui(struct ComboBoxParams& params, struct CommonRenderInterface* renderer)
TinyVRGui::TinyVRGui(struct ComboBoxParams& params, struct CommonRenderInterface* renderer)
{
m_data = new TinyVRGuiInternalData;
m_data->m_renderer = renderer;
}
TinyVRGui::~TinyVRGui()
@@ -100,123 +92,109 @@ TinyVRGui::~TinyVRGui()
delete m_data->m_testCanvas;
delete m_data;
}
bool TinyVRGui::init()
{
{
int width = 256;
int height = 256;
m_data->m_texelsRGB.resize(width*height*3);
for (int i=0;i<width;i++)
for (int j=0;j<height;j++)
{
m_data->m_texelsRGB[(i+j*width)*3+0] = 155;
m_data->m_texelsRGB[(i+j*width)*3+1] = 155;
m_data->m_texelsRGB[(i+j*width)*3+2] = 255;
}
m_data->m_testCanvas = new TestCanvasInterface2(m_data->m_texelsRGB,width,height);
m_data->m_timeSeries = new TimeSeriesCanvas(m_data->m_testCanvas,width,height,"time series");
bool clearCanvas = false;
m_data->m_timeSeries->setupTimeSeries(3,100, 0,clearCanvas);
m_data->m_timeSeries->addDataSource("Some sine wave", 255,0,0);
m_data->m_timeSeries->addDataSource("Some cosine wave", 0,255,0);
m_data->m_timeSeries->addDataSource("Delta Time (*10)", 0,0,255);
m_data->m_timeSeries->addDataSource("Tan", 255,0,255);
m_data->m_timeSeries->addDataSource("Some cosine wave2", 255,255,0);
m_data->m_timeSeries->addDataSource("Empty source2", 255,0,255);
m_data->m_textureId = m_data->m_renderer->registerTexture(&m_data->m_texelsRGB[0],width,height);
{
int width = 256;
int height = 256;
m_data->m_texelsRGB.resize(width * height * 3);
for (int i = 0; i < width; i++)
for (int j = 0; j < height; j++)
{
const char* fileName = "cube.obj";//"textured_sphere_smooth.obj";
m_data->m_texelsRGB[(i + j * width) * 3 + 0] = 155;
m_data->m_texelsRGB[(i + j * width) * 3 + 1] = 155;
m_data->m_texelsRGB[(i + j * width) * 3 + 2] = 255;
}
m_data->m_testCanvas = new TestCanvasInterface2(m_data->m_texelsRGB, width, height);
m_data->m_timeSeries = new TimeSeriesCanvas(m_data->m_testCanvas, width, height, "time series");
bool clearCanvas = false;
m_data->m_timeSeries->setupTimeSeries(3, 100, 0, clearCanvas);
m_data->m_timeSeries->addDataSource("Some sine wave", 255, 0, 0);
m_data->m_timeSeries->addDataSource("Some cosine wave", 0, 255, 0);
m_data->m_timeSeries->addDataSource("Delta Time (*10)", 0, 0, 255);
m_data->m_timeSeries->addDataSource("Tan", 255, 0, 255);
m_data->m_timeSeries->addDataSource("Some cosine wave2", 255, 255, 0);
m_data->m_timeSeries->addDataSource("Empty source2", 255, 0, 255);
m_data->m_textureId = m_data->m_renderer->registerTexture(&m_data->m_texelsRGB[0], width, height);
{
const char* fileName = "cube.obj"; //"textured_sphere_smooth.obj";
//fileName = "cube.obj";
int shapeId = -1;
b3ImportMeshData meshData;
if (b3ImportMeshUtility::loadAndRegisterMeshFromFileInternal(fileName, meshData))
{
shapeId = m_data->m_renderer->registerShape(&meshData.m_gfxShape->m_vertices->at(0).xyzw[0],
meshData.m_gfxShape->m_numvertices,
&meshData.m_gfxShape->m_indices->at(0),
meshData.m_gfxShape->m_numIndices,
B3_GL_TRIANGLES,
m_data->m_textureId);
shapeId = m_data->m_renderer->registerShape(&meshData.m_gfxShape->m_vertices->at(0).xyzw[0],
meshData.m_gfxShape->m_numvertices,
&meshData.m_gfxShape->m_indices->at(0),
meshData.m_gfxShape->m_numIndices,
B3_GL_TRIANGLES,
m_data->m_textureId);
float position[4] = {0, 0, 2, 1};
float orn[4] = {0, 0, 0, 1};
float color[4] = {1, 1, 1, 1};
float scaling[4] = {.1, .1, .1, 1};
float position[4]={0,0,2,1};
float orn[4]={0,0,0,1};
float color[4]={1,1,1,1};
float scaling[4]={.1,.1,.1,1};
m_data->m_gfxObjectId = m_data->m_renderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
m_data->m_gfxObjectId = m_data->m_renderer->registerGraphicsInstance(shapeId, position, orn, color, scaling);
m_data->m_renderer->writeTransforms();
meshData.m_gfxShape->m_scaling[0] = scaling[0];
meshData.m_gfxShape->m_scaling[1] = scaling[1];
meshData.m_gfxShape->m_scaling[2] = scaling[2];
delete meshData.m_gfxShape;
if (!meshData.m_isCached)
{
free(meshData.m_textureImage1);
}
}
}
}
}
}
m_data->m_renderer->writeTransforms();
return true;
m_data->m_renderer->writeTransforms();
return true;
}
void TinyVRGui::tick(b3Scalar deltaTime, const b3Transform& guiWorldTransform)
{
float time = m_data->m_timeSeries->getCurrentTime();
float v = sinf(time);
m_data->m_timeSeries->insertDataAtCurrentTime(v,0,true);
m_data->m_timeSeries->insertDataAtCurrentTime(v, 0, true);
v = cosf(time);
m_data->m_timeSeries->insertDataAtCurrentTime(v,1,true);
m_data->m_timeSeries->insertDataAtCurrentTime(v, 1, true);
v = tanf(time);
m_data->m_timeSeries->insertDataAtCurrentTime(v,3,true);
m_data->m_timeSeries->insertDataAtCurrentTime(deltaTime*10,2,true);
m_data->m_timeSeries->insertDataAtCurrentTime(v, 3, true);
m_data->m_timeSeries->insertDataAtCurrentTime(deltaTime * 10, 2, true);
m_data->m_timeSeries->nextTick();
m_data->m_renderer->updateTexture(m_data->m_textureId,&m_data->m_texelsRGB[0]);
m_data->m_renderer->writeSingleInstanceTransformToCPU(guiWorldTransform.getOrigin(),guiWorldTransform.getRotation(),m_data->m_gfxObjectId);
m_data->m_renderer->writeTransforms();
m_data->m_renderer->updateTexture(m_data->m_textureId, &m_data->m_texelsRGB[0]);
m_data->m_renderer->writeSingleInstanceTransformToCPU(guiWorldTransform.getOrigin(), guiWorldTransform.getRotation(), m_data->m_gfxObjectId);
m_data->m_renderer->writeTransforms();
}
void TinyVRGui::clearTextArea()
{
int width = 256;
int height = 50;
for (int i=0;i<width;i++)
for (int j=0;j<height;j++)
{
m_data->m_texelsRGB[(i+j*width)*3+0] = 155;
m_data->m_texelsRGB[(i+j*width)*3+1] = 155;
m_data->m_texelsRGB[(i+j*width)*3+2] = 255;
}
int width = 256;
int height = 50;
for (int i = 0; i < width; i++)
for (int j = 0; j < height; j++)
{
m_data->m_texelsRGB[(i + j * width) * 3 + 0] = 155;
m_data->m_texelsRGB[(i + j * width) * 3 + 1] = 155;
m_data->m_texelsRGB[(i + j * width) * 3 + 2] = 255;
}
}
void TinyVRGui::grapicalPrintf(const char* str,int rasterposx,int rasterposy,unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha)
void TinyVRGui::grapicalPrintf(const char* str, int rasterposx, int rasterposy, unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha)
{
m_data->m_timeSeries->grapicalPrintf(str,sTimeSeriesFontData,rasterposx,rasterposy,red,green,blue,alpha);
m_data->m_timeSeries->grapicalPrintf(str, sTimeSeriesFontData, rasterposx, rasterposy, red, green, blue, alpha);
}