Showing the changes to interface/src/main.cpp (1 of 16 files). Show all
Unified · Split
| @@ -204,8 +204,7 @@ bool justStarted = true; · 203 unmodified lines | ||
| 204 | 204 | |
| 205 | 205 | |
| 206 | 206 | // Every second, check the frame rates and other stuff |
| 207 | −void Timer(int extra) | |
| 208 | −{ | |
| 207 | +void Timer(int extra) { | |
| 209 | 208 | gettimeofday(&timerEnd, NULL); |
| 210 | 209 | FPS = (float)frameCount / ((float)diffclock(&timerStart, &timerEnd) / 1000.f); |
| 211 | 210 | packetsPerSecond = (float)packetCount / ((float)diffclock(&timerStart, &timerEnd) / 1000.f); |
| @@ -223,8 +222,7 @@ void Timer(int extra) · 11 unmodified lines | ||
| 223 | 222 | } |
| 224 | 223 | } |
| 225 | 224 | |
| 226 | −void displayStats(void) | |
| 227 | −{ | |
| 225 | +void displayStats(void) { | |
| 228 | 226 | int statsVerticalOffset = 50; |
| 229 | 227 | if (::menuOn == 0) { |
| 230 | 228 | statsVerticalOffset = 8; |
| @@ -265,6 +263,7 @@ void displayStats(void) · 34 unmodified lines | ||
| 265 | 263 | |
| 266 | 264 | Agent *avatarMixer = AgentList::getInstance()->soloAgentOfType(AGENT_TYPE_AVATAR_MIXER); |
| 267 | 265 | char avatarMixerStats[200]; |
| 266 | + | |
| 268 | 267 | if (avatarMixer) { |
| 269 | 268 | sprintf(avatarMixerStats, "Avatar Mixer: %.f kbps, %.f pps", |
| 270 | 269 | roundf(avatarMixer->getAverageKilobitsPerSecond()), |
| @@ -272,6 +271,7 @@ void displayStats(void) · 1 unmodified line | ||
| 272 | 271 | } else { |
| 273 | 272 | sprintf(avatarMixerStats, "No Avatar Mixer"); |
| 274 | 273 | } |
| 274 | + | |
| 275 | 275 | drawtext(10, statsVerticalOffset + 330, 0.10f, 0, 1.0, 0, avatarMixerStats); |
| 276 | 276 | |
| 277 | 277 | if (::perfStatsOn) { |
| @@ -289,8 +289,7 @@ void displayStats(void) · 11 unmodified lines | ||
| 289 | 289 | } |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | −void initDisplay(void) | |
| 293 | −{ | |
| 292 | +void initDisplay(void) { | |
| 294 | 293 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
| 295 | 294 | glEnable(GL_BLEND); |
| 296 | 295 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| @@ -302,8 +301,7 @@ void initDisplay(void) · 5 unmodified lines | ||
| 302 | 301 | if (fullscreen) glutFullScreen(); |
| 303 | 302 | } |
| 304 | 303 | |
| 305 | −void init(void) | |
| 306 | −{ | |
| 304 | +void init(void) { | |
| 307 | 305 | voxels.init(); |
| 308 | 306 | voxels.setViewerAvatar(&myAvatar); |
| 309 | 307 | voxels.setCamera(&myCamera); |
| @@ -356,8 +354,7 @@ void terminate () { · 46 unmodified lines | ||
| 356 | 354 | exit(EXIT_SUCCESS); |
| 357 | 355 | } |
| 358 | 356 | |
| 359 | −void reset_sensors() | |
| 360 | −{ | |
| 357 | +void reset_sensors() { | |
| 361 | 358 | |
| 362 | 359 | myAvatar.setPosition(start_location); |
| 363 | 360 | headMouseX = WIDTH/2; |
| @@ -373,16 +370,13 @@ void reset_sensors() · 9 unmodified lines | ||
| 373 | 370 | // |
| 374 | 371 | // Using gyro data, update both view frustum and avatar head position |
| 375 | 372 | // |
| 376 | −void updateAvatar(float frametime) | |
| 377 | −{ | |
| 373 | +void updateAvatar(float frametime) { | |
| 378 | 374 | float gyroPitchRate = serialPort.getRelativeValue(HEAD_PITCH_RATE); |
| 379 | 375 | float gyroYawRate = serialPort.getRelativeValue(HEAD_YAW_RATE ); |
| 380 | 376 | |
| 381 | 377 | myAvatar.UpdateGyros(frametime, &serialPort, &gravity); |
| 382 | 378 | |
| 383 | − // | |
| 384 | 379 | // Update gyro-based mouse (X,Y on screen) |
| 385 | − // | |
| 386 | 380 | const float MIN_MOUSE_RATE = 30.0; |
| 387 | 381 | const float MOUSE_SENSITIVITY = 0.1f; |
| 388 | 382 | if (powf(gyroYawRate*gyroYawRate + |
| @@ -397,7 +391,7 @@ void updateAvatar(float frametime) · 8 unmodified lines | ||
| 397 | 391 | headMouseY = min(headMouseY, HEIGHT); |
| 398 | 392 | |
| 399 | 393 | // Update head and body pitch and yaw based on measured gyro rates |
| 400 | − if (::gyroLook) { | |
| 394 | + if (::gyroLook) { | |
| 401 | 395 | // Yaw |
| 402 | 396 | const float MIN_YAW_RATE = 50; |
| 403 | 397 | const float YAW_SENSITIVITY = 1.0; |
| @@ -1686,6 +1680,10 @@ void idle(void) { · 1282 unmodified lines | ||
| 1686 | 1680 | handControl.stop(); |
| 1687 | 1681 | } |
| 1688 | 1682 | |
| 1683 | + if (serialPort.active && USING_INVENSENSE_MPU9150) { | |
| 1684 | + serialPort.readData(); | |
| 1685 | + } | |
| 1686 | + | |
| 1689 | 1687 | // Sample hardware, update view frustum if needed, Lsend avatar data to mixer/agents |
| 1690 | 1688 | updateAvatar(deltaTime); |
| 1691 | 1689 | |
| @@ -1712,7 +1710,7 @@ void idle(void) { · 20 unmodified lines | ||
| 1712 | 1710 | } |
| 1713 | 1711 | |
| 1714 | 1712 | // Read serial data |
| 1715 | − if (serialPort.active) { | |
| 1713 | + if (serialPort.active && !USING_INVENSENSE_MPU9150) { | |
| 1716 | 1714 | serialPort.readData(); |
| 1717 | 1715 | } |
| 1718 | 1716 | } |