mirror of
https://github.com/godotengine/godot.git
synced 2025-01-05 09:40:33 +00:00
Added gravity vector back into the accelerometer data and flipped Z on the gyro
This commit is contained in:
parent
51c60f7a49
commit
ee98e06952
@ -203,8 +203,11 @@ static int frame_count = 0;
|
||||
// Just using polling approach for now, we can set this up so it sends data to us in intervals, might be better.
|
||||
// See Apple reference pages for more details:
|
||||
// https://developer.apple.com/reference/coremotion/cmmotionmanager?language=objc
|
||||
|
||||
// Apple splits our accelerometer date into a gravity and user movement component. We add them back together
|
||||
CMAcceleration gravity = motionManager.deviceMotion.gravity;
|
||||
CMAcceleration acceleration = motionManager.deviceMotion.userAcceleration;
|
||||
OSIPhone::get_singleton()->update_accelerometer(acceleration.x, acceleration.y, acceleration.z);
|
||||
OSIPhone::get_singleton()->update_accelerometer(acceleration.x + gravity.x, acceleration.y + gravity.y, acceleration.z + gravity.z);
|
||||
|
||||
CMMagneticField magnetic = motionManager.deviceMotion.magneticField.field;
|
||||
OSIPhone::get_singleton()->update_magnetometer(magnetic.x, magnetic.y, magnetic.z);
|
||||
|
@ -371,8 +371,7 @@ void OSIPhone::update_magnetometer(float p_x, float p_y, float p_z) {
|
||||
};
|
||||
|
||||
void OSIPhone::update_gyroscope(float p_x, float p_y, float p_z) {
|
||||
///@TODO I've made the Z negative like the original accelerometer code, this probably needs more work
|
||||
input->set_gyroscope(Vector3(p_x, p_y, -p_z));
|
||||
input->set_gyroscope(Vector3(p_x, p_y, p_z));
|
||||
};
|
||||
|
||||
void OSIPhone::delete_main_loop() {
|
||||
|
Loading…
Reference in New Issue
Block a user