mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 20:13:40 +02:00
Attempt to add acceleration curve.
This commit is contained in:
parent
a1c24516c2
commit
9ea476ea89
4 changed files with 493 additions and 270 deletions
|
@ -332,7 +332,7 @@ Item {
|
|||
anchors.fill: stackView
|
||||
id: controllerPrefereneces
|
||||
objectName: "TabletControllerPreferences"
|
||||
showCategories: ["VR Movement", "Game Controller", "Sixense Controllers", "Perception Neuron", "Leap Motion"]
|
||||
showCategories: ["VR Movement", "Acceleration Step Function", "Game Controller", "Sixense Controllers", "Perception Neuron", "Leap Motion"]
|
||||
categoryProperties: {
|
||||
"VR Movement" : {
|
||||
"User real-world height (meters)" : { "anchors.right" : "undefined" },
|
||||
|
|
|
@ -139,7 +139,12 @@ MyAvatar::MyAvatar(QThread* thread) :
|
|||
_userHeightSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "userHeight", DEFAULT_AVATAR_HEIGHT),
|
||||
_flyingHMDSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "flyingHMD", _flyingPrefHMD),
|
||||
_handRelativeMovementSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "handRelativeMovement", _handRelativeMovement),
|
||||
_avatarEntityCountSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "avatarEntityData" << "size", 0)
|
||||
_avatarEntityCountSetting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "avatarEntityData" << "size", 0),
|
||||
_driveGear1Setting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "driveGear1", _driveGear1),
|
||||
_driveGear2Setting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "driveGear2", _driveGear2),
|
||||
_driveGear3Setting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "driveGear3", _driveGear3),
|
||||
_driveGear4Setting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "driveGear4", _driveGear4),
|
||||
_driveGear5Setting(QStringList() << AVATAR_SETTINGS_GROUP_NAME << "driveGear5", _driveGear5)
|
||||
{
|
||||
_clientTraitsHandler.reset(new ClientTraitsHandler(this));
|
||||
|
||||
|
@ -1302,6 +1307,11 @@ void MyAvatar::saveData() {
|
|||
_userHeightSetting.set(getUserHeight());
|
||||
_flyingHMDSetting.set(getFlyingHMDPref());
|
||||
_handRelativeMovementSetting.set(getHandRelativeMovement());
|
||||
_driveGear1Setting.set(getDriveGear1());
|
||||
_driveGear2Setting.set(getDriveGear2());
|
||||
_driveGear3Setting.set(getDriveGear3());
|
||||
_driveGear4Setting.set(getDriveGear4());
|
||||
_driveGear5Setting.set(getDriveGear5());
|
||||
|
||||
auto hmdInterface = DependencyManager::get<HMDScriptingInterface>();
|
||||
saveAvatarEntityDataToSettings();
|
||||
|
@ -1879,6 +1889,11 @@ void MyAvatar::loadData() {
|
|||
Setting::Handle<bool> firstRunVal { Settings::firstRun, true };
|
||||
setFlyingHMDPref(firstRunVal.get() ? false : _flyingHMDSetting.get());
|
||||
setHandRelativeMovement(firstRunVal.get() ? false : _handRelativeMovementSetting.get());
|
||||
setDriveGear1(firstRunVal.get() ? DEFAULT_GEAR_1 : _driveGear1Setting.get());
|
||||
setDriveGear2(firstRunVal.get() ? DEFAULT_GEAR_2 : _driveGear2Setting.get());
|
||||
setDriveGear3(firstRunVal.get() ? DEFAULT_GEAR_3 : _driveGear3Setting.get());
|
||||
setDriveGear4(firstRunVal.get() ? DEFAULT_GEAR_4 : _driveGear4Setting.get());
|
||||
setDriveGear5(firstRunVal.get() ? DEFAULT_GEAR_5 : _driveGear5Setting.get());
|
||||
setFlyingEnabled(getFlyingEnabled());
|
||||
|
||||
setDisplayName(_displayNameSetting.get());
|
||||
|
@ -3860,6 +3875,71 @@ bool MyAvatar::getHandRelativeMovement() {
|
|||
return _handRelativeMovement;
|
||||
}
|
||||
|
||||
void MyAvatar::setDriveGear1(float shiftPoint) {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "setDriveGear1", Q_ARG(float, shiftPoint));
|
||||
return;
|
||||
}
|
||||
if (shiftPoint > 1.0 || shiftPoint < 0) return;
|
||||
_driveGear1 = (shiftPoint <= _driveGear2) ? shiftPoint : _driveGear1;
|
||||
}
|
||||
|
||||
float MyAvatar::getDriveGear1() {
|
||||
return _driveGear1;
|
||||
}
|
||||
|
||||
void MyAvatar::setDriveGear2(float shiftPoint) {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "setDriveGear2", Q_ARG(float, shiftPoint));
|
||||
return;
|
||||
}
|
||||
if (shiftPoint > 1.0 || shiftPoint < 0) return;
|
||||
_driveGear2 = (shiftPoint <= _driveGear3 && shiftPoint >= _driveGear1) ? shiftPoint : _driveGear2;
|
||||
}
|
||||
|
||||
float MyAvatar::getDriveGear2() {
|
||||
return _driveGear2;
|
||||
}
|
||||
|
||||
void MyAvatar::setDriveGear3(float shiftPoint) {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "setDriveGear3", Q_ARG(float, shiftPoint));
|
||||
return;
|
||||
}
|
||||
if (shiftPoint > 1.0 || shiftPoint < 0) return;
|
||||
_driveGear3 = (shiftPoint <= _driveGear4 && shiftPoint >= _driveGear2) ? shiftPoint : _driveGear3;
|
||||
}
|
||||
|
||||
float MyAvatar::getDriveGear3() {
|
||||
return _driveGear3;
|
||||
}
|
||||
|
||||
void MyAvatar::setDriveGear4(float shiftPoint) {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "setDriveGear4", Q_ARG(float, shiftPoint));
|
||||
return;
|
||||
}
|
||||
if (shiftPoint > 1.0 || shiftPoint < 0) return;
|
||||
_driveGear4 = (shiftPoint <= _driveGear5 && shiftPoint >= _driveGear3) ? shiftPoint : _driveGear4;
|
||||
}
|
||||
|
||||
float MyAvatar::getDriveGear4() {
|
||||
return _driveGear4;
|
||||
}
|
||||
|
||||
void MyAvatar::setDriveGear5(float shiftPoint) {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "setDriveGear5", Q_ARG(float, shiftPoint));
|
||||
return;
|
||||
}
|
||||
if (shiftPoint > 1.0 || shiftPoint < 0) return;
|
||||
_driveGear5 = (shiftPoint >= _driveGear4) ? shiftPoint : _driveGear5;
|
||||
}
|
||||
|
||||
float MyAvatar::getDriveGear5() {
|
||||
return _driveGear5;
|
||||
}
|
||||
|
||||
bool MyAvatar::getFlyingHMDPref() {
|
||||
return _flyingPrefHMD;
|
||||
}
|
||||
|
|
|
@ -253,6 +253,12 @@ class MyAvatar : public Avatar {
|
|||
const QString DOMINANT_LEFT_HAND = "left";
|
||||
const QString DOMINANT_RIGHT_HAND = "right";
|
||||
|
||||
const float DEFAULT_GEAR_1 = 0.2f;
|
||||
const float DEFAULT_GEAR_2 = 0.4f;
|
||||
const float DEFAULT_GEAR_3 = 0.8f;
|
||||
const float DEFAULT_GEAR_4 = 0.9f;
|
||||
const float DEFAULT_GEAR_5 = 1.0f;
|
||||
|
||||
public:
|
||||
enum DriveKeys {
|
||||
TRANSLATE_X = 0,
|
||||
|
@ -1061,6 +1067,76 @@ public:
|
|||
*/
|
||||
Q_INVOKABLE bool getHandRelativeMovement();
|
||||
|
||||
/**jsdoc
|
||||
* Set the first 'shifting point' for acceleration step function.
|
||||
* @function MyAvatar.setDriveGear1
|
||||
* @param {number} shiftPoint - Set the first shift point for analog movement acceleration step function, between [0.0, 1.0]. Must be less than or equal to Gear 2.
|
||||
*/
|
||||
Q_INVOKABLE void setDriveGear1(float shiftPoint);
|
||||
|
||||
/**jsdoc
|
||||
* Get the first 'shifting point' for acceleration step function.
|
||||
* @function MyAvatar.getDriveGear1
|
||||
* @returns {number} Value between [0.0, 1.0].
|
||||
*/
|
||||
Q_INVOKABLE float getDriveGear1();
|
||||
|
||||
/**jsdoc
|
||||
* Set the second 'shifting point' for acceleration step function.
|
||||
* @function MyAvatar.setDriveGear2
|
||||
* @param {number} shiftPoint - Defines the second shift point for analog movement acceleration step function, between [0, 1]. Must be greater than or equal to Gear 1 and less than or equal to Gear 2.
|
||||
*/
|
||||
Q_INVOKABLE void setDriveGear2(float shiftPoint);
|
||||
|
||||
/**jsdoc
|
||||
* Get the second 'shifting point' for acceleration step function.
|
||||
* @function MyAvatar.getDriveGear2
|
||||
* @returns {number} Value between [0.0, 1.0].
|
||||
*/
|
||||
Q_INVOKABLE float getDriveGear2();
|
||||
|
||||
/**jsdoc
|
||||
* Set the third 'shifting point' for acceleration step function.
|
||||
* @function MyAvatar.setDriveGear3
|
||||
* @param {number} shiftPoint - Defines the third shift point for analog movement acceleration step function, between [0, 1]. Must be greater than or equal to Gear 2 and less than or equal to Gear 4.
|
||||
*/
|
||||
Q_INVOKABLE void setDriveGear3(float shiftPoint);
|
||||
|
||||
/**jsdoc
|
||||
* Get the third 'shifting point' for acceleration step function.
|
||||
* @function MyAvatar.getDriveGear3
|
||||
* @returns {number} Value between [0.0, 1.0].
|
||||
*/
|
||||
Q_INVOKABLE float getDriveGear3();
|
||||
|
||||
/**jsdoc
|
||||
* Set the fourth 'shifting point' for acceleration step function.
|
||||
* @function MyAvatar.setDriveGear4
|
||||
* @param {number} shiftPoint - Defines the fourth shift point for analog movement acceleration step function, between [0, 1]. Must be greater than Gear 3 and less than Gear 5.
|
||||
*/
|
||||
Q_INVOKABLE void setDriveGear4(float shiftPoint);
|
||||
|
||||
/**jsdoc
|
||||
* Get the fourth 'shifting point' for acceleration step function.
|
||||
* @function MyAvatar.getDriveGear4
|
||||
* @returns {number} Value between [0.0, 1.0].
|
||||
*/
|
||||
Q_INVOKABLE float getDriveGear4();
|
||||
|
||||
/**jsdoc
|
||||
* Set the fifth 'shifting point' for acceleration step function.
|
||||
* @function MyAvatar.setDriveGear5
|
||||
* @param {number} shiftPoint - Defines the fifth shift point for analog movement acceleration step function, between [0, 1]. Must be greater than or equal to Gear 4.
|
||||
*/
|
||||
Q_INVOKABLE void setDriveGear5(float shiftPoint);
|
||||
|
||||
/**jsdoc
|
||||
* Get the fifth 'shifting point' for acceleration step function.
|
||||
* @function MyAvatar.getDriveGear5
|
||||
* @returns {number} Value between [0.0, 1.0].
|
||||
*/
|
||||
Q_INVOKABLE float getDriveGear5();
|
||||
|
||||
/**jsdoc
|
||||
* @function MyAvatar.getAvatarScale
|
||||
* @returns {number}
|
||||
|
@ -1732,6 +1808,20 @@ private:
|
|||
float _boomLength { ZOOM_DEFAULT };
|
||||
float _yawSpeed; // degrees/sec
|
||||
float _pitchSpeed; // degrees/sec
|
||||
float _driveGear1 { DEFAULT_GEAR_1 };
|
||||
float _driveGear2 { DEFAULT_GEAR_2 };
|
||||
float _driveGear3 { DEFAULT_GEAR_3 };
|
||||
float _driveGear4 { DEFAULT_GEAR_4 };
|
||||
float _driveGear5 { DEFAULT_GEAR_5 };
|
||||
|
||||
int _controlSchemeIndex;
|
||||
|
||||
//Setting::Handle<float> _driveGear1Setting;
|
||||
//Setting::Handle<float> _driveGear2Setting;
|
||||
//Setting::Handle<float> _driveGear3Setting;
|
||||
//Setting::Handle<float> _driveGear4Setting;
|
||||
//Setting::Handle<float> _driveGear5Setting;
|
||||
//Setting::Handle<int> controlSchemeIndex;
|
||||
|
||||
glm::vec3 _thrust { 0.0f }; // impulse accumulator for outside sources
|
||||
|
||||
|
@ -1972,6 +2062,12 @@ private:
|
|||
Setting::Handle<bool> _handRelativeMovementSetting;
|
||||
Setting::Handle<int> _avatarEntityCountSetting;
|
||||
Setting::Handle<bool> _allowTeleportingSetting { "allowTeleporting", true };
|
||||
Setting::Handle<float> _driveGear1Setting;
|
||||
Setting::Handle<float> _driveGear2Setting;
|
||||
Setting::Handle<float> _driveGear3Setting;
|
||||
Setting::Handle<float> _driveGear4Setting;
|
||||
Setting::Handle<float> _driveGear5Setting;
|
||||
Setting::Handle<int> controlSchemeIndexSetting;
|
||||
std::vector<Setting::Handle<QUuid>> _avatarEntityIDSettings;
|
||||
std::vector<Setting::Handle<QByteArray>> _avatarEntityDataSettings;
|
||||
|
||||
|
|
|
@ -348,6 +348,53 @@ void setupPreferences() {
|
|||
preferences->addPreference(preference);
|
||||
}
|
||||
|
||||
static const QString ACCEL_CURVE{ "Acceleration Step Function" };
|
||||
{
|
||||
auto getter = [myAvatar]()->float { return myAvatar->getDriveGear1(); };
|
||||
auto setter = [myAvatar](float value) { myAvatar->setDriveGear1(value); };
|
||||
auto preference = new SpinnerPreference(ACCEL_CURVE, "Gear 1", getter, setter);
|
||||
preference->setMin(1);
|
||||
preference->setMax(5);
|
||||
preference->setStep(1);
|
||||
preferences->addPreference(preference);
|
||||
}
|
||||
{
|
||||
auto getter = [myAvatar]()->float { return myAvatar->getDriveGear2(); };
|
||||
auto setter = [myAvatar](float value) { myAvatar->setDriveGear2(value); };
|
||||
auto preference = new SpinnerPreference(ACCEL_CURVE, "Gear 2", getter, setter);
|
||||
preference->setMin(1);
|
||||
preference->setMax(5);
|
||||
preference->setStep(1);
|
||||
preferences->addPreference(preference);
|
||||
}
|
||||
{
|
||||
auto getter = [myAvatar]()->float { return myAvatar->getDriveGear3(); };
|
||||
auto setter = [myAvatar](float value) { myAvatar->setDriveGear3(value); };
|
||||
auto preference = new SpinnerPreference(ACCEL_CURVE, "Gear 3", getter, setter);
|
||||
preference->setMin(1);
|
||||
preference->setMax(5);
|
||||
preference->setStep(1);
|
||||
preferences->addPreference(preference);
|
||||
}
|
||||
{
|
||||
auto getter = [myAvatar]()->float { return myAvatar->getDriveGear4(); };
|
||||
auto setter = [myAvatar](float value) { myAvatar->setDriveGear4(value); };
|
||||
auto preference = new SpinnerPreference(ACCEL_CURVE, "Gear 4", getter, setter);
|
||||
preference->setMin(1);
|
||||
preference->setMax(5);
|
||||
preference->setStep(1);
|
||||
preferences->addPreference(preference);
|
||||
}
|
||||
{
|
||||
auto getter = [myAvatar]()->float { return myAvatar->getDriveGear5(); };
|
||||
auto setter = [myAvatar](float value) { myAvatar->setDriveGear5(value); };
|
||||
auto preference = new SpinnerPreference(ACCEL_CURVE, "Gear 5", getter, setter);
|
||||
preference->setMin(1);
|
||||
preference->setMax(5);
|
||||
preference->setStep(1);
|
||||
preferences->addPreference(preference);
|
||||
}
|
||||
|
||||
static const QString AVATAR_CAMERA{ "Mouse Sensitivity" };
|
||||
{
|
||||
auto getter = [myAvatar]()->float { return myAvatar->getPitchSpeed(); };
|
||||
|
|
Loading…
Reference in a new issue