mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 19:55:07 +02:00
Fix some more smart pointer
This commit is contained in:
parent
256c786e28
commit
052c3c987b
7 changed files with 62 additions and 62 deletions
|
@ -34,10 +34,10 @@
|
|||
const bool VERBOSE_HTTP_REQUEST_DEBUGGING = false;
|
||||
|
||||
AccountManager& AccountManager::getInstance(bool forceReset) {
|
||||
static std::unique_ptr<AccountManager> sharedInstance(new AccountManager());
|
||||
static auto sharedInstance = std::make_shared<AccountManager>();
|
||||
|
||||
if (forceReset) {
|
||||
sharedInstance.reset(new AccountManager());
|
||||
sharedInstance = std::make_shared<AccountManager>();
|
||||
}
|
||||
|
||||
return *sharedInstance;
|
||||
|
|
|
@ -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<gpu::State>();
|
||||
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<gpu::State>();
|
||||
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<model::Mesh>();
|
||||
|
||||
int slices = 32;
|
||||
int rings = 3;
|
||||
|
|
|
@ -918,7 +918,7 @@ bool Model::addToScene(std::shared_ptr<render::Scene> 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<MeshPartPayload::Payload>(renderData);
|
||||
renderPayload->addStatusGetters(statusGetters);
|
||||
pendingChanges.resetItem(item, renderPayload);
|
||||
_renderItems.insert(item, renderPayload);
|
||||
|
@ -928,7 +928,7 @@ bool Model::addToScene(std::shared_ptr<render::Scene> 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<MeshPartPayload::Payload>(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;
|
||||
|
|
|
@ -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<gpu::Query>());
|
||||
_timerQueries.push_back(std::make_shared<gpu::Query>());
|
||||
_timerQueries.push_back(std::make_shared<gpu::Query>());
|
||||
_currentTimerQueryIndex = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -759,7 +759,7 @@ DilatableNetworkTexture::DilatableNetworkTexture(const QUrl& url, const QByteArr
|
|||
QSharedPointer<Texture> DilatableNetworkTexture::getDilatedTexture(float dilation) {
|
||||
QSharedPointer<Texture> texture = _dilatedTextures.value(dilation);
|
||||
if (texture.isNull()) {
|
||||
texture = QSharedPointer<Texture>(new Texture());
|
||||
texture = QSharedPointer<Texture>::create();
|
||||
|
||||
if (!_image.isNull()) {
|
||||
QImage dilatedImage = _image;
|
||||
|
|
|
@ -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<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
|
||||
_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<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
|
||||
_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<gpu::Buffer>();
|
||||
}
|
||||
if (!_itemStatus) {
|
||||
_itemStatus.reset(new gpu::Buffer());
|
||||
_itemStatus = std::make_shared<gpu::Buffer>();;
|
||||
}
|
||||
|
||||
_itemBounds->resize((inItems.size() * sizeof(AABox)));
|
||||
|
@ -148,14 +148,14 @@ void DrawStatus::run(const SceneContextPointer& sceneContext, const RenderContex
|
|||
|
||||
AABox* itemAABox = reinterpret_cast<AABox*> (_itemBounds->editData());
|
||||
glm::ivec4* itemStatus = reinterpret_cast<glm::ivec4*> (_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());
|
||||
|
|
|
@ -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>();
|
||||
}
|
||||
_status->addGetter(getter);
|
||||
}
|
||||
|
||||
void Item::PayloadInterface::addStatusGetters(const Status::Getters& getters) {
|
||||
if (!_status) {
|
||||
_status.reset(new Status());
|
||||
_status = std::make_shared<Status>();
|
||||
}
|
||||
for (auto& g : getters) {
|
||||
_status->addGetter(g);
|
||||
|
|
Loading…
Reference in a new issue