From 8bb6616a2587ddd815063965f683ce5ed8580ea3 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 14 Jul 2015 18:47:35 -0700 Subject: [PATCH] remove nakedGL from skeleton IK constraint rendering --- interface/src/avatar/MyAvatar.cpp | 5 +++-- interface/src/avatar/SkeletonModel.cpp | 27 +++++++++++++------------- interface/src/avatar/SkeletonModel.h | 4 ++-- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index e532890b25..053ce7b3cc 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -333,8 +333,9 @@ void MyAvatar::render(RenderArgs* renderArgs, const glm::vec3& cameraPosition, b Avatar::render(renderArgs, cameraPosition, postLighting); // don't display IK constraints in shadow mode - if (Menu::getInstance()->isOptionChecked(MenuOption::ShowIKConstraints) && postLighting) { - _skeletonModel.renderIKConstraints(); + if (Menu::getInstance()->isOptionChecked(MenuOption::ShowIKConstraints) && + renderArgs && renderArgs->_batch) { + _skeletonModel.renderIKConstraints(*renderArgs->_batch); } } diff --git a/interface/src/avatar/SkeletonModel.cpp b/interface/src/avatar/SkeletonModel.cpp index 20d458195d..b20d2d354f 100644 --- a/interface/src/avatar/SkeletonModel.cpp +++ b/interface/src/avatar/SkeletonModel.cpp @@ -186,9 +186,9 @@ void SkeletonModel::getHandShapes(int jointIndex, QVector& shapes) } } -void SkeletonModel::renderIKConstraints() { - renderJointConstraints(getRightHandJointIndex()); - renderJointConstraints(getLeftHandJointIndex()); +void SkeletonModel::renderIKConstraints(gpu::Batch& batch) { + renderJointConstraints(batch, getRightHandJointIndex()); + renderJointConstraints(batch, getLeftHandJointIndex()); } class IndexValue { @@ -312,26 +312,27 @@ void SkeletonModel::maybeUpdateEyeRotation(const JointState& parentState, const _owningAvatar->getHead()->getFaceModel().maybeUpdateEyeRotation(this, parentState, joint, state); } -void SkeletonModel::renderJointConstraints(int jointIndex) { +void SkeletonModel::renderJointConstraints(gpu::Batch& batch, int jointIndex) { if (jointIndex == -1 || jointIndex >= _jointStates.size()) { return; } const FBXGeometry& geometry = _geometry->getFBXGeometry(); const float BASE_DIRECTION_SIZE = 0.3f; float directionSize = BASE_DIRECTION_SIZE * extractUniformScale(_scale); - glLineWidth(3.0f); + batch._glLineWidth(3.0f); do { const FBXJoint& joint = geometry.joints.at(jointIndex); const JointState& jointState = _jointStates.at(jointIndex); glm::vec3 position = _rotation * jointState.getPosition() + _translation; - - glPushMatrix(); - glTranslatef(position.x, position.y, position.z); glm::quat parentRotation = (joint.parentIndex == -1) ? _rotation : _rotation * _jointStates.at(joint.parentIndex).getRotation(); - glm::vec3 rotationAxis = glm::axis(parentRotation); - glRotatef(glm::degrees(glm::angle(parentRotation)), rotationAxis.x, rotationAxis.y, rotationAxis.z); float fanScale = directionSize * 0.75f; - glScalef(fanScale, fanScale, fanScale); + + Transform transform = Transform(); + transform.setTranslation(position); + transform.setRotation(parentRotation); + transform.setScale(fanScale); + batch.setModelTransform(transform); + const int AXIS_COUNT = 3; auto geometryCache = DependencyManager::get(); @@ -362,7 +363,7 @@ void SkeletonModel::renderJointConstraints(int jointIndex) { // 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(gpu::TRIANGLE_FAN, _triangleFanID); + geometryCache->renderVertices(batch, gpu::TRIANGLE_FAN, _triangleFanID); } glPopMatrix(); @@ -371,8 +372,6 @@ void SkeletonModel::renderJointConstraints(int jointIndex) { jointIndex = joint.parentIndex; } while (jointIndex != -1 && geometry.joints.at(jointIndex).isFree); - - glLineWidth(1.0f); } void SkeletonModel::renderOrientationDirections(int jointIndex, glm::vec3 position, const glm::quat& orientation, float size) { diff --git a/interface/src/avatar/SkeletonModel.h b/interface/src/avatar/SkeletonModel.h index 755aa3dfee..3d63238cf2 100644 --- a/interface/src/avatar/SkeletonModel.h +++ b/interface/src/avatar/SkeletonModel.h @@ -36,7 +36,7 @@ public: /// \param shapes[out] list in which is stored pointers to hand shapes void getHandShapes(int jointIndex, QVector& shapes) const; - void renderIKConstraints(); + void renderIKConstraints(gpu::Batch& batch); /// Returns the index of the left hand joint, or -1 if not found. int getLeftHandJointIndex() const { return isActive() ? _geometry->getFBXGeometry().leftHandJointIndex : -1; } @@ -144,7 +144,7 @@ protected: private: - void renderJointConstraints(int jointIndex); + void renderJointConstraints(gpu::Batch& batch, int jointIndex); void renderOrientationDirections(int jointIndex, glm::vec3 position, const glm::quat& orientation, float size); struct OrientationLineIDs {