History

Tweaks to voxel editing: edit from farther away, expand cubes to make sure they show up over voxels, initialize voxel scale with moused-over scale.

Andrzej Kapolka committed 13 years ago

Commit 0c8799b1 parent 27ed5332 files · +15 −4Browse files

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

Unified · Split

interface/src/Application.cpp+14−4
@@ -124,6 +124,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 123 unmodified lines
124124 _isHoverVoxel(false),
125125 _isHoverVoxelSounding(false),
126126 _mouseVoxelScale(1.0f / 1024.0f),
127+ _mouseVoxelScaleInitialized(false),
127128 _justEditedVoxel(false),
128129 _nudgeStarted(false),
129130 _lookingAlongX(false),
@@ -1782,7 +1783,7 @@ void Application::shrinkMirrorView() { · 1652 unmodified lines
17821783 }
17831784
17841785 const float MAX_AVATAR_EDIT_VELOCITY = 1.0f;
1785−const float MAX_VOXEL_EDIT_DISTANCE = 20.0f;
1786+const float MAX_VOXEL_EDIT_DISTANCE = 50.0f;
17861787 const float HEAD_SPHERE_RADIUS = 0.07;
17871788
17881789 static QUuid DEFAULT_NODE_ID_REF;
@@ -2051,6 +2052,8 @@ void Application::updateMouseVoxels(float deltaTime, glm::vec3& mouseRayOrigin, · 262 unmodified lines
20512052 PerformanceWarning warn(showWarnings, "Application::updateMouseVoxels()");
20522053
20532054 _mouseVoxel.s = 0.0f;
2055+ bool wasInitialized = _mouseVoxelScaleInitialized;
2056+ _mouseVoxelScaleInitialized = false;
20542057 if (Menu::getInstance()->isVoxelModeActionChecked() &&
20552058 (fabs(_myAvatar.getVelocity().x) +
20562059 fabs(_myAvatar.getVelocity().y) +
@@ -2058,6 +2061,12 @@ void Application::updateMouseVoxels(float deltaTime, glm::vec3& mouseRayOrigin, · 1 unmodified line
20582061
20592062 if (_voxels.findRayIntersection(mouseRayOrigin, mouseRayDirection, _mouseVoxel, distance, face)) {
20602063 if (distance < MAX_VOXEL_EDIT_DISTANCE) {
2064+ // set the voxel scale to that of the first moused-over voxel
2065+ if (!wasInitialized) {
2066+ _mouseVoxelScale = _mouseVoxel.s;
2067+ }
2068+ _mouseVoxelScaleInitialized = true;
2069+
20612070 // find the nearest voxel with the desired scale
20622071 if (_mouseVoxelScale > _mouseVoxel.s) {
20632072 // choose the larger voxel that encompasses the one selected
@@ -2990,6 +2999,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 926 unmodified lines
29902999 glDisable(GL_LIGHTING);
29913000 glPushMatrix();
29923001 glScalef(TREE_SCALE, TREE_SCALE, TREE_SCALE);
3002+ const float CUBE_EXPANSION = 1.01f;
29933003 if (_nudgeStarted) {
29943004 renderNudgeGuide(_nudgeGuidePosition.x, _nudgeGuidePosition.y, _nudgeGuidePosition.z, _nudgeVoxel.s);
29953005 renderNudgeGrid(_nudgeVoxel.x, _nudgeVoxel.y, _nudgeVoxel.z, _nudgeVoxel.s, _mouseVoxel.s);
@@ -2999,7 +3009,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 3 unmodified lines
29993009 _nudgeVoxel.z + _nudgeVoxel.s * 0.5f);
30003010 glColor3ub(255, 255, 255);
30013011 glLineWidth(4.0f);
3002− glutWireCube(_nudgeVoxel.s);
3012+ glutWireCube(_nudgeVoxel.s * CUBE_EXPANSION);
30033013 glPopMatrix();
30043014 } else {
30053015 renderMouseVoxelGrid(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s);
@@ -3018,13 +3028,13 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 12 unmodified lines
30183028 _nudgeGuidePosition.y + _nudgeVoxel.s*0.5f,
30193029 _nudgeGuidePosition.z + _nudgeVoxel.s*0.5f);
30203030 glLineWidth(4.0f);
3021− glutWireCube(_nudgeVoxel.s);
3031+ glutWireCube(_nudgeVoxel.s * CUBE_EXPANSION);
30223032 } else {
30233033 glTranslatef(_mouseVoxel.x + _mouseVoxel.s*0.5f,
30243034 _mouseVoxel.y + _mouseVoxel.s*0.5f,
30253035 _mouseVoxel.z + _mouseVoxel.s*0.5f);
30263036 glLineWidth(4.0f);
3027− glutWireCube(_mouseVoxel.s);
3037+ glutWireCube(_mouseVoxel.s * CUBE_EXPANSION);
30283038 }
30293039 glLineWidth(1.0f);
30303040 glPopMatrix();

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