diff --git a/interface/src/Log.cpp b/interface/src/Log.cpp index 3bfbe19a93..454a64a0fb 100644 --- a/interface/src/Log.cpp +++ b/interface/src/Log.cpp @@ -313,9 +313,11 @@ Log logger; int printLog(char const* fmt, ...) { + int result; va_list args; va_start(args,fmt); - logger.vprint(fmt, args); + result = logger.vprint(fmt, args); va_end(args); + return result; } diff --git a/interface/src/main.cpp b/interface/src/main.cpp index c024a03ba9..31cd2cd07e 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -50,6 +50,7 @@ #include "Log.h" #include "shared_Log.h" #include "voxels_Log.h" +#include "avatars_Log.h" #include "Field.h" #include "world.h" @@ -136,7 +137,7 @@ Cloud cloud(0, // Particles false // Wrap ); -VoxelSystem voxSys; +VoxelSystem voxels; Field field; #ifndef _WIN32 @@ -245,28 +246,28 @@ void displayStats(void) } std::stringstream voxelStats; - voxelStats << "Voxels Rendered: " << voxSys.getVoxelsRendered(); + voxelStats << "Voxels Rendered: " << voxels.getVoxelsRendered(); drawtext(10, statsVerticalOffset + 70, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str()); voxelStats.str(""); - voxelStats << "Voxels Created: " << voxSys.getVoxelsCreated() << " (" << voxSys.getVoxelsCreatedRunningAverage() + voxelStats << "Voxels Created: " << voxels.getVoxelsCreated() << " (" << voxels.getVoxelsCreatedRunningAverage() << "/sec in last "<< COUNTETSTATS_TIME_FRAME << " seconds) "; drawtext(10, statsVerticalOffset + 250, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str()); voxelStats.str(""); - voxelStats << "Voxels Colored: " << voxSys.getVoxelsColored() << " (" << voxSys.getVoxelsColoredRunningAverage() + voxelStats << "Voxels Colored: " << voxels.getVoxelsColored() << " (" << voxels.getVoxelsColoredRunningAverage() << "/sec in last "<< COUNTETSTATS_TIME_FRAME << " seconds) "; drawtext(10, statsVerticalOffset + 270, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str()); voxelStats.str(""); - voxelStats << "Voxels Bytes Read: " << voxSys.getVoxelsBytesRead() - << " (" << voxSys.getVoxelsBytesReadRunningAverage() << "/sec in last "<< COUNTETSTATS_TIME_FRAME << " seconds) "; + voxelStats << "Voxels Bytes Read: " << voxels.getVoxelsBytesRead() + << " (" << voxels.getVoxelsBytesReadRunningAverage() << "/sec in last "<< COUNTETSTATS_TIME_FRAME << " seconds) "; drawtext(10, statsVerticalOffset + 290,0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str()); voxelStats.str(""); - long int voxelsBytesPerColored = voxSys.getVoxelsColored() ? voxSys.getVoxelsBytesRead()/voxSys.getVoxelsColored() : 0; - long int voxelsBytesPerColoredAvg = voxSys.getVoxelsColoredRunningAverage() ? - voxSys.getVoxelsBytesReadRunningAverage()/voxSys.getVoxelsColoredRunningAverage() : 0; + long int voxelsBytesPerColored = voxels.getVoxelsColored() ? voxels.getVoxelsBytesRead()/voxels.getVoxelsColored() : 0; + long int voxelsBytesPerColoredAvg = voxels.getVoxelsColoredRunningAverage() ? + voxels.getVoxelsBytesReadRunningAverage()/voxels.getVoxelsColoredRunningAverage() : 0; voxelStats << "Voxels Bytes per Colored: " << voxelsBytesPerColored << " (" << voxelsBytesPerColoredAvg << "/sec in last "<< COUNTETSTATS_TIME_FRAME << " seconds) "; @@ -303,8 +304,8 @@ void initDisplay(void) void init(void) { - voxSys.init(); - voxSys.setViewerHead(&myAvatar); + voxels.init(); + voxels.setViewerHead(&myAvatar); myAvatar.setRenderYaw(startYaw); headMouseX = WIDTH/2; @@ -819,7 +820,7 @@ void display(void) // Draw voxels if ( showingVoxels ) { - voxSys.render(); + voxels.render(); } // Draw field vectors @@ -1153,7 +1154,7 @@ void addRandomSphere(bool wantColorRandomizer) printLog("yc=%f\n",yc); printLog("zc=%f\n",zc); - voxSys.createSphere(r,xc,yc,zc,s,solid,wantColorRandomizer); + voxels.createSphere(r,xc,yc,zc,s,solid,wantColorRandomizer); } @@ -1315,7 +1316,7 @@ void *networkReceive(void *args) case PACKET_HEADER_VOXEL_DATA: case PACKET_HEADER_Z_COMMAND: case PACKET_HEADER_ERASE_VOXEL: - voxSys.parseData(incomingPacket, bytesReceived); + voxels.parseData(incomingPacket, bytesReceived); break; case PACKET_HEADER_BULK_AVATAR_DATA: AgentList::getInstance()->processBulkAgentData(&senderAddress, @@ -1516,8 +1517,9 @@ void audioMixerUpdate(in_addr_t newMixerAddress, in_port_t newMixerPort) { int main(int argc, const char * argv[]) { - shared::printLog = ::printLog; - voxels::printLog = ::printLog; + shared_lib::printLog = & ::printLog; + voxels_lib::printLog = & ::printLog; + avatars_lib::printLog = & ::printLog; // Quick test of the Orientation class on startup! testOrientationClass(); @@ -1601,7 +1603,7 @@ int main(int argc, const char * argv[]) // Voxel File. If so, load it now. const char* voxelsFilename = getCmdOption(argc, argv, "-i"); if (voxelsFilename) { - voxSys.loadVoxelsFile(voxelsFilename,wantColorRandomizer); + voxels.loadVoxelsFile(voxelsFilename,wantColorRandomizer); printLog("Local Voxel File loaded.\n"); } diff --git a/libraries/avatars/src/Orientation.cpp b/libraries/avatars/src/Orientation.cpp index 8eeb3dd0ff..2ee190d2d5 100755 --- a/libraries/avatars/src/Orientation.cpp +++ b/libraries/avatars/src/Orientation.cpp @@ -7,7 +7,9 @@ #include "Orientation.h" #include +#include "avatars_Log.h" +using avatars_lib::printLog; static bool testingForNormalizationAndOrthogonality = true; @@ -101,7 +103,7 @@ void Orientation::testForOrthogonalAndNormalizedVectors( float epsilon ) { if (( rightLength > 1.0f + epsilon ) || ( rightLength < 1.0f - epsilon )) { - printf( "Error in Orientation class: right direction length is %f \n", rightLength ); + printLog( "Error in Orientation class: right direction length is %f \n", rightLength ); } assert ( rightLength > 1.0f - epsilon ); assert ( rightLength < 1.0f + epsilon ); @@ -109,7 +111,7 @@ void Orientation::testForOrthogonalAndNormalizedVectors( float epsilon ) { if (( upLength > 1.0f + epsilon ) || ( upLength < 1.0f - epsilon )) { - printf( "Error in Orientation class: up direction length is %f \n", upLength ); + printLog( "Error in Orientation class: up direction length is %f \n", upLength ); } assert ( upLength > 1.0f - epsilon ); assert ( upLength < 1.0f + epsilon ); @@ -117,7 +119,7 @@ void Orientation::testForOrthogonalAndNormalizedVectors( float epsilon ) { if (( frontLength > 1.0f + epsilon ) || ( frontLength < 1.0f - epsilon )) { - printf( "Error in Orientation class: front direction length is %f \n", frontLength ); + printLog( "Error in Orientation class: front direction length is %f \n", frontLength ); } assert ( frontLength > 1.0f - epsilon ); assert ( frontLength < 1.0f + epsilon ); @@ -137,22 +139,22 @@ void Orientation::testForOrthogonalAndNormalizedVectors( float epsilon ) { if ( rightDiff > epsilon ) { - printf( "Error in Orientation class: right direction not orthogonal to up and/or front. " ); - printf( "The tested cross of up and front is off by %f \n", rightDiff ); + printLog( "Error in Orientation class: right direction not orthogonal to up and/or front. " ); + printLog( "The tested cross of up and front is off by %f \n", rightDiff ); } assert ( rightDiff < epsilon ); if ( upDiff > epsilon ) { - printf( "Error in Orientation class: up direction not orthogonal to front and/or right. " ); - printf( "The tested cross of front and right is off by %f \n", upDiff ); + printLog( "Error in Orientation class: up direction not orthogonal to front and/or right. " ); + printLog( "The tested cross of front and right is off by %f \n", upDiff ); } assert ( upDiff < epsilon ); if ( frontDiff > epsilon ) { - printf( "Error in Orientation class: front direction not orthogonal to right and/or up. " ); - printf( "The tested cross of right and up is off by %f \n", frontDiff ); + printLog( "Error in Orientation class: front direction not orthogonal to right and/or up. " ); + printLog( "The tested cross of right and up is off by %f \n", frontDiff ); } assert ( frontDiff < epsilon ); } diff --git a/libraries/avatars/src/avatars_Log.cpp b/libraries/avatars/src/avatars_Log.cpp new file mode 100644 index 0000000000..da8712b755 --- /dev/null +++ b/libraries/avatars/src/avatars_Log.cpp @@ -0,0 +1,17 @@ +// +// avatars_Log.cpp +// hifi +// +// Created by Tobias Schwinger on 4/17/13. +// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// + +#include "shared_Log.h" + +#include + +namespace avatars_lib { + using namespace std; + + int (* printLog)(char const*, ...) = & printf; +} diff --git a/libraries/avatars/src/avatars_Log.h b/libraries/avatars/src/avatars_Log.h new file mode 100644 index 0000000000..1d07cf46bf --- /dev/null +++ b/libraries/avatars/src/avatars_Log.h @@ -0,0 +1,20 @@ +// +// avatars_Log.h +// hifi +// +// Created by Tobias Schwinger on 4/17/13. +// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// + +#ifndef __hifi__avatars_Log__ +#define __hifi__avatars_Log__ + +namespace avatars_lib { + + // variable that can be set from outside to redirect the log output + // of this library + extern int (* printLog)(char const*, ...); +} + +#endif /* defined(__hifi__avatars_Log__) */ + diff --git a/libraries/shared/src/AgentList.cpp b/libraries/shared/src/AgentList.cpp index 86564d21e0..d246d460b5 100644 --- a/libraries/shared/src/AgentList.cpp +++ b/libraries/shared/src/AgentList.cpp @@ -22,7 +22,7 @@ #include #endif -using shared::printLog; +using shared_lib::printLog; const char * SOLO_AGENT_TYPES_STRING = "MV"; char DOMAIN_HOSTNAME[] = "highfidelity.below92.com"; diff --git a/libraries/shared/src/PerfStat.cpp b/libraries/shared/src/PerfStat.cpp index a312f65c1b..2c3dcf93b7 100644 --- a/libraries/shared/src/PerfStat.cpp +++ b/libraries/shared/src/PerfStat.cpp @@ -16,7 +16,7 @@ #include "shared_Log.h" -using shared::printLog; +using shared_lib::printLog; // Static class members initialization here! std::map > PerfStat::groupHistoryMap; diff --git a/libraries/shared/src/SharedUtil.cpp b/libraries/shared/src/SharedUtil.cpp index dbd94a089d..39333f858e 100644 --- a/libraries/shared/src/SharedUtil.cpp +++ b/libraries/shared/src/SharedUtil.cpp @@ -20,7 +20,7 @@ #include #endif -using shared::printLog; +using shared_lib::printLog; double usecTimestamp(timeval *time) { return (time->tv_sec * 1000000.0 + time->tv_usec); diff --git a/libraries/shared/src/UDPSocket.cpp b/libraries/shared/src/UDPSocket.cpp index a61dbeb20a..94565f43ee 100644 --- a/libraries/shared/src/UDPSocket.cpp +++ b/libraries/shared/src/UDPSocket.cpp @@ -22,7 +22,7 @@ #include "shared_Log.h" -using shared::printLog; +using shared_lib::printLog; sockaddr_in destSockaddr, senderAddress; diff --git a/libraries/shared/src/shared_Log.cpp b/libraries/shared/src/shared_Log.cpp index ad8cd2d9c0..93a5c74714 100644 --- a/libraries/shared/src/shared_Log.cpp +++ b/libraries/shared/src/shared_Log.cpp @@ -1,5 +1,5 @@ // -// Log.cpp +// shared_Log.cpp // hifi // // Created by Tobias Schwinger on 4/17/13. @@ -10,7 +10,7 @@ #include -namespace shared { +namespace shared_lib { using namespace std; int (* printLog)(char const*, ...) = & printf; diff --git a/libraries/shared/src/shared_Log.h b/libraries/shared/src/shared_Log.h index 4916ddf5c1..29c1a4ed57 100644 --- a/libraries/shared/src/shared_Log.h +++ b/libraries/shared/src/shared_Log.h @@ -9,7 +9,7 @@ #ifndef __hifi__shared_Log__ #define __hifi__shared_Log__ -namespace shared { +namespace shared_lib { // variable that can be set from outside to redirect the log output // of this library diff --git a/libraries/voxels/src/Plane.cpp b/libraries/voxels/src/Plane.cpp index 083f6cf46e..2f0d43925b 100755 --- a/libraries/voxels/src/Plane.cpp +++ b/libraries/voxels/src/Plane.cpp @@ -7,7 +7,7 @@ #include "voxels_Log.h" -using voxels::printLog; +using voxels_lib::printLog; // These are some useful utilities that vec3 is missing float vec3_length(const glm::vec3& v) { diff --git a/libraries/voxels/src/ViewFrustum.cpp b/libraries/voxels/src/ViewFrustum.cpp index de126eae50..867b47922f 100644 --- a/libraries/voxels/src/ViewFrustum.cpp +++ b/libraries/voxels/src/ViewFrustum.cpp @@ -11,7 +11,7 @@ #include "ViewFrustum.h" #include "voxels_Log.h" -using voxels::printLog; +using voxels_lib::printLog; ViewFrustum::ViewFrustum() : _position(glm::vec3(0,0,0)), diff --git a/libraries/voxels/src/VoxelNode.cpp b/libraries/voxels/src/VoxelNode.cpp index d0b65f060f..5f36ad9e59 100644 --- a/libraries/voxels/src/VoxelNode.cpp +++ b/libraries/voxels/src/VoxelNode.cpp @@ -12,6 +12,8 @@ #include "VoxelNode.h" #include "OctalCode.h" +// using voxels_lib::printLog; + VoxelNode::VoxelNode() { octalCode = NULL; diff --git a/libraries/voxels/src/VoxelTree.cpp b/libraries/voxels/src/VoxelTree.cpp index 8a56487de3..87a8ea9307 100644 --- a/libraries/voxels/src/VoxelTree.cpp +++ b/libraries/voxels/src/VoxelTree.cpp @@ -21,7 +21,7 @@ #include // to load voxels from file #include // to load voxels from file -using voxels::printLog; +using voxels_lib::printLog; int boundaryDistanceForRenderLevel(unsigned int renderLevel) { switch (renderLevel) { diff --git a/libraries/voxels/src/voxels_Log.cpp b/libraries/voxels/src/voxels_Log.cpp new file mode 100644 index 0000000000..6fd637a1ec --- /dev/null +++ b/libraries/voxels/src/voxels_Log.cpp @@ -0,0 +1,17 @@ +// +// voxels_Log.cpp +// hifi +// +// Created by Tobias Schwinger on 4/17/13. +// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// + +#include "voxels_Log.h" + +#include + +namespace voxels_lib { + using namespace std; + + int (* printLog)(char const*, ...) = & printf; +} diff --git a/libraries/voxels/src/voxels_Log.h b/libraries/voxels/src/voxels_Log.h new file mode 100644 index 0000000000..3403058a3d --- /dev/null +++ b/libraries/voxels/src/voxels_Log.h @@ -0,0 +1,20 @@ +// +// voxels_Log.h +// hifi +// +// Created by Tobias Schwinger on 4/17/13. +// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// + +#ifndef __hifi__voxels_Log__ +#define __hifi__voxels_Log__ + +namespace voxels_lib { + + // variable that can be set from outside to redirect the log output + // of this library + extern int (* printLog)(char const*, ...); +} + +#endif /* defined(__hifi__voxels_Log__) */ +