mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Merge pull request #2770 from ZappoMan/modelserver
Fix a couple bugs in Models
This commit is contained in:
commit
ac549977be
25 changed files with 313 additions and 31 deletions
|
@ -35,6 +35,7 @@ Agent::Agent(const QByteArray& packet) :
|
|||
ThreadedAssignment(packet),
|
||||
_voxelEditSender(),
|
||||
_particleEditSender(),
|
||||
_modelEditSender(),
|
||||
_receivedAudioBuffer(NETWORK_BUFFER_LENGTH_SAMPLES_STEREO),
|
||||
_avatarHashMap()
|
||||
{
|
||||
|
@ -43,6 +44,7 @@ Agent::Agent(const QByteArray& packet) :
|
|||
|
||||
_scriptEngine.getVoxelsScriptingInterface()->setPacketSender(&_voxelEditSender);
|
||||
_scriptEngine.getParticlesScriptingInterface()->setPacketSender(&_particleEditSender);
|
||||
_scriptEngine.getModelsScriptingInterface()->setPacketSender(&_modelEditSender);
|
||||
}
|
||||
|
||||
void Agent::readPendingDatagrams() {
|
||||
|
@ -88,6 +90,17 @@ void Agent::readPendingDatagrams() {
|
|||
SharedNodePointer sourceNode = nodeList->sendingNodeForPacket(receivedPacket);
|
||||
sourceNode->setLastHeardMicrostamp(usecTimestampNow());
|
||||
|
||||
} else if (datagramPacketType == PacketTypeModelAddResponse) {
|
||||
// this will keep creatorTokenIDs to IDs mapped correctly
|
||||
ModelItem::handleAddModelResponse(receivedPacket);
|
||||
|
||||
// also give our local particle tree a chance to remap any internal locally created particles
|
||||
_modelViewer.getTree()->handleAddModelResponse(receivedPacket);
|
||||
|
||||
// Make sure our Node and NodeList knows we've heard from this node.
|
||||
SharedNodePointer sourceNode = nodeList->sendingNodeForPacket(receivedPacket);
|
||||
sourceNode->setLastHeardMicrostamp(usecTimestampNow());
|
||||
|
||||
} else if (datagramPacketType == PacketTypeParticleData
|
||||
|| datagramPacketType == PacketTypeParticleErase
|
||||
|| datagramPacketType == PacketTypeOctreeStats
|
||||
|
|
|
@ -64,6 +64,7 @@ private:
|
|||
ScriptEngine _scriptEngine;
|
||||
VoxelEditPacketSender _voxelEditSender;
|
||||
ParticleEditPacketSender _particleEditSender;
|
||||
ModelEditPacketSender _modelEditSender;
|
||||
|
||||
ParticleTreeHeadlessViewer _particleViewer;
|
||||
VoxelTreeHeadlessViewer _voxelViewer;
|
||||
|
|
|
@ -28,7 +28,7 @@ public:
|
|||
// Subclasses must implement these methods
|
||||
virtual OctreeQueryNode* createOctreeQueryNode();
|
||||
virtual Octree* createTree();
|
||||
virtual unsigned char getMyNodeType() const { return NodeType::ModelServer; }
|
||||
virtual char getMyNodeType() const { return NodeType::ModelServer; }
|
||||
virtual PacketType getMyQueryMessageType() const { return PacketTypeModelQuery; }
|
||||
virtual const char* getMyServerName() const { return MODEL_SERVER_NAME; }
|
||||
virtual const char* getMyLoggingServerTargetName() const { return MODEL_SERVER_LOGGING_TARGET_NAME; }
|
||||
|
|
|
@ -63,7 +63,7 @@ public:
|
|||
// Subclasses must implement these methods
|
||||
virtual OctreeQueryNode* createOctreeQueryNode() = 0;
|
||||
virtual Octree* createTree() = 0;
|
||||
virtual unsigned char getMyNodeType() const = 0;
|
||||
virtual char getMyNodeType() const = 0;
|
||||
virtual PacketType getMyQueryMessageType() const = 0;
|
||||
virtual const char* getMyServerName() const = 0;
|
||||
virtual const char* getMyLoggingServerTargetName() const = 0;
|
||||
|
|
|
@ -28,7 +28,7 @@ public:
|
|||
// Subclasses must implement these methods
|
||||
virtual OctreeQueryNode* createOctreeQueryNode();
|
||||
virtual Octree* createTree();
|
||||
virtual unsigned char getMyNodeType() const { return NodeType::ParticleServer; }
|
||||
virtual char getMyNodeType() const { return NodeType::ParticleServer; }
|
||||
virtual PacketType getMyQueryMessageType() const { return PacketTypeParticleQuery; }
|
||||
virtual const char* getMyServerName() const { return PARTICLE_SERVER_NAME; }
|
||||
virtual const char* getMyLoggingServerTargetName() const { return PARTICLE_SERVER_LOGGING_TARGET_NAME; }
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
// Subclasses must implement these methods
|
||||
virtual OctreeQueryNode* createOctreeQueryNode();
|
||||
virtual Octree* createTree();
|
||||
virtual unsigned char getMyNodeType() const { return NodeType::VoxelServer; }
|
||||
virtual char getMyNodeType() const { return NodeType::VoxelServer; }
|
||||
virtual PacketType getMyQueryMessageType() const { return PacketTypeVoxelQuery; }
|
||||
virtual const char* getMyServerName() const { return VOXEL_SERVER_NAME; }
|
||||
virtual const char* getMyLoggingServerTargetName() const { return VOXEL_SERVER_LOGGING_TARGET_NAME; }
|
||||
|
|
|
@ -35,7 +35,8 @@ var originalProperties = {
|
|||
//modelURL: "http://highfidelity-public.s3-us-west-1.amazonaws.com/meshes/birarda/birarda_head.fbx",
|
||||
//modelURL: "http://highfidelity-public.s3-us-west-1.amazonaws.com/meshes/pug.fbx",
|
||||
//modelURL: "http://highfidelity-public.s3-us-west-1.amazonaws.com/meshes/newInvader16x16-large-purple.svo",
|
||||
modelURL: "http://highfidelity-public.s3-us-west-1.amazonaws.com/meshes/minotaur/mino_full.fbx",
|
||||
//modelURL: "http://highfidelity-public.s3-us-west-1.amazonaws.com/meshes/minotaur/mino_full.fbx",
|
||||
modelURL: "http://highfidelity-public.s3-us-west-1.amazonaws.com/meshes/Combat_tank_V01.FBX",
|
||||
|
||||
modelRotation: rotation
|
||||
};
|
||||
|
@ -64,10 +65,10 @@ function moveModel(deltaTime) {
|
|||
return; // break early
|
||||
}
|
||||
|
||||
print("count =" + count);
|
||||
//print("count =" + count);
|
||||
count++;
|
||||
|
||||
print("modelID.creatorTokenID = " + modelID.creatorTokenID);
|
||||
//print("modelID.creatorTokenID = " + modelID.creatorTokenID);
|
||||
|
||||
var newProperties = {
|
||||
position: {
|
||||
|
@ -81,7 +82,7 @@ function moveModel(deltaTime) {
|
|||
|
||||
|
||||
//print("modelID = " + modelID);
|
||||
print("newProperties.position = " + newProperties.position.x + "," + newProperties.position.y+ "," + newProperties.position.z);
|
||||
//print("newProperties.position = " + newProperties.position.x + "," + newProperties.position.y+ "," + newProperties.position.z);
|
||||
|
||||
Models.editModel(modelID, newProperties);
|
||||
}
|
||||
|
|
220
examples/placeModelsWithHands.js
Normal file
220
examples/placeModelsWithHands.js
Normal file
|
@ -0,0 +1,220 @@
|
|||
//
|
||||
// placeModelsWithHands.js
|
||||
// examples
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 1/20/14.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
// maybe we should make these constants...
|
||||
var LEFT_PALM = 0;
|
||||
var LEFT_TIP = 1;
|
||||
var LEFT_BUTTON_FWD = 5;
|
||||
var LEFT_BUTTON_3 = 3;
|
||||
|
||||
var RIGHT_PALM = 2;
|
||||
var RIGHT_TIP = 3;
|
||||
var RIGHT_BUTTON_FWD = 11;
|
||||
var RIGHT_BUTTON_3 = 9;
|
||||
|
||||
var leftModelAlreadyInHand = false;
|
||||
var rightModelAlreadyInHand = false;
|
||||
var leftHandModel;
|
||||
var rightHandModel;
|
||||
|
||||
//var throwSound = new Sound("https://dl.dropboxusercontent.com/u/1864924/hifi-sounds/throw.raw");
|
||||
//var catchSound = new Sound("https://dl.dropboxusercontent.com/u/1864924/hifi-sounds/catch.raw");
|
||||
var targetRadius = 0.25;
|
||||
|
||||
|
||||
var modelURLs = [
|
||||
"http://highfidelity-public.s3-us-west-1.amazonaws.com/meshes/Feisar_Ship.FBX",
|
||||
"http://highfidelity-public.s3-us-west-1.amazonaws.com/meshes/birarda/birarda_head.fbx",
|
||||
"http://highfidelity-public.s3-us-west-1.amazonaws.com/meshes/pug.fbx",
|
||||
"http://highfidelity-public.s3-us-west-1.amazonaws.com/meshes/newInvader16x16-large-purple.svo",
|
||||
"http://highfidelity-public.s3-us-west-1.amazonaws.com/meshes/minotaur/mino_full.fbx",
|
||||
"http://highfidelity-public.s3-us-west-1.amazonaws.com/meshes/Combat_tank_V01.FBX",
|
||||
];
|
||||
|
||||
var currentModelURL = 0;
|
||||
|
||||
var wantDebugging = false;
|
||||
function debugPrint(message) {
|
||||
if (wantDebugging) {
|
||||
print(message);
|
||||
}
|
||||
}
|
||||
|
||||
function getModelHoldPosition(whichSide) {
|
||||
var normal;
|
||||
var tipPosition;
|
||||
if (whichSide == LEFT_PALM) {
|
||||
normal = Controller.getSpatialControlNormal(LEFT_PALM);
|
||||
tipPosition = Controller.getSpatialControlPosition(LEFT_TIP);
|
||||
} else {
|
||||
normal = Controller.getSpatialControlNormal(RIGHT_PALM);
|
||||
tipPosition = Controller.getSpatialControlPosition(RIGHT_TIP);
|
||||
}
|
||||
|
||||
var MODEL_FORWARD_OFFSET = 0.08; // put the model a bit forward of fingers
|
||||
position = { x: MODEL_FORWARD_OFFSET * normal.x,
|
||||
y: MODEL_FORWARD_OFFSET * normal.y,
|
||||
z: MODEL_FORWARD_OFFSET * normal.z };
|
||||
|
||||
position.x += tipPosition.x;
|
||||
position.y += tipPosition.y;
|
||||
position.z += tipPosition.z;
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
function checkControllerSide(whichSide) {
|
||||
|
||||
var BUTTON_FWD;
|
||||
var BUTTON_3;
|
||||
var palmPosition;
|
||||
var modelAlreadyInHand;
|
||||
var handMessage;
|
||||
|
||||
if (whichSide == LEFT_PALM) {
|
||||
BUTTON_FWD = LEFT_BUTTON_FWD;
|
||||
BUTTON_3 = LEFT_BUTTON_3;
|
||||
palmPosition = Controller.getSpatialControlPosition(LEFT_PALM);
|
||||
modelAlreadyInHand = leftModelAlreadyInHand;
|
||||
handMessage = "LEFT";
|
||||
} else {
|
||||
BUTTON_FWD = RIGHT_BUTTON_FWD;
|
||||
BUTTON_3 = RIGHT_BUTTON_3;
|
||||
palmPosition = Controller.getSpatialControlPosition(RIGHT_PALM);
|
||||
modelAlreadyInHand = rightModelAlreadyInHand;
|
||||
handMessage = "RIGHT";
|
||||
}
|
||||
|
||||
//print("checkControllerSide..." + handMessage);
|
||||
|
||||
var grabButtonPressed = (Controller.isButtonPressed(BUTTON_FWD) || Controller.isButtonPressed(BUTTON_3));
|
||||
|
||||
// If I don't currently have a model in my hand, then try to grab closest one
|
||||
if (!modelAlreadyInHand && grabButtonPressed) {
|
||||
var closestModel = Models.findClosestModel(palmPosition, targetRadius);
|
||||
|
||||
if (closestModel.isKnownID) {
|
||||
|
||||
debugPrint(handMessage + " HAND- CAUGHT SOMETHING!!");
|
||||
|
||||
if (whichSide == LEFT_PALM) {
|
||||
leftModelAlreadyInHand = true;
|
||||
leftHandModel = closestModel;
|
||||
} else {
|
||||
rightModelAlreadyInHand = true;
|
||||
rightHandModel = closestModel;
|
||||
}
|
||||
var modelPosition = getModelHoldPosition(whichSide);
|
||||
var properties = { position: { x: modelPosition.x,
|
||||
y: modelPosition.y,
|
||||
z: modelPosition.z },
|
||||
};
|
||||
Models.editModel(closestModel, properties);
|
||||
|
||||
/*
|
||||
var options = new AudioInjectionOptions();
|
||||
options.position = modelPosition;
|
||||
options.volume = 1.0;
|
||||
Audio.playSound(catchSound, options);
|
||||
*/
|
||||
|
||||
return; // exit early
|
||||
}
|
||||
}
|
||||
|
||||
// If '3' is pressed, and not holding a model, make a new one
|
||||
if (Controller.isButtonPressed(BUTTON_3) && !modelAlreadyInHand) {
|
||||
var modelPosition = getModelHoldPosition(whichSide);
|
||||
var properties = { position: { x: modelPosition.x,
|
||||
y: modelPosition.y,
|
||||
z: modelPosition.z },
|
||||
radius: 0.25,
|
||||
modelURL: modelURLs[currentModelURL]
|
||||
};
|
||||
|
||||
newModel = Models.addModel(properties);
|
||||
if (whichSide == LEFT_PALM) {
|
||||
leftModelAlreadyInHand = true;
|
||||
leftHandModel = newModel;
|
||||
} else {
|
||||
rightModelAlreadyInHand = true;
|
||||
rightHandModel = newModel;
|
||||
}
|
||||
|
||||
// Play a new model sound
|
||||
/*
|
||||
var options = new AudioInjectionOptions();
|
||||
options.position = modelPosition;
|
||||
options.volume = 1.0;
|
||||
Audio.playSound(catchSound, options);
|
||||
*/
|
||||
|
||||
return; // exit early
|
||||
}
|
||||
|
||||
if (modelAlreadyInHand) {
|
||||
if (whichSide == LEFT_PALM) {
|
||||
handModel = leftHandModel;
|
||||
whichTip = LEFT_TIP;
|
||||
} else {
|
||||
handModel = rightHandModel;
|
||||
whichTip = RIGHT_TIP;
|
||||
}
|
||||
|
||||
// If holding the model keep it in the palm
|
||||
if (grabButtonPressed) {
|
||||
debugPrint(">>>>> " + handMessage + "-MODEL IN HAND, grabbing, hold and move");
|
||||
var modelPosition = getModelHoldPosition(whichSide);
|
||||
var properties = { position: { x: modelPosition.x,
|
||||
y: modelPosition.y,
|
||||
z: modelPosition.z },
|
||||
};
|
||||
Models.editModel(handModel, properties);
|
||||
} else {
|
||||
debugPrint(">>>>> " + handMessage + "-MODEL IN HAND, not grabbing, RELEASE!!!");
|
||||
if (whichSide == LEFT_PALM) {
|
||||
leftModelAlreadyInHand = false;
|
||||
leftHandModel = false;
|
||||
} else {
|
||||
rightModelAlreadyInHand = false;
|
||||
rightHandModel = false;
|
||||
}
|
||||
|
||||
/*
|
||||
var options = new AudioInjectionOptions();
|
||||
options.position = modelPosition;
|
||||
options.volume = 1.0;
|
||||
Audio.playSound(throwSound, options);
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function checkController(deltaTime) {
|
||||
var numberOfButtons = Controller.getNumberOfButtons();
|
||||
var numberOfTriggers = Controller.getNumberOfTriggers();
|
||||
var numberOfSpatialControls = Controller.getNumberOfSpatialControls();
|
||||
var controllersPerTrigger = numberOfSpatialControls / numberOfTriggers;
|
||||
|
||||
// this is expected for hydras
|
||||
if (!(numberOfButtons==12 && numberOfTriggers == 2 && controllersPerTrigger == 2)) {
|
||||
debugPrint("no hydra connected?");
|
||||
return; // bail if no hydra
|
||||
}
|
||||
|
||||
checkControllerSide(LEFT_PALM);
|
||||
checkControllerSide(RIGHT_PALM);
|
||||
}
|
||||
|
||||
|
||||
// register the call back so it fires before each data send
|
||||
Script.update.connect(checkController);
|
|
@ -273,6 +273,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
// connect to the packet sent signal of the _voxelEditSender and the _particleEditSender
|
||||
connect(&_voxelEditSender, &VoxelEditPacketSender::packetSent, this, &Application::packetSent);
|
||||
connect(&_particleEditSender, &ParticleEditPacketSender::packetSent, this, &Application::packetSent);
|
||||
connect(&_modelEditSender, &ModelEditPacketSender::packetSent, this, &Application::packetSent);
|
||||
|
||||
// move the silentNodeTimer to the _nodeThread
|
||||
QTimer* silentNodeTimer = new QTimer();
|
||||
|
@ -316,6 +317,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
// Tell our voxel edit sender about our known jurisdictions
|
||||
_voxelEditSender.setVoxelServerJurisdictions(&_voxelServerJurisdictions);
|
||||
_particleEditSender.setServerJurisdictions(&_particleServerJurisdictions);
|
||||
_modelEditSender.setServerJurisdictions(&_modelServerJurisdictions);
|
||||
|
||||
Particle::setVoxelEditPacketSender(&_voxelEditSender);
|
||||
Particle::setParticleEditPacketSender(&_particleEditSender);
|
||||
|
@ -327,6 +329,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
// probably not the right long term solution. But for now, we're going to do this to
|
||||
// allow you to move a particle around in your hand
|
||||
_particleEditSender.setPacketsPerSecond(3000); // super high!!
|
||||
_modelEditSender.setPacketsPerSecond(3000); // super high!!
|
||||
|
||||
// Set the sixense filtering
|
||||
_sixenseManager.setFilter(Menu::getInstance()->isOptionChecked(MenuOption::FilterSixense));
|
||||
|
@ -397,6 +400,7 @@ Application::~Application() {
|
|||
_voxelHideShowThread.terminate();
|
||||
_voxelEditSender.terminate();
|
||||
_particleEditSender.terminate();
|
||||
_modelEditSender.terminate();
|
||||
|
||||
storeSizeAndPosition();
|
||||
saveScripts();
|
||||
|
@ -497,6 +501,8 @@ void Application::initializeGL() {
|
|||
_voxelEditSender.initialize(_enableProcessVoxelsThread);
|
||||
_voxelHideShowThread.initialize(_enableProcessVoxelsThread);
|
||||
_particleEditSender.initialize(_enableProcessVoxelsThread);
|
||||
_modelEditSender.initialize(_enableProcessVoxelsThread);
|
||||
|
||||
if (_enableProcessVoxelsThread) {
|
||||
qDebug("Voxel parsing thread created.");
|
||||
}
|
||||
|
@ -1911,6 +1917,7 @@ void Application::updateThreads(float deltaTime) {
|
|||
_voxelHideShowThread.threadRoutine();
|
||||
_voxelEditSender.threadRoutine();
|
||||
_particleEditSender.threadRoutine();
|
||||
_modelEditSender.threadRoutine();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3229,6 +3236,7 @@ void Application::nodeKilled(SharedNodePointer node) {
|
|||
_octreeSceneStatsLock.unlock();
|
||||
|
||||
} else if (node->getType() == NodeType::ModelServer) {
|
||||
|
||||
QUuid nodeUUID = node->getUUID();
|
||||
// see if this is the first we've heard of this node...
|
||||
if (_modelServerJurisdictions.find(nodeUUID) != _modelServerJurisdictions.end()) {
|
||||
|
@ -3282,7 +3290,6 @@ void Application::trackIncomingVoxelPacket(const QByteArray& packet, const Share
|
|||
}
|
||||
|
||||
int Application::parseOctreeStats(const QByteArray& packet, const SharedNodePointer& sendingNode) {
|
||||
|
||||
// But, also identify the sender, and keep track of the contained jurisdiction root for this server
|
||||
|
||||
// parse the incoming stats datas stick it in a temporary object for now, while we
|
||||
|
@ -3309,18 +3316,21 @@ int Application::parseOctreeStats(const QByteArray& packet, const SharedNodePoin
|
|||
|
||||
// see if this is the first we've heard of this node...
|
||||
NodeToJurisdictionMap* jurisdiction = NULL;
|
||||
QString serverType;
|
||||
if (sendingNode->getType() == NodeType::VoxelServer) {
|
||||
jurisdiction = &_voxelServerJurisdictions;
|
||||
serverType = "Voxel";
|
||||
} else if (sendingNode->getType() == NodeType::ParticleServer) {
|
||||
jurisdiction = &_particleServerJurisdictions;
|
||||
serverType = "Particle";
|
||||
} else {
|
||||
jurisdiction = &_modelServerJurisdictions;
|
||||
serverType = "Model";
|
||||
}
|
||||
|
||||
|
||||
if (jurisdiction->find(nodeUUID) == jurisdiction->end()) {
|
||||
qDebug("stats from new server... v[%f, %f, %f, %f]",
|
||||
rootDetails.x, rootDetails.y, rootDetails.z, rootDetails.s);
|
||||
qDebug("stats from new %s server... [%f, %f, %f, %f]",
|
||||
qPrintable(serverType), rootDetails.x, rootDetails.y, rootDetails.z, rootDetails.s);
|
||||
|
||||
// Add the jurisditionDetails object to the list of "fade outs"
|
||||
if (!Menu::getInstance()->isOptionChecked(MenuOption::DontFadeOnVoxelServerChanges)) {
|
||||
|
|
|
@ -179,6 +179,7 @@ public:
|
|||
VoxelTree* getVoxelTree() { return _voxels.getTree(); }
|
||||
ParticleTreeRenderer* getParticles() { return &_particles; }
|
||||
MetavoxelSystem* getMetavoxels() { return &_metavoxels; }
|
||||
ModelTreeRenderer* getModels() { return &_models; }
|
||||
bool getImportSucceded() { return _importSucceded; }
|
||||
VoxelSystem* getSharedVoxelSystem() { return &_sharedVoxelSystem; }
|
||||
VoxelTree* getClipboard() { return &_clipboard; }
|
||||
|
|
|
@ -56,9 +56,17 @@ void DatagramProcessor::processDatagrams() {
|
|||
Particle::handleAddParticleResponse(incomingPacket);
|
||||
application->getParticles()->getTree()->handleAddParticleResponse(incomingPacket);
|
||||
break;
|
||||
|
||||
case PacketTypeModelAddResponse:
|
||||
// this will keep creatorTokenIDs to IDs mapped correctly
|
||||
ModelItem::handleAddModelResponse(incomingPacket);
|
||||
application->getModels()->getTree()->handleAddModelResponse(incomingPacket);
|
||||
break;
|
||||
|
||||
case PacketTypeParticleData:
|
||||
case PacketTypeParticleErase:
|
||||
case PacketTypeModelData:
|
||||
case PacketTypeModelErase:
|
||||
case PacketTypeVoxelData:
|
||||
case PacketTypeVoxelErase:
|
||||
case PacketTypeOctreeStats:
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
virtual ~ModelTreeRenderer();
|
||||
|
||||
virtual Octree* createTree() { return new ModelTree(true); }
|
||||
virtual NodeType_t getMyNodeType() const { return NodeType::ModelServer; }
|
||||
virtual char getMyNodeType() const { return NodeType::ModelServer; }
|
||||
virtual PacketType getMyQueryMessageType() const { return PacketTypeModelQuery; }
|
||||
virtual PacketType getExpectedPacketType() const { return PacketTypeModelData; }
|
||||
virtual void renderElement(OctreeElement* element, RenderArgs* args);
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
virtual ~ParticleTreeRenderer();
|
||||
|
||||
virtual Octree* createTree() { return new ParticleTree(true); }
|
||||
virtual NodeType_t getMyNodeType() const { return NodeType::ParticleServer; }
|
||||
virtual char getMyNodeType() const { return NodeType::ParticleServer; }
|
||||
virtual PacketType getMyQueryMessageType() const { return PacketTypeParticleQuery; }
|
||||
virtual PacketType getExpectedPacketType() const { return PacketTypeParticleData; }
|
||||
virtual void renderElement(OctreeElement* element, RenderArgs* args);
|
||||
|
|
|
@ -44,7 +44,6 @@ void VoxelPacketProcessor::processPacket(const SharedNodePointer& sendingNode, c
|
|||
// immediately following them inside the same packet. So, we process the PacketType_OCTREE_STATS first
|
||||
// then process any remaining bytes as if it was another packet
|
||||
if (voxelPacketType == PacketTypeOctreeStats) {
|
||||
|
||||
int statsMessageLength = app->parseOctreeStats(mutablePacket, sendingNode);
|
||||
wasStatsPacket = true;
|
||||
if (messageLength > statsMessageLength) {
|
||||
|
@ -77,6 +76,14 @@ void VoxelPacketProcessor::processPacket(const SharedNodePointer& sendingNode, c
|
|||
app->_particles.processDatagram(mutablePacket, sendingNode);
|
||||
} break;
|
||||
|
||||
case PacketTypeModelErase: {
|
||||
app->_models.processEraseMessage(mutablePacket, sendingNode);
|
||||
} break;
|
||||
|
||||
case PacketTypeModelData: {
|
||||
app->_models.processDatagram(mutablePacket, sendingNode);
|
||||
} break;
|
||||
|
||||
case PacketTypeEnvironmentData: {
|
||||
app->_environment.parseData(*sendingNode->getActiveSocket(), mutablePacket);
|
||||
} break;
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
void queueModelEditMessage(PacketType type, ModelItemID modelID, const ModelItemProperties& properties);
|
||||
|
||||
// My server type is the model server
|
||||
virtual unsigned char getMyNodeType() const { return NodeType::ModelServer; }
|
||||
virtual char getMyNodeType() const { return NodeType::ModelServer; }
|
||||
virtual void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew);
|
||||
};
|
||||
#endif // hifi_ModelEditPacketSender_h
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
virtual ~ModelTreeHeadlessViewer();
|
||||
|
||||
virtual Octree* createTree() { return new ModelTree(true); }
|
||||
virtual NodeType_t getMyNodeType() const { return NodeType::ModelServer; }
|
||||
virtual char getMyNodeType() const { return NodeType::ModelServer; }
|
||||
virtual PacketType getMyQueryMessageType() const { return PacketTypeModelQuery; }
|
||||
virtual PacketType getExpectedPacketType() const { return PacketTypeModelData; }
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@ OctreeEditPacketSender::OctreeEditPacketSender() :
|
|||
_serverJurisdictions(NULL),
|
||||
_sequenceNumber(0),
|
||||
_maxPacketSize(MAX_PACKET_SIZE) {
|
||||
//qDebug("OctreeEditPacketSender::OctreeEditPacketSender() [%p] created... ", this);
|
||||
}
|
||||
|
||||
OctreeEditPacketSender::~OctreeEditPacketSender() {
|
||||
|
@ -59,29 +58,31 @@ OctreeEditPacketSender::~OctreeEditPacketSender() {
|
|||
|
||||
bool OctreeEditPacketSender::serversExist() const {
|
||||
bool hasServers = false;
|
||||
bool atLeastOnJurisdictionMissing = false; // assume the best
|
||||
bool atLeastOneJurisdictionMissing = false; // assume the best
|
||||
NodeList* nodeList = NodeList::getInstance();
|
||||
|
||||
foreach (const SharedNodePointer& node, nodeList->getNodeHash()) {
|
||||
|
||||
// only send to the NodeTypes that are getMyNodeType()
|
||||
if (node->getType() == getMyNodeType() && node->getActiveSocket()) {
|
||||
if (node->getType() == getMyNodeType() && node->getActiveSocket()) {
|
||||
|
||||
QUuid nodeUUID = node->getUUID();
|
||||
// If we've got Jurisdictions set, then check to see if we know the jurisdiction for this server
|
||||
if (_serverJurisdictions) {
|
||||
// lookup our nodeUUID in the jurisdiction map, if it's missing then we're
|
||||
// missing at least one jurisdiction
|
||||
if ((*_serverJurisdictions).find(nodeUUID) == (*_serverJurisdictions).end()) {
|
||||
atLeastOnJurisdictionMissing = true;
|
||||
atLeastOneJurisdictionMissing = true;
|
||||
}
|
||||
}
|
||||
hasServers = true;
|
||||
}
|
||||
if (atLeastOnJurisdictionMissing) {
|
||||
if (atLeastOneJurisdictionMissing) {
|
||||
break; // no point in looking further...
|
||||
}
|
||||
}
|
||||
|
||||
return (hasServers && !atLeastOnJurisdictionMissing);
|
||||
return (hasServers && !atLeastOneJurisdictionMissing);
|
||||
}
|
||||
|
||||
// This method is called when the edit packet layer has determined that it has a fully formed packet destined for
|
||||
|
@ -217,7 +218,7 @@ void OctreeEditPacketSender::queueOctreeEditMessage(PacketType type, unsigned ch
|
|||
_preServerPackets.erase(_preServerPackets.begin());
|
||||
}
|
||||
_pendingPacketsLock.unlock();
|
||||
}
|
||||
}
|
||||
return; // bail early
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ public:
|
|||
int getMaxPacketSize() const { return _maxPacketSize; }
|
||||
|
||||
// you must override these...
|
||||
virtual unsigned char getMyNodeType() const = 0;
|
||||
virtual char getMyNodeType() const = 0;
|
||||
virtual void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew) { };
|
||||
|
||||
protected:
|
||||
|
|
|
@ -34,7 +34,7 @@ void OctreeHeadlessViewer::init() {
|
|||
}
|
||||
|
||||
void OctreeHeadlessViewer::queryOctree() {
|
||||
NodeType_t serverType = getMyNodeType();
|
||||
char serverType = getMyNodeType();
|
||||
PacketType packetType = getMyQueryMessageType();
|
||||
NodeToJurisdictionMap& jurisdictions = *_jurisdictionListener->getJurisdictions();
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
virtual ~OctreeRenderer();
|
||||
|
||||
virtual Octree* createTree() = 0;
|
||||
virtual NodeType_t getMyNodeType() const = 0;
|
||||
virtual char getMyNodeType() const = 0;
|
||||
virtual PacketType getMyQueryMessageType() const = 0;
|
||||
virtual PacketType getExpectedPacketType() const = 0;
|
||||
virtual void renderElement(OctreeElement* element, RenderArgs* args) = 0;
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
void queueParticleEditMessage(PacketType type, ParticleID particleID, const ParticleProperties& properties);
|
||||
|
||||
// My server type is the particle server
|
||||
virtual unsigned char getMyNodeType() const { return NodeType::ParticleServer; }
|
||||
virtual char getMyNodeType() const { return NodeType::ParticleServer; }
|
||||
virtual void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew);
|
||||
};
|
||||
#endif // hifi_ParticleEditPacketSender_h
|
||||
|
|
|
@ -28,7 +28,7 @@ public:
|
|||
virtual ~ParticleTreeHeadlessViewer();
|
||||
|
||||
virtual Octree* createTree() { return new ParticleTree(true); }
|
||||
virtual NodeType_t getMyNodeType() const { return NodeType::ParticleServer; }
|
||||
virtual char getMyNodeType() const { return NodeType::ParticleServer; }
|
||||
virtual PacketType getMyQueryMessageType() const { return PacketTypeParticleQuery; }
|
||||
virtual PacketType getExpectedPacketType() const { return PacketTypeParticleData; }
|
||||
|
||||
|
|
|
@ -364,6 +364,16 @@ void ScriptEngine::run() {
|
|||
}
|
||||
}
|
||||
|
||||
if (_modelsScriptingInterface.getModelPacketSender()->serversExist()) {
|
||||
// release the queue of edit voxel messages.
|
||||
_modelsScriptingInterface.getModelPacketSender()->releaseQueuedMessages();
|
||||
|
||||
// since we're in non-threaded mode, call process so that the packets are sent
|
||||
if (!_modelsScriptingInterface.getModelPacketSender()->isThreaded()) {
|
||||
_modelsScriptingInterface.getModelPacketSender()->process();
|
||||
}
|
||||
}
|
||||
|
||||
if (_isAvatar && _avatarData) {
|
||||
|
||||
const int SCRIPT_AUDIO_BUFFER_SAMPLES = floor(((SCRIPT_DATA_CALLBACK_USECS * SAMPLE_RATE) / (1000 * 1000)) + 0.5);
|
||||
|
@ -475,6 +485,16 @@ void ScriptEngine::run() {
|
|||
}
|
||||
}
|
||||
|
||||
if (_modelsScriptingInterface.getModelPacketSender()->serversExist()) {
|
||||
// release the queue of edit voxel messages.
|
||||
_modelsScriptingInterface.getModelPacketSender()->releaseQueuedMessages();
|
||||
|
||||
// since we're in non-threaded mode, call process so that the packets are sent
|
||||
if (!_modelsScriptingInterface.getModelPacketSender()->isThreaded()) {
|
||||
_modelsScriptingInterface.getModelPacketSender()->process();
|
||||
}
|
||||
}
|
||||
|
||||
// If we were on a thread, then wait till it's done
|
||||
if (thread()) {
|
||||
thread()->quit();
|
||||
|
|
|
@ -48,6 +48,6 @@ public:
|
|||
bool voxelServersExist() const { return serversExist(); }
|
||||
|
||||
// My server type is the voxel server
|
||||
virtual unsigned char getMyNodeType() const { return NodeType::VoxelServer; }
|
||||
virtual char getMyNodeType() const { return NodeType::VoxelServer; }
|
||||
};
|
||||
#endif // hifi_VoxelEditPacketSender_h
|
||||
|
|
|
@ -28,7 +28,7 @@ public:
|
|||
virtual ~VoxelTreeHeadlessViewer();
|
||||
|
||||
virtual Octree* createTree() { return new VoxelTree(true); }
|
||||
virtual NodeType_t getMyNodeType() const { return NodeType::VoxelServer; }
|
||||
virtual char getMyNodeType() const { return NodeType::VoxelServer; }
|
||||
virtual PacketType getMyQueryMessageType() const { return PacketTypeVoxelQuery; }
|
||||
virtual PacketType getExpectedPacketType() const { return PacketTypeVoxelData; }
|
||||
|
||||
|
|
Loading…
Reference in a new issue