mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-11 00:58:56 +02:00
added properties to allow the toggling of the debug draw the look at vector, and the reset moving average look at on step detection
This commit is contained in:
parent
ef2d3c9f16
commit
7cc724a27b
2 changed files with 23 additions and 7 deletions
|
@ -471,6 +471,7 @@ void MyAvatar::update(float deltaTime) {
|
||||||
_averageFacing.y= sumHeadFacingY / (float)_headFacingBuffer.getNumEntries();
|
_averageFacing.y= sumHeadFacingY / (float)_headFacingBuffer.getNumEntries();
|
||||||
|
|
||||||
#ifdef DEBUG_DRAW_HMD_MOVING_AVERAGE
|
#ifdef DEBUG_DRAW_HMD_MOVING_AVERAGE
|
||||||
|
if (_drawAverageFacingEnabled) {
|
||||||
auto sensorHeadPose = getControllerPoseInSensorFrame(controller::Action::HEAD);
|
auto sensorHeadPose = getControllerPoseInSensorFrame(controller::Action::HEAD);
|
||||||
glm::vec3 worldHeadPos = transformPoint(getSensorToWorldMatrix(), sensorHeadPose.getTranslation());
|
glm::vec3 worldHeadPos = transformPoint(getSensorToWorldMatrix(), sensorHeadPose.getTranslation());
|
||||||
glm::vec3 worldFacingAverage = transformVectorFast(getSensorToWorldMatrix(), glm::vec3(_headControllerFacingMovingAverage.x, 0.0f, _headControllerFacingMovingAverage.y));
|
glm::vec3 worldFacingAverage = transformVectorFast(getSensorToWorldMatrix(), glm::vec3(_headControllerFacingMovingAverage.x, 0.0f, _headControllerFacingMovingAverage.y));
|
||||||
|
@ -478,6 +479,7 @@ void MyAvatar::update(float deltaTime) {
|
||||||
glm::vec3 worldFacing = transformVectorFast(getSensorToWorldMatrix(), glm::vec3(_headControllerFacing.x, 0.0f, _headControllerFacing.y));
|
glm::vec3 worldFacing = transformVectorFast(getSensorToWorldMatrix(), glm::vec3(_headControllerFacing.x, 0.0f, _headControllerFacing.y));
|
||||||
DebugDraw::getInstance().drawRay(worldHeadPos, worldHeadPos + worldFacing, glm::vec4(0.0f, 1.0f, 0.0f, 1.0f));
|
DebugDraw::getInstance().drawRay(worldHeadPos, worldHeadPos + worldFacing, glm::vec4(0.0f, 1.0f, 0.0f, 1.0f));
|
||||||
DebugDraw::getInstance().drawRay(worldHeadPos, worldHeadPos + worldFacingAverage, glm::vec4(0.0f, 0.0f, 1.0f, 1.0f));
|
DebugDraw::getInstance().drawRay(worldHeadPos, worldHeadPos + worldFacingAverage, glm::vec4(0.0f, 0.0f, 1.0f, 1.0f));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (_goToPending) {
|
if (_goToPending) {
|
||||||
|
@ -3594,10 +3596,16 @@ void MyAvatar::FollowHelper::prePhysicsUpdate(MyAvatar& myAvatar, const glm::mat
|
||||||
if (myAvatar.getCenterOfGravityModelEnabled()) {
|
if (myAvatar.getCenterOfGravityModelEnabled()) {
|
||||||
if (!isActive(Horizontal) && (shouldActivateHorizontalCG(myAvatar) || hasDriveInput)) {
|
if (!isActive(Horizontal) && (shouldActivateHorizontalCG(myAvatar) || hasDriveInput)) {
|
||||||
activate(Horizontal);
|
activate(Horizontal);
|
||||||
|
if (myAvatar.getEnableStepResetRotation()) {
|
||||||
|
myAvatar.setHeadControllerFacingMovingAverage(myAvatar._headControllerFacing);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!isActive(Horizontal) && (shouldActivateHorizontal(myAvatar, desiredBodyMatrix, currentBodyMatrix) || hasDriveInput)) {
|
if (!isActive(Horizontal) && (shouldActivateHorizontal(myAvatar, desiredBodyMatrix, currentBodyMatrix) || hasDriveInput)) {
|
||||||
activate(Horizontal);
|
activate(Horizontal);
|
||||||
|
if (myAvatar.getEnableStepResetRotation()) {
|
||||||
|
myAvatar.setHeadControllerFacingMovingAverage(myAvatar._headControllerFacing);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -198,6 +198,8 @@ class MyAvatar : public Avatar {
|
||||||
Q_PROPERTY(bool hasAudioEnabledFaceMovement READ getHasAudioEnabledFaceMovement WRITE setHasAudioEnabledFaceMovement)
|
Q_PROPERTY(bool hasAudioEnabledFaceMovement READ getHasAudioEnabledFaceMovement WRITE setHasAudioEnabledFaceMovement)
|
||||||
Q_PROPERTY(float rotationRecenterFilterLength READ getRotationRecenterFilterLength WRITE setRotationRecenterFilterLength)
|
Q_PROPERTY(float rotationRecenterFilterLength READ getRotationRecenterFilterLength WRITE setRotationRecenterFilterLength)
|
||||||
Q_PROPERTY(float rotationThreshold READ getRotationThreshold WRITE setRotationThreshold)
|
Q_PROPERTY(float rotationThreshold READ getRotationThreshold WRITE setRotationThreshold)
|
||||||
|
Q_PROPERTY(bool enableStepResetRotation READ getEnableStepResetRotation WRITE setEnableStepResetRotation)
|
||||||
|
Q_PROPERTY(bool enableDrawAverageFacing READ getEnableDrawAverageFacing WRITE setEnableDrawAverageFacing)
|
||||||
//TODO: make gravity feature work Q_PROPERTY(glm::vec3 gravity READ getGravity WRITE setGravity)
|
//TODO: make gravity feature work Q_PROPERTY(glm::vec3 gravity READ getGravity WRITE setGravity)
|
||||||
|
|
||||||
Q_PROPERTY(glm::vec3 leftHandPosition READ getLeftHandPosition)
|
Q_PROPERTY(glm::vec3 leftHandPosition READ getLeftHandPosition)
|
||||||
|
@ -1464,6 +1466,10 @@ private:
|
||||||
float getRotationRecenterFilterLength() const { return _rotationRecenterFilterLength; }
|
float getRotationRecenterFilterLength() const { return _rotationRecenterFilterLength; }
|
||||||
void setRotationThreshold(float angleRadians);
|
void setRotationThreshold(float angleRadians);
|
||||||
float getRotationThreshold() const { return _rotationThreshold; }
|
float getRotationThreshold() const { return _rotationThreshold; }
|
||||||
|
void setEnableStepResetRotation(bool stepReset) { _stepResetRotationEnabled = stepReset; }
|
||||||
|
bool getEnableStepResetRotation() const { return _stepResetRotationEnabled; }
|
||||||
|
void setEnableDrawAverageFacing(bool drawAverage) { _drawAverageFacingEnabled = drawAverage; }
|
||||||
|
bool getEnableDrawAverageFacing() const { return _drawAverageFacingEnabled; }
|
||||||
bool isMyAvatar() const override { return true; }
|
bool isMyAvatar() const override { return true; }
|
||||||
virtual int parseDataFromBuffer(const QByteArray& buffer) override;
|
virtual int parseDataFromBuffer(const QByteArray& buffer) override;
|
||||||
virtual glm::vec3 getSkeletonPosition() const override;
|
virtual glm::vec3 getSkeletonPosition() const override;
|
||||||
|
@ -1574,6 +1580,8 @@ private:
|
||||||
std::atomic<bool> _hasScriptedBlendShapes { false };
|
std::atomic<bool> _hasScriptedBlendShapes { false };
|
||||||
std::atomic<float> _rotationRecenterFilterLength { 4.0f };
|
std::atomic<float> _rotationRecenterFilterLength { 4.0f };
|
||||||
std::atomic<float> _rotationThreshold { 0.5235f }; // 30 degrees in radians
|
std::atomic<float> _rotationThreshold { 0.5235f }; // 30 degrees in radians
|
||||||
|
std::atomic<bool> _stepResetRotationEnabled { false };
|
||||||
|
std::atomic<bool> _drawAverageFacingEnabled { false };
|
||||||
|
|
||||||
// working copy -- see AvatarData for thread-safe _sensorToWorldMatrixCache, used for outward facing access
|
// working copy -- see AvatarData for thread-safe _sensorToWorldMatrixCache, used for outward facing access
|
||||||
glm::mat4 _sensorToWorldMatrix { glm::mat4() };
|
glm::mat4 _sensorToWorldMatrix { glm::mat4() };
|
||||||
|
|
Loading…
Reference in a new issue