unblock socket receive in Agent, add destructive voxel add to VS scripting

This commit is contained in:
Stephen Birarda 2013-09-20 14:35:25 -07:00
parent 23e7278be5
commit 04c4dabd3d
4 changed files with 34 additions and 2 deletions

View file

@ -23,6 +23,8 @@ void Agent::run() {
NodeList::getInstance()->setOwnerType(NODE_TYPE_AGENT);
NodeList::getInstance()->setNodeTypesOfInterest(&NODE_TYPE_VOXEL_SERVER, 1);
NodeList::getInstance()->getNodeSocket()->setBlocking(false);
QNetworkAccessManager manager;
// figure out the URL for the script for this agent assignment
@ -83,7 +85,7 @@ void Agent::run() {
// flush the voxel packet queue
voxelScripter.getVoxelPacketSender()->process();
if (NodeList::getInstance()->getNodeSocket()->receive((sockaddr*) &senderAddress, receivedData, &receivedBytes)) {
while (NodeList::getInstance()->getNodeSocket()->receive((sockaddr*) &senderAddress, receivedData, &receivedBytes)) {
NodeList::getInstance()->processNodeData((sockaddr*) &senderAddress, receivedData, receivedBytes);
}

View file

@ -103,6 +103,9 @@ void childClient() {
nodeList->setOwnerType(NODE_TYPE_UNASSIGNED);
nodeList->reset();
// set the NodeList socket back to blocking
nodeList->getNodeSocket()->setBlocking(true);
// reset the logging target to the the CHILD_TARGET_NAME
Logging::setTargetName(CHILD_TARGET_NAME);
}

View file

@ -8,8 +8,23 @@
#include "VoxelScriptingInterface.h"
void VoxelScriptingInterface::queueVoxelAdd(PACKET_TYPE addPacketType, VoxelDetail& addVoxelDetails) {
_voxelPacketSender.sendVoxelEditMessage(addPacketType, addVoxelDetails);
}
void VoxelScriptingInterface::queueVoxelAdd(float x, float y, float z, float scale, uchar red, uchar green, uchar blue) {
// setup a VoxelDetail struct with the data
VoxelDetail addVoxelDetail = {x, y, z, scale, red, green, blue};
_voxelPacketSender.sendVoxelEditMessage(PACKET_TYPE_SET_VOXEL, addVoxelDetail);
// queue the packet
queueVoxelAdd(PACKET_TYPE_SET_VOXEL, addVoxelDetail);
}
void VoxelScriptingInterface::queueDesctructiveVoxelAdd(float x, float y, float z, float scale,
uchar red, uchar green, uchar blue) {
// setup a VoxelDetail struct with the data
VoxelDetail addVoxelDetail = {x, y, z, scale, red, green, blue};
// queue the destructive add
queueVoxelAdd(PACKET_TYPE_SET_VOXEL_DESTRUCTIVE, addVoxelDetail);
}

View file

@ -28,9 +28,21 @@ public slots:
/// \param green the G value for RGB color of voxel
/// \param blue the B value for RGB color of voxel
void queueVoxelAdd(float x, float y, float z, float scale, uchar red, uchar green, uchar blue);
/// queues the destructive creation of a voxel which will be sent by calling process on the PacketSender
/// \param x the x-coordinate of the voxel (in VS space)
/// \param y the y-coordinate of the voxel (in VS space)
/// \param z the z-coordinate of the voxel (in VS space)
/// \param scale the scale of the voxel (in VS space)
/// \param red the R value for RGB color of voxel
/// \param green the G value for RGB color of voxel
/// \param blue the B value for RGB color of voxel
void queueDesctructiveVoxelAdd(float x, float y, float z, float scale, uchar red, uchar green, uchar blue);
private:
/// attached VoxelEditPacketSender that handles queuing and sending of packets to VS
VoxelEditPacketSender _voxelPacketSender;
void queueVoxelAdd(PACKET_TYPE addPacketType, VoxelDetail& addVoxelDetails);
};
#endif /* defined(__hifi__VoxelScriptingInterface__) */