mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-08 18:02:13 +02:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
f099702d2a
21 changed files with 451 additions and 282 deletions
|
@ -11,4 +11,5 @@ add_subdirectory(injector)
|
|||
add_subdirectory(pairing-server)
|
||||
add_subdirectory(space-server)
|
||||
add_subdirectory(voxel-edit)
|
||||
add_subdirectory(voxel-server)
|
||||
add_subdirectory(voxel-server)
|
||||
add_subdirectory(animation-server)
|
26
animation-server/CMakeLists.txt
Normal file
26
animation-server/CMakeLists.txt
Normal file
|
@ -0,0 +1,26 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
set(TARGET_NAME animation-server)
|
||||
|
||||
set(ROOT_DIR ..)
|
||||
set(MACRO_DIR ${ROOT_DIR}/cmake/macros)
|
||||
|
||||
# setup for find modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules/")
|
||||
|
||||
# set up the external glm library
|
||||
include(${MACRO_DIR}/IncludeGLM.cmake)
|
||||
include_glm(${TARGET_NAME} ${ROOT_DIR})
|
||||
|
||||
include(${MACRO_DIR}/SetupHifiProject.cmake)
|
||||
|
||||
setup_hifi_project(${TARGET_NAME})
|
||||
|
||||
# link in the shared library
|
||||
include(${MACRO_DIR}/LinkHifiLibrary.cmake)
|
||||
link_hifi_library(shared ${TARGET_NAME} ${ROOT_DIR})
|
||||
|
||||
# link in the hifi voxels library
|
||||
link_hifi_library(voxels ${TARGET_NAME} ${ROOT_DIR})
|
||||
|
||||
|
326
animation-server/src/main.cpp
Normal file
326
animation-server/src/main.cpp
Normal file
|
@ -0,0 +1,326 @@
|
|||
//
|
||||
// main.cpp
|
||||
// Animation Server
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 05/16/2013
|
||||
// Copyright (c) 2012 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <OctalCode.h>
|
||||
#include <AgentList.h>
|
||||
#include <AgentTypes.h>
|
||||
#include <EnvironmentData.h>
|
||||
#include <VoxelTree.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <SceneUtils.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "Syssocket.h"
|
||||
#include "Systime.h"
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <ifaddrs.h>
|
||||
#endif
|
||||
|
||||
const int ANIMATION_LISTEN_PORT = 40107;
|
||||
const int ACTUAL_FPS = 20;
|
||||
const double OUR_FPS_IN_MILLISECONDS = 1000.0/ACTUAL_FPS; // determines FPS from our desired FPS
|
||||
const int ANIMATE_VOXELS_INTERVAL_USECS = OUR_FPS_IN_MILLISECONDS * 1000.0; // converts from milliseconds to usecs
|
||||
|
||||
bool wantLocalDomain = false;
|
||||
|
||||
static void sendVoxelServerZMessage() {
|
||||
char message[100];
|
||||
sprintf(message,"%c%s",'Z',"a message");
|
||||
int messageSize = strlen(message) + 1;
|
||||
AgentList::getInstance()->broadcastToAgents((unsigned char*) message, messageSize, &AGENT_TYPE_VOXEL, 1);
|
||||
}
|
||||
|
||||
static void sendVoxelEditMessage(PACKET_HEADER header, VoxelDetail& detail) {
|
||||
unsigned char* bufferOut;
|
||||
int sizeOut;
|
||||
|
||||
if (createVoxelEditMessage(header, 0, 1, &detail, bufferOut, sizeOut)){
|
||||
AgentList::getInstance()->broadcastToAgents(bufferOut, sizeOut, &AGENT_TYPE_VOXEL, 1);
|
||||
delete[] bufferOut;
|
||||
}
|
||||
}
|
||||
|
||||
float intensity = 0.5f;
|
||||
float intensityIncrement = 0.1f;
|
||||
const float MAX_INTENSITY = 1.0f;
|
||||
const float MIN_INTENSITY = 0.5f;
|
||||
const float BEACON_SIZE = 0.25f / TREE_SCALE; // approximately 1/4th meter
|
||||
|
||||
static void sendVoxelBlinkMessage() {
|
||||
VoxelDetail detail;
|
||||
detail.s = BEACON_SIZE;
|
||||
|
||||
glm::vec3 position = glm::vec3(0, 0, detail.s);
|
||||
|
||||
detail.x = detail.s * floor(position.x / detail.s);
|
||||
detail.y = detail.s * floor(position.y / detail.s);
|
||||
detail.z = detail.s * floor(position.z / detail.s);
|
||||
|
||||
::intensity += ::intensityIncrement;
|
||||
if (::intensity >= MAX_INTENSITY) {
|
||||
::intensity = MAX_INTENSITY;
|
||||
::intensityIncrement = -::intensityIncrement;
|
||||
}
|
||||
if (::intensity <= MIN_INTENSITY) {
|
||||
::intensity = MIN_INTENSITY;
|
||||
::intensityIncrement = -::intensityIncrement;
|
||||
}
|
||||
|
||||
detail.red = 255 * ::intensity;
|
||||
detail.green = 0 * ::intensity;
|
||||
detail.blue = 0 * ::intensity;
|
||||
|
||||
PACKET_HEADER message = PACKET_HEADER_SET_VOXEL_DESTRUCTIVE;
|
||||
|
||||
sendVoxelEditMessage(message, detail);
|
||||
}
|
||||
|
||||
bool stringOfLightsInitialized = false;
|
||||
int currentLight = 0;
|
||||
int lightMovementDirection = 1;
|
||||
const int SEGMENT_COUNT = 4;
|
||||
const int LIGHTS_PER_SEGMENT = 80;
|
||||
const int LIGHT_COUNT = LIGHTS_PER_SEGMENT * SEGMENT_COUNT;
|
||||
glm::vec3 stringOfLights[LIGHT_COUNT];
|
||||
unsigned char offColor[3] = { 240, 240, 240 };
|
||||
unsigned char onColor[3] = { 0, 255, 255 };
|
||||
const float STRING_OF_LIGHTS_SIZE = 0.125f / TREE_SCALE; // approximately 1/8th meter
|
||||
|
||||
static void sendBlinkingStringOfLights() {
|
||||
PACKET_HEADER message = PACKET_HEADER_SET_VOXEL_DESTRUCTIVE; // we're a bully!
|
||||
float lightScale = STRING_OF_LIGHTS_SIZE;
|
||||
VoxelDetail detail;
|
||||
|
||||
detail.s = lightScale;
|
||||
|
||||
// first initialized the string of lights if needed...
|
||||
if (!stringOfLightsInitialized) {
|
||||
for (int i = 0; i < LIGHT_COUNT; i++) {
|
||||
|
||||
// four different segments on sides of initial platform
|
||||
int segment = floor(i / LIGHTS_PER_SEGMENT);
|
||||
int indexInSegment = i - (segment * LIGHTS_PER_SEGMENT);
|
||||
switch (segment) {
|
||||
case 0:
|
||||
// along x axis
|
||||
stringOfLights[i] = glm::vec3(indexInSegment * lightScale, 0, 0);
|
||||
break;
|
||||
case 1:
|
||||
// parallel to Z axis at outer X edge
|
||||
stringOfLights[i] = glm::vec3(LIGHTS_PER_SEGMENT * lightScale, 0, indexInSegment * lightScale);
|
||||
break;
|
||||
case 2:
|
||||
// parallel to X axis at outer Z edge
|
||||
stringOfLights[i] = glm::vec3((LIGHTS_PER_SEGMENT-indexInSegment) * lightScale, 0,
|
||||
LIGHTS_PER_SEGMENT * lightScale);
|
||||
break;
|
||||
case 3:
|
||||
// on Z axis
|
||||
stringOfLights[i] = glm::vec3(0, 0, (LIGHTS_PER_SEGMENT-indexInSegment) * lightScale);
|
||||
break;
|
||||
}
|
||||
|
||||
detail.x = stringOfLights[i].x;
|
||||
detail.y = stringOfLights[i].y;
|
||||
detail.z = stringOfLights[i].z;
|
||||
|
||||
detail.red = offColor[0];
|
||||
detail.green = offColor[1];
|
||||
detail.blue = offColor[2];
|
||||
sendVoxelEditMessage(message, detail);
|
||||
}
|
||||
stringOfLightsInitialized = true;
|
||||
} else {
|
||||
// turn off current light
|
||||
detail.x = detail.s * floor(stringOfLights[currentLight].x / detail.s);
|
||||
detail.y = detail.s * floor(stringOfLights[currentLight].y / detail.s);
|
||||
detail.z = detail.s * floor(stringOfLights[currentLight].z / detail.s);
|
||||
detail.red = offColor[0];
|
||||
detail.green = offColor[1];
|
||||
detail.blue = offColor[2];
|
||||
sendVoxelEditMessage(message, detail);
|
||||
|
||||
// move current light...
|
||||
// if we're at the end of our string, then change direction
|
||||
if (currentLight == LIGHT_COUNT-1) {
|
||||
lightMovementDirection = -1;
|
||||
}
|
||||
if (currentLight == 0) {
|
||||
lightMovementDirection = 1;
|
||||
}
|
||||
currentLight += lightMovementDirection;
|
||||
|
||||
// turn on new current light
|
||||
detail.x = detail.s * floor(stringOfLights[currentLight].x / detail.s);
|
||||
detail.y = detail.s * floor(stringOfLights[currentLight].y / detail.s);
|
||||
detail.z = detail.s * floor(stringOfLights[currentLight].z / detail.s);
|
||||
detail.red = onColor[0];
|
||||
detail.green = onColor[1];
|
||||
detail.blue = onColor[2];
|
||||
sendVoxelEditMessage(message, detail);
|
||||
}
|
||||
}
|
||||
|
||||
bool billboardInitialized = false;
|
||||
const int BILLBOARD_HEIGHT = 9;
|
||||
const int BILLBOARD_WIDTH = 44;
|
||||
glm::vec3 billboardPosition((0.125f / TREE_SCALE),(0.125f / TREE_SCALE),0);
|
||||
glm::vec3 billboardLights[BILLBOARD_HEIGHT][BILLBOARD_WIDTH];
|
||||
unsigned char billboardOffColor[3] = { 240, 240, 240 };
|
||||
unsigned char billboardOnColorA[3] = { 0, 0, 255 };
|
||||
unsigned char billboardOnColorB[3] = { 0, 255, 0 };
|
||||
float billboardGradient = 0.5f;
|
||||
float billboardGradientIncrement = 0.01f;
|
||||
const float BILLBOARD_MAX_GRADIENT = 1.0f;
|
||||
const float BILLBOARD_MIN_GRADIENT = 0.0f;
|
||||
const float BILLBOARD_LIGHT_SIZE = 0.125f / TREE_SCALE; // approximately 1/8 meter per light
|
||||
|
||||
// top to bottom...
|
||||
bool billBoardMessage[BILLBOARD_HEIGHT][BILLBOARD_WIDTH] = {
|
||||
{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
|
||||
{ 0,1,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,1,1,1,1,0,0,0,0,0,1,0,1,1,1,0,1,0,1,0,0,1,0,0,0,0,0,0 },
|
||||
{ 0,1,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,1,0,1,0,1,0,1,0,0,0,1,1,1,0,0,0,0,0 },
|
||||
{ 0,1,1,1,1,0,1,0,1,1,1,0,1,1,1,0,0,1,1,1,0,0,0,0,1,1,1,0,1,1,1,0,1,0,1,0,0,1,0,0,1,0,1,0 },
|
||||
{ 0,1,0,0,1,0,1,0,1,0,1,0,1,0,1,0,0,1,0,0,0,0,1,0,1,0,1,0,1,0,0,0,1,0,1,0,0,1,0,0,1,0,1,0 },
|
||||
{ 0,1,0,0,1,0,1,0,1,1,1,0,1,0,1,0,0,1,0,0,0,0,1,0,1,1,1,0,1,1,1,0,1,0,1,0,0,1,0,0,1,1,1,0 },
|
||||
{ 0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0 },
|
||||
{ 0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0 },
|
||||
{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
|
||||
};
|
||||
|
||||
static void sendBillboard() {
|
||||
PACKET_HEADER message = PACKET_HEADER_SET_VOXEL_DESTRUCTIVE; // we're a bully!
|
||||
float lightScale = BILLBOARD_LIGHT_SIZE;
|
||||
VoxelDetail detail;
|
||||
|
||||
detail.s = lightScale;
|
||||
|
||||
// first initialized the billboard of lights if needed...
|
||||
if (!billboardInitialized) {
|
||||
for (int i = 0; i < BILLBOARD_HEIGHT; i++) {
|
||||
for (int j = 0; j < BILLBOARD_WIDTH; j++) {
|
||||
|
||||
billboardLights[i][j] = billboardPosition + glm::vec3(j * lightScale, (float)((BILLBOARD_HEIGHT - i) * lightScale), 0);
|
||||
}
|
||||
}
|
||||
billboardInitialized = true;
|
||||
}
|
||||
|
||||
::billboardGradient += ::billboardGradientIncrement;
|
||||
|
||||
if (::billboardGradient >= BILLBOARD_MAX_GRADIENT) {
|
||||
::billboardGradient = BILLBOARD_MAX_GRADIENT;
|
||||
::billboardGradientIncrement = -::billboardGradientIncrement;
|
||||
}
|
||||
if (::billboardGradient <= BILLBOARD_MIN_GRADIENT) {
|
||||
::billboardGradient = BILLBOARD_MIN_GRADIENT;
|
||||
::billboardGradientIncrement = -::billboardGradientIncrement;
|
||||
}
|
||||
|
||||
for (int i = 0; i < BILLBOARD_HEIGHT; i++) {
|
||||
for (int j = 0; j < BILLBOARD_WIDTH; j++) {
|
||||
|
||||
billboardLights[i][j] = billboardPosition + glm::vec3(j * lightScale, (float)((BILLBOARD_HEIGHT - i) * lightScale), 0);
|
||||
|
||||
detail.x = billboardLights[i][j].x;
|
||||
detail.y = billboardLights[i][j].y;
|
||||
detail.z = billboardLights[i][j].z;
|
||||
|
||||
if (billBoardMessage[i][j]) {
|
||||
detail.red = (billboardOnColorA[0] + ((billboardOnColorB[0] - billboardOnColorA[0]) * ::billboardGradient));
|
||||
detail.green = (billboardOnColorA[1] + ((billboardOnColorB[1] - billboardOnColorA[1]) * ::billboardGradient));
|
||||
detail.blue = (billboardOnColorA[2] + ((billboardOnColorB[2] - billboardOnColorA[2]) * ::billboardGradient));
|
||||
} else {
|
||||
detail.red = billboardOffColor[0];
|
||||
detail.green = billboardOffColor[1];
|
||||
detail.blue = billboardOffColor[2];
|
||||
}
|
||||
sendVoxelEditMessage(message, detail);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void* animateVoxels(void* args) {
|
||||
|
||||
AgentList* agentList = AgentList::getInstance();
|
||||
timeval lastSendTime;
|
||||
|
||||
while (true) {
|
||||
gettimeofday(&lastSendTime, NULL);
|
||||
|
||||
// some animations
|
||||
//sendVoxelBlinkMessage();
|
||||
sendBlinkingStringOfLights();
|
||||
sendBillboard();
|
||||
|
||||
// dynamically sleep until we need to fire off the next set of voxels
|
||||
double usecToSleep = ANIMATE_VOXELS_INTERVAL_USECS - (usecTimestampNow() - usecTimestamp(&lastSendTime));
|
||||
|
||||
if (usecToSleep > 0) {
|
||||
usleep(usecToSleep);
|
||||
} else {
|
||||
std::cout << "Last send took too much time, not sleeping!\n";
|
||||
}
|
||||
}
|
||||
|
||||
pthread_exit(0);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, const char * argv[])
|
||||
{
|
||||
AgentList* agentList = AgentList::createInstance(AGENT_TYPE_ANIMATION_SERVER, ANIMATION_LISTEN_PORT);
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
|
||||
// Handle Local Domain testing with the --local command line
|
||||
const char* local = "--local";
|
||||
::wantLocalDomain = cmdOptionExists(argc, argv,local);
|
||||
if (::wantLocalDomain) {
|
||||
printf("Local Domain MODE!\n");
|
||||
int ip = getLocalAddress();
|
||||
sprintf(DOMAIN_IP,"%d.%d.%d.%d", (ip & 0xFF), ((ip >> 8) & 0xFF),((ip >> 16) & 0xFF), ((ip >> 24) & 0xFF));
|
||||
}
|
||||
|
||||
agentList->linkedDataCreateCallback = NULL; // do we need a callback?
|
||||
agentList->startSilentAgentRemovalThread();
|
||||
agentList->startDomainServerCheckInThread();
|
||||
|
||||
srand((unsigned)time(0));
|
||||
|
||||
pthread_t animateVoxelThread;
|
||||
pthread_create(&animateVoxelThread, NULL, animateVoxels, NULL);
|
||||
|
||||
sockaddr agentPublicAddress;
|
||||
|
||||
unsigned char* packetData = new unsigned char[MAX_PACKET_SIZE];
|
||||
ssize_t receivedBytes;
|
||||
|
||||
// loop to send to agents requesting data
|
||||
while (true) {
|
||||
// Agents sending messages to us...
|
||||
if (agentList->getAgentSocket()->receive(&agentPublicAddress, packetData, &receivedBytes)) {
|
||||
switch (packetData[0]) {
|
||||
default: {
|
||||
AgentList::getInstance()->processAgentData(&agentPublicAddress, packetData, receivedBytes);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pthread_join(animateVoxelThread, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -93,7 +93,7 @@ int main(int argc, const char* argv[]) {
|
|||
pthread_create(&receiveAgentDataThread, NULL, receiveAgentData, NULL);
|
||||
|
||||
// create an AvatarData object, "eve"
|
||||
AvatarData eve = AvatarData();
|
||||
AvatarData eve;
|
||||
|
||||
// move eve away from the origin
|
||||
// pick a random point inside a 10x10 grid
|
||||
|
|
|
@ -786,14 +786,14 @@ void Application::idle() {
|
|||
if (_myAvatar.isTransmitterV2Connected()) {
|
||||
const float HAND_FORCE_SCALING = 0.05f;
|
||||
const float* handAcceleration = _myAvatar.getTransmitterHandLastAcceleration();
|
||||
_myAvatar.setHandMovementValues(glm::vec3(-handAcceleration[0] * HAND_FORCE_SCALING,
|
||||
_myAvatar.setMovedHandOffset(glm::vec3(-handAcceleration[0] * HAND_FORCE_SCALING,
|
||||
handAcceleration[1] * HAND_FORCE_SCALING,
|
||||
handAcceleration[2] * HAND_FORCE_SCALING));
|
||||
} else {
|
||||
// update behaviors for avatar hand movement: handControl takes mouse values as input,
|
||||
// and gives back 3D values modulated for smooth transitioning between interaction modes.
|
||||
_handControl.update(_mouseX, _mouseY);
|
||||
_myAvatar.setHandMovementValues(_handControl.getValues());
|
||||
_myAvatar.setMovedHandOffset(_handControl.getValues());
|
||||
}
|
||||
|
||||
// tell my avatar if the mouse is being pressed...
|
||||
|
|
|
@ -58,7 +58,6 @@ bool usingBigSphereCollisionTest = true;
|
|||
float chatMessageScale = 0.0015;
|
||||
float chatMessageHeight = 0.45;
|
||||
|
||||
|
||||
Avatar::Avatar(bool isMine) {
|
||||
_orientation.setToIdentity();
|
||||
|
||||
|
@ -107,49 +106,6 @@ Avatar::Avatar(bool isMine) {
|
|||
else { _balls = NULL; }
|
||||
}
|
||||
|
||||
Avatar::Avatar(const Avatar &otherAvatar) : _head(otherAvatar._head) { //include the copy constructor for head
|
||||
|
||||
_velocity = otherAvatar._velocity;
|
||||
_thrust = otherAvatar._thrust;
|
||||
_rotation = otherAvatar._rotation;
|
||||
_bodyYaw = otherAvatar._bodyYaw;
|
||||
_bodyPitch = otherAvatar._bodyPitch;
|
||||
_bodyRoll = otherAvatar._bodyRoll;
|
||||
_bodyPitchDelta = otherAvatar._bodyPitchDelta;
|
||||
_bodyYawDelta = otherAvatar._bodyYawDelta;
|
||||
_bodyRollDelta = otherAvatar._bodyRollDelta;
|
||||
_mousePressed = otherAvatar._mousePressed;
|
||||
_mode = otherAvatar._mode;
|
||||
_isMine = otherAvatar._isMine;
|
||||
_renderYaw = otherAvatar._renderYaw;
|
||||
_maxArmLength = otherAvatar._maxArmLength;
|
||||
_transmitterTimer = otherAvatar._transmitterTimer;
|
||||
_transmitterIsFirstData = otherAvatar._transmitterIsFirstData;
|
||||
_transmitterTimeLastReceived = otherAvatar._transmitterTimeLastReceived;
|
||||
_transmitterHz = otherAvatar._transmitterHz;
|
||||
_transmitterInitialReading = otherAvatar._transmitterInitialReading;
|
||||
_transmitterPackets = otherAvatar._transmitterPackets;
|
||||
_isTransmitterV2Connected = otherAvatar._isTransmitterV2Connected;
|
||||
_TEST_bigSphereRadius = otherAvatar._TEST_bigSphereRadius;
|
||||
_TEST_bigSpherePosition = otherAvatar._TEST_bigSpherePosition;
|
||||
_movedHandOffset = otherAvatar._movedHandOffset;
|
||||
|
||||
_orientation.set(otherAvatar._orientation);
|
||||
|
||||
initializeSkeleton();
|
||||
|
||||
for (int i = 0; i < MAX_DRIVE_KEYS; i++) _driveKeys[i] = otherAvatar._driveKeys[i];
|
||||
|
||||
_distanceToNearestAvatar = otherAvatar._distanceToNearestAvatar;
|
||||
|
||||
initializeSkeleton();
|
||||
|
||||
}
|
||||
|
||||
Avatar* Avatar::clone() const {
|
||||
return new Avatar(*this);
|
||||
}
|
||||
|
||||
void Avatar::reset() {
|
||||
_headPitch = _headYaw = _headRoll = 0;
|
||||
_head.leanForward = _head.leanSideways = 0;
|
||||
|
@ -460,8 +416,6 @@ void Avatar::simulate(float deltaTime) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Avatar::checkForMouseRayTouching() {
|
||||
|
||||
for (int b = 0; b < NUM_AVATAR_JOINTS; b++) {
|
||||
|
@ -477,13 +431,10 @@ void Avatar::checkForMouseRayTouching() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void Avatar::setMouseRay(const glm::vec3 &origin, const glm::vec3 &direction ) {
|
||||
_mouseRayOrigin = origin; _mouseRayDirection = direction;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Avatar::updateHandMovementAndTouching(float deltaTime) {
|
||||
|
||||
// reset hand and arm positions according to hand movement
|
||||
|
@ -600,12 +551,6 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
float Avatar::getHeight() {
|
||||
return _height;
|
||||
}
|
||||
|
||||
|
||||
void Avatar::updateCollisionWithSphere(glm::vec3 position, float radius, float deltaTime) {
|
||||
float myBodyApproximateBoundingRadius = 1.0f;
|
||||
glm::vec3 vectorFromMyBodyToBigSphere(_position - position);
|
||||
|
@ -644,9 +589,6 @@ void Avatar::updateCollisionWithSphere(glm::vec3 position, float radius, float d
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Avatar::updateAvatarCollisions(float deltaTime) {
|
||||
|
||||
// Reset detector for nearest avatar
|
||||
|
@ -677,9 +619,6 @@ void Avatar::updateAvatarCollisions(float deltaTime) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//detect collisions with other avatars and respond
|
||||
void Avatar::applyCollisionWithOtherAvatar(Avatar * otherAvatar, float deltaTime) {
|
||||
|
||||
|
@ -735,8 +674,6 @@ void Avatar::applyCollisionWithOtherAvatar(Avatar * otherAvatar, float deltaTime
|
|||
otherAvatar->_velocity *= bodyMomentum;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Avatar::setDisplayingHead(bool displayingHead) {
|
||||
_displayingHead = displayingHead;
|
||||
}
|
||||
|
@ -839,16 +776,6 @@ void Avatar::render(bool lookingInMirror, glm::vec3 cameraPosition) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Avatar::setHandMovementValues(glm::vec3 handOffset) {
|
||||
_movedHandOffset = handOffset;
|
||||
}
|
||||
|
||||
AvatarMode Avatar::getMode() {
|
||||
return _mode;
|
||||
}
|
||||
|
||||
void Avatar::initializeSkeleton() {
|
||||
|
||||
for (int b=0; b<NUM_AVATAR_JOINTS; b++) {
|
||||
|
@ -1131,14 +1058,10 @@ const glm::vec3& Avatar::getHeadPosition() const {
|
|||
return _joint[ AVATAR_JOINT_HEAD_BASE ].position;
|
||||
}
|
||||
|
||||
|
||||
glm::vec3 Avatar::getApproximateEyePosition() {
|
||||
return _head.getApproximateEyePosition();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Avatar::updateArmIKAndConstraints(float deltaTime) {
|
||||
|
||||
// determine the arm vector
|
||||
|
@ -1389,7 +1312,6 @@ void Avatar::transmitterV2RenderLevels(int width, int height) {
|
|||
glEnd();
|
||||
}
|
||||
|
||||
|
||||
void Avatar::setHeadFromGyros(glm::vec3* eulerAngles, glm::vec3* angularVelocity, float deltaTime, float smoothingTime) {
|
||||
//
|
||||
// Given absolute position and angular velocity information, update the avatar's head angles
|
||||
|
@ -1428,8 +1350,6 @@ void Avatar::setHeadFromGyros(glm::vec3* eulerAngles, glm::vec3* angularVelocity
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char AVATAR_DATA_FILENAME[] = "avatar.ifd";
|
||||
|
||||
void Avatar::writeAvatarDataToFile() {
|
||||
|
@ -1457,5 +1377,4 @@ void Avatar::readAvatarDataFromFile() {
|
|||
}
|
||||
fclose(avatarFile);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -76,9 +76,7 @@ enum AvatarJointID
|
|||
class Avatar : public AvatarData {
|
||||
public:
|
||||
Avatar(bool isMine);
|
||||
Avatar(const Avatar &otherAvatar);
|
||||
Avatar* clone() const;
|
||||
|
||||
|
||||
void reset();
|
||||
void updateHeadFromGyros(float frametime, SerialInterface * serialInterface, glm::vec3 * gravity);
|
||||
void updateFromMouse(int mouseX, int mouseY, int screenWidth, int screenHeight);
|
||||
|
@ -101,18 +99,18 @@ public:
|
|||
const glm::vec3& getSpringyHeadPosition() const ; // get the springy position of the avatar's head
|
||||
const glm::vec3& getJointPosition(AvatarJointID j) const { return _joint[j].springyPosition; };
|
||||
const glm::vec3& getBodyUpDirection() const { return _orientation.getUp(); };
|
||||
float getSpeed() const { return _speed; };
|
||||
float getSpeed() const { return _speed; }
|
||||
const glm::vec3& getVelocity() const { return _velocity; };
|
||||
float getGirth();
|
||||
float getHeight();
|
||||
float getHeight() const { return _height; }
|
||||
|
||||
AvatarMode getMode();
|
||||
AvatarMode getMode() const { return _mode; }
|
||||
|
||||
void setMousePressed(bool pressed);
|
||||
void render(bool lookingInMirror, glm::vec3 cameraPosition);
|
||||
void renderBody(bool lookingInMirror);
|
||||
void simulate(float);
|
||||
void setHandMovementValues( glm::vec3 movement );
|
||||
void setMovedHandOffset(glm::vec3 movedHandOffset) { _movedHandOffset = movedHandOffset; }
|
||||
void updateArmIKAndConstraints( float deltaTime );
|
||||
void setDisplayingHead( bool displayingHead );
|
||||
|
||||
|
@ -139,6 +137,9 @@ public:
|
|||
void readAvatarDataFromFile();
|
||||
|
||||
private:
|
||||
// privatize copy constructor and assignment operator to avoid copying
|
||||
Avatar(const Avatar&);
|
||||
Avatar& operator= (const Avatar&);
|
||||
|
||||
struct AvatarJoint
|
||||
{
|
||||
|
|
|
@ -417,11 +417,6 @@ int VoxelSystem::updateNodeInArraysAsPartialVBO(VoxelNode* node) {
|
|||
return 0; // not-updated
|
||||
}
|
||||
|
||||
VoxelSystem* VoxelSystem::clone() const {
|
||||
// this still needs to be implemented, will need to be used if VoxelSystem is attached to agent
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void VoxelSystem::init() {
|
||||
|
||||
_renderWarningsOn = false;
|
||||
|
|
|
@ -31,7 +31,6 @@ public:
|
|||
~VoxelSystem();
|
||||
|
||||
int parseData(unsigned char* sourceBuffer, int numBytes);
|
||||
VoxelSystem* clone() const;
|
||||
|
||||
void setViewFrustum(ViewFrustum* viewFrustum) { _viewFrustum = viewFrustum; };
|
||||
|
||||
|
@ -82,6 +81,10 @@ public:
|
|||
creationMode mode, bool destructive = false, bool debug = false);
|
||||
|
||||
private:
|
||||
// disallow copying of VoxelSystem objects
|
||||
VoxelSystem(const VoxelSystem&);
|
||||
VoxelSystem& operator= (const VoxelSystem&);
|
||||
|
||||
int _callsToTreesToArrays;
|
||||
VoxelNodeBag _removedVoxels;
|
||||
|
||||
|
|
|
@ -24,28 +24,10 @@ AudioRingBuffer::AudioRingBuffer(int ringSamples, int bufferSamples) :
|
|||
_nextOutput = _buffer;
|
||||
};
|
||||
|
||||
AudioRingBuffer::AudioRingBuffer(const AudioRingBuffer &otherRingBuffer) {
|
||||
_ringBufferLengthSamples = otherRingBuffer._ringBufferLengthSamples;
|
||||
_bufferLengthSamples = otherRingBuffer._bufferLengthSamples;
|
||||
_started = otherRingBuffer._started;
|
||||
_shouldBeAddedToMix = otherRingBuffer._shouldBeAddedToMix;
|
||||
_shouldLoopbackForAgent = otherRingBuffer._shouldLoopbackForAgent;
|
||||
|
||||
_buffer = new int16_t[_ringBufferLengthSamples];
|
||||
memcpy(_buffer, otherRingBuffer._buffer, sizeof(int16_t) * _ringBufferLengthSamples);
|
||||
|
||||
_nextOutput = _buffer + (otherRingBuffer._nextOutput - otherRingBuffer._buffer);
|
||||
_endOfLastWrite = _buffer + (otherRingBuffer._endOfLastWrite - otherRingBuffer._buffer);
|
||||
}
|
||||
|
||||
AudioRingBuffer::~AudioRingBuffer() {
|
||||
delete[] _buffer;
|
||||
};
|
||||
|
||||
AudioRingBuffer* AudioRingBuffer::clone() const {
|
||||
return new AudioRingBuffer(*this);
|
||||
}
|
||||
|
||||
const int AGENT_LOOPBACK_MODIFIER = 307;
|
||||
|
||||
int AudioRingBuffer::parseData(unsigned char* sourceBuffer, int numBytes) {
|
||||
|
|
|
@ -22,10 +22,8 @@ class AudioRingBuffer : public AgentData {
|
|||
public:
|
||||
AudioRingBuffer(int ringSamples, int bufferSamples);
|
||||
~AudioRingBuffer();
|
||||
AudioRingBuffer(const AudioRingBuffer &otherRingBuffer);
|
||||
|
||||
int parseData(unsigned char* sourceBuffer, int numBytes);
|
||||
AudioRingBuffer* clone() const;
|
||||
|
||||
int16_t* getNextOutput() const { return _nextOutput; }
|
||||
void setNextOutput(int16_t* nextOutput) { _nextOutput = nextOutput; }
|
||||
|
@ -48,6 +46,10 @@ public:
|
|||
|
||||
short diffLastWriteNextOutput();
|
||||
private:
|
||||
// disallow copying of AudioRingBuffer objects
|
||||
AudioRingBuffer(const AudioRingBuffer&);
|
||||
AudioRingBuffer& operator= (const AudioRingBuffer&);
|
||||
|
||||
int _ringBufferLengthSamples;
|
||||
int _bufferLengthSamples;
|
||||
Position _position;
|
||||
|
|
|
@ -34,14 +34,6 @@ int unpackFloatAngleFromTwoByte(uint16_t* byteAnglePointer, float* destinationPo
|
|||
return sizeof(uint16_t);
|
||||
}
|
||||
|
||||
AvatarData::~AvatarData() {
|
||||
|
||||
}
|
||||
|
||||
AvatarData* AvatarData::clone() const {
|
||||
return new AvatarData(*this);
|
||||
}
|
||||
|
||||
int AvatarData::getBroadcastData(unsigned char* destinationBuffer) {
|
||||
unsigned char* bufferStart = destinationBuffer;
|
||||
|
||||
|
@ -200,49 +192,9 @@ int AvatarData::parseData(unsigned char* sourceBuffer, int numBytes) {
|
|||
return sourceBuffer - startPosition;
|
||||
}
|
||||
|
||||
const glm::vec3& AvatarData::getPosition() const {
|
||||
return _position;
|
||||
}
|
||||
|
||||
void AvatarData::setPosition(glm::vec3 position) {
|
||||
_position = position;
|
||||
}
|
||||
|
||||
void AvatarData::setHandPosition(glm::vec3 handPosition) {
|
||||
_handPosition = handPosition;
|
||||
}
|
||||
|
||||
float AvatarData::getBodyYaw() {
|
||||
return _bodyYaw;
|
||||
}
|
||||
|
||||
void AvatarData::setBodyYaw(float bodyYaw) {
|
||||
_bodyYaw = bodyYaw;
|
||||
}
|
||||
|
||||
float AvatarData::getBodyPitch() {
|
||||
return _bodyPitch;
|
||||
}
|
||||
|
||||
void AvatarData::setBodyPitch(float bodyPitch) {
|
||||
_bodyPitch = bodyPitch;
|
||||
}
|
||||
|
||||
float AvatarData::getBodyRoll() {
|
||||
return _bodyRoll;
|
||||
}
|
||||
|
||||
void AvatarData::setBodyRoll(float bodyRoll) {
|
||||
_bodyRoll = bodyRoll;
|
||||
}
|
||||
|
||||
void AvatarData::setHeadPitch(float p) {
|
||||
// Set head pitch and apply limits
|
||||
const float MAX_PITCH = 60;
|
||||
const float MIN_PITCH = -60;
|
||||
_headPitch = glm::clamp(p, MIN_PITCH, MAX_PITCH);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -52,25 +52,23 @@ public:
|
|||
_wantResIn(false),
|
||||
_wantColor(true) { };
|
||||
|
||||
const glm::vec3& getPosition() const { return _position; }
|
||||
void setPosition(const glm::vec3 position) { _position = position; }
|
||||
|
||||
~AvatarData();
|
||||
|
||||
AvatarData* clone() const;
|
||||
|
||||
const glm::vec3& getPosition() const;
|
||||
void setPosition(glm::vec3 position);
|
||||
void setHandPosition(glm::vec3 handPosition);
|
||||
void setHandPosition(const glm::vec3 handPosition) { _handPosition = handPosition; }
|
||||
|
||||
int getBroadcastData(unsigned char* destinationBuffer);
|
||||
int parseData(unsigned char* sourceBuffer, int numBytes);
|
||||
|
||||
// Body Rotation
|
||||
float getBodyYaw();
|
||||
float getBodyPitch();
|
||||
float getBodyRoll();
|
||||
void setBodyYaw(float bodyYaw);
|
||||
void setBodyPitch(float bodyPitch);
|
||||
void setBodyRoll(float bodyRoll);
|
||||
float getBodyYaw() const { return _bodyYaw; }
|
||||
void setBodyYaw(float bodyYaw) { _bodyYaw = bodyYaw; }
|
||||
|
||||
float getBodyPitch() const { return _bodyPitch; }
|
||||
void setBodyPitch(float bodyPitch) { _bodyPitch = bodyPitch; }
|
||||
|
||||
float getBodyRoll() const {return _bodyRoll; }
|
||||
void setBodyRoll(float bodyRoll) { _bodyRoll = bodyRoll; }
|
||||
|
||||
// Head Rotation
|
||||
void setHeadPitch(float p);
|
||||
|
@ -134,6 +132,10 @@ public:
|
|||
void setWantDelta(bool wantDelta) { _wantDelta = wantDelta; }
|
||||
|
||||
protected:
|
||||
// privatize the copy constructor and assignment operator so they cannot be called
|
||||
AvatarData(const AvatarData&);
|
||||
AvatarData& operator= (const AvatarData&);
|
||||
|
||||
glm::vec3 _position;
|
||||
glm::vec3 _handPosition;
|
||||
|
||||
|
|
|
@ -55,67 +55,6 @@ Agent::Agent(sockaddr* publicSocket, sockaddr* localSocket, char type, uint16_t
|
|||
}
|
||||
}
|
||||
|
||||
Agent::Agent(const Agent &otherAgent) :
|
||||
_type(otherAgent._type),
|
||||
_agentID(otherAgent._agentID),
|
||||
_wakeMicrostamp(otherAgent._wakeMicrostamp),
|
||||
_lastHeardMicrostamp(otherAgent._lastHeardMicrostamp),
|
||||
_isAlive(otherAgent._isAlive)
|
||||
{
|
||||
if (otherAgent._publicSocket) {
|
||||
_publicSocket = new sockaddr(*otherAgent._localSocket);
|
||||
} else {
|
||||
_publicSocket = NULL;
|
||||
}
|
||||
|
||||
if (otherAgent._localSocket) {
|
||||
_localSocket = new sockaddr(*otherAgent._localSocket);
|
||||
} else {
|
||||
_localSocket = NULL;
|
||||
}
|
||||
|
||||
if (otherAgent._activeSocket == otherAgent._publicSocket) {
|
||||
_activeSocket = _publicSocket;
|
||||
} else if (otherAgent._activeSocket == otherAgent._localSocket) {
|
||||
_activeSocket = _localSocket;
|
||||
} else {
|
||||
_activeSocket = NULL;
|
||||
}
|
||||
|
||||
if (otherAgent._linkedData) {
|
||||
_linkedData = otherAgent._linkedData->clone();
|
||||
} else {
|
||||
_linkedData = NULL;
|
||||
}
|
||||
|
||||
if (otherAgent._bytesReceivedMovingAverage != NULL) {
|
||||
_bytesReceivedMovingAverage = new SimpleMovingAverage(100);
|
||||
memcpy(_bytesReceivedMovingAverage, otherAgent._bytesReceivedMovingAverage, sizeof(SimpleMovingAverage));
|
||||
} else {
|
||||
_bytesReceivedMovingAverage = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
Agent& Agent::operator=(Agent otherAgent) {
|
||||
swap(*this, otherAgent);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Agent::swap(Agent &first, Agent &second) {
|
||||
using std::swap;
|
||||
|
||||
swap(first._isAlive, second._isAlive);
|
||||
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._wakeMicrostamp, second._wakeMicrostamp);
|
||||
swap(first._lastHeardMicrostamp, second._lastHeardMicrostamp);
|
||||
swap(first._bytesReceivedMovingAverage, second._bytesReceivedMovingAverage);
|
||||
}
|
||||
|
||||
Agent::~Agent() {
|
||||
delete _publicSocket;
|
||||
delete _localSocket;
|
||||
|
@ -130,6 +69,7 @@ const char* AGENT_TYPE_NAME_INTERFACE = "Client Interface";
|
|||
const char* AGENT_TYPE_NAME_AUDIO_MIXER = "Audio Mixer";
|
||||
const char* AGENT_TYPE_NAME_AVATAR_MIXER = "Avatar Mixer";
|
||||
const char* AGENT_TYPE_NAME_AUDIO_INJECTOR = "Audio Injector";
|
||||
const char* AGENT_TYPE_NAME_ANIMATION_SERVER = "Animation Server";
|
||||
const char* AGENT_TYPE_NAME_UNKNOWN = "Unknown";
|
||||
|
||||
const char* Agent::getTypeName() const {
|
||||
|
@ -146,6 +86,8 @@ const char* Agent::getTypeName() const {
|
|||
return AGENT_TYPE_NAME_AVATAR_MIXER;
|
||||
case AGENT_TYPE_AUDIO_INJECTOR:
|
||||
return AGENT_TYPE_NAME_AUDIO_INJECTOR;
|
||||
case AGENT_TYPE_ANIMATION_SERVER:
|
||||
return AGENT_TYPE_NAME_ANIMATION_SERVER;
|
||||
default:
|
||||
return AGENT_TYPE_NAME_UNKNOWN;
|
||||
}
|
||||
|
|
|
@ -24,9 +24,8 @@
|
|||
class Agent {
|
||||
public:
|
||||
Agent(sockaddr* publicSocket, sockaddr* localSocket, char type, uint16_t agentID);
|
||||
Agent(const Agent &otherAgent);
|
||||
~Agent();
|
||||
Agent& operator=(Agent otherAgent);
|
||||
|
||||
bool operator==(const Agent& otherAgent);
|
||||
|
||||
bool matches(sockaddr* otherPublicSocket, sockaddr* otherLocalSocket, char otherAgentType);
|
||||
|
@ -66,7 +65,9 @@ public:
|
|||
|
||||
static void printLog(Agent const&);
|
||||
private:
|
||||
void swap(Agent &first, Agent &second);
|
||||
// privatize copy and assignment operator to disallow Agent copying
|
||||
Agent(const Agent &otherAgent);
|
||||
Agent& operator=(Agent otherAgent);
|
||||
|
||||
char _type;
|
||||
uint16_t _agentID;
|
||||
|
|
|
@ -10,10 +10,9 @@
|
|||
#define hifi_AgentData_h
|
||||
|
||||
class AgentData {
|
||||
public:
|
||||
virtual ~AgentData() = 0;
|
||||
virtual int parseData(unsigned char* sourceBuffer, int numBytes) = 0;
|
||||
virtual AgentData* clone() const = 0;
|
||||
public:
|
||||
virtual ~AgentData() = 0;
|
||||
virtual int parseData(unsigned char* sourceBuffer, int numBytes) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -24,5 +24,6 @@ const char AGENT_TYPE_AVATAR = 'I';
|
|||
const char AGENT_TYPE_AUDIO_MIXER = 'M';
|
||||
const char AGENT_TYPE_AVATAR_MIXER = 'W';
|
||||
const char AGENT_TYPE_AUDIO_INJECTOR = 'A';
|
||||
const char AGENT_TYPE_ANIMATION_SERVER = 'a';
|
||||
|
||||
#endif
|
||||
|
|
|
@ -215,6 +215,7 @@ bool createVoxelEditMessage(unsigned char command, short int sequence,
|
|||
sizeOut=actualMessageSize;
|
||||
memcpy(bufferOut,messageBuffer,actualMessageSize);
|
||||
}
|
||||
delete[] messageBuffer; // clean up our temporary buffer
|
||||
return success;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,19 +11,18 @@
|
|||
#include <cstring>
|
||||
#include <cstdio>
|
||||
|
||||
VoxelAgentData::VoxelAgentData() {
|
||||
init();
|
||||
VoxelAgentData::VoxelAgentData() :
|
||||
_viewSent(false),
|
||||
_voxelPacketAvailableBytes(MAX_VOXEL_PACKET_SIZE),
|
||||
_maxSearchLevel(1),
|
||||
_maxLevelReachedInLastSearch(1)
|
||||
{
|
||||
_voxelPacket = new unsigned char[MAX_VOXEL_PACKET_SIZE];
|
||||
_voxelPacketAt = _voxelPacket;
|
||||
|
||||
resetVoxelPacket();
|
||||
}
|
||||
|
||||
void VoxelAgentData::init() {
|
||||
_voxelPacket = new unsigned char[MAX_VOXEL_PACKET_SIZE];
|
||||
_voxelPacketAvailableBytes = MAX_VOXEL_PACKET_SIZE;
|
||||
_voxelPacketAt = _voxelPacket;
|
||||
_maxSearchLevel = 1;
|
||||
_maxLevelReachedInLastSearch = 1;
|
||||
resetVoxelPacket();
|
||||
_viewSent = false;
|
||||
}
|
||||
|
||||
void VoxelAgentData::resetVoxelPacket() {
|
||||
_voxelPacket[0] = getWantColor() ? PACKET_HEADER_VOXEL_DATA : PACKET_HEADER_VOXEL_DATA_MONOCHROME;
|
||||
|
@ -43,15 +42,6 @@ VoxelAgentData::~VoxelAgentData() {
|
|||
delete[] _voxelPacket;
|
||||
}
|
||||
|
||||
VoxelAgentData::VoxelAgentData(const VoxelAgentData &otherAgentData) {
|
||||
memcpy(&_position, &otherAgentData._position, sizeof(_position));
|
||||
init();
|
||||
}
|
||||
|
||||
VoxelAgentData* VoxelAgentData::clone() const {
|
||||
return new VoxelAgentData(*this);
|
||||
}
|
||||
|
||||
bool VoxelAgentData::updateCurrentViewFrustum() {
|
||||
bool currentViewFrustumChanged = false;
|
||||
ViewFrustum newestViewFrustum;
|
||||
|
|
|
@ -19,11 +19,7 @@ class VoxelAgentData : public AvatarData {
|
|||
public:
|
||||
VoxelAgentData();
|
||||
~VoxelAgentData();
|
||||
VoxelAgentData(const VoxelAgentData &otherAgentData);
|
||||
|
||||
VoxelAgentData* clone() const;
|
||||
|
||||
void init(); // sets up data internals
|
||||
void resetVoxelPacket(); // resets voxel packet to after "V" header
|
||||
|
||||
void writeToPacket(unsigned char* buffer, int bytes); // writes to end of packet
|
||||
|
@ -52,7 +48,10 @@ public:
|
|||
bool getViewSent() const { return _viewSent; };
|
||||
void setViewSent(bool viewSent) { _viewSent = viewSent; }
|
||||
|
||||
private:
|
||||
private:
|
||||
VoxelAgentData(const VoxelAgentData &);
|
||||
VoxelAgentData& operator= (const VoxelAgentData&);
|
||||
|
||||
bool _viewSent;
|
||||
unsigned char* _voxelPacket;
|
||||
unsigned char* _voxelPacketAt;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <SharedUtil.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <SceneUtils.h>
|
||||
#include <PerfStat.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "Syssocket.h"
|
||||
|
@ -31,6 +32,7 @@
|
|||
|
||||
const char* LOCAL_VOXELS_PERSIST_FILE = "resources/voxels.hio2";
|
||||
const char* VOXELS_PERSIST_FILE = "/etc/highfidelity/voxel-server/resources/voxels.hio2";
|
||||
const double VOXEL_PERSIST_INTERVAL = 1000.0 * 30; // every 30 seconds
|
||||
|
||||
const int VOXEL_LISTEN_PORT = 40106;
|
||||
|
||||
|
@ -341,13 +343,31 @@ void deepestLevelVoxelDistributor(AgentList* agentList,
|
|||
} // end if bag wasn't empty, and so we sent stuff...
|
||||
}
|
||||
|
||||
double lastPersistVoxels = 0;
|
||||
void persistVoxelsWhenDirty() {
|
||||
double now = usecTimestampNow();
|
||||
double sinceLastTime = (now - ::lastPersistVoxels) / 1000.0;
|
||||
|
||||
// check the dirty bit and persist here...
|
||||
if (::wantVoxelPersist && ::randomTree.isDirty()) {
|
||||
printf("saving voxels to file...\n");
|
||||
randomTree.writeToFileV2(::wantLocalDomain ? LOCAL_VOXELS_PERSIST_FILE : VOXELS_PERSIST_FILE);
|
||||
randomTree.clearDirtyBit(); // tree is clean after saving
|
||||
printf("DONE saving voxels to file...\n");
|
||||
if (::wantVoxelPersist && ::randomTree.isDirty() && sinceLastTime > VOXEL_PERSIST_INTERVAL) {
|
||||
|
||||
{
|
||||
PerformanceWarning warn(true, "persistVoxelsWhenDirty() - reaverageVoxelColors()", true);
|
||||
|
||||
// after done inserting all these voxels, then reaverage colors
|
||||
randomTree.reaverageVoxelColors(randomTree.rootNode);
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
PerformanceWarning warn(true, "persistVoxelsWhenDirty() - writeToFileV2()", true);
|
||||
|
||||
printf("saving voxels to file...\n");
|
||||
randomTree.writeToFileV2(::wantLocalDomain ? LOCAL_VOXELS_PERSIST_FILE : VOXELS_PERSIST_FILE);
|
||||
randomTree.clearDirtyBit(); // tree is clean after saving
|
||||
printf("DONE saving voxels to file...\n");
|
||||
}
|
||||
::lastPersistVoxels = usecTimestampNow();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -498,13 +518,19 @@ int main(int argc, const char * argv[])
|
|||
|
||||
// loop to send to agents requesting data
|
||||
while (true) {
|
||||
|
||||
// check to see if we need to persist our voxel state
|
||||
persistVoxelsWhenDirty();
|
||||
persistVoxelsWhenDirty();
|
||||
|
||||
if (agentList->getAgentSocket()->receive(&agentPublicAddress, packetData, &receivedBytes)) {
|
||||
// XXXBHG: Hacked in support for 'S' SET command
|
||||
if (packetData[0] == PACKET_HEADER_SET_VOXEL || packetData[0] == PACKET_HEADER_SET_VOXEL_DESTRUCTIVE) {
|
||||
bool destructive = (packetData[0] == PACKET_HEADER_SET_VOXEL_DESTRUCTIVE);
|
||||
|
||||
PerformanceWarning warn(true,
|
||||
destructive ? "PACKET_HEADER_SET_VOXEL_DESTRUCTIVE" : "PACKET_HEADER_SET_VOXEL",
|
||||
true);
|
||||
|
||||
unsigned short int itemNumber = (*((unsigned short int*)&packetData[1]));
|
||||
printf("got %s - command from client receivedBytes=%ld itemNumber=%d\n",
|
||||
destructive ? "PACKET_HEADER_SET_VOXEL_DESTRUCTIVE" : "PACKET_HEADER_SET_VOXEL",
|
||||
|
@ -541,8 +567,6 @@ int main(int argc, const char * argv[])
|
|||
pVoxelData+=voxelDataSize;
|
||||
atByte+=voxelDataSize;
|
||||
}
|
||||
// after done inserting all these voxels, then reaverage colors
|
||||
randomTree.reaverageVoxelColors(randomTree.rootNode);
|
||||
}
|
||||
if (packetData[0] == PACKET_HEADER_ERASE_VOXEL) {
|
||||
|
||||
|
@ -575,6 +599,9 @@ int main(int argc, const char * argv[])
|
|||
printf("got Z message == add scene\n");
|
||||
addSphereScene(&randomTree);
|
||||
}
|
||||
if (0==strcmp(command,(char*)"a message")) {
|
||||
printf("got Z message == a message, nothing to do, just report\n");
|
||||
}
|
||||
totalLength += commandLength+1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue