|
@@ -43,6 +43,7 @@ const static float controllerDeadZone = 0.33f;
|
43
|
43
|
const static float controllerViewFactor = glm::pi<float>();
|
44
|
44
|
const static float rotationAngleClamp = glm::pi<float>() * 2.0f;
|
45
|
45
|
const static float rotationAngleVertMax = glm::pi<float>() / 2.0f;
|
|
46
|
+const static float runFactor = 2.5f;
|
46
|
47
|
|
47
|
48
|
const static glm::vec3 rightUnit(1.0f, 0.0f, 0.0f);
|
48
|
49
|
const static glm::vec3 upUnit(0.0f, 1.0f, 0.0f);
|
|
@@ -59,6 +60,7 @@ float Camera::rotationDeltaY = 0.75f;
|
59
|
60
|
bool Camera::updateViewFrustum = true;
|
60
|
61
|
bool Camera::dirty = true;
|
61
|
62
|
bool Camera::showOverlay = false;
|
|
63
|
+bool Camera::movingFaster = false;
|
62
|
64
|
int Camera::room = -1;
|
63
|
65
|
|
64
|
66
|
void Camera::reset() {
|
|
@@ -96,6 +98,8 @@ void Camera::handleAction(ActionEvents action, bool isFinished) {
|
96
|
98
|
posSpeed += upUnit * maxSpeed * factor;
|
97
|
99
|
} else if (action == crouchAction) {
|
98
|
100
|
posSpeed -= upUnit * maxSpeed * factor;
|
|
101
|
+ } else if (action == walkAction) {
|
|
102
|
+ movingFaster = !isFinished;
|
99
|
103
|
} else {
|
100
|
104
|
return;
|
101
|
105
|
}
|
|
@@ -176,9 +180,17 @@ bool Camera::update() {
|
176
|
180
|
glm::quat quatX = glm::angleAxis(rot.y, glm::vec3(1.0f, 0.0f, 0.0f));
|
177
|
181
|
glm::quat quaternion = quatY * quatX;
|
178
|
182
|
|
179
|
|
- glm::vec3 clampedSpeed(posSpeed);
|
180
|
|
- if (glm::length(clampedSpeed) > maxSpeed) {
|
181
|
|
- clampedSpeed = glm::normalize(clampedSpeed) * maxSpeed;
|
|
183
|
+ glm::vec3 clampedSpeed;
|
|
184
|
+ if (movingFaster) {
|
|
185
|
+ clampedSpeed = posSpeed * runFactor;
|
|
186
|
+ if (glm::length(clampedSpeed) > (maxSpeed * runFactor)) {
|
|
187
|
+ clampedSpeed = glm::normalize(clampedSpeed) * maxSpeed * runFactor;
|
|
188
|
+ }
|
|
189
|
+ } else {
|
|
190
|
+ clampedSpeed = posSpeed;
|
|
191
|
+ if (glm::length(clampedSpeed) > maxSpeed) {
|
|
192
|
+ clampedSpeed = glm::normalize(clampedSpeed) * maxSpeed;
|
|
193
|
+ }
|
182
|
194
|
}
|
183
|
195
|
|
184
|
196
|
pos += quaternion * clampedSpeed * dT;
|