Преглед изворни кода

Refactored RID/RID_Owner to always use O(1) allocation.

* Implements a growing chunked allocator
* Removed redudant methods get and getptr, only getornull is supported now.
Juan Linietsky пре 6 година
родитељ
комит
4f163972bb
47 измењених фајлова са 1129 додато и 1017 уклоњено
  1. 0 41
      core/rid.cpp
  2. 12 139
      core/rid.h
  3. 3 0
      core/rid_owner.cpp
  4. 266 0
      core/rid_owner.h
  5. 9 8
      drivers/dummy/rasterizer_dummy.h
  6. 3 3
      drivers/gles2/rasterizer_canvas_gles2.cpp
  7. 1 1
      drivers/gles2/rasterizer_gles2.cpp
  8. 13 13
      drivers/gles2/rasterizer_scene_gles2.cpp
  9. 8 8
      drivers/gles2/rasterizer_scene_gles2.h
  10. 50 50
      drivers/gles2/rasterizer_storage_gles2.cpp
  11. 24 23
      drivers/gles2/rasterizer_storage_gles2.h
  12. 7 5
      drivers/gles3/rasterizer_canvas_gles3.cpp
  13. 2 2
      drivers/gles3/rasterizer_canvas_gles3.h
  14. 1 1
      drivers/gles3/rasterizer_gles3.cpp
  15. 39 39
      drivers/gles3/rasterizer_scene_gles3.cpp
  16. 12 12
      drivers/gles3/rasterizer_scene_gles3.h
  17. 77 77
      drivers/gles3/rasterizer_storage_gles3.cpp
  18. 29 27
      drivers/gles3/rasterizer_storage_gles3.h
  19. 0 1
      main/main.cpp
  20. 140 140
      modules/bullet/bullet_physics_server.cpp
  21. 13 13
      modules/bullet/bullet_physics_server.h
  22. 1 1
      modules/bullet/rid_bullet.h
  23. 4 4
      modules/bullet/space_bullet.cpp
  24. 29 29
      modules/gdnavigation/gd_navigation_server.cpp
  25. 5 3
      modules/gdnavigation/gd_navigation_server.h
  26. 1 1
      modules/gdnavigation/nav_rid.h
  27. 1 1
      scene/animation/skeleton_ik.h
  28. 1 1
      servers/physics/constraint_sw.h
  29. 120 120
      servers/physics/physics_server_sw.cpp
  30. 6 5
      servers/physics/physics_server_sw.h
  31. 2 2
      servers/physics/shape_sw.h
  32. 4 4
      servers/physics/space_sw.cpp
  33. 1 1
      servers/physics/space_sw.h
  34. 1 1
      servers/physics_2d/body_2d_sw.cpp
  35. 1 1
      servers/physics_2d/constraint_2d_sw.h
  36. 123 123
      servers/physics_2d/physics_2d_server_sw.cpp
  37. 6 5
      servers/physics_2d/physics_2d_server_sw.h
  38. 2 2
      servers/physics_2d/shape_2d_sw.h
  39. 4 4
      servers/physics_2d/space_2d_sw.cpp
  40. 1 1
      servers/physics_2d/space_2d_sw.h
  41. 4 4
      servers/visual/rasterizer.h
  42. 52 52
      servers/visual/visual_server_canvas.cpp
  43. 6 6
      servers/visual/visual_server_canvas.h
  44. 34 34
      servers/visual/visual_server_scene.cpp
  45. 6 5
      servers/visual/visual_server_scene.h
  46. 1 1
      servers/visual/visual_server_viewport.cpp
  47. 4 3
      servers/visual/visual_server_viewport.h

+ 0 - 41
core/rid.cpp

@@ -1,41 +0,0 @@
-/*************************************************************************/
-/*  rid.cpp                                                              */
-/*************************************************************************/
-/*                       This file is part of:                           */
-/*                           GODOT ENGINE                                */
-/*                      https://godotengine.org                          */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur.                 */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md).   */
-/*                                                                       */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the       */
-/* "Software"), to deal in the Software without restriction, including   */
-/* without limitation the rights to use, copy, modify, merge, publish,   */
-/* distribute, sublicense, and/or sell copies of the Software, and to    */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions:                                             */
-/*                                                                       */
-/* The above copyright notice and this permission notice shall be        */
-/* included in all copies or substantial portions of the Software.       */
-/*                                                                       */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
-/*************************************************************************/
-
-#include "rid.h"
-
-RID_Data::~RID_Data() {
-}
-
-SafeRefCount RID_OwnerBase::refcount;
-
-void RID_OwnerBase::init_rid() {
-
-	refcount.init();
-}

+ 12 - 139
core/rid.h

@@ -32,172 +32,45 @@
 #define RID_H
 #define RID_H
 
 
 #include "core/list.h"
 #include "core/list.h"
+#include "core/oa_hash_map.h"
 #include "core/os/memory.h"
 #include "core/os/memory.h"
 #include "core/safe_refcount.h"
 #include "core/safe_refcount.h"
 #include "core/set.h"
 #include "core/set.h"
 #include "core/typedefs.h"
 #include "core/typedefs.h"
 
 
-class RID_OwnerBase;
-
-class RID_Data {
-
-	friend class RID_OwnerBase;
-
-#ifndef DEBUG_ENABLED
-	RID_OwnerBase *_owner;
-#endif
-	uint32_t _id;
-
-public:
-	_FORCE_INLINE_ uint32_t get_id() const { return _id; }
-
-	virtual ~RID_Data();
-};
+class RID_AllocBase;
 
 
 class RID {
 class RID {
-	friend class RID_OwnerBase;
-
-	mutable RID_Data *_data;
+	friend class RID_AllocBase;
+	uint64_t _id;
 
 
 public:
 public:
-	_FORCE_INLINE_ RID_Data *get_data() const { return _data; }
-
 	_FORCE_INLINE_ bool operator==(const RID &p_rid) const {
 	_FORCE_INLINE_ bool operator==(const RID &p_rid) const {
 
 
-		return _data == p_rid._data;
+		return _id == p_rid._id;
 	}
 	}
 	_FORCE_INLINE_ bool operator<(const RID &p_rid) const {
 	_FORCE_INLINE_ bool operator<(const RID &p_rid) const {
 
 
-		return _data < p_rid._data;
+		return _id < p_rid._id;
 	}
 	}
 	_FORCE_INLINE_ bool operator<=(const RID &p_rid) const {
 	_FORCE_INLINE_ bool operator<=(const RID &p_rid) const {
 
 
-		return _data <= p_rid._data;
+		return _id <= p_rid._id;
 	}
 	}
 	_FORCE_INLINE_ bool operator>(const RID &p_rid) const {
 	_FORCE_INLINE_ bool operator>(const RID &p_rid) const {
 
 
-		return _data > p_rid._data;
+		return _id > p_rid._id;
 	}
 	}
 	_FORCE_INLINE_ bool operator!=(const RID &p_rid) const {
 	_FORCE_INLINE_ bool operator!=(const RID &p_rid) const {
 
 
-		return _data != p_rid._data;
+		return _id != p_rid._id;
 	}
 	}
-	_FORCE_INLINE_ bool is_valid() const { return _data != NULL; }
+	_FORCE_INLINE_ bool is_valid() const { return _id != 0; }
 
 
-	_FORCE_INLINE_ uint32_t get_id() const { return _data ? _data->get_id() : 0; }
+	_FORCE_INLINE_ uint64_t get_id() const { return _id; }
 
 
 	_FORCE_INLINE_ RID() {
 	_FORCE_INLINE_ RID() {
-		_data = NULL;
-	}
-};
-
-class RID_OwnerBase {
-protected:
-	static SafeRefCount refcount;
-	_FORCE_INLINE_ void _set_data(RID &p_rid, RID_Data *p_data) {
-		p_rid._data = p_data;
-		refcount.ref();
-		p_data->_id = refcount.get();
-#ifndef DEBUG_ENABLED
-		p_data->_owner = this;
-#endif
-	}
-
-#ifndef DEBUG_ENABLED
-
-	_FORCE_INLINE_ bool _is_owner(const RID &p_rid) const {
-
-		return this == p_rid._data->_owner;
-	}
-
-	_FORCE_INLINE_ void _remove_owner(RID &p_rid) {
-
-		p_rid._data->_owner = NULL;
-	}
-#endif
-
-public:
-	virtual void get_owned_list(List<RID> *p_owned) = 0;
-
-	static void init_rid();
-	virtual ~RID_OwnerBase() {}
-};
-
-template <class T>
-class RID_Owner : public RID_OwnerBase {
-public:
-#ifdef DEBUG_ENABLED
-	mutable Set<RID_Data *> id_map;
-#endif
-public:
-	_FORCE_INLINE_ RID make_rid(T *p_data) {
-
-		RID rid;
-		_set_data(rid, p_data);
-
-#ifdef DEBUG_ENABLED
-		id_map.insert(p_data);
-#endif
-
-		return rid;
-	}
-
-	_FORCE_INLINE_ T *get(const RID &p_rid) {
-
-#ifdef DEBUG_ENABLED
-
-		ERR_FAIL_COND_V(!p_rid.is_valid(), NULL);
-		ERR_FAIL_COND_V(!id_map.has(p_rid.get_data()), NULL);
-#endif
-		return static_cast<T *>(p_rid.get_data());
-	}
-
-	_FORCE_INLINE_ T *getornull(const RID &p_rid) {
-
-#ifdef DEBUG_ENABLED
-
-		if (p_rid.get_data()) {
-			ERR_FAIL_COND_V(!id_map.has(p_rid.get_data()), NULL);
-		}
-#endif
-		return static_cast<T *>(p_rid.get_data());
-	}
-
-	_FORCE_INLINE_ T *getptr(const RID &p_rid) {
-
-		return static_cast<T *>(p_rid.get_data());
-	}
-
-	_FORCE_INLINE_ bool owns(const RID &p_rid) const {
-
-		if (p_rid.get_data() == NULL)
-			return false;
-#ifdef DEBUG_ENABLED
-		return id_map.has(p_rid.get_data());
-#else
-		return _is_owner(p_rid);
-#endif
-	}
-
-	void free(RID p_rid) {
-
-#ifdef DEBUG_ENABLED
-		id_map.erase(p_rid.get_data());
-#else
-		_remove_owner(p_rid);
-#endif
-	}
-
-	void get_owned_list(List<RID> *p_owned) {
-
-#ifdef DEBUG_ENABLED
-
-		for (typename Set<RID_Data *>::Element *E = id_map.front(); E; E = E->next()) {
-			RID r;
-			_set_data(r, static_cast<T *>(E->get()));
-			p_owned->push_back(r);
-		}
-#endif
+		_id = 0;
 	}
 	}
 };
 };
 
 

+ 3 - 0
core/rid_owner.cpp

@@ -0,0 +1,3 @@
+#include "rid_owner.h"
+
+volatile uint64_t RID_AllocBase::base_id = 1;

+ 266 - 0
core/rid_owner.h

@@ -0,0 +1,266 @@
+#ifndef RID_OWNER_H
+#define RID_OWNER_H
+
+#include "core/print_string.h"
+#include "core/rid.h"
+
+class RID_AllocBase {
+
+	static volatile uint64_t base_id;
+
+protected:
+	static RID _make_from_id(uint64_t p_id) {
+		RID rid;
+		rid._id = p_id;
+		return rid;
+	}
+
+	static uint64_t _gen_id() {
+		return atomic_increment(&base_id);
+	}
+
+	static RID _gen_rid() {
+		return _make_from_id(_gen_id());
+	}
+
+public:
+	virtual ~RID_AllocBase() {}
+};
+
+template <class T>
+class RID_Alloc : public RID_AllocBase {
+
+	T **chunks;
+	uint32_t **free_list_chunks;
+	uint32_t **validator_chunks;
+
+	uint32_t elements_in_chunk;
+	uint32_t max_alloc;
+	uint32_t alloc_count;
+
+	const char *description;
+
+public:
+	RID make_rid(const T &p_value) {
+
+		if (alloc_count == max_alloc) {
+			//allocate a new chunk
+			uint32_t chunk_count = alloc_count == 0 ? 0 : (max_alloc / elements_in_chunk + 1);
+
+			//grow chunks
+			chunks = (T **)memrealloc(chunks, sizeof(T *) * (chunk_count + 1));
+			chunks[chunk_count] = (T *)memalloc(sizeof(T) * elements_in_chunk); //but don't initialize
+
+			//grow validators
+			validator_chunks = (uint32_t **)memrealloc(validator_chunks, sizeof(uint32_t *) * (chunk_count + 1));
+			validator_chunks[chunk_count] = (uint32_t *)memalloc(sizeof(uint32_t) * elements_in_chunk);
+			//grow free lists
+			free_list_chunks = (uint32_t **)memrealloc(free_list_chunks, sizeof(uint32_t *) * (chunk_count + 1));
+			free_list_chunks[chunk_count] = (uint32_t *)memalloc(sizeof(uint32_t) * elements_in_chunk);
+
+			//initialize
+			for (uint32_t i = 0; i < elements_in_chunk; i++) {
+				//dont initialize chunk
+				validator_chunks[chunk_count][i] = 0xFFFFFFFF;
+				free_list_chunks[chunk_count][i] = alloc_count + i;
+			}
+
+			max_alloc += elements_in_chunk;
+		}
+
+		uint32_t free_index = free_list_chunks[alloc_count / elements_in_chunk][alloc_count % elements_in_chunk];
+
+		uint32_t free_chunk = free_index / elements_in_chunk;
+		uint32_t free_element = free_index % elements_in_chunk;
+
+		T *ptr = &chunks[free_chunk][free_element];
+		memnew_placement(ptr, T(p_value));
+
+		uint32_t validator = (uint32_t)(_gen_id() % 0xFFFFFFFF);
+		uint64_t id = validator;
+		id <<= 32;
+		id |= free_index;
+
+		validator_chunks[free_chunk][free_element] = validator;
+		alloc_count++;
+
+		return _make_from_id(id);
+	}
+
+	_FORCE_INLINE_ T *getornull(const RID &p_rid) {
+
+		uint64_t id = p_rid.get_id();
+		uint32_t idx = uint32_t(id & 0xFFFFFFFF);
+		if (unlikely(idx >= alloc_count)) {
+			return NULL;
+		}
+
+		uint32_t idx_chunk = idx / elements_in_chunk;
+		uint32_t idx_element = idx % elements_in_chunk;
+
+		uint32_t validator = uint32_t(id >> 32);
+		if (validator_chunks[idx_chunk][idx_element] != validator) {
+			return NULL;
+		}
+
+		return &chunks[idx_chunk][idx_element];
+	}
+
+	_FORCE_INLINE_ bool owns(const RID &p_rid) {
+
+		uint64_t id = p_rid.get_id();
+		uint32_t idx = uint32_t(id & 0xFFFFFFFF);
+		if (unlikely(idx >= alloc_count)) {
+			return false;
+		}
+
+		uint32_t idx_chunk = idx / elements_in_chunk;
+		uint32_t idx_element = idx % elements_in_chunk;
+
+		uint32_t validator = uint32_t(id >> 32);
+		return validator_chunks[idx_chunk][idx_element] == validator;
+	}
+
+	_FORCE_INLINE_ void free(const RID &p_rid) {
+
+		uint64_t id = p_rid.get_id();
+		uint32_t idx = uint32_t(id & 0xFFFFFFFF);
+		if (unlikely(idx >= alloc_count)) {
+			return;
+		}
+
+		uint32_t idx_chunk = idx / elements_in_chunk;
+		uint32_t idx_element = idx % elements_in_chunk;
+
+		uint32_t validator = uint32_t(id >> 32);
+		if (validator_chunks[idx_chunk][idx_element] != validator) {
+			return;
+		}
+
+		chunks[idx_chunk][idx_element].~T();
+		validator_chunks[idx_chunk][idx_element] = 0xFFFFFFFF; // go invalid
+
+		free_list_chunks[alloc_count / elements_in_chunk][alloc_count % elements_in_chunk] = idx;
+		alloc_count--;
+	}
+
+	void get_owned_list(List<RID> *p_owned) {
+		for (size_t i = 0; i < alloc_count; i++) {
+			uint64_t idx = free_list_chunks[i / elements_in_chunk][i % elements_in_chunk];
+			uint64_t validator = validator_chunks[idx / elements_in_chunk][idx % elements_in_chunk];
+			p_owned->push_back(_make_from_id((validator << 32) & idx));
+		}
+	}
+
+	void set_description(const char *p_descrption) {
+		description = p_descrption;
+	}
+
+	RID_Alloc(uint32_t p_target_chunk_byte_size = 4096) {
+		chunks = NULL;
+		free_list_chunks = NULL;
+		validator_chunks = NULL;
+
+		elements_in_chunk = sizeof(T) > p_target_chunk_byte_size ? 1 : (p_target_chunk_byte_size / sizeof(T));
+		max_alloc = 0;
+		alloc_count = 0;
+		description = NULL;
+	}
+
+	~RID_Alloc() {
+		if (alloc_count) {
+			if (description) {
+				print_error("ERROR: " + itos(alloc_count) + " RID allocations of type " + description + " were leaked at exit.");
+			} else {
+				print_error("ERROR: " + itos(alloc_count) + " RID allocations of unspecified type were leaked at exit.");
+			}
+
+			for (uint32_t i = 0; i < alloc_count; i++) {
+				uint64_t idx = free_list_chunks[i / elements_in_chunk][i % elements_in_chunk];
+				chunks[idx / elements_in_chunk][idx % elements_in_chunk].~T();
+			}
+		}
+
+		uint32_t chunk_count = alloc_count == 0 ? 0 : (max_alloc / elements_in_chunk + 1);
+		for (uint32_t i = 0; i < chunk_count; i++) {
+			memfree(chunks[i]);
+			memfree(validator_chunks[i]);
+			memfree(free_list_chunks[i]);
+		}
+
+		if (chunks) {
+			memfree(chunks);
+			memfree(free_list_chunks);
+			memfree(validator_chunks);
+		}
+	}
+};
+
+template <class T>
+class RID_PtrOwner {
+	RID_Alloc<T *> alloc;
+
+public:
+	_FORCE_INLINE_ RID make_rid(T *p_ptr) {
+		return alloc.make_rid(p_ptr);
+	}
+
+	_FORCE_INLINE_ T *getornull(const RID &p_rid) {
+		T **ptr = alloc.getornull(p_rid);
+		if (unlikely(!ptr)) {
+			return NULL;
+		}
+		return *ptr;
+	}
+
+	_FORCE_INLINE_ bool owns(const RID &p_rid) {
+		return alloc.owns(p_rid);
+	}
+
+	_FORCE_INLINE_ void free(const RID &p_rid) {
+		alloc.free(p_rid);
+	}
+
+	_FORCE_INLINE_ void get_owned_list(List<RID> *p_owned) {
+		return alloc.get_owned_list(p_owned);
+	}
+
+	void set_description(const char *p_descrption) {
+		alloc.set_description(p_descrption);
+	}
+	RID_PtrOwner(uint32_t p_target_chunk_byte_size = 4096) :
+			alloc(p_target_chunk_byte_size) {}
+};
+
+template <class T>
+class RID_Owner {
+	RID_Alloc<T> alloc;
+
+public:
+	_FORCE_INLINE_ RID make_rid(const T &p_ptr) {
+		return alloc.make_rid(p_ptr);
+	}
+
+	_FORCE_INLINE_ T *getornull(const RID &p_rid) {
+		return alloc.getornull(p_rid);
+	}
+
+	_FORCE_INLINE_ bool owns(const RID &p_rid) {
+		return alloc.owns(p_rid);
+	}
+
+	_FORCE_INLINE_ void free(const RID &p_rid) {
+		alloc.free(p_rid);
+	}
+
+	_FORCE_INLINE_ void get_owned_list(List<RID> *p_owned) {
+		return alloc.get_owned_list(p_owned);
+	}
+
+	void set_description(const char *p_descrption) {
+		alloc.set_description(p_descrption);
+	}
+	RID_Owner(uint32_t p_target_chunk_byte_size = 4096) :
+			alloc(p_target_chunk_byte_size) {}
+};
+#endif // RID_OWNER_H

+ 9 - 8
drivers/dummy/rasterizer_dummy.h

@@ -32,6 +32,7 @@
 #define RASTERIZER_DUMMY_H
 #define RASTERIZER_DUMMY_H
 
 
 #include "core/math/camera_matrix.h"
 #include "core/math/camera_matrix.h"
+#include "core/rid_owner.h"
 #include "core/self_list.h"
 #include "core/self_list.h"
 #include "scene/resources/mesh.h"
 #include "scene/resources/mesh.h"
 #include "servers/visual/rasterizer.h"
 #include "servers/visual/rasterizer.h"
@@ -121,7 +122,7 @@ public:
 class RasterizerStorageDummy : public RasterizerStorage {
 class RasterizerStorageDummy : public RasterizerStorage {
 public:
 public:
 	/* TEXTURE API */
 	/* TEXTURE API */
-	struct DummyTexture : public RID_Data {
+	struct DummyTexture {
 		int width;
 		int width;
 		int height;
 		int height;
 		uint32_t flags;
 		uint32_t flags;
@@ -142,14 +143,14 @@ public:
 		Vector<AABB> bone_aabbs;
 		Vector<AABB> bone_aabbs;
 	};
 	};
 
 
-	struct DummyMesh : public RID_Data {
+	struct DummyMesh {
 		Vector<DummySurface> surfaces;
 		Vector<DummySurface> surfaces;
 		int blend_shape_count;
 		int blend_shape_count;
 		VS::BlendShapeMode blend_shape_mode;
 		VS::BlendShapeMode blend_shape_mode;
 	};
 	};
 
 
-	mutable RID_Owner<DummyTexture> texture_owner;
-	mutable RID_Owner<DummyMesh> mesh_owner;
+	mutable RID_PtrOwner<DummyTexture> texture_owner;
+	mutable RID_PtrOwner<DummyMesh> mesh_owner;
 
 
 	RID texture_create() {
 	RID texture_create() {
 
 
@@ -178,7 +179,7 @@ public:
 	}
 	}
 
 
 	void texture_set_data_partial(RID p_texture, const Ref<Image> &p_image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int p_dst_mip, int p_level) {
 	void texture_set_data_partial(RID p_texture, const Ref<Image> &p_image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int p_dst_mip, int p_level) {
-		DummyTexture *t = texture_owner.get(p_texture);
+		DummyTexture *t = texture_owner.getornull(p_texture);
 
 
 		ERR_FAIL_COND(!t);
 		ERR_FAIL_COND(!t);
 		ERR_FAIL_COND_MSG(p_image.is_null(), "It's not a reference to a valid Image object.");
 		ERR_FAIL_COND_MSG(p_image.is_null(), "It's not a reference to a valid Image object.");
@@ -588,7 +589,7 @@ public:
 	void gi_probe_dynamic_data_update(RID p_gi_probe_data, int p_depth_slice, int p_slice_count, int p_mipmap, const void *p_data) {}
 	void gi_probe_dynamic_data_update(RID p_gi_probe_data, int p_depth_slice, int p_slice_count, int p_mipmap, const void *p_data) {}
 
 
 	/* LIGHTMAP CAPTURE */
 	/* LIGHTMAP CAPTURE */
-	struct Instantiable : public RID_Data {
+	struct Instantiable {
 
 
 		SelfList<RasterizerScene::InstanceBase>::List instance_list;
 		SelfList<RasterizerScene::InstanceBase>::List instance_list;
 
 
@@ -630,7 +631,7 @@ public:
 		}
 		}
 	};
 	};
 
 
-	mutable RID_Owner<LightmapCapture> lightmap_capture_data_owner;
+	mutable RID_PtrOwner<LightmapCapture> lightmap_capture_data_owner;
 	void lightmap_capture_set_bounds(RID p_capture, const AABB &p_bounds) {}
 	void lightmap_capture_set_bounds(RID p_capture, const AABB &p_bounds) {}
 	AABB lightmap_capture_get_bounds(RID p_capture) const { return AABB(); }
 	AABB lightmap_capture_get_bounds(RID p_capture) const { return AABB(); }
 	void lightmap_capture_set_octree(RID p_capture, const PoolVector<uint8_t> &p_octree) {}
 	void lightmap_capture_set_octree(RID p_capture, const PoolVector<uint8_t> &p_octree) {}
@@ -724,7 +725,7 @@ public:
 
 
 		if (texture_owner.owns(p_rid)) {
 		if (texture_owner.owns(p_rid)) {
 			// delete the texture
 			// delete the texture
-			DummyTexture *texture = texture_owner.get(p_rid);
+			DummyTexture *texture = texture_owner.getornull(p_rid);
 			texture_owner.free(p_rid);
 			texture_owner.free(p_rid);
 			memdelete(texture);
 			memdelete(texture);
 		}
 		}

+ 3 - 3
drivers/gles2/rasterizer_canvas_gles2.cpp

@@ -88,7 +88,7 @@ void RasterizerCanvasGLES2::_set_uniforms() {
 		state.canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_OUTSIDE_ALPHA, light->mode == VS::CANVAS_LIGHT_MODE_MASK ? 1.0 : 0.0);
 		state.canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_OUTSIDE_ALPHA, light->mode == VS::CANVAS_LIGHT_MODE_MASK ? 1.0 : 0.0);
 
 
 		if (state.using_shadow) {
 		if (state.using_shadow) {
-			RasterizerStorageGLES2::CanvasLightShadow *cls = storage->canvas_light_shadow_owner.get(light->shadow_buffer);
+			RasterizerStorageGLES2::CanvasLightShadow *cls = storage->canvas_light_shadow_owner.getornull(light->shadow_buffer);
 			glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 5);
 			glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 5);
 			glBindTexture(GL_TEXTURE_2D, cls->distance);
 			glBindTexture(GL_TEXTURE_2D, cls->distance);
 			state.canvas_shader.set_uniform(CanvasShaderGLES2::SHADOW_MATRIX, light->shadow_matrix_cache);
 			state.canvas_shader.set_uniform(CanvasShaderGLES2::SHADOW_MATRIX, light->shadow_matrix_cache);
@@ -1480,7 +1480,7 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons
 		{
 		{
 			//skeleton handling
 			//skeleton handling
 			if (ci->skeleton.is_valid() && storage->skeleton_owner.owns(ci->skeleton)) {
 			if (ci->skeleton.is_valid() && storage->skeleton_owner.owns(ci->skeleton)) {
-				skeleton = storage->skeleton_owner.get(ci->skeleton);
+				skeleton = storage->skeleton_owner.getornull(ci->skeleton);
 				if (!skeleton->use_2d) {
 				if (!skeleton->use_2d) {
 					skeleton = NULL;
 					skeleton = NULL;
 				} else {
 				} else {
@@ -1825,7 +1825,7 @@ void RasterizerCanvasGLES2::canvas_debug_viewport_shadows(Light *p_lights_with_s
 
 
 void RasterizerCanvasGLES2::canvas_light_shadow_buffer_update(RID p_buffer, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders, CameraMatrix *p_xform_cache) {
 void RasterizerCanvasGLES2::canvas_light_shadow_buffer_update(RID p_buffer, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders, CameraMatrix *p_xform_cache) {
 
 
-	RasterizerStorageGLES2::CanvasLightShadow *cls = storage->canvas_light_shadow_owner.get(p_buffer);
+	RasterizerStorageGLES2::CanvasLightShadow *cls = storage->canvas_light_shadow_owner.getornull(p_buffer);
 	ERR_FAIL_COND(!cls);
 	ERR_FAIL_COND(!cls);
 
 
 	glDisable(GL_BLEND);
 	glDisable(GL_BLEND);

+ 1 - 1
drivers/gles2/rasterizer_gles2.cpp

@@ -384,7 +384,7 @@ void RasterizerGLES2::set_boot_image(const Ref<Image> &p_image, const Color &p_c
 		screenrect.position += ((Size2(window_w, window_h) - screenrect.size) / 2.0).floor();
 		screenrect.position += ((Size2(window_w, window_h) - screenrect.size) / 2.0).floor();
 	}
 	}
 
 
-	RasterizerStorageGLES2::Texture *t = storage->texture_owner.get(texture);
+	RasterizerStorageGLES2::Texture *t = storage->texture_owner.getornull(texture);
 	glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 1);
 	glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 1);
 	glBindTexture(GL_TEXTURE_2D, t->tex_id);
 	glBindTexture(GL_TEXTURE_2D, t->tex_id);
 	canvas->draw_generic_textured_rect(screenrect, Rect2(0, 0, 1, 1));
 	canvas->draw_generic_textured_rect(screenrect, Rect2(0, 0, 1, 1));

+ 13 - 13
drivers/gles2/rasterizer_scene_gles2.cpp

@@ -370,7 +370,7 @@ bool RasterizerSceneGLES2::shadow_atlas_update_light(RID p_atlas, RID p_light_in
 				// it is take but invalid, so we can take it
 				// it is take but invalid, so we can take it
 
 
 				shadow_atlas->shadow_owners.erase(sh->owner);
 				shadow_atlas->shadow_owners.erase(sh->owner);
-				LightInstance *sli = light_instance_owner.get(sh->owner);
+				LightInstance *sli = light_instance_owner.getornull(sh->owner);
 				sli->shadow_atlases.erase(p_atlas);
 				sli->shadow_atlases.erase(p_atlas);
 			}
 			}
 
 
@@ -412,7 +412,7 @@ bool RasterizerSceneGLES2::shadow_atlas_update_light(RID p_atlas, RID p_light_in
 			// it is take but invalid, so we can take it
 			// it is take but invalid, so we can take it
 
 
 			shadow_atlas->shadow_owners.erase(sh->owner);
 			shadow_atlas->shadow_owners.erase(sh->owner);
-			LightInstance *sli = light_instance_owner.get(sh->owner);
+			LightInstance *sli = light_instance_owner.getornull(sh->owner);
 			sli->shadow_atlases.erase(p_atlas);
 			sli->shadow_atlases.erase(p_atlas);
 		}
 		}
 
 
@@ -976,7 +976,7 @@ void RasterizerSceneGLES2::_add_geometry(RasterizerStorageGLES2::Geometry *p_geo
 	}
 	}
 
 
 	if (!material) {
 	if (!material) {
-		material = storage->material_owner.getptr(default_material);
+		material = storage->material_owner.getornull(default_material);
 	}
 	}
 
 
 	ERR_FAIL_COND(!material);
 	ERR_FAIL_COND(!material);
@@ -1023,10 +1023,10 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G
 		if (!p_material->shader->spatial.uses_alpha_scissor && !p_material->shader->spatial.writes_modelview_or_projection && !p_material->shader->spatial.uses_vertex && !p_material->shader->spatial.uses_discard && p_material->shader->spatial.depth_draw_mode != RasterizerStorageGLES2::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS) {
 		if (!p_material->shader->spatial.uses_alpha_scissor && !p_material->shader->spatial.writes_modelview_or_projection && !p_material->shader->spatial.uses_vertex && !p_material->shader->spatial.uses_discard && p_material->shader->spatial.depth_draw_mode != RasterizerStorageGLES2::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS) {
 			//shader does not use discard and does not write a vertex position, use generic material
 			//shader does not use discard and does not write a vertex position, use generic material
 			if (p_instance->cast_shadows == VS::SHADOW_CASTING_SETTING_DOUBLE_SIDED) {
 			if (p_instance->cast_shadows == VS::SHADOW_CASTING_SETTING_DOUBLE_SIDED) {
-				p_material = storage->material_owner.getptr(!p_shadow_pass && p_material->shader->spatial.uses_world_coordinates ? default_worldcoord_material_twosided : default_material_twosided);
+				p_material = storage->material_owner.getornull(!p_shadow_pass && p_material->shader->spatial.uses_world_coordinates ? default_worldcoord_material_twosided : default_material_twosided);
 				mirror = false;
 				mirror = false;
 			} else {
 			} else {
-				p_material = storage->material_owner.getptr(!p_shadow_pass && p_material->shader->spatial.uses_world_coordinates ? default_worldcoord_material : default_material);
+				p_material = storage->material_owner.getornull(!p_shadow_pass && p_material->shader->spatial.uses_world_coordinates ? default_worldcoord_material : default_material);
 			}
 			}
 		}
 		}
 
 
@@ -1242,13 +1242,13 @@ void RasterizerSceneGLES2::_fill_render_list(InstanceBase **p_cull_result, int p
 			} break;
 			} break;
 
 
 			case VS::INSTANCE_MULTIMESH: {
 			case VS::INSTANCE_MULTIMESH: {
-				RasterizerStorageGLES2::MultiMesh *multi_mesh = storage->multimesh_owner.getptr(instance->base);
+				RasterizerStorageGLES2::MultiMesh *multi_mesh = storage->multimesh_owner.getornull(instance->base);
 				ERR_CONTINUE(!multi_mesh);
 				ERR_CONTINUE(!multi_mesh);
 
 
 				if (multi_mesh->size == 0 || multi_mesh->visible_instances == 0)
 				if (multi_mesh->size == 0 || multi_mesh->visible_instances == 0)
 					continue;
 					continue;
 
 
-				RasterizerStorageGLES2::Mesh *mesh = storage->mesh_owner.getptr(multi_mesh->mesh);
+				RasterizerStorageGLES2::Mesh *mesh = storage->mesh_owner.getornull(multi_mesh->mesh);
 				if (!mesh)
 				if (!mesh)
 					continue;
 					continue;
 
 
@@ -1261,7 +1261,7 @@ void RasterizerSceneGLES2::_fill_render_list(InstanceBase **p_cull_result, int p
 			} break;
 			} break;
 
 
 			case VS::INSTANCE_IMMEDIATE: {
 			case VS::INSTANCE_IMMEDIATE: {
-				RasterizerStorageGLES2::Immediate *im = storage->immediate_owner.getptr(instance->base);
+				RasterizerStorageGLES2::Immediate *im = storage->immediate_owner.getornull(instance->base);
 				ERR_CONTINUE(!im);
 				ERR_CONTINUE(!im);
 
 
 				_add_geometry(im, instance, NULL, -1, p_depth_pass, p_shadow_pass);
 				_add_geometry(im, instance, NULL, -1, p_depth_pass, p_shadow_pass);
@@ -1789,7 +1789,7 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) {
 				storage->info.render.vertices_count += vertices;
 				storage->info.render.vertices_count += vertices;
 
 
 				if (c.texture.is_valid() && storage->texture_owner.owns(c.texture)) {
 				if (c.texture.is_valid() && storage->texture_owner.owns(c.texture)) {
-					RasterizerStorageGLES2::Texture *t = storage->texture_owner.get(c.texture);
+					RasterizerStorageGLES2::Texture *t = storage->texture_owner.getornull(c.texture);
 
 
 					if (t->redraw_if_visible) {
 					if (t->redraw_if_visible) {
 						VisualServerRaster::redraw_request();
 						VisualServerRaster::redraw_request();
@@ -3874,11 +3874,11 @@ bool RasterizerSceneGLES2::free(RID p_rid) {
 
 
 	if (light_instance_owner.owns(p_rid)) {
 	if (light_instance_owner.owns(p_rid)) {
 
 
-		LightInstance *light_instance = light_instance_owner.getptr(p_rid);
+		LightInstance *light_instance = light_instance_owner.getornull(p_rid);
 
 
 		//remove from shadow atlases..
 		//remove from shadow atlases..
 		for (Set<RID>::Element *E = light_instance->shadow_atlases.front(); E; E = E->next()) {
 		for (Set<RID>::Element *E = light_instance->shadow_atlases.front(); E; E = E->next()) {
-			ShadowAtlas *shadow_atlas = shadow_atlas_owner.get(E->get());
+			ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(E->get());
 			ERR_CONTINUE(!shadow_atlas->shadow_owners.has(p_rid));
 			ERR_CONTINUE(!shadow_atlas->shadow_owners.has(p_rid));
 			uint32_t key = shadow_atlas->shadow_owners[p_rid];
 			uint32_t key = shadow_atlas->shadow_owners[p_rid];
 			uint32_t q = (key >> ShadowAtlas::QUADRANT_SHIFT) & 0x3;
 			uint32_t q = (key >> ShadowAtlas::QUADRANT_SHIFT) & 0x3;
@@ -3893,13 +3893,13 @@ bool RasterizerSceneGLES2::free(RID p_rid) {
 
 
 	} else if (shadow_atlas_owner.owns(p_rid)) {
 	} else if (shadow_atlas_owner.owns(p_rid)) {
 
 
-		ShadowAtlas *shadow_atlas = shadow_atlas_owner.get(p_rid);
+		ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_rid);
 		shadow_atlas_set_size(p_rid, 0);
 		shadow_atlas_set_size(p_rid, 0);
 		shadow_atlas_owner.free(p_rid);
 		shadow_atlas_owner.free(p_rid);
 		memdelete(shadow_atlas);
 		memdelete(shadow_atlas);
 	} else if (reflection_probe_instance_owner.owns(p_rid)) {
 	} else if (reflection_probe_instance_owner.owns(p_rid)) {
 
 
-		ReflectionProbeInstance *reflection_instance = reflection_probe_instance_owner.get(p_rid);
+		ReflectionProbeInstance *reflection_instance = reflection_probe_instance_owner.getornull(p_rid);
 
 
 		for (int i = 0; i < 6; i++) {
 		for (int i = 0; i < 6; i++) {
 			glDeleteFramebuffers(1, &reflection_instance->fbo[i]);
 			glDeleteFramebuffers(1, &reflection_instance->fbo[i]);

+ 8 - 8
drivers/gles2/rasterizer_scene_gles2.h

@@ -225,7 +225,7 @@ public:
 
 
 	uint64_t shadow_atlas_realloc_tolerance_msec;
 	uint64_t shadow_atlas_realloc_tolerance_msec;
 
 
-	struct ShadowAtlas : public RID_Data {
+	struct ShadowAtlas  {
 		enum {
 		enum {
 			QUADRANT_SHIFT = 27,
 			QUADRANT_SHIFT = 27,
 			SHADOW_INDEX_MASK = (1 << QUADRANT_SHIFT) - 1,
 			SHADOW_INDEX_MASK = (1 << QUADRANT_SHIFT) - 1,
@@ -273,7 +273,7 @@ public:
 
 
 	Vector<ShadowCubeMap> shadow_cubemaps;
 	Vector<ShadowCubeMap> shadow_cubemaps;
 
 
-	RID_Owner<ShadowAtlas> shadow_atlas_owner;
+	RID_PtrOwner<ShadowAtlas> shadow_atlas_owner;
 
 
 	RID shadow_atlas_create();
 	RID shadow_atlas_create();
 	void shadow_atlas_set_size(RID p_atlas, int p_size);
 	void shadow_atlas_set_size(RID p_atlas, int p_size);
@@ -304,7 +304,7 @@ public:
 
 
 	/* REFLECTION PROBE INSTANCE */
 	/* REFLECTION PROBE INSTANCE */
 
 
-	struct ReflectionProbeInstance : public RID_Data {
+	struct ReflectionProbeInstance  {
 
 
 		RasterizerStorageGLES2::ReflectionProbe *probe_ptr;
 		RasterizerStorageGLES2::ReflectionProbe *probe_ptr;
 		RID probe;
 		RID probe;
@@ -330,7 +330,7 @@ public:
 		Transform transform;
 		Transform transform;
 	};
 	};
 
 
-	mutable RID_Owner<ReflectionProbeInstance> reflection_probe_instance_owner;
+	mutable RID_PtrOwner<ReflectionProbeInstance> reflection_probe_instance_owner;
 
 
 	ReflectionProbeInstance **reflection_probe_instances;
 	ReflectionProbeInstance **reflection_probe_instances;
 	int reflection_probe_count;
 	int reflection_probe_count;
@@ -345,7 +345,7 @@ public:
 
 
 	/* ENVIRONMENT API */
 	/* ENVIRONMENT API */
 
 
-	struct Environment : public RID_Data {
+	struct Environment  {
 		VS::EnvironmentBG bg_mode;
 		VS::EnvironmentBG bg_mode;
 
 
 		RID sky;
 		RID sky;
@@ -459,7 +459,7 @@ public:
 		}
 		}
 	};
 	};
 
 
-	mutable RID_Owner<Environment> environment_owner;
+	mutable RID_PtrOwner<Environment> environment_owner;
 
 
 	virtual RID environment_create();
 	virtual RID environment_create();
 
 
@@ -496,7 +496,7 @@ public:
 
 
 	/* LIGHT INSTANCE */
 	/* LIGHT INSTANCE */
 
 
-	struct LightInstance : public RID_Data {
+	struct LightInstance  {
 
 
 		struct ShadowTransform {
 		struct ShadowTransform {
 			CameraMatrix camera;
 			CameraMatrix camera;
@@ -530,7 +530,7 @@ public:
 		Set<RID> shadow_atlases; // atlases where this light is registered
 		Set<RID> shadow_atlases; // atlases where this light is registered
 	};
 	};
 
 
-	mutable RID_Owner<LightInstance> light_instance_owner;
+	mutable RID_PtrOwner<LightInstance> light_instance_owner;
 
 
 	virtual RID light_instance_create(RID p_light);
 	virtual RID light_instance_create(RID p_light);
 	virtual void light_instance_set_transform(RID p_light_instance, const Transform &p_transform);
 	virtual void light_instance_set_transform(RID p_light_instance, const Transform &p_transform);

+ 50 - 50
drivers/gles2/rasterizer_storage_gles2.cpp

@@ -1184,7 +1184,7 @@ void RasterizerStorageGLES2::texture_set_proxy(RID p_texture, RID p_proxy) {
 	}
 	}
 
 
 	if (p_proxy.is_valid()) {
 	if (p_proxy.is_valid()) {
-		Texture *proxy = texture_owner.get(p_proxy);
+		Texture *proxy = texture_owner.getornull(p_proxy);
 		ERR_FAIL_COND(!proxy);
 		ERR_FAIL_COND(!proxy);
 		ERR_FAIL_COND(proxy == texture);
 		ERR_FAIL_COND(proxy == texture);
 		proxy->proxy_owners.insert(texture);
 		proxy->proxy_owners.insert(texture);
@@ -1201,7 +1201,7 @@ void RasterizerStorageGLES2::texture_set_force_redraw_if_visible(RID p_texture,
 }
 }
 
 
 void RasterizerStorageGLES2::texture_set_detect_3d_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) {
 void RasterizerStorageGLES2::texture_set_detect_3d_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) {
-	Texture *texture = texture_owner.get(p_texture);
+	Texture *texture = texture_owner.getornull(p_texture);
 	ERR_FAIL_COND(!texture);
 	ERR_FAIL_COND(!texture);
 
 
 	texture->detect_3d = p_callback;
 	texture->detect_3d = p_callback;
@@ -1209,7 +1209,7 @@ void RasterizerStorageGLES2::texture_set_detect_3d_callback(RID p_texture, Visua
 }
 }
 
 
 void RasterizerStorageGLES2::texture_set_detect_srgb_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) {
 void RasterizerStorageGLES2::texture_set_detect_srgb_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) {
-	Texture *texture = texture_owner.get(p_texture);
+	Texture *texture = texture_owner.getornull(p_texture);
 	ERR_FAIL_COND(!texture);
 	ERR_FAIL_COND(!texture);
 
 
 	texture->detect_srgb = p_callback;
 	texture->detect_srgb = p_callback;
@@ -1217,7 +1217,7 @@ void RasterizerStorageGLES2::texture_set_detect_srgb_callback(RID p_texture, Vis
 }
 }
 
 
 void RasterizerStorageGLES2::texture_set_detect_normal_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) {
 void RasterizerStorageGLES2::texture_set_detect_normal_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) {
-	Texture *texture = texture_owner.get(p_texture);
+	Texture *texture = texture_owner.getornull(p_texture);
 	ERR_FAIL_COND(!texture);
 	ERR_FAIL_COND(!texture);
 
 
 	texture->detect_normal = p_callback;
 	texture->detect_normal = p_callback;
@@ -1456,7 +1456,7 @@ void RasterizerStorageGLES2::shader_set_code(RID p_shader, const String &p_code)
 
 
 String RasterizerStorageGLES2::shader_get_code(RID p_shader) const {
 String RasterizerStorageGLES2::shader_get_code(RID p_shader) const {
 
 
-	const Shader *shader = shader_owner.get(p_shader);
+	const Shader *shader = shader_owner.getornull(p_shader);
 	ERR_FAIL_COND_V(!shader, "");
 	ERR_FAIL_COND_V(!shader, "");
 
 
 	return shader->code;
 	return shader->code;
@@ -1610,7 +1610,7 @@ void RasterizerStorageGLES2::update_dirty_shaders() {
 
 
 void RasterizerStorageGLES2::shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const {
 void RasterizerStorageGLES2::shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const {
 
 
-	Shader *shader = shader_owner.get(p_shader);
+	Shader *shader = shader_owner.getornull(p_shader);
 	ERR_FAIL_COND(!shader);
 	ERR_FAIL_COND(!shader);
 
 
 	if (shader->dirty_list.in_list()) {
 	if (shader->dirty_list.in_list()) {
@@ -1754,7 +1754,7 @@ void RasterizerStorageGLES2::shader_get_param_list(RID p_shader, List<PropertyIn
 
 
 void RasterizerStorageGLES2::shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture) {
 void RasterizerStorageGLES2::shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture) {
 
 
-	Shader *shader = shader_owner.get(p_shader);
+	Shader *shader = shader_owner.getornull(p_shader);
 	ERR_FAIL_COND(!shader);
 	ERR_FAIL_COND(!shader);
 	ERR_FAIL_COND(p_texture.is_valid() && !texture_owner.owns(p_texture));
 	ERR_FAIL_COND(p_texture.is_valid() && !texture_owner.owns(p_texture));
 
 
@@ -1769,7 +1769,7 @@ void RasterizerStorageGLES2::shader_set_default_texture_param(RID p_shader, cons
 
 
 RID RasterizerStorageGLES2::shader_get_default_texture_param(RID p_shader, const StringName &p_name) const {
 RID RasterizerStorageGLES2::shader_get_default_texture_param(RID p_shader, const StringName &p_name) const {
 
 
-	const Shader *shader = shader_owner.get(p_shader);
+	const Shader *shader = shader_owner.getornull(p_shader);
 	ERR_FAIL_COND_V(!shader, RID());
 	ERR_FAIL_COND_V(!shader, RID());
 
 
 	const Map<StringName, RID>::Element *E = shader->default_textures.find(p_name);
 	const Map<StringName, RID>::Element *E = shader->default_textures.find(p_name);
@@ -1800,7 +1800,7 @@ RID RasterizerStorageGLES2::material_create() {
 
 
 void RasterizerStorageGLES2::material_set_shader(RID p_material, RID p_shader) {
 void RasterizerStorageGLES2::material_set_shader(RID p_material, RID p_shader) {
 
 
-	Material *material = material_owner.get(p_material);
+	Material *material = material_owner.getornull(p_material);
 	ERR_FAIL_COND(!material);
 	ERR_FAIL_COND(!material);
 
 
 	Shader *shader = shader_owner.getornull(p_shader);
 	Shader *shader = shader_owner.getornull(p_shader);
@@ -1821,7 +1821,7 @@ void RasterizerStorageGLES2::material_set_shader(RID p_material, RID p_shader) {
 
 
 RID RasterizerStorageGLES2::material_get_shader(RID p_material) const {
 RID RasterizerStorageGLES2::material_get_shader(RID p_material) const {
 
 
-	const Material *material = material_owner.get(p_material);
+	const Material *material = material_owner.getornull(p_material);
 	ERR_FAIL_COND_V(!material, RID());
 	ERR_FAIL_COND_V(!material, RID());
 
 
 	if (material->shader) {
 	if (material->shader) {
@@ -1833,7 +1833,7 @@ RID RasterizerStorageGLES2::material_get_shader(RID p_material) const {
 
 
 void RasterizerStorageGLES2::material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) {
 void RasterizerStorageGLES2::material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) {
 
 
-	Material *material = material_owner.get(p_material);
+	Material *material = material_owner.getornull(p_material);
 	ERR_FAIL_COND(!material);
 	ERR_FAIL_COND(!material);
 
 
 	if (p_value.get_type() == Variant::NIL) {
 	if (p_value.get_type() == Variant::NIL) {
@@ -1847,7 +1847,7 @@ void RasterizerStorageGLES2::material_set_param(RID p_material, const StringName
 
 
 Variant RasterizerStorageGLES2::material_get_param(RID p_material, const StringName &p_param) const {
 Variant RasterizerStorageGLES2::material_get_param(RID p_material, const StringName &p_param) const {
 
 
-	const Material *material = material_owner.get(p_material);
+	const Material *material = material_owner.getornull(p_material);
 	ERR_FAIL_COND_V(!material, RID());
 	ERR_FAIL_COND_V(!material, RID());
 
 
 	if (material->params.has(p_param)) {
 	if (material->params.has(p_param)) {
@@ -1858,7 +1858,7 @@ Variant RasterizerStorageGLES2::material_get_param(RID p_material, const StringN
 }
 }
 
 
 Variant RasterizerStorageGLES2::material_get_param_default(RID p_material, const StringName &p_param) const {
 Variant RasterizerStorageGLES2::material_get_param_default(RID p_material, const StringName &p_param) const {
-	const Material *material = material_owner.get(p_material);
+	const Material *material = material_owner.getornull(p_material);
 	ERR_FAIL_COND_V(!material, Variant());
 	ERR_FAIL_COND_V(!material, Variant());
 
 
 	if (material->shader) {
 	if (material->shader) {
@@ -1879,14 +1879,14 @@ void RasterizerStorageGLES2::material_set_line_width(RID p_material, float p_wid
 }
 }
 
 
 void RasterizerStorageGLES2::material_set_next_pass(RID p_material, RID p_next_material) {
 void RasterizerStorageGLES2::material_set_next_pass(RID p_material, RID p_next_material) {
-	Material *material = material_owner.get(p_material);
+	Material *material = material_owner.getornull(p_material);
 	ERR_FAIL_COND(!material);
 	ERR_FAIL_COND(!material);
 
 
 	material->next_pass = p_next_material;
 	material->next_pass = p_next_material;
 }
 }
 
 
 bool RasterizerStorageGLES2::material_is_animated(RID p_material) {
 bool RasterizerStorageGLES2::material_is_animated(RID p_material) {
-	Material *material = material_owner.get(p_material);
+	Material *material = material_owner.getornull(p_material);
 	ERR_FAIL_COND_V(!material, false);
 	ERR_FAIL_COND_V(!material, false);
 	if (material->dirty_list.in_list()) {
 	if (material->dirty_list.in_list()) {
 		_update_material(material);
 		_update_material(material);
@@ -1900,7 +1900,7 @@ bool RasterizerStorageGLES2::material_is_animated(RID p_material) {
 }
 }
 
 
 bool RasterizerStorageGLES2::material_casts_shadows(RID p_material) {
 bool RasterizerStorageGLES2::material_casts_shadows(RID p_material) {
-	Material *material = material_owner.get(p_material);
+	Material *material = material_owner.getornull(p_material);
 	ERR_FAIL_COND_V(!material, false);
 	ERR_FAIL_COND_V(!material, false);
 	if (material->dirty_list.in_list()) {
 	if (material->dirty_list.in_list()) {
 		_update_material(material);
 		_update_material(material);
@@ -1947,7 +1947,7 @@ void RasterizerStorageGLES2::material_set_render_priority(RID p_material, int pr
 	ERR_FAIL_COND(priority < VS::MATERIAL_RENDER_PRIORITY_MIN);
 	ERR_FAIL_COND(priority < VS::MATERIAL_RENDER_PRIORITY_MIN);
 	ERR_FAIL_COND(priority > VS::MATERIAL_RENDER_PRIORITY_MAX);
 	ERR_FAIL_COND(priority > VS::MATERIAL_RENDER_PRIORITY_MAX);
 
 
-	Material *material = material_owner.get(p_material);
+	Material *material = material_owner.getornull(p_material);
 	ERR_FAIL_COND(!material);
 	ERR_FAIL_COND(!material);
 
 
 	material->render_priority = priority;
 	material->render_priority = priority;
@@ -2804,7 +2804,7 @@ AABB RasterizerStorageGLES2::mesh_get_custom_aabb(RID p_mesh) const {
 }
 }
 
 
 AABB RasterizerStorageGLES2::mesh_get_aabb(RID p_mesh, RID p_skeleton) const {
 AABB RasterizerStorageGLES2::mesh_get_aabb(RID p_mesh, RID p_skeleton) const {
-	Mesh *mesh = mesh_owner.get(p_mesh);
+	Mesh *mesh = mesh_owner.getornull(p_mesh);
 	ERR_FAIL_COND_V(!mesh, AABB());
 	ERR_FAIL_COND_V(!mesh, AABB());
 
 
 	if (mesh->custom_aabb != AABB())
 	if (mesh->custom_aabb != AABB())
@@ -2812,7 +2812,7 @@ AABB RasterizerStorageGLES2::mesh_get_aabb(RID p_mesh, RID p_skeleton) const {
 
 
 	Skeleton *sk = NULL;
 	Skeleton *sk = NULL;
 	if (p_skeleton.is_valid()) {
 	if (p_skeleton.is_valid()) {
-		sk = skeleton_owner.get(p_skeleton);
+		sk = skeleton_owner.getornull(p_skeleton);
 	}
 	}
 
 
 	AABB aabb;
 	AABB aabb;
@@ -3468,7 +3468,7 @@ RID RasterizerStorageGLES2::immediate_create() {
 }
 }
 
 
 void RasterizerStorageGLES2::immediate_begin(RID p_immediate, VS::PrimitiveType p_primitive, RID p_texture) {
 void RasterizerStorageGLES2::immediate_begin(RID p_immediate, VS::PrimitiveType p_primitive, RID p_texture) {
-	Immediate *im = immediate_owner.get(p_immediate);
+	Immediate *im = immediate_owner.getornull(p_immediate);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(im->building);
 	ERR_FAIL_COND(im->building);
 
 
@@ -3481,7 +3481,7 @@ void RasterizerStorageGLES2::immediate_begin(RID p_immediate, VS::PrimitiveType
 }
 }
 
 
 void RasterizerStorageGLES2::immediate_vertex(RID p_immediate, const Vector3 &p_vertex) {
 void RasterizerStorageGLES2::immediate_vertex(RID p_immediate, const Vector3 &p_vertex) {
-	Immediate *im = immediate_owner.get(p_immediate);
+	Immediate *im = immediate_owner.getornull(p_immediate);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im->building);
 	ERR_FAIL_COND(!im->building);
 
 
@@ -3509,7 +3509,7 @@ void RasterizerStorageGLES2::immediate_vertex(RID p_immediate, const Vector3 &p_
 }
 }
 
 
 void RasterizerStorageGLES2::immediate_normal(RID p_immediate, const Vector3 &p_normal) {
 void RasterizerStorageGLES2::immediate_normal(RID p_immediate, const Vector3 &p_normal) {
-	Immediate *im = immediate_owner.get(p_immediate);
+	Immediate *im = immediate_owner.getornull(p_immediate);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im->building);
 	ERR_FAIL_COND(!im->building);
 
 
@@ -3518,7 +3518,7 @@ void RasterizerStorageGLES2::immediate_normal(RID p_immediate, const Vector3 &p_
 }
 }
 
 
 void RasterizerStorageGLES2::immediate_tangent(RID p_immediate, const Plane &p_tangent) {
 void RasterizerStorageGLES2::immediate_tangent(RID p_immediate, const Plane &p_tangent) {
-	Immediate *im = immediate_owner.get(p_immediate);
+	Immediate *im = immediate_owner.getornull(p_immediate);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im->building);
 	ERR_FAIL_COND(!im->building);
 
 
@@ -3527,7 +3527,7 @@ void RasterizerStorageGLES2::immediate_tangent(RID p_immediate, const Plane &p_t
 }
 }
 
 
 void RasterizerStorageGLES2::immediate_color(RID p_immediate, const Color &p_color) {
 void RasterizerStorageGLES2::immediate_color(RID p_immediate, const Color &p_color) {
-	Immediate *im = immediate_owner.get(p_immediate);
+	Immediate *im = immediate_owner.getornull(p_immediate);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im->building);
 	ERR_FAIL_COND(!im->building);
 
 
@@ -3536,7 +3536,7 @@ void RasterizerStorageGLES2::immediate_color(RID p_immediate, const Color &p_col
 }
 }
 
 
 void RasterizerStorageGLES2::immediate_uv(RID p_immediate, const Vector2 &tex_uv) {
 void RasterizerStorageGLES2::immediate_uv(RID p_immediate, const Vector2 &tex_uv) {
-	Immediate *im = immediate_owner.get(p_immediate);
+	Immediate *im = immediate_owner.getornull(p_immediate);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im->building);
 	ERR_FAIL_COND(!im->building);
 
 
@@ -3545,7 +3545,7 @@ void RasterizerStorageGLES2::immediate_uv(RID p_immediate, const Vector2 &tex_uv
 }
 }
 
 
 void RasterizerStorageGLES2::immediate_uv2(RID p_immediate, const Vector2 &tex_uv) {
 void RasterizerStorageGLES2::immediate_uv2(RID p_immediate, const Vector2 &tex_uv) {
-	Immediate *im = immediate_owner.get(p_immediate);
+	Immediate *im = immediate_owner.getornull(p_immediate);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im->building);
 	ERR_FAIL_COND(!im->building);
 
 
@@ -3554,7 +3554,7 @@ void RasterizerStorageGLES2::immediate_uv2(RID p_immediate, const Vector2 &tex_u
 }
 }
 
 
 void RasterizerStorageGLES2::immediate_end(RID p_immediate) {
 void RasterizerStorageGLES2::immediate_end(RID p_immediate) {
-	Immediate *im = immediate_owner.get(p_immediate);
+	Immediate *im = immediate_owner.getornull(p_immediate);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im->building);
 	ERR_FAIL_COND(!im->building);
 
 
@@ -3563,7 +3563,7 @@ void RasterizerStorageGLES2::immediate_end(RID p_immediate) {
 }
 }
 
 
 void RasterizerStorageGLES2::immediate_clear(RID p_immediate) {
 void RasterizerStorageGLES2::immediate_clear(RID p_immediate) {
-	Immediate *im = immediate_owner.get(p_immediate);
+	Immediate *im = immediate_owner.getornull(p_immediate);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(im->building);
 	ERR_FAIL_COND(im->building);
 
 
@@ -3572,13 +3572,13 @@ void RasterizerStorageGLES2::immediate_clear(RID p_immediate) {
 }
 }
 
 
 AABB RasterizerStorageGLES2::immediate_get_aabb(RID p_immediate) const {
 AABB RasterizerStorageGLES2::immediate_get_aabb(RID p_immediate) const {
-	Immediate *im = immediate_owner.get(p_immediate);
+	Immediate *im = immediate_owner.getornull(p_immediate);
 	ERR_FAIL_COND_V(!im, AABB());
 	ERR_FAIL_COND_V(!im, AABB());
 	return im->aabb;
 	return im->aabb;
 }
 }
 
 
 void RasterizerStorageGLES2::immediate_set_material(RID p_immediate, RID p_material) {
 void RasterizerStorageGLES2::immediate_set_material(RID p_immediate, RID p_material) {
-	Immediate *im = immediate_owner.get(p_immediate);
+	Immediate *im = immediate_owner.getornull(p_immediate);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im);
 
 
 	im->material = p_material;
 	im->material = p_material;
@@ -3586,7 +3586,7 @@ void RasterizerStorageGLES2::immediate_set_material(RID p_immediate, RID p_mater
 }
 }
 
 
 RID RasterizerStorageGLES2::immediate_get_material(RID p_immediate) const {
 RID RasterizerStorageGLES2::immediate_get_material(RID p_immediate) const {
-	const Immediate *im = immediate_owner.get(p_immediate);
+	const Immediate *im = immediate_owner.getornull(p_immediate);
 	ERR_FAIL_COND_V(!im, RID());
 	ERR_FAIL_COND_V(!im, RID());
 	return im->material;
 	return im->material;
 }
 }
@@ -5057,7 +5057,7 @@ void RasterizerStorageGLES2::_render_target_clear(RenderTarget *rt) {
 		glDeleteFramebuffers(1, &rt->external.fbo);
 		glDeleteFramebuffers(1, &rt->external.fbo);
 
 
 		// clean up our texture
 		// clean up our texture
-		Texture *t = texture_owner.get(rt->external.texture);
+		Texture *t = texture_owner.getornull(rt->external.texture);
 		t->alloc_height = 0;
 		t->alloc_height = 0;
 		t->alloc_width = 0;
 		t->alloc_width = 0;
 		t->width = 0;
 		t->width = 0;
@@ -5079,7 +5079,7 @@ void RasterizerStorageGLES2::_render_target_clear(RenderTarget *rt) {
 		rt->depth = 0;
 		rt->depth = 0;
 	}
 	}
 
 
-	Texture *tex = texture_owner.get(rt->texture);
+	Texture *tex = texture_owner.getornull(rt->texture);
 	tex->alloc_height = 0;
 	tex->alloc_height = 0;
 	tex->alloc_width = 0;
 	tex->alloc_width = 0;
 	tex->width = 0;
 	tex->width = 0;
@@ -5206,7 +5206,7 @@ void RasterizerStorageGLES2::render_target_set_external_texture(RID p_render_tar
 			}
 			}
 
 
 			// clean up our texture
 			// clean up our texture
-			Texture *t = texture_owner.get(rt->external.texture);
+			Texture *t = texture_owner.getornull(rt->external.texture);
 			t->alloc_height = 0;
 			t->alloc_height = 0;
 			t->alloc_width = 0;
 			t->alloc_width = 0;
 			t->width = 0;
 			t->width = 0;
@@ -5258,7 +5258,7 @@ void RasterizerStorageGLES2::render_target_set_external_texture(RID p_render_tar
 			glBindFramebuffer(GL_FRAMEBUFFER, rt->external.fbo);
 			glBindFramebuffer(GL_FRAMEBUFFER, rt->external.fbo);
 
 
 			// find our texture
 			// find our texture
-			t = texture_owner.get(rt->external.texture);
+			t = texture_owner.getornull(rt->external.texture);
 		}
 		}
 
 
 		// set our texture
 		// set our texture
@@ -5448,7 +5448,7 @@ RID RasterizerStorageGLES2::canvas_light_occluder_create() {
 
 
 void RasterizerStorageGLES2::canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector<Vector2> &p_lines) {
 void RasterizerStorageGLES2::canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector<Vector2> &p_lines) {
 
 
-	CanvasOccluder *co = canvas_occluder_owner.get(p_occluder);
+	CanvasOccluder *co = canvas_occluder_owner.getornull(p_occluder);
 	ERR_FAIL_COND(!co);
 	ERR_FAIL_COND(!co);
 
 
 	co->lines = p_lines;
 	co->lines = p_lines;
@@ -5565,7 +5565,7 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
 		RenderTarget *rt = render_target_owner.getornull(p_rid);
 		RenderTarget *rt = render_target_owner.getornull(p_rid);
 		_render_target_clear(rt);
 		_render_target_clear(rt);
 
 
-		Texture *t = texture_owner.get(rt->texture);
+		Texture *t = texture_owner.getornull(rt->texture);
 		texture_owner.free(rt->texture);
 		texture_owner.free(rt->texture);
 		memdelete(t);
 		memdelete(t);
 		render_target_owner.free(p_rid);
 		render_target_owner.free(p_rid);
@@ -5574,7 +5574,7 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
 		return true;
 		return true;
 	} else if (texture_owner.owns(p_rid)) {
 	} else if (texture_owner.owns(p_rid)) {
 
 
-		Texture *t = texture_owner.get(p_rid);
+		Texture *t = texture_owner.getornull(p_rid);
 		// can't free a render target texture
 		// can't free a render target texture
 		ERR_FAIL_COND_V(t->render_target, true);
 		ERR_FAIL_COND_V(t->render_target, true);
 
 
@@ -5585,7 +5585,7 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
 		return true;
 		return true;
 	} else if (sky_owner.owns(p_rid)) {
 	} else if (sky_owner.owns(p_rid)) {
 
 
-		Sky *sky = sky_owner.get(p_rid);
+		Sky *sky = sky_owner.getornull(p_rid);
 		sky_set_texture(p_rid, RID(), 256);
 		sky_set_texture(p_rid, RID(), 256);
 		sky_owner.free(p_rid);
 		sky_owner.free(p_rid);
 		memdelete(sky);
 		memdelete(sky);
@@ -5593,7 +5593,7 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
 		return true;
 		return true;
 	} else if (shader_owner.owns(p_rid)) {
 	} else if (shader_owner.owns(p_rid)) {
 
 
-		Shader *shader = shader_owner.get(p_rid);
+		Shader *shader = shader_owner.getornull(p_rid);
 
 
 		if (shader->shader && shader->custom_code_id) {
 		if (shader->shader && shader->custom_code_id) {
 			shader->shader->free_custom_shader(shader->custom_code_id);
 			shader->shader->free_custom_shader(shader->custom_code_id);
@@ -5618,7 +5618,7 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
 		return true;
 		return true;
 	} else if (material_owner.owns(p_rid)) {
 	} else if (material_owner.owns(p_rid)) {
 
 
-		Material *m = material_owner.get(p_rid);
+		Material *m = material_owner.getornull(p_rid);
 
 
 		if (m->shader) {
 		if (m->shader) {
 			m->shader->materials.remove(&m->list);
 			m->shader->materials.remove(&m->list);
@@ -5650,7 +5650,7 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
 		return true;
 		return true;
 	} else if (skeleton_owner.owns(p_rid)) {
 	} else if (skeleton_owner.owns(p_rid)) {
 
 
-		Skeleton *s = skeleton_owner.get(p_rid);
+		Skeleton *s = skeleton_owner.getornull(p_rid);
 
 
 		if (s->update_list.in_list()) {
 		if (s->update_list.in_list()) {
 			skeleton_update_list.remove(&s->update_list);
 			skeleton_update_list.remove(&s->update_list);
@@ -5672,7 +5672,7 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
 		return true;
 		return true;
 	} else if (mesh_owner.owns(p_rid)) {
 	} else if (mesh_owner.owns(p_rid)) {
 
 
-		Mesh *mesh = mesh_owner.get(p_rid);
+		Mesh *mesh = mesh_owner.getornull(p_rid);
 
 
 		mesh->instance_remove_deps();
 		mesh->instance_remove_deps();
 		mesh_clear(p_rid);
 		mesh_clear(p_rid);
@@ -5695,7 +5695,7 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
 		return true;
 		return true;
 	} else if (multimesh_owner.owns(p_rid)) {
 	} else if (multimesh_owner.owns(p_rid)) {
 
 
-		MultiMesh *multimesh = multimesh_owner.get(p_rid);
+		MultiMesh *multimesh = multimesh_owner.getornull(p_rid);
 		multimesh->instance_remove_deps();
 		multimesh->instance_remove_deps();
 
 
 		if (multimesh->mesh.is_valid()) {
 		if (multimesh->mesh.is_valid()) {
@@ -5714,7 +5714,7 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
 
 
 		return true;
 		return true;
 	} else if (immediate_owner.owns(p_rid)) {
 	} else if (immediate_owner.owns(p_rid)) {
-		Immediate *im = immediate_owner.get(p_rid);
+		Immediate *im = immediate_owner.getornull(p_rid);
 		im->instance_remove_deps();
 		im->instance_remove_deps();
 
 
 		immediate_owner.free(p_rid);
 		immediate_owner.free(p_rid);
@@ -5723,7 +5723,7 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
 		return true;
 		return true;
 	} else if (light_owner.owns(p_rid)) {
 	} else if (light_owner.owns(p_rid)) {
 
 
-		Light *light = light_owner.get(p_rid);
+		Light *light = light_owner.getornull(p_rid);
 		light->instance_remove_deps();
 		light->instance_remove_deps();
 
 
 		light_owner.free(p_rid);
 		light_owner.free(p_rid);
@@ -5733,7 +5733,7 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
 	} else if (reflection_probe_owner.owns(p_rid)) {
 	} else if (reflection_probe_owner.owns(p_rid)) {
 
 
 		// delete the texture
 		// delete the texture
-		ReflectionProbe *reflection_probe = reflection_probe_owner.get(p_rid);
+		ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_rid);
 		reflection_probe->instance_remove_deps();
 		reflection_probe->instance_remove_deps();
 
 
 		reflection_probe_owner.free(p_rid);
 		reflection_probe_owner.free(p_rid);
@@ -5743,7 +5743,7 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
 	} else if (lightmap_capture_data_owner.owns(p_rid)) {
 	} else if (lightmap_capture_data_owner.owns(p_rid)) {
 
 
 		// delete the texture
 		// delete the texture
-		LightmapCapture *lightmap_capture = lightmap_capture_data_owner.get(p_rid);
+		LightmapCapture *lightmap_capture = lightmap_capture_data_owner.getornull(p_rid);
 		lightmap_capture->instance_remove_deps();
 		lightmap_capture->instance_remove_deps();
 
 
 		lightmap_capture_data_owner.free(p_rid);
 		lightmap_capture_data_owner.free(p_rid);
@@ -5752,7 +5752,7 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
 
 
 	} else if (canvas_occluder_owner.owns(p_rid)) {
 	} else if (canvas_occluder_owner.owns(p_rid)) {
 
 
-		CanvasOccluder *co = canvas_occluder_owner.get(p_rid);
+		CanvasOccluder *co = canvas_occluder_owner.getornull(p_rid);
 		if (co->index_id)
 		if (co->index_id)
 			glDeleteBuffers(1, &co->index_id);
 			glDeleteBuffers(1, &co->index_id);
 		if (co->vertex_id)
 		if (co->vertex_id)
@@ -5765,7 +5765,7 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
 
 
 	} else if (canvas_light_shadow_owner.owns(p_rid)) {
 	} else if (canvas_light_shadow_owner.owns(p_rid)) {
 
 
-		CanvasLightShadow *cls = canvas_light_shadow_owner.get(p_rid);
+		CanvasLightShadow *cls = canvas_light_shadow_owner.getornull(p_rid);
 		glDeleteFramebuffers(1, &cls->fbo);
 		glDeleteFramebuffers(1, &cls->fbo);
 		glDeleteRenderbuffers(1, &cls->depth);
 		glDeleteRenderbuffers(1, &cls->depth);
 		glDeleteTextures(1, &cls->distance);
 		glDeleteTextures(1, &cls->distance);

+ 24 - 23
drivers/gles2/rasterizer_storage_gles2.h

@@ -38,6 +38,7 @@
 #include "shader_compiler_gles2.h"
 #include "shader_compiler_gles2.h"
 #include "shader_gles2.h"
 #include "shader_gles2.h"
 
 
+#include "core/rid_owner.h"
 #include "shaders/copy.glsl.gen.h"
 #include "shaders/copy.glsl.gen.h"
 #include "shaders/cubemap_filter.glsl.gen.h"
 #include "shaders/cubemap_filter.glsl.gen.h"
 /*
 /*
@@ -179,7 +180,7 @@ public:
 	//////////////////////////////////DATA///////////////////////////////////////////////////
 	//////////////////////////////////DATA///////////////////////////////////////////////////
 	/////////////////////////////////////////////////////////////////////////////////////////
 	/////////////////////////////////////////////////////////////////////////////////////////
 
 
-	struct Instantiable : public RID_Data {
+	struct Instantiable {
 		SelfList<RasterizerScene::InstanceBase>::List instance_list;
 		SelfList<RasterizerScene::InstanceBase>::List instance_list;
 
 
 		_FORCE_INLINE_ void instance_change_notify(bool p_aabb, bool p_materials) {
 		_FORCE_INLINE_ void instance_change_notify(bool p_aabb, bool p_materials) {
@@ -239,7 +240,7 @@ public:
 
 
 	struct RenderTarget;
 	struct RenderTarget;
 
 
-	struct Texture : RID_Data {
+	struct Texture {
 
 
 		Texture *proxy;
 		Texture *proxy;
 		Set<Texture *> proxy_owners;
 		Set<Texture *> proxy_owners;
@@ -340,7 +341,7 @@ public:
 		}
 		}
 	};
 	};
 
 
-	mutable RID_Owner<Texture> texture_owner;
+	mutable RID_PtrOwner<Texture> texture_owner;
 
 
 	Ref<Image> _get_gl_image_and_format(const Ref<Image> &p_image, Image::Format p_format, uint32_t p_flags, Image::Format &r_real_format, GLenum &r_gl_format, GLenum &r_gl_internal_format, GLenum &r_gl_type, bool &r_compressed, bool p_force_decompress) const;
 	Ref<Image> _get_gl_image_and_format(const Ref<Image> &p_image, Image::Format p_format, uint32_t p_flags, Image::Format &r_real_format, GLenum &r_gl_format, GLenum &r_gl_internal_format, GLenum &r_gl_type, bool &r_compressed, bool p_force_decompress) const;
 
 
@@ -382,14 +383,14 @@ public:
 
 
 	/* SKY API */
 	/* SKY API */
 
 
-	struct Sky : public RID_Data {
+	struct Sky {
 
 
 		RID panorama;
 		RID panorama;
 		GLuint radiance;
 		GLuint radiance;
 		int radiance_size;
 		int radiance_size;
 	};
 	};
 
 
-	mutable RID_Owner<Sky> sky_owner;
+	mutable RID_PtrOwner<Sky> sky_owner;
 
 
 	virtual RID sky_create();
 	virtual RID sky_create();
 	virtual void sky_set_texture(RID p_sky, RID p_panorama, int p_radiance_size);
 	virtual void sky_set_texture(RID p_sky, RID p_panorama, int p_radiance_size);
@@ -398,7 +399,7 @@ public:
 
 
 	struct Material;
 	struct Material;
 
 
-	struct Shader : public RID_Data {
+	struct Shader {
 
 
 		RID self;
 		RID self;
 
 
@@ -516,7 +517,7 @@ public:
 		}
 		}
 	};
 	};
 
 
-	mutable RID_Owner<Shader> shader_owner;
+	mutable RID_PtrOwner<Shader> shader_owner;
 	mutable SelfList<Shader>::List _shader_dirty_list;
 	mutable SelfList<Shader>::List _shader_dirty_list;
 
 
 	void _shader_make_dirty(Shader *p_shader);
 	void _shader_make_dirty(Shader *p_shader);
@@ -535,7 +536,7 @@ public:
 
 
 	/* COMMON MATERIAL API */
 	/* COMMON MATERIAL API */
 
 
-	struct Material : public RID_Data {
+	struct Material {
 
 
 		Shader *shader;
 		Shader *shader;
 		Map<StringName, Variant> params;
 		Map<StringName, Variant> params;
@@ -576,7 +577,7 @@ public:
 
 
 	void _update_material(Material *p_material);
 	void _update_material(Material *p_material);
 
 
-	mutable RID_Owner<Material> material_owner;
+	mutable RID_PtrOwner<Material> material_owner;
 
 
 	virtual RID material_create();
 	virtual RID material_create();
 
 
@@ -698,7 +699,7 @@ public:
 		}
 		}
 	};
 	};
 
 
-	mutable RID_Owner<Mesh> mesh_owner;
+	mutable RID_PtrOwner<Mesh> mesh_owner;
 
 
 	virtual RID mesh_create();
 	virtual RID mesh_create();
 
 
@@ -780,7 +781,7 @@ public:
 		}
 		}
 	};
 	};
 
 
-	mutable RID_Owner<MultiMesh> multimesh_owner;
+	mutable RID_PtrOwner<MultiMesh> multimesh_owner;
 
 
 	SelfList<MultiMesh>::List multimesh_update_list;
 	SelfList<MultiMesh>::List multimesh_update_list;
 
 
@@ -843,7 +844,7 @@ public:
 	Vector2 chunk_uv;
 	Vector2 chunk_uv;
 	Vector2 chunk_uv2;
 	Vector2 chunk_uv2;
 
 
-	mutable RID_Owner<Immediate> immediate_owner;
+	mutable RID_PtrOwner<Immediate> immediate_owner;
 
 
 	virtual RID immediate_create();
 	virtual RID immediate_create();
 	virtual void immediate_begin(RID p_immediate, VS::PrimitiveType p_primitive, RID p_texture = RID());
 	virtual void immediate_begin(RID p_immediate, VS::PrimitiveType p_primitive, RID p_texture = RID());
@@ -861,7 +862,7 @@ public:
 
 
 	/* SKELETON API */
 	/* SKELETON API */
 
 
-	struct Skeleton : RID_Data {
+	struct Skeleton {
 
 
 		bool use_2d;
 		bool use_2d;
 
 
@@ -886,7 +887,7 @@ public:
 		}
 		}
 	};
 	};
 
 
-	mutable RID_Owner<Skeleton> skeleton_owner;
+	mutable RID_PtrOwner<Skeleton> skeleton_owner;
 
 
 	SelfList<Skeleton>::List skeleton_update_list;
 	SelfList<Skeleton>::List skeleton_update_list;
 
 
@@ -932,7 +933,7 @@ public:
 		uint64_t version;
 		uint64_t version;
 	};
 	};
 
 
-	mutable RID_Owner<Light> light_owner;
+	mutable RID_PtrOwner<Light> light_owner;
 
 
 	virtual RID light_create(VS::LightType p_type);
 	virtual RID light_create(VS::LightType p_type);
 
 
@@ -988,7 +989,7 @@ public:
 		int resolution;
 		int resolution;
 	};
 	};
 
 
-	mutable RID_Owner<ReflectionProbe> reflection_probe_owner;
+	mutable RID_PtrOwner<ReflectionProbe> reflection_probe_owner;
 
 
 	virtual RID reflection_probe_create();
 	virtual RID reflection_probe_create();
 
 
@@ -1074,7 +1075,7 @@ public:
 		}
 		}
 	};
 	};
 
 
-	mutable RID_Owner<LightmapCapture> lightmap_capture_data_owner;
+	mutable RID_PtrOwner<LightmapCapture> lightmap_capture_data_owner;
 
 
 	virtual RID lightmap_capture_create();
 	virtual RID lightmap_capture_create();
 	virtual void lightmap_capture_set_bounds(RID p_capture, const AABB &p_bounds);
 	virtual void lightmap_capture_set_bounds(RID p_capture, const AABB &p_bounds);
@@ -1137,7 +1138,7 @@ public:
 
 
 	/* RENDER TARGET */
 	/* RENDER TARGET */
 
 
-	struct RenderTarget : public RID_Data {
+	struct RenderTarget {
 		GLuint fbo;
 		GLuint fbo;
 		GLuint color;
 		GLuint color;
 		GLuint depth;
 		GLuint depth;
@@ -1233,7 +1234,7 @@ public:
 		}
 		}
 	};
 	};
 
 
-	mutable RID_Owner<RenderTarget> render_target_owner;
+	mutable RID_PtrOwner<RenderTarget> render_target_owner;
 
 
 	void _render_target_clear(RenderTarget *rt);
 	void _render_target_clear(RenderTarget *rt);
 	void _render_target_allocate(RenderTarget *rt);
 	void _render_target_allocate(RenderTarget *rt);
@@ -1251,7 +1252,7 @@ public:
 
 
 	/* CANVAS SHADOW */
 	/* CANVAS SHADOW */
 
 
-	struct CanvasLightShadow : public RID_Data {
+	struct CanvasLightShadow {
 
 
 		int size;
 		int size;
 		int height;
 		int height;
@@ -1260,13 +1261,13 @@ public:
 		GLuint distance; //for older devices
 		GLuint distance; //for older devices
 	};
 	};
 
 
-	RID_Owner<CanvasLightShadow> canvas_light_shadow_owner;
+	RID_PtrOwner<CanvasLightShadow> canvas_light_shadow_owner;
 
 
 	virtual RID canvas_light_shadow_buffer_create(int p_width);
 	virtual RID canvas_light_shadow_buffer_create(int p_width);
 
 
 	/* LIGHT SHADOW MAPPING */
 	/* LIGHT SHADOW MAPPING */
 
 
-	struct CanvasOccluder : public RID_Data {
+	struct CanvasOccluder {
 
 
 		GLuint vertex_id; // 0 means, unconfigured
 		GLuint vertex_id; // 0 means, unconfigured
 		GLuint index_id; // 0 means, unconfigured
 		GLuint index_id; // 0 means, unconfigured
@@ -1274,7 +1275,7 @@ public:
 		int len;
 		int len;
 	};
 	};
 
 
-	RID_Owner<CanvasOccluder> canvas_occluder_owner;
+	RID_PtrOwner<CanvasOccluder> canvas_occluder_owner;
 
 
 	virtual RID canvas_light_occluder_create();
 	virtual RID canvas_light_occluder_create();
 	virtual void canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector<Vector2> &p_lines);
 	virtual void canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector<Vector2> &p_lines);

+ 7 - 5
drivers/gles3/rasterizer_canvas_gles3.cpp

@@ -1402,7 +1402,7 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, cons
 		{
 		{
 			//skeleton handling
 			//skeleton handling
 			if (ci->skeleton.is_valid() && storage->skeleton_owner.owns(ci->skeleton)) {
 			if (ci->skeleton.is_valid() && storage->skeleton_owner.owns(ci->skeleton)) {
-				skeleton = storage->skeleton_owner.get(ci->skeleton);
+				skeleton = storage->skeleton_owner.getornull(ci->skeleton);
 				if (!skeleton->use_2d) {
 				if (!skeleton->use_2d) {
 					skeleton = NULL;
 					skeleton = NULL;
 				} else {
 				} else {
@@ -1697,11 +1697,13 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, cons
 						}
 						}
 					}
 					}
 
 
-					glBindBufferBase(GL_UNIFORM_BUFFER, 1, static_cast<LightInternal *>(light->light_internal.get_data())->ubo);
+					LightInternal *light_internal = light_internal_owner.getornull(light->light_internal);
+
+					glBindBufferBase(GL_UNIFORM_BUFFER, 1, light_internal->ubo);
 
 
 					if (has_shadow) {
 					if (has_shadow) {
 
 
-						RasterizerStorageGLES3::CanvasLightShadow *cls = storage->canvas_light_shadow_owner.get(light->shadow_buffer);
+						RasterizerStorageGLES3::CanvasLightShadow *cls = storage->canvas_light_shadow_owner.getornull(light->shadow_buffer);
 						glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 2);
 						glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 2);
 						glBindTexture(GL_TEXTURE_2D, cls->distance);
 						glBindTexture(GL_TEXTURE_2D, cls->distance);
 
 
@@ -1807,7 +1809,7 @@ void RasterizerCanvasGLES3::canvas_debug_viewport_shadows(Light *p_lights_with_s
 	while (light) {
 	while (light) {
 		if (light->shadow_buffer.is_valid()) {
 		if (light->shadow_buffer.is_valid()) {
 
 
-			RasterizerStorageGLES3::CanvasLightShadow *sb = storage->canvas_light_shadow_owner.get(light->shadow_buffer);
+			RasterizerStorageGLES3::CanvasLightShadow *sb = storage->canvas_light_shadow_owner.getornull(light->shadow_buffer);
 			if (sb) {
 			if (sb) {
 				glBindTexture(GL_TEXTURE_2D, sb->distance);
 				glBindTexture(GL_TEXTURE_2D, sb->distance);
 				draw_generic_textured_rect(Rect2(h, ofs, w - h * 2, h), Rect2(0, 0, 1, 1));
 				draw_generic_textured_rect(Rect2(h, ofs, w - h * 2, h), Rect2(0, 0, 1, 1));
@@ -1823,7 +1825,7 @@ void RasterizerCanvasGLES3::canvas_debug_viewport_shadows(Light *p_lights_with_s
 
 
 void RasterizerCanvasGLES3::canvas_light_shadow_buffer_update(RID p_buffer, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders, CameraMatrix *p_xform_cache) {
 void RasterizerCanvasGLES3::canvas_light_shadow_buffer_update(RID p_buffer, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders, CameraMatrix *p_xform_cache) {
 
 
-	RasterizerStorageGLES3::CanvasLightShadow *cls = storage->canvas_light_shadow_owner.get(p_buffer);
+	RasterizerStorageGLES3::CanvasLightShadow *cls = storage->canvas_light_shadow_owner.getornull(p_buffer);
 	ERR_FAIL_COND(!cls);
 	ERR_FAIL_COND(!cls);
 
 
 	glDisable(GL_BLEND);
 	glDisable(GL_BLEND);

+ 2 - 2
drivers/gles3/rasterizer_canvas_gles3.h

@@ -96,7 +96,7 @@ public:
 
 
 	RasterizerStorageGLES3 *storage;
 	RasterizerStorageGLES3 *storage;
 
 
-	struct LightInternal : public RID_Data {
+	struct LightInternal {
 
 
 		struct UBOData {
 		struct UBOData {
 
 
@@ -117,7 +117,7 @@ public:
 		GLuint ubo;
 		GLuint ubo;
 	};
 	};
 
 
-	RID_Owner<LightInternal> light_internal_owner;
+	RID_PtrOwner<LightInternal> light_internal_owner;
 
 
 	virtual RID light_internal_create();
 	virtual RID light_internal_create();
 	virtual void light_internal_update(RID p_rid, Light *p_light);
 	virtual void light_internal_update(RID p_rid, Light *p_light);

+ 1 - 1
drivers/gles3/rasterizer_gles3.cpp

@@ -320,7 +320,7 @@ void RasterizerGLES3::set_boot_image(const Ref<Image> &p_image, const Color &p_c
 		screenrect.position += ((Size2(window_w, window_h) - screenrect.size) / 2.0).floor();
 		screenrect.position += ((Size2(window_w, window_h) - screenrect.size) / 2.0).floor();
 	}
 	}
 
 
-	RasterizerStorageGLES3::Texture *t = storage->texture_owner.get(texture);
+	RasterizerStorageGLES3::Texture *t = storage->texture_owner.getornull(texture);
 	glActiveTexture(GL_TEXTURE0);
 	glActiveTexture(GL_TEXTURE0);
 	glBindTexture(GL_TEXTURE_2D, t->tex_id);
 	glBindTexture(GL_TEXTURE_2D, t->tex_id);
 	canvas->draw_generic_textured_rect(screenrect, Rect2(0, 0, 1, 1));
 	canvas->draw_generic_textured_rect(screenrect, Rect2(0, 0, 1, 1));

+ 39 - 39
drivers/gles3/rasterizer_scene_gles3.cpp

@@ -351,7 +351,7 @@ bool RasterizerSceneGLES3::shadow_atlas_update_light(RID p_atlas, RID p_light_in
 			if (sh->owner.is_valid()) {
 			if (sh->owner.is_valid()) {
 				//is taken, but is invalid, erasing it
 				//is taken, but is invalid, erasing it
 				shadow_atlas->shadow_owners.erase(sh->owner);
 				shadow_atlas->shadow_owners.erase(sh->owner);
-				LightInstance *sli = light_instance_owner.get(sh->owner);
+				LightInstance *sli = light_instance_owner.getornull(sh->owner);
 				sli->shadow_atlases.erase(p_atlas);
 				sli->shadow_atlases.erase(p_atlas);
 			}
 			}
 
 
@@ -391,7 +391,7 @@ bool RasterizerSceneGLES3::shadow_atlas_update_light(RID p_atlas, RID p_light_in
 		if (sh->owner.is_valid()) {
 		if (sh->owner.is_valid()) {
 			//is taken, but is invalid, erasing it
 			//is taken, but is invalid, erasing it
 			shadow_atlas->shadow_owners.erase(sh->owner);
 			shadow_atlas->shadow_owners.erase(sh->owner);
-			LightInstance *sli = light_instance_owner.get(sh->owner);
+			LightInstance *sli = light_instance_owner.getornull(sh->owner);
 			sli->shadow_atlases.erase(p_atlas);
 			sli->shadow_atlases.erase(p_atlas);
 		}
 		}
 
 
@@ -1170,7 +1170,7 @@ bool RasterizerSceneGLES3::_setup_material(RasterizerStorageGLES3::Material *p_m
 		GLenum target = GL_TEXTURE_2D;
 		GLenum target = GL_TEXTURE_2D;
 		GLuint tex = 0;
 		GLuint tex = 0;
 
 
-		RasterizerStorageGLES3::Texture *t = storage->texture_owner.getptr(textures[i]);
+		RasterizerStorageGLES3::Texture *t = storage->texture_owner.getornull(textures[i]);
 
 
 		if (t) {
 		if (t) {
 
 
@@ -1606,7 +1606,7 @@ void RasterizerSceneGLES3::_render_geometry(RenderList::Element *e) {
 
 
 				if (c.texture.is_valid() && storage->texture_owner.owns(c.texture)) {
 				if (c.texture.is_valid() && storage->texture_owner.owns(c.texture)) {
 
 
-					RasterizerStorageGLES3::Texture *t = storage->texture_owner.get(c.texture);
+					RasterizerStorageGLES3::Texture *t = storage->texture_owner.getornull(c.texture);
 
 
 					if (t->redraw_if_visible) {
 					if (t->redraw_if_visible) {
 						VisualServerRaster::redraw_request();
 						VisualServerRaster::redraw_request();
@@ -1884,7 +1884,7 @@ void RasterizerSceneGLES3::_setup_light(RenderList::Element *e, const Transform
 		const RID *reflections = e->instance->reflection_probe_instances.ptr();
 		const RID *reflections = e->instance->reflection_probe_instances.ptr();
 
 
 		for (int i = 0; i < rc; i++) {
 		for (int i = 0; i < rc; i++) {
-			ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getptr(reflections[i]);
+			ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(reflections[i]);
 			if (rpi->last_pass != render_pass) //not visible
 			if (rpi->last_pass != render_pass) //not visible
 				continue;
 				continue;
 
 
@@ -1903,7 +1903,7 @@ void RasterizerSceneGLES3::_setup_light(RenderList::Element *e, const Transform
 	if (gi_probe_count) {
 	if (gi_probe_count) {
 		const RID *ridp = e->instance->gi_probe_instances.ptr();
 		const RID *ridp = e->instance->gi_probe_instances.ptr();
 
 
-		GIProbeInstance *gipi = gi_probe_instance_owner.getptr(ridp[0]);
+		GIProbeInstance *gipi = gi_probe_instance_owner.getornull(ridp[0]);
 
 
 		float bias_scale = e->instance->baked_light ? 1 : 0;
 		float bias_scale = e->instance->baked_light ? 1 : 0;
 		glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 9);
 		glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 9);
@@ -1917,7 +1917,7 @@ void RasterizerSceneGLES3::_setup_light(RenderList::Element *e, const Transform
 		state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_CELL_SIZE1, gipi->cell_size_cache);
 		state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE_CELL_SIZE1, gipi->cell_size_cache);
 		if (gi_probe_count > 1) {
 		if (gi_probe_count > 1) {
 
 
-			GIProbeInstance *gipi2 = gi_probe_instance_owner.getptr(ridp[1]);
+			GIProbeInstance *gipi2 = gi_probe_instance_owner.getornull(ridp[1]);
 
 
 			glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 10);
 			glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 10);
 			glBindTexture(GL_TEXTURE_3D, gipi2->tex_cache);
 			glBindTexture(GL_TEXTURE_3D, gipi2->tex_cache);
@@ -2286,7 +2286,7 @@ void RasterizerSceneGLES3::_add_geometry(RasterizerStorageGLES3::Geometry *p_geo
 	}
 	}
 
 
 	if (!m) {
 	if (!m) {
-		m = storage->material_owner.getptr(default_material);
+		m = storage->material_owner.getornull(default_material);
 	}
 	}
 
 
 	ERR_FAIL_COND(!m);
 	ERR_FAIL_COND(!m);
@@ -2337,11 +2337,11 @@ void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::G
 		if (!p_material->shader->spatial.uses_alpha_scissor && !p_material->shader->spatial.writes_modelview_or_projection && !p_material->shader->spatial.uses_vertex && !p_material->shader->spatial.uses_discard && p_material->shader->spatial.depth_draw_mode != RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS) {
 		if (!p_material->shader->spatial.uses_alpha_scissor && !p_material->shader->spatial.writes_modelview_or_projection && !p_material->shader->spatial.uses_vertex && !p_material->shader->spatial.uses_discard && p_material->shader->spatial.depth_draw_mode != RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS) {
 			//shader does not use discard and does not write a vertex position, use generic material
 			//shader does not use discard and does not write a vertex position, use generic material
 			if (p_instance->cast_shadows == VS::SHADOW_CASTING_SETTING_DOUBLE_SIDED) {
 			if (p_instance->cast_shadows == VS::SHADOW_CASTING_SETTING_DOUBLE_SIDED) {
-				p_material = storage->material_owner.getptr(!p_shadow_pass && p_material->shader->spatial.uses_world_coordinates ? default_worldcoord_material_twosided : default_material_twosided);
+				p_material = storage->material_owner.getornull(!p_shadow_pass && p_material->shader->spatial.uses_world_coordinates ? default_worldcoord_material_twosided : default_material_twosided);
 				no_cull = true;
 				no_cull = true;
 				mirror = false;
 				mirror = false;
 			} else {
 			} else {
-				p_material = storage->material_owner.getptr(!p_shadow_pass && p_material->shader->spatial.uses_world_coordinates ? default_worldcoord_material : default_material);
+				p_material = storage->material_owner.getornull(!p_shadow_pass && p_material->shader->spatial.uses_world_coordinates ? default_worldcoord_material : default_material);
 			}
 			}
 		}
 		}
 
 
@@ -2792,7 +2792,7 @@ void RasterizerSceneGLES3::_setup_lights(RID *p_light_cull_result, int p_light_c
 
 
 		ERR_BREAK(i >= render_list.max_lights);
 		ERR_BREAK(i >= render_list.max_lights);
 
 
-		LightInstance *li = light_instance_owner.getptr(p_light_cull_result[i]);
+		LightInstance *li = light_instance_owner.getornull(p_light_cull_result[i]);
 
 
 		LightDataUBO ubo_data; //used for filling
 		LightDataUBO ubo_data; //used for filling
 
 
@@ -3142,7 +3142,7 @@ void RasterizerSceneGLES3::_fill_render_list(InstanceBase **p_cull_result, int p
 
 
 			case VS::INSTANCE_MESH: {
 			case VS::INSTANCE_MESH: {
 
 
-				RasterizerStorageGLES3::Mesh *mesh = storage->mesh_owner.getptr(inst->base);
+				RasterizerStorageGLES3::Mesh *mesh = storage->mesh_owner.getornull(inst->base);
 				ERR_CONTINUE(!mesh);
 				ERR_CONTINUE(!mesh);
 
 
 				int ssize = mesh->surfaces.size();
 				int ssize = mesh->surfaces.size();
@@ -3159,13 +3159,13 @@ void RasterizerSceneGLES3::_fill_render_list(InstanceBase **p_cull_result, int p
 			} break;
 			} break;
 			case VS::INSTANCE_MULTIMESH: {
 			case VS::INSTANCE_MULTIMESH: {
 
 
-				RasterizerStorageGLES3::MultiMesh *multi_mesh = storage->multimesh_owner.getptr(inst->base);
+				RasterizerStorageGLES3::MultiMesh *multi_mesh = storage->multimesh_owner.getornull(inst->base);
 				ERR_CONTINUE(!multi_mesh);
 				ERR_CONTINUE(!multi_mesh);
 
 
 				if (multi_mesh->size == 0 || multi_mesh->visible_instances == 0)
 				if (multi_mesh->size == 0 || multi_mesh->visible_instances == 0)
 					continue;
 					continue;
 
 
-				RasterizerStorageGLES3::Mesh *mesh = storage->mesh_owner.getptr(multi_mesh->mesh);
+				RasterizerStorageGLES3::Mesh *mesh = storage->mesh_owner.getornull(multi_mesh->mesh);
 				if (!mesh)
 				if (!mesh)
 					continue; //mesh not assigned
 					continue; //mesh not assigned
 
 
@@ -3180,7 +3180,7 @@ void RasterizerSceneGLES3::_fill_render_list(InstanceBase **p_cull_result, int p
 			} break;
 			} break;
 			case VS::INSTANCE_IMMEDIATE: {
 			case VS::INSTANCE_IMMEDIATE: {
 
 
-				RasterizerStorageGLES3::Immediate *immediate = storage->immediate_owner.getptr(inst->base);
+				RasterizerStorageGLES3::Immediate *immediate = storage->immediate_owner.getornull(inst->base);
 				ERR_CONTINUE(!immediate);
 				ERR_CONTINUE(!immediate);
 
 
 				_add_geometry(immediate, inst, NULL, -1, p_depth_pass, p_shadow_pass);
 				_add_geometry(immediate, inst, NULL, -1, p_depth_pass, p_shadow_pass);
@@ -3188,7 +3188,7 @@ void RasterizerSceneGLES3::_fill_render_list(InstanceBase **p_cull_result, int p
 			} break;
 			} break;
 			case VS::INSTANCE_PARTICLES: {
 			case VS::INSTANCE_PARTICLES: {
 
 
-				RasterizerStorageGLES3::Particles *particles = storage->particles_owner.getptr(inst->base);
+				RasterizerStorageGLES3::Particles *particles = storage->particles_owner.getornull(inst->base);
 				ERR_CONTINUE(!particles);
 				ERR_CONTINUE(!particles);
 
 
 				for (int j = 0; j < particles->draw_passes.size(); j++) {
 				for (int j = 0; j < particles->draw_passes.size(); j++) {
@@ -3196,7 +3196,7 @@ void RasterizerSceneGLES3::_fill_render_list(InstanceBase **p_cull_result, int p
 					RID pmesh = particles->draw_passes[j];
 					RID pmesh = particles->draw_passes[j];
 					if (!pmesh.is_valid())
 					if (!pmesh.is_valid())
 						continue;
 						continue;
-					RasterizerStorageGLES3::Mesh *mesh = storage->mesh_owner.get(pmesh);
+					RasterizerStorageGLES3::Mesh *mesh = storage->mesh_owner.getornull(pmesh);
 					if (!mesh)
 					if (!mesh)
 						continue; //mesh not assigned
 						continue; //mesh not assigned
 
 
@@ -4155,7 +4155,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
 
 
 		ERR_BREAK(i >= render_list.max_lights);
 		ERR_BREAK(i >= render_list.max_lights);
 
 
-		LightInstance *li = light_instance_owner.getptr(p_light_cull_result[i]);
+		LightInstance *li = light_instance_owner.getornull(p_light_cull_result[i]);
 		if (li->light_ptr->param[VS::LIGHT_PARAM_CONTACT_SHADOW_SIZE] > CMP_EPSILON) {
 		if (li->light_ptr->param[VS::LIGHT_PARAM_CONTACT_SHADOW_SIZE] > CMP_EPSILON) {
 			state.used_contact_shadows = true;
 			state.used_contact_shadows = true;
 		}
 		}
@@ -4229,7 +4229,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
 
 
 	if (probe) {
 	if (probe) {
 
 
-		ReflectionAtlas *ref_atlas = reflection_atlas_owner.getptr(probe->atlas);
+		ReflectionAtlas *ref_atlas = reflection_atlas_owner.getornull(probe->atlas);
 		ERR_FAIL_COND(!ref_atlas);
 		ERR_FAIL_COND(!ref_atlas);
 
 
 		int target_size = ref_atlas->size / ref_atlas->subdiv;
 		int target_size = ref_atlas->size / ref_atlas->subdiv;
@@ -4914,11 +4914,11 @@ bool RasterizerSceneGLES3::free(RID p_rid) {
 
 
 	if (light_instance_owner.owns(p_rid)) {
 	if (light_instance_owner.owns(p_rid)) {
 
 
-		LightInstance *light_instance = light_instance_owner.getptr(p_rid);
+		LightInstance *light_instance = light_instance_owner.getornull(p_rid);
 
 
 		//remove from shadow atlases..
 		//remove from shadow atlases..
 		for (Set<RID>::Element *E = light_instance->shadow_atlases.front(); E; E = E->next()) {
 		for (Set<RID>::Element *E = light_instance->shadow_atlases.front(); E; E = E->next()) {
-			ShadowAtlas *shadow_atlas = shadow_atlas_owner.get(E->get());
+			ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(E->get());
 			ERR_CONTINUE(!shadow_atlas->shadow_owners.has(p_rid));
 			ERR_CONTINUE(!shadow_atlas->shadow_owners.has(p_rid));
 			uint32_t key = shadow_atlas->shadow_owners[p_rid];
 			uint32_t key = shadow_atlas->shadow_owners[p_rid];
 			uint32_t q = (key >> ShadowAtlas::QUADRANT_SHIFT) & 0x3;
 			uint32_t q = (key >> ShadowAtlas::QUADRANT_SHIFT) & 0x3;
@@ -4933,19 +4933,19 @@ bool RasterizerSceneGLES3::free(RID p_rid) {
 
 
 	} else if (shadow_atlas_owner.owns(p_rid)) {
 	} else if (shadow_atlas_owner.owns(p_rid)) {
 
 
-		ShadowAtlas *shadow_atlas = shadow_atlas_owner.get(p_rid);
+		ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_rid);
 		shadow_atlas_set_size(p_rid, 0);
 		shadow_atlas_set_size(p_rid, 0);
 		shadow_atlas_owner.free(p_rid);
 		shadow_atlas_owner.free(p_rid);
 		memdelete(shadow_atlas);
 		memdelete(shadow_atlas);
 	} else if (reflection_atlas_owner.owns(p_rid)) {
 	} else if (reflection_atlas_owner.owns(p_rid)) {
 
 
-		ReflectionAtlas *reflection_atlas = reflection_atlas_owner.get(p_rid);
+		ReflectionAtlas *reflection_atlas = reflection_atlas_owner.getornull(p_rid);
 		reflection_atlas_set_size(p_rid, 0);
 		reflection_atlas_set_size(p_rid, 0);
 		reflection_atlas_owner.free(p_rid);
 		reflection_atlas_owner.free(p_rid);
 		memdelete(reflection_atlas);
 		memdelete(reflection_atlas);
 	} else if (reflection_probe_instance_owner.owns(p_rid)) {
 	} else if (reflection_probe_instance_owner.owns(p_rid)) {
 
 
-		ReflectionProbeInstance *reflection_instance = reflection_probe_instance_owner.get(p_rid);
+		ReflectionProbeInstance *reflection_instance = reflection_probe_instance_owner.getornull(p_rid);
 
 
 		reflection_probe_release_atlas_index(p_rid);
 		reflection_probe_release_atlas_index(p_rid);
 		reflection_probe_instance_owner.free(p_rid);
 		reflection_probe_instance_owner.free(p_rid);
@@ -4953,14 +4953,14 @@ bool RasterizerSceneGLES3::free(RID p_rid) {
 
 
 	} else if (environment_owner.owns(p_rid)) {
 	} else if (environment_owner.owns(p_rid)) {
 
 
-		Environment *environment = environment_owner.get(p_rid);
+		Environment *environment = environment_owner.getornull(p_rid);
 
 
 		environment_owner.free(p_rid);
 		environment_owner.free(p_rid);
 		memdelete(environment);
 		memdelete(environment);
 
 
 	} else if (gi_probe_instance_owner.owns(p_rid)) {
 	} else if (gi_probe_instance_owner.owns(p_rid)) {
 
 
-		GIProbeInstance *gi_probe_instance = gi_probe_instance_owner.get(p_rid);
+		GIProbeInstance *gi_probe_instance = gi_probe_instance_owner.getornull(p_rid);
 
 
 		gi_probe_instance_owner.free(p_rid);
 		gi_probe_instance_owner.free(p_rid);
 		memdelete(gi_probe_instance);
 		memdelete(gi_probe_instance);
@@ -5320,6 +5320,19 @@ void RasterizerSceneGLES3::iteration() {
 }
 }
 
 
 void RasterizerSceneGLES3::finalize() {
 void RasterizerSceneGLES3::finalize() {
+
+	storage->free(default_material);
+	storage->free(default_material_twosided);
+	storage->free(default_shader);
+	storage->free(default_shader_twosided);
+
+	storage->free(default_worldcoord_material);
+	storage->free(default_worldcoord_material_twosided);
+	storage->free(default_worldcoord_shader);
+	storage->free(default_worldcoord_shader_twosided);
+
+	storage->free(default_overdraw_material);
+	storage->free(default_overdraw_shader);
 }
 }
 
 
 RasterizerSceneGLES3::RasterizerSceneGLES3() {
 RasterizerSceneGLES3::RasterizerSceneGLES3() {
@@ -5327,19 +5340,6 @@ RasterizerSceneGLES3::RasterizerSceneGLES3() {
 
 
 RasterizerSceneGLES3::~RasterizerSceneGLES3() {
 RasterizerSceneGLES3::~RasterizerSceneGLES3() {
 
 
-	memdelete(default_material.get_data());
-	memdelete(default_material_twosided.get_data());
-	memdelete(default_shader.get_data());
-	memdelete(default_shader_twosided.get_data());
-
-	memdelete(default_worldcoord_material.get_data());
-	memdelete(default_worldcoord_material_twosided.get_data());
-	memdelete(default_worldcoord_shader.get_data());
-	memdelete(default_worldcoord_shader_twosided.get_data());
-
-	memdelete(default_overdraw_material.get_data());
-	memdelete(default_overdraw_shader.get_data());
-
 	memfree(state.spot_array_tmp);
 	memfree(state.spot_array_tmp);
 	memfree(state.omni_array_tmp);
 	memfree(state.omni_array_tmp);
 	memfree(state.reflection_array_tmp);
 	memfree(state.reflection_array_tmp);

+ 12 - 12
drivers/gles3/rasterizer_scene_gles3.h

@@ -216,7 +216,7 @@ public:
 
 
 	/* SHADOW ATLAS API */
 	/* SHADOW ATLAS API */
 
 
-	struct ShadowAtlas : public RID_Data {
+	struct ShadowAtlas  {
 
 
 		enum {
 		enum {
 			QUADRANT_SHIFT = 27,
 			QUADRANT_SHIFT = 27,
@@ -267,7 +267,7 @@ public:
 
 
 	Vector<ShadowCubeMap> shadow_cubemaps;
 	Vector<ShadowCubeMap> shadow_cubemaps;
 
 
-	RID_Owner<ShadowAtlas> shadow_atlas_owner;
+	RID_PtrOwner<ShadowAtlas> shadow_atlas_owner;
 
 
 	RID shadow_atlas_create();
 	RID shadow_atlas_create();
 	void shadow_atlas_set_size(RID p_atlas, int p_size);
 	void shadow_atlas_set_size(RID p_atlas, int p_size);
@@ -288,7 +288,7 @@ public:
 
 
 	/* REFLECTION PROBE ATLAS API */
 	/* REFLECTION PROBE ATLAS API */
 
 
-	struct ReflectionAtlas : public RID_Data {
+	struct ReflectionAtlas  {
 
 
 		int subdiv;
 		int subdiv;
 		int size;
 		int size;
@@ -304,7 +304,7 @@ public:
 		Vector<Reflection> reflections;
 		Vector<Reflection> reflections;
 	};
 	};
 
 
-	mutable RID_Owner<ReflectionAtlas> reflection_atlas_owner;
+	mutable RID_PtrOwner<ReflectionAtlas> reflection_atlas_owner;
 
 
 	virtual RID reflection_atlas_create();
 	virtual RID reflection_atlas_create();
 	virtual void reflection_atlas_set_size(RID p_ref_atlas, int p_size);
 	virtual void reflection_atlas_set_size(RID p_ref_atlas, int p_size);
@@ -324,7 +324,7 @@ public:
 
 
 	/* REFLECTION PROBE INSTANCE */
 	/* REFLECTION PROBE INSTANCE */
 
 
-	struct ReflectionProbeInstance : public RID_Data {
+	struct ReflectionProbeInstance  {
 
 
 		RasterizerStorageGLES3::ReflectionProbe *probe_ptr;
 		RasterizerStorageGLES3::ReflectionProbe *probe_ptr;
 		RID probe;
 		RID probe;
@@ -352,7 +352,7 @@ public:
 		//notes: for ambientblend, use distance to edge to blend between already existing global environment
 		//notes: for ambientblend, use distance to edge to blend between already existing global environment
 	};
 	};
 
 
-	mutable RID_Owner<ReflectionProbeInstance> reflection_probe_instance_owner;
+	mutable RID_PtrOwner<ReflectionProbeInstance> reflection_probe_instance_owner;
 
 
 	virtual RID reflection_probe_instance_create(RID p_probe);
 	virtual RID reflection_probe_instance_create(RID p_probe);
 	virtual void reflection_probe_instance_set_transform(RID p_instance, const Transform &p_transform);
 	virtual void reflection_probe_instance_set_transform(RID p_instance, const Transform &p_transform);
@@ -364,7 +364,7 @@ public:
 
 
 	/* ENVIRONMENT API */
 	/* ENVIRONMENT API */
 
 
-	struct Environment : public RID_Data {
+	struct Environment  {
 
 
 		VS::EnvironmentBG bg_mode;
 		VS::EnvironmentBG bg_mode;
 
 
@@ -533,7 +533,7 @@ public:
 		}
 		}
 	};
 	};
 
 
-	RID_Owner<Environment> environment_owner;
+	RID_PtrOwner<Environment> environment_owner;
 
 
 	virtual RID environment_create();
 	virtual RID environment_create();
 
 
@@ -590,7 +590,7 @@ public:
 		float shadow_split_offsets[4];
 		float shadow_split_offsets[4];
 	};
 	};
 
 
-	struct LightInstance : public RID_Data {
+	struct LightInstance  {
 
 
 		struct ShadowTransform {
 		struct ShadowTransform {
 
 
@@ -630,7 +630,7 @@ public:
 		LightInstance() {}
 		LightInstance() {}
 	};
 	};
 
 
-	mutable RID_Owner<LightInstance> light_instance_owner;
+	mutable RID_PtrOwner<LightInstance> light_instance_owner;
 
 
 	virtual RID light_instance_create(RID p_light);
 	virtual RID light_instance_create(RID p_light);
 	virtual void light_instance_set_transform(RID p_light_instance, const Transform &p_transform);
 	virtual void light_instance_set_transform(RID p_light_instance, const Transform &p_transform);
@@ -639,7 +639,7 @@ public:
 
 
 	/* REFLECTION INSTANCE */
 	/* REFLECTION INSTANCE */
 
 
-	struct GIProbeInstance : public RID_Data {
+	struct GIProbeInstance  {
 		RID data;
 		RID data;
 		RasterizerStorageGLES3::GIProbe *probe;
 		RasterizerStorageGLES3::GIProbe *probe;
 		GLuint tex_cache;
 		GLuint tex_cache;
@@ -653,7 +653,7 @@ public:
 		}
 		}
 	};
 	};
 
 
-	mutable RID_Owner<GIProbeInstance> gi_probe_instance_owner;
+	mutable RID_PtrOwner<GIProbeInstance> gi_probe_instance_owner;
 
 
 	virtual RID gi_probe_instance_create();
 	virtual RID gi_probe_instance_create();
 	virtual void gi_probe_instance_set_light_data(RID p_probe, RID p_base, RID p_data);
 	virtual void gi_probe_instance_set_light_data(RID p_probe, RID p_base, RID p_data);

+ 77 - 77
drivers/gles3/rasterizer_storage_gles3.cpp

@@ -647,7 +647,7 @@ void RasterizerStorageGLES3::texture_allocate(RID p_texture, int p_width, int p_
 	}
 	}
 #endif
 #endif
 
 
-	Texture *texture = texture_owner.get(p_texture);
+	Texture *texture = texture_owner.getornull(p_texture);
 	ERR_FAIL_COND(!texture);
 	ERR_FAIL_COND(!texture);
 	texture->width = p_width;
 	texture->width = p_width;
 	texture->height = p_height;
 	texture->height = p_height;
@@ -750,7 +750,7 @@ void RasterizerStorageGLES3::texture_allocate(RID p_texture, int p_width, int p_
 
 
 void RasterizerStorageGLES3::texture_set_data(RID p_texture, const Ref<Image> &p_image, int p_layer) {
 void RasterizerStorageGLES3::texture_set_data(RID p_texture, const Ref<Image> &p_image, int p_layer) {
 
 
-	Texture *texture = texture_owner.get(p_texture);
+	Texture *texture = texture_owner.getornull(p_texture);
 
 
 	ERR_FAIL_COND(!texture);
 	ERR_FAIL_COND(!texture);
 	ERR_FAIL_COND(!texture->active);
 	ERR_FAIL_COND(!texture->active);
@@ -978,7 +978,7 @@ void RasterizerStorageGLES3::texture_set_data(RID p_texture, const Ref<Image> &p
 // TODO If we want this to be usable without pre-filling pixels with a full image, we have to call glTexImage2D() with null data.
 // TODO If we want this to be usable without pre-filling pixels with a full image, we have to call glTexImage2D() with null data.
 void RasterizerStorageGLES3::texture_set_data_partial(RID p_texture, const Ref<Image> &p_image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int p_dst_mip, int p_layer) {
 void RasterizerStorageGLES3::texture_set_data_partial(RID p_texture, const Ref<Image> &p_image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int p_dst_mip, int p_layer) {
 
 
-	Texture *texture = texture_owner.get(p_texture);
+	Texture *texture = texture_owner.getornull(p_texture);
 
 
 	ERR_FAIL_COND(!texture);
 	ERR_FAIL_COND(!texture);
 	ERR_FAIL_COND(!texture->active);
 	ERR_FAIL_COND(!texture->active);
@@ -1064,7 +1064,7 @@ void RasterizerStorageGLES3::texture_set_data_partial(RID p_texture, const Ref<I
 
 
 Ref<Image> RasterizerStorageGLES3::texture_get_data(RID p_texture, int p_layer) const {
 Ref<Image> RasterizerStorageGLES3::texture_get_data(RID p_texture, int p_layer) const {
 
 
-	Texture *texture = texture_owner.get(p_texture);
+	Texture *texture = texture_owner.getornull(p_texture);
 
 
 	ERR_FAIL_COND_V(!texture, Ref<Image>());
 	ERR_FAIL_COND_V(!texture, Ref<Image>());
 	ERR_FAIL_COND_V(!texture->active, Ref<Image>());
 	ERR_FAIL_COND_V(!texture->active, Ref<Image>());
@@ -1347,7 +1347,7 @@ Ref<Image> RasterizerStorageGLES3::texture_get_data(RID p_texture, int p_layer)
 
 
 void RasterizerStorageGLES3::texture_set_flags(RID p_texture, uint32_t p_flags) {
 void RasterizerStorageGLES3::texture_set_flags(RID p_texture, uint32_t p_flags) {
 
 
-	Texture *texture = texture_owner.get(p_texture);
+	Texture *texture = texture_owner.getornull(p_texture);
 	ERR_FAIL_COND(!texture);
 	ERR_FAIL_COND(!texture);
 	if (texture->render_target) {
 	if (texture->render_target) {
 
 
@@ -1423,7 +1423,7 @@ void RasterizerStorageGLES3::texture_set_flags(RID p_texture, uint32_t p_flags)
 }
 }
 uint32_t RasterizerStorageGLES3::texture_get_flags(RID p_texture) const {
 uint32_t RasterizerStorageGLES3::texture_get_flags(RID p_texture) const {
 
 
-	Texture *texture = texture_owner.get(p_texture);
+	Texture *texture = texture_owner.getornull(p_texture);
 
 
 	ERR_FAIL_COND_V(!texture, 0);
 	ERR_FAIL_COND_V(!texture, 0);
 
 
@@ -1431,7 +1431,7 @@ uint32_t RasterizerStorageGLES3::texture_get_flags(RID p_texture) const {
 }
 }
 Image::Format RasterizerStorageGLES3::texture_get_format(RID p_texture) const {
 Image::Format RasterizerStorageGLES3::texture_get_format(RID p_texture) const {
 
 
-	Texture *texture = texture_owner.get(p_texture);
+	Texture *texture = texture_owner.getornull(p_texture);
 
 
 	ERR_FAIL_COND_V(!texture, Image::FORMAT_L8);
 	ERR_FAIL_COND_V(!texture, Image::FORMAT_L8);
 
 
@@ -1439,7 +1439,7 @@ Image::Format RasterizerStorageGLES3::texture_get_format(RID p_texture) const {
 }
 }
 
 
 VisualServer::TextureType RasterizerStorageGLES3::texture_get_type(RID p_texture) const {
 VisualServer::TextureType RasterizerStorageGLES3::texture_get_type(RID p_texture) const {
-	Texture *texture = texture_owner.get(p_texture);
+	Texture *texture = texture_owner.getornull(p_texture);
 
 
 	ERR_FAIL_COND_V(!texture, VS::TEXTURE_TYPE_2D);
 	ERR_FAIL_COND_V(!texture, VS::TEXTURE_TYPE_2D);
 
 
@@ -1447,7 +1447,7 @@ VisualServer::TextureType RasterizerStorageGLES3::texture_get_type(RID p_texture
 }
 }
 uint32_t RasterizerStorageGLES3::texture_get_texid(RID p_texture) const {
 uint32_t RasterizerStorageGLES3::texture_get_texid(RID p_texture) const {
 
 
-	Texture *texture = texture_owner.get(p_texture);
+	Texture *texture = texture_owner.getornull(p_texture);
 
 
 	ERR_FAIL_COND_V(!texture, 0);
 	ERR_FAIL_COND_V(!texture, 0);
 
 
@@ -1464,7 +1464,7 @@ void RasterizerStorageGLES3::texture_bind(RID p_texture, uint32_t p_texture_no)
 }
 }
 uint32_t RasterizerStorageGLES3::texture_get_width(RID p_texture) const {
 uint32_t RasterizerStorageGLES3::texture_get_width(RID p_texture) const {
 
 
-	Texture *texture = texture_owner.get(p_texture);
+	Texture *texture = texture_owner.getornull(p_texture);
 
 
 	ERR_FAIL_COND_V(!texture, 0);
 	ERR_FAIL_COND_V(!texture, 0);
 
 
@@ -1472,7 +1472,7 @@ uint32_t RasterizerStorageGLES3::texture_get_width(RID p_texture) const {
 }
 }
 uint32_t RasterizerStorageGLES3::texture_get_height(RID p_texture) const {
 uint32_t RasterizerStorageGLES3::texture_get_height(RID p_texture) const {
 
 
-	Texture *texture = texture_owner.get(p_texture);
+	Texture *texture = texture_owner.getornull(p_texture);
 
 
 	ERR_FAIL_COND_V(!texture, 0);
 	ERR_FAIL_COND_V(!texture, 0);
 
 
@@ -1481,7 +1481,7 @@ uint32_t RasterizerStorageGLES3::texture_get_height(RID p_texture) const {
 
 
 uint32_t RasterizerStorageGLES3::texture_get_depth(RID p_texture) const {
 uint32_t RasterizerStorageGLES3::texture_get_depth(RID p_texture) const {
 
 
-	Texture *texture = texture_owner.get(p_texture);
+	Texture *texture = texture_owner.getornull(p_texture);
 
 
 	ERR_FAIL_COND_V(!texture, 0);
 	ERR_FAIL_COND_V(!texture, 0);
 
 
@@ -1490,7 +1490,7 @@ uint32_t RasterizerStorageGLES3::texture_get_depth(RID p_texture) const {
 
 
 void RasterizerStorageGLES3::texture_set_size_override(RID p_texture, int p_width, int p_height, int p_depth) {
 void RasterizerStorageGLES3::texture_set_size_override(RID p_texture, int p_width, int p_height, int p_depth) {
 
 
-	Texture *texture = texture_owner.get(p_texture);
+	Texture *texture = texture_owner.getornull(p_texture);
 
 
 	ERR_FAIL_COND(!texture);
 	ERR_FAIL_COND(!texture);
 	ERR_FAIL_COND(texture->render_target);
 	ERR_FAIL_COND(texture->render_target);
@@ -1503,7 +1503,7 @@ void RasterizerStorageGLES3::texture_set_size_override(RID p_texture, int p_widt
 }
 }
 
 
 void RasterizerStorageGLES3::texture_set_path(RID p_texture, const String &p_path) {
 void RasterizerStorageGLES3::texture_set_path(RID p_texture, const String &p_path) {
-	Texture *texture = texture_owner.get(p_texture);
+	Texture *texture = texture_owner.getornull(p_texture);
 	ERR_FAIL_COND(!texture);
 	ERR_FAIL_COND(!texture);
 
 
 	texture->path = p_path;
 	texture->path = p_path;
@@ -1511,7 +1511,7 @@ void RasterizerStorageGLES3::texture_set_path(RID p_texture, const String &p_pat
 
 
 String RasterizerStorageGLES3::texture_get_path(RID p_texture) const {
 String RasterizerStorageGLES3::texture_get_path(RID p_texture) const {
 
 
-	Texture *texture = texture_owner.get(p_texture);
+	Texture *texture = texture_owner.getornull(p_texture);
 	ERR_FAIL_COND_V(!texture, String());
 	ERR_FAIL_COND_V(!texture, String());
 	return texture->path;
 	return texture->path;
 }
 }
@@ -1522,7 +1522,7 @@ void RasterizerStorageGLES3::texture_debug_usage(List<VS::TextureInfo> *r_info)
 
 
 	for (List<RID>::Element *E = textures.front(); E; E = E->next()) {
 	for (List<RID>::Element *E = textures.front(); E; E = E->next()) {
 
 
-		Texture *t = texture_owner.get(E->get());
+		Texture *t = texture_owner.getornull(E->get());
 		if (!t)
 		if (!t)
 			continue;
 			continue;
 		VS::TextureInfo tinfo;
 		VS::TextureInfo tinfo;
@@ -1548,7 +1548,7 @@ void RasterizerStorageGLES3::textures_keep_original(bool p_enable) {
 
 
 void RasterizerStorageGLES3::texture_set_detect_3d_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) {
 void RasterizerStorageGLES3::texture_set_detect_3d_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) {
 
 
-	Texture *texture = texture_owner.get(p_texture);
+	Texture *texture = texture_owner.getornull(p_texture);
 	ERR_FAIL_COND(!texture);
 	ERR_FAIL_COND(!texture);
 
 
 	texture->detect_3d = p_callback;
 	texture->detect_3d = p_callback;
@@ -1556,7 +1556,7 @@ void RasterizerStorageGLES3::texture_set_detect_3d_callback(RID p_texture, Visua
 }
 }
 
 
 void RasterizerStorageGLES3::texture_set_detect_srgb_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) {
 void RasterizerStorageGLES3::texture_set_detect_srgb_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) {
-	Texture *texture = texture_owner.get(p_texture);
+	Texture *texture = texture_owner.getornull(p_texture);
 	ERR_FAIL_COND(!texture);
 	ERR_FAIL_COND(!texture);
 
 
 	texture->detect_srgb = p_callback;
 	texture->detect_srgb = p_callback;
@@ -1564,7 +1564,7 @@ void RasterizerStorageGLES3::texture_set_detect_srgb_callback(RID p_texture, Vis
 }
 }
 
 
 void RasterizerStorageGLES3::texture_set_detect_normal_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) {
 void RasterizerStorageGLES3::texture_set_detect_normal_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) {
-	Texture *texture = texture_owner.get(p_texture);
+	Texture *texture = texture_owner.getornull(p_texture);
 	ERR_FAIL_COND(!texture);
 	ERR_FAIL_COND(!texture);
 
 
 	texture->detect_normal = p_callback;
 	texture->detect_normal = p_callback;
@@ -1573,7 +1573,7 @@ void RasterizerStorageGLES3::texture_set_detect_normal_callback(RID p_texture, V
 
 
 RID RasterizerStorageGLES3::texture_create_radiance_cubemap(RID p_source, int p_resolution) const {
 RID RasterizerStorageGLES3::texture_create_radiance_cubemap(RID p_source, int p_resolution) const {
 
 
-	Texture *texture = texture_owner.get(p_source);
+	Texture *texture = texture_owner.getornull(p_source);
 	ERR_FAIL_COND_V(!texture, RID());
 	ERR_FAIL_COND_V(!texture, RID());
 	ERR_FAIL_COND_V(texture->type != VS::TEXTURE_TYPE_CUBEMAP, RID());
 	ERR_FAIL_COND_V(texture->type != VS::TEXTURE_TYPE_CUBEMAP, RID());
 
 
@@ -1729,7 +1729,7 @@ Size2 RasterizerStorageGLES3::texture_size_with_proxy(RID p_texture) const {
 
 
 void RasterizerStorageGLES3::texture_set_proxy(RID p_texture, RID p_proxy) {
 void RasterizerStorageGLES3::texture_set_proxy(RID p_texture, RID p_proxy) {
 
 
-	Texture *texture = texture_owner.get(p_texture);
+	Texture *texture = texture_owner.getornull(p_texture);
 	ERR_FAIL_COND(!texture);
 	ERR_FAIL_COND(!texture);
 
 
 	if (texture->proxy) {
 	if (texture->proxy) {
@@ -1738,7 +1738,7 @@ void RasterizerStorageGLES3::texture_set_proxy(RID p_texture, RID p_proxy) {
 	}
 	}
 
 
 	if (p_proxy.is_valid()) {
 	if (p_proxy.is_valid()) {
-		Texture *proxy = texture_owner.get(p_proxy);
+		Texture *proxy = texture_owner.getornull(p_proxy);
 		ERR_FAIL_COND(!proxy);
 		ERR_FAIL_COND(!proxy);
 		ERR_FAIL_COND(proxy == texture);
 		ERR_FAIL_COND(proxy == texture);
 		proxy->proxy_owners.insert(texture);
 		proxy->proxy_owners.insert(texture);
@@ -1748,7 +1748,7 @@ void RasterizerStorageGLES3::texture_set_proxy(RID p_texture, RID p_proxy) {
 
 
 void RasterizerStorageGLES3::texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) {
 void RasterizerStorageGLES3::texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) {
 
 
-	Texture *texture = texture_owner.get(p_texture);
+	Texture *texture = texture_owner.getornull(p_texture);
 	ERR_FAIL_COND(!texture);
 	ERR_FAIL_COND(!texture);
 	texture->redraw_if_visible = p_enable;
 	texture->redraw_if_visible = p_enable;
 }
 }
@@ -2194,7 +2194,7 @@ void RasterizerStorageGLES3::_shader_make_dirty(Shader *p_shader) {
 
 
 void RasterizerStorageGLES3::shader_set_code(RID p_shader, const String &p_code) {
 void RasterizerStorageGLES3::shader_set_code(RID p_shader, const String &p_code) {
 
 
-	Shader *shader = shader_owner.get(p_shader);
+	Shader *shader = shader_owner.getornull(p_shader);
 	ERR_FAIL_COND(!shader);
 	ERR_FAIL_COND(!shader);
 
 
 	shader->code = p_code;
 	shader->code = p_code;
@@ -2234,7 +2234,7 @@ void RasterizerStorageGLES3::shader_set_code(RID p_shader, const String &p_code)
 }
 }
 String RasterizerStorageGLES3::shader_get_code(RID p_shader) const {
 String RasterizerStorageGLES3::shader_get_code(RID p_shader) const {
 
 
-	const Shader *shader = shader_owner.get(p_shader);
+	const Shader *shader = shader_owner.getornull(p_shader);
 	ERR_FAIL_COND_V(!shader, String());
 	ERR_FAIL_COND_V(!shader, String());
 
 
 	return shader->code;
 	return shader->code;
@@ -2387,7 +2387,7 @@ void RasterizerStorageGLES3::update_dirty_shaders() {
 
 
 void RasterizerStorageGLES3::shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const {
 void RasterizerStorageGLES3::shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const {
 
 
-	Shader *shader = shader_owner.get(p_shader);
+	Shader *shader = shader_owner.getornull(p_shader);
 	ERR_FAIL_COND(!shader);
 	ERR_FAIL_COND(!shader);
 
 
 	if (shader->dirty_list.in_list())
 	if (shader->dirty_list.in_list())
@@ -2502,7 +2502,7 @@ void RasterizerStorageGLES3::shader_get_param_list(RID p_shader, List<PropertyIn
 
 
 void RasterizerStorageGLES3::shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture) {
 void RasterizerStorageGLES3::shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture) {
 
 
-	Shader *shader = shader_owner.get(p_shader);
+	Shader *shader = shader_owner.getornull(p_shader);
 	ERR_FAIL_COND(!shader);
 	ERR_FAIL_COND(!shader);
 	ERR_FAIL_COND(p_texture.is_valid() && !texture_owner.owns(p_texture));
 	ERR_FAIL_COND(p_texture.is_valid() && !texture_owner.owns(p_texture));
 
 
@@ -2515,7 +2515,7 @@ void RasterizerStorageGLES3::shader_set_default_texture_param(RID p_shader, cons
 }
 }
 RID RasterizerStorageGLES3::shader_get_default_texture_param(RID p_shader, const StringName &p_name) const {
 RID RasterizerStorageGLES3::shader_get_default_texture_param(RID p_shader, const StringName &p_name) const {
 
 
-	const Shader *shader = shader_owner.get(p_shader);
+	const Shader *shader = shader_owner.getornull(p_shader);
 	ERR_FAIL_COND_V(!shader, RID());
 	ERR_FAIL_COND_V(!shader, RID());
 
 
 	const Map<StringName, RID>::Element *E = shader->default_textures.find(p_name);
 	const Map<StringName, RID>::Element *E = shader->default_textures.find(p_name);
@@ -2543,7 +2543,7 @@ RID RasterizerStorageGLES3::material_create() {
 
 
 void RasterizerStorageGLES3::material_set_shader(RID p_material, RID p_shader) {
 void RasterizerStorageGLES3::material_set_shader(RID p_material, RID p_shader) {
 
 
-	Material *material = material_owner.get(p_material);
+	Material *material = material_owner.getornull(p_material);
 	ERR_FAIL_COND(!material);
 	ERR_FAIL_COND(!material);
 
 
 	Shader *shader = shader_owner.getornull(p_shader);
 	Shader *shader = shader_owner.getornull(p_shader);
@@ -2563,7 +2563,7 @@ void RasterizerStorageGLES3::material_set_shader(RID p_material, RID p_shader) {
 
 
 RID RasterizerStorageGLES3::material_get_shader(RID p_material) const {
 RID RasterizerStorageGLES3::material_get_shader(RID p_material) const {
 
 
-	const Material *material = material_owner.get(p_material);
+	const Material *material = material_owner.getornull(p_material);
 	ERR_FAIL_COND_V(!material, RID());
 	ERR_FAIL_COND_V(!material, RID());
 
 
 	if (material->shader)
 	if (material->shader)
@@ -2574,7 +2574,7 @@ RID RasterizerStorageGLES3::material_get_shader(RID p_material) const {
 
 
 void RasterizerStorageGLES3::material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) {
 void RasterizerStorageGLES3::material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) {
 
 
-	Material *material = material_owner.get(p_material);
+	Material *material = material_owner.getornull(p_material);
 	ERR_FAIL_COND(!material);
 	ERR_FAIL_COND(!material);
 
 
 	if (p_value.get_type() == Variant::NIL)
 	if (p_value.get_type() == Variant::NIL)
@@ -2586,7 +2586,7 @@ void RasterizerStorageGLES3::material_set_param(RID p_material, const StringName
 }
 }
 Variant RasterizerStorageGLES3::material_get_param(RID p_material, const StringName &p_param) const {
 Variant RasterizerStorageGLES3::material_get_param(RID p_material, const StringName &p_param) const {
 
 
-	const Material *material = material_owner.get(p_material);
+	const Material *material = material_owner.getornull(p_material);
 	ERR_FAIL_COND_V(!material, Variant());
 	ERR_FAIL_COND_V(!material, Variant());
 
 
 	if (material->params.has(p_param))
 	if (material->params.has(p_param))
@@ -2596,7 +2596,7 @@ Variant RasterizerStorageGLES3::material_get_param(RID p_material, const StringN
 }
 }
 
 
 Variant RasterizerStorageGLES3::material_get_param_default(RID p_material, const StringName &p_param) const {
 Variant RasterizerStorageGLES3::material_get_param_default(RID p_material, const StringName &p_param) const {
-	const Material *material = material_owner.get(p_material);
+	const Material *material = material_owner.getornull(p_material);
 	ERR_FAIL_COND_V(!material, Variant());
 	ERR_FAIL_COND_V(!material, Variant());
 
 
 	if (material->shader) {
 	if (material->shader) {
@@ -2611,7 +2611,7 @@ Variant RasterizerStorageGLES3::material_get_param_default(RID p_material, const
 
 
 void RasterizerStorageGLES3::material_set_line_width(RID p_material, float p_width) {
 void RasterizerStorageGLES3::material_set_line_width(RID p_material, float p_width) {
 
 
-	Material *material = material_owner.get(p_material);
+	Material *material = material_owner.getornull(p_material);
 	ERR_FAIL_COND(!material);
 	ERR_FAIL_COND(!material);
 
 
 	material->line_width = p_width;
 	material->line_width = p_width;
@@ -2619,7 +2619,7 @@ void RasterizerStorageGLES3::material_set_line_width(RID p_material, float p_wid
 
 
 void RasterizerStorageGLES3::material_set_next_pass(RID p_material, RID p_next_material) {
 void RasterizerStorageGLES3::material_set_next_pass(RID p_material, RID p_next_material) {
 
 
-	Material *material = material_owner.get(p_material);
+	Material *material = material_owner.getornull(p_material);
 	ERR_FAIL_COND(!material);
 	ERR_FAIL_COND(!material);
 
 
 	material->next_pass = p_next_material;
 	material->next_pass = p_next_material;
@@ -2627,7 +2627,7 @@ void RasterizerStorageGLES3::material_set_next_pass(RID p_material, RID p_next_m
 
 
 bool RasterizerStorageGLES3::material_is_animated(RID p_material) {
 bool RasterizerStorageGLES3::material_is_animated(RID p_material) {
 
 
-	Material *material = material_owner.get(p_material);
+	Material *material = material_owner.getornull(p_material);
 	ERR_FAIL_COND_V(!material, false);
 	ERR_FAIL_COND_V(!material, false);
 	if (material->dirty_list.in_list()) {
 	if (material->dirty_list.in_list()) {
 		_update_material(material);
 		_update_material(material);
@@ -2641,7 +2641,7 @@ bool RasterizerStorageGLES3::material_is_animated(RID p_material) {
 }
 }
 bool RasterizerStorageGLES3::material_casts_shadows(RID p_material) {
 bool RasterizerStorageGLES3::material_casts_shadows(RID p_material) {
 
 
-	Material *material = material_owner.get(p_material);
+	Material *material = material_owner.getornull(p_material);
 	ERR_FAIL_COND_V(!material, false);
 	ERR_FAIL_COND_V(!material, false);
 	if (material->dirty_list.in_list()) {
 	if (material->dirty_list.in_list()) {
 		_update_material(material);
 		_update_material(material);
@@ -2658,7 +2658,7 @@ bool RasterizerStorageGLES3::material_casts_shadows(RID p_material) {
 
 
 void RasterizerStorageGLES3::material_add_instance_owner(RID p_material, RasterizerScene::InstanceBase *p_instance) {
 void RasterizerStorageGLES3::material_add_instance_owner(RID p_material, RasterizerScene::InstanceBase *p_instance) {
 
 
-	Material *material = material_owner.get(p_material);
+	Material *material = material_owner.getornull(p_material);
 	ERR_FAIL_COND(!material);
 	ERR_FAIL_COND(!material);
 
 
 	Map<RasterizerScene::InstanceBase *, int>::Element *E = material->instance_owners.find(p_instance);
 	Map<RasterizerScene::InstanceBase *, int>::Element *E = material->instance_owners.find(p_instance);
@@ -2671,7 +2671,7 @@ void RasterizerStorageGLES3::material_add_instance_owner(RID p_material, Rasteri
 
 
 void RasterizerStorageGLES3::material_remove_instance_owner(RID p_material, RasterizerScene::InstanceBase *p_instance) {
 void RasterizerStorageGLES3::material_remove_instance_owner(RID p_material, RasterizerScene::InstanceBase *p_instance) {
 
 
-	Material *material = material_owner.get(p_material);
+	Material *material = material_owner.getornull(p_material);
 	ERR_FAIL_COND(!material);
 	ERR_FAIL_COND(!material);
 
 
 	Map<RasterizerScene::InstanceBase *, int>::Element *E = material->instance_owners.find(p_instance);
 	Map<RasterizerScene::InstanceBase *, int>::Element *E = material->instance_owners.find(p_instance);
@@ -2688,7 +2688,7 @@ void RasterizerStorageGLES3::material_set_render_priority(RID p_material, int pr
 	ERR_FAIL_COND(priority < VS::MATERIAL_RENDER_PRIORITY_MIN);
 	ERR_FAIL_COND(priority < VS::MATERIAL_RENDER_PRIORITY_MIN);
 	ERR_FAIL_COND(priority > VS::MATERIAL_RENDER_PRIORITY_MAX);
 	ERR_FAIL_COND(priority > VS::MATERIAL_RENDER_PRIORITY_MAX);
 
 
-	Material *material = material_owner.get(p_material);
+	Material *material = material_owner.getornull(p_material);
 	ERR_FAIL_COND(!material);
 	ERR_FAIL_COND(!material);
 
 
 	material->render_priority = priority;
 	material->render_priority = priority;
@@ -4136,7 +4136,7 @@ AABB RasterizerStorageGLES3::mesh_get_custom_aabb(RID p_mesh) const {
 
 
 AABB RasterizerStorageGLES3::mesh_get_aabb(RID p_mesh, RID p_skeleton) const {
 AABB RasterizerStorageGLES3::mesh_get_aabb(RID p_mesh, RID p_skeleton) const {
 
 
-	Mesh *mesh = mesh_owner.get(p_mesh);
+	Mesh *mesh = mesh_owner.getornull(p_mesh);
 	ERR_FAIL_COND_V(!mesh, AABB());
 	ERR_FAIL_COND_V(!mesh, AABB());
 
 
 	if (mesh->custom_aabb != AABB()) {
 	if (mesh->custom_aabb != AABB()) {
@@ -4145,7 +4145,7 @@ AABB RasterizerStorageGLES3::mesh_get_aabb(RID p_mesh, RID p_skeleton) const {
 
 
 	Skeleton *sk = NULL;
 	Skeleton *sk = NULL;
 	if (p_skeleton.is_valid()) {
 	if (p_skeleton.is_valid()) {
-		sk = skeleton_owner.get(p_skeleton);
+		sk = skeleton_owner.getornull(p_skeleton);
 	}
 	}
 
 
 	AABB aabb;
 	AABB aabb;
@@ -5047,7 +5047,7 @@ RID RasterizerStorageGLES3::immediate_create() {
 void RasterizerStorageGLES3::immediate_begin(RID p_immediate, VS::PrimitiveType p_primitive, RID p_texture) {
 void RasterizerStorageGLES3::immediate_begin(RID p_immediate, VS::PrimitiveType p_primitive, RID p_texture) {
 
 
 	ERR_FAIL_INDEX(p_primitive, (int)VS::PRIMITIVE_MAX);
 	ERR_FAIL_INDEX(p_primitive, (int)VS::PRIMITIVE_MAX);
-	Immediate *im = immediate_owner.get(p_immediate);
+	Immediate *im = immediate_owner.getornull(p_immediate);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(im->building);
 	ERR_FAIL_COND(im->building);
 
 
@@ -5060,7 +5060,7 @@ void RasterizerStorageGLES3::immediate_begin(RID p_immediate, VS::PrimitiveType
 }
 }
 void RasterizerStorageGLES3::immediate_vertex(RID p_immediate, const Vector3 &p_vertex) {
 void RasterizerStorageGLES3::immediate_vertex(RID p_immediate, const Vector3 &p_vertex) {
 
 
-	Immediate *im = immediate_owner.get(p_immediate);
+	Immediate *im = immediate_owner.getornull(p_immediate);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im->building);
 	ERR_FAIL_COND(!im->building);
 
 
@@ -5090,7 +5090,7 @@ void RasterizerStorageGLES3::immediate_vertex(RID p_immediate, const Vector3 &p_
 
 
 void RasterizerStorageGLES3::immediate_normal(RID p_immediate, const Vector3 &p_normal) {
 void RasterizerStorageGLES3::immediate_normal(RID p_immediate, const Vector3 &p_normal) {
 
 
-	Immediate *im = immediate_owner.get(p_immediate);
+	Immediate *im = immediate_owner.getornull(p_immediate);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im->building);
 	ERR_FAIL_COND(!im->building);
 
 
@@ -5099,7 +5099,7 @@ void RasterizerStorageGLES3::immediate_normal(RID p_immediate, const Vector3 &p_
 }
 }
 void RasterizerStorageGLES3::immediate_tangent(RID p_immediate, const Plane &p_tangent) {
 void RasterizerStorageGLES3::immediate_tangent(RID p_immediate, const Plane &p_tangent) {
 
 
-	Immediate *im = immediate_owner.get(p_immediate);
+	Immediate *im = immediate_owner.getornull(p_immediate);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im->building);
 	ERR_FAIL_COND(!im->building);
 
 
@@ -5108,7 +5108,7 @@ void RasterizerStorageGLES3::immediate_tangent(RID p_immediate, const Plane &p_t
 }
 }
 void RasterizerStorageGLES3::immediate_color(RID p_immediate, const Color &p_color) {
 void RasterizerStorageGLES3::immediate_color(RID p_immediate, const Color &p_color) {
 
 
-	Immediate *im = immediate_owner.get(p_immediate);
+	Immediate *im = immediate_owner.getornull(p_immediate);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im->building);
 	ERR_FAIL_COND(!im->building);
 
 
@@ -5117,7 +5117,7 @@ void RasterizerStorageGLES3::immediate_color(RID p_immediate, const Color &p_col
 }
 }
 void RasterizerStorageGLES3::immediate_uv(RID p_immediate, const Vector2 &tex_uv) {
 void RasterizerStorageGLES3::immediate_uv(RID p_immediate, const Vector2 &tex_uv) {
 
 
-	Immediate *im = immediate_owner.get(p_immediate);
+	Immediate *im = immediate_owner.getornull(p_immediate);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im->building);
 	ERR_FAIL_COND(!im->building);
 
 
@@ -5126,7 +5126,7 @@ void RasterizerStorageGLES3::immediate_uv(RID p_immediate, const Vector2 &tex_uv
 }
 }
 void RasterizerStorageGLES3::immediate_uv2(RID p_immediate, const Vector2 &tex_uv) {
 void RasterizerStorageGLES3::immediate_uv2(RID p_immediate, const Vector2 &tex_uv) {
 
 
-	Immediate *im = immediate_owner.get(p_immediate);
+	Immediate *im = immediate_owner.getornull(p_immediate);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im->building);
 	ERR_FAIL_COND(!im->building);
 
 
@@ -5136,7 +5136,7 @@ void RasterizerStorageGLES3::immediate_uv2(RID p_immediate, const Vector2 &tex_u
 
 
 void RasterizerStorageGLES3::immediate_end(RID p_immediate) {
 void RasterizerStorageGLES3::immediate_end(RID p_immediate) {
 
 
-	Immediate *im = immediate_owner.get(p_immediate);
+	Immediate *im = immediate_owner.getornull(p_immediate);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im->building);
 	ERR_FAIL_COND(!im->building);
 
 
@@ -5146,7 +5146,7 @@ void RasterizerStorageGLES3::immediate_end(RID p_immediate) {
 }
 }
 void RasterizerStorageGLES3::immediate_clear(RID p_immediate) {
 void RasterizerStorageGLES3::immediate_clear(RID p_immediate) {
 
 
-	Immediate *im = immediate_owner.get(p_immediate);
+	Immediate *im = immediate_owner.getornull(p_immediate);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(im->building);
 	ERR_FAIL_COND(im->building);
 
 
@@ -5156,14 +5156,14 @@ void RasterizerStorageGLES3::immediate_clear(RID p_immediate) {
 
 
 AABB RasterizerStorageGLES3::immediate_get_aabb(RID p_immediate) const {
 AABB RasterizerStorageGLES3::immediate_get_aabb(RID p_immediate) const {
 
 
-	Immediate *im = immediate_owner.get(p_immediate);
+	Immediate *im = immediate_owner.getornull(p_immediate);
 	ERR_FAIL_COND_V(!im, AABB());
 	ERR_FAIL_COND_V(!im, AABB());
 	return im->aabb;
 	return im->aabb;
 }
 }
 
 
 void RasterizerStorageGLES3::immediate_set_material(RID p_immediate, RID p_material) {
 void RasterizerStorageGLES3::immediate_set_material(RID p_immediate, RID p_material) {
 
 
-	Immediate *im = immediate_owner.get(p_immediate);
+	Immediate *im = immediate_owner.getornull(p_immediate);
 	ERR_FAIL_COND(!im);
 	ERR_FAIL_COND(!im);
 	im->material = p_material;
 	im->material = p_material;
 	im->instance_change_notify(false, true);
 	im->instance_change_notify(false, true);
@@ -5171,7 +5171,7 @@ void RasterizerStorageGLES3::immediate_set_material(RID p_immediate, RID p_mater
 
 
 RID RasterizerStorageGLES3::immediate_get_material(RID p_immediate) const {
 RID RasterizerStorageGLES3::immediate_get_material(RID p_immediate) const {
 
 
-	const Immediate *im = immediate_owner.get(p_immediate);
+	const Immediate *im = immediate_owner.getornull(p_immediate);
 	ERR_FAIL_COND_V(!im, RID());
 	ERR_FAIL_COND_V(!im, RID());
 	return im->material;
 	return im->material;
 }
 }
@@ -6999,7 +6999,7 @@ void RasterizerStorageGLES3::_render_target_clear(RenderTarget *rt) {
 		glDeleteFramebuffers(1, &rt->external.fbo);
 		glDeleteFramebuffers(1, &rt->external.fbo);
 
 
 		// clean up our texture
 		// clean up our texture
-		Texture *t = texture_owner.get(rt->external.texture);
+		Texture *t = texture_owner.getornull(rt->external.texture);
 		t->alloc_height = 0;
 		t->alloc_height = 0;
 		t->alloc_width = 0;
 		t->alloc_width = 0;
 		t->width = 0;
 		t->width = 0;
@@ -7011,7 +7011,7 @@ void RasterizerStorageGLES3::_render_target_clear(RenderTarget *rt) {
 		rt->external.fbo = 0;
 		rt->external.fbo = 0;
 	}
 	}
 
 
-	Texture *tex = texture_owner.get(rt->texture);
+	Texture *tex = texture_owner.getornull(rt->texture);
 	tex->alloc_height = 0;
 	tex->alloc_height = 0;
 	tex->alloc_width = 0;
 	tex->alloc_width = 0;
 	tex->width = 0;
 	tex->width = 0;
@@ -7117,7 +7117,7 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt) {
 
 
 		ERR_FAIL_COND(status != GL_FRAMEBUFFER_COMPLETE);
 		ERR_FAIL_COND(status != GL_FRAMEBUFFER_COMPLETE);
 
 
-		Texture *tex = texture_owner.get(rt->texture);
+		Texture *tex = texture_owner.getornull(rt->texture);
 		tex->format = image_format;
 		tex->format = image_format;
 		tex->gl_format_cache = color_format;
 		tex->gl_format_cache = color_format;
 		tex->gl_type_cache = color_type;
 		tex->gl_type_cache = color_type;
@@ -7487,7 +7487,7 @@ void RasterizerStorageGLES3::render_target_set_external_texture(RID p_render_tar
 			glDeleteFramebuffers(1, &rt->external.fbo);
 			glDeleteFramebuffers(1, &rt->external.fbo);
 
 
 			// clean up our texture
 			// clean up our texture
-			Texture *t = texture_owner.get(rt->external.texture);
+			Texture *t = texture_owner.getornull(rt->external.texture);
 			t->alloc_height = 0;
 			t->alloc_height = 0;
 			t->alloc_width = 0;
 			t->alloc_width = 0;
 			t->width = 0;
 			t->width = 0;
@@ -7536,7 +7536,7 @@ void RasterizerStorageGLES3::render_target_set_external_texture(RID p_render_tar
 			glBindFramebuffer(GL_FRAMEBUFFER, rt->external.fbo);
 			glBindFramebuffer(GL_FRAMEBUFFER, rt->external.fbo);
 
 
 			// find our texture
 			// find our texture
-			t = texture_owner.get(rt->external.texture);
+			t = texture_owner.getornull(rt->external.texture);
 		}
 		}
 
 
 		// set our texture
 		// set our texture
@@ -7678,7 +7678,7 @@ RID RasterizerStorageGLES3::canvas_light_occluder_create() {
 
 
 void RasterizerStorageGLES3::canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector<Vector2> &p_lines) {
 void RasterizerStorageGLES3::canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector<Vector2> &p_lines) {
 
 
-	CanvasOccluder *co = canvas_occluder_owner.get(p_occluder);
+	CanvasOccluder *co = canvas_occluder_owner.getornull(p_occluder);
 	ERR_FAIL_COND(!co);
 	ERR_FAIL_COND(!co);
 
 
 	co->lines = p_lines;
 	co->lines = p_lines;
@@ -7818,7 +7818,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
 
 
 		RenderTarget *rt = render_target_owner.getornull(p_rid);
 		RenderTarget *rt = render_target_owner.getornull(p_rid);
 		_render_target_clear(rt);
 		_render_target_clear(rt);
-		Texture *t = texture_owner.get(rt->texture);
+		Texture *t = texture_owner.getornull(rt->texture);
 		texture_owner.free(rt->texture);
 		texture_owner.free(rt->texture);
 		memdelete(t);
 		memdelete(t);
 		render_target_owner.free(p_rid);
 		render_target_owner.free(p_rid);
@@ -7826,7 +7826,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
 
 
 	} else if (texture_owner.owns(p_rid)) {
 	} else if (texture_owner.owns(p_rid)) {
 		// delete the texture
 		// delete the texture
-		Texture *texture = texture_owner.get(p_rid);
+		Texture *texture = texture_owner.getornull(p_rid);
 		ERR_FAIL_COND_V(texture->render_target, true); //can't free the render target texture, dude
 		ERR_FAIL_COND_V(texture->render_target, true); //can't free the render target texture, dude
 		info.texture_mem -= texture->total_data_size;
 		info.texture_mem -= texture->total_data_size;
 		texture_owner.free(p_rid);
 		texture_owner.free(p_rid);
@@ -7834,7 +7834,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
 
 
 	} else if (sky_owner.owns(p_rid)) {
 	} else if (sky_owner.owns(p_rid)) {
 		// delete the sky
 		// delete the sky
-		Sky *sky = sky_owner.get(p_rid);
+		Sky *sky = sky_owner.getornull(p_rid);
 		sky_set_texture(p_rid, RID(), 256);
 		sky_set_texture(p_rid, RID(), 256);
 		sky_owner.free(p_rid);
 		sky_owner.free(p_rid);
 		memdelete(sky);
 		memdelete(sky);
@@ -7842,7 +7842,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
 	} else if (shader_owner.owns(p_rid)) {
 	} else if (shader_owner.owns(p_rid)) {
 
 
 		// delete the texture
 		// delete the texture
-		Shader *shader = shader_owner.get(p_rid);
+		Shader *shader = shader_owner.getornull(p_rid);
 
 
 		if (shader->shader && shader->custom_code_id)
 		if (shader->shader && shader->custom_code_id)
 			shader->shader->free_custom_shader(shader->custom_code_id);
 			shader->shader->free_custom_shader(shader->custom_code_id);
@@ -7867,7 +7867,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
 	} else if (material_owner.owns(p_rid)) {
 	} else if (material_owner.owns(p_rid)) {
 
 
 		// delete the texture
 		// delete the texture
-		Material *material = material_owner.get(p_rid);
+		Material *material = material_owner.getornull(p_rid);
 
 
 		if (material->shader) {
 		if (material->shader) {
 			material->shader->materials.remove(&material->list);
 			material->shader->materials.remove(&material->list);
@@ -7902,7 +7902,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
 	} else if (skeleton_owner.owns(p_rid)) {
 	} else if (skeleton_owner.owns(p_rid)) {
 
 
 		// delete the texture
 		// delete the texture
-		Skeleton *skeleton = skeleton_owner.get(p_rid);
+		Skeleton *skeleton = skeleton_owner.getornull(p_rid);
 		if (skeleton->update_list.in_list()) {
 		if (skeleton->update_list.in_list()) {
 			skeleton_update_list.remove(&skeleton->update_list);
 			skeleton_update_list.remove(&skeleton->update_list);
 		}
 		}
@@ -7920,7 +7920,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
 	} else if (mesh_owner.owns(p_rid)) {
 	} else if (mesh_owner.owns(p_rid)) {
 
 
 		// delete the texture
 		// delete the texture
-		Mesh *mesh = mesh_owner.get(p_rid);
+		Mesh *mesh = mesh_owner.getornull(p_rid);
 		mesh->instance_remove_deps();
 		mesh->instance_remove_deps();
 		mesh_clear(p_rid);
 		mesh_clear(p_rid);
 
 
@@ -7941,7 +7941,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
 	} else if (multimesh_owner.owns(p_rid)) {
 	} else if (multimesh_owner.owns(p_rid)) {
 
 
 		// delete the texture
 		// delete the texture
-		MultiMesh *multimesh = multimesh_owner.get(p_rid);
+		MultiMesh *multimesh = multimesh_owner.getornull(p_rid);
 		multimesh->instance_remove_deps();
 		multimesh->instance_remove_deps();
 
 
 		if (multimesh->mesh.is_valid()) {
 		if (multimesh->mesh.is_valid()) {
@@ -7958,7 +7958,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
 		memdelete(multimesh);
 		memdelete(multimesh);
 	} else if (immediate_owner.owns(p_rid)) {
 	} else if (immediate_owner.owns(p_rid)) {
 
 
-		Immediate *immediate = immediate_owner.get(p_rid);
+		Immediate *immediate = immediate_owner.getornull(p_rid);
 		immediate->instance_remove_deps();
 		immediate->instance_remove_deps();
 
 
 		immediate_owner.free(p_rid);
 		immediate_owner.free(p_rid);
@@ -7966,7 +7966,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
 	} else if (light_owner.owns(p_rid)) {
 	} else if (light_owner.owns(p_rid)) {
 
 
 		// delete the texture
 		// delete the texture
-		Light *light = light_owner.get(p_rid);
+		Light *light = light_owner.getornull(p_rid);
 		light->instance_remove_deps();
 		light->instance_remove_deps();
 
 
 		light_owner.free(p_rid);
 		light_owner.free(p_rid);
@@ -7975,7 +7975,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
 	} else if (reflection_probe_owner.owns(p_rid)) {
 	} else if (reflection_probe_owner.owns(p_rid)) {
 
 
 		// delete the texture
 		// delete the texture
-		ReflectionProbe *reflection_probe = reflection_probe_owner.get(p_rid);
+		ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_rid);
 		reflection_probe->instance_remove_deps();
 		reflection_probe->instance_remove_deps();
 
 
 		reflection_probe_owner.free(p_rid);
 		reflection_probe_owner.free(p_rid);
@@ -7984,7 +7984,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
 	} else if (gi_probe_owner.owns(p_rid)) {
 	} else if (gi_probe_owner.owns(p_rid)) {
 
 
 		// delete the texture
 		// delete the texture
-		GIProbe *gi_probe = gi_probe_owner.get(p_rid);
+		GIProbe *gi_probe = gi_probe_owner.getornull(p_rid);
 		gi_probe->instance_remove_deps();
 		gi_probe->instance_remove_deps();
 
 
 		gi_probe_owner.free(p_rid);
 		gi_probe_owner.free(p_rid);
@@ -7992,7 +7992,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
 	} else if (gi_probe_data_owner.owns(p_rid)) {
 	} else if (gi_probe_data_owner.owns(p_rid)) {
 
 
 		// delete the texture
 		// delete the texture
-		GIProbeData *gi_probe_data = gi_probe_data_owner.get(p_rid);
+		GIProbeData *gi_probe_data = gi_probe_data_owner.getornull(p_rid);
 
 
 		glDeleteTextures(1, &gi_probe_data->tex_id);
 		glDeleteTextures(1, &gi_probe_data->tex_id);
 		gi_probe_data_owner.free(p_rid);
 		gi_probe_data_owner.free(p_rid);
@@ -8000,7 +8000,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
 	} else if (lightmap_capture_data_owner.owns(p_rid)) {
 	} else if (lightmap_capture_data_owner.owns(p_rid)) {
 
 
 		// delete the texture
 		// delete the texture
-		LightmapCapture *lightmap_capture = lightmap_capture_data_owner.get(p_rid);
+		LightmapCapture *lightmap_capture = lightmap_capture_data_owner.getornull(p_rid);
 		lightmap_capture->instance_remove_deps();
 		lightmap_capture->instance_remove_deps();
 
 
 		lightmap_capture_data_owner.free(p_rid);
 		lightmap_capture_data_owner.free(p_rid);
@@ -8008,7 +8008,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
 
 
 	} else if (canvas_occluder_owner.owns(p_rid)) {
 	} else if (canvas_occluder_owner.owns(p_rid)) {
 
 
-		CanvasOccluder *co = canvas_occluder_owner.get(p_rid);
+		CanvasOccluder *co = canvas_occluder_owner.getornull(p_rid);
 		if (co->index_id)
 		if (co->index_id)
 			glDeleteBuffers(1, &co->index_id);
 			glDeleteBuffers(1, &co->index_id);
 		if (co->vertex_id)
 		if (co->vertex_id)
@@ -8021,14 +8021,14 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
 
 
 	} else if (canvas_light_shadow_owner.owns(p_rid)) {
 	} else if (canvas_light_shadow_owner.owns(p_rid)) {
 
 
-		CanvasLightShadow *cls = canvas_light_shadow_owner.get(p_rid);
+		CanvasLightShadow *cls = canvas_light_shadow_owner.getornull(p_rid);
 		glDeleteFramebuffers(1, &cls->fbo);
 		glDeleteFramebuffers(1, &cls->fbo);
 		glDeleteRenderbuffers(1, &cls->depth);
 		glDeleteRenderbuffers(1, &cls->depth);
 		glDeleteTextures(1, &cls->distance);
 		glDeleteTextures(1, &cls->distance);
 		canvas_light_shadow_owner.free(p_rid);
 		canvas_light_shadow_owner.free(p_rid);
 		memdelete(cls);
 		memdelete(cls);
 	} else if (particles_owner.owns(p_rid)) {
 	} else if (particles_owner.owns(p_rid)) {
-		Particles *particles = particles_owner.get(p_rid);
+		Particles *particles = particles_owner.getornull(p_rid);
 		particles->instance_remove_deps();
 		particles->instance_remove_deps();
 		particles_owner.free(p_rid);
 		particles_owner.free(p_rid);
 		memdelete(particles);
 		memdelete(particles);

+ 29 - 27
drivers/gles3/rasterizer_storage_gles3.h

@@ -43,6 +43,8 @@
 #include "shaders/cubemap_filter.glsl.gen.h"
 #include "shaders/cubemap_filter.glsl.gen.h"
 #include "shaders/particles.glsl.gen.h"
 #include "shaders/particles.glsl.gen.h"
 
 
+#include "core/rid_owner.h"
+
 // WebGL 2.0 has no MapBufferRange/UnmapBuffer, but offers a non-ES style BufferSubData API instead.
 // WebGL 2.0 has no MapBufferRange/UnmapBuffer, but offers a non-ES style BufferSubData API instead.
 #ifdef __EMSCRIPTEN__
 #ifdef __EMSCRIPTEN__
 void glGetBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data);
 void glGetBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data);
@@ -179,7 +181,7 @@ public:
 	//////////////////////////////////DATA///////////////////////////////////////////////////
 	//////////////////////////////////DATA///////////////////////////////////////////////////
 	/////////////////////////////////////////////////////////////////////////////////////////
 	/////////////////////////////////////////////////////////////////////////////////////////
 
 
-	struct Instantiable : public RID_Data {
+	struct Instantiable {
 
 
 		SelfList<RasterizerScene::InstanceBase>::List instance_list;
 		SelfList<RasterizerScene::InstanceBase>::List instance_list;
 
 
@@ -242,7 +244,7 @@ public:
 
 
 	struct RenderTarget;
 	struct RenderTarget;
 
 
-	struct Texture : public RID_Data {
+	struct Texture {
 
 
 		Texture *proxy;
 		Texture *proxy;
 		Set<Texture *> proxy_owners;
 		Set<Texture *> proxy_owners;
@@ -342,7 +344,7 @@ public:
 		}
 		}
 	};
 	};
 
 
-	mutable RID_Owner<Texture> texture_owner;
+	mutable RID_PtrOwner<Texture> texture_owner;
 
 
 	Ref<Image> _get_gl_image_and_format(const Ref<Image> &p_image, Image::Format p_format, uint32_t p_flags, Image::Format &r_real_format, GLenum &r_gl_format, GLenum &r_gl_internal_format, GLenum &r_gl_type, bool &r_compressed, bool &r_srgb, bool p_force_decompress) const;
 	Ref<Image> _get_gl_image_and_format(const Ref<Image> &p_image, Image::Format p_format, uint32_t p_flags, Image::Format &r_real_format, GLenum &r_gl_format, GLenum &r_gl_internal_format, GLenum &r_gl_type, bool &r_compressed, bool &r_srgb, bool p_force_decompress) const;
 
 
@@ -384,7 +386,7 @@ public:
 
 
 	/* SKY API */
 	/* SKY API */
 
 
-	struct Sky : public RID_Data {
+	struct Sky {
 
 
 		RID panorama;
 		RID panorama;
 		GLuint radiance;
 		GLuint radiance;
@@ -392,7 +394,7 @@ public:
 		int radiance_size;
 		int radiance_size;
 	};
 	};
 
 
-	mutable RID_Owner<Sky> sky_owner;
+	mutable RID_PtrOwner<Sky> sky_owner;
 
 
 	virtual RID sky_create();
 	virtual RID sky_create();
 	virtual void sky_set_texture(RID p_sky, RID p_panorama, int p_radiance_size);
 	virtual void sky_set_texture(RID p_sky, RID p_panorama, int p_radiance_size);
@@ -401,7 +403,7 @@ public:
 
 
 	struct Material;
 	struct Material;
 
 
-	struct Shader : public RID_Data {
+	struct Shader {
 
 
 		RID self;
 		RID self;
 
 
@@ -522,7 +524,7 @@ public:
 	mutable SelfList<Shader>::List _shader_dirty_list;
 	mutable SelfList<Shader>::List _shader_dirty_list;
 	void _shader_make_dirty(Shader *p_shader);
 	void _shader_make_dirty(Shader *p_shader);
 
 
-	mutable RID_Owner<Shader> shader_owner;
+	mutable RID_PtrOwner<Shader> shader_owner;
 
 
 	virtual RID shader_create();
 	virtual RID shader_create();
 
 
@@ -539,7 +541,7 @@ public:
 
 
 	/* COMMON MATERIAL API */
 	/* COMMON MATERIAL API */
 
 
-	struct Material : public RID_Data {
+	struct Material {
 
 
 		Shader *shader;
 		Shader *shader;
 		GLuint ubo_id;
 		GLuint ubo_id;
@@ -582,7 +584,7 @@ public:
 	void _material_add_geometry(RID p_material, Geometry *p_geometry);
 	void _material_add_geometry(RID p_material, Geometry *p_geometry);
 	void _material_remove_geometry(RID p_material, Geometry *p_geometry);
 	void _material_remove_geometry(RID p_material, Geometry *p_geometry);
 
 
-	mutable RID_Owner<Material> material_owner;
+	mutable RID_PtrOwner<Material> material_owner;
 
 
 	virtual RID material_create();
 	virtual RID material_create();
 
 
@@ -724,7 +726,7 @@ public:
 		}
 		}
 	};
 	};
 
 
-	mutable RID_Owner<Mesh> mesh_owner;
+	mutable RID_PtrOwner<Mesh> mesh_owner;
 
 
 	virtual RID mesh_create();
 	virtual RID mesh_create();
 
 
@@ -804,7 +806,7 @@ public:
 		}
 		}
 	};
 	};
 
 
-	mutable RID_Owner<MultiMesh> multimesh_owner;
+	mutable RID_PtrOwner<MultiMesh> multimesh_owner;
 
 
 	SelfList<MultiMesh>::List multimesh_update_list;
 	SelfList<MultiMesh>::List multimesh_update_list;
 
 
@@ -869,7 +871,7 @@ public:
 	Vector2 chunk_uv;
 	Vector2 chunk_uv;
 	Vector2 chunk_uv2;
 	Vector2 chunk_uv2;
 
 
-	mutable RID_Owner<Immediate> immediate_owner;
+	mutable RID_PtrOwner<Immediate> immediate_owner;
 
 
 	virtual RID immediate_create();
 	virtual RID immediate_create();
 	virtual void immediate_begin(RID p_immediate, VS::PrimitiveType p_primitive, RID p_texture = RID());
 	virtual void immediate_begin(RID p_immediate, VS::PrimitiveType p_primitive, RID p_texture = RID());
@@ -887,7 +889,7 @@ public:
 
 
 	/* SKELETON API */
 	/* SKELETON API */
 
 
-	struct Skeleton : RID_Data {
+	struct Skeleton {
 		bool use_2d;
 		bool use_2d;
 		int size;
 		int size;
 		Vector<float> skel_texture;
 		Vector<float> skel_texture;
@@ -904,7 +906,7 @@ public:
 		}
 		}
 	};
 	};
 
 
-	mutable RID_Owner<Skeleton> skeleton_owner;
+	mutable RID_PtrOwner<Skeleton> skeleton_owner;
 
 
 	SelfList<Skeleton>::List skeleton_update_list;
 	SelfList<Skeleton>::List skeleton_update_list;
 
 
@@ -941,7 +943,7 @@ public:
 		uint64_t version;
 		uint64_t version;
 	};
 	};
 
 
-	mutable RID_Owner<Light> light_owner;
+	mutable RID_PtrOwner<Light> light_owner;
 
 
 	virtual RID light_create(VS::LightType p_type);
 	virtual RID light_create(VS::LightType p_type);
 
 
@@ -996,7 +998,7 @@ public:
 		uint32_t cull_mask;
 		uint32_t cull_mask;
 	};
 	};
 
 
-	mutable RID_Owner<ReflectionProbe> reflection_probe_owner;
+	mutable RID_PtrOwner<ReflectionProbe> reflection_probe_owner;
 
 
 	virtual RID reflection_probe_create();
 	virtual RID reflection_probe_create();
 
 
@@ -1044,7 +1046,7 @@ public:
 		PoolVector<int> dynamic_data;
 		PoolVector<int> dynamic_data;
 	};
 	};
 
 
-	mutable RID_Owner<GIProbe> gi_probe_owner;
+	mutable RID_PtrOwner<GIProbe> gi_probe_owner;
 
 
 	virtual RID gi_probe_create();
 	virtual RID gi_probe_create();
 
 
@@ -1083,7 +1085,7 @@ public:
 
 
 	virtual uint32_t gi_probe_get_version(RID p_probe);
 	virtual uint32_t gi_probe_get_version(RID p_probe);
 
 
-	struct GIProbeData : public RID_Data {
+	struct GIProbeData {
 
 
 		int width;
 		int width;
 		int height;
 		int height;
@@ -1096,7 +1098,7 @@ public:
 		}
 		}
 	};
 	};
 
 
-	mutable RID_Owner<GIProbeData> gi_probe_data_owner;
+	mutable RID_PtrOwner<GIProbeData> gi_probe_data_owner;
 
 
 	virtual GIProbeCompression gi_probe_get_dynamic_data_get_preferred_compression() const;
 	virtual GIProbeCompression gi_probe_get_dynamic_data_get_preferred_compression() const;
 	virtual RID gi_probe_dynamic_data_create(int p_width, int p_height, int p_depth, GIProbeCompression p_compression);
 	virtual RID gi_probe_dynamic_data_create(int p_width, int p_height, int p_depth, GIProbeCompression p_compression);
@@ -1132,7 +1134,7 @@ public:
 		}
 		}
 	};
 	};
 
 
-	mutable RID_Owner<LightmapCapture> lightmap_capture_data_owner;
+	mutable RID_PtrOwner<LightmapCapture> lightmap_capture_data_owner;
 
 
 	/* PARTICLES */
 	/* PARTICLES */
 
 
@@ -1228,7 +1230,7 @@ public:
 
 
 	void update_particles();
 	void update_particles();
 
 
-	mutable RID_Owner<Particles> particles_owner;
+	mutable RID_PtrOwner<Particles> particles_owner;
 
 
 	virtual RID particles_create();
 	virtual RID particles_create();
 
 
@@ -1277,7 +1279,7 @@ public:
 
 
 	/* RENDER TARGET */
 	/* RENDER TARGET */
 
 
-	struct RenderTarget : public RID_Data {
+	struct RenderTarget {
 
 
 		GLuint fbo;
 		GLuint fbo;
 		GLuint color;
 		GLuint color;
@@ -1389,7 +1391,7 @@ public:
 		}
 		}
 	};
 	};
 
 
-	mutable RID_Owner<RenderTarget> render_target_owner;
+	mutable RID_PtrOwner<RenderTarget> render_target_owner;
 
 
 	void _render_target_clear(RenderTarget *rt);
 	void _render_target_clear(RenderTarget *rt);
 	void _render_target_allocate(RenderTarget *rt);
 	void _render_target_allocate(RenderTarget *rt);
@@ -1407,7 +1409,7 @@ public:
 
 
 	/* CANVAS SHADOW */
 	/* CANVAS SHADOW */
 
 
-	struct CanvasLightShadow : public RID_Data {
+	struct CanvasLightShadow {
 
 
 		int size;
 		int size;
 		int height;
 		int height;
@@ -1416,13 +1418,13 @@ public:
 		GLuint distance; //for older devices
 		GLuint distance; //for older devices
 	};
 	};
 
 
-	RID_Owner<CanvasLightShadow> canvas_light_shadow_owner;
+	RID_PtrOwner<CanvasLightShadow> canvas_light_shadow_owner;
 
 
 	virtual RID canvas_light_shadow_buffer_create(int p_width);
 	virtual RID canvas_light_shadow_buffer_create(int p_width);
 
 
 	/* LIGHT SHADOW MAPPING */
 	/* LIGHT SHADOW MAPPING */
 
 
-	struct CanvasOccluder : public RID_Data {
+	struct CanvasOccluder {
 
 
 		GLuint array_id; // 0 means, unconfigured
 		GLuint array_id; // 0 means, unconfigured
 		GLuint vertex_id; // 0 means, unconfigured
 		GLuint vertex_id; // 0 means, unconfigured
@@ -1431,7 +1433,7 @@ public:
 		int len;
 		int len;
 	};
 	};
 
 
-	RID_Owner<CanvasOccluder> canvas_occluder_owner;
+	RID_PtrOwner<CanvasOccluder> canvas_occluder_owner;
 
 
 	virtual RID canvas_light_occluder_create();
 	virtual RID canvas_light_occluder_create();
 	virtual void canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector<Vector2> &p_lines);
 	virtual void canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector<Vector2> &p_lines);

+ 0 - 1
main/main.cpp

@@ -352,7 +352,6 @@ void Main::print_help(const char *p_binary) {
  */
  */
 
 
 Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_phase) {
 Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_phase) {
-	RID_OwnerBase::init_rid();
 
 
 	OS::get_singleton()->initialize_core();
 	OS::get_singleton()->initialize_core();
 
 

Разлика између датотеке није приказан због своје велике величине
+ 140 - 140
modules/bullet/bullet_physics_server.cpp


+ 13 - 13
modules/bullet/bullet_physics_server.h

@@ -33,13 +33,13 @@
 
 
 #include "area_bullet.h"
 #include "area_bullet.h"
 #include "core/rid.h"
 #include "core/rid.h"
+#include "core/rid_owner.h"
 #include "joint_bullet.h"
 #include "joint_bullet.h"
 #include "rigid_body_bullet.h"
 #include "rigid_body_bullet.h"
 #include "servers/physics_server.h"
 #include "servers/physics_server.h"
 #include "shape_bullet.h"
 #include "shape_bullet.h"
 #include "soft_body_bullet.h"
 #include "soft_body_bullet.h"
 #include "space_bullet.h"
 #include "space_bullet.h"
-
 /**
 /**
 	@author AndreaCatania
 	@author AndreaCatania
 */
 */
@@ -53,12 +53,12 @@ class BulletPhysicsServer : public PhysicsServer {
 	char active_spaces_count;
 	char active_spaces_count;
 	Vector<SpaceBullet *> active_spaces;
 	Vector<SpaceBullet *> active_spaces;
 
 
-	mutable RID_Owner<SpaceBullet> space_owner;
-	mutable RID_Owner<ShapeBullet> shape_owner;
-	mutable RID_Owner<AreaBullet> area_owner;
-	mutable RID_Owner<RigidBodyBullet> rigid_body_owner;
-	mutable RID_Owner<SoftBodyBullet> soft_body_owner;
-	mutable RID_Owner<JointBullet> joint_owner;
+	mutable RID_PtrOwner<SpaceBullet> space_owner;
+	mutable RID_PtrOwner<ShapeBullet> shape_owner;
+	mutable RID_PtrOwner<AreaBullet> area_owner;
+	mutable RID_PtrOwner<RigidBodyBullet> rigid_body_owner;
+	mutable RID_PtrOwner<SoftBodyBullet> soft_body_owner;
+	mutable RID_PtrOwner<JointBullet> joint_owner;
 
 
 protected:
 protected:
 	static void _bind_methods();
 	static void _bind_methods();
@@ -67,22 +67,22 @@ public:
 	BulletPhysicsServer();
 	BulletPhysicsServer();
 	~BulletPhysicsServer();
 	~BulletPhysicsServer();
 
 
-	_FORCE_INLINE_ RID_Owner<SpaceBullet> *get_space_owner() {
+	_FORCE_INLINE_ RID_PtrOwner<SpaceBullet> *get_space_owner() {
 		return &space_owner;
 		return &space_owner;
 	}
 	}
-	_FORCE_INLINE_ RID_Owner<ShapeBullet> *get_shape_owner() {
+	_FORCE_INLINE_ RID_PtrOwner<ShapeBullet> *get_shape_owner() {
 		return &shape_owner;
 		return &shape_owner;
 	}
 	}
-	_FORCE_INLINE_ RID_Owner<AreaBullet> *get_area_owner() {
+	_FORCE_INLINE_ RID_PtrOwner<AreaBullet> *get_area_owner() {
 		return &area_owner;
 		return &area_owner;
 	}
 	}
-	_FORCE_INLINE_ RID_Owner<RigidBodyBullet> *get_rigid_body_owner() {
+	_FORCE_INLINE_ RID_PtrOwner<RigidBodyBullet> *get_rigid_body_owner() {
 		return &rigid_body_owner;
 		return &rigid_body_owner;
 	}
 	}
-	_FORCE_INLINE_ RID_Owner<SoftBodyBullet> *get_soft_body_owner() {
+	_FORCE_INLINE_ RID_PtrOwner<SoftBodyBullet> *get_soft_body_owner() {
 		return &soft_body_owner;
 		return &soft_body_owner;
 	}
 	}
-	_FORCE_INLINE_ RID_Owner<JointBullet> *get_joint_owner() {
+	_FORCE_INLINE_ RID_PtrOwner<JointBullet> *get_joint_owner() {
 		return &joint_owner;
 		return &joint_owner;
 	}
 	}
 
 

+ 1 - 1
modules/bullet/rid_bullet.h

@@ -39,7 +39,7 @@
 
 
 class BulletPhysicsServer;
 class BulletPhysicsServer;
 
 
-class RIDBullet : public RID_Data {
+class RIDBullet  {
 	RID self;
 	RID self;
 	BulletPhysicsServer *physicsServer;
 	BulletPhysicsServer *physicsServer;
 
 

+ 4 - 4
modules/bullet/space_bullet.cpp

@@ -122,7 +122,7 @@ int BulletPhysicsDirectSpaceState::intersect_shape(const RID &p_shape, const Tra
 	if (p_result_max <= 0)
 	if (p_result_max <= 0)
 		return 0;
 		return 0;
 
 
-	ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->get(p_shape);
+	ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->getornull(p_shape);
 
 
 	btCollisionShape *btShape = shape->create_bt_shape(p_xform.basis.get_scale_abs(), p_margin);
 	btCollisionShape *btShape = shape->create_bt_shape(p_xform.basis.get_scale_abs(), p_margin);
 	if (!btShape->isConvex()) {
 	if (!btShape->isConvex()) {
@@ -152,7 +152,7 @@ int BulletPhysicsDirectSpaceState::intersect_shape(const RID &p_shape, const Tra
 }
 }
 
 
 bool BulletPhysicsDirectSpaceState::cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, float p_margin, float &r_closest_safe, float &r_closest_unsafe, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, ShapeRestInfo *r_info) {
 bool BulletPhysicsDirectSpaceState::cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, float p_margin, float &r_closest_safe, float &r_closest_unsafe, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, ShapeRestInfo *r_info) {
-	ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->get(p_shape);
+	ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->getornull(p_shape);
 
 
 	btCollisionShape *btShape = shape->create_bt_shape(p_xform.basis.get_scale(), p_margin);
 	btCollisionShape *btShape = shape->create_bt_shape(p_xform.basis.get_scale(), p_margin);
 	if (!btShape->isConvex()) {
 	if (!btShape->isConvex()) {
@@ -207,7 +207,7 @@ bool BulletPhysicsDirectSpaceState::collide_shape(RID p_shape, const Transform &
 	if (p_result_max <= 0)
 	if (p_result_max <= 0)
 		return 0;
 		return 0;
 
 
-	ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->get(p_shape);
+	ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->getornull(p_shape);
 
 
 	btCollisionShape *btShape = shape->create_bt_shape(p_shape_xform.basis.get_scale_abs(), p_margin);
 	btCollisionShape *btShape = shape->create_bt_shape(p_shape_xform.basis.get_scale_abs(), p_margin);
 	if (!btShape->isConvex()) {
 	if (!btShape->isConvex()) {
@@ -239,7 +239,7 @@ bool BulletPhysicsDirectSpaceState::collide_shape(RID p_shape, const Transform &
 
 
 bool BulletPhysicsDirectSpaceState::rest_info(RID p_shape, const Transform &p_shape_xform, float p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
 bool BulletPhysicsDirectSpaceState::rest_info(RID p_shape, const Transform &p_shape_xform, float p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
 
 
-	ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->get(p_shape);
+	ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->getornull(p_shape);
 
 
 	btCollisionShape *btShape = shape->create_bt_shape(p_shape_xform.basis.get_scale_abs(), p_margin);
 	btCollisionShape *btShape = shape->create_bt_shape(p_shape_xform.basis.get_scale_abs(), p_margin);
 	if (!btShape->isConvex()) {
 	if (!btShape->isConvex()) {

+ 29 - 29
modules/gdnavigation/gd_navigation_server.cpp

@@ -140,7 +140,7 @@ RID GdNavigationServer::map_create() const {
 }
 }
 
 
 COMMAND_2(map_set_active, RID, p_map, bool, p_active) {
 COMMAND_2(map_set_active, RID, p_map, bool, p_active) {
-	NavMap *map = map_owner.get(p_map);
+	NavMap *map = map_owner.getornull(p_map);
 	ERR_FAIL_COND(map == NULL);
 	ERR_FAIL_COND(map == NULL);
 
 
 	if (p_active) {
 	if (p_active) {
@@ -153,56 +153,56 @@ COMMAND_2(map_set_active, RID, p_map, bool, p_active) {
 }
 }
 
 
 bool GdNavigationServer::map_is_active(RID p_map) const {
 bool GdNavigationServer::map_is_active(RID p_map) const {
-	NavMap *map = map_owner.get(p_map);
+	NavMap *map = map_owner.getornull(p_map);
 	ERR_FAIL_COND_V(map == NULL, false);
 	ERR_FAIL_COND_V(map == NULL, false);
 
 
 	return active_maps.find(map) >= 0;
 	return active_maps.find(map) >= 0;
 }
 }
 
 
 COMMAND_2(map_set_up, RID, p_map, Vector3, p_up) {
 COMMAND_2(map_set_up, RID, p_map, Vector3, p_up) {
-	NavMap *map = map_owner.get(p_map);
+	NavMap *map = map_owner.getornull(p_map);
 	ERR_FAIL_COND(map == NULL);
 	ERR_FAIL_COND(map == NULL);
 
 
 	map->set_up(p_up);
 	map->set_up(p_up);
 }
 }
 
 
 Vector3 GdNavigationServer::map_get_up(RID p_map) const {
 Vector3 GdNavigationServer::map_get_up(RID p_map) const {
-	NavMap *map = map_owner.get(p_map);
+	NavMap *map = map_owner.getornull(p_map);
 	ERR_FAIL_COND_V(map == NULL, Vector3());
 	ERR_FAIL_COND_V(map == NULL, Vector3());
 
 
 	return map->get_up();
 	return map->get_up();
 }
 }
 
 
 COMMAND_2(map_set_cell_size, RID, p_map, real_t, p_cell_size) {
 COMMAND_2(map_set_cell_size, RID, p_map, real_t, p_cell_size) {
-	NavMap *map = map_owner.get(p_map);
+	NavMap *map = map_owner.getornull(p_map);
 	ERR_FAIL_COND(map == NULL);
 	ERR_FAIL_COND(map == NULL);
 
 
 	map->set_cell_size(p_cell_size);
 	map->set_cell_size(p_cell_size);
 }
 }
 
 
 real_t GdNavigationServer::map_get_cell_size(RID p_map) const {
 real_t GdNavigationServer::map_get_cell_size(RID p_map) const {
-	NavMap *map = map_owner.get(p_map);
+	NavMap *map = map_owner.getornull(p_map);
 	ERR_FAIL_COND_V(map == NULL, 0);
 	ERR_FAIL_COND_V(map == NULL, 0);
 
 
 	return map->get_cell_size();
 	return map->get_cell_size();
 }
 }
 
 
 COMMAND_2(map_set_edge_connection_margin, RID, p_map, real_t, p_connection_margin) {
 COMMAND_2(map_set_edge_connection_margin, RID, p_map, real_t, p_connection_margin) {
-	NavMap *map = map_owner.get(p_map);
+	NavMap *map = map_owner.getornull(p_map);
 	ERR_FAIL_COND(map == NULL);
 	ERR_FAIL_COND(map == NULL);
 
 
 	map->set_edge_connection_margin(p_connection_margin);
 	map->set_edge_connection_margin(p_connection_margin);
 }
 }
 
 
 real_t GdNavigationServer::map_get_edge_connection_margin(RID p_map) const {
 real_t GdNavigationServer::map_get_edge_connection_margin(RID p_map) const {
-	NavMap *map = map_owner.get(p_map);
+	NavMap *map = map_owner.getornull(p_map);
 	ERR_FAIL_COND_V(map == NULL, 0);
 	ERR_FAIL_COND_V(map == NULL, 0);
 
 
 	return map->get_edge_connection_margin();
 	return map->get_edge_connection_margin();
 }
 }
 
 
 Vector<Vector3> GdNavigationServer::map_get_path(RID p_map, Vector3 p_origin, Vector3 p_destination, bool p_optimize) const {
 Vector<Vector3> GdNavigationServer::map_get_path(RID p_map, Vector3 p_origin, Vector3 p_destination, bool p_optimize) const {
-	NavMap *map = map_owner.get(p_map);
+	NavMap *map = map_owner.getornull(p_map);
 	ERR_FAIL_COND_V(map == NULL, Vector<Vector3>());
 	ERR_FAIL_COND_V(map == NULL, Vector<Vector3>());
 
 
 	return map->get_path(p_origin, p_destination, p_optimize);
 	return map->get_path(p_origin, p_destination, p_optimize);
@@ -219,7 +219,7 @@ RID GdNavigationServer::region_create() const {
 }
 }
 
 
 COMMAND_2(region_set_map, RID, p_region, RID, p_map) {
 COMMAND_2(region_set_map, RID, p_region, RID, p_map) {
-	NavRegion *region = region_owner.get(p_region);
+	NavRegion *region = region_owner.getornull(p_region);
 	ERR_FAIL_COND(region == NULL);
 	ERR_FAIL_COND(region == NULL);
 
 
 	if (region->get_map() != NULL) {
 	if (region->get_map() != NULL) {
@@ -232,7 +232,7 @@ COMMAND_2(region_set_map, RID, p_region, RID, p_map) {
 	}
 	}
 
 
 	if (p_map.is_valid()) {
 	if (p_map.is_valid()) {
-		NavMap *map = map_owner.get(p_map);
+		NavMap *map = map_owner.getornull(p_map);
 		ERR_FAIL_COND(map == NULL);
 		ERR_FAIL_COND(map == NULL);
 
 
 		map->add_region(region);
 		map->add_region(region);
@@ -241,14 +241,14 @@ COMMAND_2(region_set_map, RID, p_region, RID, p_map) {
 }
 }
 
 
 COMMAND_2(region_set_transform, RID, p_region, Transform, p_transform) {
 COMMAND_2(region_set_transform, RID, p_region, Transform, p_transform) {
-	NavRegion *region = region_owner.get(p_region);
+	NavRegion *region = region_owner.getornull(p_region);
 	ERR_FAIL_COND(region == NULL);
 	ERR_FAIL_COND(region == NULL);
 
 
 	region->set_transform(p_transform);
 	region->set_transform(p_transform);
 }
 }
 
 
 COMMAND_2(region_set_navmesh, RID, p_region, Ref<NavigationMesh>, p_nav_mesh) {
 COMMAND_2(region_set_navmesh, RID, p_region, Ref<NavigationMesh>, p_nav_mesh) {
-	NavRegion *region = region_owner.get(p_region);
+	NavRegion *region = region_owner.getornull(p_region);
 	ERR_FAIL_COND(region == NULL);
 	ERR_FAIL_COND(region == NULL);
 
 
 	region->set_mesh(p_nav_mesh);
 	region->set_mesh(p_nav_mesh);
@@ -275,7 +275,7 @@ RID GdNavigationServer::agent_create() const {
 }
 }
 
 
 COMMAND_2(agent_set_map, RID, p_agent, RID, p_map) {
 COMMAND_2(agent_set_map, RID, p_agent, RID, p_map) {
-	RvoAgent *agent = agent_owner.get(p_agent);
+	RvoAgent *agent = agent_owner.getornull(p_agent);
 	ERR_FAIL_COND(agent == NULL);
 	ERR_FAIL_COND(agent == NULL);
 
 
 	if (agent->get_map()) {
 	if (agent->get_map()) {
@@ -288,7 +288,7 @@ COMMAND_2(agent_set_map, RID, p_agent, RID, p_map) {
 	agent->set_map(NULL);
 	agent->set_map(NULL);
 
 
 	if (p_map.is_valid()) {
 	if (p_map.is_valid()) {
-		NavMap *map = map_owner.get(p_map);
+		NavMap *map = map_owner.getornull(p_map);
 		ERR_FAIL_COND(map == NULL);
 		ERR_FAIL_COND(map == NULL);
 
 
 		agent->set_map(map);
 		agent->set_map(map);
@@ -301,77 +301,77 @@ COMMAND_2(agent_set_map, RID, p_agent, RID, p_map) {
 }
 }
 
 
 COMMAND_2(agent_set_neighbor_dist, RID, p_agent, real_t, p_dist) {
 COMMAND_2(agent_set_neighbor_dist, RID, p_agent, real_t, p_dist) {
-	RvoAgent *agent = agent_owner.get(p_agent);
+	RvoAgent *agent = agent_owner.getornull(p_agent);
 	ERR_FAIL_COND(agent == NULL);
 	ERR_FAIL_COND(agent == NULL);
 
 
 	agent->get_agent()->neighborDist_ = p_dist;
 	agent->get_agent()->neighborDist_ = p_dist;
 }
 }
 
 
 COMMAND_2(agent_set_max_neighbors, RID, p_agent, int, p_count) {
 COMMAND_2(agent_set_max_neighbors, RID, p_agent, int, p_count) {
-	RvoAgent *agent = agent_owner.get(p_agent);
+	RvoAgent *agent = agent_owner.getornull(p_agent);
 	ERR_FAIL_COND(agent == NULL);
 	ERR_FAIL_COND(agent == NULL);
 
 
 	agent->get_agent()->maxNeighbors_ = p_count;
 	agent->get_agent()->maxNeighbors_ = p_count;
 }
 }
 
 
 COMMAND_2(agent_set_time_horizon, RID, p_agent, real_t, p_time) {
 COMMAND_2(agent_set_time_horizon, RID, p_agent, real_t, p_time) {
-	RvoAgent *agent = agent_owner.get(p_agent);
+	RvoAgent *agent = agent_owner.getornull(p_agent);
 	ERR_FAIL_COND(agent == NULL);
 	ERR_FAIL_COND(agent == NULL);
 
 
 	agent->get_agent()->timeHorizon_ = p_time;
 	agent->get_agent()->timeHorizon_ = p_time;
 }
 }
 
 
 COMMAND_2(agent_set_radius, RID, p_agent, real_t, p_radius) {
 COMMAND_2(agent_set_radius, RID, p_agent, real_t, p_radius) {
-	RvoAgent *agent = agent_owner.get(p_agent);
+	RvoAgent *agent = agent_owner.getornull(p_agent);
 	ERR_FAIL_COND(agent == NULL);
 	ERR_FAIL_COND(agent == NULL);
 
 
 	agent->get_agent()->radius_ = p_radius;
 	agent->get_agent()->radius_ = p_radius;
 }
 }
 
 
 COMMAND_2(agent_set_max_speed, RID, p_agent, real_t, p_max_speed) {
 COMMAND_2(agent_set_max_speed, RID, p_agent, real_t, p_max_speed) {
-	RvoAgent *agent = agent_owner.get(p_agent);
+	RvoAgent *agent = agent_owner.getornull(p_agent);
 	ERR_FAIL_COND(agent == NULL);
 	ERR_FAIL_COND(agent == NULL);
 
 
 	agent->get_agent()->maxSpeed_ = p_max_speed;
 	agent->get_agent()->maxSpeed_ = p_max_speed;
 }
 }
 
 
 COMMAND_2(agent_set_velocity, RID, p_agent, Vector3, p_velocity) {
 COMMAND_2(agent_set_velocity, RID, p_agent, Vector3, p_velocity) {
-	RvoAgent *agent = agent_owner.get(p_agent);
+	RvoAgent *agent = agent_owner.getornull(p_agent);
 	ERR_FAIL_COND(agent == NULL);
 	ERR_FAIL_COND(agent == NULL);
 
 
 	agent->get_agent()->velocity_ = RVO::Vector3(p_velocity.x, p_velocity.y, p_velocity.z);
 	agent->get_agent()->velocity_ = RVO::Vector3(p_velocity.x, p_velocity.y, p_velocity.z);
 }
 }
 
 
 COMMAND_2(agent_set_target_velocity, RID, p_agent, Vector3, p_velocity) {
 COMMAND_2(agent_set_target_velocity, RID, p_agent, Vector3, p_velocity) {
-	RvoAgent *agent = agent_owner.get(p_agent);
+	RvoAgent *agent = agent_owner.getornull(p_agent);
 	ERR_FAIL_COND(agent == NULL);
 	ERR_FAIL_COND(agent == NULL);
 
 
 	agent->get_agent()->prefVelocity_ = RVO::Vector3(p_velocity.x, p_velocity.y, p_velocity.z);
 	agent->get_agent()->prefVelocity_ = RVO::Vector3(p_velocity.x, p_velocity.y, p_velocity.z);
 }
 }
 
 
 COMMAND_2(agent_set_position, RID, p_agent, Vector3, p_position) {
 COMMAND_2(agent_set_position, RID, p_agent, Vector3, p_position) {
-	RvoAgent *agent = agent_owner.get(p_agent);
+	RvoAgent *agent = agent_owner.getornull(p_agent);
 	ERR_FAIL_COND(agent == NULL);
 	ERR_FAIL_COND(agent == NULL);
 
 
 	agent->get_agent()->position_ = RVO::Vector3(p_position.x, p_position.y, p_position.z);
 	agent->get_agent()->position_ = RVO::Vector3(p_position.x, p_position.y, p_position.z);
 }
 }
 
 
 COMMAND_2(agent_set_ignore_y, RID, p_agent, bool, p_ignore) {
 COMMAND_2(agent_set_ignore_y, RID, p_agent, bool, p_ignore) {
-	RvoAgent *agent = agent_owner.get(p_agent);
+	RvoAgent *agent = agent_owner.getornull(p_agent);
 	ERR_FAIL_COND(agent == NULL);
 	ERR_FAIL_COND(agent == NULL);
 
 
 	agent->get_agent()->ignore_y_ = p_ignore;
 	agent->get_agent()->ignore_y_ = p_ignore;
 }
 }
 
 
 bool GdNavigationServer::agent_is_map_changed(RID p_agent) const {
 bool GdNavigationServer::agent_is_map_changed(RID p_agent) const {
-	RvoAgent *agent = agent_owner.get(p_agent);
+	RvoAgent *agent = agent_owner.getornull(p_agent);
 	ERR_FAIL_COND_V(agent == NULL, false);
 	ERR_FAIL_COND_V(agent == NULL, false);
 
 
 	return agent->is_map_changed();
 	return agent->is_map_changed();
 }
 }
 
 
 COMMAND_4(agent_set_callback, RID, p_agent, Object *, p_receiver, StringName, p_method, Variant, p_udata) {
 COMMAND_4(agent_set_callback, RID, p_agent, Object *, p_receiver, StringName, p_method, Variant, p_udata) {
-	RvoAgent *agent = agent_owner.get(p_agent);
+	RvoAgent *agent = agent_owner.getornull(p_agent);
 	ERR_FAIL_COND(agent == NULL);
 	ERR_FAIL_COND(agent == NULL);
 
 
 	agent->set_callback(p_receiver == NULL ? 0 : p_receiver->get_instance_id(), p_method, p_udata);
 	agent->set_callback(p_receiver == NULL ? 0 : p_receiver->get_instance_id(), p_method, p_udata);
@@ -387,7 +387,7 @@ COMMAND_4(agent_set_callback, RID, p_agent, Object *, p_receiver, StringName, p_
 
 
 COMMAND_1(free, RID, p_object) {
 COMMAND_1(free, RID, p_object) {
 	if (map_owner.owns(p_object)) {
 	if (map_owner.owns(p_object)) {
-		NavMap *map = map_owner.get(p_object);
+		NavMap *map = map_owner.getornull(p_object);
 
 
 		// Removes any assigned region
 		// Removes any assigned region
 		std::vector<NavRegion *> regions = map->get_regions();
 		std::vector<NavRegion *> regions = map->get_regions();
@@ -408,7 +408,7 @@ COMMAND_1(free, RID, p_object) {
 		memdelete(map);
 		memdelete(map);
 
 
 	} else if (region_owner.owns(p_object)) {
 	} else if (region_owner.owns(p_object)) {
-		NavRegion *region = region_owner.get(p_object);
+		NavRegion *region = region_owner.getornull(p_object);
 
 
 		// Removes this region from the map if assigned
 		// Removes this region from the map if assigned
 		if (region->get_map() != NULL) {
 		if (region->get_map() != NULL) {
@@ -420,7 +420,7 @@ COMMAND_1(free, RID, p_object) {
 		memdelete(region);
 		memdelete(region);
 
 
 	} else if (agent_owner.owns(p_object)) {
 	} else if (agent_owner.owns(p_object)) {
-		RvoAgent *agent = agent_owner.get(p_object);
+		RvoAgent *agent = agent_owner.getornull(p_object);
 
 
 		// Removes this agent from the map if assigned
 		// Removes this agent from the map if assigned
 		if (agent->get_map() != NULL) {
 		if (agent->get_map() != NULL) {

+ 5 - 3
modules/gdnavigation/gd_navigation_server.h

@@ -31,6 +31,8 @@
 #ifndef GD_NAVIGATION_SERVER_H
 #ifndef GD_NAVIGATION_SERVER_H
 #define GD_NAVIGATION_SERVER_H
 #define GD_NAVIGATION_SERVER_H
 
 
+#include "core/rid.h"
+#include "core/rid_owner.h"
 #include "servers/navigation_server.h"
 #include "servers/navigation_server.h"
 
 
 #include "nav_map.h"
 #include "nav_map.h"
@@ -73,9 +75,9 @@ class GdNavigationServer : public NavigationServer {
 
 
 	std::vector<SetCommand *> commands;
 	std::vector<SetCommand *> commands;
 
 
-	mutable RID_Owner<NavMap> map_owner;
-	mutable RID_Owner<NavRegion> region_owner;
-	mutable RID_Owner<RvoAgent> agent_owner;
+	mutable RID_PtrOwner<NavMap> map_owner;
+	mutable RID_PtrOwner<NavRegion> region_owner;
+	mutable RID_PtrOwner<RvoAgent> agent_owner;
 
 
 	bool active;
 	bool active;
 	Vector<NavMap *> active_maps;
 	Vector<NavMap *> active_maps;

+ 1 - 1
modules/gdnavigation/nav_rid.h

@@ -37,7 +37,7 @@
 	@author AndreaCatania
 	@author AndreaCatania
 */
 */
 
 
-class NavRid : public RID_Data {
+class NavRid {
 	RID self;
 	RID self;
 
 
 public:
 public:

+ 1 - 1
scene/animation/skeleton_ik.h

@@ -98,7 +98,7 @@ class FabrikInverseKinematic {
 	};
 	};
 
 
 public:
 public:
-	struct Task : public RID_Data {
+	struct Task  {
 		RID self;
 		RID self;
 		Skeleton *skeleton;
 		Skeleton *skeleton;
 
 

+ 1 - 1
servers/physics/constraint_sw.h

@@ -33,7 +33,7 @@
 
 
 #include "body_sw.h"
 #include "body_sw.h"
 
 
-class ConstraintSW : public RID_Data {
+class ConstraintSW  {
 
 
 	BodySW **_body_ptr;
 	BodySW **_body_ptr;
 	int _body_count;
 	int _body_count;

Разлика између датотеке није приказан због своје велике величине
+ 120 - 120
servers/physics/physics_server_sw.cpp


+ 6 - 5
servers/physics/physics_server_sw.h

@@ -31,6 +31,7 @@
 #ifndef PHYSICS_SERVER_SW
 #ifndef PHYSICS_SERVER_SW
 #define PHYSICS_SERVER_SW
 #define PHYSICS_SERVER_SW
 
 
+#include "core/rid_owner.h"
 #include "joints_sw.h"
 #include "joints_sw.h"
 #include "servers/physics_server.h"
 #include "servers/physics_server.h"
 #include "shape_sw.h"
 #include "shape_sw.h"
@@ -58,11 +59,11 @@ class PhysicsServerSW : public PhysicsServer {
 
 
 	PhysicsDirectBodyStateSW *direct_state;
 	PhysicsDirectBodyStateSW *direct_state;
 
 
-	mutable RID_Owner<ShapeSW> shape_owner;
-	mutable RID_Owner<SpaceSW> space_owner;
-	mutable RID_Owner<AreaSW> area_owner;
-	mutable RID_Owner<BodySW> body_owner;
-	mutable RID_Owner<JointSW> joint_owner;
+	mutable RID_PtrOwner<ShapeSW> shape_owner;
+	mutable RID_PtrOwner<SpaceSW> space_owner;
+	mutable RID_PtrOwner<AreaSW> area_owner;
+	mutable RID_PtrOwner<BodySW> body_owner;
+	mutable RID_PtrOwner<JointSW> joint_owner;
 
 
 	//void _clear_query(QuerySW *p_query);
 	//void _clear_query(QuerySW *p_query);
 	friend class CollisionObjectSW;
 	friend class CollisionObjectSW;

+ 2 - 2
servers/physics/shape_sw.h

@@ -48,7 +48,7 @@ SHAPE_CUSTOM, ///< Server-Implementation based custom shape, calling shape_creat
 
 
 class ShapeSW;
 class ShapeSW;
 
 
-class ShapeOwnerSW : public RID_Data {
+class ShapeOwnerSW  {
 public:
 public:
 	virtual void _shape_changed() = 0;
 	virtual void _shape_changed() = 0;
 	virtual void remove_shape(ShapeSW *p_shape) = 0;
 	virtual void remove_shape(ShapeSW *p_shape) = 0;
@@ -56,7 +56,7 @@ public:
 	virtual ~ShapeOwnerSW() {}
 	virtual ~ShapeOwnerSW() {}
 };
 };
 
 
-class ShapeSW : public RID_Data {
+class ShapeSW  {
 
 
 	RID self;
 	RID self;
 	AABB aabb;
 	AABB aabb;

+ 4 - 4
servers/physics/space_sw.cpp

@@ -176,7 +176,7 @@ int PhysicsDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Transfo
 	if (p_result_max <= 0)
 	if (p_result_max <= 0)
 		return 0;
 		return 0;
 
 
-	ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.get(p_shape);
+	ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.getornull(p_shape);
 	ERR_FAIL_COND_V(!shape, 0);
 	ERR_FAIL_COND_V(!shape, 0);
 
 
 	AABB aabb = p_xform.xform(shape->get_aabb());
 	AABB aabb = p_xform.xform(shape->get_aabb());
@@ -224,7 +224,7 @@ int PhysicsDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Transfo
 
 
 bool PhysicsDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, ShapeRestInfo *r_info) {
 bool PhysicsDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, ShapeRestInfo *r_info) {
 
 
-	ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.get(p_shape);
+	ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.getornull(p_shape);
 	ERR_FAIL_COND_V(!shape, false);
 	ERR_FAIL_COND_V(!shape, false);
 
 
 	AABB aabb = p_xform.xform(shape->get_aabb());
 	AABB aabb = p_xform.xform(shape->get_aabb());
@@ -333,7 +333,7 @@ bool PhysicsDirectSpaceStateSW::collide_shape(RID p_shape, const Transform &p_sh
 	if (p_result_max <= 0)
 	if (p_result_max <= 0)
 		return 0;
 		return 0;
 
 
-	ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.get(p_shape);
+	ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.getornull(p_shape);
 	ERR_FAIL_COND_V(!shape, 0);
 	ERR_FAIL_COND_V(!shape, 0);
 
 
 	AABB aabb = p_shape_xform.xform(shape->get_aabb());
 	AABB aabb = p_shape_xform.xform(shape->get_aabb());
@@ -405,7 +405,7 @@ static void _rest_cbk_result(const Vector3 &p_point_A, const Vector3 &p_point_B,
 }
 }
 bool PhysicsDirectSpaceStateSW::rest_info(RID p_shape, const Transform &p_shape_xform, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
 bool PhysicsDirectSpaceStateSW::rest_info(RID p_shape, const Transform &p_shape_xform, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
 
 
-	ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.get(p_shape);
+	ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.getornull(p_shape);
 	ERR_FAIL_COND_V(!shape, 0);
 	ERR_FAIL_COND_V(!shape, 0);
 
 
 	AABB aabb = p_shape_xform.xform(shape->get_aabb());
 	AABB aabb = p_shape_xform.xform(shape->get_aabb());

+ 1 - 1
servers/physics/space_sw.h

@@ -59,7 +59,7 @@ public:
 	PhysicsDirectSpaceStateSW();
 	PhysicsDirectSpaceStateSW();
 };
 };
 
 
-class SpaceSW : public RID_Data {
+class SpaceSW  {
 
 
 public:
 public:
 	enum ElapsedTime {
 	enum ElapsedTime {

+ 1 - 1
servers/physics_2d/body_2d_sw.cpp

@@ -721,7 +721,7 @@ Variant Physics2DDirectBodyStateSW::get_contact_collider_shape_metadata(int p_co
 
 
 		return Variant();
 		return Variant();
 	}
 	}
-	Body2DSW *other = Physics2DServerSW::singletonsw->body_owner.get(body->contacts[p_contact_idx].collider);
+	Body2DSW *other = Physics2DServerSW::singletonsw->body_owner.getornull(body->contacts[p_contact_idx].collider);
 
 
 	int sidx = body->contacts[p_contact_idx].collider_shape;
 	int sidx = body->contacts[p_contact_idx].collider_shape;
 	if (sidx < 0 || sidx >= other->get_shape_count()) {
 	if (sidx < 0 || sidx >= other->get_shape_count()) {

+ 1 - 1
servers/physics_2d/constraint_2d_sw.h

@@ -33,7 +33,7 @@
 
 
 #include "body_2d_sw.h"
 #include "body_2d_sw.h"
 
 
-class Constraint2DSW : public RID_Data {
+class Constraint2DSW  {
 
 
 	Body2DSW **_body_ptr;
 	Body2DSW **_body_ptr;
 	int _body_count;
 	int _body_count;

Разлика између датотеке није приказан због своје велике величине
+ 123 - 123
servers/physics_2d/physics_2d_server_sw.cpp


+ 6 - 5
servers/physics_2d/physics_2d_server_sw.h

@@ -31,6 +31,7 @@
 #ifndef PHYSICS_2D_SERVER_SW
 #ifndef PHYSICS_2D_SERVER_SW
 #define PHYSICS_2D_SERVER_SW
 #define PHYSICS_2D_SERVER_SW
 
 
+#include "core/rid_owner.h"
 #include "joints_2d_sw.h"
 #include "joints_2d_sw.h"
 #include "servers/physics_2d_server.h"
 #include "servers/physics_2d_server.h"
 #include "shape_2d_sw.h"
 #include "shape_2d_sw.h"
@@ -61,11 +62,11 @@ class Physics2DServerSW : public Physics2DServer {
 
 
 	Physics2DDirectBodyStateSW *direct_state;
 	Physics2DDirectBodyStateSW *direct_state;
 
 
-	mutable RID_Owner<Shape2DSW> shape_owner;
-	mutable RID_Owner<Space2DSW> space_owner;
-	mutable RID_Owner<Area2DSW> area_owner;
-	mutable RID_Owner<Body2DSW> body_owner;
-	mutable RID_Owner<Joint2DSW> joint_owner;
+	mutable RID_PtrOwner<Shape2DSW> shape_owner;
+	mutable RID_PtrOwner<Space2DSW> space_owner;
+	mutable RID_PtrOwner<Area2DSW> area_owner;
+	mutable RID_PtrOwner<Body2DSW> body_owner;
+	mutable RID_PtrOwner<Joint2DSW> joint_owner;
 
 
 	static Physics2DServerSW *singletonsw;
 	static Physics2DServerSW *singletonsw;
 
 

+ 2 - 2
servers/physics_2d/shape_2d_sw.h

@@ -48,7 +48,7 @@ SHAPE_CUSTOM, ///< Server-Implementation based custom shape, calling shape_creat
 
 
 class Shape2DSW;
 class Shape2DSW;
 
 
-class ShapeOwner2DSW : public RID_Data {
+class ShapeOwner2DSW  {
 public:
 public:
 	virtual void _shape_changed() = 0;
 	virtual void _shape_changed() = 0;
 	virtual void remove_shape(Shape2DSW *p_shape) = 0;
 	virtual void remove_shape(Shape2DSW *p_shape) = 0;
@@ -56,7 +56,7 @@ public:
 	virtual ~ShapeOwner2DSW() {}
 	virtual ~ShapeOwner2DSW() {}
 };
 };
 
 
-class Shape2DSW : public RID_Data {
+class Shape2DSW  {
 
 
 	RID self;
 	RID self;
 	Rect2 aabb;
 	Rect2 aabb;

+ 4 - 4
servers/physics_2d/space_2d_sw.cpp

@@ -198,7 +198,7 @@ int Physics2DDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Trans
 	if (p_result_max <= 0)
 	if (p_result_max <= 0)
 		return 0;
 		return 0;
 
 
-	Shape2DSW *shape = Physics2DServerSW::singletonsw->shape_owner.get(p_shape);
+	Shape2DSW *shape = Physics2DServerSW::singletonsw->shape_owner.getornull(p_shape);
 	ERR_FAIL_COND_V(!shape, 0);
 	ERR_FAIL_COND_V(!shape, 0);
 
 
 	Rect2 aabb = p_xform.xform(shape->get_aabb());
 	Rect2 aabb = p_xform.xform(shape->get_aabb());
@@ -240,7 +240,7 @@ int Physics2DDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Trans
 
 
 bool Physics2DDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transform2D &p_xform, const Vector2 &p_motion, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
 bool Physics2DDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transform2D &p_xform, const Vector2 &p_motion, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
 
 
-	Shape2DSW *shape = Physics2DServerSW::singletonsw->shape_owner.get(p_shape);
+	Shape2DSW *shape = Physics2DServerSW::singletonsw->shape_owner.getornull(p_shape);
 	ERR_FAIL_COND_V(!shape, false);
 	ERR_FAIL_COND_V(!shape, false);
 
 
 	Rect2 aabb = p_xform.xform(shape->get_aabb());
 	Rect2 aabb = p_xform.xform(shape->get_aabb());
@@ -313,7 +313,7 @@ bool Physics2DDirectSpaceStateSW::collide_shape(RID p_shape, const Transform2D &
 	if (p_result_max <= 0)
 	if (p_result_max <= 0)
 		return 0;
 		return 0;
 
 
-	Shape2DSW *shape = Physics2DServerSW::singletonsw->shape_owner.get(p_shape);
+	Shape2DSW *shape = Physics2DServerSW::singletonsw->shape_owner.getornull(p_shape);
 	ERR_FAIL_COND_V(!shape, 0);
 	ERR_FAIL_COND_V(!shape, 0);
 
 
 	Rect2 aabb = p_shape_xform.xform(shape->get_aabb());
 	Rect2 aabb = p_shape_xform.xform(shape->get_aabb());
@@ -404,7 +404,7 @@ static void _rest_cbk_result(const Vector2 &p_point_A, const Vector2 &p_point_B,
 
 
 bool Physics2DDirectSpaceStateSW::rest_info(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
 bool Physics2DDirectSpaceStateSW::rest_info(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {
 
 
-	Shape2DSW *shape = Physics2DServerSW::singletonsw->shape_owner.get(p_shape);
+	Shape2DSW *shape = Physics2DServerSW::singletonsw->shape_owner.getornull(p_shape);
 	ERR_FAIL_COND_V(!shape, 0);
 	ERR_FAIL_COND_V(!shape, 0);
 
 
 	Rect2 aabb = p_shape_xform.xform(shape->get_aabb());
 	Rect2 aabb = p_shape_xform.xform(shape->get_aabb());

+ 1 - 1
servers/physics_2d/space_2d_sw.h

@@ -61,7 +61,7 @@ public:
 	Physics2DDirectSpaceStateSW();
 	Physics2DDirectSpaceStateSW();
 };
 };
 
 
-class Space2DSW : public RID_Data {
+class Space2DSW  {
 
 
 public:
 public:
 	enum ElapsedTime {
 	enum ElapsedTime {

+ 4 - 4
servers/visual/rasterizer.h

@@ -82,7 +82,7 @@ public:
 	virtual VS::EnvironmentBG environment_get_background(RID p_env) = 0;
 	virtual VS::EnvironmentBG environment_get_background(RID p_env) = 0;
 	virtual int environment_get_canvas_max_layer(RID p_env) = 0;
 	virtual int environment_get_canvas_max_layer(RID p_env) = 0;
 
 
-	struct InstanceBase : RID_Data {
+	struct InstanceBase {
 
 
 		VS::InstanceType base_type;
 		VS::InstanceType base_type;
 		RID base;
 		RID base;
@@ -608,7 +608,7 @@ public:
 		CANVAS_RECT_CLIP_UV = 32
 		CANVAS_RECT_CLIP_UV = 32
 	};
 	};
 
 
-	struct Light : public RID_Data {
+	struct Light {
 
 
 		bool enabled;
 		bool enabled;
 		Color color;
 		Color color;
@@ -678,7 +678,7 @@ public:
 	virtual void light_internal_update(RID p_rid, Light *p_light) = 0;
 	virtual void light_internal_update(RID p_rid, Light *p_light) = 0;
 	virtual void light_internal_free(RID p_rid) = 0;
 	virtual void light_internal_free(RID p_rid) = 0;
 
 
-	struct Item : public RID_Data {
+	struct Item {
 
 
 		struct Command {
 		struct Command {
 
 
@@ -1065,7 +1065,7 @@ public:
 	virtual void canvas_render_items(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light, const Transform2D &p_base_transform) = 0;
 	virtual void canvas_render_items(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light, const Transform2D &p_base_transform) = 0;
 	virtual void canvas_debug_viewport_shadows(Light *p_lights_with_shadow) = 0;
 	virtual void canvas_debug_viewport_shadows(Light *p_lights_with_shadow) = 0;
 
 
-	struct LightOccluderInstance : public RID_Data {
+	struct LightOccluderInstance {
 
 
 		bool enabled;
 		bool enabled;
 		RID canvas;
 		RID canvas;

+ 52 - 52
servers/visual/visual_server_canvas.cpp

@@ -74,7 +74,7 @@ void _collect_ysort_children(VisualServerCanvas::Item *p_canvas_item, Transform2
 	}
 	}
 }
 }
 
 
-void _mark_ysort_dirty(VisualServerCanvas::Item *ysort_owner, RID_Owner<VisualServerCanvas::Item> &canvas_item_owner) {
+void _mark_ysort_dirty(VisualServerCanvas::Item *ysort_owner, RID_PtrOwner<VisualServerCanvas::Item> &canvas_item_owner) {
 	do {
 	do {
 		ysort_owner->ysort_children_count = -1;
 		ysort_owner->ysort_children_count = -1;
 		ysort_owner = canvas_item_owner.owns(ysort_owner->parent) ? canvas_item_owner.getornull(ysort_owner->parent) : NULL;
 		ysort_owner = canvas_item_owner.owns(ysort_owner->parent) ? canvas_item_owner.getornull(ysort_owner->parent) : NULL;
@@ -320,7 +320,7 @@ void VisualServerCanvas::canvas_set_item_mirroring(RID p_canvas, RID p_item, con
 }
 }
 void VisualServerCanvas::canvas_set_modulate(RID p_canvas, const Color &p_color) {
 void VisualServerCanvas::canvas_set_modulate(RID p_canvas, const Color &p_color) {
 
 
-	Canvas *canvas = canvas_owner.get(p_canvas);
+	Canvas *canvas = canvas_owner.getornull(p_canvas);
 	ERR_FAIL_COND(!canvas);
 	ERR_FAIL_COND(!canvas);
 	canvas->modulate = p_color;
 	canvas->modulate = p_color;
 }
 }
@@ -331,7 +331,7 @@ void VisualServerCanvas::canvas_set_disable_scale(bool p_disable) {
 
 
 void VisualServerCanvas::canvas_set_parent(RID p_canvas, RID p_parent, float p_scale) {
 void VisualServerCanvas::canvas_set_parent(RID p_canvas, RID p_parent, float p_scale) {
 
 
-	Canvas *canvas = canvas_owner.get(p_canvas);
+	Canvas *canvas = canvas_owner.getornull(p_canvas);
 	ERR_FAIL_COND(!canvas);
 	ERR_FAIL_COND(!canvas);
 
 
 	canvas->parent = p_parent;
 	canvas->parent = p_parent;
@@ -355,11 +355,11 @@ void VisualServerCanvas::canvas_item_set_parent(RID p_item, RID p_parent) {
 
 
 		if (canvas_owner.owns(canvas_item->parent)) {
 		if (canvas_owner.owns(canvas_item->parent)) {
 
 
-			Canvas *canvas = canvas_owner.get(canvas_item->parent);
+			Canvas *canvas = canvas_owner.getornull(canvas_item->parent);
 			canvas->erase_item(canvas_item);
 			canvas->erase_item(canvas_item);
 		} else if (canvas_item_owner.owns(canvas_item->parent)) {
 		} else if (canvas_item_owner.owns(canvas_item->parent)) {
 
 
-			Item *item_owner = canvas_item_owner.get(canvas_item->parent);
+			Item *item_owner = canvas_item_owner.getornull(canvas_item->parent);
 			item_owner->child_items.erase(canvas_item);
 			item_owner->child_items.erase(canvas_item);
 
 
 			if (item_owner->sort_y) {
 			if (item_owner->sort_y) {
@@ -373,14 +373,14 @@ void VisualServerCanvas::canvas_item_set_parent(RID p_item, RID p_parent) {
 	if (p_parent.is_valid()) {
 	if (p_parent.is_valid()) {
 		if (canvas_owner.owns(p_parent)) {
 		if (canvas_owner.owns(p_parent)) {
 
 
-			Canvas *canvas = canvas_owner.get(p_parent);
+			Canvas *canvas = canvas_owner.getornull(p_parent);
 			Canvas::ChildItem ci;
 			Canvas::ChildItem ci;
 			ci.item = canvas_item;
 			ci.item = canvas_item;
 			canvas->child_items.push_back(ci);
 			canvas->child_items.push_back(ci);
 			canvas->children_order_dirty = true;
 			canvas->children_order_dirty = true;
 		} else if (canvas_item_owner.owns(p_parent)) {
 		} else if (canvas_item_owner.owns(p_parent)) {
 
 
-			Item *item_owner = canvas_item_owner.get(p_parent);
+			Item *item_owner = canvas_item_owner.getornull(p_parent);
 			item_owner->child_items.push_back(canvas_item);
 			item_owner->child_items.push_back(canvas_item);
 			item_owner->children_order_dirty = true;
 			item_owner->children_order_dirty = true;
 
 
@@ -983,7 +983,7 @@ void VisualServerCanvas::canvas_item_set_draw_index(RID p_item, int p_index) {
 
 
 void VisualServerCanvas::canvas_item_set_material(RID p_item, RID p_material) {
 void VisualServerCanvas::canvas_item_set_material(RID p_item, RID p_material) {
 
 
-	Item *canvas_item = canvas_item_owner.get(p_item);
+	Item *canvas_item = canvas_item_owner.getornull(p_item);
 	ERR_FAIL_COND(!canvas_item);
 	ERR_FAIL_COND(!canvas_item);
 
 
 	canvas_item->material = p_material;
 	canvas_item->material = p_material;
@@ -991,7 +991,7 @@ void VisualServerCanvas::canvas_item_set_material(RID p_item, RID p_material) {
 
 
 void VisualServerCanvas::canvas_item_set_use_parent_material(RID p_item, bool p_enable) {
 void VisualServerCanvas::canvas_item_set_use_parent_material(RID p_item, bool p_enable) {
 
 
-	Item *canvas_item = canvas_item_owner.get(p_item);
+	Item *canvas_item = canvas_item_owner.getornull(p_item);
 	ERR_FAIL_COND(!canvas_item);
 	ERR_FAIL_COND(!canvas_item);
 
 
 	canvas_item->use_parent_material = p_enable;
 	canvas_item->use_parent_material = p_enable;
@@ -1005,7 +1005,7 @@ RID VisualServerCanvas::canvas_light_create() {
 }
 }
 void VisualServerCanvas::canvas_light_attach_to_canvas(RID p_light, RID p_canvas) {
 void VisualServerCanvas::canvas_light_attach_to_canvas(RID p_light, RID p_canvas) {
 
 
-	RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
+	RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
 	ERR_FAIL_COND(!clight);
 	ERR_FAIL_COND(!clight);
 
 
 	if (clight->canvas.is_valid()) {
 	if (clight->canvas.is_valid()) {
@@ -1021,70 +1021,70 @@ void VisualServerCanvas::canvas_light_attach_to_canvas(RID p_light, RID p_canvas
 
 
 	if (clight->canvas.is_valid()) {
 	if (clight->canvas.is_valid()) {
 
 
-		Canvas *canvas = canvas_owner.get(clight->canvas);
+		Canvas *canvas = canvas_owner.getornull(clight->canvas);
 		canvas->lights.insert(clight);
 		canvas->lights.insert(clight);
 	}
 	}
 }
 }
 
 
 void VisualServerCanvas::canvas_light_set_enabled(RID p_light, bool p_enabled) {
 void VisualServerCanvas::canvas_light_set_enabled(RID p_light, bool p_enabled) {
 
 
-	RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
+	RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
 	ERR_FAIL_COND(!clight);
 	ERR_FAIL_COND(!clight);
 
 
 	clight->enabled = p_enabled;
 	clight->enabled = p_enabled;
 }
 }
 void VisualServerCanvas::canvas_light_set_scale(RID p_light, float p_scale) {
 void VisualServerCanvas::canvas_light_set_scale(RID p_light, float p_scale) {
 
 
-	RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
+	RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
 	ERR_FAIL_COND(!clight);
 	ERR_FAIL_COND(!clight);
 
 
 	clight->scale = p_scale;
 	clight->scale = p_scale;
 }
 }
 void VisualServerCanvas::canvas_light_set_transform(RID p_light, const Transform2D &p_transform) {
 void VisualServerCanvas::canvas_light_set_transform(RID p_light, const Transform2D &p_transform) {
 
 
-	RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
+	RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
 	ERR_FAIL_COND(!clight);
 	ERR_FAIL_COND(!clight);
 
 
 	clight->xform = p_transform;
 	clight->xform = p_transform;
 }
 }
 void VisualServerCanvas::canvas_light_set_texture(RID p_light, RID p_texture) {
 void VisualServerCanvas::canvas_light_set_texture(RID p_light, RID p_texture) {
 
 
-	RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
+	RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
 	ERR_FAIL_COND(!clight);
 	ERR_FAIL_COND(!clight);
 
 
 	clight->texture = p_texture;
 	clight->texture = p_texture;
 }
 }
 void VisualServerCanvas::canvas_light_set_texture_offset(RID p_light, const Vector2 &p_offset) {
 void VisualServerCanvas::canvas_light_set_texture_offset(RID p_light, const Vector2 &p_offset) {
 
 
-	RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
+	RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
 	ERR_FAIL_COND(!clight);
 	ERR_FAIL_COND(!clight);
 
 
 	clight->texture_offset = p_offset;
 	clight->texture_offset = p_offset;
 }
 }
 void VisualServerCanvas::canvas_light_set_color(RID p_light, const Color &p_color) {
 void VisualServerCanvas::canvas_light_set_color(RID p_light, const Color &p_color) {
 
 
-	RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
+	RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
 	ERR_FAIL_COND(!clight);
 	ERR_FAIL_COND(!clight);
 
 
 	clight->color = p_color;
 	clight->color = p_color;
 }
 }
 void VisualServerCanvas::canvas_light_set_height(RID p_light, float p_height) {
 void VisualServerCanvas::canvas_light_set_height(RID p_light, float p_height) {
 
 
-	RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
+	RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
 	ERR_FAIL_COND(!clight);
 	ERR_FAIL_COND(!clight);
 
 
 	clight->height = p_height;
 	clight->height = p_height;
 }
 }
 void VisualServerCanvas::canvas_light_set_energy(RID p_light, float p_energy) {
 void VisualServerCanvas::canvas_light_set_energy(RID p_light, float p_energy) {
 
 
-	RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
+	RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
 	ERR_FAIL_COND(!clight);
 	ERR_FAIL_COND(!clight);
 
 
 	clight->energy = p_energy;
 	clight->energy = p_energy;
 }
 }
 void VisualServerCanvas::canvas_light_set_z_range(RID p_light, int p_min_z, int p_max_z) {
 void VisualServerCanvas::canvas_light_set_z_range(RID p_light, int p_min_z, int p_max_z) {
 
 
-	RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
+	RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
 	ERR_FAIL_COND(!clight);
 	ERR_FAIL_COND(!clight);
 
 
 	clight->z_min = p_min_z;
 	clight->z_min = p_min_z;
@@ -1092,7 +1092,7 @@ void VisualServerCanvas::canvas_light_set_z_range(RID p_light, int p_min_z, int
 }
 }
 void VisualServerCanvas::canvas_light_set_layer_range(RID p_light, int p_min_layer, int p_max_layer) {
 void VisualServerCanvas::canvas_light_set_layer_range(RID p_light, int p_min_layer, int p_max_layer) {
 
 
-	RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
+	RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
 	ERR_FAIL_COND(!clight);
 	ERR_FAIL_COND(!clight);
 
 
 	clight->layer_max = p_max_layer;
 	clight->layer_max = p_max_layer;
@@ -1100,21 +1100,21 @@ void VisualServerCanvas::canvas_light_set_layer_range(RID p_light, int p_min_lay
 }
 }
 void VisualServerCanvas::canvas_light_set_item_cull_mask(RID p_light, int p_mask) {
 void VisualServerCanvas::canvas_light_set_item_cull_mask(RID p_light, int p_mask) {
 
 
-	RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
+	RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
 	ERR_FAIL_COND(!clight);
 	ERR_FAIL_COND(!clight);
 
 
 	clight->item_mask = p_mask;
 	clight->item_mask = p_mask;
 }
 }
 void VisualServerCanvas::canvas_light_set_item_shadow_cull_mask(RID p_light, int p_mask) {
 void VisualServerCanvas::canvas_light_set_item_shadow_cull_mask(RID p_light, int p_mask) {
 
 
-	RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
+	RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
 	ERR_FAIL_COND(!clight);
 	ERR_FAIL_COND(!clight);
 
 
 	clight->item_shadow_mask = p_mask;
 	clight->item_shadow_mask = p_mask;
 }
 }
 void VisualServerCanvas::canvas_light_set_mode(RID p_light, VS::CanvasLightMode p_mode) {
 void VisualServerCanvas::canvas_light_set_mode(RID p_light, VS::CanvasLightMode p_mode) {
 
 
-	RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
+	RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
 	ERR_FAIL_COND(!clight);
 	ERR_FAIL_COND(!clight);
 
 
 	clight->mode = p_mode;
 	clight->mode = p_mode;
@@ -1122,7 +1122,7 @@ void VisualServerCanvas::canvas_light_set_mode(RID p_light, VS::CanvasLightMode
 
 
 void VisualServerCanvas::canvas_light_set_shadow_enabled(RID p_light, bool p_enabled) {
 void VisualServerCanvas::canvas_light_set_shadow_enabled(RID p_light, bool p_enabled) {
 
 
-	RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
+	RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
 	ERR_FAIL_COND(!clight);
 	ERR_FAIL_COND(!clight);
 
 
 	if (clight->shadow_buffer.is_valid() == p_enabled)
 	if (clight->shadow_buffer.is_valid() == p_enabled)
@@ -1138,7 +1138,7 @@ void VisualServerCanvas::canvas_light_set_shadow_buffer_size(RID p_light, int p_
 
 
 	ERR_FAIL_COND(p_size < 32 || p_size > 16384);
 	ERR_FAIL_COND(p_size < 32 || p_size > 16384);
 
 
-	RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
+	RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
 	ERR_FAIL_COND(!clight);
 	ERR_FAIL_COND(!clight);
 
 
 	int new_size = next_power_of_2(p_size);
 	int new_size = next_power_of_2(p_size);
@@ -1157,21 +1157,21 @@ void VisualServerCanvas::canvas_light_set_shadow_gradient_length(RID p_light, fl
 
 
 	ERR_FAIL_COND(p_length < 0);
 	ERR_FAIL_COND(p_length < 0);
 
 
-	RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
+	RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
 	ERR_FAIL_COND(!clight);
 	ERR_FAIL_COND(!clight);
 
 
 	clight->shadow_gradient_length = p_length;
 	clight->shadow_gradient_length = p_length;
 }
 }
 void VisualServerCanvas::canvas_light_set_shadow_filter(RID p_light, VS::CanvasLightShadowFilter p_filter) {
 void VisualServerCanvas::canvas_light_set_shadow_filter(RID p_light, VS::CanvasLightShadowFilter p_filter) {
 
 
-	RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
+	RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
 	ERR_FAIL_COND(!clight);
 	ERR_FAIL_COND(!clight);
 
 
 	clight->shadow_filter = p_filter;
 	clight->shadow_filter = p_filter;
 }
 }
 void VisualServerCanvas::canvas_light_set_shadow_color(RID p_light, const Color &p_color) {
 void VisualServerCanvas::canvas_light_set_shadow_color(RID p_light, const Color &p_color) {
 
 
-	RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
+	RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
 	ERR_FAIL_COND(!clight);
 	ERR_FAIL_COND(!clight);
 
 
 	clight->shadow_color = p_color;
 	clight->shadow_color = p_color;
@@ -1179,7 +1179,7 @@ void VisualServerCanvas::canvas_light_set_shadow_color(RID p_light, const Color
 
 
 void VisualServerCanvas::canvas_light_set_shadow_smooth(RID p_light, float p_smooth) {
 void VisualServerCanvas::canvas_light_set_shadow_smooth(RID p_light, float p_smooth) {
 
 
-	RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
+	RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light);
 	ERR_FAIL_COND(!clight);
 	ERR_FAIL_COND(!clight);
 	clight->shadow_smooth = p_smooth;
 	clight->shadow_smooth = p_smooth;
 }
 }
@@ -1192,12 +1192,12 @@ RID VisualServerCanvas::canvas_light_occluder_create() {
 }
 }
 void VisualServerCanvas::canvas_light_occluder_attach_to_canvas(RID p_occluder, RID p_canvas) {
 void VisualServerCanvas::canvas_light_occluder_attach_to_canvas(RID p_occluder, RID p_canvas) {
 
 
-	RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.get(p_occluder);
+	RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder);
 	ERR_FAIL_COND(!occluder);
 	ERR_FAIL_COND(!occluder);
 
 
 	if (occluder->canvas.is_valid()) {
 	if (occluder->canvas.is_valid()) {
 
 
-		Canvas *canvas = canvas_owner.get(occluder->canvas);
+		Canvas *canvas = canvas_owner.getornull(occluder->canvas);
 		canvas->occluders.erase(occluder);
 		canvas->occluders.erase(occluder);
 	}
 	}
 
 
@@ -1208,24 +1208,24 @@ void VisualServerCanvas::canvas_light_occluder_attach_to_canvas(RID p_occluder,
 
 
 	if (occluder->canvas.is_valid()) {
 	if (occluder->canvas.is_valid()) {
 
 
-		Canvas *canvas = canvas_owner.get(occluder->canvas);
+		Canvas *canvas = canvas_owner.getornull(occluder->canvas);
 		canvas->occluders.insert(occluder);
 		canvas->occluders.insert(occluder);
 	}
 	}
 }
 }
 void VisualServerCanvas::canvas_light_occluder_set_enabled(RID p_occluder, bool p_enabled) {
 void VisualServerCanvas::canvas_light_occluder_set_enabled(RID p_occluder, bool p_enabled) {
 
 
-	RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.get(p_occluder);
+	RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder);
 	ERR_FAIL_COND(!occluder);
 	ERR_FAIL_COND(!occluder);
 
 
 	occluder->enabled = p_enabled;
 	occluder->enabled = p_enabled;
 }
 }
 void VisualServerCanvas::canvas_light_occluder_set_polygon(RID p_occluder, RID p_polygon) {
 void VisualServerCanvas::canvas_light_occluder_set_polygon(RID p_occluder, RID p_polygon) {
 
 
-	RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.get(p_occluder);
+	RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder);
 	ERR_FAIL_COND(!occluder);
 	ERR_FAIL_COND(!occluder);
 
 
 	if (occluder->polygon.is_valid()) {
 	if (occluder->polygon.is_valid()) {
-		LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get(p_polygon);
+		LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.getornull(p_polygon);
 		if (occluder_poly) {
 		if (occluder_poly) {
 			occluder_poly->owners.erase(occluder);
 			occluder_poly->owners.erase(occluder);
 		}
 		}
@@ -1235,7 +1235,7 @@ void VisualServerCanvas::canvas_light_occluder_set_polygon(RID p_occluder, RID p
 	occluder->polygon_buffer = RID();
 	occluder->polygon_buffer = RID();
 
 
 	if (occluder->polygon.is_valid()) {
 	if (occluder->polygon.is_valid()) {
-		LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get(p_polygon);
+		LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.getornull(p_polygon);
 		if (!occluder_poly) {
 		if (!occluder_poly) {
 			occluder->polygon = RID();
 			occluder->polygon = RID();
 			ERR_FAIL_COND(!occluder_poly);
 			ERR_FAIL_COND(!occluder_poly);
@@ -1249,14 +1249,14 @@ void VisualServerCanvas::canvas_light_occluder_set_polygon(RID p_occluder, RID p
 }
 }
 void VisualServerCanvas::canvas_light_occluder_set_transform(RID p_occluder, const Transform2D &p_xform) {
 void VisualServerCanvas::canvas_light_occluder_set_transform(RID p_occluder, const Transform2D &p_xform) {
 
 
-	RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.get(p_occluder);
+	RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder);
 	ERR_FAIL_COND(!occluder);
 	ERR_FAIL_COND(!occluder);
 
 
 	occluder->xform = p_xform;
 	occluder->xform = p_xform;
 }
 }
 void VisualServerCanvas::canvas_light_occluder_set_light_mask(RID p_occluder, int p_mask) {
 void VisualServerCanvas::canvas_light_occluder_set_light_mask(RID p_occluder, int p_mask) {
 
 
-	RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.get(p_occluder);
+	RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder);
 	ERR_FAIL_COND(!occluder);
 	ERR_FAIL_COND(!occluder);
 
 
 	occluder->light_mask = p_mask;
 	occluder->light_mask = p_mask;
@@ -1300,7 +1300,7 @@ void VisualServerCanvas::canvas_occluder_polygon_set_shape(RID p_occluder_polygo
 }
 }
 void VisualServerCanvas::canvas_occluder_polygon_set_shape_as_lines(RID p_occluder_polygon, const PoolVector<Vector2> &p_shape) {
 void VisualServerCanvas::canvas_occluder_polygon_set_shape_as_lines(RID p_occluder_polygon, const PoolVector<Vector2> &p_shape) {
 
 
-	LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get(p_occluder_polygon);
+	LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.getornull(p_occluder_polygon);
 	ERR_FAIL_COND(!occluder_poly);
 	ERR_FAIL_COND(!occluder_poly);
 	ERR_FAIL_COND(p_shape.size() & 1);
 	ERR_FAIL_COND(p_shape.size() & 1);
 
 
@@ -1324,7 +1324,7 @@ void VisualServerCanvas::canvas_occluder_polygon_set_shape_as_lines(RID p_occlud
 
 
 void VisualServerCanvas::canvas_occluder_polygon_set_cull_mode(RID p_occluder_polygon, VS::CanvasOccluderPolygonCullMode p_mode) {
 void VisualServerCanvas::canvas_occluder_polygon_set_cull_mode(RID p_occluder_polygon, VS::CanvasOccluderPolygonCullMode p_mode) {
 
 
-	LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get(p_occluder_polygon);
+	LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.getornull(p_occluder_polygon);
 	ERR_FAIL_COND(!occluder_poly);
 	ERR_FAIL_COND(!occluder_poly);
 	occluder_poly->cull_mode = p_mode;
 	occluder_poly->cull_mode = p_mode;
 	for (Set<RasterizerCanvas::LightOccluderInstance *>::Element *E = occluder_poly->owners.front(); E; E = E->next()) {
 	for (Set<RasterizerCanvas::LightOccluderInstance *>::Element *E = occluder_poly->owners.front(); E; E = E->next()) {
@@ -1336,12 +1336,12 @@ bool VisualServerCanvas::free(RID p_rid) {
 
 
 	if (canvas_owner.owns(p_rid)) {
 	if (canvas_owner.owns(p_rid)) {
 
 
-		Canvas *canvas = canvas_owner.get(p_rid);
+		Canvas *canvas = canvas_owner.getornull(p_rid);
 		ERR_FAIL_COND_V(!canvas, false);
 		ERR_FAIL_COND_V(!canvas, false);
 
 
 		while (canvas->viewports.size()) {
 		while (canvas->viewports.size()) {
 
 
-			VisualServerViewport::Viewport *vp = VSG::viewport->viewport_owner.get(canvas->viewports.front()->get());
+			VisualServerViewport::Viewport *vp = VSG::viewport->viewport_owner.getornull(canvas->viewports.front()->get());
 			ERR_FAIL_COND_V(!vp, true);
 			ERR_FAIL_COND_V(!vp, true);
 
 
 			Map<RID, VisualServerViewport::Viewport::CanvasData>::Element *E = vp->canvas_map.find(p_rid);
 			Map<RID, VisualServerViewport::Viewport::CanvasData>::Element *E = vp->canvas_map.find(p_rid);
@@ -1372,18 +1372,18 @@ bool VisualServerCanvas::free(RID p_rid) {
 
 
 	} else if (canvas_item_owner.owns(p_rid)) {
 	} else if (canvas_item_owner.owns(p_rid)) {
 
 
-		Item *canvas_item = canvas_item_owner.get(p_rid);
+		Item *canvas_item = canvas_item_owner.getornull(p_rid);
 		ERR_FAIL_COND_V(!canvas_item, true);
 		ERR_FAIL_COND_V(!canvas_item, true);
 
 
 		if (canvas_item->parent.is_valid()) {
 		if (canvas_item->parent.is_valid()) {
 
 
 			if (canvas_owner.owns(canvas_item->parent)) {
 			if (canvas_owner.owns(canvas_item->parent)) {
 
 
-				Canvas *canvas = canvas_owner.get(canvas_item->parent);
+				Canvas *canvas = canvas_owner.getornull(canvas_item->parent);
 				canvas->erase_item(canvas_item);
 				canvas->erase_item(canvas_item);
 			} else if (canvas_item_owner.owns(canvas_item->parent)) {
 			} else if (canvas_item_owner.owns(canvas_item->parent)) {
 
 
-				Item *item_owner = canvas_item_owner.get(canvas_item->parent);
+				Item *item_owner = canvas_item_owner.getornull(canvas_item->parent);
 				item_owner->child_items.erase(canvas_item);
 				item_owner->child_items.erase(canvas_item);
 
 
 				if (item_owner->sort_y) {
 				if (item_owner->sort_y) {
@@ -1409,11 +1409,11 @@ bool VisualServerCanvas::free(RID p_rid) {
 
 
 	} else if (canvas_light_owner.owns(p_rid)) {
 	} else if (canvas_light_owner.owns(p_rid)) {
 
 
-		RasterizerCanvas::Light *canvas_light = canvas_light_owner.get(p_rid);
+		RasterizerCanvas::Light *canvas_light = canvas_light_owner.getornull(p_rid);
 		ERR_FAIL_COND_V(!canvas_light, true);
 		ERR_FAIL_COND_V(!canvas_light, true);
 
 
 		if (canvas_light->canvas.is_valid()) {
 		if (canvas_light->canvas.is_valid()) {
-			Canvas *canvas = canvas_owner.get(canvas_light->canvas);
+			Canvas *canvas = canvas_owner.getornull(canvas_light->canvas);
 			if (canvas)
 			if (canvas)
 				canvas->lights.erase(canvas_light);
 				canvas->lights.erase(canvas_light);
 		}
 		}
@@ -1428,12 +1428,12 @@ bool VisualServerCanvas::free(RID p_rid) {
 
 
 	} else if (canvas_light_occluder_owner.owns(p_rid)) {
 	} else if (canvas_light_occluder_owner.owns(p_rid)) {
 
 
-		RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.get(p_rid);
+		RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_rid);
 		ERR_FAIL_COND_V(!occluder, true);
 		ERR_FAIL_COND_V(!occluder, true);
 
 
 		if (occluder->polygon.is_valid()) {
 		if (occluder->polygon.is_valid()) {
 
 
-			LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get(occluder->polygon);
+			LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.getornull(occluder->polygon);
 			if (occluder_poly) {
 			if (occluder_poly) {
 				occluder_poly->owners.erase(occluder);
 				occluder_poly->owners.erase(occluder);
 			}
 			}
@@ -1441,7 +1441,7 @@ bool VisualServerCanvas::free(RID p_rid) {
 
 
 		if (occluder->canvas.is_valid() && canvas_owner.owns(occluder->canvas)) {
 		if (occluder->canvas.is_valid() && canvas_owner.owns(occluder->canvas)) {
 
 
-			Canvas *canvas = canvas_owner.get(occluder->canvas);
+			Canvas *canvas = canvas_owner.getornull(occluder->canvas);
 			canvas->occluders.erase(occluder);
 			canvas->occluders.erase(occluder);
 		}
 		}
 
 
@@ -1450,7 +1450,7 @@ bool VisualServerCanvas::free(RID p_rid) {
 
 
 	} else if (canvas_light_occluder_polygon_owner.owns(p_rid)) {
 	} else if (canvas_light_occluder_polygon_owner.owns(p_rid)) {
 
 
-		LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get(p_rid);
+		LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.getornull(p_rid);
 		ERR_FAIL_COND_V(!occluder_poly, true);
 		ERR_FAIL_COND_V(!occluder_poly, true);
 		VSG::storage->free(occluder_poly->occluder);
 		VSG::storage->free(occluder_poly->occluder);
 
 

+ 6 - 6
servers/visual/visual_server_canvas.h

@@ -90,7 +90,7 @@ public:
 		}
 		}
 	};
 	};
 
 
-	struct LightOccluderPolygon : RID_Data {
+	struct LightOccluderPolygon  {
 
 
 		bool active;
 		bool active;
 		Rect2 aabb;
 		Rect2 aabb;
@@ -104,9 +104,9 @@ public:
 		}
 		}
 	};
 	};
 
 
-	RID_Owner<LightOccluderPolygon> canvas_light_occluder_polygon_owner;
+	RID_PtrOwner<LightOccluderPolygon> canvas_light_occluder_polygon_owner;
 
 
-	RID_Owner<RasterizerCanvas::LightOccluderInstance> canvas_light_occluder_owner;
+	RID_PtrOwner<RasterizerCanvas::LightOccluderInstance> canvas_light_occluder_owner;
 
 
 	struct Canvas : public VisualServerViewport::CanvasBase {
 	struct Canvas : public VisualServerViewport::CanvasBase {
 
 
@@ -150,9 +150,9 @@ public:
 		}
 		}
 	};
 	};
 
 
-	mutable RID_Owner<Canvas> canvas_owner;
-	RID_Owner<Item> canvas_item_owner;
-	RID_Owner<RasterizerCanvas::Light> canvas_light_owner;
+	mutable RID_PtrOwner<Canvas> canvas_owner;
+	RID_PtrOwner<Item> canvas_item_owner;
+	RID_PtrOwner<RasterizerCanvas::Light> canvas_light_owner;
 
 
 	bool disable_scale;
 	bool disable_scale;
 
 

+ 34 - 34
servers/visual/visual_server_scene.cpp

@@ -46,7 +46,7 @@ RID VisualServerScene::camera_create() {
 
 
 void VisualServerScene::camera_set_perspective(RID p_camera, float p_fovy_degrees, float p_z_near, float p_z_far) {
 void VisualServerScene::camera_set_perspective(RID p_camera, float p_fovy_degrees, float p_z_near, float p_z_far) {
 
 
-	Camera *camera = camera_owner.get(p_camera);
+	Camera *camera = camera_owner.getornull(p_camera);
 	ERR_FAIL_COND(!camera);
 	ERR_FAIL_COND(!camera);
 	camera->type = Camera::PERSPECTIVE;
 	camera->type = Camera::PERSPECTIVE;
 	camera->fov = p_fovy_degrees;
 	camera->fov = p_fovy_degrees;
@@ -56,7 +56,7 @@ void VisualServerScene::camera_set_perspective(RID p_camera, float p_fovy_degree
 
 
 void VisualServerScene::camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far) {
 void VisualServerScene::camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far) {
 
 
-	Camera *camera = camera_owner.get(p_camera);
+	Camera *camera = camera_owner.getornull(p_camera);
 	ERR_FAIL_COND(!camera);
 	ERR_FAIL_COND(!camera);
 	camera->type = Camera::ORTHOGONAL;
 	camera->type = Camera::ORTHOGONAL;
 	camera->size = p_size;
 	camera->size = p_size;
@@ -65,7 +65,7 @@ void VisualServerScene::camera_set_orthogonal(RID p_camera, float p_size, float
 }
 }
 
 
 void VisualServerScene::camera_set_frustum(RID p_camera, float p_size, Vector2 p_offset, float p_z_near, float p_z_far) {
 void VisualServerScene::camera_set_frustum(RID p_camera, float p_size, Vector2 p_offset, float p_z_near, float p_z_far) {
-	Camera *camera = camera_owner.get(p_camera);
+	Camera *camera = camera_owner.getornull(p_camera);
 	ERR_FAIL_COND(!camera);
 	ERR_FAIL_COND(!camera);
 	camera->type = Camera::FRUSTUM;
 	camera->type = Camera::FRUSTUM;
 	camera->size = p_size;
 	camera->size = p_size;
@@ -76,14 +76,14 @@ void VisualServerScene::camera_set_frustum(RID p_camera, float p_size, Vector2 p
 
 
 void VisualServerScene::camera_set_transform(RID p_camera, const Transform &p_transform) {
 void VisualServerScene::camera_set_transform(RID p_camera, const Transform &p_transform) {
 
 
-	Camera *camera = camera_owner.get(p_camera);
+	Camera *camera = camera_owner.getornull(p_camera);
 	ERR_FAIL_COND(!camera);
 	ERR_FAIL_COND(!camera);
 	camera->transform = p_transform.orthonormalized();
 	camera->transform = p_transform.orthonormalized();
 }
 }
 
 
 void VisualServerScene::camera_set_cull_mask(RID p_camera, uint32_t p_layers) {
 void VisualServerScene::camera_set_cull_mask(RID p_camera, uint32_t p_layers) {
 
 
-	Camera *camera = camera_owner.get(p_camera);
+	Camera *camera = camera_owner.getornull(p_camera);
 	ERR_FAIL_COND(!camera);
 	ERR_FAIL_COND(!camera);
 
 
 	camera->visible_layers = p_layers;
 	camera->visible_layers = p_layers;
@@ -91,14 +91,14 @@ void VisualServerScene::camera_set_cull_mask(RID p_camera, uint32_t p_layers) {
 
 
 void VisualServerScene::camera_set_environment(RID p_camera, RID p_env) {
 void VisualServerScene::camera_set_environment(RID p_camera, RID p_env) {
 
 
-	Camera *camera = camera_owner.get(p_camera);
+	Camera *camera = camera_owner.getornull(p_camera);
 	ERR_FAIL_COND(!camera);
 	ERR_FAIL_COND(!camera);
 	camera->env = p_env;
 	camera->env = p_env;
 }
 }
 
 
 void VisualServerScene::camera_set_use_vertical_aspect(RID p_camera, bool p_enable) {
 void VisualServerScene::camera_set_use_vertical_aspect(RID p_camera, bool p_enable) {
 
 
-	Camera *camera = camera_owner.get(p_camera);
+	Camera *camera = camera_owner.getornull(p_camera);
 	ERR_FAIL_COND(!camera);
 	ERR_FAIL_COND(!camera);
 	camera->vaspect = p_enable;
 	camera->vaspect = p_enable;
 }
 }
@@ -275,28 +275,28 @@ RID VisualServerScene::scenario_create() {
 
 
 void VisualServerScene::scenario_set_debug(RID p_scenario, VS::ScenarioDebugMode p_debug_mode) {
 void VisualServerScene::scenario_set_debug(RID p_scenario, VS::ScenarioDebugMode p_debug_mode) {
 
 
-	Scenario *scenario = scenario_owner.get(p_scenario);
+	Scenario *scenario = scenario_owner.getornull(p_scenario);
 	ERR_FAIL_COND(!scenario);
 	ERR_FAIL_COND(!scenario);
 	scenario->debug = p_debug_mode;
 	scenario->debug = p_debug_mode;
 }
 }
 
 
 void VisualServerScene::scenario_set_environment(RID p_scenario, RID p_environment) {
 void VisualServerScene::scenario_set_environment(RID p_scenario, RID p_environment) {
 
 
-	Scenario *scenario = scenario_owner.get(p_scenario);
+	Scenario *scenario = scenario_owner.getornull(p_scenario);
 	ERR_FAIL_COND(!scenario);
 	ERR_FAIL_COND(!scenario);
 	scenario->environment = p_environment;
 	scenario->environment = p_environment;
 }
 }
 
 
 void VisualServerScene::scenario_set_fallback_environment(RID p_scenario, RID p_environment) {
 void VisualServerScene::scenario_set_fallback_environment(RID p_scenario, RID p_environment) {
 
 
-	Scenario *scenario = scenario_owner.get(p_scenario);
+	Scenario *scenario = scenario_owner.getornull(p_scenario);
 	ERR_FAIL_COND(!scenario);
 	ERR_FAIL_COND(!scenario);
 	scenario->fallback_environment = p_environment;
 	scenario->fallback_environment = p_environment;
 }
 }
 
 
 void VisualServerScene::scenario_set_reflection_atlas_size(RID p_scenario, int p_size, int p_subdiv) {
 void VisualServerScene::scenario_set_reflection_atlas_size(RID p_scenario, int p_size, int p_subdiv) {
 
 
-	Scenario *scenario = scenario_owner.get(p_scenario);
+	Scenario *scenario = scenario_owner.getornull(p_scenario);
 	ERR_FAIL_COND(!scenario);
 	ERR_FAIL_COND(!scenario);
 	VSG::scene_render->reflection_atlas_set_size(scenario->reflection_atlas, p_size);
 	VSG::scene_render->reflection_atlas_set_size(scenario->reflection_atlas, p_size);
 	VSG::scene_render->reflection_atlas_set_subdivision(scenario->reflection_atlas, p_subdiv);
 	VSG::scene_render->reflection_atlas_set_subdivision(scenario->reflection_atlas, p_subdiv);
@@ -330,7 +330,7 @@ RID VisualServerScene::instance_create() {
 
 
 void VisualServerScene::instance_set_base(RID p_instance, RID p_base) {
 void VisualServerScene::instance_set_base(RID p_instance, RID p_base) {
 
 
-	Instance *instance = instance_owner.get(p_instance);
+	Instance *instance = instance_owner.getornull(p_instance);
 	ERR_FAIL_COND(!instance);
 	ERR_FAIL_COND(!instance);
 
 
 	Scenario *scenario = instance->scenario;
 	Scenario *scenario = instance->scenario;
@@ -503,7 +503,7 @@ void VisualServerScene::instance_set_base(RID p_instance, RID p_base) {
 }
 }
 void VisualServerScene::instance_set_scenario(RID p_instance, RID p_scenario) {
 void VisualServerScene::instance_set_scenario(RID p_instance, RID p_scenario) {
 
 
-	Instance *instance = instance_owner.get(p_instance);
+	Instance *instance = instance_owner.getornull(p_instance);
 	ERR_FAIL_COND(!instance);
 	ERR_FAIL_COND(!instance);
 
 
 	if (instance->scenario) {
 	if (instance->scenario) {
@@ -547,7 +547,7 @@ void VisualServerScene::instance_set_scenario(RID p_instance, RID p_scenario) {
 
 
 	if (p_scenario.is_valid()) {
 	if (p_scenario.is_valid()) {
 
 
-		Scenario *scenario = scenario_owner.get(p_scenario);
+		Scenario *scenario = scenario_owner.getornull(p_scenario);
 		ERR_FAIL_COND(!scenario);
 		ERR_FAIL_COND(!scenario);
 
 
 		instance->scenario = scenario;
 		instance->scenario = scenario;
@@ -580,14 +580,14 @@ void VisualServerScene::instance_set_scenario(RID p_instance, RID p_scenario) {
 }
 }
 void VisualServerScene::instance_set_layer_mask(RID p_instance, uint32_t p_mask) {
 void VisualServerScene::instance_set_layer_mask(RID p_instance, uint32_t p_mask) {
 
 
-	Instance *instance = instance_owner.get(p_instance);
+	Instance *instance = instance_owner.getornull(p_instance);
 	ERR_FAIL_COND(!instance);
 	ERR_FAIL_COND(!instance);
 
 
 	instance->layer_mask = p_mask;
 	instance->layer_mask = p_mask;
 }
 }
 void VisualServerScene::instance_set_transform(RID p_instance, const Transform &p_transform) {
 void VisualServerScene::instance_set_transform(RID p_instance, const Transform &p_transform) {
 
 
-	Instance *instance = instance_owner.get(p_instance);
+	Instance *instance = instance_owner.getornull(p_instance);
 	ERR_FAIL_COND(!instance);
 	ERR_FAIL_COND(!instance);
 
 
 	if (instance->transform == p_transform)
 	if (instance->transform == p_transform)
@@ -611,14 +611,14 @@ void VisualServerScene::instance_set_transform(RID p_instance, const Transform &
 }
 }
 void VisualServerScene::instance_attach_object_instance_id(RID p_instance, ObjectID p_id) {
 void VisualServerScene::instance_attach_object_instance_id(RID p_instance, ObjectID p_id) {
 
 
-	Instance *instance = instance_owner.get(p_instance);
+	Instance *instance = instance_owner.getornull(p_instance);
 	ERR_FAIL_COND(!instance);
 	ERR_FAIL_COND(!instance);
 
 
 	instance->object_id = p_id;
 	instance->object_id = p_id;
 }
 }
 void VisualServerScene::instance_set_blend_shape_weight(RID p_instance, int p_shape, float p_weight) {
 void VisualServerScene::instance_set_blend_shape_weight(RID p_instance, int p_shape, float p_weight) {
 
 
-	Instance *instance = instance_owner.get(p_instance);
+	Instance *instance = instance_owner.getornull(p_instance);
 	ERR_FAIL_COND(!instance);
 	ERR_FAIL_COND(!instance);
 
 
 	if (instance->update_item.in_list()) {
 	if (instance->update_item.in_list()) {
@@ -631,7 +631,7 @@ void VisualServerScene::instance_set_blend_shape_weight(RID p_instance, int p_sh
 
 
 void VisualServerScene::instance_set_surface_material(RID p_instance, int p_surface, RID p_material) {
 void VisualServerScene::instance_set_surface_material(RID p_instance, int p_surface, RID p_material) {
 
 
-	Instance *instance = instance_owner.get(p_instance);
+	Instance *instance = instance_owner.getornull(p_instance);
 	ERR_FAIL_COND(!instance);
 	ERR_FAIL_COND(!instance);
 
 
 	if (instance->base_type == VS::INSTANCE_MESH) {
 	if (instance->base_type == VS::INSTANCE_MESH) {
@@ -654,7 +654,7 @@ void VisualServerScene::instance_set_surface_material(RID p_instance, int p_surf
 
 
 void VisualServerScene::instance_set_visible(RID p_instance, bool p_visible) {
 void VisualServerScene::instance_set_visible(RID p_instance, bool p_visible) {
 
 
-	Instance *instance = instance_owner.get(p_instance);
+	Instance *instance = instance_owner.getornull(p_instance);
 	ERR_FAIL_COND(!instance);
 	ERR_FAIL_COND(!instance);
 
 
 	if (instance->visible == p_visible)
 	if (instance->visible == p_visible)
@@ -697,7 +697,7 @@ inline bool is_geometry_instance(VisualServer::InstanceType p_type) {
 
 
 void VisualServerScene::instance_set_use_lightmap(RID p_instance, RID p_lightmap_instance, RID p_lightmap) {
 void VisualServerScene::instance_set_use_lightmap(RID p_instance, RID p_lightmap_instance, RID p_lightmap) {
 
 
-	Instance *instance = instance_owner.get(p_instance);
+	Instance *instance = instance_owner.getornull(p_instance);
 	ERR_FAIL_COND(!instance);
 	ERR_FAIL_COND(!instance);
 
 
 	if (instance->lightmap_capture) {
 	if (instance->lightmap_capture) {
@@ -708,7 +708,7 @@ void VisualServerScene::instance_set_use_lightmap(RID p_instance, RID p_lightmap
 	}
 	}
 
 
 	if (p_lightmap_instance.is_valid()) {
 	if (p_lightmap_instance.is_valid()) {
-		Instance *lightmap_instance = instance_owner.get(p_lightmap_instance);
+		Instance *lightmap_instance = instance_owner.getornull(p_lightmap_instance);
 		ERR_FAIL_COND(!lightmap_instance);
 		ERR_FAIL_COND(!lightmap_instance);
 		ERR_FAIL_COND(lightmap_instance->base_type != VS::INSTANCE_LIGHTMAP_CAPTURE);
 		ERR_FAIL_COND(lightmap_instance->base_type != VS::INSTANCE_LIGHTMAP_CAPTURE);
 		instance->lightmap_capture = lightmap_instance;
 		instance->lightmap_capture = lightmap_instance;
@@ -721,7 +721,7 @@ void VisualServerScene::instance_set_use_lightmap(RID p_instance, RID p_lightmap
 
 
 void VisualServerScene::instance_set_custom_aabb(RID p_instance, AABB p_aabb) {
 void VisualServerScene::instance_set_custom_aabb(RID p_instance, AABB p_aabb) {
 
 
-	Instance *instance = instance_owner.get(p_instance);
+	Instance *instance = instance_owner.getornull(p_instance);
 	ERR_FAIL_COND(!instance);
 	ERR_FAIL_COND(!instance);
 	ERR_FAIL_COND(!is_geometry_instance(instance->base_type));
 	ERR_FAIL_COND(!is_geometry_instance(instance->base_type));
 
 
@@ -747,7 +747,7 @@ void VisualServerScene::instance_set_custom_aabb(RID p_instance, AABB p_aabb) {
 
 
 void VisualServerScene::instance_attach_skeleton(RID p_instance, RID p_skeleton) {
 void VisualServerScene::instance_attach_skeleton(RID p_instance, RID p_skeleton) {
 
 
-	Instance *instance = instance_owner.get(p_instance);
+	Instance *instance = instance_owner.getornull(p_instance);
 	ERR_FAIL_COND(!instance);
 	ERR_FAIL_COND(!instance);
 
 
 	if (instance->skeleton == p_skeleton)
 	if (instance->skeleton == p_skeleton)
@@ -770,7 +770,7 @@ void VisualServerScene::instance_set_exterior(RID p_instance, bool p_enabled) {
 }
 }
 
 
 void VisualServerScene::instance_set_extra_visibility_margin(RID p_instance, real_t p_margin) {
 void VisualServerScene::instance_set_extra_visibility_margin(RID p_instance, real_t p_margin) {
-	Instance *instance = instance_owner.get(p_instance);
+	Instance *instance = instance_owner.getornull(p_instance);
 	ERR_FAIL_COND(!instance);
 	ERR_FAIL_COND(!instance);
 
 
 	instance->extra_margin = p_margin;
 	instance->extra_margin = p_margin;
@@ -780,7 +780,7 @@ void VisualServerScene::instance_set_extra_visibility_margin(RID p_instance, rea
 Vector<ObjectID> VisualServerScene::instances_cull_aabb(const AABB &p_aabb, RID p_scenario) const {
 Vector<ObjectID> VisualServerScene::instances_cull_aabb(const AABB &p_aabb, RID p_scenario) const {
 
 
 	Vector<ObjectID> instances;
 	Vector<ObjectID> instances;
-	Scenario *scenario = scenario_owner.get(p_scenario);
+	Scenario *scenario = scenario_owner.getornull(p_scenario);
 	ERR_FAIL_COND_V(!scenario, instances);
 	ERR_FAIL_COND_V(!scenario, instances);
 
 
 	const_cast<VisualServerScene *>(this)->update_dirty_instances(); // check dirty instances before culling
 	const_cast<VisualServerScene *>(this)->update_dirty_instances(); // check dirty instances before culling
@@ -804,7 +804,7 @@ Vector<ObjectID> VisualServerScene::instances_cull_aabb(const AABB &p_aabb, RID
 Vector<ObjectID> VisualServerScene::instances_cull_ray(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario) const {
 Vector<ObjectID> VisualServerScene::instances_cull_ray(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario) const {
 
 
 	Vector<ObjectID> instances;
 	Vector<ObjectID> instances;
-	Scenario *scenario = scenario_owner.get(p_scenario);
+	Scenario *scenario = scenario_owner.getornull(p_scenario);
 	ERR_FAIL_COND_V(!scenario, instances);
 	ERR_FAIL_COND_V(!scenario, instances);
 	const_cast<VisualServerScene *>(this)->update_dirty_instances(); // check dirty instances before culling
 	const_cast<VisualServerScene *>(this)->update_dirty_instances(); // check dirty instances before culling
 
 
@@ -826,7 +826,7 @@ Vector<ObjectID> VisualServerScene::instances_cull_ray(const Vector3 &p_from, co
 Vector<ObjectID> VisualServerScene::instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario) const {
 Vector<ObjectID> VisualServerScene::instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario) const {
 
 
 	Vector<ObjectID> instances;
 	Vector<ObjectID> instances;
-	Scenario *scenario = scenario_owner.get(p_scenario);
+	Scenario *scenario = scenario_owner.getornull(p_scenario);
 	ERR_FAIL_COND_V(!scenario, instances);
 	ERR_FAIL_COND_V(!scenario, instances);
 	const_cast<VisualServerScene *>(this)->update_dirty_instances(); // check dirty instances before culling
 	const_cast<VisualServerScene *>(this)->update_dirty_instances(); // check dirty instances before culling
 
 
@@ -850,7 +850,7 @@ Vector<ObjectID> VisualServerScene::instances_cull_convex(const Vector<Plane> &p
 
 
 void VisualServerScene::instance_geometry_set_flag(RID p_instance, VS::InstanceFlags p_flags, bool p_enabled) {
 void VisualServerScene::instance_geometry_set_flag(RID p_instance, VS::InstanceFlags p_flags, bool p_enabled) {
 
 
-	Instance *instance = instance_owner.get(p_instance);
+	Instance *instance = instance_owner.getornull(p_instance);
 	ERR_FAIL_COND(!instance);
 	ERR_FAIL_COND(!instance);
 
 
 	switch (p_flags) {
 	switch (p_flags) {
@@ -871,7 +871,7 @@ void VisualServerScene::instance_geometry_set_flag(RID p_instance, VS::InstanceF
 }
 }
 void VisualServerScene::instance_geometry_set_cast_shadows_setting(RID p_instance, VS::ShadowCastingSetting p_shadow_casting_setting) {
 void VisualServerScene::instance_geometry_set_cast_shadows_setting(RID p_instance, VS::ShadowCastingSetting p_shadow_casting_setting) {
 
 
-	Instance *instance = instance_owner.get(p_instance);
+	Instance *instance = instance_owner.getornull(p_instance);
 	ERR_FAIL_COND(!instance);
 	ERR_FAIL_COND(!instance);
 
 
 	instance->cast_shadows = p_shadow_casting_setting;
 	instance->cast_shadows = p_shadow_casting_setting;
@@ -879,7 +879,7 @@ void VisualServerScene::instance_geometry_set_cast_shadows_setting(RID p_instanc
 }
 }
 void VisualServerScene::instance_geometry_set_material_override(RID p_instance, RID p_material) {
 void VisualServerScene::instance_geometry_set_material_override(RID p_instance, RID p_material) {
 
 
-	Instance *instance = instance_owner.get(p_instance);
+	Instance *instance = instance_owner.getornull(p_instance);
 	ERR_FAIL_COND(!instance);
 	ERR_FAIL_COND(!instance);
 
 
 	if (instance->material_override.is_valid()) {
 	if (instance->material_override.is_valid()) {
@@ -3468,14 +3468,14 @@ bool VisualServerScene::free(RID p_rid) {
 
 
 	if (camera_owner.owns(p_rid)) {
 	if (camera_owner.owns(p_rid)) {
 
 
-		Camera *camera = camera_owner.get(p_rid);
+		Camera *camera = camera_owner.getornull(p_rid);
 
 
 		camera_owner.free(p_rid);
 		camera_owner.free(p_rid);
 		memdelete(camera);
 		memdelete(camera);
 
 
 	} else if (scenario_owner.owns(p_rid)) {
 	} else if (scenario_owner.owns(p_rid)) {
 
 
-		Scenario *scenario = scenario_owner.get(p_rid);
+		Scenario *scenario = scenario_owner.getornull(p_rid);
 
 
 		while (scenario->instances.first()) {
 		while (scenario->instances.first()) {
 			instance_set_scenario(scenario->instances.first()->self()->self, RID());
 			instance_set_scenario(scenario->instances.first()->self()->self, RID());
@@ -3490,7 +3490,7 @@ bool VisualServerScene::free(RID p_rid) {
 
 
 		update_dirty_instances();
 		update_dirty_instances();
 
 
-		Instance *instance = instance_owner.get(p_rid);
+		Instance *instance = instance_owner.getornull(p_rid);
 
 
 		instance_set_use_lightmap(p_rid, RID(), RID());
 		instance_set_use_lightmap(p_rid, RID(), RID());
 		instance_set_scenario(p_rid, RID());
 		instance_set_scenario(p_rid, RID());

+ 6 - 5
servers/visual/visual_server_scene.h

@@ -37,6 +37,7 @@
 #include "core/math/octree.h"
 #include "core/math/octree.h"
 #include "core/os/semaphore.h"
 #include "core/os/semaphore.h"
 #include "core/os/thread.h"
 #include "core/os/thread.h"
+#include "core/rid_owner.h"
 #include "core/self_list.h"
 #include "core/self_list.h"
 #include "servers/arvr/arvr_interface.h"
 #include "servers/arvr/arvr_interface.h"
 
 
@@ -57,7 +58,7 @@ public:
 
 
 	/* CAMERA API */
 	/* CAMERA API */
 
 
-	struct Camera : public RID_Data {
+	struct Camera {
 
 
 		enum Type {
 		enum Type {
 			PERSPECTIVE,
 			PERSPECTIVE,
@@ -88,7 +89,7 @@ public:
 		}
 		}
 	};
 	};
 
 
-	mutable RID_Owner<Camera> camera_owner;
+	mutable RID_PtrOwner<Camera> camera_owner;
 
 
 	virtual RID camera_create();
 	virtual RID camera_create();
 	virtual void camera_set_perspective(RID p_camera, float p_fovy_degrees, float p_z_near, float p_z_far);
 	virtual void camera_set_perspective(RID p_camera, float p_fovy_degrees, float p_z_near, float p_z_far);
@@ -103,7 +104,7 @@ public:
 
 
 	struct Instance;
 	struct Instance;
 
 
-	struct Scenario : RID_Data {
+	struct Scenario {
 
 
 		VS::ScenarioDebugMode debug;
 		VS::ScenarioDebugMode debug;
 		RID self;
 		RID self;
@@ -121,7 +122,7 @@ public:
 		Scenario() { debug = VS::SCENARIO_DEBUG_DISABLED; }
 		Scenario() { debug = VS::SCENARIO_DEBUG_DISABLED; }
 	};
 	};
 
 
-	mutable RID_Owner<Scenario> scenario_owner;
+	mutable RID_PtrOwner<Scenario> scenario_owner;
 
 
 	static void *_instance_pair(void *p_self, OctreeElementID, Instance *p_A, int, OctreeElementID, Instance *p_B, int);
 	static void *_instance_pair(void *p_self, OctreeElementID, Instance *p_A, int, OctreeElementID, Instance *p_B, int);
 	static void _instance_unpair(void *p_self, OctreeElementID, Instance *p_A, int, OctreeElementID, Instance *p_B, int, void *);
 	static void _instance_unpair(void *p_self, OctreeElementID, Instance *p_A, int, OctreeElementID, Instance *p_B, int, void *);
@@ -432,7 +433,7 @@ public:
 	RID reflection_probe_instance_cull_result[MAX_REFLECTION_PROBES_CULLED];
 	RID reflection_probe_instance_cull_result[MAX_REFLECTION_PROBES_CULLED];
 	int reflection_probe_cull_count;
 	int reflection_probe_cull_count;
 
 
-	RID_Owner<Instance> instance_owner;
+	RID_PtrOwner<Instance> instance_owner;
 
 
 	virtual RID instance_create();
 	virtual RID instance_create();
 
 

+ 1 - 1
servers/visual/visual_server_viewport.cpp

@@ -84,7 +84,7 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E
 
 
 	if (!p_viewport->hide_canvas && !p_viewport->disable_environment && VSG::scene->scenario_owner.owns(p_viewport->scenario)) {
 	if (!p_viewport->hide_canvas && !p_viewport->disable_environment && VSG::scene->scenario_owner.owns(p_viewport->scenario)) {
 
 
-		VisualServerScene::Scenario *scenario = VSG::scene->scenario_owner.get(p_viewport->scenario);
+		VisualServerScene::Scenario *scenario = VSG::scene->scenario_owner.getornull(p_viewport->scenario);
 		ERR_FAIL_COND(!scenario);
 		ERR_FAIL_COND(!scenario);
 		if (VSG::scene_render->is_environment(scenario->environment)) {
 		if (VSG::scene_render->is_environment(scenario->environment)) {
 			scenario_draw_canvas_bg = VSG::scene_render->environment_get_background(scenario->environment) == VS::ENV_BG_CANVAS;
 			scenario_draw_canvas_bg = VSG::scene_render->environment_get_background(scenario->environment) == VS::ENV_BG_CANVAS;

+ 4 - 3
servers/visual/visual_server_viewport.h

@@ -31,6 +31,7 @@
 #ifndef VISUALSERVERVIEWPORT_H
 #ifndef VISUALSERVERVIEWPORT_H
 #define VISUALSERVERVIEWPORT_H
 #define VISUALSERVERVIEWPORT_H
 
 
+#include "core/rid_owner.h"
 #include "core/self_list.h"
 #include "core/self_list.h"
 #include "rasterizer.h"
 #include "rasterizer.h"
 #include "servers/arvr/arvr_interface.h"
 #include "servers/arvr/arvr_interface.h"
@@ -38,10 +39,10 @@
 
 
 class VisualServerViewport {
 class VisualServerViewport {
 public:
 public:
-	struct CanvasBase : public RID_Data {
+	struct CanvasBase {
 	};
 	};
 
 
-	struct Viewport : public RID_Data {
+	struct Viewport {
 
 
 		RID self;
 		RID self;
 		RID parent;
 		RID parent;
@@ -127,7 +128,7 @@ public:
 		}
 		}
 	};
 	};
 
 
-	mutable RID_Owner<Viewport> viewport_owner;
+	mutable RID_PtrOwner<Viewport> viewport_owner;
 
 
 	struct ViewportSort {
 	struct ViewportSort {
 		_FORCE_INLINE_ bool operator()(const Viewport *p_left, const Viewport *p_right) const {
 		_FORCE_INLINE_ bool operator()(const Viewport *p_left, const Viewport *p_right) const {

Неке датотеке нису приказане због велике количине промена