From ee1340706610e99aaa605610e85a03cd27a769f4 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 29 Jun 2015 17:04:30 -0700 Subject: [PATCH 01/15] Fix smart pointer casts --- interface/src/Application.cpp | 12 ++++++------ interface/src/Application.h | 2 +- interface/src/avatar/Avatar.cpp | 4 ++-- interface/src/avatar/MyAvatar.cpp | 4 ++-- interface/src/devices/Faceshift.cpp | 4 ++-- interface/src/ui/overlays/Overlays.cpp | 18 +++++++++--------- .../entities/src/EntityScriptingInterface.cpp | 6 +++--- libraries/render/src/render/Scene.h | 2 +- 8 files changed, 26 insertions(+), 26 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 4b9d97ee08..c39a08bd27 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2230,8 +2230,8 @@ void Application::shrinkMirrorView() { const float HEAD_SPHERE_RADIUS = 0.1f; -bool Application::isLookingAtMyAvatar(Avatar* avatar) { - glm::vec3 theirLookAt = avatar->getHead()->getLookAtPosition(); +bool Application::isLookingAtMyAvatar(AvatarSharedPointer avatar) { + glm::vec3 theirLookAt = dynamic_pointer_cast(avatar)->getHead()->getLookAtPosition(); glm::vec3 myEyePosition = _myAvatar->getHead()->getEyePosition(); if (pointInSphere(theirLookAt, myEyePosition, HEAD_SPHERE_RADIUS * _myAvatar->getScale())) { return true; @@ -2303,17 +2303,17 @@ void Application::updateMyAvatarLookAtPosition() { // If a face tracker is active, look at the eye for the side my gaze is biased toward if (tracker->getEstimatedEyeYaw() > _myAvatar->getHead()->getFinalYaw()) { // Look at their right eye - lookAtSpot = static_cast(lookingAt.get())->getHead()->getRightEyePosition(); + lookAtSpot = static_pointer_cast(lookingAt)->getHead()->getRightEyePosition(); } else { // Look at their left eye - lookAtSpot = static_cast(lookingAt.get())->getHead()->getLeftEyePosition(); + lookAtSpot = static_pointer_cast(lookingAt)->getHead()->getLeftEyePosition(); } } else { // Need to add randomly looking back and forth between left and right eye for case with no tracker if (_myAvatar->isLookingAtLeftEye()) { - lookAtSpot = static_cast(lookingAt.get())->getHead()->getLeftEyePosition(); + lookAtSpot = static_pointer_cast(lookingAt)->getHead()->getLeftEyePosition(); } else { - lookAtSpot = static_cast(lookingAt.get())->getHead()->getRightEyePosition(); + lookAtSpot = static_pointer_cast(lookingAt)->getHead()->getRightEyePosition(); } } } else { diff --git a/interface/src/Application.h b/interface/src/Application.h index 8dd987fbcd..e5e49187f3 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -322,7 +322,7 @@ public: QStringList getRunningScripts() { return _scriptEnginesHash.keys(); } ScriptEngine* getScriptEngine(QString scriptHash) { return _scriptEnginesHash.contains(scriptHash) ? _scriptEnginesHash[scriptHash] : NULL; } - bool isLookingAtMyAvatar(Avatar* avatar); + bool isLookingAtMyAvatar(AvatarSharedPointer avatar); float getRenderResolutionScale() const; int getRenderAmbientLight() const; diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index 6ff8fb52df..8d72e1a78c 100644 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -65,10 +65,10 @@ namespace render { return ItemKey::Builder::opaqueShape(); } template <> const Item::Bound payloadGetBound(const AvatarSharedPointer& avatar) { - return static_cast(avatar.get())->getBounds(); + return static_pointer_cast(avatar)->getBounds(); } template <> void payloadRender(const AvatarSharedPointer& avatar, RenderArgs* args) { - Avatar* avatarPtr = static_cast(avatar.get()); + auto avatarPtr = static_pointer_cast(avatar); bool renderLookAtVectors = Menu::getInstance()->isOptionChecked(MenuOption::RenderLookAtVectors); avatarPtr->setDisplayingLookatVectors(renderLookAtVectors); diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index c6a4ae39aa..b1703c2a23 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -882,7 +882,7 @@ void MyAvatar::updateLookAtTargetAvatar() { int howManyLookingAtMe = 0; foreach (const AvatarSharedPointer& avatarPointer, DependencyManager::get()->getAvatarHash()) { - Avatar* avatar = static_cast(avatarPointer.get()); + auto avatar = static_pointer_cast(avatarPointer); bool isCurrentTarget = avatar->getIsLookAtTarget(); float distanceTo = glm::length(avatar->getHead()->getEyePosition() - cameraPosition); avatar->setIsLookAtTarget(false); @@ -912,7 +912,7 @@ void MyAvatar::updateLookAtTargetAvatar() { } auto avatarPointer = _lookAtTargetAvatar.lock(); if (avatarPointer) { - static_cast(avatarPointer.get())->setIsLookAtTarget(true); + static_pointer_cast(avatarPointer)->setIsLookAtTarget(true); } } diff --git a/interface/src/devices/Faceshift.cpp b/interface/src/devices/Faceshift.cpp index b517f9d67b..33124858c5 100644 --- a/interface/src/devices/Faceshift.cpp +++ b/interface/src/devices/Faceshift.cpp @@ -208,7 +208,7 @@ void Faceshift::receive(const QByteArray& buffer) { for (fsMsgPtr msg; (msg = _stream.get_message()); ) { switch (msg->id()) { case fsMsg::MSG_OUT_TRACKING_STATE: { - const fsTrackingData& data = static_cast(msg.get())->tracking_data(); + const fsTrackingData& data = static_pointer_cast(msg)->tracking_data(); if ((_tracking = data.m_trackingSuccessful)) { glm::quat newRotation = glm::quat(data.m_headRotation.w, -data.m_headRotation.x, data.m_headRotation.y, -data.m_headRotation.z); @@ -256,7 +256,7 @@ void Faceshift::receive(const QByteArray& buffer) { break; } case fsMsg::MSG_OUT_BLENDSHAPE_NAMES: { - const vector& names = static_cast(msg.get())->blendshape_names(); + const vector& names = static_pointer_cast(msg)->blendshape_names(); for (size_t i = 0; i < names.size(); i++) { if (names[i] == "EyeBlink_L") { _leftBlinkIndex = i; diff --git a/interface/src/ui/overlays/Overlays.cpp b/interface/src/ui/overlays/Overlays.cpp index dc49478f38..3948b208b0 100644 --- a/interface/src/ui/overlays/Overlays.cpp +++ b/interface/src/ui/overlays/Overlays.cpp @@ -207,7 +207,7 @@ bool Overlays::editOverlay(unsigned int id, const QScriptValue& properties) { if (thisOverlay) { if (thisOverlay->is3D()) { - Base3DOverlay* overlay3D = static_cast(thisOverlay.get()); + auto overlay3D = std::static_pointer_cast(thisOverlay); bool oldDrawOnHUD = overlay3D->getDrawOnHUD(); thisOverlay->setProperties(properties); @@ -269,15 +269,15 @@ unsigned int Overlays::getOverlayAtPoint(const glm::vec2& point) { i.previous(); unsigned int thisID = i.key(); if (i.value()->is3D()) { - Base3DOverlay* thisOverlay = static_cast(i.value().get()); - if (!thisOverlay->getIgnoreRayIntersection()) { + auto thisOverlay = std::dynamic_pointer_cast(i.value()); + if (thisOverlay && !thisOverlay->getIgnoreRayIntersection()) { if (thisOverlay->findRayIntersection(origin, direction, distance, thisFace)) { return thisID; } } } else { - Overlay2D* thisOverlay = static_cast(i.value().get()); - if (thisOverlay->getVisible() && thisOverlay->isLoaded() && + auto thisOverlay = std::dynamic_pointer_cast(i.value()); + if (thisOverlay && thisOverlay->getVisible() && thisOverlay->isLoaded() && thisOverlay->getBoundingRect().contains(pointCopy.x, pointCopy.y, false)) { return thisID; } @@ -341,8 +341,8 @@ RayToOverlayIntersectionResult Overlays::findRayIntersection(const PickRay& ray) while (i.hasPrevious()) { i.previous(); unsigned int thisID = i.key(); - Base3DOverlay* thisOverlay = static_cast(i.value().get()); - if (thisOverlay->getVisible() && !thisOverlay->getIgnoreRayIntersection() && thisOverlay->isLoaded()) { + auto thisOverlay = std::dynamic_pointer_cast(i.value()); + if (thisOverlay && thisOverlay->getVisible() && !thisOverlay->getIgnoreRayIntersection() && thisOverlay->isLoaded()) { float thisDistance; BoxFace thisFace; QString thisExtraInfo; @@ -458,13 +458,13 @@ QSizeF Overlays::textSize(unsigned int id, const QString& text) const { Overlay::Pointer thisOverlay = _overlaysHUD[id]; if (thisOverlay) { if (typeid(*thisOverlay) == typeid(TextOverlay)) { - return static_cast(thisOverlay.get())->textSize(text); + return std::dynamic_pointer_cast(thisOverlay)->textSize(text); } } else { thisOverlay = _overlaysWorld[id]; if (thisOverlay) { if (typeid(*thisOverlay) == typeid(Text3DOverlay)) { - return static_cast(thisOverlay.get())->textSize(text); + return std::dynamic_pointer_cast(thisOverlay)->textSize(text); } } } diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index c9f7378bc8..4de03053bb 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -411,7 +411,7 @@ bool EntityScriptingInterface::setVoxels(QUuid entityID, return false; } - EntityItemPointer entity = static_cast(_entityTree->findEntityByEntityItemID(entityID)); + EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID); if (!entity) { qCDebug(entities) << "EntityScriptingInterface::setVoxelSphere no entity with ID" << entityID; return false; @@ -424,7 +424,7 @@ bool EntityScriptingInterface::setVoxels(QUuid entityID, auto now = usecTimestampNow(); - PolyVoxEntityItem* polyVoxEntity = static_cast(entity.get()); + auto polyVoxEntity = std::dynamic_pointer_cast(entity); _entityTree->lockForWrite(); actor(*polyVoxEntity); entity->setLastEdited(now); @@ -460,7 +460,7 @@ bool EntityScriptingInterface::setPoints(QUuid entityID, std::function(entity.get()); + auto lineEntity = std::static_pointer_cast(entity); _entityTree->lockForWrite(); bool success = actor(*lineEntity); entity->setLastEdited(now); diff --git a/libraries/render/src/render/Scene.h b/libraries/render/src/render/Scene.h index 5ec9f0c951..ae5a5b0f23 100644 --- a/libraries/render/src/render/Scene.h +++ b/libraries/render/src/render/Scene.h @@ -314,7 +314,7 @@ protected: DataPointer _data; // Update mechanics - virtual void update(const UpdateFunctorPointer& functor) { static_cast(functor.get())->_func((*_data)); } + virtual void update(const UpdateFunctorPointer& functor) { std::static_pointer_cast(functor)->_func((*_data)); } friend class Item; }; From 7b5a5a339abbb4e7f77f13d4da0c04f73d1e94e2 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Wed, 1 Jul 2015 19:46:06 -0700 Subject: [PATCH 02/15] Use make_shared/create to make shared pointers --- ice-server/src/IceServer.cpp | 2 +- interface/src/Application.cpp | 10 +- interface/src/avatar/MyAvatar.cpp | 4 +- interface/src/devices/Joystick.cpp | 2 +- interface/src/devices/KeyboardMouseDevice.cpp | 2 +- interface/src/devices/SixenseManager.cpp | 2 +- interface/src/ui/ApplicationCompositor.cpp | 6 +- libraries/avatars/src/AvatarData.cpp | 6 +- libraries/avatars/src/AvatarHashMap.cpp | 2 +- libraries/avatars/src/Player.cpp | 2 +- libraries/avatars/src/Recording.cpp | 4 +- .../src/RenderableBoxEntityItem.cpp | 2 +- .../src/RenderableEntityItem.h | 4 +- .../src/RenderableLightEntityItem.cpp | 2 +- .../src/RenderableLineEntityItem.cpp | 2 +- .../src/RenderableModelEntityItem.cpp | 6 +- .../RenderableParticleEffectEntityItem.cpp | 2 +- .../src/RenderablePolyVoxEntityItem.cpp | 9 +- .../src/RenderableSphereEntityItem.cpp | 2 +- .../src/RenderableTextEntityItem.cpp | 2 +- .../src/RenderableWebEntityItem.cpp | 2 +- .../src/RenderableZoneEntityItem.cpp | 6 +- libraries/entities/src/ModelEntityItem.cpp | 2 +- .../entities/src/ParticleEffectEntityItem.cpp | 2 +- libraries/entities/src/PolyVoxEntityItem.cpp | 7 +- libraries/entities/src/TextEntityItem.cpp | 2 +- libraries/entities/src/WebEntityItem.cpp | 2 +- libraries/entities/src/ZoneEntityItem.cpp | 2 +- libraries/fbx/src/FBXReader.cpp | 10 +- libraries/fbx/src/OBJReader.cpp | 2 +- libraries/gpu/src/gpu/GLBackendState.cpp | 60 +++--- libraries/gpu/src/gpu/Texture.cpp | 6 +- libraries/model/src/model/Light.cpp | 2 +- libraries/model/src/model/Material.cpp | 2 +- libraries/model/src/model/Skybox.cpp | 8 +- libraries/model/src/model/Stage.cpp | 11 +- libraries/networking/src/NetworkPeer.cpp | 2 +- .../src/DeferredLightingEffect.cpp | 8 +- libraries/render-utils/src/Environment.cpp | 2 +- libraries/render-utils/src/GeometryCache.cpp | 172 +++++++++--------- libraries/render-utils/src/Model.cpp | 26 +-- libraries/render-utils/src/OglplusHelpers.cpp | 2 +- .../render-utils/src/RenderDeferredTask.cpp | 4 +- libraries/render-utils/src/TextRenderer3D.cpp | 6 +- libraries/render/src/render/DrawTask.h | 6 +- libraries/render/src/render/Engine.cpp | 6 +- libraries/render/src/render/Scene.h | 2 +- .../src/SceneScriptingInterface.h | 2 +- libraries/shared/src/Transform.h | 3 +- libraries/ui/src/InfoView.cpp | 2 +- tools/scribe/src/TextTemplate.cpp | 22 +-- tools/scribe/src/TextTemplate.h | 2 +- tools/scribe/src/main.cpp | 4 +- 53 files changed, 233 insertions(+), 237 deletions(-) diff --git a/ice-server/src/IceServer.cpp b/ice-server/src/IceServer.cpp index 8b5e5a4b39..d660b12b87 100644 --- a/ice-server/src/IceServer.cpp +++ b/ice-server/src/IceServer.cpp @@ -110,7 +110,7 @@ SharedNetworkPeer IceServer::addOrUpdateHeartbeatingPeer(const QByteArray& incom if (!matchingPeer) { // if we don't have this sender we need to create them now - matchingPeer = SharedNetworkPeer(new NetworkPeer(senderUUID, publicSocket, localSocket)); + matchingPeer = QSharedPointer::create(senderUUID, publicSocket, localSocket); _activePeers.insert(senderUUID, matchingPeer); qDebug() << "Added a new network peer" << *matchingPeer; diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index c39a08bd27..4352d1a75b 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -374,7 +374,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : _bookmarks = new Bookmarks(); // Before setting up the menu _runningScriptsWidget = new RunningScriptsWidget(_window); - _renderEngine->addTask(render::TaskPointer(new RenderDeferredTask())); + _renderEngine->addTask(make_shared()); _renderEngine->registerScene(_main3DScene); // start the nodeThread so its event loop is running @@ -3426,8 +3426,8 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se // Background rendering decision if (BackgroundRenderData::_item == 0) { - auto backgroundRenderData = BackgroundRenderData::Pointer(new BackgroundRenderData(&_environment)); - auto backgroundRenderPayload = render::PayloadPointer(new BackgroundRenderData::Payload(backgroundRenderData)); + auto backgroundRenderData = make_shared(&_environment); + auto backgroundRenderPayload = make_shared(backgroundRenderData); BackgroundRenderData::_item = _main3DScene->allocateID(); pendingChanges.resetItem(WorldBoxRenderData::_item, backgroundRenderPayload); } else { @@ -3475,8 +3475,8 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se // Make sure the WorldBox is in the scene if (WorldBoxRenderData::_item == 0) { - auto worldBoxRenderData = WorldBoxRenderData::Pointer(new WorldBoxRenderData()); - auto worldBoxRenderPayload = render::PayloadPointer(new WorldBoxRenderData::Payload(worldBoxRenderData)); + auto worldBoxRenderData = make_shared(); + auto worldBoxRenderPayload = make_shared(worldBoxRenderData); WorldBoxRenderData::_item = _main3DScene->allocateID(); diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index b1703c2a23..f1f34db9b3 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -434,7 +434,7 @@ void MyAvatar::startRecording() { return; } if (!_recorder) { - _recorder = RecorderPointer(new Recorder(this)); + _recorder = QSharedPointer::create(this); } // connect to AudioClient's signal so we get input audio auto audioClient = DependencyManager::get(); @@ -486,7 +486,7 @@ void MyAvatar::loadLastRecording() { return; } if (!_player) { - _player = PlayerPointer(new Player(this)); + _player = QSharedPointer::create(this); } _player->loadRecording(_recorder->getRecording()); diff --git a/interface/src/devices/Joystick.cpp b/interface/src/devices/Joystick.cpp index 91f3b98bac..8cb1c3fa6b 100644 --- a/interface/src/devices/Joystick.cpp +++ b/interface/src/devices/Joystick.cpp @@ -103,7 +103,7 @@ void Joystick::registerToUserInputMapper(UserInputMapper& mapper) { // Grab the current free device ID _deviceID = mapper.getFreeDeviceID(); - auto proxy = UserInputMapper::DeviceProxy::Pointer(new UserInputMapper::DeviceProxy(_name)); + auto proxy = std::make_shared(_name); proxy->getButton = [this] (const UserInputMapper::Input& input, int timestamp) -> bool { return this->getButton(input.getChannel()); }; proxy->getAxis = [this] (const UserInputMapper::Input& input, int timestamp) -> float { return this->getAxis(input.getChannel()); }; proxy->getAvailabeInputs = [this] () -> QVector { diff --git a/interface/src/devices/KeyboardMouseDevice.cpp b/interface/src/devices/KeyboardMouseDevice.cpp index dd8de00bc7..6eb675114b 100755 --- a/interface/src/devices/KeyboardMouseDevice.cpp +++ b/interface/src/devices/KeyboardMouseDevice.cpp @@ -159,7 +159,7 @@ void KeyboardMouseDevice::registerToUserInputMapper(UserInputMapper& mapper) { // Grab the current free device ID _deviceID = mapper.getFreeDeviceID(); - auto proxy = UserInputMapper::DeviceProxy::Pointer(new UserInputMapper::DeviceProxy("Keyboard")); + auto proxy = std::make_shared("Keyboard"); proxy->getButton = [this] (const UserInputMapper::Input& input, int timestamp) -> bool { return this->getButton(input.getChannel()); }; proxy->getAxis = [this] (const UserInputMapper::Input& input, int timestamp) -> float { return this->getAxis(input.getChannel()); }; proxy->getAvailabeInputs = [this] () -> QVector { diff --git a/interface/src/devices/SixenseManager.cpp b/interface/src/devices/SixenseManager.cpp index 12b6f4263b..2a2adbe617 100644 --- a/interface/src/devices/SixenseManager.cpp +++ b/interface/src/devices/SixenseManager.cpp @@ -662,7 +662,7 @@ void SixenseManager::registerToUserInputMapper(UserInputMapper& mapper) { // Grab the current free device ID _deviceID = mapper.getFreeDeviceID(); - auto proxy = UserInputMapper::DeviceProxy::Pointer(new UserInputMapper::DeviceProxy("Hydra")); + auto proxy = std::make_shared("Hydra"); proxy->getButton = [this] (const UserInputMapper::Input& input, int timestamp) -> bool { return this->getButton(input.getChannel()); }; proxy->getAxis = [this] (const UserInputMapper::Input& input, int timestamp) -> float { return this->getAxis(input.getChannel()); }; proxy->getAvailabeInputs = [this] () -> QVector { diff --git a/interface/src/ui/ApplicationCompositor.cpp b/interface/src/ui/ApplicationCompositor.cpp index 6cdf690d99..d1f7c67e51 100644 --- a/interface/src/ui/ApplicationCompositor.cpp +++ b/interface/src/ui/ApplicationCompositor.cpp @@ -620,8 +620,8 @@ void ApplicationCompositor::buildHemiVertices( auto geometryCache = DependencyManager::get(); - _hemiVertices = gpu::BufferPointer(new gpu::Buffer()); - _hemiIndices = gpu::BufferPointer(new gpu::Buffer()); + _hemiVertices = std::make_shared(); + _hemiIndices = std::make_shared(); if (fov >= PI) { @@ -683,7 +683,7 @@ void ApplicationCompositor::drawSphereSection(gpu::Batch& batch) { static const int VERTEX_DATA_SLOT = 0; static const int TEXTURE_DATA_SLOT = 1; static const int COLOR_DATA_SLOT = 2; - gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); // 1 for everyone + auto streamFormat = std::make_shared(); // 1 for everyone streamFormat->setAttribute(gpu::Stream::POSITION, VERTEX_DATA_SLOT, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ), 0); streamFormat->setAttribute(gpu::Stream::TEXCOORD, TEXTURE_DATA_SLOT, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::UV)); streamFormat->setAttribute(gpu::Stream::COLOR, COLOR_DATA_SLOT, gpu::Element(gpu::VEC4, gpu::FLOAT, gpu::RGBA)); diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index 9a6400ae16..0266c1f697 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -617,7 +617,7 @@ void AvatarData::loadRecording(QString filename) { return; } if (!_player) { - _player = PlayerPointer(new Player(this)); + _player = QSharedPointer::create(this); } _player->loadFromFile(filename); @@ -629,7 +629,7 @@ void AvatarData::startPlaying() { return; } if (!_player) { - _player = PlayerPointer(new Player(this)); + _player = QSharedPointer::create(this); } _player->startPlaying(); } @@ -731,7 +731,7 @@ void AvatarData::stopPlaying() { } } -void AvatarData::changeReferential(Referential *ref) { +void AvatarData::changeReferential(Referential* ref) { delete _referential; _referential = ref; } diff --git a/libraries/avatars/src/AvatarHashMap.cpp b/libraries/avatars/src/AvatarHashMap.cpp index 6d0d9d8d76..12c9f5c5e7 100644 --- a/libraries/avatars/src/AvatarHashMap.cpp +++ b/libraries/avatars/src/AvatarHashMap.cpp @@ -51,7 +51,7 @@ bool AvatarHashMap::isAvatarInRange(const glm::vec3& position, const float range } AvatarSharedPointer AvatarHashMap::newSharedAvatar() { - return AvatarSharedPointer(new AvatarData()); + return std::make_shared(); } AvatarSharedPointer AvatarHashMap::addAvatar(const QUuid& sessionUUID, const QWeakPointer& mixerWeakPointer) { diff --git a/libraries/avatars/src/Player.cpp b/libraries/avatars/src/Player.cpp index d3f33ca7c8..e7d94f0735 100644 --- a/libraries/avatars/src/Player.cpp +++ b/libraries/avatars/src/Player.cpp @@ -202,7 +202,7 @@ void Player::loadFromFile(const QString& file) { if (_recording) { _recording->clear(); } else { - _recording = RecordingPointer(new Recording()); + _recording = QSharedPointer(); } readRecordingFromFile(_recording, file); diff --git a/libraries/avatars/src/Recording.cpp b/libraries/avatars/src/Recording.cpp index ce0855462b..76e1d68050 100644 --- a/libraries/avatars/src/Recording.cpp +++ b/libraries/avatars/src/Recording.cpp @@ -417,7 +417,7 @@ RecordingPointer readRecordingFromFile(RecordingPointer recording, const QString // Reset the recording passed in the arguments if (!recording) { - recording.reset(new Recording()); + recording = QSharedPointer::create(); } QDataStream fileStream(byteArray); @@ -652,7 +652,7 @@ RecordingPointer readRecordingFromRecFile(RecordingPointer recording, const QStr timer.start(); if (!recording) { - recording.reset(new Recording()); + recording = QSharedPointer::create(); } QDataStream fileStream(byteArray); diff --git a/libraries/entities-renderer/src/RenderableBoxEntityItem.cpp b/libraries/entities-renderer/src/RenderableBoxEntityItem.cpp index 23b93250bc..a7a59ac88d 100644 --- a/libraries/entities-renderer/src/RenderableBoxEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableBoxEntityItem.cpp @@ -23,7 +23,7 @@ #include "RenderableDebugableEntityItem.h" EntityItemPointer RenderableBoxEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { - return EntityItemPointer(new RenderableBoxEntityItem(entityID, properties)); + return std::make_shared(entityID, properties); } void RenderableBoxEntityItem::render(RenderArgs* args) { diff --git a/libraries/entities-renderer/src/RenderableEntityItem.h b/libraries/entities-renderer/src/RenderableEntityItem.h index 2037788ace..1832ef28c3 100644 --- a/libraries/entities-renderer/src/RenderableEntityItem.h +++ b/libraries/entities-renderer/src/RenderableEntityItem.h @@ -37,8 +37,8 @@ public: bool addToScene(EntityItemPointer self, std::shared_ptr scene, render::PendingChanges& pendingChanges) { _myItem = scene->allocateID(); - auto renderData = RenderableEntityItemProxy::Pointer(new RenderableEntityItemProxy(self)); - auto renderPayload = render::PayloadPointer(new RenderableEntityItemProxy::Payload(renderData)); + auto renderData = std::make_shared(self); + auto renderPayload = std::make_shared(renderData); pendingChanges.resetItem(_myItem, renderPayload); diff --git a/libraries/entities-renderer/src/RenderableLightEntityItem.cpp b/libraries/entities-renderer/src/RenderableLightEntityItem.cpp index 819989d5ec..010a204810 100644 --- a/libraries/entities-renderer/src/RenderableLightEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableLightEntityItem.cpp @@ -21,7 +21,7 @@ #include "RenderableLightEntityItem.h" EntityItemPointer RenderableLightEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { - return EntityItemPointer(new RenderableLightEntityItem(entityID, properties)); + return std::make_shared(entityID, properties); } void RenderableLightEntityItem::render(RenderArgs* args) { diff --git a/libraries/entities-renderer/src/RenderableLineEntityItem.cpp b/libraries/entities-renderer/src/RenderableLineEntityItem.cpp index 6eb575814a..03e4890445 100644 --- a/libraries/entities-renderer/src/RenderableLineEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableLineEntityItem.cpp @@ -21,7 +21,7 @@ #include "RenderableLineEntityItem.h" EntityItemPointer RenderableLineEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { - return EntityItemPointer(new RenderableLineEntityItem(entityID, properties)); + return std::make_shared(entityID, properties); } void RenderableLineEntityItem::updateGeometry() { diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index 14a64d289e..90d9e4e942 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -26,7 +26,7 @@ #include "RenderableModelEntityItem.h" EntityItemPointer RenderableModelEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { - return EntityItemPointer(new RenderableModelEntityItem(entityID, properties)); + return std::make_shared(entityID, properties); } RenderableModelEntityItem::~RenderableModelEntityItem() { @@ -171,8 +171,8 @@ bool RenderableModelEntityItem::addToScene(EntityItemPointer self, std::shared_p render::PendingChanges& pendingChanges) { _myMetaItem = scene->allocateID(); - auto renderData = RenderableModelEntityItemMeta::Pointer(new RenderableModelEntityItemMeta(self)); - auto renderPayload = render::PayloadPointer(new RenderableModelEntityItemMeta::Payload(renderData)); + auto renderData = std::make_shared(self); + auto renderPayload = std::make_shared(renderData); pendingChanges.resetItem(_myMetaItem, renderPayload); diff --git a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp index d00728a9eb..4277452b2b 100644 --- a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp @@ -21,7 +21,7 @@ #include "RenderableParticleEffectEntityItem.h" EntityItemPointer RenderableParticleEffectEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { - return EntityItemPointer(new RenderableParticleEffectEntityItem(entityID, properties)); + return std::make_shared(entityID, properties); } RenderableParticleEffectEntityItem::RenderableParticleEffectEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) : diff --git a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp index 46cfcefa40..8daa674e03 100644 --- a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp @@ -42,7 +42,7 @@ #include "RenderablePolyVoxEntityItem.h" EntityItemPointer RenderablePolyVoxEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { - return EntityItemPointer(new RenderablePolyVoxEntityItem(entityID, properties)); + return std::make_shared(entityID, properties); } RenderablePolyVoxEntityItem::RenderablePolyVoxEntityItem(const EntityItemID& entityItemID, @@ -351,15 +351,16 @@ void RenderablePolyVoxEntityItem::getModel() { auto mesh = _modelGeometry.getMesh(); const std::vector& vecIndices = polyVoxMesh.getIndices(); - auto indexBuffer = new gpu::Buffer(vecIndices.size() * sizeof(uint32_t), (gpu::Byte*)vecIndices.data()); + auto indexBuffer = std::make_shared(vecIndices.size() * sizeof(uint32_t), + (gpu::Byte*)vecIndices.data()); auto indexBufferPtr = gpu::BufferPointer(indexBuffer); auto indexBufferView = new gpu::BufferView(indexBufferPtr, gpu::Element(gpu::SCALAR, gpu::UINT32, gpu::RAW)); mesh->setIndexBuffer(*indexBufferView); const std::vector& vecVertices = polyVoxMesh.getVertices(); - auto vertexBuffer = new gpu::Buffer(vecVertices.size() * sizeof(PolyVox::PositionMaterialNormal), - (gpu::Byte*)vecVertices.data()); + auto vertexBuffer = std::make_shared(vecVertices.size() * sizeof(PolyVox::PositionMaterialNormal), + (gpu::Byte*)vecVertices.data()); auto vertexBufferPtr = gpu::BufferPointer(vertexBuffer); auto vertexBufferView = new gpu::BufferView(vertexBufferPtr, 0, diff --git a/libraries/entities-renderer/src/RenderableSphereEntityItem.cpp b/libraries/entities-renderer/src/RenderableSphereEntityItem.cpp index 6d9cb525d6..658aaa9f4a 100644 --- a/libraries/entities-renderer/src/RenderableSphereEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableSphereEntityItem.cpp @@ -23,7 +23,7 @@ #include "RenderableDebugableEntityItem.h" EntityItemPointer RenderableSphereEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { - return EntityItemPointer(new RenderableSphereEntityItem(entityID, properties)); + return std::make_shared(entityID, properties); } void RenderableSphereEntityItem::render(RenderArgs* args) { diff --git a/libraries/entities-renderer/src/RenderableTextEntityItem.cpp b/libraries/entities-renderer/src/RenderableTextEntityItem.cpp index 245cf00a3d..52c53b3003 100644 --- a/libraries/entities-renderer/src/RenderableTextEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableTextEntityItem.cpp @@ -24,7 +24,7 @@ #include "GLMHelpers.h" EntityItemPointer RenderableTextEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { - return EntityItemPointer(new RenderableTextEntityItem(entityID, properties)); + return std::make_shared(entityID, properties); } void RenderableTextEntityItem::render(RenderArgs* args) { diff --git a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp index 94f88b8390..baa7925a65 100644 --- a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp @@ -32,7 +32,7 @@ const float DPI = 30.47f; const float METERS_TO_INCHES = 39.3701f; EntityItemPointer RenderableWebEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { - return EntityItemPointer(new RenderableWebEntityItem(entityID, properties)); + return std::make_shared(entityID, properties); } RenderableWebEntityItem::RenderableWebEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) : diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index 8c147cac05..4afca6994a 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -21,7 +21,7 @@ #include EntityItemPointer RenderableZoneEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { - return EntityItemPointer(new RenderableZoneEntityItem(entityID, properties)); + return std::make_shared(entityID, properties); } template @@ -196,8 +196,8 @@ bool RenderableZoneEntityItem::addToScene(EntityItemPointer self, std::shared_pt render::PendingChanges& pendingChanges) { _myMetaItem = scene->allocateID(); - auto renderData = RenderableZoneEntityItemMeta::Pointer(new RenderableZoneEntityItemMeta(self)); - auto renderPayload = render::PayloadPointer(new RenderableZoneEntityItemMeta::Payload(renderData)); + auto renderData = std::make_shared(self); + auto renderPayload = std::make_shared(renderData); pendingChanges.resetItem(_myMetaItem, renderPayload); return true; diff --git a/libraries/entities/src/ModelEntityItem.cpp b/libraries/entities/src/ModelEntityItem.cpp index a6ae9e04de..bd8c8d70dc 100644 --- a/libraries/entities/src/ModelEntityItem.cpp +++ b/libraries/entities/src/ModelEntityItem.cpp @@ -29,7 +29,7 @@ const float ModelEntityItem::DEFAULT_ANIMATION_FPS = 30.0f; EntityItemPointer ModelEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { - return EntityItemPointer(new ModelEntityItem(entityID, properties)); + return std::make_shared(entityID, properties); } ModelEntityItem::ModelEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) : diff --git a/libraries/entities/src/ParticleEffectEntityItem.cpp b/libraries/entities/src/ParticleEffectEntityItem.cpp index 5c8a5b63a1..a5c689fbbd 100644 --- a/libraries/entities/src/ParticleEffectEntityItem.cpp +++ b/libraries/entities/src/ParticleEffectEntityItem.cpp @@ -56,7 +56,7 @@ const QString ParticleEffectEntityItem::DEFAULT_TEXTURES = ""; EntityItemPointer ParticleEffectEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { - return EntityItemPointer(new ParticleEffectEntityItem(entityID, properties)); + return std::make_shared(entityID, properties); } // our non-pure virtual subclass for now... diff --git a/libraries/entities/src/PolyVoxEntityItem.cpp b/libraries/entities/src/PolyVoxEntityItem.cpp index 6f284caeaa..8dbf764431 100644 --- a/libraries/entities/src/PolyVoxEntityItem.cpp +++ b/libraries/entities/src/PolyVoxEntityItem.cpp @@ -28,12 +28,9 @@ const PolyVoxEntityItem::PolyVoxSurfaceStyle PolyVoxEntityItem::DEFAULT_VOXEL_SU PolyVoxEntityItem::SURFACE_MARCHING_CUBES; EntityItemPointer PolyVoxEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { - return EntityItemPointer(new PolyVoxEntityItem(entityID, properties)); + return std::make_shared(entityID, properties); } - - - QByteArray PolyVoxEntityItem::makeEmptyVoxelData(quint16 voxelXSize, quint16 voxelYSize, quint16 voxelZSize) { int rawSize = voxelXSize * voxelYSize * voxelZSize; @@ -48,8 +45,6 @@ QByteArray PolyVoxEntityItem::makeEmptyVoxelData(quint16 voxelXSize, quint16 vox return newVoxelData; } - - PolyVoxEntityItem::PolyVoxEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) : EntityItem(entityItemID), _voxelVolumeSize(PolyVoxEntityItem::DEFAULT_VOXEL_VOLUME_SIZE), diff --git a/libraries/entities/src/TextEntityItem.cpp b/libraries/entities/src/TextEntityItem.cpp index 31ee9e6676..8f50743410 100644 --- a/libraries/entities/src/TextEntityItem.cpp +++ b/libraries/entities/src/TextEntityItem.cpp @@ -30,7 +30,7 @@ const xColor TextEntityItem::DEFAULT_BACKGROUND_COLOR = { 0, 0, 0}; const bool TextEntityItem::DEFAULT_FACE_CAMERA = false; EntityItemPointer TextEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { - return EntityItemPointer(new TextEntityItem(entityID, properties)); + return std::make_shared(entityID, properties); } TextEntityItem::TextEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) : diff --git a/libraries/entities/src/WebEntityItem.cpp b/libraries/entities/src/WebEntityItem.cpp index 4c849f5270..b0b0864fdf 100644 --- a/libraries/entities/src/WebEntityItem.cpp +++ b/libraries/entities/src/WebEntityItem.cpp @@ -23,7 +23,7 @@ const QString WebEntityItem::DEFAULT_SOURCE_URL("http://www.google.com"); EntityItemPointer WebEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { - return EntityItemPointer(new WebEntityItem(entityID, properties)); + return std::make_shared(entityID, properties); } WebEntityItem::WebEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) : diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index 6f44223892..b82592f73a 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -30,7 +30,7 @@ const ShapeType ZoneEntityItem::DEFAULT_SHAPE_TYPE = SHAPE_TYPE_BOX; const QString ZoneEntityItem::DEFAULT_COMPOUND_SHAPE_URL = ""; EntityItemPointer ZoneEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { - return EntityItemPointer(new ZoneEntityItem(entityID, properties)); + return std::make_shared(entityID, properties); } ZoneEntityItem::ZoneEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) : diff --git a/libraries/fbx/src/FBXReader.cpp b/libraries/fbx/src/FBXReader.cpp index 236e2979f5..4d7bff4df0 100644 --- a/libraries/fbx/src/FBXReader.cpp +++ b/libraries/fbx/src/FBXReader.cpp @@ -1323,7 +1323,7 @@ void buildModelMesh(ExtractedMesh& extracted) { model::Mesh mesh; // Grab the vertices in a buffer - gpu::BufferPointer vb(new gpu::Buffer()); + auto vb = make_shared(); vb->setData(extracted.mesh.vertices.size() * sizeof(glm::vec3), (const gpu::Byte*) extracted.mesh.vertices.data()); gpu::BufferView vbv(vb, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); @@ -1348,7 +1348,7 @@ void buildModelMesh(ExtractedMesh& extracted) { int totalAttributeSize = clusterWeightsOffset + clusterWeightsSize; // Copy all attribute data in a single attribute buffer - gpu::BufferPointer attribBuffer(new gpu::Buffer()); + auto attribBuffer = make_shared(); attribBuffer->resize(totalAttributeSize); attribBuffer->setSubData(normalsOffset, normalsSize, (gpu::Byte*) fbxMesh.normals.constData()); attribBuffer->setSubData(tangentsOffset, tangentsSize, (gpu::Byte*) fbxMesh.tangents.constData()); @@ -1407,7 +1407,7 @@ void buildModelMesh(ExtractedMesh& extracted) { return; } - gpu::BufferPointer ib(new gpu::Buffer()); + auto ib = make_shared(); ib->resize(totalIndices * sizeof(int)); int indexNum = 0; @@ -1437,7 +1437,7 @@ void buildModelMesh(ExtractedMesh& extracted) { mesh.setIndexBuffer(ibv); if (parts.size()) { - gpu::BufferPointer pb(new gpu::Buffer()); + auto pb = make_shared(); pb->setData(parts.size() * sizeof(model::Mesh::Part), (const gpu::Byte*) parts.data()); gpu::BufferView pbv(pb, gpu::Element(gpu::VEC4, gpu::UINT32, gpu::XYZW)); mesh.setPartBuffer(pbv); @@ -1926,7 +1926,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping, } material.id = getID(object.properties); - material._material = model::MaterialPointer(new model::Material()); + material._material = make_shared(); material._material->setEmissive(material.emissive); if (glm::all(glm::equal(material.diffuse, glm::vec3(0.0f)))) { material._material->setDiffuse(material.diffuse); diff --git a/libraries/fbx/src/OBJReader.cpp b/libraries/fbx/src/OBJReader.cpp index b7fea218d8..2ec80e3d85 100644 --- a/libraries/fbx/src/OBJReader.cpp +++ b/libraries/fbx/src/OBJReader.cpp @@ -131,7 +131,7 @@ void setMeshPartDefaults(FBXMeshPart& meshPart, QString materialID) { meshPart.materialID = materialID; meshPart.opacity = 1.0; - meshPart._material = model::MaterialPointer(new model::Material()); + meshPart._material = std::make_shared(); meshPart._material->setDiffuse(glm::vec3(1.0, 1.0, 1.0)); meshPart._material->setOpacity(1.0); meshPart._material->setMetallic(0.0); diff --git a/libraries/gpu/src/gpu/GLBackendState.cpp b/libraries/gpu/src/gpu/GLBackendState.cpp index ef272bb708..0d1b0b669d 100644 --- a/libraries/gpu/src/gpu/GLBackendState.cpp +++ b/libraries/gpu/src/gpu/GLBackendState.cpp @@ -40,97 +40,99 @@ const GLBackend::GLState::Commands makeResetStateCommands() { // and we have a 50/50 chance that State::DEFAULT is not yet initialized. // Since State::DEFAULT = State::Data() it is much easier to not use the actual State::DEFAULT // but another State::Data object with a default initialization. - State::Data DEFAULT = State::Data(); + const State::Data DEFAULT = State::Data(); - CommandPointer depthBiasCommand = CommandPointer(new CommandDepthBias(&GLBackend::do_setStateDepthBias, Vec2(DEFAULT.depthBias, DEFAULT.depthBiasSlopeScale))); - CommandPointer stencilCommand = CommandPointer(new CommandStencil(&GLBackend::do_setStateStencil, DEFAULT.stencilActivation, DEFAULT.stencilTestFront, DEFAULT.stencilTestBack)); + auto depthBiasCommand = std::make_shared(&GLBackend::do_setStateDepthBias, + Vec2(DEFAULT.depthBias, DEFAULT.depthBiasSlopeScale)); + auto stencilCommand = std::make_shared(&GLBackend::do_setStateStencil, DEFAULT.stencilActivation, + DEFAULT.stencilTestFront, DEFAULT.stencilTestBack); // The state commands to reset to default, // WARNING depending on the order of the State::Field enum return { - CommandPointer(new Command1I(&GLBackend::do_setStateFillMode, DEFAULT.fillMode)), - CommandPointer(new Command1I(&GLBackend::do_setStateCullMode, DEFAULT.cullMode)), - CommandPointer(new Command1B(&GLBackend::do_setStateFrontFaceClockwise, DEFAULT.frontFaceClockwise)), - CommandPointer(new Command1B(&GLBackend::do_setStateDepthClipEnable, DEFAULT.depthClipEnable)), - CommandPointer(new Command1B(&GLBackend::do_setStateScissorEnable, DEFAULT.scissorEnable)), - CommandPointer(new Command1B(&GLBackend::do_setStateMultisampleEnable, DEFAULT.multisampleEnable)), - CommandPointer(new Command1B(&GLBackend::do_setStateAntialiasedLineEnable, DEFAULT.antialisedLineEnable)), + std::make_shared(&GLBackend::do_setStateFillMode, DEFAULT.fillMode), + std::make_shared(&GLBackend::do_setStateCullMode, DEFAULT.cullMode), + std::make_shared(&GLBackend::do_setStateFrontFaceClockwise, DEFAULT.frontFaceClockwise), + std::make_shared(&GLBackend::do_setStateDepthClipEnable, DEFAULT.depthClipEnable), + std::make_shared(&GLBackend::do_setStateScissorEnable, DEFAULT.scissorEnable), + std::make_shared(&GLBackend::do_setStateMultisampleEnable, DEFAULT.multisampleEnable), + std::make_shared(&GLBackend::do_setStateAntialiasedLineEnable, DEFAULT.antialisedLineEnable), // Depth bias has 2 fields in State but really one call in GLBackend CommandPointer(depthBiasCommand), CommandPointer(depthBiasCommand), - CommandPointer(new CommandDepthTest(&GLBackend::do_setStateDepthTest, DEFAULT.depthTest)), + std::make_shared(&GLBackend::do_setStateDepthTest, DEFAULT.depthTest), // Depth bias has 3 fields in State but really one call in GLBackend CommandPointer(stencilCommand), CommandPointer(stencilCommand), CommandPointer(stencilCommand), - CommandPointer(new Command1B(&GLBackend::do_setStateAlphaToCoverageEnable, DEFAULT.alphaToCoverageEnable)), + std::make_shared(&GLBackend::do_setStateAlphaToCoverageEnable, DEFAULT.alphaToCoverageEnable), - CommandPointer(new Command1U(&GLBackend::do_setStateSampleMask, DEFAULT.sampleMask)), + std::make_shared(&GLBackend::do_setStateSampleMask, DEFAULT.sampleMask), - CommandPointer(new CommandBlend(&GLBackend::do_setStateBlend, DEFAULT.blendFunction)), + std::make_shared(&GLBackend::do_setStateBlend, DEFAULT.blendFunction), - CommandPointer(new Command1U(&GLBackend::do_setStateColorWriteMask, DEFAULT.colorWriteMask)) + std::make_shared(&GLBackend::do_setStateColorWriteMask, DEFAULT.colorWriteMask) }; } void generateFillMode(GLBackend::GLState::Commands& commands, State::FillMode fillMode) { - commands.push_back(CommandPointer(new Command1I(&GLBackend::do_setStateFillMode, int32(fillMode)))); + commands.push_back(std::make_shared(&GLBackend::do_setStateFillMode, int32(fillMode))); } void generateCullMode(GLBackend::GLState::Commands& commands, State::CullMode cullMode) { - commands.push_back(CommandPointer(new Command1I(&GLBackend::do_setStateCullMode, int32(cullMode)))); + commands.push_back(std::make_shared(&GLBackend::do_setStateCullMode, int32(cullMode))); } void generateFrontFaceClockwise(GLBackend::GLState::Commands& commands, bool isClockwise) { - commands.push_back(CommandPointer(new Command1B(&GLBackend::do_setStateFrontFaceClockwise, isClockwise))); + commands.push_back(std::make_shared(&GLBackend::do_setStateFrontFaceClockwise, isClockwise)); } void generateDepthClipEnable(GLBackend::GLState::Commands& commands, bool enable) { - commands.push_back(CommandPointer(new Command1B(&GLBackend::do_setStateDepthClipEnable, enable))); + commands.push_back(std::make_shared(&GLBackend::do_setStateDepthClipEnable, enable)); } void generateScissorEnable(GLBackend::GLState::Commands& commands, bool enable) { - commands.push_back(CommandPointer(new Command1B(&GLBackend::do_setStateScissorEnable, enable))); + commands.push_back(std::make_shared(&GLBackend::do_setStateScissorEnable, enable)); } void generateMultisampleEnable(GLBackend::GLState::Commands& commands, bool enable) { - commands.push_back(CommandPointer(new Command1B(&GLBackend::do_setStateMultisampleEnable, enable))); + commands.push_back(std::make_shared(&GLBackend::do_setStateMultisampleEnable, enable)); } void generateAntialiasedLineEnable(GLBackend::GLState::Commands& commands, bool enable) { - commands.push_back(CommandPointer(new Command1B(&GLBackend::do_setStateAntialiasedLineEnable, enable))); + commands.push_back(std::make_shared(&GLBackend::do_setStateAntialiasedLineEnable, enable)); } void generateDepthBias(GLBackend::GLState::Commands& commands, const State& state) { - commands.push_back(CommandPointer(new CommandDepthBias(&GLBackend::do_setStateDepthBias, Vec2(state.getDepthBias(), state.getDepthBiasSlopeScale())))); + commands.push_back(std::make_shared(&GLBackend::do_setStateDepthBias, Vec2(state.getDepthBias(), state.getDepthBiasSlopeScale()))); } void generateDepthTest(GLBackend::GLState::Commands& commands, const State::DepthTest& test) { - commands.push_back(CommandPointer(new CommandDepthTest(&GLBackend::do_setStateDepthTest, int32(test.getRaw())))); + commands.push_back(std::make_shared(&GLBackend::do_setStateDepthTest, int32(test.getRaw()))); } void generateStencil(GLBackend::GLState::Commands& commands, const State& state) { - commands.push_back(CommandPointer(new CommandStencil(&GLBackend::do_setStateStencil, state.getStencilActivation(), state.getStencilTestFront(), state.getStencilTestBack()))); + commands.push_back(std::make_shared(&GLBackend::do_setStateStencil, state.getStencilActivation(), state.getStencilTestFront(), state.getStencilTestBack())); } void generateAlphaToCoverageEnable(GLBackend::GLState::Commands& commands, bool enable) { - commands.push_back(CommandPointer(new Command1B(&GLBackend::do_setStateAlphaToCoverageEnable, enable))); + commands.push_back(std::make_shared(&GLBackend::do_setStateAlphaToCoverageEnable, enable)); } void generateSampleMask(GLBackend::GLState::Commands& commands, uint32 mask) { - commands.push_back(CommandPointer(new Command1U(&GLBackend::do_setStateSampleMask, mask))); + commands.push_back(std::make_shared(&GLBackend::do_setStateSampleMask, mask)); } void generateBlend(GLBackend::GLState::Commands& commands, const State& state) { - commands.push_back(CommandPointer(new CommandBlend(&GLBackend::do_setStateBlend, state.getBlendFunction()))); + commands.push_back(std::make_shared(&GLBackend::do_setStateBlend, state.getBlendFunction())); } void generateColorWriteMask(GLBackend::GLState::Commands& commands, uint32 mask) { - commands.push_back(CommandPointer(new Command1U(&GLBackend::do_setStateColorWriteMask, mask))); + commands.push_back(std::make_shared(&GLBackend::do_setStateColorWriteMask, mask)); } GLBackend::GLState* GLBackend::syncGPUObject(const State& state) { diff --git a/libraries/gpu/src/gpu/Texture.cpp b/libraries/gpu/src/gpu/Texture.cpp index 69c00336f1..d16ab5c047 100755 --- a/libraries/gpu/src/gpu/Texture.cpp +++ b/libraries/gpu/src/gpu/Texture.cpp @@ -80,7 +80,7 @@ bool Texture::Storage::allocateMip(uint16 level) { auto& mip = _mips[level]; for (auto& face : mip) { if (!face) { - face.reset(new Pixels()); + face = std::make_shared(); changed = true; } } @@ -419,7 +419,7 @@ bool Texture::generateIrradiance() { return false; } if (!_irradiance) { - _irradiance.reset(new SphericalHarmonics()); + _irradiance = std::make_shared(); } _irradiance->evalFromTexture(*this); @@ -563,7 +563,7 @@ glm::vec3 linearTosRGB(glm::vec3& color) { return glm::pow(color, glm::vec3(GAMMA_CORRECTION_INV)); } -// Originial code for the Spherical Harmonics taken from "Sun and Black Cat- Igor Dykhta (igor dykhta email) © 2007-2014 " +// Originial code for the Spherical Harmonics taken from "Sun and Black Cat- Igor Dykhta (igor dykhta email) � 2007-2014 " void sphericalHarmonicsAdd(float * result, int order, const float * inputA, const float * inputB) { const int numCoeff = order * order; for(int i=0; i < numCoeff; i++) { diff --git a/libraries/model/src/model/Light.cpp b/libraries/model/src/model/Light.cpp index 60c6f6b3af..0d030b611f 100755 --- a/libraries/model/src/model/Light.cpp +++ b/libraries/model/src/model/Light.cpp @@ -18,7 +18,7 @@ Light::Light() : _transform() { // only if created from nothing shall we create the Buffer to store the properties Schema schema; - _schemaBuffer = gpu::BufferView(new gpu::Buffer(sizeof(Schema), (const gpu::Byte*) &schema)); + _schemaBuffer = gpu::BufferView(std::make_shared(sizeof(Schema), (const gpu::Byte*) &schema)); } Light::Light(const Light& light) : diff --git a/libraries/model/src/model/Material.cpp b/libraries/model/src/model/Material.cpp index a3448889b0..7e52212fd1 100755 --- a/libraries/model/src/model/Material.cpp +++ b/libraries/model/src/model/Material.cpp @@ -20,7 +20,7 @@ Material::Material() : // only if created from nothing shall we create the Buffer to store the properties Schema schema; - _schemaBuffer = gpu::BufferView(new gpu::Buffer(sizeof(Schema), (const gpu::Byte*) &schema)); + _schemaBuffer = gpu::BufferView(std::make_shared(sizeof(Schema), (const gpu::Byte*) &schema)); } diff --git a/libraries/model/src/model/Skybox.cpp b/libraries/model/src/model/Skybox.cpp index 10199adda3..28b4f8d0cf 100755 --- a/libraries/model/src/model/Skybox.cpp +++ b/libraries/model/src/model/Skybox.cpp @@ -68,19 +68,19 @@ void Skybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const Sky SKYBOX_CONSTANTS_SLOT = skyShader->getUniforms().findLocation("skyboxBuffer"); } - auto skyState = gpu::StatePointer(new gpu::State()); + auto skyState = std::make_shared(); thePipeline = gpu::PipelinePointer(gpu::Pipeline::create(skyShader, skyState)); const float CLIP = 1.0f; const glm::vec2 vertices[4] = { {-CLIP, -CLIP}, {CLIP, -CLIP}, {-CLIP, CLIP}, {CLIP, CLIP}}; - theBuffer.reset(new gpu::Buffer(sizeof(vertices), (const gpu::Byte*) vertices)); + theBuffer = std::make_shared(sizeof(vertices), (const gpu::Byte*) vertices); - theFormat.reset(new gpu::Stream::Format()); + theFormat = std::make_shared(); theFormat->setAttribute(gpu::Stream::POSITION, gpu::Stream::POSITION, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::XYZ)); auto color = glm::vec4(1.0f); - theConstants.reset(new gpu::Buffer(sizeof(color), (const gpu::Byte*) &color)); + theConstants = std::make_shared(sizeof(color), (const gpu::Byte*) &color); } glm::mat4 projMat; diff --git a/libraries/model/src/model/Stage.cpp b/libraries/model/src/model/Stage.cpp index 4fff47e2fd..fa086d0d2b 100644 --- a/libraries/model/src/model/Stage.cpp +++ b/libraries/model/src/model/Stage.cpp @@ -136,7 +136,7 @@ void EarthSunModel::setSunLongitude(float lon) { Atmosphere::Atmosphere() { // only if created from nothing shall we create the Buffer to store the properties Data data; - _dataBuffer = gpu::BufferView(new gpu::Buffer(sizeof(Data), (const gpu::Byte*) &data)); + _dataBuffer = gpu::BufferView(std::make_shared(sizeof(Data), (const gpu::Byte*) &data)); setScatteringWavelength(_scatteringWavelength); setRayleighScattering(_rayleighScattering); @@ -188,8 +188,8 @@ const float NUM_HOURS_PER_DAY = 24.0f; const float NUM_HOURS_PER_HALF_DAY = NUM_HOURS_PER_DAY * 0.5f; SunSkyStage::SunSkyStage() : - _sunLight(new Light()), - _skybox(new Skybox()) + _sunLight(std::make_shared()), + _skybox(std::make_shared()) { _sunLight->setType(Light::SUN); @@ -204,9 +204,8 @@ SunSkyStage::SunSkyStage() : // Begining of march setYearTime(60.0f); - _skybox.reset(new Skybox()); + _skybox = std::make_shared(); _skybox->setColor(Color(1.0f, 0.0f, 0.0f)); - } SunSkyStage::~SunSkyStage() { @@ -302,4 +301,4 @@ void SunSkyStage::setBackgroundMode(BackgroundMode mode) { void SunSkyStage::setSkybox(const SkyboxPointer& skybox) { _skybox = skybox; invalidate(); -} +} diff --git a/libraries/networking/src/NetworkPeer.cpp b/libraries/networking/src/NetworkPeer.cpp index dfa4066dd2..09ab143d55 100644 --- a/libraries/networking/src/NetworkPeer.cpp +++ b/libraries/networking/src/NetworkPeer.cpp @@ -216,7 +216,7 @@ static QHash PEER_BANDWIDTH; BandwidthRecorder& getBandwidthRecorder(const QUuid & uuid) { if (!PEER_BANDWIDTH.count(uuid)) { - PEER_BANDWIDTH.insert(uuid, BandwidthRecorderPtr(new BandwidthRecorder())); + PEER_BANDWIDTH.insert(uuid, QSharedPointer::create()); } return *PEER_BANDWIDTH[uuid].data(); } diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index b49d1985bb..4d6470c315 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -62,7 +62,7 @@ void DeferredLightingEffect::init(AbstractViewStateInterface* viewState) { gpu::Shader::makeProgram(*program, slotBindings); gpu::Shader::makeProgram(*programTextured, slotBindings); - gpu::StatePointer state = gpu::StatePointer(new gpu::State()); + auto state = std::make_shared(); state->setCullMode(gpu::State::CULL_BACK); state->setDepthTest(true, true, gpu::LESS_EQUAL); state->setBlendFunction(false, @@ -70,7 +70,7 @@ void DeferredLightingEffect::init(AbstractViewStateInterface* viewState) { gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE); - gpu::StatePointer stateCullNone = gpu::StatePointer(new gpu::State()); + auto stateCullNone = std::make_shared(); stateCullNone->setCullMode(gpu::State::CULL_NONE); stateCullNone->setDepthTest(true, true, gpu::LESS_EQUAL); stateCullNone->setBlendFunction(false, @@ -106,7 +106,7 @@ void DeferredLightingEffect::init(AbstractViewStateInterface* viewState) { // Allocate a global light representing the Global Directional light casting shadow (the sun) and the ambient light _globalLights.push_back(0); - _allocatedLights.push_back(model::LightPointer(new model::Light())); + _allocatedLights.push_back(std::make_shared()); model::LightPointer lp = _allocatedLights[0]; @@ -187,7 +187,7 @@ void DeferredLightingEffect::addSpotLight(const glm::vec3& position, float radiu unsigned int lightID = _pointLights.size() + _spotLights.size() + _globalLights.size(); if (lightID >= _allocatedLights.size()) { - _allocatedLights.push_back(model::LightPointer(new model::Light())); + _allocatedLights.push_back(std::make_shared()); } model::LightPointer lp = _allocatedLights[lightID]; diff --git a/libraries/render-utils/src/Environment.cpp b/libraries/render-utils/src/Environment.cpp index 411beca0ae..87870ca057 100644 --- a/libraries/render-utils/src/Environment.cpp +++ b/libraries/render-utils/src/Environment.cpp @@ -68,7 +68,7 @@ void Environment::setupAtmosphereProgram(const char* vertSource, const char* fra gpu::Shader::BindingSet slotBindings; gpu::Shader::makeProgram(*program, slotBindings); - gpu::StatePointer state = gpu::StatePointer(new gpu::State()); + auto state = std::make_shared(); state->setCullMode(gpu::State::CULL_NONE); state->setDepthTest(false); diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 3e7e9a0adf..33e1372278 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -83,8 +83,8 @@ void GeometryCache::renderSphere(gpu::Batch& batch, float radius, int slices, in qCDebug(renderutils) << "renderSphere()... RELEASING REGISTERED VERTICES BUFFER"; #endif } - - gpu::BufferPointer verticesBuffer(new gpu::Buffer()); + + auto verticesBuffer = std::make_shared(); if (registered) { _registeredSphereVertices[id] = verticesBuffer; _lastRegisteredSphereVertices[id] = radiusKey; @@ -148,7 +148,7 @@ void GeometryCache::renderSphere(gpu::Batch& batch, float radius, int slices, in #endif } - gpu::BufferPointer indicesBuffer(new gpu::Buffer()); + auto indicesBuffer = std::make_shared(); if (registered) { _registeredSphereIndices[id] = indicesBuffer; _lastRegisteredSphereIndices[id] = slicesStacksKey; @@ -233,8 +233,8 @@ void GeometryCache::renderSphere(gpu::Batch& batch, float radius, int slices, in qCDebug(renderutils) << "renderSphere()... RELEASING REGISTERED COLORS BUFFER"; #endif } - - gpu::BufferPointer colorBuffer(new gpu::Buffer()); + + auto colorBuffer = std::make_shared(); if (registered) { _registeredSphereColors[id] = colorBuffer; _lastRegisteredSphereColors[id] = colorKey; @@ -279,7 +279,7 @@ void GeometryCache::renderSphere(gpu::Batch& batch, float radius, int slices, in const int VERTICES_SLOT = 0; const int NORMALS_SLOT = 1; const int COLOR_SLOT = 2; - gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); // 1 for everyone + auto streamFormat = std::make_shared(); // 1 for everyone streamFormat->setAttribute(gpu::Stream::POSITION, VERTICES_SLOT, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ), 0); streamFormat->setAttribute(gpu::Stream::NORMAL, NORMALS_SLOT, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); streamFormat->setAttribute(gpu::Stream::COLOR, COLOR_SLOT, gpu::Element(gpu::VEC4, gpu::UINT8, gpu::RGBA)); @@ -414,7 +414,7 @@ void GeometryCache::renderGrid(gpu::Batch& batch, int xDivisions, int yDivisions int vertices = (xDivisions + 1 + yDivisions + 1) * 2; if (!_gridBuffers.contains(key)) { - gpu::BufferPointer verticesBuffer(new gpu::Buffer()); + auto verticesBuffer = std::make_shared(); GLfloat* vertexData = new GLfloat[vertices * 2]; GLfloat* vertex = vertexData; @@ -445,7 +445,7 @@ void GeometryCache::renderGrid(gpu::Batch& batch, int xDivisions, int yDivisions } if (!_gridColors.contains(colorKey)) { - gpu::BufferPointer colorBuffer(new gpu::Buffer()); + auto colorBuffer = std::make_shared(); _gridColors[colorKey] = colorBuffer; int compactColor = ((int(color.x * 255.0f) & 0xFF)) | @@ -468,7 +468,7 @@ void GeometryCache::renderGrid(gpu::Batch& batch, int xDivisions, int yDivisions const int VERTICES_SLOT = 0; const int COLOR_SLOT = 1; - gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); // 1 for everyone + auto streamFormat = std::make_shared(); // 1 for everyone streamFormat->setAttribute(gpu::Stream::POSITION, VERTICES_SLOT, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::XYZ), 0); streamFormat->setAttribute(gpu::Stream::COLOR, COLOR_SLOT, gpu::Element(gpu::VEC4, gpu::UINT8, gpu::RGBA)); @@ -507,7 +507,7 @@ void GeometryCache::renderGrid(gpu::Batch& batch, int x, int y, int width, int h int vertices = (cols + 1 + rows + 1) * 2; if ((registered && !_registeredAlternateGridBuffers.contains(id)) || (!registered && !_alternateGridBuffers.contains(key))) { - gpu::BufferPointer verticesBuffer(new gpu::Buffer()); + auto verticesBuffer = std::make_shared(); GLfloat* vertexData = new GLfloat[vertices * 2]; GLfloat* vertex = vertexData; @@ -550,7 +550,7 @@ void GeometryCache::renderGrid(gpu::Batch& batch, int x, int y, int width, int h } if (!_gridColors.contains(colorKey)) { - gpu::BufferPointer colorBuffer(new gpu::Buffer()); + auto colorBuffer = std::make_shared(); _gridColors[colorKey] = colorBuffer; int compactColor = ((int(color.x * 255.0f) & 0xFF)) | @@ -575,7 +575,7 @@ void GeometryCache::renderGrid(gpu::Batch& batch, int x, int y, int width, int h const int VERTICES_SLOT = 0; const int COLOR_SLOT = 1; - gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); // 1 for everyone + auto streamFormat = std::make_shared(); // 1 for everyone streamFormat->setAttribute(gpu::Stream::POSITION, VERTICES_SLOT, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::XYZ), 0); streamFormat->setAttribute(gpu::Stream::COLOR, COLOR_SLOT, gpu::Element(gpu::VEC4, gpu::UINT8, gpu::RGBA)); @@ -603,11 +603,11 @@ void GeometryCache::updateVertices(int id, const QVector& points, con details.isCreated = true; details.vertices = points.size(); details.vertexSize = FLOATS_PER_VERTEX; - - gpu::BufferPointer verticesBuffer(new gpu::Buffer()); - gpu::BufferPointer colorBuffer(new gpu::Buffer()); - gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); - gpu::BufferStreamPointer stream(new gpu::BufferStream()); + + auto verticesBuffer = std::make_shared(); + auto colorBuffer = std::make_shared(); + auto streamFormat = std::make_shared(); + auto stream = std::make_shared(); details.verticesBuffer = verticesBuffer; details.colorBuffer = colorBuffer; @@ -664,11 +664,11 @@ void GeometryCache::updateVertices(int id, const QVector& points, con details.isCreated = true; details.vertices = points.size(); details.vertexSize = FLOATS_PER_VERTEX; - - gpu::BufferPointer verticesBuffer(new gpu::Buffer()); - gpu::BufferPointer colorBuffer(new gpu::Buffer()); - gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); - gpu::BufferStreamPointer stream(new gpu::BufferStream()); + + auto verticesBuffer = std::make_shared(); + auto colorBuffer = std::make_shared(); + auto streamFormat = std::make_shared(); + auto stream = std::make_shared(); details.verticesBuffer = verticesBuffer; details.colorBuffer = colorBuffer; @@ -727,11 +727,11 @@ void GeometryCache::updateVertices(int id, const QVector& points, con details.isCreated = true; details.vertices = points.size(); details.vertexSize = FLOATS_PER_VERTEX; - - gpu::BufferPointer verticesBuffer(new gpu::Buffer()); - gpu::BufferPointer colorBuffer(new gpu::Buffer()); - gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); - gpu::BufferStreamPointer stream(new gpu::BufferStream()); + + auto verticesBuffer = std::make_shared(); + auto colorBuffer = std::make_shared(); + auto streamFormat = std::make_shared(); + auto stream = std::make_shared(); details.verticesBuffer = verticesBuffer; details.colorBuffer = colorBuffer; @@ -818,7 +818,7 @@ void GeometryCache::renderSolidCube(gpu::Batch& batch, float size, const glm::ve const int NORMALS_OFFSET = sizeof(GLfloat) * FLOATS_PER_VERTEX; if (!_solidCubeVertices.contains(size)) { - gpu::BufferPointer verticesBuffer(new gpu::Buffer()); + auto verticesBuffer = std::make_shared(); _solidCubeVertices[size] = verticesBuffer; GLfloat* vertexData = new GLfloat[vertexPoints * 2]; // vertices and normals @@ -869,15 +869,15 @@ void GeometryCache::renderSolidCube(gpu::Batch& batch, float size, const glm::ve 12,13,14, 14,15,12, // left 16,17,18, 18,19,16, // bottom 20,21,22, 22,23,20 }; // back - - gpu::BufferPointer indexBuffer(new gpu::Buffer()); + + auto indexBuffer = std::make_shared(); _solidCubeIndexBuffer = indexBuffer; _solidCubeIndexBuffer->append(sizeof(cannonicalIndices), (gpu::Byte*) cannonicalIndices); } if (!_solidCubeColors.contains(colorKey)) { - gpu::BufferPointer colorBuffer(new gpu::Buffer()); + auto colorBuffer = std::make_shared(); _solidCubeColors[colorKey] = colorBuffer; const int NUM_COLOR_SCALARS_PER_CUBE = 24; @@ -900,7 +900,7 @@ void GeometryCache::renderSolidCube(gpu::Batch& batch, float size, const glm::ve const int VERTICES_SLOT = 0; const int NORMALS_SLOT = 1; const int COLOR_SLOT = 2; - gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); // 1 for everyone + auto streamFormat = std::make_shared(); // 1 for everyone streamFormat->setAttribute(gpu::Stream::POSITION, VERTICES_SLOT, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ), 0); streamFormat->setAttribute(gpu::Stream::NORMAL, NORMALS_SLOT, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); @@ -935,7 +935,7 @@ void GeometryCache::renderWireCube(gpu::Batch& batch, float size, const glm::vec const int indices = (TOP_EDGES + BOTTOM_EDGES + SIDE_EDGES) * VERTICES_PER_EDGE; if (!_cubeVerticies.contains(size)) { - gpu::BufferPointer verticesBuffer(new gpu::Buffer()); + auto verticesBuffer = std::make_shared(); _cubeVerticies[size] = verticesBuffer; int vertexPoints = vertices * FLOATS_PER_VERTEX; @@ -961,15 +961,15 @@ void GeometryCache::renderWireCube(gpu::Batch& batch, float size, const glm::vec 4, 5, 5, 6, 6, 7, 7, 4, // (bottom) 0, 4, 1, 5, 2, 6, 3, 7, // (side edges) }; - - gpu::BufferPointer indexBuffer(new gpu::Buffer()); + + auto indexBuffer = std::make_shared(); _wireCubeIndexBuffer = indexBuffer; _wireCubeIndexBuffer->append(sizeof(cannonicalIndices), (gpu::Byte*) cannonicalIndices); } if (!_cubeColors.contains(colorKey)) { - gpu::BufferPointer colorBuffer(new gpu::Buffer()); + auto colorBuffer = std::make_shared(); _cubeColors[colorKey] = colorBuffer; const int NUM_COLOR_SCALARS_PER_CUBE = 8; @@ -987,7 +987,7 @@ void GeometryCache::renderWireCube(gpu::Batch& batch, float size, const glm::vec const int VERTICES_SLOT = 0; const int COLOR_SLOT = 1; - gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); // 1 for everyone + auto streamFormat = std::make_shared(); // 1 for everyone streamFormat->setAttribute(gpu::Stream::POSITION, VERTICES_SLOT, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ), 0); streamFormat->setAttribute(gpu::Stream::COLOR, COLOR_SLOT, gpu::Element(gpu::VEC4, gpu::UINT8, gpu::RGBA)); @@ -1036,11 +1036,11 @@ void GeometryCache::renderBevelCornersRect(gpu::Batch& batch, int x, int y, int details.isCreated = true; details.vertices = NUM_VERTICES; details.vertexSize = FLOATS_PER_VERTEX; - - gpu::BufferPointer verticesBuffer(new gpu::Buffer()); - gpu::BufferPointer colorBuffer(new gpu::Buffer()); - gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); - gpu::BufferStreamPointer stream(new gpu::BufferStream()); + + auto verticesBuffer = std::make_shared(); + auto colorBuffer = std::make_shared(); + auto streamFormat = std::make_shared(); + auto stream = std::make_shared(); details.verticesBuffer = verticesBuffer; details.colorBuffer = colorBuffer; @@ -1144,11 +1144,11 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, co details.isCreated = true; details.vertices = vertices; details.vertexSize = FLOATS_PER_VERTEX; - - gpu::BufferPointer verticesBuffer(new gpu::Buffer()); - gpu::BufferPointer colorBuffer(new gpu::Buffer()); - gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); - gpu::BufferStreamPointer stream(new gpu::BufferStream()); + + auto verticesBuffer = std::make_shared(); + auto colorBuffer = std::make_shared(); + auto streamFormat = std::make_shared(); + auto stream = std::make_shared(); details.verticesBuffer = verticesBuffer; details.colorBuffer = colorBuffer; @@ -1250,11 +1250,11 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, co details.isCreated = true; details.vertices = vertices; details.vertexSize = FLOATS_PER_VERTEX; - - gpu::BufferPointer verticesBuffer(new gpu::Buffer()); - gpu::BufferPointer colorBuffer(new gpu::Buffer()); - gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); - gpu::BufferStreamPointer stream(new gpu::BufferStream()); + + auto verticesBuffer = std::make_shared(); + auto colorBuffer = std::make_shared(); + auto streamFormat = std::make_shared(); + auto stream = std::make_shared(); details.verticesBuffer = verticesBuffer; details.colorBuffer = colorBuffer; @@ -1329,11 +1329,11 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& minCorner, co details.isCreated = true; details.vertices = vertices; details.vertexSize = FLOATS_PER_VERTEX; - - gpu::BufferPointer verticesBuffer(new gpu::Buffer()); - gpu::BufferPointer colorBuffer(new gpu::Buffer()); - gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); - gpu::BufferStreamPointer stream(new gpu::BufferStream()); + + auto verticesBuffer = std::make_shared(); + auto colorBuffer = std::make_shared(); + auto streamFormat = std::make_shared(); + auto stream = std::make_shared(); details.verticesBuffer = verticesBuffer; details.colorBuffer = colorBuffer; @@ -1432,11 +1432,11 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& topLeft, cons details.isCreated = true; details.vertices = vertices; details.vertexSize = FLOATS_PER_VERTEX; // NOTE: this isn't used for BatchItemDetails maybe we can get rid of it - - gpu::BufferPointer verticesBuffer(new gpu::Buffer()); - gpu::BufferPointer colorBuffer(new gpu::Buffer()); - gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); - gpu::BufferStreamPointer stream(new gpu::BufferStream()); + + auto verticesBuffer = std::make_shared(); + auto colorBuffer = std::make_shared(); + auto streamFormat = std::make_shared(); + auto stream = std::make_shared(); details.verticesBuffer = verticesBuffer; details.colorBuffer = colorBuffer; @@ -1519,11 +1519,11 @@ void GeometryCache::renderDashedLine(gpu::Batch& batch, const glm::vec3& start, details.vertices = (segmentCountFloor + 1) * 2; details.vertexSize = FLOATS_PER_VERTEX; details.isCreated = true; - - gpu::BufferPointer verticesBuffer(new gpu::Buffer()); - gpu::BufferPointer colorBuffer(new gpu::Buffer()); - gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); - gpu::BufferStreamPointer stream(new gpu::BufferStream()); + + auto verticesBuffer = std::make_shared(); + auto colorBuffer = std::make_shared(); + auto streamFormat = std::make_shared(); + auto stream = std::make_shared(); details.verticesBuffer = verticesBuffer; details.colorBuffer = colorBuffer; @@ -1684,11 +1684,11 @@ void GeometryCache::renderLine(gpu::Batch& batch, const glm::vec3& p1, const glm details.isCreated = true; details.vertices = vertices; details.vertexSize = FLOATS_PER_VERTEX; - - gpu::BufferPointer verticesBuffer(new gpu::Buffer()); - gpu::BufferPointer colorBuffer(new gpu::Buffer()); - gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); - gpu::BufferStreamPointer stream(new gpu::BufferStream()); + + auto verticesBuffer = std::make_shared(); + auto colorBuffer = std::make_shared(); + auto streamFormat = std::make_shared(); + auto stream = std::make_shared(); details.verticesBuffer = verticesBuffer; details.colorBuffer = colorBuffer; @@ -1774,11 +1774,11 @@ void GeometryCache::renderLine(gpu::Batch& batch, const glm::vec2& p1, const glm details.isCreated = true; details.vertices = vertices; details.vertexSize = FLOATS_PER_VERTEX; - - gpu::BufferPointer verticesBuffer(new gpu::Buffer()); - gpu::BufferPointer colorBuffer(new gpu::Buffer()); - gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); - gpu::BufferStreamPointer stream(new gpu::BufferStream()); + + auto verticesBuffer = std::make_shared(); + auto colorBuffer = std::make_shared(); + auto streamFormat = std::make_shared(); + auto stream = std::make_shared(); details.verticesBuffer = verticesBuffer; details.colorBuffer = colorBuffer; @@ -1835,7 +1835,7 @@ void GeometryCache::useSimpleDrawPipeline(gpu::Batch& batch) { auto program = gpu::ShaderPointer(gpu::Shader::createProgram(vs, ps)); gpu::Shader::makeProgram((*program)); - auto state = gpu::StatePointer(new gpu::State()); + auto state = std::make_shared(); // enable decal blend state->setBlendFunction(true, gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA); @@ -2213,8 +2213,8 @@ void NetworkGeometry::downloadFinished(QNetworkReply* reply) { } QVariantHash lods = _mapping.value("lod").toHash(); for (QVariantHash::const_iterator it = lods.begin(); it != lods.end(); it++) { - QSharedPointer geometry(new NetworkGeometry(url.resolved(it.key()), - QSharedPointer(), true, _mapping, _textureBase)); + auto geometry = QSharedPointer::create(url.resolved(it.key()), + QSharedPointer(), true, _mapping, _textureBase); geometry->setSelf(geometry.staticCast()); geometry->setLODParent(_lodParent); _lods.insert(it.value().toFloat(), geometry); @@ -2290,7 +2290,7 @@ void NetworkGeometry::setGeometry(const FBXGeometry& geometry) { } { - networkMesh._indexBuffer = gpu::BufferPointer(new gpu::Buffer()); + networkMesh._indexBuffer = std::make_shared(); networkMesh._indexBuffer->resize(totalIndices * sizeof(int)); int offset = 0; foreach(const FBXMeshPart& part, mesh.parts) { @@ -2304,7 +2304,7 @@ void NetworkGeometry::setGeometry(const FBXGeometry& geometry) { } { - networkMesh._vertexBuffer = gpu::BufferPointer(new gpu::Buffer()); + networkMesh._vertexBuffer = std::make_shared(); // if we don't need to do any blending, the positions/normals can be static if (mesh.blendshapes.isEmpty()) { int normalsOffset = mesh.vertices.size() * sizeof(glm::vec3); @@ -2332,7 +2332,7 @@ void NetworkGeometry::setGeometry(const FBXGeometry& geometry) { mesh.clusterWeights.size() * sizeof(glm::vec4), (gpu::Byte*) mesh.clusterWeights.constData()); // otherwise, at least the cluster indices/weights can be static - networkMesh._vertexStream = gpu::BufferStreamPointer(new gpu::BufferStream()); + networkMesh._vertexStream = std::make_shared(); networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, 0, sizeof(glm::vec3)); if (mesh.normals.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, normalsOffset, sizeof(glm::vec3)); if (mesh.tangents.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, tangentsOffset, sizeof(glm::vec3)); @@ -2343,7 +2343,7 @@ void NetworkGeometry::setGeometry(const FBXGeometry& geometry) { if (mesh.clusterWeights.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, clusterWeightsOffset, sizeof(glm::vec4)); int channelNum = 0; - networkMesh._vertexFormat = gpu::Stream::FormatPointer(new gpu::Stream::Format()); + networkMesh._vertexFormat = std::make_shared(); networkMesh._vertexFormat->setAttribute(gpu::Stream::POSITION, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ), 0); if (mesh.normals.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::NORMAL, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); if (mesh.tangents.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::TANGENT, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); @@ -2374,7 +2374,7 @@ void NetworkGeometry::setGeometry(const FBXGeometry& geometry) { networkMesh._vertexBuffer->setSubData(clusterWeightsOffset, mesh.clusterWeights.size() * sizeof(glm::vec4), (gpu::Byte*) mesh.clusterWeights.constData()); - networkMesh._vertexStream = gpu::BufferStreamPointer(new gpu::BufferStream()); + networkMesh._vertexStream = std::make_shared(); if (mesh.tangents.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, 0, sizeof(glm::vec3)); if (mesh.colors.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, colorsOffset, sizeof(glm::vec3)); if (mesh.texCoords.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, texCoordsOffset, sizeof(glm::vec2)); @@ -2382,7 +2382,7 @@ void NetworkGeometry::setGeometry(const FBXGeometry& geometry) { if (mesh.clusterWeights.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, clusterWeightsOffset, sizeof(glm::vec4)); int channelNum = 0; - networkMesh._vertexFormat = gpu::Stream::FormatPointer(new gpu::Stream::Format()); + networkMesh._vertexFormat = std::make_shared(); networkMesh._vertexFormat->setAttribute(gpu::Stream::POSITION, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); if (mesh.normals.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::NORMAL, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); if (mesh.tangents.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::TANGENT, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index 93f3f345f0..d03f80358e 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -121,11 +121,11 @@ void Model::RenderPipelineLib::addRenderPipeline(Model::RenderKey key, gpu::Shader::makeProgram(*program, slotBindings); - auto locations = std::shared_ptr(new Locations()); + auto locations = std::make_shared(); initLocations(program, *locations); - gpu::StatePointer state = gpu::StatePointer(new gpu::State()); + auto state = std::make_shared(); // Backface on shadow if (key.isShadow()) { @@ -152,7 +152,7 @@ void Model::RenderPipelineLib::addRenderPipeline(Model::RenderKey key, if (!key.isWireFrame()) { RenderKey wireframeKey(key.getRaw() | RenderKey::IS_WIREFRAME); - gpu::StatePointer wireframeState = gpu::StatePointer(new gpu::State(state->getValues())); + auto wireframeState = std::make_shared(state->getValues()); wireframeState->setFillMode(gpu::State::FILL_LINE); @@ -165,7 +165,7 @@ void Model::RenderPipelineLib::addRenderPipeline(Model::RenderKey key, if (!key.isShadow()) { RenderKey mirrorKey(key.getRaw() | RenderKey::IS_MIRROR); - gpu::StatePointer mirrorState = gpu::StatePointer(new gpu::State(state->getValues())); + auto mirrorState = std::make_shared(state->getValues()); mirrorState->setFrontFaceClockwise(true); @@ -175,7 +175,7 @@ void Model::RenderPipelineLib::addRenderPipeline(Model::RenderKey key, if (!key.isWireFrame()) { RenderKey wireframeKey(key.getRaw() | RenderKey::IS_MIRROR | RenderKey::IS_WIREFRAME); - gpu::StatePointer wireframeState = gpu::StatePointer(new gpu::State(state->getValues()));; + auto wireframeState = std::make_shared(state->getValues()); wireframeState->setFillMode(gpu::State::FILL_LINE); @@ -481,8 +481,8 @@ bool Model::updateGeometry() { MeshState state; state.clusterMatrices.resize(mesh.clusters.size()); _meshStates.append(state); - - gpu::BufferPointer buffer(new gpu::Buffer()); + + auto buffer = std::make_shared(); if (!mesh.blendshapes.isEmpty()) { buffer->resize((mesh.vertices.size() + mesh.normals.size()) * sizeof(glm::vec3)); buffer->setSubData(0, mesh.vertices.size() * sizeof(glm::vec3), (gpu::Byte*) mesh.vertices.constData()); @@ -890,7 +890,7 @@ bool Model::addToScene(std::shared_ptr scene, render::PendingChan foreach (auto renderItem, _transparentRenderItems) { auto item = scene->allocateID(); auto renderData = MeshPartPayload::Pointer(renderItem); - auto renderPayload = render::PayloadPointer(new MeshPartPayload::Payload(renderData)); + auto renderPayload = std::make_shared(renderData); pendingChanges.resetItem(item, renderPayload); _renderItems.insert(item, renderPayload); somethingAdded = true; @@ -899,7 +899,7 @@ bool Model::addToScene(std::shared_ptr scene, render::PendingChan foreach (auto renderItem, _opaqueRenderItems) { auto item = scene->allocateID(); auto renderData = MeshPartPayload::Pointer(renderItem); - auto renderPayload = render::PayloadPointer(new MeshPartPayload::Payload(renderData)); + auto renderPayload = std::make_shared(renderData); pendingChanges.resetItem(item, renderPayload); _renderItems.insert(item, renderPayload); somethingAdded = true; @@ -2103,9 +2103,9 @@ void Model::segregateMeshGroups() { for (int partIndex = 0; partIndex < totalParts; partIndex++) { // this is a good place to create our renderPayloads if (translucentMesh) { - _transparentRenderItems << std::shared_ptr(new MeshPartPayload(true, this, i, partIndex)); + _transparentRenderItems << std::make_shared(true, this, i, partIndex); } else { - _opaqueRenderItems << std::shared_ptr(new MeshPartPayload(false, this, i, partIndex)); + _opaqueRenderItems << std::make_shared(false, this, i, partIndex); } } } @@ -2152,7 +2152,7 @@ bool Model::initWhenReady(render::ScenePointer scene) { foreach (auto renderItem, _transparentRenderItems) { auto item = scene->allocateID(); auto renderData = MeshPartPayload::Pointer(renderItem); - auto renderPayload = render::PayloadPointer(new MeshPartPayload::Payload(renderData)); + auto renderPayload = std::make_shared(renderData); _renderItems.insert(item, renderPayload); pendingChanges.resetItem(item, renderPayload); } @@ -2160,7 +2160,7 @@ bool Model::initWhenReady(render::ScenePointer scene) { foreach (auto renderItem, _opaqueRenderItems) { auto item = scene->allocateID(); auto renderData = MeshPartPayload::Pointer(renderItem); - auto renderPayload = render::PayloadPointer(new MeshPartPayload::Payload(renderData)); + auto renderPayload = std::make_shared(renderData); _renderItems.insert(item, renderPayload); pendingChanges.resetItem(item, renderPayload); } diff --git a/libraries/render-utils/src/OglplusHelpers.cpp b/libraries/render-utils/src/OglplusHelpers.cpp index 47f9778cac..2205893d46 100644 --- a/libraries/render-utils/src/OglplusHelpers.cpp +++ b/libraries/render-utils/src/OglplusHelpers.cpp @@ -57,7 +57,7 @@ ProgramPtr loadDefaultShader() { void compileProgram(ProgramPtr & result, const std::string& vs, const std::string& fs) { using namespace oglplus; try { - result = ProgramPtr(new Program()); + result = QSharedPointer::create(); // attach the shaders to the program result->AttachShader( VertexShader() diff --git a/libraries/render-utils/src/RenderDeferredTask.cpp b/libraries/render-utils/src/RenderDeferredTask.cpp index e0c66eb604..b5da7c7f00 100755 --- a/libraries/render-utils/src/RenderDeferredTask.cpp +++ b/libraries/render-utils/src/RenderDeferredTask.cpp @@ -180,8 +180,8 @@ const gpu::PipelinePointer& DrawOverlay3D::getOpaquePipeline() { auto vs = gpu::ShaderPointer(gpu::Shader::createVertex(std::string(overlay3D_vert))); auto ps = gpu::ShaderPointer(gpu::Shader::createPixel(std::string(overlay3D_frag))); auto program = gpu::ShaderPointer(gpu::Shader::createProgram(vs, ps)); - - auto state = gpu::StatePointer(new gpu::State()); + + auto state = std::make_shared(); state->setDepthTest(true, true, gpu::LESS_EQUAL); _opaquePipeline.reset(gpu::Pipeline::create(program, state)); diff --git a/libraries/render-utils/src/TextRenderer3D.cpp b/libraries/render-utils/src/TextRenderer3D.cpp index d202d89aba..b7dd7340b2 100644 --- a/libraries/render-utils/src/TextRenderer3D.cpp +++ b/libraries/render-utils/src/TextRenderer3D.cpp @@ -340,7 +340,7 @@ void Font3D::setupGPU() { _outlineLoc = program->getUniforms().findLocation("Outline"); _colorLoc = program->getUniforms().findLocation("Color"); - gpu::StatePointer state = gpu::StatePointer(new gpu::State()); + auto state = std::make_shared(); state->setCullMode(gpu::State::CULL_BACK); state->setDepthTest(true, true, gpu::LESS_EQUAL); state->setBlendFunction(false, @@ -356,7 +356,7 @@ void Font3D::setupGPU() { assert(sizeof(QuadBuilder) == 4 * sizeof(TextureVertex)); // Setup rendering structures - _format.reset(new gpu::Stream::Format()); + _format = std::make_shared(); _format->setAttribute(gpu::Stream::POSITION, 0, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::XYZ), 0); _format->setAttribute(gpu::Stream::TEXCOORD, 0, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::UV), OFFSET); } @@ -369,7 +369,7 @@ void Font3D::drawString(gpu::Batch& batch, float x, float y, const QString& str, } if (str != _lastStringRendered || bounds != _lastBounds) { - _verticesBuffer.reset(new gpu::Buffer()); + _verticesBuffer = std::make_shared(); _numVertices = 0; _lastStringRendered = str; _lastBounds = bounds; diff --git a/libraries/render/src/render/DrawTask.h b/libraries/render/src/render/DrawTask.h index 8a4d424005..16d84f809a 100755 --- a/libraries/render/src/render/DrawTask.h +++ b/libraries/render/src/render/DrawTask.h @@ -43,11 +43,11 @@ public: Varying() {} template - Varying(const T& data) : _concept(new Job::Varying::Model(data)) {} + Varying(const T& data) : _concept(std::make_shared>(data)) {} // Access the _data contained win the concept explicitely - template T& edit() { return (static_cast*> (_concept.get())->_data); } - template const T& get() const { return (static_cast*> (_concept.get())->_data); } + template T& edit() { return std::static_pointer_cast>(_concept)->_data; } + template const T& get() const { return std::static_pointer_cast>(_concept)->_data; } protected: friend class Job; diff --git a/libraries/render/src/render/Engine.cpp b/libraries/render/src/render/Engine.cpp index 1697271121..86f35eb831 100644 --- a/libraries/render/src/render/Engine.cpp +++ b/libraries/render/src/render/Engine.cpp @@ -15,8 +15,8 @@ using namespace render; Engine::Engine() : - _sceneContext(new SceneContext()), - _renderContext(new RenderContext()) + _sceneContext(std::make_shared()), + _renderContext(std::make_shared()) { } @@ -45,6 +45,6 @@ void Engine::buildStandardTaskPipeline() { _tasks.clear(); } - addTask(TaskPointer(new DrawSceneTask())); + addTask(std::make_shared()); } diff --git a/libraries/render/src/render/Scene.h b/libraries/render/src/render/Scene.h index ae5a5b0f23..918b9609f8 100644 --- a/libraries/render/src/render/Scene.h +++ b/libraries/render/src/render/Scene.h @@ -398,7 +398,7 @@ public: void removeItem(ItemID id); template void updateItem(ItemID id, std::function func) { - updateItem(id, UpdateFunctorPointer(new UpdateFunctor(func))); + updateItem(id, std::make_shared>(func)); } void updateItem(ItemID id, const UpdateFunctorPointer& functor); diff --git a/libraries/script-engine/src/SceneScriptingInterface.h b/libraries/script-engine/src/SceneScriptingInterface.h index 8359aa58fa..e2a206c695 100644 --- a/libraries/script-engine/src/SceneScriptingInterface.h +++ b/libraries/script-engine/src/SceneScriptingInterface.h @@ -113,7 +113,7 @@ protected: SceneScriptingInterface() {}; ~SceneScriptingInterface() {}; - model::SunSkyStagePointer _skyStage = model::SunSkyStagePointer(new model::SunSkyStage()); + model::SunSkyStagePointer _skyStage = std::make_shared(); bool _shouldRenderAvatars = true; bool _shouldRenderEntities = true; diff --git a/libraries/shared/src/Transform.h b/libraries/shared/src/Transform.h index e961f379c8..f5afd9125c 100644 --- a/libraries/shared/src/Transform.h +++ b/libraries/shared/src/Transform.h @@ -156,8 +156,7 @@ protected: mutable Flags _flags; // Cached transform - // TODO: replace this auto ptr by a "unique ptr" as soon as we are compiling in C++11 - mutable std::auto_ptr _matrix; + mutable std::unique_ptr _matrix; bool isCacheInvalid() const { return _flags[FLAG_CACHE_INVALID]; } void validCache() const { _flags.set(FLAG_CACHE_INVALID, false); } diff --git a/libraries/ui/src/InfoView.cpp b/libraries/ui/src/InfoView.cpp index dd754f209a..77b641e8c6 100644 --- a/libraries/ui/src/InfoView.cpp +++ b/libraries/ui/src/InfoView.cpp @@ -25,7 +25,7 @@ InfoView::InfoView(QQuickItem* parent) : QQuickItem(parent) { } void InfoView::registerType() { - qmlRegisterType("Hifi", 1, 0, NAME.toLocal8Bit().constData()); + qmlRegisterType("Hifi", 1, 0, NAME.toLocal8Bit().constData()); } QString fetchVersion(const QUrl& url) { diff --git a/tools/scribe/src/TextTemplate.cpp b/tools/scribe/src/TextTemplate.cpp index f860860ae4..c468df278b 100755 --- a/tools/scribe/src/TextTemplate.cpp +++ b/tools/scribe/src/TextTemplate.cpp @@ -42,7 +42,7 @@ const TextTemplatePointer TextTemplate::Config::addInclude(const ConfigPointer& String includeStream; if (config->_includerCallback(config, include, includeStream)) { // ok, then create a new Template on the include file with this as lib - included = TextTemplatePointer(new TextTemplate(include, config)); + included = std::make_shared(include, config); std::stringstream src(includeStream); @@ -398,7 +398,7 @@ const BlockPointer TextTemplate::processStepVar(const BlockPointer& block, Strin BlockPointer parent = Block::getCurrentBlock(block); // Add a new BLock - BlockPointer newBlock = BlockPointer(new Block(_root->sourceName)); + BlockPointer newBlock = std::make_shared(_root->sourceName); (newBlock->ostr) << grabbed; newBlock->command.type = Command::VAR; @@ -460,7 +460,7 @@ const BlockPointer TextTemplate::processStepDef(const BlockPointer& block, Strin BlockPointer parent = Block::getCurrentBlock(block); // Add a new BLock - BlockPointer newBlock = BlockPointer(new Block(_root->sourceName)); + BlockPointer newBlock = std::make_shared(_root->sourceName); (newBlock->ostr) << grabbed; newBlock->command.type = Command::DEF; @@ -482,12 +482,12 @@ const BlockPointer TextTemplate::processStepCommandIf(const BlockPointer& block, BlockPointer parent = Block::getCurrentBlock(block); // Add a new BLock depth - BlockPointer newIfBlock = BlockPointer(new Block(_root->sourceName)); + BlockPointer newIfBlock = std::make_shared(_root->sourceName); newIfBlock->command.type = Command::IFBLOCK; Block::addNewBlock(parent, newIfBlock); - BlockPointer newBlock = BlockPointer(new Block(_root->sourceName)); + BlockPointer newBlock = std::make_shared(_root->sourceName); (newBlock->ostr) << grabbed; newBlock->command.type = Command::IF; @@ -506,7 +506,7 @@ const BlockPointer TextTemplate::processStepCommandEndIf(const BlockPointer& blo if ((parent->command.type == Command::IF) || (parent->command.type == Command::ELIF) || (parent->command.type == Command::ELSE)) { - BlockPointer newBlock = BlockPointer(new Block(_root->sourceName)); + BlockPointer newBlock = std::make_shared(_root->sourceName); (newBlock->ostr) << grabbed; newBlock->command.type = Command::ENDIF; @@ -533,7 +533,7 @@ const BlockPointer TextTemplate::processStepCommandElse(const BlockPointer& bloc parent = parent->parent; // Add a new BLock depth - BlockPointer newBlock = BlockPointer(new Block(_root->sourceName)); + BlockPointer newBlock = std::make_shared(_root->sourceName); newBlock->ostr << grabbed; newBlock->command.type = Command::ELSE; newBlock->command.arguments.push_back(expression); @@ -562,7 +562,7 @@ const BlockPointer TextTemplate::processStepCommandElif(const BlockPointer& bloc parent = parent->parent; // Add a new BLock depth - BlockPointer newBlock = BlockPointer(new Block(_root->sourceName)); + BlockPointer newBlock = std::make_shared(_root->sourceName); (newBlock->ostr) << grabbed; newBlock->command.type = Command::ELIF; @@ -595,7 +595,7 @@ const BlockPointer TextTemplate::processStepInclude(const BlockPointer& block, S BlockPointer parent = Block::getCurrentBlock(block); // Add a new BLock - BlockPointer newBlock = BlockPointer(new Block(_root->sourceName)); + BlockPointer newBlock = std::make_shared(_root->sourceName); (newBlock->ostr) << grabbed; newBlock->command.type = Command::INCLUDE; @@ -631,7 +631,7 @@ const BlockPointer TextTemplate::processStepFunc(const BlockPointer& block, Stri BlockPointer parent = Block::getCurrentBlock(block); // Add a new BLock - BlockPointer newBlock = BlockPointer(new Block(_root->sourceName)); + BlockPointer newBlock = std::make_shared(_root->sourceName); (newBlock->ostr) << grabbed; newBlock->command.type = Command::FUNC; @@ -660,7 +660,7 @@ const BlockPointer TextTemplate::processStepEndFunc(const BlockPointer& block, S // Everything is cool , so let's unplugg the FUnc block from this tree and just put the EndFunc block - BlockPointer newBlock = BlockPointer(new Block(_root->sourceName)); + BlockPointer newBlock = std::make_shared(_root->sourceName); (newBlock->ostr) << grabbed; newBlock->command.type = Command::ENDFUNC; diff --git a/tools/scribe/src/TextTemplate.h b/tools/scribe/src/TextTemplate.h index 30a17bc1c9..a19d2938da 100755 --- a/tools/scribe/src/TextTemplate.h +++ b/tools/scribe/src/TextTemplate.h @@ -141,7 +141,7 @@ public: static bool loadFile(const Config::Pointer& config, const char* filename, String& source); - TextTemplate(const String& name, const Config::Pointer& config = Config::Pointer(new Config())); + TextTemplate(const String& name, const Config::Pointer& config = std::make_shared()); ~TextTemplate(); // Scibe does all the job of parsing an inout template stream and then gneerating theresulting stream using the vars diff --git a/tools/scribe/src/main.cpp b/tools/scribe/src/main.cpp index 10f0a026ca..cc44fedacc 100755 --- a/tools/scribe/src/main.cpp +++ b/tools/scribe/src/main.cpp @@ -31,7 +31,7 @@ int main (int argc, char** argv) { bool showParseTree = false; bool makeCPlusPlus = false; - TextTemplate::Config::Pointer config(new TextTemplate::Config()); + auto config = std::make_shared(); enum Mode { READY = 0, @@ -165,7 +165,7 @@ int main (int argc, char** argv) { return 0; } - TextTemplate::Pointer scribe(new TextTemplate(srcFilename, config)); + auto scribe = std::make_shared(srcFilename, config); // ready to parse and generate std::ostringstream destStringStream; From 293ccc1713d285a9c02c801ae7d17c7e39906929 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 15 Jul 2015 15:32:02 -0700 Subject: [PATCH 03/15] remove some dead code --- interface/src/ui/ApplicationCompositor.cpp | 1 - libraries/render-utils/src/GeometryCache.cpp | 2 -- 2 files changed, 3 deletions(-) diff --git a/interface/src/ui/ApplicationCompositor.cpp b/interface/src/ui/ApplicationCompositor.cpp index 8565371a9b..4623109cdd 100644 --- a/interface/src/ui/ApplicationCompositor.cpp +++ b/interface/src/ui/ApplicationCompositor.cpp @@ -197,7 +197,6 @@ void ApplicationCompositor::displayOverlayTexture(RenderArgs* renderArgs) { updateTooltips(); auto deviceSize = qApp->getDeviceSize(); - glViewport(0, 0, deviceSize.width(), deviceSize.height()); //Handle fading and deactivation/activation of UI gpu::Batch batch; diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 7cb882acc1..2bf41bc9b3 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -433,8 +433,6 @@ void GeometryCache::renderGrid(gpu::Batch& batch, int x, int y, int width, int h } // Draw vertical grid lines for (int i = cols + 1; --i >= 0; ) { - //glVertex2i(tx, y); - //glVertex2i(tx, y + height); *(vertex++) = tx; *(vertex++) = y; From 96e18af77b03fb8448d7a5ae6ba2884d3b486c42 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Fri, 17 Jul 2015 17:44:25 -0700 Subject: [PATCH 04/15] trying to remove the naked gl calls aroiund the rearViewMirror --- interface/src/Application.cpp | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index afe3a28431..f5b05868fc 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -982,11 +982,11 @@ void Application::paintGL() { glViewport(0, 0, size.width(), size.height()); renderArgs._viewport = glm::ivec4(0, 0, size.width(), size.height()); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); + // glMatrixMode(GL_MODELVIEW); + // glPushMatrix(); + // glLoadIdentity(); displaySide(&renderArgs, _myCamera); - glPopMatrix(); + // glPopMatrix(); renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE; if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { @@ -1004,7 +1004,7 @@ void Application::paintGL() { GL_COLOR_BUFFER_BIT, GL_LINEAR); glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); - glBindTexture(GL_TEXTURE_2D, 0); // ??? + // glBindTexture(GL_TEXTURE_2D, 0); // ??? _compositor.displayOverlayTexture(&renderArgs); } @@ -3683,6 +3683,7 @@ void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& regi // Grab current viewport to reset it at the end int viewport[4]; glGetIntegerv(GL_VIEWPORT, viewport); + auto masterViewport = renderArgs->_viewport; float aspect = (float)region.width() / region.height(); float fov = MIRROR_FIELD_OF_VIEW; @@ -3737,18 +3738,27 @@ void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& regi } bool updateViewFrustum = false; updateProjectionMatrix(_mirrorCamera, updateViewFrustum); - glEnable(GL_SCISSOR_TEST); + /* glEnable(GL_SCISSOR_TEST); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glDisable(GL_SCISSOR_TEST); + */ + gpu::Batch batch; + batch.setViewportTransform(renderArgs->_viewport); + // batch.setStateScissorRect(scissor); + batch.clearFramebuffer(gpu::Framebuffer::BUFFER_COLORS | gpu::Framebuffer::BUFFER_DEPTH, glm::vec4(0.0f), 1.0f, 0, true); + + renderArgs->_context->syncCache(); + renderArgs->_context->render(batch); // render rear mirror view - glPushMatrix(); + // glPushMatrix(); displaySide(renderArgs, _mirrorCamera, true, billboard); - glPopMatrix(); - + // glPopMatrix(); + // reset Viewport and projection matrix renderArgs->_viewport = glm::ivec4(viewport[0], viewport[1], viewport[2], viewport[3]); glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); - glDisable(GL_SCISSOR_TEST); + // glDisable(GL_SCISSOR_TEST); updateProjectionMatrix(_myCamera, updateViewFrustum); } From 052c3c987b4c1d2ea1f7e7a7f154c966e4bec6fe Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 17 Jul 2015 18:10:34 -0700 Subject: [PATCH 05/15] Fix some more smart pointer --- libraries/networking/src/AccountManager.cpp | 4 +- .../src/DeferredLightingEffect.cpp | 6 +- libraries/render-utils/src/Model.cpp | 6 +- .../render-utils/src/RenderDeferredTask.cpp | 6 +- libraries/render-utils/src/TextureCache.cpp | 2 +- libraries/render/src/render/DrawStatus.cpp | 96 +++++++++---------- libraries/render/src/render/Scene.cpp | 4 +- 7 files changed, 62 insertions(+), 62 deletions(-) diff --git a/libraries/networking/src/AccountManager.cpp b/libraries/networking/src/AccountManager.cpp index 2830a13ca7..0eff6a6b91 100644 --- a/libraries/networking/src/AccountManager.cpp +++ b/libraries/networking/src/AccountManager.cpp @@ -34,10 +34,10 @@ const bool VERBOSE_HTTP_REQUEST_DEBUGGING = false; AccountManager& AccountManager::getInstance(bool forceReset) { - static std::unique_ptr sharedInstance(new AccountManager()); + static auto sharedInstance = std::make_shared(); if (forceReset) { - sharedInstance.reset(new AccountManager()); + sharedInstance = std::make_shared(); } return *sharedInstance; diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index 074fb39ce2..2fbce1c7bb 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -117,7 +117,7 @@ void DeferredLightingEffect::init(AbstractViewStateInterface* viewState) { //auto PSBlit = gpu::StandardShaderLib::getDrawTexturePS(); auto blitProgram = gpu::StandardShaderLib::getProgram(gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS, gpu::StandardShaderLib::getDrawTexturePS); gpu::Shader::makeProgram(*blitProgram); - gpu::StatePointer blitState = gpu::StatePointer(new gpu::State()); + auto blitState = std::make_shared(); blitState->setBlendFunction(true, gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA, gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE); @@ -614,7 +614,7 @@ void DeferredLightingEffect::loadLightProgram(const char* vertSource, const char locations.atmosphereBufferUnit = program->getUniforms().findLocation("atmosphereBufferUnit"); #endif - gpu::StatePointer state = gpu::StatePointer(new gpu::State()); + auto state = std::make_shared(); if (lightVolume) { state->setCullMode(gpu::State::CULL_BACK); @@ -657,7 +657,7 @@ void DeferredLightingEffect::setGlobalSkybox(const model::SkyboxPointer& skybox) model::MeshPointer DeferredLightingEffect::getSpotLightMesh() { if (!_spotLightMesh) { - _spotLightMesh.reset(new model::Mesh()); + _spotLightMesh = std::make_shared(); int slices = 32; int rings = 3; diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index 273f0a6c4b..ef728be538 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -918,7 +918,7 @@ bool Model::addToScene(std::shared_ptr scene, render::PendingChan foreach (auto renderItem, _transparentRenderItems) { auto item = scene->allocateID(); auto renderData = MeshPartPayload::Pointer(renderItem); - auto renderPayload = render::PayloadPointer(new MeshPartPayload::Payload(renderData)); + auto renderPayload = std::make_shared(renderData); renderPayload->addStatusGetters(statusGetters); pendingChanges.resetItem(item, renderPayload); _renderItems.insert(item, renderPayload); @@ -928,7 +928,7 @@ bool Model::addToScene(std::shared_ptr scene, render::PendingChan foreach (auto renderItem, _opaqueRenderItems) { auto item = scene->allocateID(); auto renderData = MeshPartPayload::Pointer(renderItem); - auto renderPayload = render::PayloadPointer(new MeshPartPayload::Payload(renderData)); + auto renderPayload = std::make_shared(renderData); renderPayload->addStatusGetters(statusGetters); pendingChanges.resetItem(item, renderPayload); _renderItems.insert(item, renderPayload); @@ -1260,7 +1260,7 @@ uint qHash(const WeakAnimationHandlePointer& handle, uint seed) { } AnimationHandlePointer Model::createAnimationHandle() { - AnimationHandlePointer handle(new AnimationHandle(this)); + auto handle = AnimationHandlePointer::create(this); handle->_self = handle; _animationHandles.insert(handle); return handle; diff --git a/libraries/render-utils/src/RenderDeferredTask.cpp b/libraries/render-utils/src/RenderDeferredTask.cpp index ff45b41a7d..c2f28eda9f 100755 --- a/libraries/render-utils/src/RenderDeferredTask.cpp +++ b/libraries/render-utils/src/RenderDeferredTask.cpp @@ -78,9 +78,9 @@ RenderDeferredTask::RenderDeferredTask() : Task() { _jobs.push_back(Job(new ResetGLState::JobModel())); // Give ourselves 3 frmaes of timer queries - _timerQueries.push_back(gpu::QueryPointer(new gpu::Query())); - _timerQueries.push_back(gpu::QueryPointer(new gpu::Query())); - _timerQueries.push_back(gpu::QueryPointer(new gpu::Query())); + _timerQueries.push_back(std::make_shared()); + _timerQueries.push_back(std::make_shared()); + _timerQueries.push_back(std::make_shared()); _currentTimerQueryIndex = 0; } diff --git a/libraries/render-utils/src/TextureCache.cpp b/libraries/render-utils/src/TextureCache.cpp index 953cfda910..6bf7d48f51 100644 --- a/libraries/render-utils/src/TextureCache.cpp +++ b/libraries/render-utils/src/TextureCache.cpp @@ -759,7 +759,7 @@ DilatableNetworkTexture::DilatableNetworkTexture(const QUrl& url, const QByteArr QSharedPointer DilatableNetworkTexture::getDilatedTexture(float dilation) { QSharedPointer texture = _dilatedTextures.value(dilation); if (texture.isNull()) { - texture = QSharedPointer(new Texture()); + texture = QSharedPointer::create(); if (!_image.isNull()) { QImage dilatedImage = _image; diff --git a/libraries/render/src/render/DrawStatus.cpp b/libraries/render/src/render/DrawStatus.cpp index 90d167cc2a..408fdd7968 100644 --- a/libraries/render/src/render/DrawStatus.cpp +++ b/libraries/render/src/render/DrawStatus.cpp @@ -34,27 +34,27 @@ using namespace render; const gpu::PipelinePointer& DrawStatus::getDrawItemBoundsPipeline() { - if (!_drawItemBoundsPipeline) { - auto vs = gpu::ShaderPointer(gpu::Shader::createVertex(std::string(drawItemBounds_vert))); - auto ps = gpu::ShaderPointer(gpu::Shader::createPixel(std::string(drawItemBounds_frag))); - gpu::ShaderPointer program = gpu::ShaderPointer(gpu::Shader::createProgram(vs, ps)); - - gpu::Shader::BindingSet slotBindings; - gpu::Shader::makeProgram(*program, slotBindings); - - _drawItemBoundPosLoc = program->getUniforms().findLocation("inBoundPos"); - _drawItemBoundDimLoc = program->getUniforms().findLocation("inBoundDim"); - - gpu::StatePointer state = gpu::StatePointer(new gpu::State()); - - state->setDepthTest(true, false, gpu::LESS_EQUAL); - - // Blend on transparent - state->setBlendFunction(true, - gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA, - gpu::State::DEST_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ZERO); - - // Good to go add the brand new pipeline + if (!_drawItemBoundsPipeline) { + auto vs = gpu::ShaderPointer(gpu::Shader::createVertex(std::string(drawItemBounds_vert))); + auto ps = gpu::ShaderPointer(gpu::Shader::createPixel(std::string(drawItemBounds_frag))); + gpu::ShaderPointer program = gpu::ShaderPointer(gpu::Shader::createProgram(vs, ps)); + + gpu::Shader::BindingSet slotBindings; + gpu::Shader::makeProgram(*program, slotBindings); + + _drawItemBoundPosLoc = program->getUniforms().findLocation("inBoundPos"); + _drawItemBoundDimLoc = program->getUniforms().findLocation("inBoundDim"); + + auto state = std::make_shared(); + + state->setDepthTest(true, false, gpu::LESS_EQUAL); + + // Blend on transparent + state->setBlendFunction(true, + gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA, + gpu::State::DEST_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ZERO); + + // Good to go add the brand new pipeline _drawItemBoundsPipeline.reset(gpu::Pipeline::create(program, state)); } return _drawItemBoundsPipeline; @@ -62,27 +62,27 @@ const gpu::PipelinePointer& DrawStatus::getDrawItemBoundsPipeline() { const gpu::PipelinePointer& DrawStatus::getDrawItemStatusPipeline() { if (!_drawItemStatusPipeline) { - auto vs = gpu::ShaderPointer(gpu::Shader::createVertex(std::string(drawItemStatus_vert))); - auto ps = gpu::ShaderPointer(gpu::Shader::createPixel(std::string(drawItemStatus_frag))); - gpu::ShaderPointer program = gpu::ShaderPointer(gpu::Shader::createProgram(vs, ps)); - - gpu::Shader::BindingSet slotBindings; - gpu::Shader::makeProgram(*program, slotBindings); - - _drawItemStatusPosLoc = program->getUniforms().findLocation("inBoundPos"); - _drawItemStatusDimLoc = program->getUniforms().findLocation("inBoundDim"); - _drawItemStatusValueLoc = program->getUniforms().findLocation("inStatus"); - - gpu::StatePointer state = gpu::StatePointer(new gpu::State()); - - state->setDepthTest(false, false, gpu::LESS_EQUAL); - - // Blend on transparent - state->setBlendFunction(true, - gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA, - gpu::State::DEST_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ZERO); - - // Good to go add the brand new pipeline + auto vs = gpu::ShaderPointer(gpu::Shader::createVertex(std::string(drawItemStatus_vert))); + auto ps = gpu::ShaderPointer(gpu::Shader::createPixel(std::string(drawItemStatus_frag))); + gpu::ShaderPointer program = gpu::ShaderPointer(gpu::Shader::createProgram(vs, ps)); + + gpu::Shader::BindingSet slotBindings; + gpu::Shader::makeProgram(*program, slotBindings); + + _drawItemStatusPosLoc = program->getUniforms().findLocation("inBoundPos"); + _drawItemStatusDimLoc = program->getUniforms().findLocation("inBoundDim"); + _drawItemStatusValueLoc = program->getUniforms().findLocation("inStatus"); + + auto state = std::make_shared(); + + state->setDepthTest(false, false, gpu::LESS_EQUAL); + + // Blend on transparent + state->setBlendFunction(true, + gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA, + gpu::State::DEST_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ZERO); + + // Good to go add the brand new pipeline _drawItemStatusPipeline.reset(gpu::Pipeline::create(program, state)); } return _drawItemStatusPipeline; @@ -98,10 +98,10 @@ void DrawStatus::run(const SceneContextPointer& sceneContext, const RenderContex int nbItems = 0; { if (!_itemBounds) { - _itemBounds.reset(new gpu::Buffer()); + _itemBounds = std::make_shared(); } if (!_itemStatus) { - _itemStatus.reset(new gpu::Buffer()); + _itemStatus = std::make_shared();; } _itemBounds->resize((inItems.size() * sizeof(AABox))); @@ -148,14 +148,14 @@ void DrawStatus::run(const SceneContextPointer& sceneContext, const RenderContex AABox* itemAABox = reinterpret_cast (_itemBounds->editData()); glm::ivec4* itemStatus = reinterpret_cast (_itemStatus->editData()); - - const unsigned int VEC3_ADRESS_OFFSET = 3; - + + const unsigned int VEC3_ADRESS_OFFSET = 3; + for (int i = 0; i < nbItems; i++) { batch._glUniform3fv(_drawItemBoundPosLoc, 1, (const GLfloat*) (itemAABox + i)); batch._glUniform3fv(_drawItemBoundDimLoc, 1, ((const GLfloat*) (itemAABox + i)) + VEC3_ADRESS_OFFSET); - batch.draw(gpu::LINES, 24, 0); + batch.draw(gpu::LINES, 24, 0); } batch.setPipeline(getDrawItemStatusPipeline()); diff --git a/libraries/render/src/render/Scene.cpp b/libraries/render/src/render/Scene.cpp index 1b52145a1c..4e1087d142 100644 --- a/libraries/render/src/render/Scene.cpp +++ b/libraries/render/src/render/Scene.cpp @@ -87,14 +87,14 @@ void Item::Status::getPackedValues(glm::ivec4& values) const { void Item::PayloadInterface::addStatusGetter(const Status::Getter& getter) { if (!_status) { - _status.reset(new Status()); + _status = std::make_shared(); } _status->addGetter(getter); } void Item::PayloadInterface::addStatusGetters(const Status::Getters& getters) { if (!_status) { - _status.reset(new Status()); + _status = std::make_shared(); } for (auto& g : getters) { _status->addGetter(g); From 1c965736e80477a9f4a69d56f6055b5a8dd838ce Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 17 Jul 2015 18:15:11 -0700 Subject: [PATCH 06/15] Remove merge error --- libraries/render-utils/src/TextRenderer3D.cpp | 403 ------------------ 1 file changed, 403 deletions(-) diff --git a/libraries/render-utils/src/TextRenderer3D.cpp b/libraries/render-utils/src/TextRenderer3D.cpp index b88883ba64..a93ba1daec 100644 --- a/libraries/render-utils/src/TextRenderer3D.cpp +++ b/libraries/render-utils/src/TextRenderer3D.cpp @@ -33,409 +33,6 @@ #include "GeometryCache.h" #include "DeferredLightingEffect.h" -<<<<<<< HEAD -// Helper functions for reading binary data from an IO device -template -void readStream(QIODevice& in, T& t) { - in.read((char*) &t, sizeof(t)); -} - -template -void readStream(QIODevice& in, T (&t)[N]) { - in.read((char*) t, N); -} - -template -void fillBuffer(QBuffer& buffer, T (&t)[N]) { - buffer.setData((const char*) t, N); -} - -// stores the font metrics for a single character -struct Glyph3D { - QChar c; - glm::vec2 texOffset; - glm::vec2 texSize; - glm::vec2 size; - glm::vec2 offset; - float d; // xadvance - adjusts character positioning - size_t indexOffset; - - // We adjust bounds because offset is the bottom left corner of the font but the top left corner of a QRect - QRectF bounds() const { return glmToRect(offset, size).translated(0.0f, -size.y); } - QRectF textureBounds() const { return glmToRect(texOffset, texSize); } - - void read(QIODevice& in); -}; - -void Glyph3D::read(QIODevice& in) { - uint16_t charcode; - readStream(in, charcode); - c = charcode; - readStream(in, texOffset); - readStream(in, size); - readStream(in, offset); - readStream(in, d); - texSize = size; -} - -struct TextureVertex { - glm::vec2 pos; - glm::vec2 tex; - TextureVertex() {} - TextureVertex(const glm::vec2& pos, const glm::vec2& tex) : pos(pos), tex(tex) {} -}; - -struct QuadBuilder { - TextureVertex vertices[4]; - QuadBuilder(const glm::vec2& min, const glm::vec2& size, - const glm::vec2& texMin, const glm::vec2& texSize) { - // min = bottomLeft - vertices[0] = TextureVertex(min, - texMin + glm::vec2(0.0f, texSize.y)); - vertices[1] = TextureVertex(min + glm::vec2(size.x, 0.0f), - texMin + texSize); - vertices[2] = TextureVertex(min + size, - texMin + glm::vec2(texSize.x, 0.0f)); - vertices[3] = TextureVertex(min + glm::vec2(0.0f, size.y), - texMin); - } - QuadBuilder(const Glyph3D& glyph, const glm::vec2& offset) : - QuadBuilder(offset + glm::vec2(glyph.offset.x, glyph.offset.y - glyph.size.y), glyph.size, - glyph.texOffset, glyph.texSize) {} - -}; - -class Font3D { -public: - Font3D(); - - void read(QIODevice& path); - - glm::vec2 computeExtent(const QString& str) const; - float getFontSize() const { return _fontSize; } - - // Render string to batch - void drawString(gpu::Batch& batch, float x, float y, const QString& str, - const glm::vec4* color, TextRenderer3D::EffectType effectType, - const glm::vec2& bound); - -private: - QStringList tokenizeForWrapping(const QString& str) const; - QStringList splitLines(const QString& str) const; - glm::vec2 computeTokenExtent(const QString& str) const; - - const Glyph3D& getGlyph(const QChar& c) const; - - void setupGPU(); - - // maps characters to cached glyph info - // HACK... the operator[] const for QHash returns a - // copy of the value, not a const value reference, so - // we declare the hash as mutable in order to avoid such - // copies - mutable QHash _glyphs; - - // Font characteristics - QString _family; - float _fontSize = 0.0f; - float _leading = 0.0f; - float _ascent = 0.0f; - float _descent = 0.0f; - float _spaceWidth = 0.0f; - - bool _initialized = false; - - // gpu structures - gpu::PipelinePointer _pipeline; - gpu::TexturePointer _texture; - gpu::Stream::FormatPointer _format; - gpu::BufferPointer _verticesBuffer; - gpu::BufferStreamPointer _stream; - unsigned int _numVertices = 0; - - int _fontLoc = -1; - int _outlineLoc = -1; - int _colorLoc = -1; - - // last string render characteristics - QString _lastStringRendered; - glm::vec2 _lastBounds; -}; - -static QHash LOADED_FONTS; - -Font3D* loadFont3D(QIODevice& fontFile) { - Font3D* result = new Font3D(); - result->read(fontFile); - return result; -} - -Font3D* loadFont3D(const QString& family) { - if (!LOADED_FONTS.contains(family)) { - - const QString SDFF_COURIER_PRIME_FILENAME = ":/CourierPrime.sdff"; - const QString SDFF_INCONSOLATA_MEDIUM_FILENAME = ":/InconsolataMedium.sdff"; - const QString SDFF_ROBOTO_FILENAME = ":/Roboto.sdff"; - const QString SDFF_TIMELESS_FILENAME = ":/Timeless.sdff"; - - QString loadFilename; - - if (family == MONO_FONT_FAMILY) { - loadFilename = SDFF_COURIER_PRIME_FILENAME; - } else if (family == INCONSOLATA_FONT_FAMILY) { - loadFilename = SDFF_INCONSOLATA_MEDIUM_FILENAME; - } else if (family == SANS_FONT_FAMILY) { - loadFilename = SDFF_ROBOTO_FILENAME; - } else { - if (!LOADED_FONTS.contains(SERIF_FONT_FAMILY)) { - loadFilename = SDFF_TIMELESS_FILENAME; - } else { - LOADED_FONTS[family] = LOADED_FONTS[SERIF_FONT_FAMILY]; - } - } - - if (!loadFilename.isEmpty()) { - QFile fontFile(loadFilename); - fontFile.open(QIODevice::ReadOnly); - - qCDebug(renderutils) << "Loaded font" << loadFilename << "from Qt Resource System."; - - LOADED_FONTS[family] = loadFont3D(fontFile); - } - } - return LOADED_FONTS[family]; -} - -Font3D::Font3D() { - static bool fontResourceInitComplete = false; - if (!fontResourceInitComplete) { - Q_INIT_RESOURCE(fonts); - fontResourceInitComplete = true; - } -} - -// NERD RAGE: why doesn't QHash have a 'const T & operator[] const' member -const Glyph3D& Font3D::getGlyph(const QChar& c) const { - if (!_glyphs.contains(c)) { - return _glyphs[QChar('?')]; - } - return _glyphs[c]; -} - -QStringList Font3D::splitLines(const QString& str) const { - return str.split('\n'); -} - -QStringList Font3D::tokenizeForWrapping(const QString& str) const { - QStringList tokens; - for(auto line : splitLines(str)) { - if (!tokens.empty()) { - tokens << QString('\n'); - } - tokens << line.split(' '); - } - return tokens; -} - -glm::vec2 Font3D::computeTokenExtent(const QString& token) const { - glm::vec2 advance(0, _fontSize); - foreach(QChar c, token) { - Q_ASSERT(c != '\n'); - advance.x += (c == ' ') ? _spaceWidth : getGlyph(c).d; - } - return advance; -} - -glm::vec2 Font3D::computeExtent(const QString& str) const { - glm::vec2 extent = glm::vec2(0.0f, 0.0f); - - QStringList lines{ splitLines(str) }; - if (!lines.empty()) { - for(const auto& line : lines) { - glm::vec2 tokenExtent = computeTokenExtent(line); - extent.x = std::max(tokenExtent.x, extent.x); - } - extent.y = lines.count() * _fontSize; - } - return extent; -} - -void Font3D::read(QIODevice& in) { - uint8_t header[4]; - readStream(in, header); - if (memcmp(header, "SDFF", 4)) { - qFatal("Bad SDFF file"); - } - - uint16_t version; - readStream(in, version); - - // read font name - _family = ""; - if (version > 0x0001) { - char c; - readStream(in, c); - while (c) { - _family += c; - readStream(in, c); - } - } - - // read font data - readStream(in, _leading); - readStream(in, _ascent); - readStream(in, _descent); - readStream(in, _spaceWidth); - _fontSize = _ascent + _descent; - - // Read character count - uint16_t count; - readStream(in, count); - // read metrics data for each character - QVector glyphs(count); - // std::for_each instead of Qt foreach because we need non-const references - std::for_each(glyphs.begin(), glyphs.end(), [&](Glyph3D& g) { - g.read(in); - }); - - // read image data - QImage image; - if (!image.loadFromData(in.readAll(), "PNG")) { - qFatal("Failed to read SDFF image"); - } - - _glyphs.clear(); - glm::vec2 imageSize = toGlm(image.size()); - foreach(Glyph3D g, glyphs) { - // Adjust the pixel texture coordinates into UV coordinates, - g.texSize /= imageSize; - g.texOffset /= imageSize; - // store in the character to glyph hash - _glyphs[g.c] = g; - }; - - image = image.convertToFormat(QImage::Format_RGBA8888); - - gpu::Element formatGPU = gpu::Element(gpu::VEC3, gpu::UINT8, gpu::RGB); - gpu::Element formatMip = gpu::Element(gpu::VEC3, gpu::UINT8, gpu::RGB); - if (image.hasAlphaChannel()) { - formatGPU = gpu::Element(gpu::VEC4, gpu::UINT8, gpu::RGBA); - formatMip = gpu::Element(gpu::VEC4, gpu::UINT8, gpu::BGRA); - } - _texture = gpu::TexturePointer(gpu::Texture::create2D(formatGPU, image.width(), image.height(), - gpu::Sampler(gpu::Sampler::FILTER_MIN_POINT_MAG_LINEAR))); - _texture->assignStoredMip(0, formatMip, image.byteCount(), image.constBits()); - _texture->autoGenerateMips(-1); -} - -void Font3D::setupGPU() { - if (!_initialized) { - _initialized = true; - - // Setup render pipeline - auto vertexShader = gpu::ShaderPointer(gpu::Shader::createVertex(std::string(sdf_text3D_vert))); - auto pixelShader = gpu::ShaderPointer(gpu::Shader::createPixel(std::string(sdf_text3D_frag))); - gpu::ShaderPointer program = gpu::ShaderPointer(gpu::Shader::createProgram(vertexShader, pixelShader)); - - gpu::Shader::BindingSet slotBindings; - gpu::Shader::makeProgram(*program, slotBindings); - - _fontLoc = program->getTextures().findLocation("Font"); - _outlineLoc = program->getUniforms().findLocation("Outline"); - _colorLoc = program->getUniforms().findLocation("Color"); - - auto state = std::make_shared(); - state->setCullMode(gpu::State::CULL_BACK); - state->setDepthTest(true, true, gpu::LESS_EQUAL); - state->setBlendFunction(true, - gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA, - gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE); - _pipeline = gpu::PipelinePointer(gpu::Pipeline::create(program, state)); - - // Sanity checks - static const int OFFSET = offsetof(TextureVertex, tex); - assert(OFFSET == sizeof(glm::vec2)); - assert(sizeof(glm::vec2) == 2 * sizeof(float)); - assert(sizeof(TextureVertex) == 2 * sizeof(glm::vec2)); - assert(sizeof(QuadBuilder) == 4 * sizeof(TextureVertex)); - - // Setup rendering structures - _format = std::make_shared(); - _format->setAttribute(gpu::Stream::POSITION, 0, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::XYZ), 0); - _format->setAttribute(gpu::Stream::TEXCOORD, 0, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::UV), OFFSET); - } -} - -void Font3D::drawString(gpu::Batch& batch, float x, float y, const QString& str, const glm::vec4* color, - TextRenderer3D::EffectType effectType, const glm::vec2& bounds) { - if (str == "") { - return; - } - - if (str != _lastStringRendered || bounds != _lastBounds) { - _verticesBuffer = std::make_shared(); - _numVertices = 0; - _lastStringRendered = str; - _lastBounds = bounds; - - // Top left of text - glm::vec2 advance = glm::vec2(x, y); - foreach(const QString& token, tokenizeForWrapping(str)) { - bool isNewLine = (token == QString('\n')); - bool forceNewLine = false; - - // Handle wrapping - if (!isNewLine && (bounds.x != -1) && (advance.x + computeExtent(token).x > x + bounds.x)) { - // We are out of the x bound, force new line - forceNewLine = true; - } - if (isNewLine || forceNewLine) { - // Character return, move the advance to a new line - advance = glm::vec2(x, advance.y - _leading); - - if (isNewLine) { - // No need to draw anything, go directly to next token - continue; - } else if (computeExtent(token).x > bounds.x) { - // token will never fit, stop drawing - break; - } - } - if ((bounds.y != -1) && (advance.y - _fontSize < -y - bounds.y)) { - // We are out of the y bound, stop drawing - break; - } - - // Draw the token - if (!isNewLine) { - for (auto c : token) { - auto glyph = _glyphs[c]; - - QuadBuilder qd(glyph, advance - glm::vec2(0.0f, _ascent)); - _verticesBuffer->append(sizeof(QuadBuilder), (const gpu::Byte*)&qd); - _numVertices += 4; - - // Advance by glyph size - advance.x += glyph.d; - } - - // Add space after all non return tokens - advance.x += _spaceWidth; - } - } - } - - setupGPU(); - batch.setPipeline(_pipeline); - batch.setUniformTexture(_fontLoc, _texture); - batch._glUniform1i(_outlineLoc, (effectType == TextRenderer3D::OUTLINE_EFFECT)); - batch._glUniform4fv(_colorLoc, 1, (const GLfloat*)color); - - batch.setInputFormat(_format); - batch.setInputBuffer(0, _verticesBuffer, 0, _format->getChannels().at(0)._stride); - batch.draw(gpu::QUADS, _numVertices, 0); -} -======= const float TextRenderer3D::DEFAULT_POINT_SIZE = 12; TextRenderer3D* TextRenderer3D::getInstance(const char* family, float pointSize, From 640171d5bd505678a1330f5d219393b88433fb9b Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 17 Jul 2015 18:22:35 -0700 Subject: [PATCH 07/15] Restore AccountManager setup --- libraries/networking/src/AccountManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/networking/src/AccountManager.cpp b/libraries/networking/src/AccountManager.cpp index 0eff6a6b91..2830a13ca7 100644 --- a/libraries/networking/src/AccountManager.cpp +++ b/libraries/networking/src/AccountManager.cpp @@ -34,10 +34,10 @@ const bool VERBOSE_HTTP_REQUEST_DEBUGGING = false; AccountManager& AccountManager::getInstance(bool forceReset) { - static auto sharedInstance = std::make_shared(); + static std::unique_ptr sharedInstance(new AccountManager()); if (forceReset) { - sharedInstance = std::make_shared(); + sharedInstance.reset(new AccountManager()); } return *sharedInstance; From 73ffe5d9f6b681252de9170522c31569f902ecd2 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 20 Jul 2015 10:25:59 -0700 Subject: [PATCH 08/15] Fix Avatar > Blue Sphere While Speaking not rendering --- interface/src/avatar/Avatar.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index 239359c1cf..aa54343e01 100644 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -485,7 +485,7 @@ void Avatar::render(RenderArgs* renderArgs, const glm::vec3& cameraPosition, boo // quick check before falling into the code below: // (a 10 degree breadth of an almost 2 meter avatar kicks in at about 12m) const float MIN_VOICE_SPHERE_DISTANCE = 12.0f; - if (postLighting && Menu::getInstance()->isOptionChecked(MenuOption::BlueSpeechSphere) + if (Menu::getInstance()->isOptionChecked(MenuOption::BlueSpeechSphere) && distanceToTarget > MIN_VOICE_SPHERE_DISTANCE) { // render voice intensity sphere for avatars that are farther away @@ -499,7 +499,7 @@ void Avatar::render(RenderArgs* renderArgs, const glm::vec3& cameraPosition, boo float angle = abs(angleBetween(toTarget + delta, toTarget - delta)); float sphereRadius = getHead()->getAverageLoudness() * SPHERE_LOUDNESS_SCALING; - if (renderArgs->_renderMode == RenderArgs::NORMAL_RENDER_MODE && (sphereRadius > MIN_SPHERE_SIZE) && + if (renderArgs->_renderMode == RenderArgs::DEFAULT_RENDER_MODE && (sphereRadius > MIN_SPHERE_SIZE) && (angle < MAX_SPHERE_ANGLE) && (angle > MIN_SPHERE_ANGLE)) { Transform transform; transform.setTranslation(_position); From 1a9f6e12a5851cf040c41ab94b05b38df5738d2c Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Mon, 20 Jul 2015 12:20:04 -0700 Subject: [PATCH 09/15] something not compiling but just before merge with upstream --- interface/src/Application.cpp | 49 ++++++++++--------- interface/src/Application.h | 28 +++++------ .../src/ui/overlays/LocalModelsOverlay.cpp | 4 +- libraries/gpu/src/gpu/GLBackendTransform.cpp | 8 +-- .../src/AbstractViewStateInterface.h | 2 +- 5 files changed, 49 insertions(+), 42 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 0b6a44fe83..e613b60344 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -321,7 +321,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : _previousScriptLocation("LastScriptLocation"), _scriptsLocationHandle("scriptsLocation"), _fieldOfView("fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES), - _viewTransform(), _scaleMirror(1.0f), _rotateMirror(0.0f), _raiseMirror(0.0f), @@ -1079,10 +1078,12 @@ void Application::resizeGL() { _renderResolution = toGlm(renderSize); DependencyManager::get()->setFrameBufferSize(renderSize); - glViewport(0, 0, _renderResolution.x, _renderResolution.y); // shouldn't this account for the menu??? + // glViewport(0, 0, _renderResolution.x, _renderResolution.y); // shouldn't this account for the menu??? - updateProjectionMatrix(); - glLoadIdentity(); + //updateProjectionMatrix(); + // glLoadIdentity(); + + loadViewFrustum(_myCamera, _viewFrustum); } resetCameras(_myCamera, _renderResolution); @@ -1094,11 +1095,14 @@ void Application::resizeGL() { _glWidget->makeCurrent(); } - +/* void Application::updateProjectionMatrix() { - updateProjectionMatrix(_myCamera); + // _projectionMatrix = _myCamera.getProjection(); + loadViewFrustum(_myCamera, _viewFrustum); +// updateProjectionMatrix(_myCamera); } - +*/ +/* void Application::updateProjectionMatrix(Camera& camera, bool updateViewFrustum) { _projectionMatrix = camera.getProjection(); @@ -1112,7 +1116,7 @@ void Application::updateProjectionMatrix(Camera& camera, bool updateViewFrustum) glMatrixMode(GL_MODELVIEW); } - +*/ void Application::controlledBroadcastToNodes(const QByteArray& packet, const NodeSet& destinationNodeTypes) { foreach(NodeType_t type, destinationNodeTypes) { // Perform the broadcast for one type @@ -3118,8 +3122,7 @@ void Application::updateShadowMap(RenderArgs* renderArgs) { // this is what is used for rendering the Entities and avatars Transform viewTransform; viewTransform.setRotation(rotation); - // viewTransform.postTranslate(shadowFrustumCenter); - setViewTransform(viewTransform); + // setViewTransform(viewTransform); glEnable(GL_POLYGON_OFFSET_FILL); @@ -3440,7 +3443,7 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se viewTransform.preTranslate(_viewMatrixTranslation); } - setViewTransform(viewTransform); +// setViewTransform(viewTransform); glTranslatef(_viewMatrixTranslation.x, _viewMatrixTranslation.y, _viewMatrixTranslation.z); @@ -3615,9 +3618,9 @@ void Application::updateUntranslatedViewMatrix(const glm::vec3& viewMatrixTransl _viewMatrixTranslation = viewMatrixTranslation; } -void Application::setViewTransform(const Transform& view) { +/*void Application::setViewTransform(const Transform& view) { _viewTransform = view; -} +}*/ void Application::loadTranslatedViewMatrix(const glm::vec3& translation) { glLoadMatrixf((const GLfloat*)&_untranslatedViewMatrix); @@ -3685,8 +3688,8 @@ glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& region, bool billboard) { // Grab current viewport to reset it at the end - int viewport[4]; - glGetIntegerv(GL_VIEWPORT, viewport); + // int viewport[4]; +// glGetIntegerv(GL_VIEWPORT, viewport); auto masterViewport = renderArgs->_viewport; float aspect = (float)region.width() / region.height(); float fov = MIRROR_FIELD_OF_VIEW; @@ -3727,16 +3730,16 @@ void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& regi // set the bounds of rear mirror view if (billboard) { QSize size = DependencyManager::get()->getFrameBufferSize(); - glViewport(region.x(), size.height() - region.y() - region.height(), region.width(), region.height()); - glScissor(region.x(), size.height() - region.y() - region.height(), region.width(), region.height()); + // glViewport(region.x(), size.height() - region.y() - region.height(), region.width(), region.height()); + // glScissor(region.x(), size.height() - region.y() - region.height(), region.width(), region.height()); renderArgs->_viewport = glm::ivec4(region.x(), size.height() - region.y() - region.height(), region.width(), region.height()); } else { // if not rendering the billboard, the region is in device independent coordinates; must convert to device QSize size = DependencyManager::get()->getFrameBufferSize(); float ratio = (float)QApplication::desktop()->windowHandle()->devicePixelRatio() * getRenderResolutionScale(); int x = region.x() * ratio, y = region.y() * ratio, width = region.width() * ratio, height = region.height() * ratio; - glViewport(x, size.height() - y - height, width, height); - glScissor(x, size.height() - y - height, width, height); + // glViewport(x, size.height() - y - height, width, height); + // glScissor(x, size.height() - y - height, width, height); renderArgs->_viewport = glm::ivec4(x, size.height() - y - height, width, height); } @@ -3748,7 +3751,7 @@ void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& regi */ gpu::Batch batch; batch.setViewportTransform(renderArgs->_viewport); - // batch.setStateScissorRect(scissor); + batch.setStateScissorRect(renderArgs->_viewport); batch.clearFramebuffer(gpu::Framebuffer::BUFFER_COLORS | gpu::Framebuffer::BUFFER_DEPTH, glm::vec4(0.0f), 1.0f, 0, true); renderArgs->_context->syncCache(); @@ -3760,9 +3763,9 @@ void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& regi // glPopMatrix(); // reset Viewport and projection matrix - renderArgs->_viewport = glm::ivec4(viewport[0], viewport[1], viewport[2], viewport[3]); - glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); - // glDisable(GL_SCISSOR_TEST); + //renderArgs->_viewport = glm::ivec4(viewport[0], viewport[1], viewport[2], viewport[3]); + renderArgs->_viewport = masterViewport; + // glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); updateProjectionMatrix(_myCamera, updateViewFrustum); } diff --git a/interface/src/Application.h b/interface/src/Application.h index 1fe1acb25a..bcd3717576 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -241,11 +241,11 @@ public: Overlays& getOverlays() { return _overlays; } float getFps() const { return _fps; } - const glm::vec3& getViewMatrixTranslation() const { return _viewMatrixTranslation; } - void setViewMatrixTranslation(const glm::vec3& translation) { _viewMatrixTranslation = translation; } + // const glm::vec3& getViewMatrixTranslation() const { return _viewMatrixTranslation; } + // void setViewMatrixTranslation(const glm::vec3& translation) { _viewMatrixTranslation = translation; } - virtual const Transform& getViewTransform() const { return _viewTransform; } - void setViewTransform(const Transform& view); + // virtual const Transform& getViewTransform() const { return _viewTransform; } + // void setViewTransform(const Transform& view); float getFieldOfView() { return _fieldOfView.get(); } void setFieldOfView(float fov) { _fieldOfView.set(fov); } @@ -276,14 +276,14 @@ public: /// the view matrix translation. void updateUntranslatedViewMatrix(const glm::vec3& viewMatrixTranslation = glm::vec3()); - const glm::mat4& getUntranslatedViewMatrix() const { return _untranslatedViewMatrix; } +// const glm::mat4& getUntranslatedViewMatrix() const { return _untranslatedViewMatrix; } /// Loads a view matrix that incorporates the specified model translation without the precision issues that can /// result from matrix multiplication at high translation magnitudes. - void loadTranslatedViewMatrix(const glm::vec3& translation); + // void loadTranslatedViewMatrix(const glm::vec3& translation); - void getModelViewMatrix(glm::dmat4* modelViewMatrix); - void getProjectionMatrix(glm::dmat4* projectionMatrix); + // void getModelViewMatrix(glm::dmat4* modelViewMatrix); + // void getProjectionMatrix(glm::dmat4* projectionMatrix); virtual const glm::vec3& getShadowDistances() const { return _shadowDistances; } @@ -475,8 +475,8 @@ private slots: private: void resetCameras(Camera& camera, const glm::uvec2& size); - void updateProjectionMatrix(); - void updateProjectionMatrix(Camera& camera, bool updateViewFrustum = true); + // void updateProjectionMatrix(); + // void updateProjectionMatrix(Camera& camera, bool updateViewFrustum = true); void sendPingPackets(); @@ -568,10 +568,10 @@ private: Setting::Handle _scriptsLocationHandle; Setting::Handle _fieldOfView; - Transform _viewTransform; - glm::mat4 _untranslatedViewMatrix; - glm::vec3 _viewMatrixTranslation; - glm::mat4 _projectionMatrix; + //Transform _viewTransform; + //glm::mat4 _untranslatedViewMatrix; + //glm::vec3 _viewMatrixTranslation; + //glm::mat4 _projectionMatrix; float _scaleMirror; float _rotateMirror; diff --git a/interface/src/ui/overlays/LocalModelsOverlay.cpp b/interface/src/ui/overlays/LocalModelsOverlay.cpp index 06b27f8f22..3e7c7601c6 100644 --- a/interface/src/ui/overlays/LocalModelsOverlay.cpp +++ b/interface/src/ui/overlays/LocalModelsOverlay.cpp @@ -34,7 +34,9 @@ void LocalModelsOverlay::render(RenderArgs* args) { auto batch = args ->_batch; Application* app = Application::getInstance(); - glm::vec3 oldTranslation = app->getViewMatrixTranslation(); + + glm::vec3 oldTranslation = app->getViewFrustum()->getPosition(); +// glm::vec3 oldTranslation = app->getViewMatrixTranslation(); Transform transform = Transform(); transform.setTranslation(oldTranslation + getPosition()); batch->setViewTransform(transform); diff --git a/libraries/gpu/src/gpu/GLBackendTransform.cpp b/libraries/gpu/src/gpu/GLBackendTransform.cpp index 01229cb317..65d9c6ed75 100755 --- a/libraries/gpu/src/gpu/GLBackendTransform.cpp +++ b/libraries/gpu/src/gpu/GLBackendTransform.cpp @@ -32,6 +32,11 @@ void GLBackend::do_setProjectionTransform(Batch& batch, uint32 paramOffset) { void GLBackend::do_setViewportTransform(Batch& batch, uint32 paramOffset) { memcpy(&_transform._viewport, batch.editData(batch._params[paramOffset]._uint), sizeof(Vec4i)); + + // Where we assign the GL viewport + glViewport(_transform._viewport.x, _transform._viewport.y, _transform._viewport.z, _transform._viewport.w); + + // The Viewport is tagged invalid because the CameraTransformUBO is not up to date and willl need update on next drawcall _transform._invalidViewport = true; } @@ -85,9 +90,6 @@ void GLBackend::updateTransform() { // Check all the dirty flags and update the state accordingly if (_transform._invalidViewport) { _transform._transformCamera._viewport = glm::vec4(_transform._viewport); - - // Where we assign the GL viewport - glViewport(_transform._viewport.x, _transform._viewport.y, _transform._viewport.z, _transform._viewport.w); } if (_transform._invalidProj) { diff --git a/libraries/render-utils/src/AbstractViewStateInterface.h b/libraries/render-utils/src/AbstractViewStateInterface.h index ff417da85e..a1e664a7a1 100644 --- a/libraries/render-utils/src/AbstractViewStateInterface.h +++ b/libraries/render-utils/src/AbstractViewStateInterface.h @@ -51,7 +51,7 @@ public: virtual bool getCascadeShadowsEnabled() = 0; virtual QThread* getMainThread() = 0; - virtual const Transform& getViewTransform() const = 0; + // virtual const Transform& getViewTransform() const = 0; virtual void setupWorldLight() = 0; virtual bool shouldRenderMesh(float largestDimension, float distanceToCamera) = 0; virtual float getSizeScale() const = 0; From 648d0f6d433113b65dcef2aa588d00e26e555f89 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Mon, 20 Jul 2015 15:12:27 -0700 Subject: [PATCH 10/15] fix a bunch of warnings --- interface/src/Application.cpp | 4 ++-- interface/src/GLCanvas.cpp | 4 ++-- interface/src/Stars.cpp | 16 +++++++++------- interface/src/avatar/FaceModel.cpp | 1 - interface/src/devices/OculusManager.cpp | 2 ++ interface/src/ui/ApplicationOverlay.cpp | 8 ++++---- interface/src/ui/ApplicationOverlay.h | 2 +- interface/src/ui/overlays/LocalModelsOverlay.cpp | 2 -- libraries/render-utils/src/TextRenderer3D.cpp | 1 - libraries/render-utils/src/TextRenderer3D.h | 1 - tests/render-utils/src/main.cpp | 2 +- 11 files changed, 21 insertions(+), 22 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ce156354fb..a6444bb98d 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -333,11 +333,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : _isThrottleFPSEnabled(false), _aboutToQuit(false), _notifiedPacketVersionMismatchThisDomain(false), + _glWidget(new GLCanvas()), _domainConnectionRefusals(QList()), _maxOctreePPS(maxOctreePacketsPerSecond.get()), _lastFaceTrackerUpdate(0), - _applicationOverlay(), - _glWidget(new GLCanvas()) + _applicationOverlay() { setInstance(this); #ifdef Q_OS_WIN diff --git a/interface/src/GLCanvas.cpp b/interface/src/GLCanvas.cpp index be7ed6ec72..705a98b855 100644 --- a/interface/src/GLCanvas.cpp +++ b/interface/src/GLCanvas.cpp @@ -60,8 +60,8 @@ void GLCanvas::initializeGL() { void GLCanvas::paintGL() { PROFILE_RANGE(__FUNCTION__); - if (!_throttleRendering - && (!Application::getInstance()->getWindow()->isMinimized()) || !Application::getInstance()->isThrottleFPSEnabled()) { + if (!_throttleRendering && + (!Application::getInstance()->getWindow()->isMinimized() || !Application::getInstance()->isThrottleFPSEnabled())) { Application::getInstance()->paintGL(); } } diff --git a/interface/src/Stars.cpp b/interface/src/Stars.cpp index e6c96d9b4b..5f15363ab1 100644 --- a/interface/src/Stars.cpp +++ b/interface/src/Stars.cpp @@ -31,14 +31,14 @@ static const float TILT = 0.0f; static const unsigned int STARFIELD_NUM_STARS = 50000; static const unsigned int STARFIELD_SEED = 1; -static const float STAR_COLORIZATION = 0.1f; +//static const float STAR_COLORIZATION = 0.1f; static const float TAU = 6.28318530717958f; -static const float HALF_TAU = TAU / 2.0f; -static const float QUARTER_TAU = TAU / 4.0f; -static const float MILKY_WAY_WIDTH = TAU / 30.0f; // width in radians of one half of the Milky Way -static const float MILKY_WAY_INCLINATION = 0.0f; // angle of Milky Way from horizontal in degrees -static const float MILKY_WAY_RATIO = 0.4f; +//static const float HALF_TAU = TAU / 2.0f; +//static const float QUARTER_TAU = TAU / 4.0f; +//static const float MILKY_WAY_WIDTH = TAU / 30.0f; // width in radians of one half of the Milky Way +//static const float MILKY_WAY_INCLINATION = 0.0f; // angle of Milky Way from horizontal in degrees +//static const float MILKY_WAY_RATIO = 0.4f; static const char* UNIFORM_TIME_NAME = "iGlobalTime"; @@ -55,9 +55,11 @@ static float frand() { } // Produce a random radian value between 0 and 2 PI (TAU) +/* static float rrand() { return frand() * TAU; } + */ // http://mathworld.wolfram.com/SpherePointPicking.html static vec2 randPolar() { @@ -117,7 +119,7 @@ void Stars::render(RenderArgs* renderArgs, float alpha) { static std::once_flag once; const int VERTICES_SLOT = 0; - const int COLOR_SLOT = 2; + //const int COLOR_SLOT = 2; std::call_once(once, [&] { QElapsedTimer startTime; diff --git a/interface/src/avatar/FaceModel.cpp b/interface/src/avatar/FaceModel.cpp index 170965bb4d..16b370d459 100644 --- a/interface/src/avatar/FaceModel.cpp +++ b/interface/src/avatar/FaceModel.cpp @@ -49,7 +49,6 @@ void FaceModel::simulate(float deltaTime, bool fullUpdate) { } void FaceModel::maybeUpdateNeckRotation(const JointState& parentState, const FBXJoint& joint, JointState& state) { - Avatar* owningAvatar = static_cast(_owningHead->_owningAvatar); // get the rotation axes in joint space and use them to adjust the rotation glm::mat3 axes = glm::mat3_cast(glm::quat()); glm::mat3 inverse = glm::mat3(glm::inverse(parentState.getTransform() * diff --git a/interface/src/devices/OculusManager.cpp b/interface/src/devices/OculusManager.cpp index 9395584a66..f9c2adc785 100644 --- a/interface/src/devices/OculusManager.cpp +++ b/interface/src/devices/OculusManager.cpp @@ -398,6 +398,8 @@ void OculusManager::connect(QOpenGLContext* shareContext) { int configResult = ovrHmd_ConfigureRendering(_ovrHmd, &cfg.Config, distortionCaps, _eyeFov, _eyeRenderDesc); assert(configResult); + Q_UNUSED(configResult); + _outputWindow->doneCurrent(); for_each_eye([&](ovrEyeType eye) { diff --git a/interface/src/ui/ApplicationOverlay.cpp b/interface/src/ui/ApplicationOverlay.cpp index ed2c68aba5..2c1b01fee1 100644 --- a/interface/src/ui/ApplicationOverlay.cpp +++ b/interface/src/ui/ApplicationOverlay.cpp @@ -32,8 +32,8 @@ const vec4 CONNECTION_STATUS_BORDER_COLOR{ 1.0f, 0.0f, 0.0f, 0.8f }; const float CONNECTION_STATUS_BORDER_LINE_WIDTH = 4.0f; -static const float ORTHO_NEAR_CLIP = -10000; -static const float ORTHO_FAR_CLIP = 10000; +static const float ORTHO_NEAR_CLIP = -1000; +static const float ORTHO_FAR_CLIP = 1000; ApplicationOverlay::ApplicationOverlay() { @@ -131,7 +131,7 @@ void ApplicationOverlay::renderAudioScope(RenderArgs* renderArgs) { batch.setResourceTexture(0, textureCache->getWhiteTexture()); int width = renderArgs->_viewport.z; int height = renderArgs->_viewport.w; - mat4 legacyProjection = glm::ortho(0, width, height, 0, -1000, 1000); + mat4 legacyProjection = glm::ortho(0, width, height, 0, ORTHO_NEAR_CLIP, ORTHO_FAR_CLIP); batch.setProjectionTransform(legacyProjection); batch.setModelTransform(Transform()); batch.setViewTransform(Transform()); @@ -151,7 +151,7 @@ void ApplicationOverlay::renderOverlays(RenderArgs* renderArgs) { batch.setResourceTexture(0, textureCache->getWhiteTexture()); int width = renderArgs->_viewport.z; int height = renderArgs->_viewport.w; - mat4 legacyProjection = glm::ortho(0, width, height, 0, -1000, 1000); + mat4 legacyProjection = glm::ortho(0, width, height, 0, ORTHO_NEAR_CLIP, ORTHO_FAR_CLIP); batch.setProjectionTransform(legacyProjection); batch.setModelTransform(Transform()); batch.setViewTransform(Transform()); diff --git a/interface/src/ui/ApplicationOverlay.h b/interface/src/ui/ApplicationOverlay.h index 92485fba82..66cf591e21 100644 --- a/interface/src/ui/ApplicationOverlay.h +++ b/interface/src/ui/ApplicationOverlay.h @@ -13,7 +13,7 @@ #define hifi_ApplicationOverlay_h #include -class QOpenGLFramebufferObject; +//class QOpenGLFramebufferObject; // Handles the drawing of the overlays to the screen // TODO, move divide up the rendering, displaying and input handling diff --git a/interface/src/ui/overlays/LocalModelsOverlay.cpp b/interface/src/ui/overlays/LocalModelsOverlay.cpp index 9a2733c739..875ffb1a35 100644 --- a/interface/src/ui/overlays/LocalModelsOverlay.cpp +++ b/interface/src/ui/overlays/LocalModelsOverlay.cpp @@ -31,8 +31,6 @@ void LocalModelsOverlay::update(float deltatime) { void LocalModelsOverlay::render(RenderArgs* args) { if (_visible) { - float glowLevel = getGlowLevel(); // FIXME, glowing removed for now - auto batch = args ->_batch; Transform transform = Transform(); transform.setTranslation(args->_viewFrustum->getPosition() + getPosition()); diff --git a/libraries/render-utils/src/TextRenderer3D.cpp b/libraries/render-utils/src/TextRenderer3D.cpp index 5519300a2e..c3056be00b 100644 --- a/libraries/render-utils/src/TextRenderer3D.cpp +++ b/libraries/render-utils/src/TextRenderer3D.cpp @@ -40,7 +40,6 @@ TextRenderer3D* TextRenderer3D::getInstance(const char* family, float pointSize, TextRenderer3D::TextRenderer3D(const char* family, float pointSize, int weight, bool italic, EffectType effect, int effectThickness) : - _pointSize(pointSize), _effectType(effect), _effectThickness(effectThickness), _font(Font::load(family)) { diff --git a/libraries/render-utils/src/TextRenderer3D.h b/libraries/render-utils/src/TextRenderer3D.h index c5af61a252..ea230016f2 100644 --- a/libraries/render-utils/src/TextRenderer3D.h +++ b/libraries/render-utils/src/TextRenderer3D.h @@ -54,7 +54,6 @@ private: // text color glm::vec4 _color; - float _pointSize{ DEFAULT_POINT_SIZE }; Font* _font; }; diff --git a/tests/render-utils/src/main.cpp b/tests/render-utils/src/main.cpp index 350db8c879..3b7eb18368 100644 --- a/tests/render-utils/src/main.cpp +++ b/tests/render-utils/src/main.cpp @@ -184,7 +184,7 @@ protected: #define SERIF_FONT_FAMILY "Times New Roman" #endif -static const wchar_t* EXAMPLE_TEXT = L"Hello"; +//static const wchar_t* EXAMPLE_TEXT = L"Hello"; //static const wchar_t* EXAMPLE_TEXT = L"\xC1y Hello 1.0\ny\xC1 line 2\n\xC1y"; static const glm::uvec2 QUAD_OFFSET(10, 10); From 65a79cfefbdf2d9cfc15f83d7f0bf0c31eed799c Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Mon, 20 Jul 2015 15:58:25 -0700 Subject: [PATCH 11/15] fix a bunch of warnings --- interface/src/ui/ApplicationOverlay.h | 1 - 1 file changed, 1 deletion(-) diff --git a/interface/src/ui/ApplicationOverlay.h b/interface/src/ui/ApplicationOverlay.h index 66cf591e21..ae09aa0b10 100644 --- a/interface/src/ui/ApplicationOverlay.h +++ b/interface/src/ui/ApplicationOverlay.h @@ -13,7 +13,6 @@ #define hifi_ApplicationOverlay_h #include -//class QOpenGLFramebufferObject; // Handles the drawing of the overlays to the screen // TODO, move divide up the rendering, displaying and input handling From 9d9142c274ec47c035e6840a97c2ebe7375634d7 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Mon, 20 Jul 2015 16:50:24 -0700 Subject: [PATCH 12/15] cleaning commented code supposedly dead now --- interface/src/Application.cpp | 55 ----------------------------------- interface/src/Application.h | 27 ----------------- 2 files changed, 82 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 01c1c08952..c2460e4e55 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -961,10 +961,6 @@ void Application::paintGL() { // FIXME: it's happening again in the updateSHadow and it shouldn't, this should be the place loadViewFrustum(_myCamera, _viewFrustum); - if (getShadowsEnabled()) { - renderArgs._renderMode = RenderArgs::SHADOW_RENDER_MODE; - updateShadowMap(&renderArgs); - } renderArgs._renderMode = RenderArgs::DEFAULT_RENDER_MODE; @@ -2971,13 +2967,6 @@ glm::vec3 Application::getSunDirection() { // FIXME, preprocessor guard this check to occur only in DEBUG builds static QThread * activeRenderingThread = nullptr; -void Application::updateShadowMap(RenderArgs* renderArgs) { - // TODO fix shadows and make them use the GPU library -} - -void Application::setupWorldLight(RenderArgs* renderArgs) { -} - bool Application::shouldRenderMesh(float largestDimension, float distanceToCamera) { return DependencyManager::get()->shouldRenderMesh(largestDimension, distanceToCamera); } @@ -3222,30 +3211,6 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se // load the view frustum loadViewFrustum(theCamera, _displayViewFrustum); - // store view matrix without translation, which we'll use for precision-sensitive objects - // updateUntranslatedViewMatrix(-theCamera.getPosition()); - - // Equivalent to what is happening with _untranslatedViewMatrix and the _viewMatrixTranslation - // the viewTransofmr object is updatded with the correct values and saved, - // this is what is used for rendering the Entities and avatars - Transform viewTransform; - viewTransform.setTranslation(theCamera.getPosition()); - viewTransform.setRotation(theCamera.getRotation()); - /* if (renderArgs->_renderSide != RenderArgs::MONO) { - glm::mat4 invView = glm::inverse(_untranslatedViewMatrix); - - viewTransform.evalFromRawMatrix(invView); - viewTransform.preTranslate(_viewMatrixTranslation); - }*/ - -// setViewTransform(viewTransform); - - // Setup 3D lights (after the camera transform, so that they are positioned in world space) - { - PerformanceTimer perfTimer("lights"); - setupWorldLight(renderArgs); - } - // TODO fix shadows and make them use the GPU library // The pending changes collecting the changes here @@ -3374,26 +3339,6 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se activeRenderingThread = nullptr; } -void Application::updateUntranslatedViewMatrix(const glm::vec3& viewMatrixTranslation) { - // _viewMatrixTranslation = viewMatrixTranslation; -} - -/*void Application::setViewTransform(const Transform& view) { - _viewTransform = view; -}*/ - -//void Application::loadTranslatedViewMatrix(const glm::vec3& translation) { -//} -/* -void Application::getModelViewMatrix(glm::dmat4* modelViewMatrix) { - (*modelViewMatrix) =_untranslatedViewMatrix; - (*modelViewMatrix)[3] = _untranslatedViewMatrix * glm::vec4(_viewMatrixTranslation, 1); -} - -void Application::getProjectionMatrix(glm::dmat4* projectionMatrix) { - *projectionMatrix = _projectionMatrix; -} -*/ void Application::computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal, float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const { diff --git a/interface/src/Application.h b/interface/src/Application.h index d377be7727..736f515390 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -236,11 +236,6 @@ public: Overlays& getOverlays() { return _overlays; } float getFps() const { return _fps; } - // const glm::vec3& getViewMatrixTranslation() const { return _viewMatrixTranslation; } - // void setViewMatrixTranslation(const glm::vec3& translation) { _viewMatrixTranslation = translation; } - - // virtual const Transform& getViewTransform() const { return _viewTransform; } - // void setViewTransform(const Transform& view); float getFieldOfView() { return _fieldOfView.get(); } void setFieldOfView(float fov) { _fieldOfView.set(fov); } @@ -258,26 +253,12 @@ public: void resetProfile(const QString& username); - virtual void setupWorldLight(RenderArgs* renderArgs); virtual bool shouldRenderMesh(float largestDimension, float distanceToCamera); QImage renderAvatarBillboard(RenderArgs* renderArgs); void displaySide(RenderArgs* renderArgs, Camera& whichCamera, bool selfAvatarOnly = false, bool billboard = false); - /// Stores the current modelview matrix as the untranslated view matrix to use for transforms and the supplied vector as - /// the view matrix translation. - void updateUntranslatedViewMatrix(const glm::vec3& viewMatrixTranslation = glm::vec3()); - -// const glm::mat4& getUntranslatedViewMatrix() const { return _untranslatedViewMatrix; } - - /// Loads a view matrix that incorporates the specified model translation without the precision issues that can - /// result from matrix multiplication at high translation magnitudes. - // void loadTranslatedViewMatrix(const glm::vec3& translation); - - // void getModelViewMatrix(glm::dmat4* modelViewMatrix); - // void getProjectionMatrix(glm::dmat4* projectionMatrix); - virtual const glm::vec3& getShadowDistances() const { return _shadowDistances; } /// Computes the off-axis frustum parameters for the view frustum, taking mirroring into account. @@ -470,8 +451,6 @@ private slots: private: void resetCameras(Camera& camera, const glm::uvec2& size); - // void updateProjectionMatrix(); - // void updateProjectionMatrix(Camera& camera, bool updateViewFrustum = true); void sendPingPackets(); @@ -502,7 +481,6 @@ private: glm::vec3 getSunDirection(); - void updateShadowMap(RenderArgs* renderArgs); void renderRearViewMirror(RenderArgs* renderArgs, const QRect& region, bool billboard = false); void setMenuShortcutsEnabled(bool enabled); @@ -561,11 +539,6 @@ private: Setting::Handle _scriptsLocationHandle; Setting::Handle _fieldOfView; - //Transform _viewTransform; - //glm::mat4 _untranslatedViewMatrix; - //glm::vec3 _viewMatrixTranslation; - //glm::mat4 _projectionMatrix; - float _scaleMirror; float _rotateMirror; float _raiseMirror; From ad1771c738e6cbba1d8b9da62e91aa4e4603e66b Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Mon, 20 Jul 2015 17:09:11 -0700 Subject: [PATCH 13/15] removing dead code --- interface/src/avatar/SkeletonModel.cpp | 5 ++--- interface/src/ui/ApplicationCompositor.cpp | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/interface/src/avatar/SkeletonModel.cpp b/interface/src/avatar/SkeletonModel.cpp index 1a1cace359..d92481494a 100644 --- a/interface/src/avatar/SkeletonModel.cpp +++ b/interface/src/avatar/SkeletonModel.cpp @@ -789,12 +789,11 @@ void SkeletonModel::renderBoundingCollisionShapes(gpu::Batch& batch, float alpha // so no need to render it return; } - // Application::getInstance()->loadTranslatedViewMatrix(_translation); // draw a blue sphere at the capsule endpoint glm::vec3 endPoint; _boundingShape.getEndPoint(endPoint); - endPoint = endPoint - _translation; + endPoint = endPoint + _translation; Transform transform = Transform(); transform.setTranslation(endPoint); batch.setModelTransform(transform); @@ -805,7 +804,7 @@ void SkeletonModel::renderBoundingCollisionShapes(gpu::Batch& batch, float alpha // draw a yellow sphere at the capsule startpoint glm::vec3 startPoint; _boundingShape.getStartPoint(startPoint); - startPoint = startPoint - _translation; + startPoint = startPoint + _translation; glm::vec3 axis = endPoint - startPoint; Transform axisTransform = Transform(); axisTransform.setTranslation(-axis); diff --git a/interface/src/ui/ApplicationCompositor.cpp b/interface/src/ui/ApplicationCompositor.cpp index 60f314cb7b..a48bb0ef1c 100644 --- a/interface/src/ui/ApplicationCompositor.cpp +++ b/interface/src/ui/ApplicationCompositor.cpp @@ -370,7 +370,6 @@ QPoint ApplicationCompositor::getPalmClickLocation(const PalmData *palm) const { } else { MyAvatar* myAvatar = DependencyManager::get()->getMyAvatar(); glm::mat4 projection; - // qApp->getProjectionMatrix(&projection); qApp->getDisplayViewFrustum()->evalProjectionMatrix(projection); glm::quat invOrientation = glm::inverse(myAvatar->getOrientation()); glm::vec3 eyePos = myAvatar->getDefaultEyePosition(); From 5bf85961d270386b69b3aadc37e791a5869d6b74 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Mon, 20 Jul 2015 17:13:02 -0700 Subject: [PATCH 14/15] removing dead code --- interface/src/Application.cpp | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index c2460e4e55..6edc49a08f 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1093,22 +1093,6 @@ void Application::resizeGL() { _glWidget->makeCurrent(); } -/* -void Application::updateProjectionMatrix() { - // _projectionMatrix = _myCamera.getProjection(); - loadViewFrustum(_myCamera, _viewFrustum); -// updateProjectionMatrix(_myCamera); -} -*/ -/* -void Application::updateProjectionMatrix(Camera& camera, bool updateViewFrustum) { - _projectionMatrix = camera.getProjection(); - // Tell our viewFrustum about this change, using the application camera - if (updateViewFrustum) { - loadViewFrustum(camera, _viewFrustum); - } -} -*/ bool Application::importSVOFromURL(const QString& urlString) { QUrl url(urlString); @@ -3459,16 +3443,11 @@ void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& regi bool updateViewFrustum = false; loadViewFrustum(_mirrorCamera, _viewFrustum); - // updateProjectionMatrix(_mirrorCamera, updateViewFrustum); + // render rear mirror view displaySide(renderArgs, _mirrorCamera, true, billboard); - //{ - // gpu::Batch batch; - // renderArgs->_viewport = originalViewport; - // batch.setViewportTransform(originalViewport); - // renderArgs->_context->render(batch); - //} + renderArgs->_viewport = originalViewport; } From 558f10640bf87e4f2dd1e44f7a732501b5cc046c Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 21 Jul 2015 08:30:33 -0700 Subject: [PATCH 15/15] coding standard fix --- interface/src/ui/ApplicationOverlay.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/ui/ApplicationOverlay.cpp b/interface/src/ui/ApplicationOverlay.cpp index 2c1b01fee1..87462e4c3e 100644 --- a/interface/src/ui/ApplicationOverlay.cpp +++ b/interface/src/ui/ApplicationOverlay.cpp @@ -32,8 +32,8 @@ const vec4 CONNECTION_STATUS_BORDER_COLOR{ 1.0f, 0.0f, 0.0f, 0.8f }; const float CONNECTION_STATUS_BORDER_LINE_WIDTH = 4.0f; -static const float ORTHO_NEAR_CLIP = -1000; -static const float ORTHO_FAR_CLIP = 1000; +static const float ORTHO_NEAR_CLIP = -1000.0f; +static const float ORTHO_FAR_CLIP = 1000.0f; ApplicationOverlay::ApplicationOverlay() {