Code review changes

This commit is contained in:
vincent 2013-04-10 08:28:26 +02:00
parent 4f41aab89a
commit bb380e841e
9 changed files with 58 additions and 70 deletions

View file

@ -6,7 +6,6 @@
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. // Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
// //
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include "FieldOfView.h" #include "FieldOfView.h"
#include "Stars.h" #include "Stars.h"

View file

@ -137,7 +137,7 @@ namespace starfield {
// ww + ww aa = dd // ww + ww aa = dd
// ww = dd / (1 + aa) // ww = dd / (1 + aa)
float diag = 2.0f * std::sin(halfPersp); float diag = 2.0f * std::sin(halfPersp);
float near2 = std::cos(halfPersp); float nearClip = std::cos(halfPersp);
float hw = 0.5f * sqrt(diag * diag / (1.0f + aspect * aspect)); float hw = 0.5f * sqrt(diag * diag / (1.0f + aspect * aspect));
float hh = hw * aspect; float hh = hw * aspect;
@ -165,11 +165,11 @@ namespace starfield {
#if STARFIELD_DEBUG_LOD #if STARFIELD_DEBUG_LOD
mat4 matrix_debug = glm::translate( mat4 matrix_debug = glm::translate(
glm::frustum(-hw,hw, -hh,hh, near2,10.0f), glm::frustum(-hw, hw, -hh, hh, nearClip, 10.0f),
vec3(0.0f, 0.0f, -4.0f)) * glm::affineInverse(matrix); vec3(0.0f, 0.0f, -4.0f)) * glm::affineInverse(matrix);
#endif #endif
matrix = glm::frustum(-hw,hw, -hh,hh, near2,10.0f) matrix = glm::frustum(-hw,hw, -hh,hh, nearClip,10.0f)
* glm::affineInverse(matrix); * glm::affineInverse(matrix);
this->_itrOutIndex = (unsigned*) _arrBatchOffs; this->_itrOutIndex = (unsigned*) _arrBatchOffs;
@ -374,11 +374,11 @@ namespace starfield {
float halfSlice = 0.5f * slice; float halfSlice = 0.5f * slice;
float daz = halfSlice * cos(abs(altitude) - halfSlice); float daz = halfSlice * cos(abs(altitude) - halfSlice);
float dal = halfSlice; float dal = halfSlice;
float near2 = cos(_valHalfPersp + sqrt(daz*daz+dal*dal)); float nearClip = cos(_valHalfPersp + sqrt(daz * daz + dal * dal));
// fprintf(stderr, "Stars.cpp: checking tile #%d, w = %f, near = %f\n", i, w, near2); // fprintf(stderr, "Stars.cpp: checking tile #%d, w = %f, near = %f\n", i, w, nearClip);
return w > near2; return w > nearClip;
} }
void updateVertexCount(Tile* t, BrightnessLevel minBright) { void updateVertexCount(Tile* t, BrightnessLevel minBright) {

View file

@ -1,5 +1,5 @@
// //
// starfield/renderer/Tiling.h // starfield/renderer/
// interface // interface
// //
// Created by Tobias Schwinger on 3/22/13. // Created by Tobias Schwinger on 3/22/13.
@ -15,16 +15,12 @@
#ifdef _WIN32 #ifdef _WIN32
#include "../Config.h" #include "../Config.h"
#define lrint(x) (floor(x+(x>0) ? 0.5 : -0.5)) #define lrint(x) (floor(x + (x > 0) ? 0.5 : -0.5))
inline float remainder(float x,float y) { return std::fmod(x,y); } inline float remainder(float x, float y) { return std::fmod(x, y); }
inline int round(float x) { return (floor(x + 0.5)); } inline int round(float x) { return (floor(x + 0.5)); }
double log2( double n ) double log2( double n ) { return log( n ) / log( 2 ); }
{
// log(n)/log(2) is log2.
return log( n ) / log( 2 );
}
#else #else
#include "../starfield/Config.h" #include "starfield/Config.h"
#endif #endif
namespace starfield { namespace starfield {

View file

@ -12,17 +12,15 @@ set(HIFI_SHARED_LIBRARY HifiShared)
set(EXTERNAL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external) set(EXTERNAL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external)
if (WIN32) if (WIN32)
# include headers for external libraries and InterfaceConfig. # include headers for external libraries and InterfaceConfig.
include_directories( include_directories(${EXTERNAL_ROOT_DIR})
${EXTERNAL_ROOT_DIR}
)
endif (WIN32) endif (WIN32)
if (NOT WIN32)
find_package(CURL REQUIRED) if (NOT WIN32)
include_directories(${CURL_INCLUDE_DIRS}) find_package(CURL REQUIRED)
# link target to common, external libraries include_directories(${CURL_INCLUDE_DIRS})
target_link_libraries(HifiShared ${CURL_LIBRARY}) # link target to common, external libraries
target_link_libraries(HifiShared ${CURL_LIBRARY})
endif (NOT WIN32) endif (NOT WIN32)
# link required libraries on UNIX # link required libraries on UNIX

View file

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

View file

@ -11,7 +11,6 @@
#include "PerfStat.h" #include "PerfStat.h"
#include <cstdio> #include <cstdio>
#include <string> #include <string>
#include <map> #include <map>

View file

@ -1,17 +1,14 @@
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
#define _timeval_ #define _timeval_
#include "Systime.h" #include "Systime.h"
int gettimeofday( timeval* p_tv, timezone* p_tz ) int gettimeofday( timeval* p_tv, timezone* p_tz )
{ {
int tt = timeGetTime(); int tt = timeGetTime();
p_tv->tv_sec = tt / 1000;
p_tv->tv_usec = tt % 1000 *1000;
return 0;
}
p_tv->tv_sec = tt / 1000;
p_tv->tv_usec = tt % 1000 * 1000;
return 0;
}
#endif #endif

View file

@ -89,7 +89,7 @@ int getLocalAddress() {
char szHostName[255]; char szHostName[255];
gethostname(szHostName, 255); gethostname(szHostName, 255);
struct hostent *host_entry; struct hostent *host_entry;
host_entry=gethostbyname(szHostName); host_entry = gethostbyname(szHostName);
char * szLocalIP; char * szLocalIP;
szLocalIP = inet_ntoa (*(struct in_addr *)*host_entry->h_addr_list); szLocalIP = inet_ntoa (*(struct in_addr *)*host_entry->h_addr_list);
localAddress = inet_addr(szLocalIP); localAddress = inet_addr(szLocalIP);
@ -140,34 +140,34 @@ UDPSocket::~UDPSocket() {
bool UDPSocket::init() { bool UDPSocket::init() {
#ifdef _WIN32 #ifdef _WIN32
WORD wVersionRequested; WORD wVersionRequested;
WSADATA wsaData; WSADATA wsaData;
int err; int err;
wVersionRequested = MAKEWORD( 2, 2 ); wVersionRequested = MAKEWORD( 2, 2 );
err = WSAStartup( wVersionRequested, &wsaData ); err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 ) { if ( err != 0 ) {
/* Tell the user that we could not find a usable */ /* Tell the user that we could not find a usable */
/* WinSock DLL. */ /* WinSock DLL. */
return false; return false;
} }
/* Confirm that the WinSock DLL supports 2.2.*/ /* Confirm that the WinSock DLL supports 2.2.*/
/* Note that if the DLL supports versions later */ /* Note that if the DLL supports versions later */
/* than 2.2 in addition to 2.2, it will still return */ /* than 2.2 in addition to 2.2, it will still return */
/* 2.2 in wVersion since that is the version we */ /* 2.2 in wVersion since that is the version we */
/* requested. */ /* requested. */
if ( LOBYTE( wsaData.wVersion ) != 2 || if ( LOBYTE( wsaData.wVersion ) != 2 ||
HIBYTE( wsaData.wVersion ) != 2 ) { HIBYTE( wsaData.wVersion ) != 2 ) {
/* Tell the user that we could not find a usable */ /* Tell the user that we could not find a usable */
/* WinSock DLL. */ /* WinSock DLL. */
WSACleanup( ); WSACleanup();
return false; return false;
} }
#endif #endif
return true; return true;
} }
// Receive data on this socket with retrieving address of sender // Receive data on this socket with retrieving address of sender

View file

@ -18,7 +18,6 @@
size_t const UrlReader::max_read_ahead = CURL_MAX_WRITE_SIZE; size_t const UrlReader::max_read_ahead = CURL_MAX_WRITE_SIZE;
#else #else
size_t const UrlReader::max_read_ahead = 0; size_t const UrlReader::max_read_ahead = 0;
#endif #endif
char const* const UrlReader::success = "UrlReader: Success!"; char const* const UrlReader::success = "UrlReader: Success!";