mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 12:37:51 +02:00
Merge branch 'master' of github.com:highfidelity/hifi into model-scripting-2
This commit is contained in:
commit
8da91695df
43 changed files with 190 additions and 105 deletions
|
@ -510,6 +510,8 @@ Menu::Menu() {
|
||||||
avatar.get(), SLOT(setEnableInverseKinematics(bool)));
|
avatar.get(), SLOT(setEnableInverseKinematics(bool)));
|
||||||
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::RenderSensorToWorldMatrix, 0, false,
|
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::RenderSensorToWorldMatrix, 0, false,
|
||||||
avatar.get(), SLOT(setEnableDebugDrawSensorToWorldMatrix(bool)));
|
avatar.get(), SLOT(setEnableDebugDrawSensorToWorldMatrix(bool)));
|
||||||
|
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::RenderIKTargets, 0, false,
|
||||||
|
avatar.get(), SLOT(setEnableDebugDrawIKTargets(bool)));
|
||||||
|
|
||||||
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::ActionMotorControl,
|
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::ActionMotorControl,
|
||||||
Qt::CTRL | Qt::SHIFT | Qt::Key_K, true, avatar.get(), SLOT(updateMotionBehaviorFromMenu()),
|
Qt::CTRL | Qt::SHIFT | Qt::Key_K, true, avatar.get(), SLOT(updateMotionBehaviorFromMenu()),
|
||||||
|
|
|
@ -161,6 +161,7 @@ namespace MenuOption {
|
||||||
const QString RenderResolutionThird = "1/3";
|
const QString RenderResolutionThird = "1/3";
|
||||||
const QString RenderResolutionQuarter = "1/4";
|
const QString RenderResolutionQuarter = "1/4";
|
||||||
const QString RenderSensorToWorldMatrix = "Show SensorToWorld Matrix";
|
const QString RenderSensorToWorldMatrix = "Show SensorToWorld Matrix";
|
||||||
|
const QString RenderIKTargets = "Show IK Targets";
|
||||||
const QString ResetAvatarSize = "Reset Avatar Size";
|
const QString ResetAvatarSize = "Reset Avatar Size";
|
||||||
const QString ResetSensors = "Reset Sensors";
|
const QString ResetSensors = "Reset Sensors";
|
||||||
const QString RunningScripts = "Running Scripts...";
|
const QString RunningScripts = "Running Scripts...";
|
||||||
|
|
|
@ -491,6 +491,11 @@ void MyAvatar::simulate(float deltaTime) {
|
||||||
|
|
||||||
{
|
{
|
||||||
PerformanceTimer perfTimer("skeleton");
|
PerformanceTimer perfTimer("skeleton");
|
||||||
|
|
||||||
|
if (_rig) {
|
||||||
|
_rig->setEnableDebugDrawIKTargets(_enableDebugDrawIKTargets);
|
||||||
|
}
|
||||||
|
|
||||||
_skeletonModel->simulate(deltaTime);
|
_skeletonModel->simulate(deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -916,6 +921,10 @@ void MyAvatar::setEnableDebugDrawSensorToWorldMatrix(bool isEnabled) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyAvatar::setEnableDebugDrawIKTargets(bool isEnabled) {
|
||||||
|
_enableDebugDrawIKTargets = isEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
void MyAvatar::setEnableMeshVisible(bool isEnabled) {
|
void MyAvatar::setEnableMeshVisible(bool isEnabled) {
|
||||||
render::ScenePointer scene = qApp->getMain3DScene();
|
render::ScenePointer scene = qApp->getMain3DScene();
|
||||||
_skeletonModel->setVisibleInScene(isEnabled, scene);
|
_skeletonModel->setVisibleInScene(isEnabled, scene);
|
||||||
|
|
|
@ -482,6 +482,7 @@ public slots:
|
||||||
void setEnableDebugDrawPosition(bool isEnabled);
|
void setEnableDebugDrawPosition(bool isEnabled);
|
||||||
void setEnableDebugDrawHandControllers(bool isEnabled);
|
void setEnableDebugDrawHandControllers(bool isEnabled);
|
||||||
void setEnableDebugDrawSensorToWorldMatrix(bool isEnabled);
|
void setEnableDebugDrawSensorToWorldMatrix(bool isEnabled);
|
||||||
|
void setEnableDebugDrawIKTargets(bool isEnabled);
|
||||||
bool getEnableMeshVisible() const { return _skeletonModel->isVisible(); }
|
bool getEnableMeshVisible() const { return _skeletonModel->isVisible(); }
|
||||||
void setEnableMeshVisible(bool isEnabled);
|
void setEnableMeshVisible(bool isEnabled);
|
||||||
void setUseAnimPreAndPostRotations(bool isEnabled);
|
void setUseAnimPreAndPostRotations(bool isEnabled);
|
||||||
|
@ -668,6 +669,7 @@ private:
|
||||||
bool _enableDebugDrawAnimPose { false };
|
bool _enableDebugDrawAnimPose { false };
|
||||||
bool _enableDebugDrawHandControllers { false };
|
bool _enableDebugDrawHandControllers { false };
|
||||||
bool _enableDebugDrawSensorToWorldMatrix { false };
|
bool _enableDebugDrawSensorToWorldMatrix { false };
|
||||||
|
bool _enableDebugDrawIKTargets { false };
|
||||||
|
|
||||||
AudioListenerMode _audioListenerMode;
|
AudioListenerMode _audioListenerMode;
|
||||||
glm::vec3 _customListenPosition;
|
glm::vec3 _customListenPosition;
|
||||||
|
|
|
@ -24,7 +24,7 @@ AnimBlendLinear::~AnimBlendLinear() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const AnimPoseVec& AnimBlendLinear::evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) {
|
const AnimPoseVec& AnimBlendLinear::evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut) {
|
||||||
|
|
||||||
_alpha = animVars.lookup(_alphaVar, _alpha);
|
_alpha = animVars.lookup(_alphaVar, _alpha);
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ const AnimPoseVec& AnimBlendLinear::evaluate(const AnimVariantMap& animVars, flo
|
||||||
pose = AnimPose::identity;
|
pose = AnimPose::identity;
|
||||||
}
|
}
|
||||||
} else if (_children.size() == 1) {
|
} else if (_children.size() == 1) {
|
||||||
_poses = _children[0]->evaluate(animVars, dt, triggersOut);
|
_poses = _children[0]->evaluate(animVars, context, dt, triggersOut);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
float clampedAlpha = glm::clamp(_alpha, 0.0f, (float)(_children.size() - 1));
|
float clampedAlpha = glm::clamp(_alpha, 0.0f, (float)(_children.size() - 1));
|
||||||
|
@ -41,7 +41,7 @@ const AnimPoseVec& AnimBlendLinear::evaluate(const AnimVariantMap& animVars, flo
|
||||||
size_t nextPoseIndex = glm::ceil(clampedAlpha);
|
size_t nextPoseIndex = glm::ceil(clampedAlpha);
|
||||||
float alpha = glm::fract(clampedAlpha);
|
float alpha = glm::fract(clampedAlpha);
|
||||||
|
|
||||||
evaluateAndBlendChildren(animVars, triggersOut, alpha, prevPoseIndex, nextPoseIndex, dt);
|
evaluateAndBlendChildren(animVars, context, triggersOut, alpha, prevPoseIndex, nextPoseIndex, dt);
|
||||||
}
|
}
|
||||||
return _poses;
|
return _poses;
|
||||||
}
|
}
|
||||||
|
@ -51,15 +51,15 @@ const AnimPoseVec& AnimBlendLinear::getPosesInternal() const {
|
||||||
return _poses;
|
return _poses;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimBlendLinear::evaluateAndBlendChildren(const AnimVariantMap& animVars, Triggers& triggersOut, float alpha,
|
void AnimBlendLinear::evaluateAndBlendChildren(const AnimVariantMap& animVars, const AnimContext& context, Triggers& triggersOut, float alpha,
|
||||||
size_t prevPoseIndex, size_t nextPoseIndex, float dt) {
|
size_t prevPoseIndex, size_t nextPoseIndex, float dt) {
|
||||||
if (prevPoseIndex == nextPoseIndex) {
|
if (prevPoseIndex == nextPoseIndex) {
|
||||||
// this can happen if alpha is on an integer boundary
|
// this can happen if alpha is on an integer boundary
|
||||||
_poses = _children[prevPoseIndex]->evaluate(animVars, dt, triggersOut);
|
_poses = _children[prevPoseIndex]->evaluate(animVars, context, dt, triggersOut);
|
||||||
} else {
|
} else {
|
||||||
// need to eval and blend between two children.
|
// need to eval and blend between two children.
|
||||||
auto prevPoses = _children[prevPoseIndex]->evaluate(animVars, dt, triggersOut);
|
auto prevPoses = _children[prevPoseIndex]->evaluate(animVars, context, dt, triggersOut);
|
||||||
auto nextPoses = _children[nextPoseIndex]->evaluate(animVars, dt, triggersOut);
|
auto nextPoses = _children[nextPoseIndex]->evaluate(animVars, context, dt, triggersOut);
|
||||||
|
|
||||||
if (prevPoses.size() > 0 && prevPoses.size() == nextPoses.size()) {
|
if (prevPoses.size() > 0 && prevPoses.size() == nextPoses.size()) {
|
||||||
_poses.resize(prevPoses.size());
|
_poses.resize(prevPoses.size());
|
||||||
|
|
|
@ -30,7 +30,7 @@ public:
|
||||||
AnimBlendLinear(const QString& id, float alpha);
|
AnimBlendLinear(const QString& id, float alpha);
|
||||||
virtual ~AnimBlendLinear() override;
|
virtual ~AnimBlendLinear() override;
|
||||||
|
|
||||||
virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) override;
|
virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut) override;
|
||||||
|
|
||||||
void setAlphaVar(const QString& alphaVar) { _alphaVar = alphaVar; }
|
void setAlphaVar(const QString& alphaVar) { _alphaVar = alphaVar; }
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ protected:
|
||||||
// for AnimDebugDraw rendering
|
// for AnimDebugDraw rendering
|
||||||
virtual const AnimPoseVec& getPosesInternal() const override;
|
virtual const AnimPoseVec& getPosesInternal() const override;
|
||||||
|
|
||||||
void evaluateAndBlendChildren(const AnimVariantMap& animVars, Triggers& triggersOut, float alpha,
|
void evaluateAndBlendChildren(const AnimVariantMap& animVars, const AnimContext& context, Triggers& triggersOut, float alpha,
|
||||||
size_t prevPoseIndex, size_t nextPoseIndex, float dt);
|
size_t prevPoseIndex, size_t nextPoseIndex, float dt);
|
||||||
|
|
||||||
AnimPoseVec _poses;
|
AnimPoseVec _poses;
|
||||||
|
|
|
@ -26,7 +26,7 @@ AnimBlendLinearMove::~AnimBlendLinearMove() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const AnimPoseVec& AnimBlendLinearMove::evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) {
|
const AnimPoseVec& AnimBlendLinearMove::evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut) {
|
||||||
|
|
||||||
assert(_children.size() == _characteristicSpeeds.size());
|
assert(_children.size() == _characteristicSpeeds.size());
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ const AnimPoseVec& AnimBlendLinearMove::evaluate(const AnimVariantMap& animVars,
|
||||||
const int nextPoseIndex = 0;
|
const int nextPoseIndex = 0;
|
||||||
float prevDeltaTime, nextDeltaTime;
|
float prevDeltaTime, nextDeltaTime;
|
||||||
setFrameAndPhase(dt, alpha, prevPoseIndex, nextPoseIndex, &prevDeltaTime, &nextDeltaTime, triggersOut);
|
setFrameAndPhase(dt, alpha, prevPoseIndex, nextPoseIndex, &prevDeltaTime, &nextDeltaTime, triggersOut);
|
||||||
evaluateAndBlendChildren(animVars, triggersOut, alpha, prevPoseIndex, nextPoseIndex, prevDeltaTime, nextDeltaTime);
|
evaluateAndBlendChildren(animVars, context, triggersOut, alpha, prevPoseIndex, nextPoseIndex, prevDeltaTime, nextDeltaTime);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
auto clampedAlpha = glm::clamp(_alpha, 0.0f, (float)(_children.size() - 1));
|
auto clampedAlpha = glm::clamp(_alpha, 0.0f, (float)(_children.size() - 1));
|
||||||
|
@ -52,7 +52,7 @@ const AnimPoseVec& AnimBlendLinearMove::evaluate(const AnimVariantMap& animVars,
|
||||||
auto alpha = glm::fract(clampedAlpha);
|
auto alpha = glm::fract(clampedAlpha);
|
||||||
float prevDeltaTime, nextDeltaTime;
|
float prevDeltaTime, nextDeltaTime;
|
||||||
setFrameAndPhase(dt, alpha, prevPoseIndex, nextPoseIndex, &prevDeltaTime, &nextDeltaTime, triggersOut);
|
setFrameAndPhase(dt, alpha, prevPoseIndex, nextPoseIndex, &prevDeltaTime, &nextDeltaTime, triggersOut);
|
||||||
evaluateAndBlendChildren(animVars, triggersOut, alpha, prevPoseIndex, nextPoseIndex, prevDeltaTime, nextDeltaTime);
|
evaluateAndBlendChildren(animVars, context, triggersOut, alpha, prevPoseIndex, nextPoseIndex, prevDeltaTime, nextDeltaTime);
|
||||||
}
|
}
|
||||||
return _poses;
|
return _poses;
|
||||||
}
|
}
|
||||||
|
@ -62,16 +62,16 @@ const AnimPoseVec& AnimBlendLinearMove::getPosesInternal() const {
|
||||||
return _poses;
|
return _poses;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimBlendLinearMove::evaluateAndBlendChildren(const AnimVariantMap& animVars, Triggers& triggersOut, float alpha,
|
void AnimBlendLinearMove::evaluateAndBlendChildren(const AnimVariantMap& animVars, const AnimContext& context, Triggers& triggersOut, float alpha,
|
||||||
size_t prevPoseIndex, size_t nextPoseIndex,
|
size_t prevPoseIndex, size_t nextPoseIndex,
|
||||||
float prevDeltaTime, float nextDeltaTime) {
|
float prevDeltaTime, float nextDeltaTime) {
|
||||||
if (prevPoseIndex == nextPoseIndex) {
|
if (prevPoseIndex == nextPoseIndex) {
|
||||||
// this can happen if alpha is on an integer boundary
|
// this can happen if alpha is on an integer boundary
|
||||||
_poses = _children[prevPoseIndex]->evaluate(animVars, prevDeltaTime, triggersOut);
|
_poses = _children[prevPoseIndex]->evaluate(animVars, context, prevDeltaTime, triggersOut);
|
||||||
} else {
|
} else {
|
||||||
// need to eval and blend between two children.
|
// need to eval and blend between two children.
|
||||||
auto prevPoses = _children[prevPoseIndex]->evaluate(animVars, prevDeltaTime, triggersOut);
|
auto prevPoses = _children[prevPoseIndex]->evaluate(animVars, context, prevDeltaTime, triggersOut);
|
||||||
auto nextPoses = _children[nextPoseIndex]->evaluate(animVars, nextDeltaTime, triggersOut);
|
auto nextPoses = _children[nextPoseIndex]->evaluate(animVars, context, nextDeltaTime, triggersOut);
|
||||||
|
|
||||||
if (prevPoses.size() > 0 && prevPoses.size() == nextPoses.size()) {
|
if (prevPoses.size() > 0 && prevPoses.size() == nextPoses.size()) {
|
||||||
_poses.resize(prevPoses.size());
|
_poses.resize(prevPoses.size());
|
||||||
|
|
|
@ -39,7 +39,7 @@ public:
|
||||||
AnimBlendLinearMove(const QString& id, float alpha, float desiredSpeed, const std::vector<float>& characteristicSpeeds);
|
AnimBlendLinearMove(const QString& id, float alpha, float desiredSpeed, const std::vector<float>& characteristicSpeeds);
|
||||||
virtual ~AnimBlendLinearMove() override;
|
virtual ~AnimBlendLinearMove() override;
|
||||||
|
|
||||||
virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) override;
|
virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut) override;
|
||||||
|
|
||||||
void setAlphaVar(const QString& alphaVar) { _alphaVar = alphaVar; }
|
void setAlphaVar(const QString& alphaVar) { _alphaVar = alphaVar; }
|
||||||
void setDesiredSpeedVar(const QString& desiredSpeedVar) { _desiredSpeedVar = desiredSpeedVar; }
|
void setDesiredSpeedVar(const QString& desiredSpeedVar) { _desiredSpeedVar = desiredSpeedVar; }
|
||||||
|
@ -48,7 +48,7 @@ protected:
|
||||||
// for AnimDebugDraw rendering
|
// for AnimDebugDraw rendering
|
||||||
virtual const AnimPoseVec& getPosesInternal() const override;
|
virtual const AnimPoseVec& getPosesInternal() const override;
|
||||||
|
|
||||||
void evaluateAndBlendChildren(const AnimVariantMap& animVars, Triggers& triggersOut, float alpha,
|
void evaluateAndBlendChildren(const AnimVariantMap& animVars, const AnimContext& context, Triggers& triggersOut, float alpha,
|
||||||
size_t prevPoseIndex, size_t nextPoseIndex,
|
size_t prevPoseIndex, size_t nextPoseIndex,
|
||||||
float prevDeltaTime, float nextDeltaTime);
|
float prevDeltaTime, float nextDeltaTime);
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ AnimClip::~AnimClip() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const AnimPoseVec& AnimClip::evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) {
|
const AnimPoseVec& AnimClip::evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut) {
|
||||||
|
|
||||||
// lookup parameters from animVars, using current instance variables as defaults.
|
// lookup parameters from animVars, using current instance variables as defaults.
|
||||||
_startFrame = animVars.lookup(_startFrameVar, _startFrame);
|
_startFrame = animVars.lookup(_startFrameVar, _startFrame);
|
||||||
|
|
|
@ -30,7 +30,7 @@ public:
|
||||||
AnimClip(const QString& id, const QString& url, float startFrame, float endFrame, float timeScale, bool loopFlag, bool mirrorFlag);
|
AnimClip(const QString& id, const QString& url, float startFrame, float endFrame, float timeScale, bool loopFlag, bool mirrorFlag);
|
||||||
virtual ~AnimClip() override;
|
virtual ~AnimClip() override;
|
||||||
|
|
||||||
virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) override;
|
virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut) override;
|
||||||
|
|
||||||
void setStartFrameVar(const QString& startFrameVar) { _startFrameVar = startFrameVar; }
|
void setStartFrameVar(const QString& startFrameVar) { _startFrameVar = startFrameVar; }
|
||||||
void setEndFrameVar(const QString& endFrameVar) { _endFrameVar = endFrameVar; }
|
void setEndFrameVar(const QString& endFrameVar) { _endFrameVar = endFrameVar; }
|
||||||
|
|
16
libraries/animation/src/AnimContext.cpp
Normal file
16
libraries/animation/src/AnimContext.cpp
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
//
|
||||||
|
// AnimContext.cpp
|
||||||
|
//
|
||||||
|
// Created by Anthony J. Thibault on 9/19/16.
|
||||||
|
// Copyright (c) 2016 High Fidelity, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "AnimContext.h"
|
||||||
|
|
||||||
|
AnimContext::AnimContext(bool enableDebugDrawIKTargets, const glm::mat4& geometryToRigMatrix) :
|
||||||
|
_enableDebugDrawIKTargets(enableDebugDrawIKTargets),
|
||||||
|
_geometryToRigMatrix(geometryToRigMatrix) {
|
||||||
|
}
|
30
libraries/animation/src/AnimContext.h
Normal file
30
libraries/animation/src/AnimContext.h
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
//
|
||||||
|
// AnimContext.h
|
||||||
|
//
|
||||||
|
// Created by Anthony J. Thibault on 9/19/16.
|
||||||
|
// Copyright (c) 2016 High Fidelity, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef hifi_AnimContext_h
|
||||||
|
#define hifi_AnimContext_h
|
||||||
|
|
||||||
|
#include <glm/glm.hpp>
|
||||||
|
#include <glm/gtc/quaternion.hpp>
|
||||||
|
|
||||||
|
class AnimContext {
|
||||||
|
public:
|
||||||
|
AnimContext(bool enableDebugDrawIKTargets, const glm::mat4& geometryToRigMatrix);
|
||||||
|
|
||||||
|
bool getEnableDebugDrawIKTargets() const { return _enableDebugDrawIKTargets; }
|
||||||
|
const glm::mat4& getGeometryToRigMatrix() const { return _geometryToRigMatrix; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
bool _enableDebugDrawIKTargets { false };
|
||||||
|
glm::mat4 _geometryToRigMatrix;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // hifi_AnimContext_h
|
|
@ -14,6 +14,8 @@
|
||||||
#include <NumericalConstants.h>
|
#include <NumericalConstants.h>
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
#include <shared/NsightHelpers.h>
|
#include <shared/NsightHelpers.h>
|
||||||
|
#include <DebugDraw.h>
|
||||||
|
#include "Rig.h"
|
||||||
|
|
||||||
#include "ElbowConstraint.h"
|
#include "ElbowConstraint.h"
|
||||||
#include "SwingTwistConstraint.h"
|
#include "SwingTwistConstraint.h"
|
||||||
|
@ -378,14 +380,14 @@ int AnimInverseKinematics::solveTargetWithCCD(const IKTarget& target, AnimPoseVe
|
||||||
}
|
}
|
||||||
|
|
||||||
//virtual
|
//virtual
|
||||||
const AnimPoseVec& AnimInverseKinematics::evaluate(const AnimVariantMap& animVars, float dt, AnimNode::Triggers& triggersOut) {
|
const AnimPoseVec& AnimInverseKinematics::evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, AnimNode::Triggers& triggersOut) {
|
||||||
// don't call this function, call overlay() instead
|
// don't call this function, call overlay() instead
|
||||||
assert(false);
|
assert(false);
|
||||||
return _relativePoses;
|
return _relativePoses;
|
||||||
}
|
}
|
||||||
|
|
||||||
//virtual
|
//virtual
|
||||||
const AnimPoseVec& AnimInverseKinematics::overlay(const AnimVariantMap& animVars, float dt, Triggers& triggersOut, const AnimPoseVec& underPoses) {
|
const AnimPoseVec& AnimInverseKinematics::overlay(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut, const AnimPoseVec& underPoses) {
|
||||||
|
|
||||||
const float MAX_OVERLAY_DT = 1.0f / 30.0f; // what to clamp delta-time to in AnimInverseKinematics::overlay
|
const float MAX_OVERLAY_DT = 1.0f / 30.0f; // what to clamp delta-time to in AnimInverseKinematics::overlay
|
||||||
if (dt > MAX_OVERLAY_DT) {
|
if (dt > MAX_OVERLAY_DT) {
|
||||||
|
@ -439,6 +441,28 @@ const AnimPoseVec& AnimInverseKinematics::overlay(const AnimVariantMap& animVars
|
||||||
computeTargets(animVars, targets, underPoses);
|
computeTargets(animVars, targets, underPoses);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// debug render ik targets
|
||||||
|
if (context.getEnableDebugDrawIKTargets()) {
|
||||||
|
const vec4 WHITE(1.0f);
|
||||||
|
glm::mat4 rigToAvatarMat = createMatFromQuatAndPos(Quaternions::Y_180, glm::vec3());
|
||||||
|
|
||||||
|
for (auto& target : targets) {
|
||||||
|
glm::mat4 geomTargetMat = createMatFromQuatAndPos(target.getRotation(), target.getTranslation());
|
||||||
|
glm::mat4 avatarTargetMat = rigToAvatarMat * context.getGeometryToRigMatrix() * geomTargetMat;
|
||||||
|
|
||||||
|
QString name = QString("ikTarget%1").arg(target.getIndex());
|
||||||
|
DebugDraw::getInstance().addMyAvatarMarker(name, glmExtractRotation(avatarTargetMat), extractTranslation(avatarTargetMat), WHITE);
|
||||||
|
}
|
||||||
|
} else if (context.getEnableDebugDrawIKTargets() != _previousEnableDebugIKTargets) {
|
||||||
|
// remove markers if they were added last frame.
|
||||||
|
for (auto& target : targets) {
|
||||||
|
QString name = QString("ikTarget%1").arg(target.getIndex());
|
||||||
|
DebugDraw::getInstance().removeMyAvatarMarker(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_previousEnableDebugIKTargets = context.getEnableDebugDrawIKTargets();
|
||||||
|
|
||||||
if (targets.empty()) {
|
if (targets.empty()) {
|
||||||
// no IK targets but still need to enforce constraints
|
// no IK targets but still need to enforce constraints
|
||||||
std::map<int, RotationConstraint*>::iterator constraintItr = _constraints.begin();
|
std::map<int, RotationConstraint*>::iterator constraintItr = _constraints.begin();
|
||||||
|
|
|
@ -34,8 +34,8 @@ public:
|
||||||
|
|
||||||
void setTargetVars(const QString& jointName, const QString& positionVar, const QString& rotationVar, const QString& typeVar);
|
void setTargetVars(const QString& jointName, const QString& positionVar, const QString& rotationVar, const QString& typeVar);
|
||||||
|
|
||||||
virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, float dt, AnimNode::Triggers& triggersOut) override;
|
virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, AnimNode::Triggers& triggersOut) override;
|
||||||
virtual const AnimPoseVec& overlay(const AnimVariantMap& animVars, float dt, Triggers& triggersOut, const AnimPoseVec& underPoses) override;
|
virtual const AnimPoseVec& overlay(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut, const AnimPoseVec& underPoses) override;
|
||||||
|
|
||||||
void clearIKJointLimitHistory();
|
void clearIKJointLimitHistory();
|
||||||
|
|
||||||
|
@ -97,6 +97,7 @@ protected:
|
||||||
int _maxTargetIndex { 0 };
|
int _maxTargetIndex { 0 };
|
||||||
|
|
||||||
float _maxErrorOnLastSolve { FLT_MAX };
|
float _maxErrorOnLastSolve { FLT_MAX };
|
||||||
|
bool _previousEnableDebugIKTargets { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_AnimInverseKinematics_h
|
#endif // hifi_AnimInverseKinematics_h
|
||||||
|
|
|
@ -22,11 +22,11 @@ AnimManipulator::~AnimManipulator() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const AnimPoseVec& AnimManipulator::evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) {
|
const AnimPoseVec& AnimManipulator::evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut) {
|
||||||
return overlay(animVars, dt, triggersOut, _skeleton->getRelativeBindPoses());
|
return overlay(animVars, context, dt, triggersOut, _skeleton->getRelativeBindPoses());
|
||||||
}
|
}
|
||||||
|
|
||||||
const AnimPoseVec& AnimManipulator::overlay(const AnimVariantMap& animVars, float dt, Triggers& triggersOut, const AnimPoseVec& underPoses) {
|
const AnimPoseVec& AnimManipulator::overlay(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut, const AnimPoseVec& underPoses) {
|
||||||
_alpha = animVars.lookup(_alphaVar, _alpha);
|
_alpha = animVars.lookup(_alphaVar, _alpha);
|
||||||
|
|
||||||
_poses = underPoses;
|
_poses = underPoses;
|
||||||
|
|
|
@ -22,8 +22,8 @@ public:
|
||||||
AnimManipulator(const QString& id, float alpha);
|
AnimManipulator(const QString& id, float alpha);
|
||||||
virtual ~AnimManipulator() override;
|
virtual ~AnimManipulator() override;
|
||||||
|
|
||||||
virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) override;
|
virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut) override;
|
||||||
virtual const AnimPoseVec& overlay(const AnimVariantMap& animVars, float dt, Triggers& triggersOut, const AnimPoseVec& underPoses) override;
|
virtual const AnimPoseVec& overlay(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut, const AnimPoseVec& underPoses) override;
|
||||||
|
|
||||||
void setAlphaVar(const QString& alphaVar) { _alphaVar = alphaVar; }
|
void setAlphaVar(const QString& alphaVar) { _alphaVar = alphaVar; }
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include "AnimSkeleton.h"
|
#include "AnimSkeleton.h"
|
||||||
#include "AnimVariant.h"
|
#include "AnimVariant.h"
|
||||||
|
#include "AnimContext.h"
|
||||||
|
|
||||||
class QJsonObject;
|
class QJsonObject;
|
||||||
|
|
||||||
|
@ -72,9 +73,10 @@ public:
|
||||||
|
|
||||||
AnimSkeleton::ConstPointer getSkeleton() const { return _skeleton; }
|
AnimSkeleton::ConstPointer getSkeleton() const { return _skeleton; }
|
||||||
|
|
||||||
virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) = 0;
|
virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut) = 0;
|
||||||
virtual const AnimPoseVec& overlay(const AnimVariantMap& animVars, float dt, Triggers& triggersOut, const AnimPoseVec& underPoses) {
|
virtual const AnimPoseVec& overlay(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut,
|
||||||
return evaluate(animVars, dt, triggersOut);
|
const AnimPoseVec& underPoses) {
|
||||||
|
return evaluate(animVars, context, dt, triggersOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCurrentFrame(float frame);
|
void setCurrentFrame(float frame);
|
||||||
|
|
|
@ -39,7 +39,7 @@ void AnimOverlay::buildBoneSet(BoneSet boneSet) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const AnimPoseVec& AnimOverlay::evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) {
|
const AnimPoseVec& AnimOverlay::evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut) {
|
||||||
|
|
||||||
// lookup parameters from animVars, using current instance variables as defaults.
|
// lookup parameters from animVars, using current instance variables as defaults.
|
||||||
// NOTE: switching bonesets can be an expensive operation, let's try to avoid it.
|
// NOTE: switching bonesets can be an expensive operation, let's try to avoid it.
|
||||||
|
@ -51,8 +51,8 @@ const AnimPoseVec& AnimOverlay::evaluate(const AnimVariantMap& animVars, float d
|
||||||
_alpha = animVars.lookup(_alphaVar, _alpha);
|
_alpha = animVars.lookup(_alphaVar, _alpha);
|
||||||
|
|
||||||
if (_children.size() >= 2) {
|
if (_children.size() >= 2) {
|
||||||
auto& underPoses = _children[1]->evaluate(animVars, dt, triggersOut);
|
auto& underPoses = _children[1]->evaluate(animVars, context, dt, triggersOut);
|
||||||
auto& overPoses = _children[0]->overlay(animVars, dt, triggersOut, underPoses);
|
auto& overPoses = _children[0]->overlay(animVars, context, dt, triggersOut, underPoses);
|
||||||
|
|
||||||
if (underPoses.size() > 0 && underPoses.size() == overPoses.size()) {
|
if (underPoses.size() > 0 && underPoses.size() == overPoses.size()) {
|
||||||
_poses.resize(underPoses.size());
|
_poses.resize(underPoses.size());
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
AnimOverlay(const QString& id, BoneSet boneSet, float alpha);
|
AnimOverlay(const QString& id, BoneSet boneSet, float alpha);
|
||||||
virtual ~AnimOverlay() override;
|
virtual ~AnimOverlay() override;
|
||||||
|
|
||||||
virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) override;
|
virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut) override;
|
||||||
|
|
||||||
void setBoneSetVar(const QString& boneSetVar) { _boneSetVar = boneSetVar; }
|
void setBoneSetVar(const QString& boneSetVar) { _boneSetVar = boneSetVar; }
|
||||||
void setAlphaVar(const QString& alphaVar) { _alphaVar = alphaVar; }
|
void setAlphaVar(const QString& alphaVar) { _alphaVar = alphaVar; }
|
||||||
|
|
|
@ -21,7 +21,7 @@ AnimStateMachine::~AnimStateMachine() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const AnimPoseVec& AnimStateMachine::evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) {
|
const AnimPoseVec& AnimStateMachine::evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut) {
|
||||||
|
|
||||||
QString desiredStateID = animVars.lookup(_currentStateVar, _currentState->getID());
|
QString desiredStateID = animVars.lookup(_currentStateVar, _currentState->getID());
|
||||||
if (_currentState->getID() != desiredStateID) {
|
if (_currentState->getID() != desiredStateID) {
|
||||||
|
@ -29,7 +29,7 @@ const AnimPoseVec& AnimStateMachine::evaluate(const AnimVariantMap& animVars, fl
|
||||||
bool foundState = false;
|
bool foundState = false;
|
||||||
for (auto& state : _states) {
|
for (auto& state : _states) {
|
||||||
if (state->getID() == desiredStateID) {
|
if (state->getID() == desiredStateID) {
|
||||||
switchState(animVars, state);
|
switchState(animVars, context, state);
|
||||||
foundState = true;
|
foundState = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ const AnimPoseVec& AnimStateMachine::evaluate(const AnimVariantMap& animVars, fl
|
||||||
// evaluate currentState transitions
|
// evaluate currentState transitions
|
||||||
auto desiredState = evaluateTransitions(animVars);
|
auto desiredState = evaluateTransitions(animVars);
|
||||||
if (desiredState != _currentState) {
|
if (desiredState != _currentState) {
|
||||||
switchState(animVars, desiredState);
|
switchState(animVars, context, desiredState);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(_currentState);
|
assert(_currentState);
|
||||||
|
@ -62,7 +62,7 @@ const AnimPoseVec& AnimStateMachine::evaluate(const AnimVariantMap& animVars, fl
|
||||||
} else if (_interpType == InterpType::SnapshotPrev) {
|
} else if (_interpType == InterpType::SnapshotPrev) {
|
||||||
// interp between the prev snapshot and evaluated next target.
|
// interp between the prev snapshot and evaluated next target.
|
||||||
// this is useful for interping into a blend
|
// this is useful for interping into a blend
|
||||||
localNextPoses = currentStateNode->evaluate(animVars, dt, triggersOut);
|
localNextPoses = currentStateNode->evaluate(animVars, context, dt, triggersOut);
|
||||||
prevPoses = &_prevPoses;
|
prevPoses = &_prevPoses;
|
||||||
nextPoses = &localNextPoses;
|
nextPoses = &localNextPoses;
|
||||||
} else {
|
} else {
|
||||||
|
@ -79,7 +79,7 @@ const AnimPoseVec& AnimStateMachine::evaluate(const AnimVariantMap& animVars, fl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!_duringInterp) {
|
if (!_duringInterp) {
|
||||||
_poses = currentStateNode->evaluate(animVars, dt, triggersOut);
|
_poses = currentStateNode->evaluate(animVars, context, dt, triggersOut);
|
||||||
}
|
}
|
||||||
return _poses;
|
return _poses;
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ void AnimStateMachine::addState(State::Pointer state) {
|
||||||
_states.push_back(state);
|
_states.push_back(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimStateMachine::switchState(const AnimVariantMap& animVars, State::Pointer desiredState) {
|
void AnimStateMachine::switchState(const AnimVariantMap& animVars, const AnimContext& context, State::Pointer desiredState) {
|
||||||
|
|
||||||
const float FRAMES_PER_SECOND = 30.0f;
|
const float FRAMES_PER_SECOND = 30.0f;
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ void AnimStateMachine::switchState(const AnimVariantMap& animVars, State::Pointe
|
||||||
_prevPoses = _poses;
|
_prevPoses = _poses;
|
||||||
// snapshot next pose at the target frame.
|
// snapshot next pose at the target frame.
|
||||||
nextStateNode->setCurrentFrame(desiredState->_interpTarget);
|
nextStateNode->setCurrentFrame(desiredState->_interpTarget);
|
||||||
_nextPoses = nextStateNode->evaluate(animVars, dt, triggers);
|
_nextPoses = nextStateNode->evaluate(animVars, context, dt, triggers);
|
||||||
} else if (_interpType == InterpType::SnapshotPrev) {
|
} else if (_interpType == InterpType::SnapshotPrev) {
|
||||||
// snapshot previoius pose
|
// snapshot previoius pose
|
||||||
_prevPoses = _poses;
|
_prevPoses = _poses;
|
||||||
|
|
|
@ -113,7 +113,7 @@ public:
|
||||||
explicit AnimStateMachine(const QString& id);
|
explicit AnimStateMachine(const QString& id);
|
||||||
virtual ~AnimStateMachine() override;
|
virtual ~AnimStateMachine() override;
|
||||||
|
|
||||||
virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) override;
|
virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut) override;
|
||||||
|
|
||||||
void setCurrentStateVar(QString& currentStateVar) { _currentStateVar = currentStateVar; }
|
void setCurrentStateVar(QString& currentStateVar) { _currentStateVar = currentStateVar; }
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ protected:
|
||||||
|
|
||||||
void addState(State::Pointer state);
|
void addState(State::Pointer state);
|
||||||
|
|
||||||
void switchState(const AnimVariantMap& animVars, State::Pointer desiredState);
|
void switchState(const AnimVariantMap& animVars, const AnimContext& context, State::Pointer desiredState);
|
||||||
State::Pointer evaluateTransitions(const AnimVariantMap& animVars) const;
|
State::Pointer evaluateTransitions(const AnimVariantMap& animVars) const;
|
||||||
|
|
||||||
// for AnimDebugDraw rendering
|
// for AnimDebugDraw rendering
|
||||||
|
|
|
@ -950,9 +950,11 @@ void Rig::updateAnimations(float deltaTime, glm::mat4 rootTransform) {
|
||||||
updateAnimationStateHandlers();
|
updateAnimationStateHandlers();
|
||||||
_animVars.setRigToGeometryTransform(_rigToGeometryTransform);
|
_animVars.setRigToGeometryTransform(_rigToGeometryTransform);
|
||||||
|
|
||||||
|
AnimContext context(_enableDebugDrawIKTargets, getGeometryToRigTransform());
|
||||||
|
|
||||||
// evaluate the animation
|
// evaluate the animation
|
||||||
AnimNode::Triggers triggersOut;
|
AnimNode::Triggers triggersOut;
|
||||||
_internalPoseSet._relativePoses = _animNode->evaluate(_animVars, deltaTime, triggersOut);
|
_internalPoseSet._relativePoses = _animNode->evaluate(_animVars, context, deltaTime, triggersOut);
|
||||||
if ((int)_internalPoseSet._relativePoses.size() != _animSkeleton->getNumJoints()) {
|
if ((int)_internalPoseSet._relativePoses.size() != _animSkeleton->getNumJoints()) {
|
||||||
// animations haven't fully loaded yet.
|
// animations haven't fully loaded yet.
|
||||||
_internalPoseSet._relativePoses = _animSkeleton->getRelativeDefaultPoses();
|
_internalPoseSet._relativePoses = _animSkeleton->getRelativeDefaultPoses();
|
||||||
|
@ -1427,9 +1429,10 @@ void Rig::computeAvatarBoundingCapsule(
|
||||||
|
|
||||||
// call overlay twice: once to verify AnimPoseVec joints and again to do the IK
|
// call overlay twice: once to verify AnimPoseVec joints and again to do the IK
|
||||||
AnimNode::Triggers triggersOut;
|
AnimNode::Triggers triggersOut;
|
||||||
|
AnimContext context(false, glm::mat4());
|
||||||
float dt = 1.0f; // the value of this does not matter
|
float dt = 1.0f; // the value of this does not matter
|
||||||
ikNode.overlay(animVars, dt, triggersOut, _animSkeleton->getRelativeBindPoses());
|
ikNode.overlay(animVars, context, dt, triggersOut, _animSkeleton->getRelativeBindPoses());
|
||||||
AnimPoseVec finalPoses = ikNode.overlay(animVars, dt, triggersOut, _animSkeleton->getRelativeBindPoses());
|
AnimPoseVec finalPoses = ikNode.overlay(animVars, context, dt, triggersOut, _animSkeleton->getRelativeBindPoses());
|
||||||
|
|
||||||
// convert relative poses to absolute
|
// convert relative poses to absolute
|
||||||
_animSkeleton->convertRelativePosesToAbsolute(finalPoses);
|
_animSkeleton->convertRelativePosesToAbsolute(finalPoses);
|
||||||
|
|
|
@ -219,6 +219,8 @@ public:
|
||||||
|
|
||||||
const glm::mat4& getGeometryToRigTransform() const { return _geometryToRigTransform; }
|
const glm::mat4& getGeometryToRigTransform() const { return _geometryToRigTransform; }
|
||||||
|
|
||||||
|
void setEnableDebugDrawIKTargets(bool enableDebugDrawIKTargets) { _enableDebugDrawIKTargets = enableDebugDrawIKTargets; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void onLoadComplete();
|
void onLoadComplete();
|
||||||
|
|
||||||
|
@ -324,7 +326,8 @@ protected:
|
||||||
|
|
||||||
mutable uint32_t _jointNameWarningCount { 0 };
|
mutable uint32_t _jointNameWarningCount { 0 };
|
||||||
float _maxHipsOffsetLength { 1.0f };
|
float _maxHipsOffsetLength { 1.0f };
|
||||||
float _maxErrorOnLastSolve { 0.0f };
|
|
||||||
|
bool _enableDebugDrawIKTargets { false };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMap<int, StateHandler> _stateHandlers;
|
QMap<int, StateHandler> _stateHandlers;
|
||||||
|
|
|
@ -608,7 +608,6 @@ RayToEntityIntersectionResult EntityTreeRenderer::findRayIntersectionWorker(cons
|
||||||
(void**)&intersectedEntity, lockType, &result.accurate);
|
(void**)&intersectedEntity, lockType, &result.accurate);
|
||||||
if (result.intersects && intersectedEntity) {
|
if (result.intersects && intersectedEntity) {
|
||||||
result.entityID = intersectedEntity->getEntityItemID();
|
result.entityID = intersectedEntity->getEntityItemID();
|
||||||
result.properties = intersectedEntity->getProperties();
|
|
||||||
result.intersection = ray.origin + (ray.direction * result.distance);
|
result.intersection = ray.origin + (ray.direction * result.distance);
|
||||||
result.entity = intersectedEntity;
|
result.entity = intersectedEntity;
|
||||||
}
|
}
|
||||||
|
@ -704,7 +703,9 @@ void EntityTreeRenderer::mousePressEvent(QMouseEvent* event) {
|
||||||
if (rayPickResult.intersects) {
|
if (rayPickResult.intersects) {
|
||||||
//qCDebug(entitiesrenderer) << "mousePressEvent over entity:" << rayPickResult.entityID;
|
//qCDebug(entitiesrenderer) << "mousePressEvent over entity:" << rayPickResult.entityID;
|
||||||
|
|
||||||
QString urlString = rayPickResult.properties.getHref();
|
auto entity = getTree()->findEntityByEntityItemID(rayPickResult.entityID);
|
||||||
|
auto properties = entity->getProperties();
|
||||||
|
QString urlString = properties.getHref();
|
||||||
QUrl url = QUrl(urlString, QUrl::StrictMode);
|
QUrl url = QUrl(urlString, QUrl::StrictMode);
|
||||||
if (url.isValid() && !url.isEmpty()){
|
if (url.isValid() && !url.isEmpty()){
|
||||||
DependencyManager::get<AddressManager>()->handleLookupString(urlString);
|
DependencyManager::get<AddressManager>()->handleLookupString(urlString);
|
||||||
|
@ -750,12 +751,6 @@ void EntityTreeRenderer::mouseDoublePressEvent(QMouseEvent* event) {
|
||||||
if (rayPickResult.intersects) {
|
if (rayPickResult.intersects) {
|
||||||
//qCDebug(entitiesrenderer) << "mouseDoublePressEvent over entity:" << rayPickResult.entityID;
|
//qCDebug(entitiesrenderer) << "mouseDoublePressEvent over entity:" << rayPickResult.entityID;
|
||||||
|
|
||||||
QString urlString = rayPickResult.properties.getHref();
|
|
||||||
QUrl url = QUrl(urlString, QUrl::StrictMode);
|
|
||||||
if (url.isValid() && !url.isEmpty()){
|
|
||||||
DependencyManager::get<AddressManager>()->handleLookupString(urlString);
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::vec2 pos2D = projectOntoEntityXYPlane(rayPickResult.entity, ray, rayPickResult);
|
glm::vec2 pos2D = projectOntoEntityXYPlane(rayPickResult.entity, ray, rayPickResult);
|
||||||
PointerEvent pointerEvent(PointerEvent::Press, MOUSE_POINTER_ID,
|
PointerEvent pointerEvent(PointerEvent::Press, MOUSE_POINTER_ID,
|
||||||
pos2D, rayPickResult.intersection,
|
pos2D, rayPickResult.intersection,
|
||||||
|
|
|
@ -812,7 +812,7 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& shapeInfo) {
|
||||||
auto& meshes = _model->getGeometry()->getMeshes();
|
auto& meshes = _model->getGeometry()->getMeshes();
|
||||||
int32_t numMeshes = (int32_t)(meshes.size());
|
int32_t numMeshes = (int32_t)(meshes.size());
|
||||||
|
|
||||||
const int MAX_ALLOWED_MESH_COUNT = 500;
|
const int MAX_ALLOWED_MESH_COUNT = 1000;
|
||||||
if (numMeshes > MAX_ALLOWED_MESH_COUNT) {
|
if (numMeshes > MAX_ALLOWED_MESH_COUNT) {
|
||||||
// too many will cause the deadlock timer to throw...
|
// too many will cause the deadlock timer to throw...
|
||||||
shapeInfo.setParams(SHAPE_TYPE_BOX, 0.5f * dimensions);
|
shapeInfo.setParams(SHAPE_TYPE_BOX, 0.5f * dimensions);
|
||||||
|
|
|
@ -674,7 +674,6 @@ RayToEntityIntersectionResult EntityScriptingInterface::findRayIntersectionWorke
|
||||||
(void**)&intersectedEntity, lockType, &result.accurate);
|
(void**)&intersectedEntity, lockType, &result.accurate);
|
||||||
if (result.intersects && intersectedEntity) {
|
if (result.intersects && intersectedEntity) {
|
||||||
result.entityID = intersectedEntity->getEntityItemID();
|
result.entityID = intersectedEntity->getEntityItemID();
|
||||||
result.properties = intersectedEntity->getProperties();
|
|
||||||
result.intersection = ray.origin + (ray.direction * result.distance);
|
result.intersection = ray.origin + (ray.direction * result.distance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -839,7 +838,6 @@ RayToEntityIntersectionResult::RayToEntityIntersectionResult() :
|
||||||
intersects(false),
|
intersects(false),
|
||||||
accurate(true), // assume it's accurate
|
accurate(true), // assume it's accurate
|
||||||
entityID(),
|
entityID(),
|
||||||
properties(),
|
|
||||||
distance(0),
|
distance(0),
|
||||||
face(),
|
face(),
|
||||||
entity(NULL)
|
entity(NULL)
|
||||||
|
@ -855,9 +853,6 @@ QScriptValue RayToEntityIntersectionResultToScriptValue(QScriptEngine* engine, c
|
||||||
QScriptValue entityItemValue = EntityItemIDtoScriptValue(engine, value.entityID);
|
QScriptValue entityItemValue = EntityItemIDtoScriptValue(engine, value.entityID);
|
||||||
obj.setProperty("entityID", entityItemValue);
|
obj.setProperty("entityID", entityItemValue);
|
||||||
|
|
||||||
QScriptValue propertiesValue = EntityItemPropertiesToScriptValue(engine, value.properties);
|
|
||||||
obj.setProperty("properties", propertiesValue);
|
|
||||||
|
|
||||||
obj.setProperty("distance", value.distance);
|
obj.setProperty("distance", value.distance);
|
||||||
|
|
||||||
QString faceName = "";
|
QString faceName = "";
|
||||||
|
@ -903,10 +898,6 @@ void RayToEntityIntersectionResultFromScriptValue(const QScriptValue& object, Ra
|
||||||
QScriptValue entityIDValue = object.property("entityID");
|
QScriptValue entityIDValue = object.property("entityID");
|
||||||
// EntityItemIDfromScriptValue(entityIDValue, value.entityID);
|
// EntityItemIDfromScriptValue(entityIDValue, value.entityID);
|
||||||
quuidFromScriptValue(entityIDValue, value.entityID);
|
quuidFromScriptValue(entityIDValue, value.entityID);
|
||||||
QScriptValue entityPropertiesValue = object.property("properties");
|
|
||||||
if (entityPropertiesValue.isValid()) {
|
|
||||||
EntityItemPropertiesFromScriptValueHonorReadOnly(entityPropertiesValue, value.properties);
|
|
||||||
}
|
|
||||||
value.distance = object.property("distance").toVariant().toFloat();
|
value.distance = object.property("distance").toVariant().toFloat();
|
||||||
|
|
||||||
QString faceName = object.property("face").toVariant().toString();
|
QString faceName = object.property("face").toVariant().toString();
|
||||||
|
|
|
@ -58,7 +58,6 @@ public:
|
||||||
bool intersects;
|
bool intersects;
|
||||||
bool accurate;
|
bool accurate;
|
||||||
QUuid entityID;
|
QUuid entityID;
|
||||||
EntityItemProperties properties;
|
|
||||||
float distance;
|
float distance;
|
||||||
BoxFace face;
|
BoxFace face;
|
||||||
glm::vec3 intersection;
|
glm::vec3 intersection;
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
|
|
||||||
#include "GLTexture.h"
|
#include "GLTexture.h"
|
||||||
|
|
||||||
#include <NumericalConstants.h>
|
|
||||||
|
|
||||||
#include "GLBackend.h"
|
#include "GLBackend.h"
|
||||||
|
|
||||||
using namespace gpu;
|
using namespace gpu;
|
||||||
|
|
|
@ -72,7 +72,7 @@ GL41Texture::GL41Texture(const std::weak_ptr<GLBackend>& backend, const Texture&
|
||||||
incrementTextureGPUCount();
|
incrementTextureGPUCount();
|
||||||
withPreservedTexture([&] {
|
withPreservedTexture([&] {
|
||||||
GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat(), _gpuObject.getStoredMipFormat());
|
GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat(), _gpuObject.getStoredMipFormat());
|
||||||
auto numMips = _gpuObject.evalNumMips();
|
auto numMips = _gpuObject.getNumMipLevels();
|
||||||
for (uint16_t mipLevel = 0; mipLevel < numMips; ++mipLevel) {
|
for (uint16_t mipLevel = 0; mipLevel < numMips; ++mipLevel) {
|
||||||
// Get the mip level dimensions, accounting for the downgrade level
|
// Get the mip level dimensions, accounting for the downgrade level
|
||||||
Vec3u dimensions = _gpuObject.evalMipDimensions(mipLevel);
|
Vec3u dimensions = _gpuObject.evalMipDimensions(mipLevel);
|
||||||
|
|
|
@ -186,8 +186,10 @@ GL45FixedAllocationTexture::~GL45FixedAllocationTexture() {
|
||||||
void GL45FixedAllocationTexture::allocateStorage() const {
|
void GL45FixedAllocationTexture::allocateStorage() const {
|
||||||
const GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat());
|
const GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat());
|
||||||
const auto dimensions = _gpuObject.getDimensions();
|
const auto dimensions = _gpuObject.getDimensions();
|
||||||
const auto mips = _gpuObject.evalNumMips();
|
const auto mips = _gpuObject.getNumMipLevels();
|
||||||
|
|
||||||
glTextureStorage2D(_id, mips, texelFormat.internalFormat, dimensions.x, dimensions.y);
|
glTextureStorage2D(_id, mips, texelFormat.internalFormat, dimensions.x, dimensions.y);
|
||||||
|
glTextureParameteri(_id, GL_TEXTURE_BASE_LEVEL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GL45FixedAllocationTexture::syncSampler() const {
|
void GL45FixedAllocationTexture::syncSampler() const {
|
||||||
|
@ -214,7 +216,7 @@ GL45AttachmentTexture::~GL45AttachmentTexture() {
|
||||||
using GL45StrictResourceTexture = GL45Backend::GL45StrictResourceTexture;
|
using GL45StrictResourceTexture = GL45Backend::GL45StrictResourceTexture;
|
||||||
|
|
||||||
GL45StrictResourceTexture::GL45StrictResourceTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture) : GL45FixedAllocationTexture(backend, texture) {
|
GL45StrictResourceTexture::GL45StrictResourceTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture) : GL45FixedAllocationTexture(backend, texture) {
|
||||||
auto mipLevels = _gpuObject.evalNumMips();
|
auto mipLevels = _gpuObject.getNumMipLevels();
|
||||||
for (uint16_t sourceMip = 0; sourceMip < mipLevels; ++sourceMip) {
|
for (uint16_t sourceMip = 0; sourceMip < mipLevels; ++sourceMip) {
|
||||||
uint16_t targetMip = sourceMip;
|
uint16_t targetMip = sourceMip;
|
||||||
size_t maxFace = GLTexture::getFaceCount(_target);
|
size_t maxFace = GLTexture::getFaceCount(_target);
|
||||||
|
|
|
@ -461,10 +461,10 @@ void GL45ResourceTexture::allocateStorage(uint16 allocatedMip) {
|
||||||
_allocatedMip = allocatedMip;
|
_allocatedMip = allocatedMip;
|
||||||
const GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat());
|
const GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat());
|
||||||
const auto dimensions = _gpuObject.evalMipDimensions(_allocatedMip);
|
const auto dimensions = _gpuObject.evalMipDimensions(_allocatedMip);
|
||||||
const auto totalMips = _gpuObject.evalNumMips();
|
const auto totalMips = _gpuObject.getNumMipLevels();
|
||||||
const auto mips = totalMips - _allocatedMip;
|
const auto mips = totalMips - _allocatedMip;
|
||||||
glTextureStorage2D(_id, mips, texelFormat.internalFormat, dimensions.x, dimensions.y);
|
glTextureStorage2D(_id, mips, texelFormat.internalFormat, dimensions.x, dimensions.y);
|
||||||
auto mipLevels = _gpuObject.evalNumMips();
|
auto mipLevels = _gpuObject.getNumMipLevels();
|
||||||
_size = 0;
|
_size = 0;
|
||||||
for (uint16_t mip = _allocatedMip; mip < mipLevels; ++mip) {
|
for (uint16_t mip = _allocatedMip; mip < mipLevels; ++mip) {
|
||||||
_size += _gpuObject.evalMipSize(mip);
|
_size += _gpuObject.evalMipSize(mip);
|
||||||
|
@ -474,7 +474,7 @@ void GL45ResourceTexture::allocateStorage(uint16 allocatedMip) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GL45ResourceTexture::copyMipsFromTexture() {
|
void GL45ResourceTexture::copyMipsFromTexture() {
|
||||||
auto mipLevels = _gpuObject.evalNumMips();
|
auto mipLevels = _gpuObject.getNumMipLevels();
|
||||||
size_t maxFace = GLTexture::getFaceCount(_target);
|
size_t maxFace = GLTexture::getFaceCount(_target);
|
||||||
for (uint16_t sourceMip = _populatedMip; sourceMip < mipLevels; ++sourceMip) {
|
for (uint16_t sourceMip = _populatedMip; sourceMip < mipLevels; ++sourceMip) {
|
||||||
uint16_t targetMip = sourceMip - _allocatedMip;
|
uint16_t targetMip = sourceMip - _allocatedMip;
|
||||||
|
@ -499,7 +499,7 @@ void GL45ResourceTexture::promote() {
|
||||||
uint16_t oldAllocatedMip = _allocatedMip;
|
uint16_t oldAllocatedMip = _allocatedMip;
|
||||||
// allocate storage for new level
|
// allocate storage for new level
|
||||||
allocateStorage(_allocatedMip - std::min<uint16_t>(_allocatedMip, 2));
|
allocateStorage(_allocatedMip - std::min<uint16_t>(_allocatedMip, 2));
|
||||||
uint16_t mips = _gpuObject.evalNumMips();
|
uint16_t mips = _gpuObject.getNumMipLevels();
|
||||||
// copy pre-existing mips
|
// copy pre-existing mips
|
||||||
for (uint16_t mip = _populatedMip; mip < mips; ++mip) {
|
for (uint16_t mip = _populatedMip; mip < mips; ++mip) {
|
||||||
auto mipDimensions = _gpuObject.evalMipDimensions(mip);
|
auto mipDimensions = _gpuObject.evalMipDimensions(mip);
|
||||||
|
@ -532,7 +532,7 @@ void GL45ResourceTexture::demote() {
|
||||||
const_cast<GLuint&>(_id) = allocate(_gpuObject);
|
const_cast<GLuint&>(_id) = allocate(_gpuObject);
|
||||||
allocateStorage(_allocatedMip + 1);
|
allocateStorage(_allocatedMip + 1);
|
||||||
_populatedMip = std::max(_populatedMip, _allocatedMip);
|
_populatedMip = std::max(_populatedMip, _allocatedMip);
|
||||||
uint16_t mips = _gpuObject.evalNumMips();
|
uint16_t mips = _gpuObject.getNumMipLevels();
|
||||||
// copy pre-existing mips
|
// copy pre-existing mips
|
||||||
for (uint16_t mip = _populatedMip; mip < mips; ++mip) {
|
for (uint16_t mip = _populatedMip; mip < mips; ++mip) {
|
||||||
auto mipDimensions = _gpuObject.evalMipDimensions(mip);
|
auto mipDimensions = _gpuObject.evalMipDimensions(mip);
|
||||||
|
|
|
@ -418,8 +418,8 @@ public:
|
||||||
|
|
||||||
uint32 evalTotalSize(uint16 startingMip = 0) const {
|
uint32 evalTotalSize(uint16 startingMip = 0) const {
|
||||||
uint32 size = 0;
|
uint32 size = 0;
|
||||||
uint16 minMipLevel = std::max(minMip(), startingMip);
|
uint16 minMipLevel = std::max(getMinMip(), startingMip);
|
||||||
uint16 maxMipLevel = maxMip();
|
uint16 maxMipLevel = getMaxMip();
|
||||||
for (uint16 l = minMipLevel; l <= maxMipLevel; l++) {
|
for (uint16 l = minMipLevel; l <= maxMipLevel; l++) {
|
||||||
size += evalMipSize(l);
|
size += evalMipSize(l);
|
||||||
}
|
}
|
||||||
|
@ -429,12 +429,9 @@ public:
|
||||||
// max mip is in the range [ 0 if no sub mips, log2(max(width, height, depth))]
|
// max mip is in the range [ 0 if no sub mips, log2(max(width, height, depth))]
|
||||||
// if autoGenerateMip is on => will provide the maxMIp level specified
|
// if autoGenerateMip is on => will provide the maxMIp level specified
|
||||||
// else provide the deepest mip level provided through assignMip
|
// else provide the deepest mip level provided through assignMip
|
||||||
uint16 maxMip() const { return _maxMip; }
|
uint16 getMaxMip() const { return _maxMip; }
|
||||||
|
uint16 getMinMip() const { return _minMip; }
|
||||||
uint16 minMip() const { return _minMip; }
|
uint16 getNumMipLevels() const { return _maxMip + 1; }
|
||||||
|
|
||||||
uint16 mipLevels() const { return _maxMip + 1; }
|
|
||||||
|
|
||||||
uint16 usedMipLevels() const { return (_maxMip - _minMip) + 1; }
|
uint16 usedMipLevels() const { return (_maxMip - _minMip) + 1; }
|
||||||
|
|
||||||
const std::string& source() const { return _source; }
|
const std::string& source() const { return _source; }
|
||||||
|
|
|
@ -121,7 +121,7 @@ ktx::KTXUniquePointer Texture::serialize(const Texture& texture) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Number level of mips coming
|
// Number level of mips coming
|
||||||
header.numberOfMipmapLevels = texture.maxMip() + 1;
|
header.numberOfMipmapLevels = texture.getNumMipLevels();
|
||||||
|
|
||||||
ktx::Images images;
|
ktx::Images images;
|
||||||
for (uint32_t level = 0; level < header.numberOfMipmapLevels; level++) {
|
for (uint32_t level = 0; level < header.numberOfMipmapLevels; level++) {
|
||||||
|
|
|
@ -74,11 +74,11 @@ void AmbientOcclusionFramebuffer::allocate() {
|
||||||
auto width = _frameSize.x;
|
auto width = _frameSize.x;
|
||||||
auto height = _frameSize.y;
|
auto height = _frameSize.y;
|
||||||
|
|
||||||
_occlusionTexture = gpu::TexturePointer(gpu::Texture::create2D(gpu::Element::COLOR_RGBA_32, width, height, gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT)));
|
_occlusionTexture = gpu::TexturePointer(gpu::Texture::createRenderBuffer(gpu::Element::COLOR_RGBA_32, width, height, gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT)));
|
||||||
_occlusionFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("occlusion"));
|
_occlusionFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("occlusion"));
|
||||||
_occlusionFramebuffer->setRenderBuffer(0, _occlusionTexture);
|
_occlusionFramebuffer->setRenderBuffer(0, _occlusionTexture);
|
||||||
|
|
||||||
_occlusionBlurredTexture = gpu::TexturePointer(gpu::Texture::create2D(gpu::Element::COLOR_RGBA_32, width, height, gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT)));
|
_occlusionBlurredTexture = gpu::TexturePointer(gpu::Texture::createRenderBuffer(gpu::Element::COLOR_RGBA_32, width, height, gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT)));
|
||||||
_occlusionBlurredFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("occlusionBlurred"));
|
_occlusionBlurredFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("occlusionBlurred"));
|
||||||
_occlusionBlurredFramebuffer->setRenderBuffer(0, _occlusionBlurredTexture);
|
_occlusionBlurredFramebuffer->setRenderBuffer(0, _occlusionBlurredTexture);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,18 +72,18 @@ void LinearDepthFramebuffer::allocate() {
|
||||||
auto height = _frameSize.y;
|
auto height = _frameSize.y;
|
||||||
|
|
||||||
// For Linear Depth:
|
// For Linear Depth:
|
||||||
_linearDepthTexture = gpu::TexturePointer(gpu::Texture::createRenderBuffer(gpu::Element(gpu::SCALAR, gpu::FLOAT, gpu::RGB), width, height,
|
_linearDepthTexture = gpu::TexturePointer(gpu::Texture::createRenderBuffer(gpu::Element(gpu::SCALAR, gpu::FLOAT, gpu::RED), width, height,
|
||||||
gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT)));
|
gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT)));
|
||||||
_linearDepthFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("linearDepth"));
|
_linearDepthFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("linearDepth"));
|
||||||
_linearDepthFramebuffer->setRenderBuffer(0, _linearDepthTexture);
|
_linearDepthFramebuffer->setRenderBuffer(0, _linearDepthTexture);
|
||||||
_linearDepthFramebuffer->setDepthStencilBuffer(_primaryDepthTexture, _primaryDepthTexture->getTexelFormat());
|
_linearDepthFramebuffer->setDepthStencilBuffer(_primaryDepthTexture, _primaryDepthTexture->getTexelFormat());
|
||||||
|
|
||||||
// For Downsampling:
|
// For Downsampling:
|
||||||
_halfLinearDepthTexture = gpu::TexturePointer(gpu::Texture::createRenderBuffer(gpu::Element(gpu::SCALAR, gpu::FLOAT, gpu::RGB), _halfFrameSize.x, _halfFrameSize.y,
|
_halfLinearDepthTexture = gpu::TexturePointer(gpu::Texture::createRenderBuffer(gpu::Element(gpu::SCALAR, gpu::FLOAT, gpu::RED), _halfFrameSize.x, _halfFrameSize.y,
|
||||||
gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT)));
|
gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT)));
|
||||||
_halfLinearDepthTexture->autoGenerateMips(5);
|
_halfLinearDepthTexture->autoGenerateMips(5);
|
||||||
|
|
||||||
_halfNormalTexture = gpu::TexturePointer(gpu::Texture::createRenderBuffer(gpu::Element(gpu::VEC3, gpu::NUINT8, gpu::RGB), _halfFrameSize.x, _halfFrameSize.y,
|
_halfNormalTexture = gpu::TexturePointer(gpu::Texture::createRenderBuffer(gpu::Element::COLOR_RGBA_32, _halfFrameSize.x, _halfFrameSize.y,
|
||||||
gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT)));
|
gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT)));
|
||||||
|
|
||||||
_downsampleFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("halfLinearDepth"));
|
_downsampleFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("halfLinearDepth"));
|
||||||
|
|
|
@ -142,7 +142,8 @@ function mousePressEvent(event) {
|
||||||
if (!pickResults.intersects) {
|
if (!pickResults.intersects) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (pickResults.properties.dynamic) {
|
var isDynamic = Entites.getEntityProperties(pickResults.entityID, "dynamic").dynamic;
|
||||||
|
if (isDynamic) {
|
||||||
grabbedEntity = pickResults.entityID;
|
grabbedEntity = pickResults.entityID;
|
||||||
var props = Entities.getEntityProperties(grabbedEntity)
|
var props = Entities.getEntityProperties(grabbedEntity)
|
||||||
originalGravity = props.gravity;
|
originalGravity = props.gravity;
|
||||||
|
|
|
@ -190,7 +190,10 @@ function controller(side) {
|
||||||
direction: Vec3.normalize(Vec3.subtract(this.tipPosition, this.palmPosition))
|
direction: Vec3.normalize(Vec3.subtract(this.tipPosition, this.palmPosition))
|
||||||
};
|
};
|
||||||
var intersection = getRayIntersection(pickRay, true);
|
var intersection = getRayIntersection(pickRay, true);
|
||||||
if (intersection.intersects && intersection.properties.dynamic) {
|
|
||||||
|
var isDynamic = Entites.getEntityProperties(intersection.entityID, "dynamic").dynamic;
|
||||||
|
|
||||||
|
if (intersection.intersects && isDynamic) {
|
||||||
this.laserWasHovered = true;
|
this.laserWasHovered = true;
|
||||||
if (this.triggerHeld && !this.grabbing) {
|
if (this.triggerHeld && !this.grabbing) {
|
||||||
this.grab(intersection.entityID);
|
this.grab(intersection.entityID);
|
||||||
|
|
|
@ -38,7 +38,6 @@ function mouseMoveEvent(event) {
|
||||||
|
|
||||||
if (intersection.intersects) {
|
if (intersection.intersects) {
|
||||||
print("intersection entityID=" + intersection.entityID);
|
print("intersection entityID=" + intersection.entityID);
|
||||||
print("intersection properties.modelURL=" + intersection.properties.modelURL);
|
|
||||||
print("intersection face=" + intersection.face);
|
print("intersection face=" + intersection.face);
|
||||||
print("intersection distance=" + intersection.distance);
|
print("intersection distance=" + intersection.distance);
|
||||||
print("intersection intersection.x/y/z=" + intersection.intersection.x + ", "
|
print("intersection intersection.x/y/z=" + intersection.intersection.x + ", "
|
||||||
|
|
|
@ -77,6 +77,8 @@
|
||||||
//Comment out above line and uncomment below line to see difference in performance between using a whitelist, and not using one
|
//Comment out above line and uncomment below line to see difference in performance between using a whitelist, and not using one
|
||||||
// this.intersection = Entities.findRayIntersection(pickRay, true);
|
// this.intersection = Entities.findRayIntersection(pickRay, true);
|
||||||
|
|
||||||
|
var type = Entites.getEntityProperties(this.intersection.entityID, "type").type;
|
||||||
|
|
||||||
if (this.intersection.intersects) {
|
if (this.intersection.intersects) {
|
||||||
var distance = Vec3.distance(handPosition, this.intersection.intersection);
|
var distance = Vec3.distance(handPosition, this.intersection.intersection);
|
||||||
if (distance < MAX_DISTANCE) {
|
if (distance < MAX_DISTANCE) {
|
||||||
|
@ -98,7 +100,7 @@
|
||||||
this.oldPosition = null;
|
this.oldPosition = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (this.intersection.properties.type !== "Unknown") {
|
} else if (type !== "Unknown") {
|
||||||
//Sometimes ray will pick against an invisible object with type unkown... so if type is unknown, ignore
|
//Sometimes ray will pick against an invisible object with type unkown... so if type is unknown, ignore
|
||||||
this.stopPainting();
|
this.stopPainting();
|
||||||
}
|
}
|
||||||
|
|
|
@ -382,7 +382,10 @@ function MyController(hand) {
|
||||||
|
|
||||||
var grabbableData = getEntityCustomData(GRABBABLE_DATA_KEY, intersection.entityID, DEFAULT_GRABBABLE_DATA);
|
var grabbableData = getEntityCustomData(GRABBABLE_DATA_KEY, intersection.entityID, DEFAULT_GRABBABLE_DATA);
|
||||||
|
|
||||||
if (intersection.properties.name == "Grab Debug Entity") {
|
var properties = Entites.getEntityProperties(intersection.entityID, ["locked", "name"]);
|
||||||
|
|
||||||
|
|
||||||
|
if (properties.name == "Grab Debug Entity") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,7 +402,7 @@ function MyController(hand) {
|
||||||
this.grabbedEntity = intersection.entityID;
|
this.grabbedEntity = intersection.entityID;
|
||||||
this.setState(STATE_NEAR_TRIGGER);
|
this.setState(STATE_NEAR_TRIGGER);
|
||||||
return;
|
return;
|
||||||
} else if (!intersection.properties.locked) {
|
} else if (!properties.locked) {
|
||||||
var ownerObj = getEntityCustomData('ownerKey', intersection.entityID, null);
|
var ownerObj = getEntityCustomData('ownerKey', intersection.entityID, null);
|
||||||
|
|
||||||
if (ownerObj == null || ownerObj.ownerID === MyAvatar.sessionUUID) { //I can only grab new or already mine items
|
if (ownerObj == null || ownerObj.ownerID === MyAvatar.sessionUUID) { //I can only grab new or already mine items
|
||||||
|
|
|
@ -343,7 +343,8 @@ Grabber.prototype.pressEvent = function(event) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pickResults.properties.dynamic) {
|
var isDynamic = Entities.getEntityProperties(pickResults.entityID, "dynamic").dynamic;
|
||||||
|
if (!isDynamic) {
|
||||||
// only grab dynamic objects
|
// only grab dynamic objects
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,8 +151,9 @@
|
||||||
});
|
});
|
||||||
}, randFloat(10, 200));
|
}, randFloat(10, 200));
|
||||||
}
|
}
|
||||||
if (intersection.properties.dynamic === 1) {
|
var isDynamic = Entities.getEntityProperties(intersection.entityID, "dynamic").dynamic;
|
||||||
// Any dynaic entity can be shot
|
if (isDynamic === 1) {
|
||||||
|
// Any dynamic entity can be shot
|
||||||
Entities.editEntity(intersection.entityID, {
|
Entities.editEntity(intersection.entityID, {
|
||||||
velocity: Vec3.multiply(this.firingDirection, this.bulletForce)
|
velocity: Vec3.multiply(this.firingDirection, this.bulletForce)
|
||||||
});
|
});
|
||||||
|
@ -347,7 +348,7 @@
|
||||||
this.laser = Overlays.addOverlay("line3d", {
|
this.laser = Overlays.addOverlay("line3d", {
|
||||||
start: ZERO_VECTOR,
|
start: ZERO_VECTOR,
|
||||||
end: ZERO_VECTOR,
|
end: ZERO_VECTOR,
|
||||||
color: COLORS.RED,
|
color: { red: 255, green: 0, blue: 0},
|
||||||
alpha: 1,
|
alpha: 1,
|
||||||
visible: true,
|
visible: true,
|
||||||
lineWidth: 2
|
lineWidth: 2
|
||||||
|
|
|
@ -456,7 +456,7 @@ protected:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto texture = _textures[_currentTextureIndex];
|
auto texture = _textures[_currentTextureIndex];
|
||||||
texture->setMinMip(texture->minMip() + 1);
|
texture->setMinMip(texture->getMinMip() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadTexture() {
|
void loadTexture() {
|
||||||
|
|
Loading…
Reference in a new issue