Removed last consumer of JointState class

Removed option to render IK constraints used by old animation system
This commit is contained in:
Anthony J. Thibault 2015-11-20 11:26:54 -08:00
parent df7ca3bc38
commit a4116e633a
8 changed files with 26 additions and 121 deletions

View file

@ -458,7 +458,6 @@ Menu::Menu() {
addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::EnableHandMouseInput, 0, false); addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::EnableHandMouseInput, 0, false);
addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::LowVelocityFilter, 0, true, addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::LowVelocityFilter, 0, true,
qApp, SLOT(setLowVelocityFilter(bool))); qApp, SLOT(setLowVelocityFilter(bool)));
addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::ShowIKConstraints, 0, false);
MenuWrapper* leapOptionsMenu = handOptionsMenu->addMenu("Leap Motion"); MenuWrapper* leapOptionsMenu = handOptionsMenu->addMenu("Leap Motion");
addCheckableActionToQMenuAndActionHash(leapOptionsMenu, MenuOption::LeapMotionOnHMD, 0, false); addCheckableActionToQMenuAndActionHash(leapOptionsMenu, MenuOption::LeapMotionOnHMD, 0, false);

View file

@ -271,7 +271,6 @@ namespace MenuOption {
const QString ScriptedMotorControl = "Enable Scripted Motor Control"; const QString ScriptedMotorControl = "Enable Scripted Motor Control";
const QString ShowDSConnectTable = "Show Domain Connection Timing"; const QString ShowDSConnectTable = "Show Domain Connection Timing";
const QString ShowBordersEntityNodes = "Show Entity Nodes"; const QString ShowBordersEntityNodes = "Show Entity Nodes";
const QString ShowIKConstraints = "Show IK Constraints";
const QString ShowRealtimeEntityStats = "Show Realtime Entity Stats"; const QString ShowRealtimeEntityStats = "Show Realtime Entity Stats";
const QString ShowWhosLookingAtMe = "Show Who's Looking at Me"; const QString ShowWhosLookingAtMe = "Show Who's Looking at Me";
const QString StandingHMDSensorMode = "Standing HMD Sensor Mode"; const QString StandingHMDSensorMode = "Standing HMD Sensor Mode";

View file

@ -32,10 +32,7 @@ void FaceModel::simulate(float deltaTime, bool fullUpdate) {
neckPosition = owningAvatar->getPosition(); neckPosition = owningAvatar->getPosition();
} }
setTranslation(neckPosition); setTranslation(neckPosition);
glm::quat neckParentRotation; glm::quat neckParentRotation = owningAvatar->getOrientation();
if (!owningAvatar->getSkeletonModel().getNeckParentRotationFromDefaultOrientation(neckParentRotation)) {
neckParentRotation = owningAvatar->getOrientation();
}
setRotation(neckParentRotation); setRotation(neckParentRotation);
setScale(glm::vec3(1.0f, 1.0f, 1.0f) * _owningHead->getScale()); setScale(glm::vec3(1.0f, 1.0f, 1.0f) * _owningHead->getScale());

View file

@ -268,7 +268,6 @@ void MyAvatar::simulate(float deltaTime) {
{ {
PerformanceTimer perfTimer("joints"); PerformanceTimer perfTimer("joints");
// copy out the skeleton joints from the model // copy out the skeleton joints from the model
_jointData.resize(_rig->getJointStateCount());
_rig->copyJointsIntoJointData(_jointData); _rig->copyJointsIntoJointData(_jointData);
} }
@ -507,11 +506,14 @@ void MyAvatar::render(RenderArgs* renderArgs, const glm::vec3& cameraPosition) {
Avatar::render(renderArgs, cameraPosition); Avatar::render(renderArgs, cameraPosition);
// AJT: REMOVE
/*
// don't display IK constraints in shadow mode // don't display IK constraints in shadow mode
if (Menu::getInstance()->isOptionChecked(MenuOption::ShowIKConstraints) && if (Menu::getInstance()->isOptionChecked(MenuOption::ShowIKConstraints) &&
renderArgs && renderArgs->_batch) { renderArgs && renderArgs->_batch) {
_skeletonModel.renderIKConstraints(*renderArgs->_batch); _skeletonModel.renderIKConstraints(*renderArgs->_batch);
} }
*/
} }
void MyAvatar::clearReferential() { void MyAvatar::clearReferential() {
@ -1285,7 +1287,7 @@ void MyAvatar::preRender(RenderArgs* renderArgs) {
auto rig = _skeletonModel.getRig(); auto rig = _skeletonModel.getRig();
// build AnimPoseVec from JointStates. // build absolute AnimPoseVec from rig
AnimPoseVec absPoses; AnimPoseVec absPoses;
absPoses.reserve(_debugDrawSkeleton->getNumJoints()); absPoses.reserve(_debugDrawSkeleton->getNumJoints());
for (int i = 0; i < _rig->getJointStateCount(); i++) { for (int i = 0; i < _rig->getJointStateCount(); i++) {

View file

@ -26,7 +26,6 @@
SkeletonModel::SkeletonModel(Avatar* owningAvatar, QObject* parent, RigPointer rig) : SkeletonModel::SkeletonModel(Avatar* owningAvatar, QObject* parent, RigPointer rig) :
Model(rig, parent), Model(rig, parent),
_triangleFanID(DependencyManager::get<GeometryCache>()->allocateID()),
_owningAvatar(owningAvatar), _owningAvatar(owningAvatar),
_boundingCapsuleLocalOffset(0.0f), _boundingCapsuleLocalOffset(0.0f),
_boundingCapsuleRadius(0.0f), _boundingCapsuleRadius(0.0f),
@ -254,11 +253,6 @@ void SkeletonModel::simulate(float deltaTime, bool fullUpdate) {
} }
} }
void SkeletonModel::renderIKConstraints(gpu::Batch& batch) {
renderJointConstraints(batch, getRightHandJointIndex());
renderJointConstraints(batch, getLeftHandJointIndex());
}
class IndexValue { class IndexValue {
public: public:
int index; int index;
@ -285,98 +279,6 @@ void SkeletonModel::applyPalmData(int jointIndex, const PalmData& palm) {
glm::quat palmRotation = inverseRotation * palm.getRotation(); glm::quat palmRotation = inverseRotation * palm.getRotation();
} }
void SkeletonModel::renderJointConstraints(gpu::Batch& batch, int jointIndex) {
if (jointIndex == -1 || jointIndex >= _rig->getJointStateCount()) {
return;
}
const FBXGeometry& geometry = _geometry->getFBXGeometry();
const float BASE_DIRECTION_SIZE = 0.3f;
float directionSize = BASE_DIRECTION_SIZE * extractUniformScale(_scale);
// FIXME: THe line width of 3.0f is not supported anymore, we ll need a workaround
do {
const FBXJoint& joint = geometry.joints.at(jointIndex);
const JointState& jointState = _rig->getJointState(jointIndex);
glm::vec3 position = _rotation * jointState.getPosition() + _translation;
glm::quat parentRotation = (joint.parentIndex == -1) ?
_rotation :
_rotation * _rig->getJointState(joint.parentIndex).getRotation();
float fanScale = directionSize * 0.75f;
Transform transform = Transform();
transform.setTranslation(position);
transform.setRotation(parentRotation);
transform.setScale(fanScale);
batch.setModelTransform(transform);
const int AXIS_COUNT = 3;
auto geometryCache = DependencyManager::get<GeometryCache>();
for (int i = 0; i < AXIS_COUNT; i++) {
if (joint.rotationMin[i] <= -PI + EPSILON && joint.rotationMax[i] >= PI - EPSILON) {
continue; // unconstrained
}
glm::vec3 axis;
axis[i] = 1.0f;
glm::vec3 otherAxis;
if (i == 0) {
otherAxis.y = 1.0f;
} else {
otherAxis.x = 1.0f;
}
glm::vec4 color(otherAxis.r, otherAxis.g, otherAxis.b, 0.75f);
QVector<glm::vec3> points;
points << glm::vec3(0.0f, 0.0f, 0.0f);
const int FAN_SEGMENTS = 16;
for (int j = 0; j < FAN_SEGMENTS; j++) {
glm::vec3 rotated = glm::angleAxis(glm::mix(joint.rotationMin[i], joint.rotationMax[i],
(float)j / (FAN_SEGMENTS - 1)), axis) * otherAxis;
points << rotated;
}
// TODO: this is really inefficient constantly recreating these vertices buffers. It would be
// better if the skeleton model cached these buffers for each of the joints they are rendering
geometryCache->updateVertices(_triangleFanID, points, color);
geometryCache->renderVertices(batch, gpu::TRIANGLE_FAN, _triangleFanID);
}
renderOrientationDirections(batch, jointIndex, position, _rotation * jointState.getRotation(), directionSize);
jointIndex = joint.parentIndex;
} while (jointIndex != -1 && geometry.joints.at(jointIndex).isFree);
}
void SkeletonModel::renderOrientationDirections(gpu::Batch& batch, int jointIndex,
glm::vec3 position, const glm::quat& orientation, float size) {
auto geometryCache = DependencyManager::get<GeometryCache>();
if (!_jointOrientationLines.contains(jointIndex)) {
OrientationLineIDs jointLineIDs;
jointLineIDs._up = geometryCache->allocateID();
jointLineIDs._front = geometryCache->allocateID();
jointLineIDs._right = geometryCache->allocateID();
_jointOrientationLines[jointIndex] = jointLineIDs;
}
OrientationLineIDs& jointLineIDs = _jointOrientationLines[jointIndex];
glm::vec3 pRight = position + orientation * IDENTITY_RIGHT * size;
glm::vec3 pUp = position + orientation * IDENTITY_UP * size;
glm::vec3 pFront = position + orientation * IDENTITY_FRONT * size;
glm::vec3 red(1.0f, 0.0f, 0.0f);
geometryCache->renderLine(batch, position, pRight, red, jointLineIDs._right);
glm::vec3 green(0.0f, 1.0f, 0.0f);
geometryCache->renderLine(batch, position, pUp, green, jointLineIDs._up);
glm::vec3 blue(0.0f, 0.0f, 1.0f);
geometryCache->renderLine(batch, position, pFront, blue, jointLineIDs._front);
}
bool SkeletonModel::getLeftHandPosition(glm::vec3& position) const { bool SkeletonModel::getLeftHandPosition(glm::vec3& position) const {
return getJointPositionInWorldFrame(getLeftHandJointIndex(), position); return getJointPositionInWorldFrame(getLeftHandJointIndex(), position);
} }
@ -421,6 +323,8 @@ bool SkeletonModel::getLocalNeckPosition(glm::vec3& neckPosition) const {
return isActive() && getJointPosition(_geometry->getFBXGeometry().neckJointIndex, neckPosition); return isActive() && getJointPosition(_geometry->getFBXGeometry().neckJointIndex, neckPosition);
} }
// AJT: REMOVE
/*
bool SkeletonModel::getNeckParentRotationFromDefaultOrientation(glm::quat& neckParentRotation) const { bool SkeletonModel::getNeckParentRotationFromDefaultOrientation(glm::quat& neckParentRotation) const {
if (!isActive()) { if (!isActive()) {
return false; return false;
@ -437,6 +341,7 @@ bool SkeletonModel::getNeckParentRotationFromDefaultOrientation(glm::quat& neckP
} }
return success; return success;
} }
*/
bool SkeletonModel::getEyeModelPositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePosition) const { bool SkeletonModel::getEyeModelPositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePosition) const {
if (!isActive()) { if (!isActive()) {

View file

@ -33,7 +33,10 @@ public:
virtual void updateRig(float deltaTime, glm::mat4 parentTransform) override; virtual void updateRig(float deltaTime, glm::mat4 parentTransform) override;
void updateAttitude(); void updateAttitude();
// AJT: REMOVE
/*
void renderIKConstraints(gpu::Batch& batch); void renderIKConstraints(gpu::Batch& batch);
*/
/// Returns the index of the left hand joint, or -1 if not found. /// Returns the index of the left hand joint, or -1 if not found.
int getLeftHandJointIndex() const { return isActive() ? _geometry->getFBXGeometry().leftHandJointIndex : -1; } int getLeftHandJointIndex() const { return isActive() ? _geometry->getFBXGeometry().leftHandJointIndex : -1; }
@ -82,10 +85,13 @@ public:
bool getNeckPosition(glm::vec3& neckPosition) const; bool getNeckPosition(glm::vec3& neckPosition) const;
bool getLocalNeckPosition(glm::vec3& neckPosition) const; bool getLocalNeckPosition(glm::vec3& neckPosition) const;
// AJT: REMOVE
/*
/// Returns the rotation of the neck joint's parent from default orientation /// Returns the rotation of the neck joint's parent from default orientation
/// \return whether or not the neck was found /// \return whether or not the neck was found
bool getNeckParentRotationFromDefaultOrientation(glm::quat& neckParentRotation) const; bool getNeckParentRotationFromDefaultOrientation(glm::quat& neckParentRotation) const;
*/
/// Retrieve the positions of up to two eye meshes. /// Retrieve the positions of up to two eye meshes.
/// \return whether or not both eye meshes were found /// \return whether or not both eye meshes were found
@ -117,18 +123,6 @@ protected:
void applyPalmData(int jointIndex, const PalmData& palm); void applyPalmData(int jointIndex, const PalmData& palm);
private: private:
void renderJointConstraints(gpu::Batch& batch, int jointIndex);
void renderOrientationDirections(gpu::Batch& batch, int jointIndex,
glm::vec3 position, const glm::quat& orientation, float size);
struct OrientationLineIDs {
int _up;
int _front;
int _right;
};
QHash<int, OrientationLineIDs> _jointOrientationLines;
int _triangleFanID;
bool getEyeModelPositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePosition) const; bool getEyeModelPositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePosition) const;
Avatar* _owningAvatar; Avatar* _owningAvatar;

View file

@ -299,12 +299,15 @@ void Rig::reset(const QVector<FBXJoint>& fbxJoints) {
} }
} }
// AJT: REMOVE
/*
JointState Rig::getJointState(int jointIndex) const { JointState Rig::getJointState(int jointIndex) const {
if (jointIndex == -1 || jointIndex >= _jointStates.size()) { if (jointIndex == -1 || jointIndex >= _jointStates.size()) {
return JointState(); return JointState();
} }
return _jointStates[jointIndex]; return _jointStates[jointIndex];
} }
*/
bool Rig::getJointStateRotation(int index, glm::quat& rotation) const { bool Rig::getJointStateRotation(int index, glm::quat& rotation) const {
if (AJT_HACK_USE_JOINT_STATES) { // AJT: LEGACY if (AJT_HACK_USE_JOINT_STATES) { // AJT: LEGACY
@ -453,7 +456,7 @@ bool Rig::getJointRotation(int jointIndex, glm::quat& rotation) const {
rotation = _jointStates[jointIndex].getRotation(); rotation = _jointStates[jointIndex].getRotation();
} }
if (jointIndex >= 0 && jointIndex < _relativePoses.size()) { if (jointIndex >= 0 && jointIndex < (int)_relativePoses.size()) {
rotation = _relativePoses[jointIndex].rot; rotation = _relativePoses[jointIndex].rot;
return true; return true;
} else { } else {
@ -470,7 +473,7 @@ bool Rig::getJointTranslation(int jointIndex, glm::vec3& translation) const {
translation = _jointStates[jointIndex].getTranslation(); translation = _jointStates[jointIndex].getTranslation();
} }
if (jointIndex >= 0 && jointIndex < _relativePoses.size()) { if (jointIndex >= 0 && jointIndex < (int)_relativePoses.size()) {
translation = _relativePoses[jointIndex].trans; translation = _relativePoses[jointIndex].trans;
return true; return true;
} else { } else {
@ -1020,12 +1023,14 @@ void Rig::clearJointStatePriorities() {
} }
} }
/*
void Rig::applyJointRotationDelta(int jointIndex, const glm::quat& delta, float priority) { void Rig::applyJointRotationDelta(int jointIndex, const glm::quat& delta, float priority) {
if (jointIndex == -1 || _jointStates.isEmpty()) { if (jointIndex == -1 || _jointStates.isEmpty()) {
return; return;
} }
_jointStates[jointIndex].applyRotationDelta(delta, priority); _jointStates[jointIndex].applyRotationDelta(delta, priority);
} }
*/
glm::quat Rig::getJointDefaultRotationInParentFrame(int jointIndex) { glm::quat Rig::getJointDefaultRotationInParentFrame(int jointIndex) {
if (jointIndex == -1 || _jointStates.isEmpty()) { if (jointIndex == -1 || _jointStates.isEmpty()) {
@ -1400,6 +1405,7 @@ glm::mat4 Rig::getJointTransform(int jointIndex) const {
} }
void Rig::copyJointsIntoJointData(QVector<JointData>& jointDataVec) const { void Rig::copyJointsIntoJointData(QVector<JointData>& jointDataVec) const {
jointDataVec.resize(getJointStateCount());
for (int i = 0; i < jointDataVec.size(); i++) { for (int i = 0; i < jointDataVec.size(); i++) {
JointData& data = jointDataVec[i]; JointData& data = jointDataVec[i];
data.rotationSet |= getJointStateRotation(i, data.rotation); data.rotationSet |= getJointStateRotation(i, data.rotation);

View file

@ -102,8 +102,11 @@ public:
void reset(const QVector<FBXJoint>& fbxJoints); void reset(const QVector<FBXJoint>& fbxJoints);
bool getJointStateRotation(int index, glm::quat& rotation) const; bool getJointStateRotation(int index, glm::quat& rotation) const;
bool getJointStateTranslation(int index, glm::vec3& translation) const; bool getJointStateTranslation(int index, glm::vec3& translation) const;
// AJT: REMOVE
/*
void applyJointRotationDelta(int jointIndex, const glm::quat& delta, float priority); void applyJointRotationDelta(int jointIndex, const glm::quat& delta, float priority);
JointState getJointState(int jointIndex) const; // XXX JointState getJointState(int jointIndex) const; // XXX
*/
void clearJointState(int index); void clearJointState(int index);
void clearJointStates(); void clearJointStates();
void clearJointAnimationPriority(int index); void clearJointAnimationPriority(int index);