mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 06:44:06 +02:00
Snap grid overlay to major worldlines
This commit is contained in:
parent
fd6aa9a78b
commit
0b4e82405f
1 changed files with 7 additions and 2 deletions
|
@ -59,9 +59,14 @@ void Grid3DOverlay::render(RenderArgs* args) {
|
|||
if (_followCamera) {
|
||||
auto avatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
|
||||
|
||||
// Add the camera position at the plane of the avatar's base (the floor)
|
||||
auto cameraPosition = args->_viewFrustum->getPosition();
|
||||
// Get the camera position rounded to the nearest major grid line
|
||||
// This grid is for UI and should lie on worldlines
|
||||
auto cameraPosition =
|
||||
(float)_majorGridEvery * glm::round(args->_viewFrustum->getPosition() / (float)_majorGridEvery);
|
||||
|
||||
// Get the plane of the avatar's feet (or collision ground)
|
||||
auto avatarBaseHeight = avatar->getPosition().y - avatar->getUniformScale();
|
||||
|
||||
position += glm::vec3(cameraPosition.x, avatarBaseHeight, cameraPosition.z);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue