mirror of
https://github.com/overte-org/overte.git
synced 2025-04-16 00:41:16 +02:00
Merge branch 'master' of https://github.com/worklist/hifi into render_voxels_optimization
This commit is contained in:
commit
5cfbcc5caa
7 changed files with 98 additions and 38 deletions
|
@ -111,7 +111,8 @@ int audioCallback (const void *inputBuffer,
|
|||
|
||||
int16_t *inputLeft = ((int16_t **) inputBuffer)[0];
|
||||
|
||||
// printLog("Audio callback at %6.0f\n", usecTimestampNow()/1000);
|
||||
// Add Procedural effects to input samples
|
||||
data->addProceduralSounds(inputLeft, BUFFER_LENGTH_SAMPLES);
|
||||
|
||||
if (inputLeft != NULL) {
|
||||
|
||||
|
|
|
@ -30,6 +30,9 @@ public:
|
|||
|
||||
void setWalkingState(bool newWalkState);
|
||||
|
||||
void setLastAcceleration(glm::vec3 a) { audioData->setLastAcceleration(a); };
|
||||
void setLastVelocity(glm::vec3 v) { audioData->setLastVelocity(v); };
|
||||
|
||||
// terminates audio I/O
|
||||
bool terminate();
|
||||
private:
|
||||
|
|
|
@ -28,4 +28,20 @@ AudioData::~AudioData() {
|
|||
delete audioSocket;
|
||||
}
|
||||
|
||||
// Take a pointer to the acquired microphone input samples and add procedural sounds
|
||||
void AudioData::addProceduralSounds(int16_t* inputBuffer, int numSamples) {
|
||||
const float MAX_AUDIBLE_VELOCITY = 3.0;
|
||||
const float MIN_AUDIBLE_VELOCITY = 0.1;
|
||||
const float VOLUME = 200;
|
||||
float speed = glm::length(_lastVelocity);
|
||||
if ((speed > MIN_AUDIBLE_VELOCITY) && (speed < MAX_AUDIBLE_VELOCITY)) {
|
||||
for (int i = 0; i < numSamples; i++) {
|
||||
inputBuffer[i] += (int16_t) ((randFloat() - 0.5f) * VOLUME * speed) ;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -39,6 +39,17 @@ class AudioData {
|
|||
|
||||
bool mixerLoopbackFlag;
|
||||
bool playWalkSound;
|
||||
|
||||
// Added avatar acceleration and velocity for procedural effects sounds from client
|
||||
void setLastVelocity(glm::vec3 v) { _lastVelocity = v; };
|
||||
void setLastAcceleration(glm::vec3 a) { _lastAcceleration = a; };
|
||||
void addProceduralSounds(int16_t* inputBuffer, int numSamples);
|
||||
|
||||
private:
|
||||
glm::vec3 _lastVelocity;
|
||||
glm::vec3 _lastAcceleration;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif /* defined(__interface__AudioData__) */
|
||||
|
|
|
@ -105,6 +105,7 @@ public:
|
|||
const glm::vec3& getJointPosition(AvatarJointID j) const { return _joint[j].position; };
|
||||
const glm::vec3& getBodyUpDirection() const { return _orientation.getUp(); };
|
||||
float getSpeed() const { return _speed; };
|
||||
const glm::vec3& getVelocity() const { return _velocity; };
|
||||
float getGirth();
|
||||
float getHeight();
|
||||
|
||||
|
|
|
@ -120,8 +120,6 @@ char starFile[] = "https://s3-us-west-1.amazonaws.com/highfidelity/stars.txt";
|
|||
char starCacheFile[] = "cachedStars.txt";
|
||||
Stars stars;
|
||||
|
||||
bool showingVoxels = true;
|
||||
|
||||
glm::vec3 box(WORLD_SIZE,WORLD_SIZE,WORLD_SIZE);
|
||||
|
||||
VoxelSystem voxels;
|
||||
|
@ -136,16 +134,18 @@ Audio audio(&audioScope, &myAvatar);
|
|||
#endif
|
||||
|
||||
#define IDLE_SIMULATE_MSECS 16 // How often should call simulate and other stuff
|
||||
// in the idle loop?
|
||||
// in the idle loop? (60 FPS is default)
|
||||
|
||||
// Where one's own agent begins in the world (needs to become a dynamic thing passed to the program)
|
||||
glm::vec3 start_location(6.1f, 0, 1.4f);
|
||||
|
||||
glm::vec3 start_location(6.1f, 0, 1.4f); // Where one's own agent begins in the world
|
||||
// (will be overwritten if avatar data file is found)
|
||||
|
||||
bool renderWarningsOn = false; // Whether to show render pipeline warnings
|
||||
|
||||
bool statsOn = false; // Whether to show onscreen text overlay with stats
|
||||
bool starsOn = false; // Whether to display the stars
|
||||
bool atmosphereOn = true; // Whether to display the atmosphere
|
||||
bool renderStatsOn = false; // Whether to show onscreen text overlay with stats
|
||||
bool renderVoxels = true; // Whether to render voxels
|
||||
bool renderStarsOn = true; // Whether to display the stars
|
||||
bool renderAtmosphereOn = true; // Whether to display the atmosphere
|
||||
bool renderAvatarsOn = true; // Whether to render avatars
|
||||
bool paintOn = false; // Whether to paint voxels as you fly around
|
||||
VoxelDetail paintingVoxel; // The voxel we're painting if we're painting
|
||||
unsigned char dominantColor = 0; // The dominant color of the voxel we're painting
|
||||
|
@ -683,12 +683,12 @@ void renderViewFrustum(ViewFrustum& viewFrustum) {
|
|||
void displaySide(Camera& whichCamera) {
|
||||
glPushMatrix();
|
||||
|
||||
if (::starsOn) {
|
||||
if (::renderStarsOn) {
|
||||
// should be the first rendering pass - w/o depth buffer / lighting
|
||||
|
||||
// compute starfield alpha based on distance from atmosphere
|
||||
float alpha = 1.0f;
|
||||
if (::atmosphereOn) {
|
||||
if (::renderAtmosphereOn) {
|
||||
float height = glm::distance(whichCamera.getPosition(), environment.getAtmosphereCenter());
|
||||
if (height < environment.getAtmosphereInnerRadius()) {
|
||||
alpha = 0.0f;
|
||||
|
@ -704,7 +704,7 @@ void displaySide(Camera& whichCamera) {
|
|||
}
|
||||
|
||||
// draw the sky dome
|
||||
if (::atmosphereOn) {
|
||||
if (::renderAtmosphereOn) {
|
||||
environment.renderAtmosphere(whichCamera);
|
||||
}
|
||||
|
||||
|
@ -722,29 +722,31 @@ void displaySide(Camera& whichCamera) {
|
|||
drawGroundPlaneGrid(10.f);
|
||||
|
||||
// Draw voxels
|
||||
if (showingVoxels) {
|
||||
if (renderVoxels) {
|
||||
voxels.render();
|
||||
}
|
||||
|
||||
// Render avatars of other agents
|
||||
AgentList* agentList = AgentList::getInstance();
|
||||
agentList->lock();
|
||||
for (AgentList::iterator agent = agentList->begin(); agent != agentList->end(); agent++) {
|
||||
if (agent->getLinkedData() != NULL && agent->getType() == AGENT_TYPE_AVATAR) {
|
||||
Avatar *avatar = (Avatar *)agent->getLinkedData();
|
||||
avatar->render(0, ::myCamera.getPosition());
|
||||
if (::renderAvatarsOn) {
|
||||
// Render avatars of other agents
|
||||
AgentList* agentList = AgentList::getInstance();
|
||||
agentList->lock();
|
||||
for (AgentList::iterator agent = agentList->begin(); agent != agentList->end(); agent++) {
|
||||
if (agent->getLinkedData() != NULL && agent->getType() == AGENT_TYPE_AVATAR) {
|
||||
Avatar *avatar = (Avatar *)agent->getLinkedData();
|
||||
avatar->render(0, ::myCamera.getPosition());
|
||||
}
|
||||
}
|
||||
agentList->unlock();
|
||||
|
||||
// Render my own Avatar
|
||||
myAvatar.render(::lookingInMirror, ::myCamera.getPosition());
|
||||
}
|
||||
agentList->unlock();
|
||||
|
||||
// Render the world box
|
||||
if (!::lookingInMirror && ::statsOn) { render_world_box(); }
|
||||
if (!::lookingInMirror && ::renderStatsOn) { render_world_box(); }
|
||||
|
||||
// brad's frustum for debugging
|
||||
if (::frustumOn) renderViewFrustum(::viewFrustum);
|
||||
|
||||
//Render my own avatar
|
||||
myAvatar.render(::lookingInMirror, ::myCamera.getPosition());
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
@ -915,7 +917,7 @@ void displayOverlay() {
|
|||
|
||||
//noiseTest(WIDTH, HEIGHT);
|
||||
|
||||
if (displayHeadMouse && !::lookingInMirror && statsOn) {
|
||||
if (displayHeadMouse && !::lookingInMirror && renderStatsOn) {
|
||||
// Display small target box at center or head mouse target that can also be used to measure LOD
|
||||
glColor3f(1.0, 1.0, 1.0);
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
|
@ -937,7 +939,7 @@ void displayOverlay() {
|
|||
glLineWidth(1.0f);
|
||||
glPointSize(1.0f);
|
||||
|
||||
if (::statsOn) { displayStats(); }
|
||||
if (::renderStatsOn) { displayStats(); }
|
||||
if (::logOn) { logger.render(WIDTH, HEIGHT); }
|
||||
|
||||
// Show menu
|
||||
|
@ -1222,17 +1224,23 @@ int setFullscreen(int state) {
|
|||
}
|
||||
|
||||
int setVoxels(int state) {
|
||||
return setValue(state, &::showingVoxels);
|
||||
return setValue(state, &::renderVoxels);
|
||||
}
|
||||
|
||||
int setStars(int state) {
|
||||
return setValue(state, &::starsOn);
|
||||
return setValue(state, &::renderStarsOn);
|
||||
}
|
||||
|
||||
int setAtmosphere(int state) {
|
||||
return setValue(state, &::atmosphereOn);
|
||||
return setValue(state, &::renderAtmosphereOn);
|
||||
}
|
||||
|
||||
int setRenderAvatars(int state) {
|
||||
return setValue(state, &::renderAvatarsOn);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int setOculus(int state) {
|
||||
bool wasOn = ::oculusOn;
|
||||
int value = setValue(state, &::oculusOn);
|
||||
|
@ -1243,7 +1251,7 @@ int setOculus(int state) {
|
|||
}
|
||||
|
||||
int setStats(int state) {
|
||||
return setValue(state, &::statsOn);
|
||||
return setValue(state, &::renderStatsOn);
|
||||
}
|
||||
|
||||
int setMenu(int state) {
|
||||
|
@ -1379,6 +1387,7 @@ void initMenu() {
|
|||
menuColumnRender->addRow("Voxels (V)", setVoxels);
|
||||
menuColumnRender->addRow("Stars (*)", setStars);
|
||||
menuColumnRender->addRow("Atmosphere (A)", setAtmosphere);
|
||||
menuColumnRender->addRow("Avatars", setRenderAvatars);
|
||||
menuColumnRender->addRow("Oculus (o)", setOculus);
|
||||
|
||||
// Tools
|
||||
|
@ -1541,10 +1550,10 @@ void key(unsigned char k, int x, int y) {
|
|||
|
||||
// Process keypresses
|
||||
if (k == 'q' || k == 'Q') ::terminate();
|
||||
if (k == '/') ::statsOn = !::statsOn; // toggle stats
|
||||
if (k == '*') ::starsOn = !::starsOn; // toggle stars
|
||||
if (k == 'V' || k == 'v') ::showingVoxels = !::showingVoxels; // toggle voxels
|
||||
if (k == 'A') ::atmosphereOn = !::atmosphereOn;
|
||||
if (k == '/') ::renderStatsOn = !::renderStatsOn; // toggle stats
|
||||
if (k == '*') ::renderStarsOn = !::renderStarsOn; // toggle stars
|
||||
if (k == 'V' || k == 'v') ::renderVoxels = !::renderVoxels; // toggle voxels
|
||||
if (k == 'A') ::renderAtmosphereOn = !::renderAtmosphereOn;
|
||||
if (k == 'F') ::frustumOn = !::frustumOn; // toggle view frustum debugging
|
||||
if (k == 'C') ::cameraFrustum = !::cameraFrustum; // toggle which frustum to look at
|
||||
if (k == 'O' || k == 'G') setFrustumOffset(MENU_ROW_PICKED); // toggle view frustum offset debugging
|
||||
|
@ -1686,6 +1695,7 @@ void idle(void) {
|
|||
handControl.stop();
|
||||
}
|
||||
|
||||
// Read serial port interface devices
|
||||
if (serialPort.active && USING_INVENSENSE_MPU9150) {
|
||||
serialPort.readData();
|
||||
}
|
||||
|
@ -1711,7 +1721,11 @@ void idle(void) {
|
|||
|
||||
myAvatar.setGravity(getGravity(myAvatar.getPosition()));
|
||||
myAvatar.simulate(deltaTime);
|
||||
|
||||
|
||||
// Update audio stats for procedural sounds
|
||||
audio.setLastAcceleration(myAvatar.getThrust());
|
||||
audio.setLastVelocity(myAvatar.getVelocity());
|
||||
|
||||
glutPostRedisplay();
|
||||
lastTimeIdle = check;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,21 @@
|
|||
|
||||
VoxelTree myTree;
|
||||
|
||||
void voxelTutorial(VoxelTree* tree) {
|
||||
int _nodeCount=0;
|
||||
bool countVoxelsOperation(VoxelNode* node, void* extraData) {
|
||||
if (node->isColored()){
|
||||
_nodeCount++;
|
||||
}
|
||||
return true; // keep going
|
||||
}
|
||||
|
||||
void addLandscape(VoxelTree * tree) {
|
||||
printf("Adding Landscape...\n");
|
||||
}
|
||||
|
||||
void addScene(VoxelTree * tree) {
|
||||
printf("adding scene...\n");
|
||||
|
||||
// We want our corner voxels to be about 1/2 meter high, and our TREE_SCALE is in meters, so...
|
||||
float voxelSize = 0.5f / TREE_SCALE;
|
||||
|
||||
|
|
Loading…
Reference in a new issue