Merge branch 'master' of git://github.com/worklist/hifi into 19262

This commit is contained in:
tosh 2013-04-17 20:01:51 +02:00
commit c261449937
6 changed files with 30 additions and 27 deletions

View file

@ -548,7 +548,6 @@ void Head::simulate(float deltaTime) {
void Head::render(int faceToFace, int isMine) {
/*
//---------------------------------------------------
// show avatar position
//---------------------------------------------------
@ -557,7 +556,6 @@ void Head::render(int faceToFace, int isMine) {
glScalef( 0.03, 0.03, 0.03 );
glutSolidSphere( 1, 10, 10 );
glPopMatrix();
*/
//---------------------------------------------------
// show avatar orientation

View file

@ -12,9 +12,7 @@
static bool testingForNormalizationAndOrthogonality = true;
Orientation::Orientation() {
right = glm::vec3( 1.0, 0.0, 0.0 );
up = glm::vec3( 0.0, 1.0, 0.0 );
front = glm::vec3( 0.0, 0.0, 1.0 );
setToIdentity();
}

View file

@ -19,8 +19,6 @@
#include <arpa/inet.h>
#endif
Agent::Agent() {}
Agent::Agent(sockaddr *agentPublicSocket, sockaddr *agentLocalSocket, char agentType, uint16_t thisAgentId) {
publicSocket = new sockaddr;
memcpy(publicSocket, agentPublicSocket, sizeof(sockaddr));
@ -37,7 +35,8 @@ Agent::Agent(sockaddr *agentPublicSocket, sockaddr *agentLocalSocket, char agent
activeSocket = NULL;
linkedData = NULL;
pthread_mutex_init(&deleteMutex, NULL);
deleteMutex = new pthread_mutex_t;
pthread_mutex_init(deleteMutex, NULL);
}
Agent::Agent(const Agent &otherAgent) {
@ -67,25 +66,34 @@ Agent::Agent(const Agent &otherAgent) {
linkedData = NULL;
}
pthread_mutex_init(&deleteMutex, NULL);
deleteMutex = new pthread_mutex_t;
pthread_mutex_init(deleteMutex, NULL);
}
Agent& Agent::operator=(Agent otherAgent) {
std::cout << "Agent swap constructor called on resize?\n";
swap(*this, otherAgent);
return *this;
}
void Agent::swap(Agent &first, Agent &second) {
using std::swap;
swap(first.publicSocket, second.publicSocket);
swap(first.localSocket, second.localSocket);
swap(first.activeSocket, second.activeSocket);
swap(first.type, second.type);
swap(first.linkedData, second.linkedData);
swap(first.agentId, second.agentId);
swap(first.firstRecvTimeUsecs, second.firstRecvTimeUsecs);
swap(first.lastRecvTimeUsecs, second.lastRecvTimeUsecs);
swap(first.deleteMutex, second.deleteMutex);
}
Agent::~Agent() {
// the deleteMutex isn't destroyed here
// that's handled by the agent list silent agent removal thread
delete publicSocket;
delete localSocket;
delete linkedData;

View file

@ -19,17 +19,8 @@
#include <sys/socket.h>
#endif
class Agent {
void swap(Agent &first, Agent &second);
sockaddr *publicSocket, *localSocket, *activeSocket;
char type;
uint16_t agentId;
double firstRecvTimeUsecs;
double lastRecvTimeUsecs;
AgentData *linkedData;
public:
Agent();
class Agent {
public:
Agent(sockaddr *agentPublicSocket, sockaddr *agentLocalSocket, char agentType, uint16_t thisAgentId);
Agent(const Agent &otherAgent);
~Agent();
@ -38,7 +29,7 @@ public:
bool matches(sockaddr *otherPublicSocket, sockaddr *otherLocalSocket, char otherAgentType);
pthread_mutex_t deleteMutex;
pthread_mutex_t *deleteMutex;
char getType() const;
const char* getTypeName() const;
@ -59,7 +50,15 @@ public:
AgentData* getLinkedData();
void setLinkedData(AgentData *newData);
friend std::ostream& operator<<(std::ostream& os, const Agent* agent);
friend std::ostream& operator<<(std::ostream& os, const Agent* agent);
private:
void swap(Agent &first, Agent &second);
sockaddr *publicSocket, *localSocket, *activeSocket;
char type;
uint16_t agentId;
double firstRecvTimeUsecs;
double lastRecvTimeUsecs;
AgentData *linkedData;
};
std::ostream& operator<<(std::ostream& os, const Agent* agent);

View file

@ -334,7 +334,7 @@ void *removeSilentAgents(void *args) {
for(std::vector<Agent>::iterator agent = agents->begin(); agent != agents->end();) {
pthread_mutex_t * agentDeleteMutex = &agent->deleteMutex;
pthread_mutex_t* agentDeleteMutex = agent->deleteMutex;
if ((checkTimeUSecs - agent->getLastRecvTimeUsecs()) > AGENT_SILENCE_THRESHOLD_USECS
&& agent->getType() != AGENT_TYPE_VOXEL

View file

@ -129,7 +129,7 @@ void eraseVoxelTreeAndCleanupAgentVisitData() {
// lock this agent's delete mutex so that the delete thread doesn't
// kill the agent while we are working with it
pthread_mutex_lock(&thisAgent->deleteMutex);
pthread_mutex_lock(thisAgent->deleteMutex);
// clean up the agent visit data
delete agentData->rootMarkerNode;
@ -137,7 +137,7 @@ void eraseVoxelTreeAndCleanupAgentVisitData() {
// unlock the delete mutex so the other thread can
// kill the agent if it has dissapeared
pthread_mutex_unlock(&thisAgent->deleteMutex);
pthread_mutex_unlock(thisAgent->deleteMutex);
}
}
@ -167,7 +167,7 @@ void *distributeVoxelsToListeners(void *args) {
// lock this agent's delete mutex so that the delete thread doesn't
// kill the agent while we are working with it
pthread_mutex_lock(&thisAgent->deleteMutex);
pthread_mutex_lock(thisAgent->deleteMutex);
stopOctal = NULL;
packetCount = 0;
@ -207,7 +207,7 @@ void *distributeVoxelsToListeners(void *args) {
// unlock the delete mutex so the other thread can
// kill the agent if it has dissapeared
pthread_mutex_unlock(&thisAgent->deleteMutex);
pthread_mutex_unlock(thisAgent->deleteMutex);
}
// dynamically sleep until we need to fire off the next set of voxels