mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 04:03:35 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into getEntityPropertiesPerformance
Conflicts: libraries/entities-renderer/src/EntityTreeRenderer.cpp libraries/entities-renderer/src/EntityTreeRenderer.h libraries/script-engine/src/ScriptCache.cpp libraries/script-engine/src/ScriptCache.h
This commit is contained in:
commit
6fac447b97
14 changed files with 70 additions and 67 deletions
|
@ -1302,7 +1302,7 @@ void MyAvatar::initAnimGraph() {
|
||||||
// or run a local web-server
|
// or run a local web-server
|
||||||
// python -m SimpleHTTPServer&
|
// python -m SimpleHTTPServer&
|
||||||
//auto graphUrl = QUrl("http://localhost:8000/avatar.json");
|
//auto graphUrl = QUrl("http://localhost:8000/avatar.json");
|
||||||
auto graphUrl = QUrl("https://gist.githubusercontent.com/hyperlogic/04a02c47eb56d8bfaebb/raw/5f2a4e268d35147c83d44881e268f83a6296e89b/ik-avatar-hands.json");
|
auto graphUrl = QUrl("https://gist.githubusercontent.com/hyperlogic/04a02c47eb56d8bfaebb/raw/72517b231f606b724c5169e02642e401f9af5a54/ik-avatar-hands.json");
|
||||||
_rig->initAnimGraph(graphUrl, _skeletonModel.getGeometry()->getFBXGeometry());
|
_rig->initAnimGraph(graphUrl, _skeletonModel.getGeometry()->getFBXGeometry());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// AnimController.cpp
|
// AnimManipulator.cpp
|
||||||
//
|
//
|
||||||
// Created by Anthony J. Thibault on 9/8/15.
|
// Created by Anthony J. Thibault on 9/8/15.
|
||||||
// Copyright (c) 2015 High Fidelity, Inc. All rights reserved.
|
// Copyright (c) 2015 High Fidelity, Inc. All rights reserved.
|
||||||
|
@ -8,24 +8,25 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "AnimController.h"
|
#include "AnimManipulator.h"
|
||||||
|
#include "AnimUtil.h"
|
||||||
#include "AnimationLogging.h"
|
#include "AnimationLogging.h"
|
||||||
|
|
||||||
AnimController::AnimController(const std::string& id, float alpha) :
|
AnimManipulator::AnimManipulator(const std::string& id, float alpha) :
|
||||||
AnimNode(AnimNode::Type::Controller, id),
|
AnimNode(AnimNode::Type::Manipulator, id),
|
||||||
_alpha(alpha) {
|
_alpha(alpha) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimController::~AnimController() {
|
AnimManipulator::~AnimManipulator() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const AnimPoseVec& AnimController::evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) {
|
const AnimPoseVec& AnimManipulator::evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) {
|
||||||
return overlay(animVars, dt, triggersOut, _skeleton->getRelativeBindPoses());
|
return overlay(animVars, dt, triggersOut, _skeleton->getRelativeBindPoses());
|
||||||
}
|
}
|
||||||
|
|
||||||
const AnimPoseVec& AnimController::overlay(const AnimVariantMap& animVars, float dt, Triggers& triggersOut, const AnimPoseVec& underPoses) {
|
const AnimPoseVec& AnimManipulator::overlay(const AnimVariantMap& animVars, float dt, Triggers& triggersOut, const AnimPoseVec& underPoses) {
|
||||||
_alpha = animVars.lookup(_alphaVar, _alpha);
|
_alpha = animVars.lookup(_alphaVar, _alpha);
|
||||||
|
|
||||||
for (auto& jointVar : _jointVars) {
|
for (auto& jointVar : _jointVars) {
|
||||||
|
@ -33,52 +34,56 @@ const AnimPoseVec& AnimController::overlay(const AnimVariantMap& animVars, float
|
||||||
QString qJointName = QString::fromStdString(jointVar.jointName);
|
QString qJointName = QString::fromStdString(jointVar.jointName);
|
||||||
jointVar.jointIndex = _skeleton->nameToJointIndex(qJointName);
|
jointVar.jointIndex = _skeleton->nameToJointIndex(qJointName);
|
||||||
if (jointVar.jointIndex < 0) {
|
if (jointVar.jointIndex < 0) {
|
||||||
qCWarning(animation) << "AnimController could not find jointName" << qJointName << "in skeleton";
|
qCWarning(animation) << "AnimManipulator could not find jointName" << qJointName << "in skeleton";
|
||||||
}
|
}
|
||||||
jointVar.hasPerformedJointLookup = true;
|
jointVar.hasPerformedJointLookup = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jointVar.jointIndex >= 0) {
|
if (jointVar.jointIndex >= 0) {
|
||||||
|
|
||||||
AnimPose defaultPose;
|
AnimPose defaultAbsPose;
|
||||||
glm::quat absRot;
|
AnimPose defaultRelPose;
|
||||||
glm::quat parentAbsRot;
|
AnimPose parentAbsPose = AnimPose::identity;
|
||||||
if (jointVar.jointIndex <= (int)underPoses.size()) {
|
if (jointVar.jointIndex <= (int)underPoses.size()) {
|
||||||
|
|
||||||
// jointVar is an absolute rotation, if it is not set we will use the underPose as our default value
|
// jointVar is an absolute rotation, if it is not set we will use the underPose as our default value
|
||||||
defaultPose = _skeleton->getAbsolutePose(jointVar.jointIndex, underPoses);
|
defaultRelPose = underPoses[jointVar.jointIndex];
|
||||||
absRot = animVars.lookup(jointVar.var, defaultPose.rot);
|
defaultAbsPose = _skeleton->getAbsolutePose(jointVar.jointIndex, underPoses);
|
||||||
|
defaultAbsPose.rot = animVars.lookup(jointVar.var, defaultAbsPose.rot);
|
||||||
|
|
||||||
// because jointVar is absolute, we must use an absolute parent frame to convert into a relative pose.
|
// because jointVar is absolute, we must use an absolute parent frame to convert into a relative pose.
|
||||||
int parentIndex = _skeleton->getParentIndex(jointVar.jointIndex);
|
int parentIndex = _skeleton->getParentIndex(jointVar.jointIndex);
|
||||||
if (parentIndex >= 0) {
|
if (parentIndex >= 0) {
|
||||||
parentAbsRot = _skeleton->getAbsolutePose(parentIndex, underPoses).rot;
|
parentAbsPose = _skeleton->getAbsolutePose(parentIndex, underPoses);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// jointVar is an absolute rotation, if it is not set we will use the bindPose as our default value
|
// jointVar is an absolute rotation, if it is not set we will use the bindPose as our default value
|
||||||
defaultPose = _skeleton->getAbsoluteBindPose(jointVar.jointIndex);
|
defaultRelPose = AnimPose::identity;
|
||||||
absRot = animVars.lookup(jointVar.var, defaultPose.rot);
|
defaultAbsPose = _skeleton->getAbsoluteBindPose(jointVar.jointIndex);
|
||||||
|
defaultAbsPose.rot = animVars.lookup(jointVar.var, defaultAbsPose.rot);
|
||||||
|
|
||||||
// because jointVar is absolute, we must use an absolute parent frame to convert into a relative pose
|
// because jointVar is absolute, we must use an absolute parent frame to convert into a relative pose
|
||||||
// here we use the bind pose
|
// here we use the bind pose
|
||||||
int parentIndex = _skeleton->getParentIndex(jointVar.jointIndex);
|
int parentIndex = _skeleton->getParentIndex(jointVar.jointIndex);
|
||||||
if (parentIndex >= 0) {
|
if (parentIndex >= 0) {
|
||||||
parentAbsRot = _skeleton->getAbsoluteBindPose(parentIndex).rot;
|
parentAbsPose = _skeleton->getAbsoluteBindPose(parentIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert from absolute to relative
|
// convert from absolute to relative
|
||||||
glm::quat relRot = glm::inverse(parentAbsRot) * absRot;
|
AnimPose relPose = parentAbsPose.inverse() * defaultAbsPose;
|
||||||
_poses[jointVar.jointIndex] = AnimPose(defaultPose.scale, relRot, defaultPose.trans);
|
|
||||||
|
// blend with underPose
|
||||||
|
::blend(1, &defaultRelPose, &relPose, _alpha, &_poses[jointVar.jointIndex]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return _poses;
|
return _poses;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimController::setSkeletonInternal(AnimSkeleton::ConstPointer skeleton) {
|
void AnimManipulator::setSkeletonInternal(AnimSkeleton::ConstPointer skeleton) {
|
||||||
AnimNode::setSkeletonInternal(skeleton);
|
AnimNode::setSkeletonInternal(skeleton);
|
||||||
|
|
||||||
// invalidate all jointVar indices
|
// invalidate all jointVar indices
|
||||||
|
@ -97,10 +102,10 @@ void AnimController::setSkeletonInternal(AnimSkeleton::ConstPointer skeleton) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// for AnimDebugDraw rendering
|
// for AnimDebugDraw rendering
|
||||||
const AnimPoseVec& AnimController::getPosesInternal() const {
|
const AnimPoseVec& AnimManipulator::getPosesInternal() const {
|
||||||
return _poses;
|
return _poses;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimController::addJointVar(const JointVar& jointVar) {
|
void AnimManipulator::addJointVar(const JointVar& jointVar) {
|
||||||
_jointVars.push_back(jointVar);
|
_jointVars.push_back(jointVar);
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// AnimController.h
|
// AnimManipulator.h
|
||||||
//
|
//
|
||||||
// Created by Anthony J. Thibault on 9/8/15.
|
// Created by Anthony J. Thibault on 9/8/15.
|
||||||
// Copyright (c) 2015 High Fidelity, Inc. All rights reserved.
|
// Copyright (c) 2015 High Fidelity, Inc. All rights reserved.
|
||||||
|
@ -8,19 +8,19 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef hifi_AnimController_h
|
#ifndef hifi_AnimManipulator_h
|
||||||
#define hifi_AnimController_h
|
#define hifi_AnimManipulator_h
|
||||||
|
|
||||||
#include "AnimNode.h"
|
#include "AnimNode.h"
|
||||||
|
|
||||||
// Allows procedural control over a set of joints.
|
// Allows procedural control over a set of joints.
|
||||||
|
|
||||||
class AnimController : public AnimNode {
|
class AnimManipulator : public AnimNode {
|
||||||
public:
|
public:
|
||||||
friend class AnimTests;
|
friend class AnimTests;
|
||||||
|
|
||||||
AnimController(const std::string& id, float alpha);
|
AnimManipulator(const std::string& id, float alpha);
|
||||||
virtual ~AnimController() override;
|
virtual ~AnimManipulator() override;
|
||||||
|
|
||||||
virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) override;
|
virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, 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, float dt, Triggers& triggersOut, const AnimPoseVec& underPoses) override;
|
||||||
|
@ -50,9 +50,9 @@ protected:
|
||||||
std::vector<JointVar> _jointVars;
|
std::vector<JointVar> _jointVars;
|
||||||
|
|
||||||
// no copies
|
// no copies
|
||||||
AnimController(const AnimController&) = delete;
|
AnimManipulator(const AnimManipulator&) = delete;
|
||||||
AnimController& operator=(const AnimController&) = delete;
|
AnimManipulator& operator=(const AnimManipulator&) = delete;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_AnimController_h
|
#endif // hifi_AnimManipulator_h
|
|
@ -40,7 +40,7 @@ public:
|
||||||
BlendLinear,
|
BlendLinear,
|
||||||
Overlay,
|
Overlay,
|
||||||
StateMachine,
|
StateMachine,
|
||||||
Controller,
|
Manipulator,
|
||||||
InverseKinematics,
|
InverseKinematics,
|
||||||
NumTypes
|
NumTypes
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include "AnimOverlay.h"
|
#include "AnimOverlay.h"
|
||||||
#include "AnimNodeLoader.h"
|
#include "AnimNodeLoader.h"
|
||||||
#include "AnimStateMachine.h"
|
#include "AnimStateMachine.h"
|
||||||
#include "AnimController.h"
|
#include "AnimManipulator.h"
|
||||||
#include "AnimInverseKinematics.h"
|
#include "AnimInverseKinematics.h"
|
||||||
|
|
||||||
using NodeLoaderFunc = AnimNode::Pointer (*)(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl);
|
using NodeLoaderFunc = AnimNode::Pointer (*)(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl);
|
||||||
|
@ -31,7 +31,7 @@ static AnimNode::Pointer loadClipNode(const QJsonObject& jsonObj, const QString&
|
||||||
static AnimNode::Pointer loadBlendLinearNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl);
|
static AnimNode::Pointer loadBlendLinearNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl);
|
||||||
static AnimNode::Pointer loadOverlayNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl);
|
static AnimNode::Pointer loadOverlayNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl);
|
||||||
static AnimNode::Pointer loadStateMachineNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl);
|
static AnimNode::Pointer loadStateMachineNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl);
|
||||||
static AnimNode::Pointer loadControllerNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl);
|
static AnimNode::Pointer loadManipulatorNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl);
|
||||||
static AnimNode::Pointer loadInverseKinematicsNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl);
|
static AnimNode::Pointer loadInverseKinematicsNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl);
|
||||||
|
|
||||||
// called after children have been loaded
|
// called after children have been loaded
|
||||||
|
@ -40,7 +40,7 @@ static bool processClipNode(AnimNode::Pointer node, const QJsonObject& jsonObj,
|
||||||
static bool processBlendLinearNode(AnimNode::Pointer node, const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl) { return true; }
|
static bool processBlendLinearNode(AnimNode::Pointer node, const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl) { return true; }
|
||||||
static bool processOverlayNode(AnimNode::Pointer node, const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl) { return true; }
|
static bool processOverlayNode(AnimNode::Pointer node, const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl) { return true; }
|
||||||
bool processStateMachineNode(AnimNode::Pointer node, const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl);
|
bool processStateMachineNode(AnimNode::Pointer node, const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl);
|
||||||
static bool processControllerNode(AnimNode::Pointer node, const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl) { return true; }
|
static bool processManipulatorNode(AnimNode::Pointer node, const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl) { return true; }
|
||||||
static bool processInverseKinematicsNode(AnimNode::Pointer node, const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl) { return true; }
|
static bool processInverseKinematicsNode(AnimNode::Pointer node, const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl) { return true; }
|
||||||
|
|
||||||
static const char* animNodeTypeToString(AnimNode::Type type) {
|
static const char* animNodeTypeToString(AnimNode::Type type) {
|
||||||
|
@ -49,7 +49,7 @@ static const char* animNodeTypeToString(AnimNode::Type type) {
|
||||||
case AnimNode::Type::BlendLinear: return "blendLinear";
|
case AnimNode::Type::BlendLinear: return "blendLinear";
|
||||||
case AnimNode::Type::Overlay: return "overlay";
|
case AnimNode::Type::Overlay: return "overlay";
|
||||||
case AnimNode::Type::StateMachine: return "stateMachine";
|
case AnimNode::Type::StateMachine: return "stateMachine";
|
||||||
case AnimNode::Type::Controller: return "controller";
|
case AnimNode::Type::Manipulator: return "manipulator";
|
||||||
case AnimNode::Type::InverseKinematics: return "inverseKinematics";
|
case AnimNode::Type::InverseKinematics: return "inverseKinematics";
|
||||||
case AnimNode::Type::NumTypes: return nullptr;
|
case AnimNode::Type::NumTypes: return nullptr;
|
||||||
};
|
};
|
||||||
|
@ -62,7 +62,7 @@ static NodeLoaderFunc animNodeTypeToLoaderFunc(AnimNode::Type type) {
|
||||||
case AnimNode::Type::BlendLinear: return loadBlendLinearNode;
|
case AnimNode::Type::BlendLinear: return loadBlendLinearNode;
|
||||||
case AnimNode::Type::Overlay: return loadOverlayNode;
|
case AnimNode::Type::Overlay: return loadOverlayNode;
|
||||||
case AnimNode::Type::StateMachine: return loadStateMachineNode;
|
case AnimNode::Type::StateMachine: return loadStateMachineNode;
|
||||||
case AnimNode::Type::Controller: return loadControllerNode;
|
case AnimNode::Type::Manipulator: return loadManipulatorNode;
|
||||||
case AnimNode::Type::InverseKinematics: return loadInverseKinematicsNode;
|
case AnimNode::Type::InverseKinematics: return loadInverseKinematicsNode;
|
||||||
case AnimNode::Type::NumTypes: return nullptr;
|
case AnimNode::Type::NumTypes: return nullptr;
|
||||||
};
|
};
|
||||||
|
@ -75,7 +75,7 @@ static NodeProcessFunc animNodeTypeToProcessFunc(AnimNode::Type type) {
|
||||||
case AnimNode::Type::BlendLinear: return processBlendLinearNode;
|
case AnimNode::Type::BlendLinear: return processBlendLinearNode;
|
||||||
case AnimNode::Type::Overlay: return processOverlayNode;
|
case AnimNode::Type::Overlay: return processOverlayNode;
|
||||||
case AnimNode::Type::StateMachine: return processStateMachineNode;
|
case AnimNode::Type::StateMachine: return processStateMachineNode;
|
||||||
case AnimNode::Type::Controller: return processControllerNode;
|
case AnimNode::Type::Manipulator: return processManipulatorNode;
|
||||||
case AnimNode::Type::InverseKinematics: return processInverseKinematicsNode;
|
case AnimNode::Type::InverseKinematics: return processInverseKinematicsNode;
|
||||||
case AnimNode::Type::NumTypes: return nullptr;
|
case AnimNode::Type::NumTypes: return nullptr;
|
||||||
};
|
};
|
||||||
|
@ -122,7 +122,7 @@ static NodeProcessFunc animNodeTypeToProcessFunc(AnimNode::Type type) {
|
||||||
static AnimNode::Type stringToEnum(const QString& str) {
|
static AnimNode::Type stringToEnum(const QString& str) {
|
||||||
// O(n), move to map when number of types becomes large.
|
// O(n), move to map when number of types becomes large.
|
||||||
const int NUM_TYPES = static_cast<int>(AnimNode::Type::NumTypes);
|
const int NUM_TYPES = static_cast<int>(AnimNode::Type::NumTypes);
|
||||||
for (int i = 0; i < NUM_TYPES; i++ ) {
|
for (int i = 0; i < NUM_TYPES; i++) {
|
||||||
AnimNode::Type type = static_cast<AnimNode::Type>(i);
|
AnimNode::Type type = static_cast<AnimNode::Type>(i);
|
||||||
if (str == animNodeTypeToString(type)) {
|
if (str == animNodeTypeToString(type)) {
|
||||||
return type;
|
return type;
|
||||||
|
@ -288,10 +288,10 @@ static AnimNode::Pointer loadStateMachineNode(const QJsonObject& jsonObj, const
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
static AnimNode::Pointer loadControllerNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl) {
|
static AnimNode::Pointer loadManipulatorNode(const QJsonObject& jsonObj, const QString& id, const QUrl& jsonUrl) {
|
||||||
|
|
||||||
READ_FLOAT(alpha, jsonObj, id, jsonUrl, nullptr);
|
READ_FLOAT(alpha, jsonObj, id, jsonUrl, nullptr);
|
||||||
auto node = std::make_shared<AnimController>(id.toStdString(), alpha);
|
auto node = std::make_shared<AnimManipulator>(id.toStdString(), alpha);
|
||||||
|
|
||||||
READ_OPTIONAL_STRING(alphaVar, jsonObj);
|
READ_OPTIONAL_STRING(alphaVar, jsonObj);
|
||||||
if (!alphaVar.isEmpty()) {
|
if (!alphaVar.isEmpty()) {
|
||||||
|
@ -315,7 +315,7 @@ static AnimNode::Pointer loadControllerNode(const QJsonObject& jsonObj, const QS
|
||||||
READ_STRING(var, jointObj, id, jsonUrl, nullptr);
|
READ_STRING(var, jointObj, id, jsonUrl, nullptr);
|
||||||
READ_STRING(jointName, jointObj, id, jsonUrl, nullptr);
|
READ_STRING(jointName, jointObj, id, jsonUrl, nullptr);
|
||||||
|
|
||||||
AnimController::JointVar jointVar(var.toStdString(), jointName.toStdString());
|
AnimManipulator::JointVar jointVar(var.toStdString(), jointName.toStdString());
|
||||||
node->addJointVar(jointVar);
|
node->addJointVar(jointVar);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -173,8 +173,8 @@ void AnimOverlay::buildEmptyBoneSet() {
|
||||||
void AnimOverlay::buildLeftHandBoneSet() {
|
void AnimOverlay::buildLeftHandBoneSet() {
|
||||||
assert(_skeleton);
|
assert(_skeleton);
|
||||||
buildEmptyBoneSet();
|
buildEmptyBoneSet();
|
||||||
int headJoint = _skeleton->nameToJointIndex("LeftHand");
|
int handJoint = _skeleton->nameToJointIndex("LeftHand");
|
||||||
for_each_child_joint(_skeleton, headJoint, [&](int i) {
|
for_each_child_joint(_skeleton, handJoint, [&](int i) {
|
||||||
_boneSetVec[i] = 1.0f;
|
_boneSetVec[i] = 1.0f;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -182,8 +182,8 @@ void AnimOverlay::buildLeftHandBoneSet() {
|
||||||
void AnimOverlay::buildRightHandBoneSet() {
|
void AnimOverlay::buildRightHandBoneSet() {
|
||||||
assert(_skeleton);
|
assert(_skeleton);
|
||||||
buildEmptyBoneSet();
|
buildEmptyBoneSet();
|
||||||
int headJoint = _skeleton->nameToJointIndex("RightHand");
|
int handJoint = _skeleton->nameToJointIndex("RightHand");
|
||||||
for_each_child_joint(_skeleton, headJoint, [&](int i) {
|
for_each_child_joint(_skeleton, handJoint, [&](int i) {
|
||||||
_boneSetVec[i] = 1.0f;
|
_boneSetVec[i] = 1.0f;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -742,12 +742,10 @@ void Rig::inverseKinematics(int endIndex, glm::vec3 targetPosition, const glm::q
|
||||||
|
|
||||||
if (_enableAnimGraph && _animSkeleton) {
|
if (_enableAnimGraph && _animSkeleton) {
|
||||||
if (endIndex == _leftHandJointIndex) {
|
if (endIndex == _leftHandJointIndex) {
|
||||||
auto rootTrans = _animSkeleton->getAbsoluteBindPose(_rootJointIndex).trans;
|
_animVars.set("leftHandPosition", targetPosition);
|
||||||
_animVars.set("leftHandPosition", targetPosition + rootTrans);
|
|
||||||
_animVars.set("leftHandRotation", targetRotation);
|
_animVars.set("leftHandRotation", targetRotation);
|
||||||
} else if (endIndex == _rightHandJointIndex) {
|
} else if (endIndex == _rightHandJointIndex) {
|
||||||
auto rootTrans = _animSkeleton->getAbsoluteBindPose(_rootJointIndex).trans;
|
_animVars.set("rightHandPosition", targetPosition);
|
||||||
_animVars.set("rightHandPosition", targetPosition + rootTrans);
|
|
||||||
_animVars.set("rightHandRotation", targetRotation);
|
_animVars.set("rightHandRotation", targetRotation);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -995,10 +993,9 @@ void Rig::updateNeckJoint(int index, const HeadParameters& params) {
|
||||||
glm::angleAxis(glm::radians(-params.localHeadPitch), X_AXIS));
|
glm::angleAxis(glm::radians(-params.localHeadPitch), X_AXIS));
|
||||||
_animVars.set("headRotation", realLocalHeadOrientation);
|
_animVars.set("headRotation", realLocalHeadOrientation);
|
||||||
|
|
||||||
auto rootTrans = _animSkeleton->getAbsoluteBindPose(_rootJointIndex).trans;
|
|
||||||
// There's a theory that when not in hmd, we should _animVars.unset("headPosition").
|
// There's a theory that when not in hmd, we should _animVars.unset("headPosition").
|
||||||
// However, until that works well, let's always request head be positioned where requested by hmd, camera, or default.
|
// However, until that works well, let's always request head be positioned where requested by hmd, camera, or default.
|
||||||
_animVars.set("headPosition", params.localHeadPosition + rootTrans);
|
_animVars.set("headPosition", params.localHeadPosition);
|
||||||
} else if (!_enableAnimGraph) {
|
} else if (!_enableAnimGraph) {
|
||||||
|
|
||||||
auto& state = _jointStates[index];
|
auto& state = _jointStates[index];
|
||||||
|
|
|
@ -94,12 +94,12 @@ void EntityTreeRenderer::clear() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTreeRenderer::reloadEntityScripts() {
|
void EntityTreeRenderer::reloadEntityScripts() {
|
||||||
_entitiesScriptEngine->unloadAllEntityScripts();
|
_entitiesScriptEngine->unloadAllEntityScripts();
|
||||||
foreach(auto entity, _entitiesInScene) {
|
foreach(auto entity, _entitiesInScene) {
|
||||||
if (!entity->getScript().isEmpty()) {
|
if (!entity->getScript().isEmpty()) {
|
||||||
_entitiesScriptEngine->loadEntityScript(entity->getEntityItemID(), entity->getScript(), true);
|
_entitiesScriptEngine->loadEntityScript(entity->getEntityItemID(), entity->getScript(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTreeRenderer::init() {
|
void EntityTreeRenderer::init() {
|
||||||
|
|
|
@ -62,9 +62,8 @@ public:
|
||||||
/// clears the tree
|
/// clears the tree
|
||||||
virtual void clear();
|
virtual void clear();
|
||||||
|
|
||||||
/// reloads the entity scripts, calling unload and preload
|
/// reloads the entity scripts, calling unload and preload
|
||||||
void reloadEntityScripts();
|
void reloadEntityScripts();
|
||||||
|
|
||||||
|
|
||||||
/// if a renderable entity item needs a model, we will allocate it for them
|
/// if a renderable entity item needs a model, we will allocate it for them
|
||||||
Q_INVOKABLE Model* allocateModel(const QString& url, const QString& collisionUrl);
|
Q_INVOKABLE Model* allocateModel(const QString& url, const QString& collisionUrl);
|
||||||
|
|
|
@ -373,7 +373,10 @@ void DeferredLightingEffect::render(RenderArgs* args) {
|
||||||
projMats[0] = monoProjMat;
|
projMats[0] = monoProjMat;
|
||||||
|
|
||||||
deferredTransforms[0].projection = monoProjMat;
|
deferredTransforms[0].projection = monoProjMat;
|
||||||
|
|
||||||
deferredTransforms[0].viewInverse = monoViewMat;
|
deferredTransforms[0].viewInverse = monoViewMat;
|
||||||
|
viewTransforms[0] = monoViewTransform;
|
||||||
|
|
||||||
deferredTransforms[0].stereoSide = 0.0f;
|
deferredTransforms[0].stereoSide = 0.0f;
|
||||||
|
|
||||||
clipQuad[0] = glm::vec4(sMin, tMin, sWidth, tHeight);
|
clipQuad[0] = glm::vec4(sMin, tMin, sWidth, tHeight);
|
||||||
|
|
|
@ -31,7 +31,6 @@ void ScriptCache::clearCache() {
|
||||||
_scriptCache.clear();
|
_scriptCache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString ScriptCache::getScript(const QUrl& unnormalizedURL, ScriptUser* scriptUser, bool& isPending, bool reload) {
|
QString ScriptCache::getScript(const QUrl& unnormalizedURL, ScriptUser* scriptUser, bool& isPending, bool reload) {
|
||||||
QUrl url = ResourceManager::normalizeURL(unnormalizedURL);
|
QUrl url = ResourceManager::normalizeURL(unnormalizedURL);
|
||||||
QString scriptContents;
|
QString scriptContents;
|
||||||
|
|
|
@ -28,7 +28,7 @@ class ScriptCache : public QObject, public Dependency {
|
||||||
SINGLETON_DEPENDENCY
|
SINGLETON_DEPENDENCY
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void clearCache();
|
void clearCache();
|
||||||
void getScriptContents(const QString& scriptOrURL, contentAvailableCallback contentAvailable, bool forceDownload = false);
|
void getScriptContents(const QString& scriptOrURL, contentAvailableCallback contentAvailable, bool forceDownload = false);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -405,7 +405,7 @@ void ScriptEngine::registerGetterSetter(const QString& name, QScriptEngine::Func
|
||||||
QScriptValue setterFunction = newFunction(setter, 1);
|
QScriptValue setterFunction = newFunction(setter, 1);
|
||||||
QScriptValue getterFunction = newFunction(getter);
|
QScriptValue getterFunction = newFunction(getter);
|
||||||
|
|
||||||
if (!parent.isNull()) {
|
if (!parent.isNull() && !parent.isEmpty()) {
|
||||||
QScriptValue object = globalObject().property(parent);
|
QScriptValue object = globalObject().property(parent);
|
||||||
if (object.isValid()) {
|
if (object.isValid()) {
|
||||||
object.setProperty(name, setterFunction, QScriptValue::PropertySetter);
|
object.setProperty(name, setterFunction, QScriptValue::PropertySetter);
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
"children": []
|
"children": []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "controllerOverlay",
|
"id": "manipulatorOverlay",
|
||||||
"type": "overlay",
|
"type": "overlay",
|
||||||
"data": {
|
"data": {
|
||||||
"alpha": 1.0,
|
"alpha": 1.0,
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
"id": "spineLean",
|
"id": "spineLean",
|
||||||
"type": "controller",
|
"type": "manipulator",
|
||||||
"data": {
|
"data": {
|
||||||
"alpha": 1.0,
|
"alpha": 1.0,
|
||||||
"joints": [
|
"joints": [
|
||||||
|
|
Loading…
Reference in a new issue