mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 01:00:50 +02:00
Adjust clip distance as HMD head moves backwards
This commit is contained in:
parent
a04bd09b83
commit
7b54443bda
1 changed files with 10 additions and 0 deletions
|
@ -1037,6 +1037,16 @@ void MyAvatar::renderBody(ViewFrustum* renderFrustum, RenderMode renderMode, boo
|
|||
camera->setNearClip(DEFAULT_NEAR_CLIP);
|
||||
} else {
|
||||
float clipDistance = _skeletonModel.getHeadClipDistance();
|
||||
if (OculusManager::isConnected()) {
|
||||
// If avatar is horizontally in front of camera, increase clip distance by the amount it is in front.
|
||||
glm::vec3 cameraToAvatar = _position - cameraPos;
|
||||
cameraToAvatar.y = 0.0f;
|
||||
glm::vec3 cameraLookAt = camera->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f);
|
||||
float headOffset = glm::dot(cameraLookAt, cameraToAvatar);
|
||||
if (headOffset > 0) {
|
||||
clipDistance += headOffset;
|
||||
}
|
||||
}
|
||||
camera->setNearClip(clipDistance);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue