mirror of
https://github.com/overte-org/overte.git
synced 2025-08-13 01:54:58 +02:00
Set clip near distance per skeleton model if no separate head model
This commit is contained in:
parent
468b62e536
commit
a04bd09b83
3 changed files with 22 additions and 4 deletions
|
@ -1028,7 +1028,18 @@ void MyAvatar::renderBody(ViewFrustum* renderFrustum, RenderMode renderMode, boo
|
|||
if (!(_skeletonModel.isRenderable() && getHead()->getFaceModel().isRenderable())) {
|
||||
return; // wait until both models are loaded
|
||||
}
|
||||
|
||||
|
||||
Camera *camera = Application::getInstance()->getCamera();
|
||||
const glm::vec3 cameraPos = camera->getPosition();
|
||||
|
||||
// Set near clip distance according to skeleton model dimensions if first person and there is no separate head model.
|
||||
if (shouldRenderHead(cameraPos, renderMode) || !getHead()->getFaceModel().getURL().isEmpty()) {
|
||||
camera->setNearClip(DEFAULT_NEAR_CLIP);
|
||||
} else {
|
||||
float clipDistance = _skeletonModel.getHeadClipDistance();
|
||||
camera->setNearClip(clipDistance);
|
||||
}
|
||||
|
||||
// Render the body's voxels and head
|
||||
Model::RenderMode modelRenderMode = (renderMode == SHADOW_RENDER_MODE) ?
|
||||
Model::SHADOW_RENDER_MODE : Model::DEFAULT_RENDER_MODE;
|
||||
|
@ -1040,8 +1051,6 @@ void MyAvatar::renderBody(ViewFrustum* renderFrustum, RenderMode renderMode, boo
|
|||
}
|
||||
|
||||
// Render head so long as the camera isn't inside it
|
||||
const Camera *camera = Application::getInstance()->getCamera();
|
||||
const glm::vec3 cameraPos = camera->getPosition();
|
||||
if (shouldRenderHead(cameraPos, renderMode)) {
|
||||
getHead()->render(1.0f, renderFrustum, modelRenderMode, postLighting);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,8 @@ SkeletonModel::SkeletonModel(Avatar* owningAvatar, QObject* parent) :
|
|||
_defaultEyeModelPosition(glm::vec3(0.0f, 0.0f, 0.0f)),
|
||||
_standingFoot(NO_FOOT),
|
||||
_standingOffset(0.0f),
|
||||
_clampedFootPosition(0.0f)
|
||||
_clampedFootPosition(0.0f),
|
||||
_headClipDistance(DEFAULT_NEAR_CLIP)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -78,6 +79,10 @@ void SkeletonModel::setJointStates(QVector<JointState> states) {
|
|||
buildShapes();
|
||||
}
|
||||
|
||||
Extents meshExtents = getMeshExtents();
|
||||
_headClipDistance = -(meshExtents.minimum.z / _scale.z - _defaultEyeModelPosition.z);
|
||||
_headClipDistance = std::max(_headClipDistance, DEFAULT_NEAR_CLIP);
|
||||
|
||||
emit skeletonLoaded();
|
||||
}
|
||||
|
||||
|
|
|
@ -110,6 +110,8 @@ public:
|
|||
|
||||
bool hasSkeleton();
|
||||
|
||||
float getHeadClipDistance() const { return _headClipDistance; }
|
||||
|
||||
signals:
|
||||
|
||||
void skeletonLoaded();
|
||||
|
@ -160,6 +162,8 @@ private:
|
|||
int _standingFoot;
|
||||
glm::vec3 _standingOffset;
|
||||
glm::vec3 _clampedFootPosition;
|
||||
|
||||
float _headClipDistance; // Near clip distance to use if no separate head model
|
||||
};
|
||||
|
||||
#endif // hifi_SkeletonModel_h
|
||||
|
|
Loading…
Reference in a new issue