mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 22:10:25 +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;
|
const bool VERBOSE_HTTP_REQUEST_DEBUGGING = false;
|
||||||
|
|
||||||
AccountManager& AccountManager::getInstance(bool forceReset) {
|
AccountManager& AccountManager::getInstance(bool forceReset) {
|
||||||
static std::unique_ptr<AccountManager> sharedInstance(new AccountManager());
|
static auto sharedInstance = std::make_shared<AccountManager>();
|
||||||
|
|
||||||
if (forceReset) {
|
if (forceReset) {
|
||||||
sharedInstance.reset(new AccountManager());
|
sharedInstance = std::make_shared<AccountManager>();
|
||||||
}
|
}
|
||||||
|
|
||||||
return *sharedInstance;
|
return *sharedInstance;
|
||||||
|
|
|
@ -117,7 +117,7 @@ void DeferredLightingEffect::init(AbstractViewStateInterface* viewState) {
|
||||||
//auto PSBlit = gpu::StandardShaderLib::getDrawTexturePS();
|
//auto PSBlit = gpu::StandardShaderLib::getDrawTexturePS();
|
||||||
auto blitProgram = gpu::StandardShaderLib::getProgram(gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS, gpu::StandardShaderLib::getDrawTexturePS);
|
auto blitProgram = gpu::StandardShaderLib::getProgram(gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS, gpu::StandardShaderLib::getDrawTexturePS);
|
||||||
gpu::Shader::makeProgram(*blitProgram);
|
gpu::Shader::makeProgram(*blitProgram);
|
||||||
gpu::StatePointer blitState = gpu::StatePointer(new gpu::State());
|
auto blitState = std::make_shared<gpu::State>();
|
||||||
blitState->setBlendFunction(true,
|
blitState->setBlendFunction(true,
|
||||||
gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
|
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);
|
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");
|
locations.atmosphereBufferUnit = program->getUniforms().findLocation("atmosphereBufferUnit");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
auto state = std::make_shared<gpu::State>();
|
||||||
if (lightVolume) {
|
if (lightVolume) {
|
||||||
state->setCullMode(gpu::State::CULL_BACK);
|
state->setCullMode(gpu::State::CULL_BACK);
|
||||||
|
|
||||||
|
@ -657,7 +657,7 @@ void DeferredLightingEffect::setGlobalSkybox(const model::SkyboxPointer& skybox)
|
||||||
|
|
||||||
model::MeshPointer DeferredLightingEffect::getSpotLightMesh() {
|
model::MeshPointer DeferredLightingEffect::getSpotLightMesh() {
|
||||||
if (!_spotLightMesh) {
|
if (!_spotLightMesh) {
|
||||||
_spotLightMesh.reset(new model::Mesh());
|
_spotLightMesh = std::make_shared<model::Mesh>();
|
||||||
|
|
||||||
int slices = 32;
|
int slices = 32;
|
||||||
int rings = 3;
|
int rings = 3;
|
||||||
|
|
|
@ -918,7 +918,7 @@ bool Model::addToScene(std::shared_ptr<render::Scene> scene, render::PendingChan
|
||||||
foreach (auto renderItem, _transparentRenderItems) {
|
foreach (auto renderItem, _transparentRenderItems) {
|
||||||
auto item = scene->allocateID();
|
auto item = scene->allocateID();
|
||||||
auto renderData = MeshPartPayload::Pointer(renderItem);
|
auto renderData = MeshPartPayload::Pointer(renderItem);
|
||||||
auto renderPayload = render::PayloadPointer(new MeshPartPayload::Payload(renderData));
|
auto renderPayload = std::make_shared<MeshPartPayload::Payload>(renderData);
|
||||||
renderPayload->addStatusGetters(statusGetters);
|
renderPayload->addStatusGetters(statusGetters);
|
||||||
pendingChanges.resetItem(item, renderPayload);
|
pendingChanges.resetItem(item, renderPayload);
|
||||||
_renderItems.insert(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) {
|
foreach (auto renderItem, _opaqueRenderItems) {
|
||||||
auto item = scene->allocateID();
|
auto item = scene->allocateID();
|
||||||
auto renderData = MeshPartPayload::Pointer(renderItem);
|
auto renderData = MeshPartPayload::Pointer(renderItem);
|
||||||
auto renderPayload = render::PayloadPointer(new MeshPartPayload::Payload(renderData));
|
auto renderPayload = std::make_shared<MeshPartPayload::Payload>(renderData);
|
||||||
renderPayload->addStatusGetters(statusGetters);
|
renderPayload->addStatusGetters(statusGetters);
|
||||||
pendingChanges.resetItem(item, renderPayload);
|
pendingChanges.resetItem(item, renderPayload);
|
||||||
_renderItems.insert(item, renderPayload);
|
_renderItems.insert(item, renderPayload);
|
||||||
|
@ -1260,7 +1260,7 @@ uint qHash(const WeakAnimationHandlePointer& handle, uint seed) {
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimationHandlePointer Model::createAnimationHandle() {
|
AnimationHandlePointer Model::createAnimationHandle() {
|
||||||
AnimationHandlePointer handle(new AnimationHandle(this));
|
auto handle = AnimationHandlePointer::create(this);
|
||||||
handle->_self = handle;
|
handle->_self = handle;
|
||||||
_animationHandles.insert(handle);
|
_animationHandles.insert(handle);
|
||||||
return handle;
|
return handle;
|
||||||
|
|
|
@ -78,9 +78,9 @@ RenderDeferredTask::RenderDeferredTask() : Task() {
|
||||||
_jobs.push_back(Job(new ResetGLState::JobModel()));
|
_jobs.push_back(Job(new ResetGLState::JobModel()));
|
||||||
|
|
||||||
// Give ourselves 3 frmaes of timer queries
|
// Give ourselves 3 frmaes of timer queries
|
||||||
_timerQueries.push_back(gpu::QueryPointer(new gpu::Query()));
|
_timerQueries.push_back(std::make_shared<gpu::Query>());
|
||||||
_timerQueries.push_back(gpu::QueryPointer(new gpu::Query()));
|
_timerQueries.push_back(std::make_shared<gpu::Query>());
|
||||||
_timerQueries.push_back(gpu::QueryPointer(new gpu::Query()));
|
_timerQueries.push_back(std::make_shared<gpu::Query>());
|
||||||
_currentTimerQueryIndex = 0;
|
_currentTimerQueryIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -759,7 +759,7 @@ DilatableNetworkTexture::DilatableNetworkTexture(const QUrl& url, const QByteArr
|
||||||
QSharedPointer<Texture> DilatableNetworkTexture::getDilatedTexture(float dilation) {
|
QSharedPointer<Texture> DilatableNetworkTexture::getDilatedTexture(float dilation) {
|
||||||
QSharedPointer<Texture> texture = _dilatedTextures.value(dilation);
|
QSharedPointer<Texture> texture = _dilatedTextures.value(dilation);
|
||||||
if (texture.isNull()) {
|
if (texture.isNull()) {
|
||||||
texture = QSharedPointer<Texture>(new Texture());
|
texture = QSharedPointer<Texture>::create();
|
||||||
|
|
||||||
if (!_image.isNull()) {
|
if (!_image.isNull()) {
|
||||||
QImage dilatedImage = _image;
|
QImage dilatedImage = _image;
|
||||||
|
|
|
@ -34,27 +34,27 @@ using namespace render;
|
||||||
|
|
||||||
|
|
||||||
const gpu::PipelinePointer& DrawStatus::getDrawItemBoundsPipeline() {
|
const gpu::PipelinePointer& DrawStatus::getDrawItemBoundsPipeline() {
|
||||||
if (!_drawItemBoundsPipeline) {
|
if (!_drawItemBoundsPipeline) {
|
||||||
auto vs = gpu::ShaderPointer(gpu::Shader::createVertex(std::string(drawItemBounds_vert)));
|
auto vs = gpu::ShaderPointer(gpu::Shader::createVertex(std::string(drawItemBounds_vert)));
|
||||||
auto ps = gpu::ShaderPointer(gpu::Shader::createPixel(std::string(drawItemBounds_frag)));
|
auto ps = gpu::ShaderPointer(gpu::Shader::createPixel(std::string(drawItemBounds_frag)));
|
||||||
gpu::ShaderPointer program = gpu::ShaderPointer(gpu::Shader::createProgram(vs, ps));
|
gpu::ShaderPointer program = gpu::ShaderPointer(gpu::Shader::createProgram(vs, ps));
|
||||||
|
|
||||||
gpu::Shader::BindingSet slotBindings;
|
gpu::Shader::BindingSet slotBindings;
|
||||||
gpu::Shader::makeProgram(*program, slotBindings);
|
gpu::Shader::makeProgram(*program, slotBindings);
|
||||||
|
|
||||||
_drawItemBoundPosLoc = program->getUniforms().findLocation("inBoundPos");
|
_drawItemBoundPosLoc = program->getUniforms().findLocation("inBoundPos");
|
||||||
_drawItemBoundDimLoc = program->getUniforms().findLocation("inBoundDim");
|
_drawItemBoundDimLoc = program->getUniforms().findLocation("inBoundDim");
|
||||||
|
|
||||||
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
auto state = std::make_shared<gpu::State>();
|
||||||
|
|
||||||
state->setDepthTest(true, false, gpu::LESS_EQUAL);
|
state->setDepthTest(true, false, gpu::LESS_EQUAL);
|
||||||
|
|
||||||
// Blend on transparent
|
// Blend on transparent
|
||||||
state->setBlendFunction(true,
|
state->setBlendFunction(true,
|
||||||
gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
|
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);
|
gpu::State::DEST_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ZERO);
|
||||||
|
|
||||||
// Good to go add the brand new pipeline
|
// Good to go add the brand new pipeline
|
||||||
_drawItemBoundsPipeline.reset(gpu::Pipeline::create(program, state));
|
_drawItemBoundsPipeline.reset(gpu::Pipeline::create(program, state));
|
||||||
}
|
}
|
||||||
return _drawItemBoundsPipeline;
|
return _drawItemBoundsPipeline;
|
||||||
|
@ -62,27 +62,27 @@ const gpu::PipelinePointer& DrawStatus::getDrawItemBoundsPipeline() {
|
||||||
|
|
||||||
const gpu::PipelinePointer& DrawStatus::getDrawItemStatusPipeline() {
|
const gpu::PipelinePointer& DrawStatus::getDrawItemStatusPipeline() {
|
||||||
if (!_drawItemStatusPipeline) {
|
if (!_drawItemStatusPipeline) {
|
||||||
auto vs = gpu::ShaderPointer(gpu::Shader::createVertex(std::string(drawItemStatus_vert)));
|
auto vs = gpu::ShaderPointer(gpu::Shader::createVertex(std::string(drawItemStatus_vert)));
|
||||||
auto ps = gpu::ShaderPointer(gpu::Shader::createPixel(std::string(drawItemStatus_frag)));
|
auto ps = gpu::ShaderPointer(gpu::Shader::createPixel(std::string(drawItemStatus_frag)));
|
||||||
gpu::ShaderPointer program = gpu::ShaderPointer(gpu::Shader::createProgram(vs, ps));
|
gpu::ShaderPointer program = gpu::ShaderPointer(gpu::Shader::createProgram(vs, ps));
|
||||||
|
|
||||||
gpu::Shader::BindingSet slotBindings;
|
gpu::Shader::BindingSet slotBindings;
|
||||||
gpu::Shader::makeProgram(*program, slotBindings);
|
gpu::Shader::makeProgram(*program, slotBindings);
|
||||||
|
|
||||||
_drawItemStatusPosLoc = program->getUniforms().findLocation("inBoundPos");
|
_drawItemStatusPosLoc = program->getUniforms().findLocation("inBoundPos");
|
||||||
_drawItemStatusDimLoc = program->getUniforms().findLocation("inBoundDim");
|
_drawItemStatusDimLoc = program->getUniforms().findLocation("inBoundDim");
|
||||||
_drawItemStatusValueLoc = program->getUniforms().findLocation("inStatus");
|
_drawItemStatusValueLoc = program->getUniforms().findLocation("inStatus");
|
||||||
|
|
||||||
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
auto state = std::make_shared<gpu::State>();
|
||||||
|
|
||||||
state->setDepthTest(false, false, gpu::LESS_EQUAL);
|
state->setDepthTest(false, false, gpu::LESS_EQUAL);
|
||||||
|
|
||||||
// Blend on transparent
|
// Blend on transparent
|
||||||
state->setBlendFunction(true,
|
state->setBlendFunction(true,
|
||||||
gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
|
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);
|
gpu::State::DEST_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ZERO);
|
||||||
|
|
||||||
// Good to go add the brand new pipeline
|
// Good to go add the brand new pipeline
|
||||||
_drawItemStatusPipeline.reset(gpu::Pipeline::create(program, state));
|
_drawItemStatusPipeline.reset(gpu::Pipeline::create(program, state));
|
||||||
}
|
}
|
||||||
return _drawItemStatusPipeline;
|
return _drawItemStatusPipeline;
|
||||||
|
@ -98,10 +98,10 @@ void DrawStatus::run(const SceneContextPointer& sceneContext, const RenderContex
|
||||||
int nbItems = 0;
|
int nbItems = 0;
|
||||||
{
|
{
|
||||||
if (!_itemBounds) {
|
if (!_itemBounds) {
|
||||||
_itemBounds.reset(new gpu::Buffer());
|
_itemBounds = std::make_shared<gpu::Buffer>();
|
||||||
}
|
}
|
||||||
if (!_itemStatus) {
|
if (!_itemStatus) {
|
||||||
_itemStatus.reset(new gpu::Buffer());
|
_itemStatus = std::make_shared<gpu::Buffer>();;
|
||||||
}
|
}
|
||||||
|
|
||||||
_itemBounds->resize((inItems.size() * sizeof(AABox)));
|
_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());
|
AABox* itemAABox = reinterpret_cast<AABox*> (_itemBounds->editData());
|
||||||
glm::ivec4* itemStatus = reinterpret_cast<glm::ivec4*> (_itemStatus->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++) {
|
for (int i = 0; i < nbItems; i++) {
|
||||||
batch._glUniform3fv(_drawItemBoundPosLoc, 1, (const GLfloat*) (itemAABox + i));
|
batch._glUniform3fv(_drawItemBoundPosLoc, 1, (const GLfloat*) (itemAABox + i));
|
||||||
batch._glUniform3fv(_drawItemBoundDimLoc, 1, ((const GLfloat*) (itemAABox + i)) + VEC3_ADRESS_OFFSET);
|
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());
|
batch.setPipeline(getDrawItemStatusPipeline());
|
||||||
|
|
|
@ -87,14 +87,14 @@ void Item::Status::getPackedValues(glm::ivec4& values) const {
|
||||||
|
|
||||||
void Item::PayloadInterface::addStatusGetter(const Status::Getter& getter) {
|
void Item::PayloadInterface::addStatusGetter(const Status::Getter& getter) {
|
||||||
if (!_status) {
|
if (!_status) {
|
||||||
_status.reset(new Status());
|
_status = std::make_shared<Status>();
|
||||||
}
|
}
|
||||||
_status->addGetter(getter);
|
_status->addGetter(getter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Item::PayloadInterface::addStatusGetters(const Status::Getters& getters) {
|
void Item::PayloadInterface::addStatusGetters(const Status::Getters& getters) {
|
||||||
if (!_status) {
|
if (!_status) {
|
||||||
_status.reset(new Status());
|
_status = std::make_shared<Status>();
|
||||||
}
|
}
|
||||||
for (auto& g : getters) {
|
for (auto& g : getters) {
|
||||||
_status->addGetter(g);
|
_status->addGetter(g);
|
||||||
|
|
Loading…
Reference in a new issue