mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:35:08 +02:00
Merge pull request #12099 from sethalves/run
allow avatar walk-speed to be set from javascript
This commit is contained in:
commit
8f22c719b3
4 changed files with 58 additions and 2 deletions
|
@ -1925,7 +1925,7 @@ void MyAvatar::preDisplaySide(RenderArgs* renderArgs) {
|
|||
_prevShouldDrawHead = shouldDrawHead;
|
||||
}
|
||||
|
||||
const float RENDER_HEAD_CUTOFF_DISTANCE = 0.3f;
|
||||
const float RENDER_HEAD_CUTOFF_DISTANCE = 0.47f;
|
||||
|
||||
bool MyAvatar::cameraInsideHead(const glm::vec3& cameraPosition) const {
|
||||
return glm::length(cameraPosition - getHeadPosition()) < (RENDER_HEAD_CUTOFF_DISTANCE * getModelScale());
|
||||
|
@ -2096,7 +2096,7 @@ void MyAvatar::updateActionMotor(float deltaTime) {
|
|||
_actionMotorVelocity = motorSpeed * direction;
|
||||
} else {
|
||||
// we're interacting with a floor --> simple horizontal speed and exponential decay
|
||||
_actionMotorVelocity = getSensorToWorldScale() * DEFAULT_AVATAR_MAX_WALKING_SPEED * direction;
|
||||
_actionMotorVelocity = getSensorToWorldScale() * _walkSpeed.get() * direction;
|
||||
}
|
||||
|
||||
float boomChange = getDriveKey(ZOOM);
|
||||
|
@ -2688,6 +2688,14 @@ float MyAvatar::getUserEyeHeight() const {
|
|||
return userHeight - userHeight * ratio;
|
||||
}
|
||||
|
||||
float MyAvatar::getWalkSpeed() const {
|
||||
return _walkSpeed.get();
|
||||
}
|
||||
|
||||
void MyAvatar::setWalkSpeed(float value) {
|
||||
_walkSpeed.set(value);
|
||||
}
|
||||
|
||||
glm::vec3 MyAvatar::getPositionForAudio() {
|
||||
switch (_audioListenerMode) {
|
||||
case AudioListenerMode::FROM_HEAD:
|
||||
|
|
|
@ -163,6 +163,8 @@ class MyAvatar : public Avatar {
|
|||
|
||||
Q_PROPERTY(QUuid SELF_ID READ getSelfID CONSTANT)
|
||||
|
||||
Q_PROPERTY(float walkSpeed READ getWalkSpeed WRITE setWalkSpeed);
|
||||
|
||||
const QString DOMINANT_LEFT_HAND = "left";
|
||||
const QString DOMINANT_RIGHT_HAND = "right";
|
||||
|
||||
|
@ -557,6 +559,9 @@ public:
|
|||
|
||||
const QUuid& getSelfID() const { return AVATAR_SELF_ID; }
|
||||
|
||||
void setWalkSpeed(float value);
|
||||
float getWalkSpeed() const;
|
||||
|
||||
public slots:
|
||||
void increaseSize();
|
||||
void decreaseSize();
|
||||
|
@ -840,6 +845,9 @@ private:
|
|||
|
||||
// height of user in sensor space, when standing erect.
|
||||
ThreadSafeValueCache<float> _userHeight { DEFAULT_AVATAR_HEIGHT };
|
||||
|
||||
// max unscaled forward movement speed
|
||||
ThreadSafeValueCache<float> _walkSpeed { DEFAULT_AVATAR_MAX_WALKING_SPEED };
|
||||
};
|
||||
|
||||
QScriptValue audioListenModeToScriptValue(QScriptEngine* engine, const AudioListenerMode& audioListenerMode);
|
||||
|
|
1
scripts/system/assets/images/run.svg
Normal file
1
scripts/system/assets/images/run.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 100 100" enable-background="new 0 0 100 100" xml:space="preserve"><path d="M56.3,18.2c-2.6,0-28.1,0-32.5,0s-5.3,7.1,0,7.1h23.7c0.9,0,1.2,0.6,0.8,1.3c0,0-6,10.8-8.3,14.3c-2.3,3.5-1.1,9,1.7,11 C49.1,57.4,60.5,66,60.5,66c0.7,0.5,1.2,1.6,1.2,2.4c0,0,0,15.2,0,21.7c0,6.5,9.6,6.2,9.6,0c0-4.9,0-27.1,0-27.1 c0-0.8-0.5-1.9-1.2-2.5L53.8,48.5C53.2,48,53,47,53.4,46.3l10.2-17.9C63.5,28.4,58.9,18.2,56.3,18.2z M38.1,53.8l-8.6,12.1 c0,0-4.4-3.1-9.5-7.2c-5-4.1-10.9,2.8-5.8,6.8c2.6,2,6.8,5.2,10.3,8c3.6,2.8,9,3.2,12.6-2.1c5.2-7.8,8.2-12,8.2-12L38.1,53.8z M61.2,39.8c0,0,4.8,7,6.8,10.1c2.1,3,6.7,2.3,9.8,0c3.1-2.3,6.1-4.3,8.3-6c3.6-2.7-0.1-8.6-3.9-6c-4.7,3.3-7.7,5.7-7.7,5.7 c-0.6,0.5-1.5,0.4-2-0.4L65.9,32L61.2,39.8z M61.8,7.5c-3.7,6.2,0.9,12.7,3.8,14.4c2.1,1.3,5.1,2.6,8.3-2.7s3.3-8.8-3-12.6 C68.8,5.4,64.3,3.3,61.8,7.5z"></path></svg>
|
After Width: | Height: | Size: 955 B |
39
scripts/system/run.js
Normal file
39
scripts/system/run.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
"use strict";
|
||||
|
||||
/* global Script, Tablet, MyAvatar */
|
||||
|
||||
(function() { // BEGIN LOCAL_SCOPE
|
||||
var WALK_SPEED = 2.6;
|
||||
var RUN_SPEED = 4.5;
|
||||
var MIDDLE_SPEED = (WALK_SPEED + RUN_SPEED) / 2.0;
|
||||
|
||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||
var button = tablet.addButton({
|
||||
icon: Script.resolvePath("assets/images/run.svg"),
|
||||
text: "RUN",
|
||||
sortOrder: 15
|
||||
});
|
||||
|
||||
function onClicked() {
|
||||
if (MyAvatar.walkSpeed < MIDDLE_SPEED) {
|
||||
button.editProperties({isActive: true});
|
||||
MyAvatar.walkSpeed = RUN_SPEED;
|
||||
} else {
|
||||
button.editProperties({isActive: false});
|
||||
MyAvatar.walkSpeed = WALK_SPEED;
|
||||
}
|
||||
}
|
||||
|
||||
function cleanup() {
|
||||
button.clicked.disconnect(onClicked);
|
||||
tablet.removeButton(button);
|
||||
}
|
||||
|
||||
button.clicked.connect(onClicked);
|
||||
if (MyAvatar.walkSpeed < MIDDLE_SPEED) {
|
||||
button.editProperties({isActive: false});
|
||||
} else {
|
||||
button.editProperties({isActive: true});
|
||||
}
|
||||
|
||||
}());
|
Loading…
Reference in a new issue