From be5612711be6e2d4284baf68d8989763c0b2d26b Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Wed, 17 Jul 2013 16:43:34 -0700 Subject: [PATCH 1/8] clean up of particle system --- interface/src/Application.cpp | 13 +++---------- interface/src/ParticleSystem.cpp | 13 +++++-------- interface/src/ParticleSystem.h | 16 +++++++--------- 3 files changed, 15 insertions(+), 27 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 6057ae26ed..020a4d9316 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -73,7 +73,7 @@ using namespace std; static char STAR_FILE[] = "https://s3-us-west-1.amazonaws.com/highfidelity/stars.txt"; static char STAR_CACHE_FILE[] = "cachedStars.txt"; -static const bool TESTING_PARTICLE_SYSTEM = false; +static const bool TESTING_PARTICLE_SYSTEM = true; static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored @@ -3514,19 +3514,11 @@ void Application::updateParticleSystem(float deltaTime) { glm::vec4 color(0.0f, 0.0f, 0.0f, 1.0f); glm::vec3 velocity(0.0f, 0.1f, 0.0f); float lifespan = 100000.0f; - - // determine a collision sphere - glm::vec3 collisionSpherePosition = glm::vec3( 5.0f, 0.5f, 5.0f ); - float collisionSphereRadius = 0.5f; - _particleSystem.setCollisionSphere(_coolDemoParticleEmitter, collisionSpherePosition, collisionSphereRadius); _particleSystem.emitParticlesNow(_coolDemoParticleEmitter, 1500, radius, color, velocity, lifespan); } // signal that the particle system has been initialized _particleSystemInitialized = true; - - // apply a preset color palette - _particleSystem.setOrangeBlueColorPalette(); } else { // update the particle system @@ -3547,6 +3539,7 @@ void Application::updateParticleSystem(float deltaTime) { ParticleSystem::ParticleAttributes attributes; attributes.radius = 0.01f; + attributes.color = glm::vec4( 1.0f, 1.0f, 1.0f, 1.0f); attributes.gravity = 0.0f + 0.05f * sinf( t * 0.52f ); attributes.airFriction = 2.5 + 2.0f * sinf( t * 0.32f ); attributes.jitter = 0.05f + 0.05f * sinf( t * 0.42f ); @@ -3563,7 +3556,7 @@ void Application::updateParticleSystem(float deltaTime) { attributes.gravity = 0.0f; } - _particleSystem.setParticleAttributes(_coolDemoParticleEmitter, attributes); + _particleSystem.setParticleAttributes(_coolDemoParticleEmitter, attributes); } _particleSystem.setUpDirection(glm::vec3(0.0f, 1.0f, 0.0f)); diff --git a/interface/src/ParticleSystem.cpp b/interface/src/ParticleSystem.cpp index 15343203e4..fb96492515 100644 --- a/interface/src/ParticleSystem.cpp +++ b/interface/src/ParticleSystem.cpp @@ -147,7 +147,7 @@ void ParticleSystem::killParticle(int p) { _numParticles --; } - +/* void ParticleSystem::setOrangeBlueColorPalette() { for (unsigned int p = 0; p < _numParticles; p++) { @@ -163,6 +163,7 @@ void ParticleSystem::setOrangeBlueColorPalette() { _particle[p].color = glm::vec4(red, green, blue, alpha); } } +*/ void ParticleSystem::setParticleAttributes(int emitterIndex, ParticleAttributes attributes) { @@ -201,13 +202,7 @@ void ParticleSystem::updateParticle(int p, float deltaTime) { int lifeStage = (int)( ageFraction * (NUM_PARTICLE_LIFE_STAGES-1) ); float lifeStageFraction = ageFraction * ( NUM_PARTICLE_LIFE_STAGES - 1 ) - lifeStage; - - /* - if ( p == 0 ) { - printf( "lifespan = %f ageFraction = %f lifeStage = %d lifeStageFraction = %f\n", _particle[p].lifespan, ageFraction, lifeStage, lifeStageFraction ); - } - */ - + _particle[p].radius = _emitter[_particle[p].emitterIndex].particleAttributes[lifeStage ].radius * (1.0f - lifeStageFraction) + _emitter[_particle[p].emitterIndex].particleAttributes[lifeStage+1].radius * lifeStageFraction; @@ -294,6 +289,7 @@ void ParticleSystem::updateParticle(int p, float deltaTime) { _particle[p].age += deltaTime; } +/* void ParticleSystem::setCollisionSphere(int e, glm::vec3 position, float radius) { int lifeStage = 0; @@ -302,6 +298,7 @@ void ParticleSystem::setCollisionSphere(int e, glm::vec3 position, float radius) _emitter[e].particleAttributes[lifeStage].collisionSpherePosition = position; _emitter[e].particleAttributes[lifeStage].collisionSphereRadius = radius; } +*/ void ParticleSystem::setEmitterBaseParticle(int emitterIndex, bool showing ) { diff --git a/interface/src/ParticleSystem.h b/interface/src/ParticleSystem.h index 244b791d39..9b808f746b 100644 --- a/interface/src/ParticleSystem.h +++ b/interface/src/ParticleSystem.h @@ -42,17 +42,15 @@ public: void emitParticlesNow(int emitterIndex, int numParticles, float radius, glm::vec4 color, glm::vec3 velocity, float lifespan); void simulate(float deltaTime); void render(); + + void setUpDirection(glm::vec3 upDirection) {_upDirection = upDirection;} // tell particle system which direction is up void setEmitterBaseParticle(int emitterIndex, bool showing ); void setEmitterBaseParticle(int emitterIndex, bool showing, float radius, glm::vec4 color ); - - void setOrangeBlueColorPalette(); // apply a nice preset color palette to the particles - void setUpDirection(glm::vec3 upDirection) {_upDirection = upDirection;} // tell particle system which direction is up - void setParticleAttributes(int emitterIndex, ParticleAttributes attributes); - void setParticleAttributes(int emitterIndex, int lifeStage, ParticleAttributes attributes); - void setCollisionSphere (int emitterIndex, glm::vec3 position, float radius); // specify a sphere for the particles to collide with - void setEmitterPosition (int emitterIndex, glm::vec3 position) { _emitter[emitterIndex].position = position; } // set position of emitter - void setEmitterRotation (int emitterIndex, glm::quat rotation) { _emitter[emitterIndex].rotation = rotation; } // set rotation of emitter - void setShowingEmitter (int emitterIndex, bool showing ) { _emitter[emitterIndex].visible = showing; } // set its visibiity + void setParticleAttributes (int emitterIndex, ParticleAttributes attributes); + void setParticleAttributes (int emitterIndex, int lifeStage, ParticleAttributes attributes); + void setEmitterPosition (int emitterIndex, glm::vec3 position) { _emitter[emitterIndex].position = position; } // set position of emitter + void setEmitterRotation (int emitterIndex, glm::quat rotation) { _emitter[emitterIndex].rotation = rotation; } // set rotation of emitter + void setShowingEmitter (int emitterIndex, bool showing ) { _emitter[emitterIndex].visible = showing; } // set its visibiity private: From 1264b3ce66bbf2d7c91308d1f0378261e600b448 Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Wed, 17 Jul 2013 17:00:18 -0700 Subject: [PATCH 2/8] removed deprecated code --- interface/src/ParticleSystem.cpp | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/interface/src/ParticleSystem.cpp b/interface/src/ParticleSystem.cpp index 076c8f6983..0b0b7a7389 100644 --- a/interface/src/ParticleSystem.cpp +++ b/interface/src/ParticleSystem.cpp @@ -147,24 +147,6 @@ void ParticleSystem::killParticle(int p) { _numParticles --; } -/* -void ParticleSystem::setOrangeBlueColorPalette() { - - for (unsigned int p = 0; p < _numParticles; p++) { - - float radian = ((float)p / (float)_numParticles) * PI_TIMES_TWO; - float wave = sinf(radian); - - float red = 0.5f + 0.5f * wave; - float green = 0.3f + 0.3f * wave; - float blue = 0.2f - 0.2f * wave; - float alpha = 1.0f; - - _particle[p].color = glm::vec4(red, green, blue, alpha); - } -} -*/ - void ParticleSystem::setParticleAttributes(int emitterIndex, ParticleAttributes attributes) { From 9c2ea6e7e4ebe8dea68352083e13a7335bcbb15c Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Wed, 17 Jul 2013 17:07:53 -0700 Subject: [PATCH 3/8] more clean up --- interface/src/Application.cpp | 2 +- interface/src/ParticleSystem.cpp | 11 ----------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 5814575796..c2a3faa501 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -73,7 +73,7 @@ using namespace std; static char STAR_FILE[] = "https://s3-us-west-1.amazonaws.com/highfidelity/stars.txt"; static char STAR_CACHE_FILE[] = "cachedStars.txt"; -static const bool TESTING_PARTICLE_SYSTEM = true; +static const bool TESTING_PARTICLE_SYSTEM = false; static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored diff --git a/interface/src/ParticleSystem.cpp b/interface/src/ParticleSystem.cpp index 0b0b7a7389..81ed67bf6c 100644 --- a/interface/src/ParticleSystem.cpp +++ b/interface/src/ParticleSystem.cpp @@ -271,17 +271,6 @@ void ParticleSystem::updateParticle(int p, float deltaTime) { _particle[p].age += deltaTime; } -/* -void ParticleSystem::setCollisionSphere(int e, glm::vec3 position, float radius) { - - int lifeStage = 0; - - _emitter[e].particleAttributes[lifeStage].usingCollisionSphere = true; - _emitter[e].particleAttributes[lifeStage].collisionSpherePosition = position; - _emitter[e].particleAttributes[lifeStage].collisionSphereRadius = radius; -} -*/ - void ParticleSystem::setEmitterBaseParticle(int emitterIndex, bool showing ) { _emitter[emitterIndex].baseParticle.alive = true; From f89b1fcd4c347b69770048d995b763f80c3c3139 Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Wed, 17 Jul 2013 18:10:30 -0700 Subject: [PATCH 4/8] more clean up of particle system --- interface/src/Application.cpp | 6 +- interface/src/Hand.cpp | 12 ++-- interface/src/ParticleSystem.cpp | 99 ++++++++++++++------------------ interface/src/ParticleSystem.h | 40 ++++++------- 4 files changed, 70 insertions(+), 87 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index c2a3faa501..8f14e8ed57 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -73,7 +73,7 @@ using namespace std; static char STAR_FILE[] = "https://s3-us-west-1.amazonaws.com/highfidelity/stars.txt"; static char STAR_CACHE_FILE[] = "cachedStars.txt"; -static const bool TESTING_PARTICLE_SYSTEM = false; +static const bool TESTING_PARTICLE_SYSTEM = true; static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored @@ -3510,11 +3510,9 @@ void Application::updateParticleSystem(float deltaTime) { _particleSystem.setShowingEmitter(_coolDemoParticleEmitter, true); glm::vec3 particleEmitterPosition = glm::vec3(5.0f, 1.0f, 5.0f); _particleSystem.setEmitterPosition(_coolDemoParticleEmitter, particleEmitterPosition); - float radius = 0.01f; - glm::vec4 color(0.0f, 0.0f, 0.0f, 1.0f); glm::vec3 velocity(0.0f, 0.1f, 0.0f); float lifespan = 100000.0f; - _particleSystem.emitParticlesNow(_coolDemoParticleEmitter, 1500, radius, color, velocity, lifespan); + _particleSystem.emitParticlesNow(_coolDemoParticleEmitter, 1500, velocity, lifespan); } // signal that the particle system has been initialized diff --git a/interface/src/Hand.cpp b/interface/src/Hand.cpp index bbfd58c5b1..69d8ddfaac 100755 --- a/interface/src/Hand.cpp +++ b/interface/src/Hand.cpp @@ -216,9 +216,13 @@ void Hand::updateFingerParticles(float deltaTime) { if (!_particleSystemInitialized) { for ( int f = 0; f< NUM_FINGERS_PER_HAND; f ++ ) { + + _particleSystem.setShowingEmitter(f, true ); _fingerParticleEmitter[f] = _particleSystem.addEmitter(); + assert( _fingerParticleEmitter[f] != -1 ); + ParticleSystem::ParticleAttributes attributes; // set attributes for each life stage of the particle: @@ -277,17 +281,17 @@ void Hand::updateFingerParticles(float deltaTime) { } else { fingerDirection = IDENTITY_UP; } + + glm::quat particleEmitterRotation = rotationBetween(palm.getNormal(), fingerDirection); - glm::quat particleEmitterRotation = rotationBetween(IDENTITY_UP, fingerDirection); + //glm::quat particleEmitterRotation = glm::angleAxis(0.0f, fingerDirection); _particleSystem.setEmitterPosition(_fingerParticleEmitter[f], particleEmitterPosition); _particleSystem.setEmitterRotation(_fingerParticleEmitter[f], particleEmitterRotation); - float radius = 0.005f; - const glm::vec4 color(1.0f, 0.6f, 0.0f, 0.5f); const glm::vec3 velocity = fingerDirection * 0.002f; const float lifespan = 1.0f; - _particleSystem.emitParticlesNow(_fingerParticleEmitter[f], 1, radius, color, velocity, lifespan); + _particleSystem.emitParticlesNow(_fingerParticleEmitter[f], 1, velocity, lifespan); } } } diff --git a/interface/src/ParticleSystem.cpp b/interface/src/ParticleSystem.cpp index 81ed67bf6c..9dcdbe5f06 100644 --- a/interface/src/ParticleSystem.cpp +++ b/interface/src/ParticleSystem.cpp @@ -21,36 +21,35 @@ ParticleSystem::ParticleSystem() { _numParticles = 0; _upDirection = glm::vec3(0.0f, 1.0f, 0.0f); // default - for (unsigned int e = 0; e < MAX_EMITTERS; e++) { - _emitter[e].position = glm::vec3(0.0f, 0.0f, 0.0f); - _emitter[e].rotation = glm::quat(); - _emitter[e].right = IDENTITY_RIGHT; - _emitter[e].up = IDENTITY_UP; - _emitter[e].front = IDENTITY_FRONT; - _emitter[e].visible = false; - _emitter[e].baseParticle.alive = false; - _emitter[e].baseParticle.age = 0.0f; - _emitter[e].baseParticle.lifespan = 0.0f; - _emitter[e].baseParticle.radius = 0.0f; - _emitter[e].baseParticle.emitterIndex = 0; - _emitter[e].baseParticle.position = glm::vec3(0.0f, 0.0f, 0.0f); - _emitter[e].baseParticle.velocity = glm::vec3(0.0f, 0.0f, 0.0f); - + for (unsigned int emitterIndex = 0; emitterIndex < MAX_EMITTERS; emitterIndex++) { + _emitter[emitterIndex].position = glm::vec3(0.0f, 0.0f, 0.0f); + _emitter[emitterIndex].rotation = glm::quat(); + _emitter[emitterIndex].visible = false; + _emitter[emitterIndex].baseParticle.alive = false; + _emitter[emitterIndex].baseParticle.age = 0.0f; + _emitter[emitterIndex].baseParticle.lifespan = 0.0f; + _emitter[emitterIndex].baseParticle.radius = 0.0f; + _emitter[emitterIndex].baseParticle.emitterIndex = 0; + _emitter[emitterIndex].baseParticle.position = glm::vec3(0.0f, 0.0f, 0.0f); + _emitter[emitterIndex].baseParticle.velocity = glm::vec3(0.0f, 0.0f, 0.0f); - for (int s = 0; sradius = DEFAULT_PARTICLE_RADIUS; + a->color = glm::vec4(0.0f, 0.0f, 0.0f, 0.0f); + a->bounce = DEFAULT_PARTICLE_BOUNCE; + a->airFriction = DEFAULT_PARTICLE_AIR_FRICTION; + a->gravity = 0.0f; + a->jitter = 0.0f; + a->emitterAttraction = 0.0f; + a->tornadoForce = 0.0f; + a->neighborAttraction = 0.0f; + a->neighborRepulsion = 0.0f; + a->collisionSphereRadius = 0.0f; + a->collisionSpherePosition = glm::vec3(0.0f, 0.0f, 0.0f); + a->usingCollisionSphere = false; } }; @@ -79,11 +78,6 @@ int ParticleSystem::addEmitter() { void ParticleSystem::simulate(float deltaTime) { - // update emitters - for (unsigned int e = 0; e < _numEmitters; e++) { - updateEmitter(e, deltaTime); - } - // update particles for (unsigned int p = 0; p < _numParticles; p++) { if (_particle[p].alive) { @@ -96,23 +90,14 @@ void ParticleSystem::simulate(float deltaTime) { } } - -void ParticleSystem::updateEmitter(int e, float deltaTime) { - - _emitter[e].front = _emitter[e].rotation * IDENTITY_FRONT; - _emitter[e].right = _emitter[e].rotation * IDENTITY_RIGHT; - _emitter[e].up = _emitter[e].rotation * IDENTITY_UP; -} - - -void ParticleSystem::emitParticlesNow(int e, int num, float radius, glm::vec4 color, glm::vec3 velocity, float lifespan) { +void ParticleSystem::emitParticlesNow(int e, int num, glm::vec3 velocity, float lifespan) { for (unsigned int p = 0; p < num; p++) { - createParticle(e, _emitter[e].position, velocity, radius, color, lifespan); + createParticle(e, velocity, lifespan); } } -void ParticleSystem::createParticle(int e, glm::vec3 position, glm::vec3 velocity, float radius, glm::vec4 color, float lifespan) { +void ParticleSystem::createParticle(int e, glm::vec3 velocity, float lifespan) { for (unsigned int p = 0; p < MAX_PARTICLES; p++) { if (!_particle[p].alive) { @@ -121,12 +106,10 @@ void ParticleSystem::createParticle(int e, glm::vec3 position, glm::vec3 velocit _particle[p].lifespan = lifespan; _particle[p].alive = true; _particle[p].age = 0.0f; - _particle[p].position = position; _particle[p].velocity = velocity; - _particle[p].color = color; - - _particle[p].radius = _emitter[e].particleAttributes[0].radius; - _particle[p].color = _emitter[e].particleAttributes[0].color; + _particle[p].position = _emitter[e].position; + _particle[p].radius = _emitter[e].particleAttributes[0].radius; + _particle[p].color = _emitter[e].particleAttributes[0].color; _numParticles ++; @@ -227,7 +210,11 @@ void ParticleSystem::updateParticle(int p, float deltaTime) { } // apply tornado force - glm::vec3 tornadoDirection = glm::cross(vectorToHome, myEmitter.up); + + + glm::vec3 emitterUp = myEmitter.rotation * IDENTITY_UP; + + glm::vec3 tornadoDirection = glm::cross(vectorToHome, emitterUp); _particle[p].velocity += tornadoDirection * myEmitter.particleAttributes[lifeStage].tornadoForce * deltaTime; // apply air friction @@ -363,10 +350,10 @@ void ParticleSystem::renderParticle(int p) { void ParticleSystem::renderEmitter(int e, float size) { - - glm::vec3 r = _emitter[e].right * size; - glm::vec3 u = _emitter[e].up * size; - glm::vec3 f = _emitter[e].front * size; + + glm::vec3 r = _emitter[e].rotation * IDENTITY_FRONT * size; + glm::vec3 u = _emitter[e].rotation * IDENTITY_RIGHT * size; + glm::vec3 f = _emitter[e].rotation * IDENTITY_UP * size; glLineWidth(2.0f); diff --git a/interface/src/ParticleSystem.h b/interface/src/ParticleSystem.h index 268e11abb6..764800f23e 100644 --- a/interface/src/ParticleSystem.h +++ b/interface/src/ParticleSystem.h @@ -4,7 +4,6 @@ // // Created by Jeffrey on July 10, 2013 // -// #ifndef hifi_ParticleSystem_h #define hifi_ParticleSystem_h @@ -38,15 +37,15 @@ public: ParticleSystem(); - int addEmitter(); // add (create) an emitter and get its unique id - void emitParticlesNow(int emitterIndex, int numParticles, float radius, glm::vec4 color, glm::vec3 velocity, float lifespan); + int addEmitter(); // add (create new) emitter and get its unique id + void emitParticlesNow(int emitterIndex, int numParticles, glm::vec3 velocity, float lifespan); void simulate(float deltaTime); void render(); void setUpDirection(glm::vec3 upDirection) {_upDirection = upDirection;} // tell particle system which direction is up void setEmitterBaseParticle(int emitterIndex, bool showing ); void setEmitterBaseParticle(int emitterIndex, bool showing, float radius, glm::vec4 color ); - void setParticleAttributes (int emitterIndex, ParticleAttributes attributes); + void setParticleAttributes (int emitterIndex, ParticleAttributes attributes); void setParticleAttributes (int emitterIndex, int lifeStage, ParticleAttributes attributes); void setEmitterPosition (int emitterIndex, glm::vec3 position) { _emitter[emitterIndex].position = position; } // set position of emitter void setEmitterRotation (int emitterIndex, glm::quat rotation) { _emitter[emitterIndex].rotation = rotation; } // set rotation of emitter @@ -55,38 +54,33 @@ public: private: struct Particle { - bool alive; // is the particle active? - glm::vec3 position; // position - glm::vec3 velocity; // velocity - glm::vec4 color; // color (rgba) - float age; // age in seconds - float radius; // radius - float lifespan; // how long this particle stays alive (in seconds) - int emitterIndex; // which emitter created this particle? + bool alive; // is the particle active? + glm::vec3 position; // position + glm::vec3 velocity; // velocity + glm::vec4 color; // color (rgba) + float age; // age in seconds + float radius; // radius + float lifespan; // how long this particle stays alive (in seconds) + int emitterIndex; // which emitter created this particle? }; struct Emitter { glm::vec3 position; glm::quat rotation; - glm::vec3 right; // derived from rotation - glm::vec3 up; // derived from rotation - glm::vec3 front; // derived from rotation bool visible; Particle baseParticle; // a non-physical particle at the emitter position ParticleAttributes particleAttributes[NUM_PARTICLE_LIFE_STAGES]; // the attributes of particles emitted from this emitter }; - glm::vec3 _upDirection; - Emitter _emitter[MAX_EMITTERS]; - Particle _particle[MAX_PARTICLES]; - int _numParticles; - int _numEmitters; + glm::vec3 _upDirection; + Emitter _emitter[MAX_EMITTERS]; + Particle _particle[MAX_PARTICLES]; + int _numParticles; + int _numEmitters; // private methods - void updateEmitter(int e, float deltaTime); void updateParticle(int index, float deltaTime); - void createParticle(int e, glm::vec3 position, glm::vec3 velocity, float radius, glm::vec4 color, float lifespan); - //void runSpecialEffectsTest(int e, float deltaTime); // for debugging and artistic exploration + void createParticle(int e, glm::vec3 velocity, float lifespan); void killParticle(int p); void renderEmitter(int emitterIndex, float size); void renderParticle(int p); From 1e421d222d3c13cf1ba1ddf822c9d68f124d351d Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 18 Jul 2013 10:20:01 -0700 Subject: [PATCH 5/8] cleaned up some compiler warnings and constants --- libraries/voxels/src/CoverageMap.cpp | 10 +++++----- libraries/voxels/src/VoxelConstants.h | 5 +++-- libraries/voxels/src/VoxelTree.cpp | 5 ++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libraries/voxels/src/CoverageMap.cpp b/libraries/voxels/src/CoverageMap.cpp index 31bcfb64cb..170e30f28d 100644 --- a/libraries/voxels/src/CoverageMap.cpp +++ b/libraries/voxels/src/CoverageMap.cpp @@ -430,7 +430,7 @@ bool CoverageRegion::mergeItemsInArray(VoxelProjectedPolygon* seed, bool seedInA otherPolygon->merge(*seed); if (seedInArray) { - const int IGNORED = NULL; + int* IGNORED = NULL; // remove this otherOtherPolygon for our polygon array _polygonCount = removeFromSortedArrays((void*)seed, (void**)_polygons, _polygonDistances, IGNORED, @@ -479,7 +479,7 @@ void CoverageRegion::storeInArray(VoxelProjectedPolygon* polygon) { // in the list. We still check to see if the polygon is "in front" of the target polygon before we test occlusion. Since // sometimes things come out of order. const bool SORT_BY_SIZE = false; - const int IGNORED = NULL; + int IGNORED = 0; if (SORT_BY_SIZE) { // This old code assumes that polygons will always be added in z-buffer order, but that doesn't seem to // be a good assumption. So instead, we will need to sort this by distance. Use a binary search to find the @@ -488,12 +488,12 @@ void CoverageRegion::storeInArray(VoxelProjectedPolygon* polygon) { float reverseArea = 4.0f - area; //qDebug("store by size area=%f reverse area=%f\n", area, reverseArea); _polygonCount = insertIntoSortedArrays((void*)polygon, reverseArea, IGNORED, - (void**)_polygons, _polygonSizes, IGNORED, + (void**)_polygons, _polygonSizes, &IGNORED, _polygonCount, _polygonArraySize); } else { - const int IGNORED = NULL; + int IGNORED = 0; _polygonCount = insertIntoSortedArrays((void*)polygon, polygon->getDistance(), IGNORED, - (void**)_polygons, _polygonDistances, IGNORED, + (void**)_polygons, _polygonDistances, &IGNORED, _polygonCount, _polygonArraySize); } diff --git a/libraries/voxels/src/VoxelConstants.h b/libraries/voxels/src/VoxelConstants.h index 452772ff07..55dff0c69a 100644 --- a/libraries/voxels/src/VoxelConstants.h +++ b/libraries/voxels/src/VoxelConstants.h @@ -23,7 +23,8 @@ const glm::vec3 IDENTITY_FRONT = glm::vec3( 0.0f, 0.0f,-1.0f); const bool LOW_RES_MONO = false; // while in "low res mode" do voxels switch to monochrome const uint64_t CHANGE_FUDGE = 1000 * 200; // useconds of fudge in determining if we want to resend changed voxels -const int TREE_SCALE = 128; +const int TREE_SCALE = 128; // This is the number of meters of the 0.0 to 1.0 voxel universe +const float VOXEL_SIZE_SCALE = 50000.0f; // This controls the LOD bigger will make smaller voxels visible at greater distance const int NUMBER_OF_CHILDREN = 8; const int MAX_VOXEL_PACKET_SIZE = 1492; @@ -40,4 +41,4 @@ const glBufferIndex GLBUFFER_INDEX_UNKNOWN = ULONG_MAX; const float SIXTY_FPS_IN_MILLISECONDS = 1000.0f / 60.0f; const float VIEW_CULLING_RATE_IN_MILLISECONDS = 1000.0f; // once a second is fine -#endif +#endif \ No newline at end of file diff --git a/libraries/voxels/src/VoxelTree.cpp b/libraries/voxels/src/VoxelTree.cpp index 203ed7e908..9cb6a85f93 100644 --- a/libraries/voxels/src/VoxelTree.cpp +++ b/libraries/voxels/src/VoxelTree.cpp @@ -32,12 +32,11 @@ #include "VoxelTree.h" float boundaryDistanceForRenderLevel(unsigned int renderLevel) { - const float voxelSizeScale = 50000.0f; - return voxelSizeScale / powf(2, renderLevel); + return ::VOXEL_SIZE_SCALE / powf(2, renderLevel); } float boundaryDistanceSquaredForRenderLevel(unsigned int renderLevel) { - const float voxelSizeScale = (50000.0f/TREE_SCALE) * (50000.0f/TREE_SCALE); + const float voxelSizeScale = (::VOXEL_SIZE_SCALE/TREE_SCALE) * (::VOXEL_SIZE_SCALE/TREE_SCALE); return voxelSizeScale / powf(2, (2 * renderLevel)); } From 2ad99f3129becd8f51319ceb5e9e280fbf44502d Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 18 Jul 2013 10:26:08 -0700 Subject: [PATCH 6/8] point to stars file on non-SSL for easier RV redirect --- interface/src/Application.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index d6e3c1a89f..7b0694695b 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -70,7 +70,7 @@ using namespace std; // Starfield information -static char STAR_FILE[] = "https://s3-us-west-1.amazonaws.com/highfidelity/stars.txt"; +static char STAR_FILE[] = "http://s3-us-west-1.amazonaws.com/highfidelity/stars.txt"; static char STAR_CACHE_FILE[] = "cachedStars.txt"; static const bool TESTING_PARTICLE_SYSTEM = false; From b3b8ef33478883c8e6a034859b4324d9e6f9b534 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Thu, 18 Jul 2013 11:24:39 -0700 Subject: [PATCH 7/8] Gyros don't move view for small head movements --- interface/src/Head.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index 84ae9fffe9..a477910d67 100644 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -226,9 +226,9 @@ void Head::simulate(float deltaTime, bool isMine) { const float CAMERA_FOLLOW_HEAD_RATE_START = 0.01f; const float CAMERA_FOLLOW_HEAD_RATE_MAX = 0.5f; const float CAMERA_FOLLOW_HEAD_RATE_RAMP_RATE = 1.05f; - const float CAMERA_STOP_TOLERANCE_DEGREES = 0.1f; - const float CAMERA_PITCH_START_TOLERANCE_DEGREES = 10.0f; - const float CAMERA_YAW_START_TOLERANCE_DEGREES = 3.0f; + const float CAMERA_STOP_TOLERANCE_DEGREES = 0.5f; + const float CAMERA_PITCH_START_TOLERANCE_DEGREES = 20.0f; + const float CAMERA_YAW_START_TOLERANCE_DEGREES = 10.0f; float cameraHeadAngleDifference = glm::length(glm::vec2(_pitch - _cameraPitch, _yaw - _cameraYaw)); if (_isCameraMoving) { _cameraFollowHeadRate = glm::clamp(_cameraFollowHeadRate * CAMERA_FOLLOW_HEAD_RATE_RAMP_RATE, From c41f5e27ef9d686836375efba626d3899b0d9f4d Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 18 Jul 2013 11:25:01 -0700 Subject: [PATCH 8/8] fixed crash --- libraries/voxels/src/CoverageMap.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/voxels/src/CoverageMap.cpp b/libraries/voxels/src/CoverageMap.cpp index 170e30f28d..634c67a71c 100644 --- a/libraries/voxels/src/CoverageMap.cpp +++ b/libraries/voxels/src/CoverageMap.cpp @@ -430,10 +430,10 @@ bool CoverageRegion::mergeItemsInArray(VoxelProjectedPolygon* seed, bool seedInA otherPolygon->merge(*seed); if (seedInArray) { - int* IGNORED = NULL; + int* IGNORED_ADDRESS = NULL; // remove this otherOtherPolygon for our polygon array _polygonCount = removeFromSortedArrays((void*)seed, - (void**)_polygons, _polygonDistances, IGNORED, + (void**)_polygons, _polygonDistances, IGNORED_ADDRESS, _polygonCount, _polygonArraySize); _totalPolygons--; } @@ -479,7 +479,8 @@ void CoverageRegion::storeInArray(VoxelProjectedPolygon* polygon) { // in the list. We still check to see if the polygon is "in front" of the target polygon before we test occlusion. Since // sometimes things come out of order. const bool SORT_BY_SIZE = false; - int IGNORED = 0; + const int IGNORED = 0; + int* IGNORED_ADDRESS = NULL; if (SORT_BY_SIZE) { // This old code assumes that polygons will always be added in z-buffer order, but that doesn't seem to // be a good assumption. So instead, we will need to sort this by distance. Use a binary search to find the @@ -488,12 +489,11 @@ void CoverageRegion::storeInArray(VoxelProjectedPolygon* polygon) { float reverseArea = 4.0f - area; //qDebug("store by size area=%f reverse area=%f\n", area, reverseArea); _polygonCount = insertIntoSortedArrays((void*)polygon, reverseArea, IGNORED, - (void**)_polygons, _polygonSizes, &IGNORED, + (void**)_polygons, _polygonSizes, IGNORED_ADDRESS, _polygonCount, _polygonArraySize); } else { - int IGNORED = 0; _polygonCount = insertIntoSortedArrays((void*)polygon, polygon->getDistance(), IGNORED, - (void**)_polygons, _polygonDistances, &IGNORED, + (void**)_polygons, _polygonDistances, IGNORED_ADDRESS, _polygonCount, _polygonArraySize); }