Merge pull request #805 from ZappoMan/master

Tweaks for Grayson
This commit is contained in:
Philip Rosedale 2013-08-07 10:01:58 -07:00
commit cdfabd7647
3 changed files with 75 additions and 5 deletions

View file

@ -36,6 +36,7 @@ bool includeBorderTracer = true;
bool includeMovingBug = true;
bool includeBlinkingVoxel = false;
bool includeDanceFloor = true;
bool buildStreet = false;
const int ANIMATION_LISTEN_PORT = 40107;
@ -616,6 +617,61 @@ static void sendBillboard() {
}
}
bool roadInitialized = false;
const int ROAD_WIDTH_METERS = 3.0f;
const int BRICKS_ACROSS_ROAD = 32;
const float ROAD_BRICK_SIZE = 0.125f/TREE_SCALE; //(ROAD_WIDTH_METERS / TREE_SCALE) / BRICKS_ACROSS_ROAD; // in voxel units
const int ROAD_LENGTH = 1.0f / ROAD_BRICK_SIZE; // in bricks
const int ROAD_WIDTH = BRICKS_ACROSS_ROAD; // in bricks
glm::vec3 roadPosition(0.5f - (ROAD_BRICK_SIZE * BRICKS_ACROSS_ROAD), 0.0f, 0.0f);
const int BRICKS_PER_PACKET = 32; // guessing
const int PACKETS_PER_ROAD = VOXELS_PER_PACKET / (ROAD_LENGTH * ROAD_WIDTH);
void doBuildStreet() {
if (roadInitialized) {
return;
}
PACKET_TYPE message = PACKET_TYPE_SET_VOXEL_DESTRUCTIVE; // we're a bully!
static VoxelDetail details[BRICKS_PER_PACKET];
unsigned char* bufferOut;
int sizeOut;
for (int z = 0; z < ROAD_LENGTH; z++) {
for (int x = 0; x < ROAD_WIDTH; x++) {
int nthVoxel = ((z * ROAD_WIDTH) + x);
int item = nthVoxel % BRICKS_PER_PACKET;
glm::vec3 brick = roadPosition + glm::vec3(x * ROAD_BRICK_SIZE, 0, z * ROAD_BRICK_SIZE);
details[item].s = ROAD_BRICK_SIZE;
details[item].x = brick.x;
details[item].y = brick.y;
details[item].z = brick.z;
unsigned char randomTone = randIntInRange(118,138);
details[item].red = randomTone;
details[item].green = randomTone;
details[item].blue = randomTone;
if (item == BRICKS_PER_PACKET - 1) {
if (createVoxelEditMessage(message, 0, BRICKS_PER_PACKET, (VoxelDetail*)&details, bufferOut, sizeOut)){
::packetsSent++;
::bytesSent += sizeOut;
if (true || ::shouldShowPacketsPerSecond) {
printf("building road sending packet of size=%d\n", sizeOut);
}
NodeList::getInstance()->broadcastToNodes(bufferOut, sizeOut, &NODE_TYPE_VOXEL_SERVER, 1);
delete[] bufferOut;
}
}
}
}
roadInitialized = true;
}
double start = 0;
@ -645,6 +701,10 @@ void* animateVoxels(void* args) {
sendDanceFloor();
}
if (::buildStreet) {
doBuildStreet();
}
uint64_t end = usecTimestampNow();
uint64_t elapsedSeconds = (end - ::start) / 1000000;
if (::shouldShowPacketsPerSecond) {
@ -688,6 +748,9 @@ int main(int argc, const char * argv[])
const char* NO_DANCE_FLOOR = "--NoDanceFloor";
::includeDanceFloor = !cmdOptionExists(argc, argv, NO_DANCE_FLOOR);
const char* BUILD_STREET = "--BuildStreet";
::buildStreet = cmdOptionExists(argc, argv, BUILD_STREET);
// Handle Local Domain testing with the --local command line
const char* showPPS = "--showPPS";
::shouldShowPacketsPerSecond = cmdOptionExists(argc, argv, showPPS);
@ -700,6 +763,11 @@ int main(int argc, const char * argv[])
nodeList->setDomainIPToLocalhost();
}
const char* domainIP = getCmdOption(argc, argv, "--domain");
if (domainIP) {
NodeList::getInstance()->setDomainIP(domainIP);
}
nodeList->linkedDataCreateCallback = NULL; // do we need a callback?
nodeList->startSilentNodeRemovalThread();

View file

@ -77,8 +77,10 @@ static char STAR_CACHE_FILE[] = "cachedStars.txt";
static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored
const glm::vec3 START_LOCATION(4.f, 0.f, 5.f); // Where one's own node begins in the world
// (will be overwritten if avatar data file is found)
// Where one's own Avatar begins in the world (will be overwritten if avatar data file is found)
// this is basically in the center of the ground plane. Slightly adjusted. This was asked for by
// Grayson as he's building a street around here for demo dinner 2
const glm::vec3 START_LOCATION(0.485f * TREE_SCALE, 0.f, 0.5f * TREE_SCALE);
const int IDLE_SIMULATE_MSECS = 16; // How often should call simulate and other stuff
// in the idle loop? (60 FPS is default)
@ -3052,7 +3054,7 @@ void Application::displaySide(Camera& whichCamera) {
glDisable(GL_FOG);
glDisable(GL_NORMALIZE);
renderGroundPlaneGrid(EDGE_SIZE_GROUND_PLANE, _audio.getCollisionSoundMagnitude());
//renderGroundPlaneGrid(EDGE_SIZE_GROUND_PLANE, _audio.getCollisionSoundMagnitude());
}
// Draw voxels
if (_renderVoxels->isChecked()) {

View file

@ -215,7 +215,6 @@ bool createVoxelEditMessage(unsigned char command, short int sequence,
bool success = true; // assume the best
int messageSize = MAXIMUM_EDIT_VOXEL_MESSAGE_SIZE; // just a guess for now
int actualMessageSize = 3;
unsigned char* messageBuffer = new unsigned char[messageSize];
int numBytesPacketHeader = populateTypeAndVersion(messageBuffer, command);
@ -223,6 +222,7 @@ bool createVoxelEditMessage(unsigned char command, short int sequence,
*sequenceAt = sequence;
unsigned char* copyAt = &messageBuffer[numBytesPacketHeader + sizeof(sequence)];
int actualMessageSize = numBytesPacketHeader + sizeof(sequence);
for (int i = 0; i < voxelCount && success; i++) {
// get the coded voxel
@ -232,7 +232,7 @@ bool createVoxelEditMessage(unsigned char command, short int sequence,
int lengthOfVoxelData = bytesRequiredForCodeLength(*voxelData)+SIZE_OF_COLOR_DATA;
// make sure we have room to copy this voxel
if (actualMessageSize+lengthOfVoxelData > MAXIMUM_EDIT_VOXEL_MESSAGE_SIZE) {
if (actualMessageSize + lengthOfVoxelData > MAXIMUM_EDIT_VOXEL_MESSAGE_SIZE) {
success = false;
} else {
// add it to our message