mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:50:00 +02:00
more work on seeing voxels
This commit is contained in:
parent
08b7b86c3e
commit
d361c75b50
3 changed files with 25 additions and 64 deletions
|
@ -14,23 +14,29 @@ var yaw = 45;
|
||||||
var yawMax = 70;
|
var yawMax = 70;
|
||||||
var yawMin = 20;
|
var yawMin = 20;
|
||||||
|
|
||||||
var isLocal = true;
|
var isLocal = false;
|
||||||
|
|
||||||
// set up our VoxelViewer with a position and orientation
|
// set up our VoxelViewer with a position and orientation
|
||||||
var orientation = Quat.fromPitchYawRoll(0, yaw, 0);
|
var orientation = Quat.fromPitchYawRoll(0, yaw, 0);
|
||||||
|
|
||||||
if (isLocal) {
|
function init() {
|
||||||
MyAvatar.position = {x: 10, y: 0, z: 10};
|
if (isLocal) {
|
||||||
MyAvatar.orientation = orientation;
|
MyAvatar.position = {x: 10, y: 0, z: 10};
|
||||||
} else {
|
MyAvatar.orientation = orientation;
|
||||||
VoxelViewer.setPosition({x: 10, y: 0, z: 10});
|
} else {
|
||||||
VoxelViewer.setOrientation(orientation);
|
VoxelViewer.setPosition({x: 10, y: 0, z: 10});
|
||||||
VoxelViewer.queryOctree();
|
VoxelViewer.setOrientation(orientation);
|
||||||
Agent.isAvatar = true;
|
VoxelViewer.queryOctree();
|
||||||
|
Agent.isAvatar = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function keepLooking() {
|
function keepLooking() {
|
||||||
//print("count =" + count);
|
//print("count =" + count);
|
||||||
|
|
||||||
|
if (count == 0) {
|
||||||
|
init();
|
||||||
|
}
|
||||||
count++;
|
count++;
|
||||||
if (count % 10 == 0) {
|
if (count % 10 == 0) {
|
||||||
yaw += yawDirection;
|
yaw += yawDirection;
|
||||||
|
@ -46,6 +52,7 @@ function keepLooking() {
|
||||||
} else {
|
} else {
|
||||||
VoxelViewer.setOrientation(orientation);
|
VoxelViewer.setOrientation(orientation);
|
||||||
VoxelViewer.queryOctree();
|
VoxelViewer.queryOctree();
|
||||||
|
print("VoxelViewer.getOctreeElementsCount()=" + VoxelViewer.getOctreeElementsCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -61,3 +68,7 @@ Script.willSendVisualDataCallback.connect(keepLooking);
|
||||||
// register our scriptEnding callback
|
// register our scriptEnding callback
|
||||||
Script.scriptEnding.connect(scriptEnding);
|
Script.scriptEnding.connect(scriptEnding);
|
||||||
|
|
||||||
|
|
||||||
|
// test for local...
|
||||||
|
Menu.isOptionChecked("Voxels");
|
||||||
|
isLocal = true; // will only get here on local client
|
||||||
|
|
|
@ -226,65 +226,13 @@ void OctreeHeadlessViewer::queryOctree() {
|
||||||
|
|
||||||
|
|
||||||
int OctreeHeadlessViewer::parseOctreeStats(const QByteArray& packet, const SharedNodePointer& sourceNode) {
|
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;
|
OctreeSceneStats temp;
|
||||||
int statsMessageLength = temp.unpackFromMessage(reinterpret_cast<const unsigned char*>(packet.data()), packet.size());
|
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;
|
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,
|
void OctreeHeadlessViewer::trackIncomingOctreePacket(const QByteArray& packet,
|
||||||
|
|
|
@ -59,6 +59,8 @@ public slots:
|
||||||
int getBoundaryLevelAdjust() const { return _boundaryLevelAdjust; }
|
int getBoundaryLevelAdjust() const { return _boundaryLevelAdjust; }
|
||||||
int getMaxPacketsPerSecond() const { return _maxPacketsPerSecond; }
|
int getMaxPacketsPerSecond() const { return _maxPacketsPerSecond; }
|
||||||
|
|
||||||
|
unsigned getOctreeElementsCount() const { return _tree->getOctreeElementsCount(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ViewFrustum _viewFrustum;
|
ViewFrustum _viewFrustum;
|
||||||
JurisdictionListener* _jurisdictionListener;
|
JurisdictionListener* _jurisdictionListener;
|
||||||
|
|
Loading…
Reference in a new issue