mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 16:43:33 +02:00
Have the voxel server push out an environment packet with its regular updates.
This commit is contained in:
parent
e40edd07e4
commit
7c9b0d8f58
2 changed files with 13 additions and 2 deletions
|
@ -26,6 +26,8 @@ EnvironmentData::EnvironmentData() :
|
|||
int EnvironmentData::getBroadcastData(unsigned char* destinationBuffer) const {
|
||||
unsigned char* bufferStart = destinationBuffer;
|
||||
|
||||
*destinationBuffer++ = PACKET_HEADER_ENVIRONMENT_DATA;
|
||||
|
||||
memcpy(destinationBuffer, &_atmosphereCenter, sizeof(_atmosphereCenter));
|
||||
destinationBuffer += sizeof(_atmosphereCenter);
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <OctalCode.h>
|
||||
#include <AgentList.h>
|
||||
#include <AgentTypes.h>
|
||||
#include <EnvironmentData.h>
|
||||
#include <VoxelTree.h>
|
||||
#include "VoxelAgentData.h"
|
||||
#include <SharedUtil.h>
|
||||
|
@ -48,6 +49,8 @@ bool wantVoxelPersist = true;
|
|||
bool wantColorRandomizer = false;
|
||||
bool debugVoxelSending = false;
|
||||
|
||||
EnvironmentData environmentData;
|
||||
|
||||
void addSphere(VoxelTree * tree,bool random, bool wantColorRandomizer) {
|
||||
float r = random ? randFloatInRange(0.05,0.1) : 0.25;
|
||||
float xc = random ? randFloatInRange(r,(1-r)) : 0.5;
|
||||
|
@ -237,7 +240,7 @@ void voxelDistributor(AgentList* agentList, AgentList::iterator& agent, VoxelAge
|
|||
int trueBytesSent = 0;
|
||||
double start = usecTimestampNow();
|
||||
|
||||
while (packetsSentThisInterval < PACKETS_PER_CLIENT_PER_INTERVAL) {
|
||||
while (packetsSentThisInterval < PACKETS_PER_CLIENT_PER_INTERVAL - 1) {
|
||||
if (!agentData->nodeBag.isEmpty()) {
|
||||
VoxelNode* subTree = agentData->nodeBag.extract();
|
||||
bytesWritten = randomTree.encodeTreeBitstream(agentData->getMaxSearchLevel(), subTree,
|
||||
|
@ -267,6 +270,12 @@ void voxelDistributor(AgentList* agentList, AgentList::iterator& agent, VoxelAge
|
|||
packetsSentThisInterval = PACKETS_PER_CLIENT_PER_INTERVAL; // done for now, no nodes left
|
||||
}
|
||||
}
|
||||
// send the environment packet
|
||||
int envPacketLength = environmentData.getBroadcastData(tempOutputBuffer);
|
||||
agentList->getAgentSocket().send(agent->getActiveSocket(), tempOutputBuffer, envPacketLength);
|
||||
trueBytesSent += envPacketLength;
|
||||
truePacketsSent++;
|
||||
|
||||
double end = usecTimestampNow();
|
||||
double elapsedmsec = (end - start)/1000.0;
|
||||
if (elapsedmsec > 100) {
|
||||
|
@ -559,4 +568,4 @@ int main(int argc, const char * argv[])
|
|||
pthread_join(sendVoxelThread, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue