Merge pull request #22 from dominiquevincent/19171

Code Review for Job #19171
This commit is contained in:
birarda 2013-04-10 15:49:23 -07:00
commit 88c2e9510d
12 changed files with 560 additions and 35 deletions

144
interface/src/Menu.cpp Normal file
View file

@ -0,0 +1,144 @@
#include <algorithm>
#include "InterfaceConfig.h"
#include "Util.h"
#include "MenuRow.h"
#include "MenuColumn.h"
#include "Menu.h"
const int LINE_HEIGHT = 30;
const int MENU_HEIGHT = 30;
const int MENU_Y_OFFSET = 8; // under windows we have 8 vertical pixels offset. In 2D an object with y=8, the object is displayed at y=0
// change the value in the other platforms (if required).
Menu::Menu() {
currentColumn = -1;
leftMouseOver = 0;
rightMouseOver = 0;
topMouseOver = 0;
bottomMouseOver = 0;
}
Menu::~Menu() {
columns.clear();
}
void Menu::mouseClickColumn(int columnIndex) {
if (currentColumn == columnIndex) {
currentColumn = -1;
} else {
currentColumn = columnIndex;
}
}
void Menu::setMouseOver(int leftPosition, int rightPosition, int top, int bottom) {
leftMouseOver = leftPosition;
rightMouseOver = rightPosition;
topMouseOver = top;
bottomMouseOver = bottom;
}
void Menu::renderMouseOver() {
if (leftMouseOver != 0 || topMouseOver != 0 || rightMouseOver != 0 ||& bottomMouseOver != 0) {
glColor4f(0, 0, 0, 0.1);
glBegin(GL_QUADS); {
glVertex2f(leftMouseOver, MENU_Y_OFFSET + topMouseOver);
glVertex2f(rightMouseOver, MENU_Y_OFFSET + topMouseOver);
glVertex2f(rightMouseOver, MENU_Y_OFFSET + bottomMouseOver);
glVertex2f(leftMouseOver, MENU_Y_OFFSET + bottomMouseOver);
}
glEnd();
}
}
bool Menu::mouseClick(int x, int y) {
int leftPosition = 0.5 * SPACE_BETWEEN_COLUMNS;
int rightPosition = 0;
int columnWidth = 0;
bool menuFound = false;
for (unsigned int i = 0; i < columns.size(); ++i) {
columnWidth = columns[i].getWidth();
rightPosition = leftPosition + columnWidth + 1.5 * SPACE_BETWEEN_COLUMNS;
if (x > leftPosition && x < rightPosition && y > 0 && y < MENU_HEIGHT) {
mouseClickColumn(i);
menuFound = true;
break;
} else if (currentColumn == i) {
menuFound = columns[i].mouseClick(x, y, leftPosition, MENU_HEIGHT, LINE_HEIGHT);
if (menuFound) {
currentColumn = -1;
}
}
leftPosition = rightPosition;
}
return menuFound;
}
bool Menu::mouseOver(int x, int y) {
int leftPosition = 0.5 * SPACE_BETWEEN_COLUMNS;
int rightPosition;
int columnWidth;
bool overMenu = false;
for (unsigned int i = 0; i < columns.size(); ++i) {
columnWidth = columns[i].getWidth();
rightPosition = leftPosition + columnWidth + SPACE_BETWEEN_COLUMNS;
if (x > leftPosition && x < rightPosition && y > 0 && y < MENU_HEIGHT) {
setMouseOver(leftPosition, rightPosition, 0, MENU_HEIGHT);
overMenu = true;
if (currentColumn >= 0) {
columns[currentColumn].setMouseOver(0, 0, 0, 0);
currentColumn = i;
}
break;
} else if (currentColumn == i) {
columns[i].mouseOver(x, y, leftPosition, MENU_HEIGHT, LINE_HEIGHT);
}
leftPosition = rightPosition;
}
if (!overMenu) {
setMouseOver(0, 0, 0, 0);
}
return overMenu;
}
void Menu::render(int screenWidth, int screenHeight) {
float scale = 0.10;
int mono = 0;
glColor3f(0.9, 0.9, 0.9);
int width = screenWidth;
int height = screenHeight;
glBegin(GL_QUADS); {
glVertex2f(0, MENU_Y_OFFSET);
glVertex2f(width, MENU_Y_OFFSET);
glVertex2f(width, MENU_HEIGHT + MENU_Y_OFFSET);
glVertex2f(0 , MENU_HEIGHT + MENU_Y_OFFSET);
}
glEnd();
int xPosition = SPACE_BETWEEN_COLUMNS;
char* columnName;
int columnWidth;
for (unsigned int i = 0; i < columns.size(); ++i) {
columnName = columns[i].getName();
columnWidth = columns[i].getWidth(scale, mono, xPosition - 0.5 * SPACE_BETWEEN_COLUMNS);
drawtext(xPosition, 18 + MENU_Y_OFFSET, scale, 0, 1.0, mono, columnName, 0, 0, 0);
xPosition += columnWidth + SPACE_BETWEEN_COLUMNS;
if (currentColumn == i) {
columns[i].render(MENU_Y_OFFSET, MENU_HEIGHT, LINE_HEIGHT);
}
}
renderMouseOver();
}
MenuColumn* Menu::addColumn(char *columnName) {
MenuColumn* pColumn;
pColumn = new MenuColumn(columnName);
columns.push_back(*pColumn);
delete pColumn;
return &columns[columns.size() - 1];
}

27
interface/src/Menu.h Normal file
View file

@ -0,0 +1,27 @@
#ifndef __hifi__Menu__
#define __hifi__Menu__
#include <vector>
class Menu {
public:
Menu();
~Menu();
void mouseClickColumn(int iColumnIndex);
void setMouseOver(int xLeft, int xRight, int yTop, int yBottom);
void renderMouseOver();
bool mouseClick(int x, int y);
bool mouseOver(int x, int y);
void render(int screenwidth, int screenheight);
void renderColumn(int i);
MenuColumn* addColumn(char *columnName);
private:
std::vector<MenuColumn> columns;
int currentColumn;
int leftMouseOver;
int rightMouseOver;
int topMouseOver;
int bottomMouseOver;
};
#endif /* defined(__hifi__Menu__) */

View file

@ -0,0 +1,149 @@
#include <algorithm>
#include "InterfaceConfig.h"
#include "Util.h"
#include "MenuRow.h"
#include "MenuColumn.h"
#include "Menu.h"
MenuColumn::MenuColumn() {
}
MenuColumn::MenuColumn(char * columnName) {
int length = std::min(MAX_COLUMN_NAME - 1,(int) strlen(columnName));
strncpy(this->columnName, columnName, length);
this->columnName[length] = '\0';
columnWidth = 0;
leftPosition = 0;
leftMouseOver = 0;
rightMouseOver = 0;
topMouseOver = 0;
bottomMouseOver = 0;
}
MenuColumn::~MenuColumn() {
rows.clear();
}
void MenuColumn::mouseClickRow(int numberOfRowsIndex) {
rows[numberOfRowsIndex].call();
}
bool MenuColumn::mouseClick(int x, int y, int leftPosition, int menuHeight, int lineHeight) {
int rightPosition = leftPosition + 200;
int topPosition = menuHeight;
int bottomPosition = menuHeight;
int columnWidth = 0;
bool menuFound = false;
for (unsigned int i = 0; i < rows.size(); ++i) {
columnWidth = rows[i].getWidth();
topPosition = bottomPosition + lineHeight;
if (x > leftPosition && x < rightPosition && y > bottomPosition && y < topPosition) {
mouseClickRow(i);
menuFound = true;
break;
}
bottomPosition = topPosition;
}
return menuFound;
}
void MenuColumn::setMouseOver(int leftPosition, int rightPosition, int topPosition, int bottomPosition) {
leftMouseOver = leftPosition;
rightMouseOver = rightPosition;
topMouseOver = topPosition;
bottomMouseOver = bottomPosition;
}
bool MenuColumn::mouseOver(int x, int y, int leftPosition, int menuHeight, int lineHeight) {
int rightPosition = leftPosition + 100;
int topPosition = menuHeight;
int bottomPosition = menuHeight;
int columnWidth = 0;
bool overMenu = false;
for (unsigned int i = 0; i < rows.size(); ++i) {
columnWidth = rows[i].getWidth();
topPosition = bottomPosition + lineHeight ;
if (x > leftPosition && x < rightPosition && y > bottomPosition && y < topPosition) {
setMouseOver(leftPosition, rightPosition, bottomPosition, topPosition);
overMenu = true;
break;
}
bottomPosition = topPosition;
}
if (!overMenu) {
setMouseOver(0, 0, 0, 0);
}
return overMenu;
}
char* MenuColumn::getName() {
return this->columnName;
}
int MenuColumn::getWidth(float scale, int mono, int leftPosition) {
if (columnWidth == 0) {
columnWidth = widthText(scale, mono, this->columnName);
this->leftPosition = leftPosition;
}
return columnWidth;
}
int MenuColumn::getWidth() {
return columnWidth;
}
int MenuColumn::getLeftPosition() {
return leftPosition;
}
int MenuColumn::addRow(char * rowName, PFNRowCallback callback) {
MenuRow* row;
row = new MenuRow(rowName, callback);
rows.push_back(*row);
delete row;
return 0;
}
void MenuColumn::render(int yOffset, int menuHeight, int lineHeight) {
int numberOfRows = rows.size();
if (numberOfRows > 0) {
glColor3f(0.9,0.9,0.9);
glBegin(GL_QUADS); {
glVertex2f(leftPosition, yOffset + menuHeight);
glVertex2f(leftPosition+100, yOffset + menuHeight);
glVertex2f(leftPosition+100, yOffset + menuHeight + numberOfRows*lineHeight);
glVertex2f(leftPosition , yOffset + menuHeight + numberOfRows* lineHeight);
}
glEnd();
}
float scale = 0.10;
int mono = 0;
int y = menuHeight + lineHeight / 2 ;
char* rowName;
int columnWidth = 0;
for (unsigned int i = 0; i < rows.size(); ++i) {
rowName = rows[i].getName();
columnWidth = rows[i].getWidth(scale, mono, 0);
drawtext(leftPosition + SPACE_BEFORE_ROW_NAME, y+5 + yOffset, scale, 0, 1.0, mono, rowName, 0, 0, 0);
y += lineHeight;
}
renderMouseOver(yOffset);
}
void MenuColumn::renderMouseOver(int yOffset) {
if (leftMouseOver != 0 || topMouseOver != 0 || rightMouseOver != 0 ||& bottomMouseOver != 0) {
glColor4f(0,0,0,0.1);
glBegin(GL_QUADS); {
glVertex2f(leftMouseOver, yOffset + topMouseOver);
glVertex2f(rightMouseOver, yOffset + topMouseOver);
glVertex2f(rightMouseOver, yOffset + bottomMouseOver);
glVertex2f(leftMouseOver , yOffset + bottomMouseOver);
}
glEnd();
}
}

View file

@ -0,0 +1,33 @@
#ifndef __hifi__MenuColumn__
#define __hifi__MenuColumn__
#include <vector>
class MenuColumn {
public:
MenuColumn();
MenuColumn(char * columnName);
~MenuColumn();
void mouseClickRow(int iColumnIndex);
bool mouseClick(int x, int y, int xLeft, int menuHeight, int lineHeight);
void setMouseOver(int xLeft, int xRight, int yTop, int yBottom);
bool mouseOver(int x, int y, int xLeft, int menuHeight, int lineHeight);
char* getName();
int getWidth(float scale, int mono, int leftPosition);
int getWidth();
int getLeftPosition();
void render(int yOffset, int menuHeight, int lineHeight);
void MenuColumn::renderMouseOver(int yOffset);
int addRow(char * rowName, PFNRowCallback callback);
private:
char columnName[MAX_COLUMN_NAME];
int columnWidth;
int leftPosition;
std::vector<MenuRow> rows;
int leftMouseOver;
int rightMouseOver;
int topMouseOver;
int bottomMouseOver;
};
#endif /* defined(__hifi__MenuColumn__) */

53
interface/src/MenuRow.cpp Normal file
View file

@ -0,0 +1,53 @@
#include <algorithm>
#include "InterfaceConfig.h"
#include "Util.h"
#include "MenuRow.h"
#include "MenuColumn.h"
#include "Menu.h"
MenuRow::MenuRow() {
}
MenuRow::MenuRow(char * columnName, PFNRowCallback callback) {
int length = std::min(MAX_COLUMN_NAME - 5,(int) strlen(columnName));
strncpy(this->rowName, columnName, length);
memcpy(this->rowName + length, " \0", 5);
this->callback = callback;
rowWidth = 0;
}
MenuRow::~MenuRow() {
}
void MenuRow::call() {
callback(-2);
}
char* MenuRow::getName() {
int length = (int) strlen(this->rowName) - 4;
int currentValue = callback(-1);
if (currentValue == 0) {
memcpy(this->rowName + length, " OFF\0", 5);
} else if (currentValue == 1) {
memcpy(this->rowName + length, " ON \0", 5);
} else {
memcpy(this->rowName + length, " \0", 5);
}
return this->rowName;
}
int MenuRow::getWidth(float scale, int mono, int leftPosition) {
if (rowWidth == 0) {
rowWidth = widthText( scale, mono, this->rowName);
}
return rowWidth;
}
int MenuRow::getWidth() {
return rowWidth;
}

27
interface/src/MenuRow.h Normal file
View file

@ -0,0 +1,27 @@
#ifndef __hifi__MenuRow__
#define __hifi__MenuRow__
const int MAX_COLUMN_NAME = 50;
const int SPACE_BETWEEN_COLUMNS = 20;
const int SPACE_BEFORE_ROW_NAME = 10;
#define MenuCallBack CALLBACK
typedef int(MenuCallBack * PFNRowCallback)(int);
class MenuRow {
public:
MenuRow();
MenuRow(char * rowName, PFNRowCallback);
~MenuRow();
void call();
char * getName();
int getWidth(float scale, int mono, int leftPosition);
int getWidth();
private:
char rowName[MAX_COLUMN_NAME];
int rowWidth;
PFNRowCallback callback;
};
#endif /* defined(__hifi__MenuRow__) */

View file

@ -90,6 +90,16 @@ double diffclock(timeval *clock1,timeval *clock2)
return diffms;
}
int widthText(float scale, int mono, char *string) {
int width = 0;
if (!mono) {
width = scale * glutStrokeLength(GLUT_STROKE_ROMAN, (const unsigned char *) string);
} else {
width = scale * glutStrokeLength(GLUT_STROKE_MONO_ROMAN, (const unsigned char *) string);
}
return width;
}
void drawtext(int x, int y, float scale, float rotate, float thick, int mono,
char const* string, float r, float g, float b)
{

View file

@ -38,6 +38,7 @@ float angle_to(glm::vec3 head_pos, glm::vec3 source_pos, float render_yaw, float
float randFloat();
void render_world_box();
void render_vector(glm::vec3 * vec);
int widthText(float scale, int mono, char *string);
void drawtext(int x, int y, float scale, float rotate, float thick, int mono,
char const* string, float r=1.0, float g=1.0, float b=1.0);
void drawvec3(int x, int y, float scale, float rotate, float thick, int mono, glm::vec3 vec,

View file

@ -57,6 +57,9 @@
#include "FieldOfView.h"
#include "Stars.h"
#include "MenuRow.h"
#include "MenuColumn.h"
#include "Menu.h"
#include "Head.h"
#include "Hand.h"
#include "Camera.h"
@ -175,6 +178,9 @@ int mouseX, mouseY; // Where is the mouse
int mouseStartX, mouseStartY; // Mouse location at start of last down click
int mousePressed = 0; // true if mouse has been pressed (clear when finished)
Menu menu; // main menu
int menuOn = 0; // Whether to show onscreen menu
//
// Serial USB Variables
//
@ -232,43 +238,47 @@ void Timer(int extra)
void displayStats(void)
{
int statsVerticalOffset = 50;
if (::menuOn == 0) {
statsVerticalOffset = 8;
}
// bitmap chars are about 10 pels high
char legend[] = "/ - toggle this display, Q - exit, H - show head, M - show hand, T - test audio";
drawtext(10, 15, 0.10f, 0, 1.0, 0, legend);
drawtext(10, statsVerticalOffset + 15, 0.10f, 0, 1.0, 0, legend);
char legend2[] = "* - toggle stars, & - toggle paint mode, '-' - send erase all, '%' - send add scene";
drawtext(10, 32, 0.10f, 0, 1.0, 0, legend2);
drawtext(10, statsVerticalOffset + 32, 0.10f, 0, 1.0, 0, legend2);
glm::vec3 avatarPos = myAvatar.getPos();
char stats[200];
sprintf(stats, "FPS = %3.0f Pkts/s = %d Bytes/s = %d Head(x,y,z)=( %f , %f , %f )",
FPS, packetsPerSecond, bytesPerSecond, avatarPos.x,avatarPos.y,avatarPos.z);
drawtext(10, 49, 0.10f, 0, 1.0, 0, stats);
drawtext(10, statsVerticalOffset + 49, 0.10f, 0, 1.0, 0, stats);
if (serialPort.active) {
sprintf(stats, "ADC samples = %d, LED = %d",
serialPort.getNumSamples(), serialPort.getLED());
drawtext(300, 30, 0.10f, 0, 1.0, 0, stats);
drawtext(300, statsVerticalOffset + 30, 0.10f, 0, 1.0, 0, stats);
}
std::stringstream voxelStats;
voxelStats << "Voxels Rendered: " << voxels.getVoxelsRendered();
drawtext(10,70,0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
drawtext(10, statsVerticalOffset + 70, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
voxelStats.str("");
voxelStats << "Voxels Created: " << voxels.getVoxelsCreated() << " (" << voxels.getVoxelsCreatedRunningAverage()
<< "/sec in last "<< COUNTETSTATS_TIME_FRAME << " seconds) ";
drawtext(10,250,0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
drawtext(10, statsVerticalOffset + 250, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
voxelStats.str("");
voxelStats << "Voxels Colored: " << voxels.getVoxelsColored() << " (" << voxels.getVoxelsColoredRunningAverage()
<< "/sec in last "<< COUNTETSTATS_TIME_FRAME << " seconds) ";
drawtext(10,270,0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
drawtext(10, statsVerticalOffset + 270, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
voxelStats.str("");
voxelStats << "Voxels Bytes Read: " << voxels.getVoxelsBytesRead()
<< " (" << voxels.getVoxelsBytesReadRunningAverage() << "/sec in last "<< COUNTETSTATS_TIME_FRAME << " seconds) ";
drawtext(10,290,0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
drawtext(10, statsVerticalOffset + 290,0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
voxelStats.str("");
long int voxelsBytesPerColored = voxels.getVoxelsColored() ? voxels.getVoxelsBytesRead()/voxels.getVoxelsColored() : 0;
@ -277,7 +287,7 @@ void displayStats(void)
voxelStats << "Voxels Bytes per Colored: " << voxelsBytesPerColored
<< " (" << voxelsBytesPerColoredAvg << "/sec in last "<< COUNTETSTATS_TIME_FRAME << " seconds) ";
drawtext(10,310,0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
drawtext(10, statsVerticalOffset + 310, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
if (::perfStatsOn) {
@ -286,7 +296,7 @@ void displayStats(void)
int lines = PerfStat::DumpStats(perfStatLinesArray);
int atZ = 150; // arbitrary place on screen that looks good
for (int line=0; line < lines; line++) {
drawtext(10,atZ,0.10f, 0, 1.0, 0, perfStatLinesArray[line]);
drawtext(10, statsVerticalOffset + atZ, 0.10f, 0, 1.0, 0, perfStatLinesArray[line]);
delete perfStatLinesArray[line]; // we're responsible for cleanup
perfStatLinesArray[line]=NULL;
atZ+=20; // height of a line
@ -815,6 +825,13 @@ void display(void)
glPointSize(1.0f);
displayStats();
}
// Show menu
if (::menuOn) {
glLineWidth(1.0f);
glPointSize(1.0f);
menu.render(WIDTH,HEIGHT);
}
// Draw number of nearby people always
glPointSize(1.0f);
@ -838,6 +855,59 @@ void display(void)
frameCount++;
}
int MenuCallBack setValue(int state, int *value) {
if (state == -2) {
*value = !(*value);
} else if (state == -1) {
return *value;
} else {
*value = state;
}
return *value;
}
int MenuCallBack setHead(int state) {
return setValue(state, &displayHead);
}
int MenuCallBack setField(int state) {
return setValue(state, &displayField);
}
int MenuCallBack setNoise(int state) {
int iRet = setValue(state, &noiseOn);
if (noiseOn) {
myAvatar.setNoise(noise);
} else {
myAvatar.setNoise(0);
}
return iRet;
}
int MenuCallBack setStats(int state) {
return setValue(state, &statsOn);
}
int MenuCallBack setMenu(int state) {
return setValue(state, &::menuOn);
}
int MenuCallBack setMirror(int state) {
return setValue(state, &headMirror);
}
void initMenu() {
MenuColumn *menuColumnOptions, *menuColumnTools;
menuColumnOptions = menu.addColumn("Options");
menuColumnOptions->addRow("Head", setHead);
menuColumnOptions->addRow("Field", setField);
menuColumnOptions->addRow("Noise", setNoise);
menuColumnOptions->addRow("Mirror", setMirror);
menuColumnTools = menu.addColumn("Tools");
menuColumnTools->addRow("Stats", setStats);
menuColumnTools->addRow("Menu", setMenu);
}
void testPointToVoxel()
{
float y=0;
@ -1019,7 +1089,8 @@ void key(unsigned char k, int x, int y)
#endif
}
if (k == 'm') headMirror = !headMirror;
// if (k == 'm') headMirror = !headMirror; // move in the menu
if (k == 'm') setMenu(-2);
if (k == 'f') displayField = !displayField;
if (k == 'l') displayLevels = !displayLevels;
@ -1163,18 +1234,19 @@ void mouseFunc( int button, int state, int x, int y )
{
if( button == GLUT_LEFT_BUTTON && state == GLUT_DOWN )
{
mouseX = x;
mouseY = y;
mousePressed = 1;
lattice.mouseClick((float)x/(float)WIDTH,(float)y/(float)HEIGHT);
mouseStartX = x;
mouseStartY = y;
if (!menu.mouseClick(x, y)) {
mouseX = x;
mouseY = y;
mousePressed = 1;
lattice.mouseClick((float)x/(float)WIDTH, (float)y/(float)HEIGHT);
mouseStartX = x;
mouseStartY = y;
}
}
if( button == GLUT_LEFT_BUTTON && state == GLUT_UP )
{
mouseX = x;
mouseY = y;
mousePressed = 0;
if( button == GLUT_LEFT_BUTTON && state == GLUT_UP ) {
mouseX = x;
mouseY = y;
mousePressed = 0;
}
}
@ -1189,6 +1261,7 @@ void motionFunc( int x, int y)
void mouseoverFunc( int x, int y)
{
menu.mouseOver(x, y);
mouseX = x;
mouseY = y;
if (mousePressed == 0)
@ -1252,7 +1325,8 @@ int main(int argc, const char * argv[])
#endif
printf( "Created Display Window.\n" );
initMenu();
initDisplay();
printf( "Initialized Display.\n" );

View file

@ -311,18 +311,6 @@ void AgentList::stopSilentAgentRemovalThread() {
pthread_join(removeSilentAgentsThread, NULL);
}
#ifdef _WIN32
void usleep(int waitTime) {
__int64 time1 = 0, time2 = 0, sysFreq = 0;
QueryPerformanceCounter((LARGE_INTEGER *)&time1);
QueryPerformanceFrequency((LARGE_INTEGER *)&sysFreq);
do {
QueryPerformanceCounter((LARGE_INTEGER *)&time2);
} while( (time2 - time1) < waitTime);
}
#endif
void *checkInWithDomainServer(void *args) {
AgentList *parentAgentList = (AgentList *)args;

View file

@ -9,6 +9,9 @@
#include <cstdlib>
#include <cstdio>
#include <cstring>
#ifdef _WIN32
#include "Syssocket.h"
#endif
#include "SharedUtil.h"
#include "OctalCode.h"
@ -336,3 +339,15 @@ void printVoxelCode(unsigned char* voxelCode) {
outputBits(voxelCode[i]);
}
}
#ifdef _WIN32
void usleep(int waitTime) {
__int64 time1 = 0, time2 = 0, sysFreq = 0;
QueryPerformanceCounter((LARGE_INTEGER *)&time1);
QueryPerformanceFrequency((LARGE_INTEGER *)&sysFreq);
do {
QueryPerformanceCounter((LARGE_INTEGER *)&time2);
} while( (time2 - time1) < waitTime);
}
#endif

View file

@ -50,4 +50,8 @@ unsigned char* pointToVoxel(float x, float y, float z, float s, unsigned char r,
bool createVoxelEditMessage(unsigned char command, short int sequence,
int voxelCount, VoxelDetail* voxelDetails, unsigned char*& bufferOut, int& sizeOut);
#ifdef _WIN32
void usleep(int waitTime);
#endif
#endif /* defined(__hifi__SharedUtil__) */