mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-08 14:58:26 +02:00
Initial Commit - more to do.
This commit is contained in:
parent
030b39050a
commit
72ca62c4af
4 changed files with 25 additions and 6 deletions
|
@ -60,6 +60,8 @@
|
||||||
#include "MovingEntitiesOperator.h"
|
#include "MovingEntitiesOperator.h"
|
||||||
#include "SceneScriptingInterface.h"
|
#include "SceneScriptingInterface.h"
|
||||||
|
|
||||||
|
#include "CharacterController.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
const float DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES = 30.0f;
|
const float DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES = 30.0f;
|
||||||
|
@ -2259,6 +2261,10 @@ float MyAvatar::getDomainMaxScale() {
|
||||||
return _domainMaximumScale;
|
return _domainMaximumScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyAvatar::setGravity(float gravity) {
|
||||||
|
emit gravityChanged(gravity);
|
||||||
|
}
|
||||||
|
|
||||||
void MyAvatar::increaseSize() {
|
void MyAvatar::increaseSize() {
|
||||||
// make sure we're starting from an allowable scale
|
// make sure we're starting from an allowable scale
|
||||||
clampTargetScaleToDomainLimits();
|
clampTargetScaleToDomainLimits();
|
||||||
|
|
|
@ -146,6 +146,8 @@ class MyAvatar : public Avatar {
|
||||||
Q_PROPERTY(float hmdRollControlDeadZone READ getHMDRollControlDeadZone WRITE setHMDRollControlDeadZone)
|
Q_PROPERTY(float hmdRollControlDeadZone READ getHMDRollControlDeadZone WRITE setHMDRollControlDeadZone)
|
||||||
Q_PROPERTY(float hmdRollControlRate READ getHMDRollControlRate WRITE setHMDRollControlRate)
|
Q_PROPERTY(float hmdRollControlRate READ getHMDRollControlRate WRITE setHMDRollControlRate)
|
||||||
|
|
||||||
|
Q_PROPERTY(float gravity WRITE updateGravity NOTIFY gravityChanged);
|
||||||
|
|
||||||
const QString DOMINANT_LEFT_HAND = "left";
|
const QString DOMINANT_LEFT_HAND = "left";
|
||||||
const QString DOMINANT_RIGHT_HAND = "right";
|
const QString DOMINANT_RIGHT_HAND = "right";
|
||||||
|
|
||||||
|
@ -540,6 +542,8 @@ public slots:
|
||||||
float getDomainMinScale();
|
float getDomainMinScale();
|
||||||
float getDomainMaxScale();
|
float getDomainMaxScale();
|
||||||
|
|
||||||
|
void setGravity(float gravity);
|
||||||
|
|
||||||
void goToLocation(const glm::vec3& newPosition,
|
void goToLocation(const glm::vec3& newPosition,
|
||||||
bool hasOrientation = false, const glm::quat& newOrientation = glm::quat(),
|
bool hasOrientation = false, const glm::quat& newOrientation = glm::quat(),
|
||||||
bool shouldFaceLocation = false);
|
bool shouldFaceLocation = false);
|
||||||
|
@ -592,6 +596,7 @@ signals:
|
||||||
void wentActive();
|
void wentActive();
|
||||||
void skeletonChanged();
|
void skeletonChanged();
|
||||||
void dominantHandChanged(const QString& hand);
|
void dominantHandChanged(const QString& hand);
|
||||||
|
void gravityChanged(const float gravity);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
const btVector3 LOCAL_UP_AXIS(0.0f, 1.0f, 0.0f);
|
const btVector3 LOCAL_UP_AXIS(0.0f, 1.0f, 0.0f);
|
||||||
const float JUMP_SPEED = 3.5f;
|
const float JUMP_SPEED = 3.5f;
|
||||||
const float MAX_FALL_HEIGHT = 20.0f;
|
const float MAX_FALL_HEIGHT = 20.0f;
|
||||||
|
const float DEFAULT_CHARACTER_GRAVITY = -5.0f;
|
||||||
|
|
||||||
#ifdef DEBUG_STATE_CHANGE
|
#ifdef DEBUG_STATE_CHANGE
|
||||||
#define SET_STATE(desiredState, reason) setState(desiredState, reason)
|
#define SET_STATE(desiredState, reason) setState(desiredState, reason)
|
||||||
|
@ -371,19 +372,20 @@ void CharacterController::setState(State desiredState) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharacterController::updateGravity() {
|
void CharacterController::updateGravity(float gravity = DEFAULT_CHARACTER_GRAVITY) {
|
||||||
int16_t collisionGroup = computeCollisionGroup();
|
int16_t collisionGroup = computeCollisionGroup();
|
||||||
if (_state == State::Hover || collisionGroup == BULLET_COLLISION_GROUP_COLLISIONLESS) {
|
if (_state == State::Hover || collisionGroup == BULLET_COLLISION_GROUP_COLLISIONLESS) {
|
||||||
_gravity = 0.0f;
|
_gravity = 0.0f;
|
||||||
} else {
|
} else {
|
||||||
const float DEFAULT_CHARACTER_GRAVITY = -5.0f;
|
_gravity = gravity;
|
||||||
_gravity = DEFAULT_CHARACTER_GRAVITY;
|
|
||||||
}
|
}
|
||||||
if (_rigidBody) {
|
if (_rigidBody) {
|
||||||
_rigidBody->setGravity(_gravity * _currentUp);
|
_rigidBody->setGravity(_gravity * _currentUp);
|
||||||
}
|
}
|
||||||
|
emit gravityChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CharacterController::setLocalBoundingBox(const glm::vec3& minCorner, const glm::vec3& scale) {
|
void CharacterController::setLocalBoundingBox(const glm::vec3& minCorner, const glm::vec3& scale) {
|
||||||
float x = scale.x;
|
float x = scale.x;
|
||||||
float z = scale.z;
|
float z = scale.z;
|
||||||
|
|
|
@ -42,10 +42,16 @@ const btScalar MAX_CHARACTER_MOTOR_TIMESCALE = 60.0f; // one minute
|
||||||
const btScalar MIN_CHARACTER_MOTOR_TIMESCALE = 0.05f;
|
const btScalar MIN_CHARACTER_MOTOR_TIMESCALE = 0.05f;
|
||||||
|
|
||||||
class CharacterController : public btCharacterControllerInterface {
|
class CharacterController : public btCharacterControllerInterface {
|
||||||
|
|
||||||
|
Q_PROPERTY(float gravity WRITE updateGravity NOTIFY gravityChanged);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void gravityChanged();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CharacterController();
|
CharacterController();
|
||||||
virtual ~CharacterController();
|
virtual ~CharacterController();
|
||||||
|
void updateGravity(float gravity);
|
||||||
bool needsRemoval() const;
|
bool needsRemoval() const;
|
||||||
bool needsAddition() const;
|
bool needsAddition() const;
|
||||||
virtual void setDynamicsWorld(btDynamicsWorld* world);
|
virtual void setDynamicsWorld(btDynamicsWorld* world);
|
||||||
|
@ -130,7 +136,7 @@ protected:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
virtual void updateMassProperties() = 0;
|
virtual void updateMassProperties() = 0;
|
||||||
void updateGravity();
|
void updateGravity(float gravity);
|
||||||
void updateUpAxis(const glm::quat& rotation);
|
void updateUpAxis(const glm::quat& rotation);
|
||||||
bool checkForSupport(btCollisionWorld* collisionWorld);
|
bool checkForSupport(btCollisionWorld* collisionWorld);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue