mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 23:14:34 +02:00
remove nakedGL from skeleton IK constraint rendering
This commit is contained in:
parent
5a927c4c90
commit
8bb6616a25
3 changed files with 18 additions and 18 deletions
|
@ -333,8 +333,9 @@ void MyAvatar::render(RenderArgs* renderArgs, const glm::vec3& cameraPosition, b
|
||||||
Avatar::render(renderArgs, cameraPosition, postLighting);
|
Avatar::render(renderArgs, cameraPosition, postLighting);
|
||||||
|
|
||||||
// don't display IK constraints in shadow mode
|
// don't display IK constraints in shadow mode
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::ShowIKConstraints) && postLighting) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::ShowIKConstraints) &&
|
||||||
_skeletonModel.renderIKConstraints();
|
renderArgs && renderArgs->_batch) {
|
||||||
|
_skeletonModel.renderIKConstraints(*renderArgs->_batch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -186,9 +186,9 @@ void SkeletonModel::getHandShapes(int jointIndex, QVector<const Shape*>& shapes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonModel::renderIKConstraints() {
|
void SkeletonModel::renderIKConstraints(gpu::Batch& batch) {
|
||||||
renderJointConstraints(getRightHandJointIndex());
|
renderJointConstraints(batch, getRightHandJointIndex());
|
||||||
renderJointConstraints(getLeftHandJointIndex());
|
renderJointConstraints(batch, getLeftHandJointIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
class IndexValue {
|
class IndexValue {
|
||||||
|
@ -312,26 +312,27 @@ void SkeletonModel::maybeUpdateEyeRotation(const JointState& parentState, const
|
||||||
_owningAvatar->getHead()->getFaceModel().maybeUpdateEyeRotation(this, parentState, joint, state);
|
_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()) {
|
if (jointIndex == -1 || jointIndex >= _jointStates.size()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const FBXGeometry& geometry = _geometry->getFBXGeometry();
|
const FBXGeometry& geometry = _geometry->getFBXGeometry();
|
||||||
const float BASE_DIRECTION_SIZE = 0.3f;
|
const float BASE_DIRECTION_SIZE = 0.3f;
|
||||||
float directionSize = BASE_DIRECTION_SIZE * extractUniformScale(_scale);
|
float directionSize = BASE_DIRECTION_SIZE * extractUniformScale(_scale);
|
||||||
glLineWidth(3.0f);
|
batch._glLineWidth(3.0f);
|
||||||
do {
|
do {
|
||||||
const FBXJoint& joint = geometry.joints.at(jointIndex);
|
const FBXJoint& joint = geometry.joints.at(jointIndex);
|
||||||
const JointState& jointState = _jointStates.at(jointIndex);
|
const JointState& jointState = _jointStates.at(jointIndex);
|
||||||
glm::vec3 position = _rotation * jointState.getPosition() + _translation;
|
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::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;
|
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;
|
const int AXIS_COUNT = 3;
|
||||||
|
|
||||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||||
|
@ -362,7 +363,7 @@ void SkeletonModel::renderJointConstraints(int jointIndex) {
|
||||||
// TODO: this is really inefficient constantly recreating these vertices buffers. It would be
|
// 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
|
// better if the skeleton model cached these buffers for each of the joints they are rendering
|
||||||
geometryCache->updateVertices(_triangleFanID, points, color);
|
geometryCache->updateVertices(_triangleFanID, points, color);
|
||||||
geometryCache->renderVertices(gpu::TRIANGLE_FAN, _triangleFanID);
|
geometryCache->renderVertices(batch, gpu::TRIANGLE_FAN, _triangleFanID);
|
||||||
|
|
||||||
}
|
}
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
@ -371,8 +372,6 @@ void SkeletonModel::renderJointConstraints(int jointIndex) {
|
||||||
jointIndex = joint.parentIndex;
|
jointIndex = joint.parentIndex;
|
||||||
|
|
||||||
} while (jointIndex != -1 && geometry.joints.at(jointIndex).isFree);
|
} 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) {
|
void SkeletonModel::renderOrientationDirections(int jointIndex, glm::vec3 position, const glm::quat& orientation, float size) {
|
||||||
|
|
|
@ -36,7 +36,7 @@ public:
|
||||||
/// \param shapes[out] list in which is stored pointers to hand shapes
|
/// \param shapes[out] list in which is stored pointers to hand shapes
|
||||||
void getHandShapes(int jointIndex, QVector<const Shape*>& shapes) const;
|
void getHandShapes(int jointIndex, QVector<const Shape*>& shapes) const;
|
||||||
|
|
||||||
void renderIKConstraints();
|
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; }
|
||||||
|
@ -144,7 +144,7 @@ protected:
|
||||||
|
|
||||||
private:
|
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);
|
void renderOrientationDirections(int jointIndex, glm::vec3 position, const glm::quat& orientation, float size);
|
||||||
|
|
||||||
struct OrientationLineIDs {
|
struct OrientationLineIDs {
|
||||||
|
|
Loading…
Reference in a new issue