Showing the changes to interface/src/Application.cpp (1 of 188 files). Show all
Unified · Split
| @@ -71,6 +71,7 @@ · 70 unmodified lines | ||
| 71 | 71 | #include <PacketHeaders.h> |
| 72 | 72 | #include <PathUtils.h> |
| 73 | 73 | #include <PerfStat.h> |
| 74 | +#include <PhysicsEngine.h> | |
| 74 | 75 | #include <ProgramObject.h> |
| 75 | 76 | #include <ResourceCache.h> |
| 76 | 77 | #include <SoundCache.h> |
| @@ -157,6 +158,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 80 unmodified lines | ||
| 157 | 158 | _voxelImporter(), |
| 158 | 159 | _importSucceded(false), |
| 159 | 160 | _sharedVoxelSystem(TREE_SCALE, DEFAULT_MAX_VOXELS_PER_SYSTEM, &_clipboard), |
| 161 | +#ifdef USE_BULLET_PHYSICS | |
| 162 | + _physicsEngine(glm::vec3(0.0f)), | |
| 163 | +#endif // USE_BULLET_PHYSICS | |
| 160 | 164 | _entities(true, this, this), |
| 161 | 165 | _entityCollisionSystem(), |
| 162 | 166 | _entityClipboardRenderer(false, this, this), |
| @@ -2028,6 +2032,12 @@ void Application::init() { · 1865 unmodified lines | ||
| 2028 | 2032 | // save settings when avatar changes |
| 2029 | 2033 | connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings); |
| 2030 | 2034 | |
| 2035 | +#ifdef USE_BULLET_PHYSICS | |
| 2036 | + EntityTree* tree = _entities.getTree(); | |
| 2037 | + _physicsEngine.setEntityTree(tree); | |
| 2038 | + tree->setSimulation(&_physicsEngine); | |
| 2039 | + _physicsEngine.init(&_entityEditSender); | |
| 2040 | +#endif // USE_BULLET_PHYSICS | |
| 2031 | 2041 | // make sure our texture cache knows about window size changes |
| 2032 | 2042 | DependencyManager::get<TextureCache>()->associateWithWidget(glCanvas.data()); |
| 2033 | 2043 | |
| @@ -2337,6 +2347,13 @@ void Application::update(float deltaTime) { · 303 unmodified lines | ||
| 2337 | 2347 | updateDialogs(deltaTime); // update various stats dialogs if present |
| 2338 | 2348 | updateCursor(deltaTime); // Handle cursor updates |
| 2339 | 2349 | |
| 2350 | +#ifdef USE_BULLET_PHYSICS | |
| 2351 | + { | |
| 2352 | + PerformanceTimer perfTimer("physics"); | |
| 2353 | + _physicsEngine.stepSimulation(); | |
| 2354 | + } | |
| 2355 | +#endif // USE_BULLET_PHYSICS | |
| 2356 | + | |
| 2340 | 2357 | if (!_aboutToQuit) { |
| 2341 | 2358 | PerformanceTimer perfTimer("entities"); |
| 2342 | 2359 | // NOTE: the _entities.update() call below will wait for lock |
| @@ -2880,18 +2897,18 @@ void Application::updateShadowMap() { · 537 unmodified lines | ||
| 2880 | 2897 | |
| 2881 | 2898 | { |
| 2882 | 2899 | PerformanceTimer perfTimer("entities"); |
| 2883 | − _entities.render(RenderArgs::SHADOW_RENDER_MODE); | |
| 2900 | + // _entities.render(RenderArgs::SHADOW_RENDER_MODE); | |
| 2884 | 2901 | } |
| 2885 | 2902 | |
| 2886 | 2903 | // render JS/scriptable overlays |
| 2887 | 2904 | { |
| 2888 | 2905 | PerformanceTimer perfTimer("3dOverlays"); |
| 2889 | − _overlays.render3D(false, RenderArgs::SHADOW_RENDER_MODE); | |
| 2906 | + _overlays.renderWorld(false, RenderArgs::SHADOW_RENDER_MODE); | |
| 2890 | 2907 | } |
| 2891 | 2908 | |
| 2892 | 2909 | { |
| 2893 | 2910 | PerformanceTimer perfTimer("3dOverlaysFront"); |
| 2894 | − _overlays.render3D(true, RenderArgs::SHADOW_RENDER_MODE); | |
| 2911 | + _overlays.renderWorld(true, RenderArgs::SHADOW_RENDER_MODE); | |
| 2895 | 2912 | } |
| 2896 | 2913 | |
| 2897 | 2914 | glDisable(GL_POLYGON_OFFSET_FILL); |
| @@ -3119,7 +3136,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr · 221 unmodified lines | ||
| 3119 | 3136 | // render JS/scriptable overlays |
| 3120 | 3137 | { |
| 3121 | 3138 | PerformanceTimer perfTimer("3dOverlays"); |
| 3122 | − _overlays.render3D(false); | |
| 3139 | + _overlays.renderWorld(false); | |
| 3123 | 3140 | } |
| 3124 | 3141 | |
| 3125 | 3142 | // render the ambient occlusion effect if enabled |
| @@ -3208,7 +3225,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr · 82 unmodified lines | ||
| 3208 | 3225 | { |
| 3209 | 3226 | PerformanceTimer perfTimer("3dOverlaysFront"); |
| 3210 | 3227 | glClear(GL_DEPTH_BUFFER_BIT); |
| 3211 | − _overlays.render3D(true); | |
| 3228 | + _overlays.renderWorld(true); | |
| 3212 | 3229 | } |
| 3213 | 3230 | } |
| 3214 | 3231 | |
| @@ -3626,16 +3643,6 @@ void Application::updateWindowTitle(){ · 411 unmodified lines | ||
| 3626 | 3643 | QString title = QString() + (!username.isEmpty() ? username + " @ " : QString()) |
| 3627 | 3644 | + DependencyManager::get<AddressManager>()->getCurrentDomain() + connectionStatus + buildVersion; |
| 3628 | 3645 | |
| 3629 | − AccountManager& accountManager = AccountManager::getInstance(); | |
| 3630 | − if (accountManager.getAccountInfo().hasBalance()) { | |
| 3631 | − float creditBalance = accountManager.getAccountInfo().getBalance() / SATOSHIS_PER_CREDIT; | |
| 3632 | − | |
| 3633 | − QString creditBalanceString; | |
| 3634 | − creditBalanceString.sprintf("%.8f", creditBalance); | |
| 3635 | − | |
| 3636 | − title += " - ₵" + creditBalanceString; | |
| 3637 | − } | |
| 3638 | − | |
| 3639 | 3646 | #ifndef WIN32 |
| 3640 | 3647 | // crashes with vs2013/win32 |
| 3641 | 3648 | qDebug("Application title set to: %s", title.toStdString().c_str()); |
| @@ -4197,6 +4204,25 @@ void Application::openUrl(const QUrl& url) { · 555 unmodified lines | ||
| 4197 | 4204 | } |
| 4198 | 4205 | } |
| 4199 | 4206 | |
| 4207 | +void Application::updateMyAvatarTransform() { | |
| 4208 | + bumpSettings(); | |
| 4209 | +#ifdef USE_BULLET_PHYSICS | |
| 4210 | + const float SIMULATION_OFFSET_QUANTIZATION = 16.0f; // meters | |
| 4211 | + glm::vec3 avatarPosition = _myAvatar->getPosition(); | |
| 4212 | + glm::vec3 physicsWorldOffset = _physicsEngine.getOriginOffset(); | |
| 4213 | + if (glm::distance(avatarPosition, physicsWorldOffset) > SIMULATION_OFFSET_QUANTIZATION) { | |
| 4214 | + glm::vec3 newOriginOffset = avatarPosition; | |
| 4215 | + int halfExtent = (int)HALF_SIMULATION_EXTENT; | |
| 4216 | + for (int i = 0; i < 3; ++i) { | |
| 4217 | + newOriginOffset[i] = (float)(glm::max(halfExtent, | |
| 4218 | + ((int)(avatarPosition[i] / SIMULATION_OFFSET_QUANTIZATION)) * (int)SIMULATION_OFFSET_QUANTIZATION)); | |
| 4219 | + } | |
| 4220 | + // TODO: Andrew to replace this with method that actually moves existing object positions in PhysicsEngine | |
| 4221 | + _physicsEngine.setOriginOffset(newOriginOffset); | |
| 4222 | + } | |
| 4223 | +#endif // USE_BULLET_PHYSICS | |
| 4224 | +} | |
| 4225 | + | |
| 4200 | 4226 | void Application::domainSettingsReceived(const QJsonObject& domainSettingsObject) { |
| 4201 | 4227 | |
| 4202 | 4228 | // from the domain-handler, figure out the satoshi cost per voxel and per meter cubed |