History

Orbit around voxel center, limit hover distance.

Andrzej Kapolka committed 12 years ago

Commit 9d831a21 parent 7abb7d93 files · +9 −8Browse files

Showing the changes to interface/src/Application.cpp (1 of 3 files). Show all

Unified · Split

interface/src/Application.cpp+7−6
@@ -1121,7 +1121,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 1120 unmodified lines
11211121 return;
11221122 }
11231123 if (_isHoverVoxel) {
1124− _myAvatar.orbit(glm::vec3(_hoverVoxel.x, _hoverVoxel.y, _hoverVoxel.z) * (float)TREE_SCALE, deltaX, deltaY);
1124+ _myAvatar.orbit(getMouseVoxelWorldCoordinates(_hoverVoxel), deltaX, deltaY);
11251125 return;
11261126 }
11271127 }
@@ -1618,10 +1618,9 @@ void Application::makeVoxel(glm::vec3 position, · 490 unmodified lines
16181618 isDestructive);
16191619 }
16201620
1621−const glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail _mouseVoxel) {
1622− return glm::vec3((_mouseVoxel.x + _mouseVoxel.s / 2.f) * TREE_SCALE,
1623− (_mouseVoxel.y + _mouseVoxel.s / 2.f) * TREE_SCALE,
1624− (_mouseVoxel.z + _mouseVoxel.s / 2.f) * TREE_SCALE);
1621+glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail& mouseVoxel) {
1622+ return glm::vec3((mouseVoxel.x + mouseVoxel.s / 2.f) * TREE_SCALE, (mouseVoxel.y + mouseVoxel.s / 2.f) * TREE_SCALE,
1623+ (mouseVoxel.z + mouseVoxel.s / 2.f) * TREE_SCALE);
16251624 }
16261625
16271626 const float NUDGE_PRECISION_MIN = 1 / pow(2.0, 12.0);
@@ -2245,7 +2244,9 @@ void Application::updateHoverVoxels(float deltaTime, glm::vec3& mouseRayOrigin, · 617 unmodified lines
22452244 if (!(_voxels.treeIsBusy() || _mousePressed)) {
22462245 {
22472246 PerformanceWarning warn(showWarnings, "Application::updateHoverVoxels() _voxels.findRayIntersection()");
2248− _isHoverVoxel = _voxels.findRayIntersection(mouseRayOrigin, mouseRayDirection, _hoverVoxel, distance, face);
2247+ const float MAX_HOVER_DISTANCE = 100.0f;
2248+ _isHoverVoxel = _voxels.findRayIntersection(mouseRayOrigin, mouseRayDirection, _hoverVoxel, distance, face) &&
2249+ glm::distance(getMouseVoxelWorldCoordinates(_hoverVoxel), mouseRayOrigin) < MAX_HOVER_DISTANCE;
22492250 }
22502251 if (MAKE_SOUND_ON_VOXEL_HOVER && _isHoverVoxel &&
22512252 glm::vec4(_hoverVoxel.x, _hoverVoxel.y, _hoverVoxel.z, _hoverVoxel.s) != oldVoxel) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t