more work on seeing voxels

This commit is contained in:
ZappoMan 2014-02-26 14:16:22 -08:00
parent 08b7b86c3e
commit d361c75b50
3 changed files with 25 additions and 64 deletions

View file

@ -14,23 +14,29 @@ var yaw = 45;
var yawMax = 70;
var yawMin = 20;
var isLocal = true;
var isLocal = false;
// set up our VoxelViewer with a position and orientation
var orientation = Quat.fromPitchYawRoll(0, yaw, 0);
if (isLocal) {
MyAvatar.position = {x: 10, y: 0, z: 10};
MyAvatar.orientation = orientation;
} else {
VoxelViewer.setPosition({x: 10, y: 0, z: 10});
VoxelViewer.setOrientation(orientation);
VoxelViewer.queryOctree();
Agent.isAvatar = true;
function init() {
if (isLocal) {
MyAvatar.position = {x: 10, y: 0, z: 10};
MyAvatar.orientation = orientation;
} else {
VoxelViewer.setPosition({x: 10, y: 0, z: 10});
VoxelViewer.setOrientation(orientation);
VoxelViewer.queryOctree();
Agent.isAvatar = true;
}
}
function keepLooking() {
//print("count =" + count);
if (count == 0) {
init();
}
count++;
if (count % 10 == 0) {
yaw += yawDirection;
@ -46,6 +52,7 @@ function keepLooking() {
} else {
VoxelViewer.setOrientation(orientation);
VoxelViewer.queryOctree();
print("VoxelViewer.getOctreeElementsCount()=" + VoxelViewer.getOctreeElementsCount());
}
}
@ -61,3 +68,7 @@ Script.willSendVisualDataCallback.connect(keepLooking);
// register our scriptEnding callback
Script.scriptEnding.connect(scriptEnding);
// test for local...
Menu.isOptionChecked("Voxels");
isLocal = true; // will only get here on local client

View file

@ -226,65 +226,13 @@ void OctreeHeadlessViewer::queryOctree() {
int OctreeHeadlessViewer::parseOctreeStats(const QByteArray& packet, const SharedNodePointer& sourceNode) {
// 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
// determine which server it belongs to
OctreeSceneStats temp;
int statsMessageLength = temp.unpackFromMessage(reinterpret_cast<const unsigned char*>(packet.data()), packet.size());
// TODO: actually do something with these stats, like expose them to JS...
return statsMessageLength;
#if 0 // CURRENTLY NOT YET IMPLEMENTED
// quick fix for crash... why would voxelServer be NULL?
if (sourceNode) {
QUuid nodeUUID = sendingNode->getUUID();
// now that we know the node ID, let's add these stats to the stats for that node...
_voxelSceneStatsLock.lockForWrite();
if (_octreeServerSceneStats.find(nodeUUID) != _octreeServerSceneStats.end()) {
_octreeServerSceneStats[nodeUUID].unpackFromMessage(reinterpret_cast<const unsigned char*>(packet.data()),
packet.size());
} else {
_octreeServerSceneStats[nodeUUID] = temp;
}
_voxelSceneStatsLock.unlock();
VoxelPositionSize rootDetails;
voxelDetailsForCode(temp.getJurisdictionRoot(), rootDetails);
// see if this is the first we've heard of this node...
NodeToJurisdictionMap* jurisdiction = NULL;
if (sendingNode->getType() == NodeType::VoxelServer) {
jurisdiction = &_voxelServerJurisdictions;
} else {
jurisdiction = &_particleServerJurisdictions;
}
if (jurisdiction->find(nodeUUID) == jurisdiction->end()) {
printf("stats from new server... v[%f, %f, %f, %f]\n",
rootDetails.x, rootDetails.y, rootDetails.z, rootDetails.s);
// Add the jurisditionDetails object to the list of "fade outs"
if (!Menu::getInstance()->isOptionChecked(MenuOption::DontFadeOnVoxelServerChanges)) {
VoxelFade fade(VoxelFade::FADE_OUT, NODE_ADDED_RED, NODE_ADDED_GREEN, NODE_ADDED_BLUE);
fade.voxelDetails = rootDetails;
const float slightly_smaller = 0.99f;
fade.voxelDetails.s = fade.voxelDetails.s * slightly_smaller;
_voxelFades.push_back(fade);
}
}
// store jurisdiction details for later use
// This is bit of fiddling is because JurisdictionMap assumes it is the owner of the values used to construct it
// but VoxelSceneStats thinks it's just returning a reference to it's contents. So we need to make a copy of the
// details from the VoxelSceneStats to construct the JurisdictionMap
JurisdictionMap jurisdictionMap;
jurisdictionMap.copyContents(temp.getJurisdictionRoot(), temp.getJurisdictionEndNodes());
(*jurisdiction)[nodeUUID] = jurisdictionMap;
}
return statsMessageLength;
#endif
}
void OctreeHeadlessViewer::trackIncomingOctreePacket(const QByteArray& packet,

View file

@ -59,6 +59,8 @@ public slots:
int getBoundaryLevelAdjust() const { return _boundaryLevelAdjust; }
int getMaxPacketsPerSecond() const { return _maxPacketsPerSecond; }
unsigned getOctreeElementsCount() const { return _tree->getOctreeElementsCount(); }
private:
ViewFrustum _viewFrustum;
JurisdictionListener* _jurisdictionListener;