mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 08:36:26 +02:00
get VS back to a point where it talks to client
This commit is contained in:
parent
0820900365
commit
846ba80c10
1 changed files with 48 additions and 15 deletions
|
@ -47,40 +47,40 @@ int randomlyFillVoxelTree(int levelsToGo, VoxelNode *currentRootNode) {
|
||||||
// randomly generate children for this node
|
// randomly generate children for this node
|
||||||
// the first level of the tree (where levelsToGo = MAX_VOXEL_TREE_DEPTH_LEVELS) has all 8
|
// the first level of the tree (where levelsToGo = MAX_VOXEL_TREE_DEPTH_LEVELS) has all 8
|
||||||
if (levelsToGo > 0) {
|
if (levelsToGo > 0) {
|
||||||
|
|
||||||
int grandChildrenFromNode = 0;
|
int grandChildrenFromNode = 0;
|
||||||
bool createdChildren = false;
|
bool createdChildren = false;
|
||||||
int colorArray[4] = {};
|
int colorArray[4] = {};
|
||||||
|
|
||||||
createdChildren = false;
|
createdChildren = false;
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
if (((i == 0 || i == 1 | i == 4 | i == 5) && (randomBoolean() || levelsToGo != 1)) ) {
|
if (((i == 0 || i == 1 | i == 4 | i == 5) && (randomBoolean() || levelsToGo != 1)) ) {
|
||||||
// create a new VoxelNode to put here
|
// create a new VoxelNode to put here
|
||||||
currentRootNode->children[i] = new VoxelNode();
|
currentRootNode->children[i] = new VoxelNode();
|
||||||
|
|
||||||
// give this child it's octal code
|
// give this child it's octal code
|
||||||
currentRootNode->children[i]->octalCode = childOctalCode(currentRootNode->octalCode, i);
|
currentRootNode->children[i]->octalCode = childOctalCode(currentRootNode->octalCode, i);
|
||||||
|
|
||||||
// fill out the lower levels of the tree using that node as the root node
|
// fill out the lower levels of the tree using that node as the root node
|
||||||
grandChildrenFromNode = randomlyFillVoxelTree(levelsToGo - 1, currentRootNode->children[i]);
|
grandChildrenFromNode = randomlyFillVoxelTree(levelsToGo - 1, currentRootNode->children[i]);
|
||||||
|
|
||||||
if (currentRootNode->children[i]->color[3] == 1) {
|
if (currentRootNode->children[i]->color[3] == 1) {
|
||||||
for (int c = 0; c < 3; c++) {
|
for (int c = 0; c < 3; c++) {
|
||||||
colorArray[c] += currentRootNode->children[i]->color[c];
|
colorArray[c] += currentRootNode->children[i]->color[c];
|
||||||
}
|
}
|
||||||
|
|
||||||
colorArray[3]++;
|
colorArray[3]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (grandChildrenFromNode > 0) {
|
if (grandChildrenFromNode > 0) {
|
||||||
currentRootNode->childMask += (1 << (7 - i));
|
currentRootNode->childMask += (1 << (7 - i));
|
||||||
}
|
}
|
||||||
|
|
||||||
createdChildren = true;
|
createdChildren = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!createdChildren) {
|
if (!createdChildren) {
|
||||||
// we didn't create any children for this node, making it a leaf
|
// we didn't create any children for this node, making it a leaf
|
||||||
// give it a random color
|
// give it a random color
|
||||||
|
@ -89,12 +89,12 @@ int randomlyFillVoxelTree(int levelsToGo, VoxelNode *currentRootNode) {
|
||||||
// set the color value for this node
|
// set the color value for this node
|
||||||
currentRootNode->setColorFromAverageOfChildren(colorArray);
|
currentRootNode->setColorFromAverageOfChildren(colorArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
return createdChildren;
|
return createdChildren;
|
||||||
} else {
|
} else {
|
||||||
// this is a leaf node, just give it a color
|
// this is a leaf node, just give it a color
|
||||||
currentRootNode->setRandomColor(MIN_BRIGHTNESS);
|
currentRootNode->setRandomColor(MIN_BRIGHTNESS);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,11 +125,11 @@ int main(int argc, const char * argv[])
|
||||||
|
|
||||||
unsigned char *voxelPacket = new unsigned char[MAX_VOXEL_PACKET_SIZE];
|
unsigned char *voxelPacket = new unsigned char[MAX_VOXEL_PACKET_SIZE];
|
||||||
unsigned char *voxelPacketEnd;
|
unsigned char *voxelPacketEnd;
|
||||||
|
|
||||||
unsigned char *stopOctal;
|
unsigned char *stopOctal;
|
||||||
int packetCount;
|
int packetCount;
|
||||||
int totalBytesSent;
|
int totalBytesSent;
|
||||||
|
|
||||||
sockaddr agentPublicAddress;
|
sockaddr agentPublicAddress;
|
||||||
|
|
||||||
char *packetData = new char[MAX_PACKET_SIZE];
|
char *packetData = new char[MAX_PACKET_SIZE];
|
||||||
|
@ -144,8 +144,41 @@ int main(int argc, const char * argv[])
|
||||||
agentList.increaseAgentId();
|
agentList.increaseAgentId();
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse this agent's position
|
|
||||||
agentList.updateAgentWithData(&agentPublicAddress, (void *)packetData, receivedBytes);
|
agentList.updateAgentWithData(&agentPublicAddress, (void *)packetData, receivedBytes);
|
||||||
|
|
||||||
|
VoxelAgentData *agentData = (VoxelAgentData *) agentList.getAgents()[agentList.indexOfMatchingAgent(&agentPublicAddress)].getLinkedData();
|
||||||
|
int newLevel = 10;
|
||||||
|
if (newLevel > agentData->lastSentLevel) {
|
||||||
|
// the agent has already received a deeper level than this from us
|
||||||
|
// do nothing
|
||||||
|
|
||||||
|
stopOctal = randomTree.rootNode->octalCode;
|
||||||
|
packetCount = 0;
|
||||||
|
totalBytesSent = 0;
|
||||||
|
randomTree.leavesWrittenToBitstream = 0;
|
||||||
|
|
||||||
|
while (stopOctal != NULL) {
|
||||||
|
voxelPacketEnd = voxelPacket;
|
||||||
|
stopOctal = randomTree.loadBitstreamBuffer(voxelPacketEnd,
|
||||||
|
stopOctal,
|
||||||
|
randomTree.rootNode,
|
||||||
|
newLevel);
|
||||||
|
|
||||||
|
agentList.getAgentSocket().send((sockaddr *)&agentPublicAddress,
|
||||||
|
voxelPacket,
|
||||||
|
voxelPacketEnd - voxelPacket);
|
||||||
|
|
||||||
|
packetCount++;
|
||||||
|
totalBytesSent += voxelPacketEnd - voxelPacket;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%d packets sent to client totalling %d bytes\n", packetCount, totalBytesSent);
|
||||||
|
printf("%d leaves were sent - %f bpv\n",
|
||||||
|
randomTree.leavesWrittenToBitstream,
|
||||||
|
(float)totalBytesSent / randomTree.leavesWrittenToBitstream);
|
||||||
|
|
||||||
|
agentData->lastSentLevel = newLevel;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue