mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-08 06:32:35 +02:00
integrates logging for 'avatars' library, fixes missig return in Log.cpp, adds _lib suffix for log callback namespaces and reverts voxels -> voxLib rename in main
This commit is contained in:
parent
f899ff9378
commit
bf5f54c9d0
17 changed files with 119 additions and 37 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
|
||||
#include "Orientation.h"
|
||||
#include <SharedUtil.h>
|
||||
#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 );
|
||||
}
|
||||
|
|
17
libraries/avatars/src/avatars_Log.cpp
Normal file
17
libraries/avatars/src/avatars_Log.cpp
Normal file
|
@ -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 <cstdio>
|
||||
|
||||
namespace avatars_lib {
|
||||
using namespace std;
|
||||
|
||||
int (* printLog)(char const*, ...) = & printf;
|
||||
}
|
20
libraries/avatars/src/avatars_Log.h
Normal file
20
libraries/avatars/src/avatars_Log.h
Normal file
|
@ -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__) */
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
using shared::printLog;
|
||||
using shared_lib::printLog;
|
||||
|
||||
const char * SOLO_AGENT_TYPES_STRING = "MV";
|
||||
char DOMAIN_HOSTNAME[] = "highfidelity.below92.com";
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
#include "shared_Log.h"
|
||||
|
||||
using shared::printLog;
|
||||
using shared_lib::printLog;
|
||||
|
||||
// Static class members initialization here!
|
||||
std::map<std::string,PerfStatHistory,std::less<std::string> > PerfStat::groupHistoryMap;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#endif
|
||||
|
||||
using shared::printLog;
|
||||
using shared_lib::printLog;
|
||||
|
||||
double usecTimestamp(timeval *time) {
|
||||
return (time->tv_sec * 1000000.0 + time->tv_usec);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "shared_Log.h"
|
||||
|
||||
using shared::printLog;
|
||||
using shared_lib::printLog;
|
||||
|
||||
sockaddr_in destSockaddr, senderAddress;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Log.cpp
|
||||
// shared_Log.cpp
|
||||
// hifi
|
||||
//
|
||||
// Created by Tobias Schwinger on 4/17/13.
|
||||
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include <cstdio>
|
||||
|
||||
namespace shared {
|
||||
namespace shared_lib {
|
||||
using namespace std;
|
||||
|
||||
int (* printLog)(char const*, ...) = & printf;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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)),
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
#include "VoxelNode.h"
|
||||
#include "OctalCode.h"
|
||||
|
||||
// using voxels_lib::printLog;
|
||||
|
||||
VoxelNode::VoxelNode() {
|
||||
octalCode = NULL;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <iostream> // to load voxels from file
|
||||
#include <fstream> // to load voxels from file
|
||||
|
||||
using voxels::printLog;
|
||||
using voxels_lib::printLog;
|
||||
|
||||
int boundaryDistanceForRenderLevel(unsigned int renderLevel) {
|
||||
switch (renderLevel) {
|
||||
|
|
17
libraries/voxels/src/voxels_Log.cpp
Normal file
17
libraries/voxels/src/voxels_Log.cpp
Normal file
|
@ -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 <cstdio>
|
||||
|
||||
namespace voxels_lib {
|
||||
using namespace std;
|
||||
|
||||
int (* printLog)(char const*, ...) = & printf;
|
||||
}
|
20
libraries/voxels/src/voxels_Log.h
Normal file
20
libraries/voxels/src/voxels_Log.h
Normal file
|
@ -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__) */
|
||||
|
Loading…
Reference in a new issue