mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 09:43:47 +02:00
getting rid of QSHaredPointer in favor of std::shared_ptr
This commit is contained in:
parent
fad623ae48
commit
ade404a74d
11 changed files with 49 additions and 30 deletions
|
@ -1687,7 +1687,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping,
|
|||
}
|
||||
} else if (object.name == "Material") {
|
||||
Material material = { glm::vec3(1.0f, 1.0f, 1.0f), glm::vec3(1.0f, 1.0f, 1.0f), glm::vec3(), 96.0f, 1.0f,
|
||||
QString(""), QSharedPointer<model::Material>(NULL)};
|
||||
QString(""), model::MaterialPointer(NULL)};
|
||||
foreach (const FBXNode& subobject, object.children) {
|
||||
bool properties = false;
|
||||
QByteArray propertyName;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
#include <QSharedPointer>
|
||||
#include <memory>
|
||||
#ifdef _DEBUG
|
||||
#include <QDebug>
|
||||
#endif
|
||||
|
@ -156,7 +156,7 @@ protected:
|
|||
friend class Backend;
|
||||
};
|
||||
|
||||
typedef QSharedPointer<Buffer> BufferPointer;
|
||||
typedef std::shared_ptr<Buffer> BufferPointer;
|
||||
typedef std::vector< BufferPointer > Buffers;
|
||||
|
||||
|
||||
|
@ -317,7 +317,7 @@ public:
|
|||
|
||||
template <typename T> const T& get() const {
|
||||
#if _DEBUG
|
||||
if (_buffer.isNull()) {
|
||||
if (!_buffer) {
|
||||
qDebug() << "Accessing null gpu::buffer!";
|
||||
}
|
||||
if (sizeof(T) > (_buffer->getSize() - _offset)) {
|
||||
|
@ -333,7 +333,7 @@ public:
|
|||
|
||||
template <typename T> T& edit() {
|
||||
#if _DEBUG
|
||||
if (_buffer.isNull()) {
|
||||
if (!_buffer) {
|
||||
qDebug() << "Accessing null gpu::buffer!";
|
||||
}
|
||||
if (sizeof(T) > (_buffer->getSize() - _offset)) {
|
||||
|
@ -350,7 +350,7 @@ public:
|
|||
template <typename T> const T& get(const Index index) const {
|
||||
Resource::Size elementOffset = index * sizeof(T) + _offset;
|
||||
#if _DEBUG
|
||||
if (_buffer.isNull()) {
|
||||
if (!_buffer) {
|
||||
qDebug() << "Accessing null gpu::buffer!";
|
||||
}
|
||||
if (sizeof(T) > (_buffer->getSize() - elementOffset)) {
|
||||
|
@ -366,7 +366,7 @@ public:
|
|||
template <typename T> T& edit(const Index index) const {
|
||||
Resource::Size elementOffset = index * sizeof(T) + _offset;
|
||||
#if _DEBUG
|
||||
if (_buffer.isNull()) {
|
||||
if (!_buffer) {
|
||||
qDebug() << "Accessing null gpu::buffer!";
|
||||
}
|
||||
if (sizeof(T) > (_buffer->getSize() - elementOffset)) {
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace gpu {
|
|||
class Shader {
|
||||
public:
|
||||
|
||||
typedef QSharedPointer< Shader > Pointer;
|
||||
typedef std::shared_ptr< Shader > Pointer;
|
||||
typedef std::vector< Pointer > Shaders;
|
||||
|
||||
class Source {
|
||||
|
|
|
@ -117,7 +117,7 @@ public:
|
|||
void evaluateCache();
|
||||
};
|
||||
|
||||
typedef QSharedPointer<Format> FormatPointer;
|
||||
typedef std::shared_ptr<Format> FormatPointer;
|
||||
};
|
||||
|
||||
typedef std::vector< Offset > Offsets;
|
||||
|
@ -143,7 +143,7 @@ protected:
|
|||
Offsets _offsets;
|
||||
Strides _strides;
|
||||
};
|
||||
typedef QSharedPointer<BufferStream> BufferStreamPointer;
|
||||
typedef std::shared_ptr<BufferStream> BufferStreamPointer;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ public:
|
|||
Element _format;
|
||||
bool _isGPULoaded;
|
||||
};
|
||||
typedef QSharedPointer< Pixels > PixelsPointer;
|
||||
typedef std::shared_ptr< Pixels > PixelsPointer;
|
||||
|
||||
class Storage {
|
||||
public:
|
||||
|
@ -303,7 +303,7 @@ protected:
|
|||
friend class Backend;
|
||||
};
|
||||
|
||||
typedef QSharedPointer<Texture> TexturePointer;
|
||||
typedef std::shared_ptr<Texture> TexturePointer;
|
||||
typedef std::vector< TexturePointer > Textures;
|
||||
|
||||
|
||||
|
@ -344,7 +344,7 @@ public:
|
|||
TextureView(const TextureView& view) = default;
|
||||
TextureView& operator=(const TextureView& view) = default;
|
||||
|
||||
explicit operator bool() const { return (_texture); }
|
||||
explicit operator bool() const { return bool(_texture); }
|
||||
bool operator !() const { return (!_texture); }
|
||||
};
|
||||
typedef std::vector<TextureView> TextureViews;
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
void setVertexBuffer(const BufferView& buffer);
|
||||
const BufferView& getVertexBuffer() const { return _vertexBuffer; }
|
||||
uint getNumVertices() const { return _vertexBuffer.getNumElements(); }
|
||||
bool hasVertexData() const { return !_vertexBuffer._buffer.isNull(); }
|
||||
bool hasVertexData() const { return !_vertexBuffer._buffer; }
|
||||
|
||||
// Attribute Buffers
|
||||
int getNumAttributes() const { return _attributeBuffers.size(); }
|
||||
|
@ -126,7 +126,7 @@ protected:
|
|||
void evalVertexFormat();
|
||||
|
||||
};
|
||||
typedef QSharedPointer< Mesh > MeshPointer;
|
||||
typedef std::shared_ptr< Mesh > MeshPointer;
|
||||
|
||||
|
||||
class Geometry {
|
||||
|
|
|
@ -282,7 +282,7 @@ protected:
|
|||
const Schema& getSchema() const { return _schemaBuffer.get<Schema>(); }
|
||||
Schema& editSchema() { return _schemaBuffer.edit<Schema>(); }
|
||||
};
|
||||
typedef QSharedPointer< Light > LightPointer;
|
||||
typedef std::shared_ptr< Light > LightPointer;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -19,7 +19,26 @@
|
|||
#include "gpu/Resource.h"
|
||||
#include "gpu/Texture.h"
|
||||
|
||||
#include <qurl.h>
|
||||
|
||||
namespace model {
|
||||
|
||||
// TextureStorage is a specialized version of the gpu::Texture::Storage
|
||||
// It adds the URL and the notion that it owns the gpu::Texture
|
||||
class LoadedTexture : public gpu::Texture::Storage {
|
||||
public:
|
||||
LoadedTexture(const QUrl& url);
|
||||
~LoadedTexture();
|
||||
|
||||
const QUrl& getUrl() const { return _url; }
|
||||
const gpu::TexturePointer& getGPUTexture() const { return _gpuTexture; }
|
||||
|
||||
protected:
|
||||
gpu::TexturePointer _gpuTexture;
|
||||
QUrl _url;
|
||||
};
|
||||
typedef std::shared_ptr< LoadedTexture > LoadedTexturePointer;
|
||||
|
||||
typedef gpu::BufferView UniformBufferView;
|
||||
typedef gpu::TextureView TextureView;
|
||||
|
||||
|
@ -102,7 +121,7 @@ protected:
|
|||
TextureMap _textureMap;
|
||||
|
||||
};
|
||||
typedef QSharedPointer< Material > MaterialPointer;
|
||||
typedef std::shared_ptr< Material > MaterialPointer;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ protected:
|
|||
|
||||
void updateScattering();
|
||||
};
|
||||
typedef QSharedPointer< Atmosphere > AtmospherePointer;
|
||||
typedef std::shared_ptr< Atmosphere > AtmospherePointer;
|
||||
|
||||
|
||||
class Skybox {
|
||||
|
@ -173,7 +173,7 @@ public:
|
|||
protected:
|
||||
gpu::TexturePointer _cubemap;
|
||||
};
|
||||
typedef QSharedPointer< Skybox > SkyboxPointer;
|
||||
typedef std::shared_ptr< Skybox > SkyboxPointer;
|
||||
|
||||
// Sun sky stage generates the rendering primitives to display a scene realistically
|
||||
// at the specified location and time around earth
|
||||
|
@ -244,7 +244,7 @@ protected:
|
|||
void updateGraphicsObject() const;
|
||||
};
|
||||
|
||||
typedef QSharedPointer< SunSkyStage > SunSkyStagePointer;
|
||||
typedef std::shared_ptr< SunSkyStage > SunSkyStagePointer;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ void GeometryCache::renderSphere(float radius, int slices, int stacks, const glm
|
|||
|| (!registered && !_sphereVertices.contains(radiusKey))) {
|
||||
|
||||
if (registered && _registeredSphereVertices.contains(id)) {
|
||||
_registeredSphereVertices[id].clear();
|
||||
_registeredSphereVertices[id].reset();
|
||||
#ifdef WANT_DEBUG
|
||||
qCDebug(renderutils) << "renderSphere()... RELEASING REGISTERED VERTICES BUFFER";
|
||||
#endif
|
||||
|
@ -133,7 +133,7 @@ void GeometryCache::renderSphere(float radius, int slices, int stacks, const glm
|
|||
|| (!registered && !_sphereIndices.contains(slicesStacksKey))) {
|
||||
|
||||
if (registered && _registeredSphereIndices.contains(id)) {
|
||||
_registeredSphereIndices[id].clear();
|
||||
_registeredSphereIndices[id].reset();
|
||||
#ifdef WANT_DEBUG
|
||||
qCDebug(renderutils) << "renderSphere()... RELEASING REGISTERED INDICES BUFFER";
|
||||
#endif
|
||||
|
@ -219,7 +219,7 @@ void GeometryCache::renderSphere(float radius, int slices, int stacks, const glm
|
|||
|| (!registered && !_sphereColors.contains(colorKey))) {
|
||||
|
||||
if (registered && _registeredSphereColors.contains(id)) {
|
||||
_registeredSphereColors[id].clear();
|
||||
_registeredSphereColors[id].reset();
|
||||
#ifdef WANT_DEBUG
|
||||
qCDebug(renderutils) << "renderSphere()... RELEASING REGISTERED COLORS BUFFER";
|
||||
#endif
|
||||
|
@ -1581,10 +1581,10 @@ GeometryCache::BatchItemDetails::~BatchItemDetails() {
|
|||
|
||||
void GeometryCache::BatchItemDetails::clear() {
|
||||
isCreated = false;
|
||||
verticesBuffer.clear();
|
||||
colorBuffer.clear();
|
||||
streamFormat.clear();
|
||||
stream.clear();
|
||||
verticesBuffer.reset();
|
||||
colorBuffer.reset();
|
||||
streamFormat.reset();
|
||||
stream.reset();
|
||||
}
|
||||
|
||||
void GeometryCache::renderLine(const glm::vec3& p1, const glm::vec3& p2,
|
||||
|
|
|
@ -90,7 +90,7 @@ const int permutation[256] =
|
|||
#define USE_CHRIS_NOISE 1
|
||||
|
||||
const gpu::TexturePointer& TextureCache::getPermutationNormalTexture() {
|
||||
if (_permutationNormalTexture.isNull()) {
|
||||
if (_permutationNormalTexture) {
|
||||
|
||||
// the first line consists of random permutation offsets
|
||||
unsigned char data[256 * 2 * 3];
|
||||
|
@ -134,7 +134,7 @@ static void loadSingleColorTexture(const unsigned char* color) {
|
|||
*/
|
||||
|
||||
const gpu::TexturePointer& TextureCache::getWhiteTexture() {
|
||||
if (_whiteTexture.isNull()) {
|
||||
if (_whiteTexture) {
|
||||
_whiteTexture = gpu::TexturePointer(gpu::Texture::create2D(gpu::Element(gpu::VEC4, gpu::UINT8, gpu::RGBA), 1, 1));
|
||||
_whiteTexture->assignStoredMip(0, _whiteTexture->getTexelFormat(), sizeof(OPAQUE_WHITE), OPAQUE_WHITE);
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ const gpu::TexturePointer& TextureCache::getWhiteTexture() {
|
|||
}
|
||||
|
||||
const gpu::TexturePointer& TextureCache::getBlueTexture() {
|
||||
if (_blueTexture.isNull()) {
|
||||
if (_blueTexture) {
|
||||
_blueTexture = gpu::TexturePointer(gpu::Texture::create2D(gpu::Element(gpu::VEC4, gpu::UINT8, gpu::RGBA), 1, 1));
|
||||
_blueTexture->assignStoredMip(0, _blueTexture->getTexelFormat(), sizeof(OPAQUE_BLUE), OPAQUE_BLUE);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue