mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 12:53:03 +02:00
Improved mouse look behavior to be smoother, removed transmitter debug.
This commit is contained in:
parent
cf7946abf0
commit
b1e3a0984b
3 changed files with 10 additions and 19 deletions
|
@ -1206,7 +1206,7 @@ void Application::initMenu() {
|
|||
(_gyroLook = optionsMenu->addAction("Gyro Look"))->setCheckable(true);
|
||||
_gyroLook->setChecked(false);
|
||||
(_mouseLook = optionsMenu->addAction("Mouse Look"))->setCheckable(true);
|
||||
_mouseLook->setChecked(false);
|
||||
_mouseLook->setChecked(true);
|
||||
(_showHeadMouse = optionsMenu->addAction("Head Mouse"))->setCheckable(true);
|
||||
_showHeadMouse->setChecked(false);
|
||||
(_transmitterDrives = optionsMenu->addAction("Transmitter Drive"))->setCheckable(true);
|
||||
|
|
|
@ -317,30 +317,23 @@ glm::quat Avatar::getWorldAlignedOrientation () const {
|
|||
|
||||
void Avatar::updateFromMouse(int mouseX, int mouseY, int screenWidth, int screenHeight) {
|
||||
// Update head yaw and pitch based on mouse input
|
||||
const float MOUSE_MOVE_RADIUS = 0.3f;
|
||||
const float MOUSE_ROTATE_SPEED = 4.0f;
|
||||
const float MOUSE_PITCH_SPEED = 2.0f;
|
||||
const float MOUSE_ROTATE_SPEED = 0.01f;
|
||||
const float MOUSE_PITCH_SPEED = 0.02f;
|
||||
const int TITLE_BAR_HEIGHT = 46;
|
||||
float mouseLocationX = (float)mouseX / (float)screenWidth - 0.5f;
|
||||
float mouseLocationY = (float)mouseY / (float)screenHeight - 0.5f;
|
||||
|
||||
if ((mouseX > 1) && (mouseX < screenWidth) && (mouseY > TITLE_BAR_HEIGHT) && (mouseY < screenHeight)) {
|
||||
//
|
||||
// Mouse must be inside screen (not at edge) and not on title bar for movement to happen
|
||||
//
|
||||
if (mouseLocationX > MOUSE_MOVE_RADIUS) {
|
||||
_head.addYaw(-(mouseLocationX - MOUSE_MOVE_RADIUS) / (0.5f - MOUSE_MOVE_RADIUS) * MOUSE_ROTATE_SPEED);
|
||||
} else if (mouseLocationX < -MOUSE_MOVE_RADIUS) {
|
||||
_head.addYaw(-(mouseLocationX + MOUSE_MOVE_RADIUS) / (0.5f - MOUSE_MOVE_RADIUS) * MOUSE_ROTATE_SPEED);
|
||||
}
|
||||
|
||||
if (mouseLocationY > MOUSE_MOVE_RADIUS) {
|
||||
_head.addPitch(-(mouseLocationY - MOUSE_MOVE_RADIUS) / (0.5f - MOUSE_MOVE_RADIUS) * MOUSE_PITCH_SPEED);
|
||||
} else if (mouseLocationY < -MOUSE_MOVE_RADIUS) {
|
||||
_head.addPitch(-(mouseLocationY + MOUSE_MOVE_RADIUS) / (0.5f - MOUSE_MOVE_RADIUS) * MOUSE_PITCH_SPEED);
|
||||
int pixelMoveThreshold = screenWidth / 6;
|
||||
glm::vec2 mouseVector(mouseX - (screenWidth / 2), mouseY - (screenHeight / 2));
|
||||
if (glm::length(mouseVector) > pixelMoveThreshold) {
|
||||
mouseVector -= glm::normalize(mouseVector) * (float) pixelMoveThreshold;
|
||||
_head.addYaw(-mouseVector.x * MOUSE_ROTATE_SPEED);
|
||||
_head.addPitch(-mouseVector.y * MOUSE_PITCH_SPEED);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
||||
|
|
|
@ -70,9 +70,7 @@ void Transmitter::processIncomingData(unsigned char* packetData, int numBytes) {
|
|||
|
||||
// Update estimated absolute position from rotation rates
|
||||
_estimatedRotation += _lastRotationRate * DELTA_TIME;
|
||||
|
||||
printf("The accel %f, %f, %f\n", _lastAcceleration.x, _lastAcceleration.y, _lastAcceleration.z);
|
||||
|
||||
|
||||
// Sensor Fusion! Slowly adjust estimated rotation to be relative to gravity (average acceleration)
|
||||
const float GRAVITY_FOLLOW_RATE = 1.f;
|
||||
float rollAngle = angleBetween(glm::vec3(_lastAcceleration.x, _lastAcceleration.y, 0.f), glm::vec3(0,-1,0)) *
|
||||
|
|
Loading…
Reference in a new issue