mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-02-19 22:24:23 +01:00
More module cleanups.
This commit is contained in:
parent
77d4171dff
commit
ef952b88b7
@ -136,11 +136,7 @@ Vector<Variant> SpeciesModelData::get_customizable_slot_entries(const int slot_i
|
||||
ERR_FAIL_INDEX_V(slot_index, _customizable_slots.size(), r);
|
||||
|
||||
for (int i = 0; i < _customizable_slots[slot_index].size(); i++) {
|
||||
#if GODOT4
|
||||
r.push_back(_customizable_slots[slot_index][i]);
|
||||
#else
|
||||
r.push_back(_customizable_slots[slot_index][i].get_ref_ptr());
|
||||
#endif
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
@ -22,8 +22,6 @@ SOFTWARE.
|
||||
|
||||
#include "texture_layer_merger.h"
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
int TextureLayerMerger::get_width() const {
|
||||
return _width;
|
||||
}
|
||||
@ -68,11 +66,7 @@ Ref<ImageTexture> TextureLayerMerger::get_result_as_texture() const {
|
||||
ERR_FAIL_COND_V(!_image.is_valid(), Ref<ImageTexture>());
|
||||
|
||||
Ref<ImageTexture> tex;
|
||||
#if VERSION_MAJOR < 4
|
||||
tex.instance();
|
||||
#else
|
||||
tex.instantiate();
|
||||
#endif
|
||||
tex->create_from_image(_image);
|
||||
|
||||
return tex;
|
||||
@ -166,11 +160,7 @@ void TextureLayerMerger::set_rect(const int p_index, const Rect2 &p_rect) {
|
||||
void TextureLayerMerger::remove_texture(const int p_index) {
|
||||
ERR_FAIL_INDEX(p_index, _entries.size());
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
return _entries.remove(p_index);
|
||||
#else
|
||||
return _entries.remove_at(p_index);
|
||||
#endif
|
||||
}
|
||||
|
||||
int TextureLayerMerger::get_texture_count() {
|
||||
@ -185,11 +175,7 @@ void TextureLayerMerger::merge() {
|
||||
ERR_FAIL_COND(_width <= 0 || _height <= 0);
|
||||
|
||||
if (!_image.is_valid()) {
|
||||
#if VERSION_MAJOR < 4
|
||||
_image.instance();
|
||||
#else
|
||||
_image.instantiate();
|
||||
#endif
|
||||
}
|
||||
|
||||
PoolVector<uint8_t> data;
|
||||
@ -224,11 +210,7 @@ void TextureLayerMerger::merge() {
|
||||
|
||||
ERR_CONTINUE(!atlas.is_valid());
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
input_image = atlas->get_data();
|
||||
#else
|
||||
input_image = atlas->get_image();
|
||||
#endif
|
||||
|
||||
Rect2 region = altas_texture->get_region();
|
||||
|
||||
@ -244,11 +226,7 @@ void TextureLayerMerger::merge() {
|
||||
if (rh > atlas_h)
|
||||
rh = atlas_h;
|
||||
} else {
|
||||
#if VERSION_MAJOR < 4
|
||||
input_image = e.texture->get_data();
|
||||
#else
|
||||
input_image = e.texture->get_image();
|
||||
#endif
|
||||
}
|
||||
|
||||
ERR_CONTINUE(!input_image.is_valid());
|
||||
@ -334,11 +312,7 @@ void TextureLayerMerger::merge() {
|
||||
}
|
||||
}
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
_image->create(_width, _height, (_texture_flags & Texture::FLAG_MIPMAPS) != 0, Image::FORMAT_RGBA8, data);
|
||||
#else
|
||||
_image->create(_width, _height, true, Image::FORMAT_RGBA8, data);
|
||||
#endif
|
||||
}
|
||||
|
||||
void TextureLayerMerger::write_base_color_to_array(PoolVector<uint8_t> &data) {
|
||||
|
@ -22,36 +22,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/object/ref_counted.h"
|
||||
#ifndef Reference
|
||||
#define Reference RefCounted
|
||||
#endif
|
||||
#include "core/templates/vector.h"
|
||||
#include "core/io/image.h"
|
||||
#else
|
||||
#include "core/image.h"
|
||||
#include "core/reference.h"
|
||||
#include "core/vector.h"
|
||||
#include "core/image.h"
|
||||
#endif
|
||||
|
||||
#include "core/math/rect2.h"
|
||||
#include "scene/resources/texture.h"
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR >= 4
|
||||
#define PoolVector Vector
|
||||
#define Texture Texture2D
|
||||
#endif
|
||||
|
||||
class TextureLayerMerger : public Reference {
|
||||
|
||||
GDCLASS(TextureLayerMerger, Reference);
|
||||
|
||||
public:
|
||||
|
@ -87,11 +87,7 @@ void TextureMerger::set_packer(const Ref<TexturePacker> &packer) {
|
||||
Vector<Variant> TextureMerger::get_textures() {
|
||||
Vector<Variant> r;
|
||||
for (int i = 0; i < _textures.size(); i++) {
|
||||
#if VERSION_MAJOR < 4
|
||||
r.push_back(_textures[i].get_ref_ptr());
|
||||
#else
|
||||
r.push_back(_textures[i]);
|
||||
#endif
|
||||
}
|
||||
return r;
|
||||
}
|
||||
@ -140,13 +136,9 @@ Ref<AtlasTexture> TextureMerger::add_texture(const Ref<Texture> &texture) {
|
||||
Ref<AtlasTexture> tex = _packer->add_texture(texture);
|
||||
|
||||
if (!contains) {
|
||||
#if VERSION_MAJOR < 4
|
||||
if (has_method("_texture_added")) {
|
||||
call("_texture_added", tex);
|
||||
}
|
||||
#else
|
||||
GDVIRTUAL_CALL(_texture_added, tex);
|
||||
#endif
|
||||
|
||||
emit_signal("texture_added", tex);
|
||||
|
||||
@ -174,13 +166,9 @@ Ref<AtlasTexture> TextureMerger::get_texture_index(const int index) {
|
||||
|
||||
bool TextureMerger::unref_texture_index(const int index) {
|
||||
if (_packer->unref_texture_index(index)) {
|
||||
#if VERSION_MAJOR < 4
|
||||
if (has_method("_texture_removed")) {
|
||||
call("_texture_removed");
|
||||
}
|
||||
#else
|
||||
GDVIRTUAL_CALL(_texture_removed);
|
||||
#endif
|
||||
|
||||
emit_signal("texture_removed");
|
||||
|
||||
@ -194,13 +182,9 @@ bool TextureMerger::unref_texture_index(const int index) {
|
||||
|
||||
bool TextureMerger::unref_texture(const Ref<Texture> &texture) {
|
||||
if (_packer->unref_texture(texture)) {
|
||||
#if VERSION_MAJOR < 4
|
||||
if (has_method("_texture_removed")) {
|
||||
call("_texture_removed");
|
||||
}
|
||||
#else
|
||||
GDVIRTUAL_CALL(_texture_removed);
|
||||
#endif
|
||||
|
||||
emit_signal("texture_removed");
|
||||
|
||||
@ -215,13 +199,9 @@ bool TextureMerger::unref_texture(const Ref<Texture> &texture) {
|
||||
void TextureMerger::remove_texture_index(const int index) {
|
||||
_packer->remove_texture_index(index);
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
if (has_method("_texture_removed")) {
|
||||
call("_texture_removed");
|
||||
}
|
||||
#else
|
||||
GDVIRTUAL_CALL(_texture_removed);
|
||||
#endif
|
||||
|
||||
emit_signal("texture_removed");
|
||||
|
||||
@ -231,13 +211,9 @@ void TextureMerger::remove_texture_index(const int index) {
|
||||
void TextureMerger::remove_texture(const Ref<Texture> &texture) {
|
||||
_packer->remove_texture(texture);
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
if (has_method("_texture_removed")) {
|
||||
call("_texture_removed");
|
||||
}
|
||||
#else
|
||||
GDVIRTUAL_CALL(_texture_removed);
|
||||
#endif
|
||||
|
||||
emit_signal("texture_removed");
|
||||
|
||||
@ -262,13 +238,9 @@ int TextureMerger::get_generated_texture_count() {
|
||||
void TextureMerger::merge() {
|
||||
_packer->merge();
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
if (has_method("_texture_merged")) {
|
||||
call("_texture_merged");
|
||||
}
|
||||
#else
|
||||
GDVIRTUAL_CALL(_texture_merged);
|
||||
#endif
|
||||
|
||||
emit_signal("texture_merged");
|
||||
}
|
||||
@ -276,11 +248,7 @@ void TextureMerger::merge() {
|
||||
TextureMerger::TextureMerger() {
|
||||
_automatic_merge = false;
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
_packer.instance();
|
||||
#else
|
||||
_packer.instantiate();
|
||||
#endif
|
||||
|
||||
_packer->set_keep_original_atlases(false);
|
||||
}
|
||||
@ -313,15 +281,9 @@ void TextureMerger::_bind_methods() {
|
||||
ADD_SIGNAL(MethodInfo("texture_added", PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "AtlasTexture")));
|
||||
ADD_SIGNAL(MethodInfo("texture_removed"));
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
BIND_VMETHOD(MethodInfo("_texture_merged"));
|
||||
BIND_VMETHOD(MethodInfo("_texture_added", PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "AtlasTexture")));
|
||||
BIND_VMETHOD(MethodInfo("_texture_removed"));
|
||||
#else
|
||||
GDVIRTUAL_BIND(_texture_merged);
|
||||
GDVIRTUAL_BIND(_texture_added, "texture");
|
||||
GDVIRTUAL_BIND(_texture_removed);
|
||||
#endif
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_dirty"), &TextureMerger::get_dirty);
|
||||
ClassDB::bind_method(D_METHOD("set_dirty", "value"), &TextureMerger::set_dirty);
|
||||
|
@ -22,18 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/templates/vector.h"
|
||||
#include "core/config/engine.h"
|
||||
#else
|
||||
#include "core/vector.h"
|
||||
#include "core/engine.h"
|
||||
#endif
|
||||
#include "core/vector.h"
|
||||
|
||||
#include "scene/main/node.h"
|
||||
|
||||
@ -89,12 +79,6 @@ public:
|
||||
|
||||
void merge();
|
||||
|
||||
#if VERSION_MAJOR >= 4
|
||||
GDVIRTUAL0(_texture_merged);
|
||||
GDVIRTUAL1(_texture_added, Ref<AtlasTexture>);
|
||||
GDVIRTUAL0(_texture_removed);
|
||||
#endif
|
||||
|
||||
TextureMerger();
|
||||
~TextureMerger();
|
||||
|
||||
@ -107,7 +91,7 @@ private:
|
||||
bool _dirty;
|
||||
|
||||
Ref<TexturePacker> _packer;
|
||||
Vector<Ref<Texture> > _textures;
|
||||
Vector<Ref<Texture>> _textures;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -83,11 +83,7 @@ Ref<AtlasTexture> TexturePacker::add_texture(const Ref<Texture> &texture) {
|
||||
}
|
||||
|
||||
Ref<AtlasTexture> tex;
|
||||
#if VERSION_MAJOR < 4
|
||||
tex.instance();
|
||||
#else
|
||||
tex.instantiate();
|
||||
#endif
|
||||
|
||||
tex->set_atlas(atlas_text->get_atlas());
|
||||
tex->set_region(atlas_text->get_region());
|
||||
@ -124,11 +120,7 @@ Ref<AtlasTexture> TexturePacker::add_texture(const Ref<Texture> &texture) {
|
||||
}
|
||||
|
||||
Ref<AtlasTexture> tex;
|
||||
#if VERSION_MAJOR < 4
|
||||
tex.instance();
|
||||
#else
|
||||
tex.instantiate();
|
||||
#endif
|
||||
|
||||
//Temp setup, so the texture is usable even while the atlases are generating.
|
||||
tex->set_atlas(texture);
|
||||
@ -208,11 +200,7 @@ bool TexturePacker::unref_texture_index(const int index) {
|
||||
int rc = --(r->refcount);
|
||||
|
||||
if (rc <= 0) {
|
||||
#if VERSION_MAJOR < 4
|
||||
_rects.remove(index);
|
||||
#else
|
||||
_rects.remove_at(index);
|
||||
#endif
|
||||
|
||||
r->original_texture.unref();
|
||||
r->atlas_texture.unref();
|
||||
@ -241,11 +229,7 @@ bool TexturePacker::unref_texture(const Ref<Texture> &texture) {
|
||||
int rc = --(r->refcount);
|
||||
|
||||
if (rc <= 0) {
|
||||
#if VERSION_MAJOR < 4
|
||||
_rects.remove(i);
|
||||
#else
|
||||
_rects.remove_at(i);
|
||||
#endif
|
||||
|
||||
r->original_texture.unref();
|
||||
r->atlas_texture.unref();
|
||||
@ -286,11 +270,7 @@ void TexturePacker::remove_texture(const Ref<Texture> &texture) {
|
||||
t = r->original_texture;
|
||||
|
||||
if (t == texture) {
|
||||
#if VERSION_MAJOR < 4
|
||||
_rects.remove(i);
|
||||
#else
|
||||
_rects.remove_at(i);
|
||||
#endif
|
||||
|
||||
r->original_texture.unref();
|
||||
r->atlas_texture.unref();
|
||||
@ -382,11 +362,7 @@ void TexturePacker::merge() {
|
||||
|
||||
ERR_CONTINUE(!otext.is_valid());
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
Ref<Image> img = otext->get_data();
|
||||
#else
|
||||
Ref<Image> img = otext->get_image();
|
||||
#endif
|
||||
|
||||
ERR_CONTINUE(!img.is_valid());
|
||||
|
||||
@ -413,25 +389,13 @@ void TexturePacker::merge() {
|
||||
}
|
||||
|
||||
Ref<Image> image;
|
||||
#if VERSION_MAJOR < 4
|
||||
image.instance();
|
||||
#else
|
||||
image.instantiate();
|
||||
#endif
|
||||
image->create(b.size.w, b.size.h, false, Image::FORMAT_RGBA8, data);
|
||||
|
||||
Ref<ImageTexture> texture;
|
||||
#if VERSION_MAJOR < 4
|
||||
texture.instance();
|
||||
#else
|
||||
texture.instantiate();
|
||||
#endif
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
texture->create_from_image(image, _texture_flags);
|
||||
#else
|
||||
texture->create_from_image(image);
|
||||
#endif
|
||||
|
||||
_generated_textures.set(i, texture);
|
||||
|
||||
@ -476,12 +440,10 @@ int TexturePacker::get_offset_for_format(const Image::Format format) {
|
||||
case Image::FORMAT_BPTC_RGBA:
|
||||
case Image::FORMAT_BPTC_RGBF:
|
||||
case Image::FORMAT_BPTC_RGBFU:
|
||||
#if VERSION_MAJOR <= 3
|
||||
case Image::FORMAT_PVRTC2:
|
||||
case Image::FORMAT_PVRTC2A:
|
||||
case Image::FORMAT_PVRTC4:
|
||||
case Image::FORMAT_PVRTC4A:
|
||||
#endif
|
||||
case Image::FORMAT_ETC:
|
||||
case Image::FORMAT_ETC2_R11:
|
||||
case Image::FORMAT_ETC2_R11S:
|
||||
@ -490,13 +452,7 @@ int TexturePacker::get_offset_for_format(const Image::Format format) {
|
||||
case Image::FORMAT_ETC2_RGB8:
|
||||
case Image::FORMAT_ETC2_RGBA8:
|
||||
case Image::FORMAT_ETC2_RGB8A1:
|
||||
#if VERSION_MAJOR >= 4
|
||||
case Image::FORMAT_RGB565:
|
||||
case Image::FORMAT_ETC2_RA_AS_RG:
|
||||
case Image::FORMAT_DXT5_RA_AS_RG:
|
||||
#else
|
||||
case Image::FORMAT_RGBA5551:
|
||||
#endif
|
||||
case Image::FORMAT_MAX:
|
||||
return 0;
|
||||
}
|
||||
@ -505,11 +461,7 @@ int TexturePacker::get_offset_for_format(const Image::Format format) {
|
||||
}
|
||||
|
||||
TexturePacker::TexturePacker() {
|
||||
#if VERSION_MAJOR < 4
|
||||
_texture_flags = Texture::FLAG_MIPMAPS | Texture::FLAG_FILTER;
|
||||
#else
|
||||
_texture_flags = 0;
|
||||
#endif
|
||||
|
||||
_max_atlas_size = 1024;
|
||||
_keep_original_atlases = false;
|
||||
|
@ -22,41 +22,17 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/io/image.h"
|
||||
#include "core/object/ref_counted.h"
|
||||
#ifndef Reference
|
||||
#define Reference RefCounted
|
||||
#endif
|
||||
#include "core/templates/vector.h"
|
||||
#include "core/string/ustring.h"
|
||||
#include "core/math/color.h"
|
||||
#else
|
||||
#include "core/color.h"
|
||||
#include "core/image.h"
|
||||
#include "core/reference.h"
|
||||
#include "core/vector.h"
|
||||
#include "core/ustring.h"
|
||||
#include "core/color.h"
|
||||
#endif
|
||||
#include "core/vector.h"
|
||||
|
||||
#include "scene/resources/texture.h"
|
||||
#include <vector>
|
||||
|
||||
#include "rectpack2D/pack.h"
|
||||
|
||||
#if VERSION_MAJOR >= 4
|
||||
#define PoolVector Vector
|
||||
#define Texture Texture2D
|
||||
#define PoolByteArray PackedByteArray
|
||||
|
||||
#define REAL FLOAT
|
||||
#endif
|
||||
|
||||
class TexturePacker : public Reference {
|
||||
GDCLASS(TexturePacker, Reference);
|
||||
|
||||
@ -114,7 +90,7 @@ private:
|
||||
int _margin;
|
||||
|
||||
Vector<rect_xywhf *> _rects;
|
||||
Vector<Ref<ImageTexture> > _generated_textures;
|
||||
Vector<Ref<ImageTexture>> _generated_textures;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -27,11 +27,7 @@ SOFTWARE.
|
||||
void EditorPluginPackerImageResource::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE:
|
||||
#if VERSION_MAJOR < 4
|
||||
_importer.instance();
|
||||
#else
|
||||
_importer.instantiate();
|
||||
#endif
|
||||
add_import_plugin(_importer);
|
||||
|
||||
break;
|
||||
|
@ -22,23 +22,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/string/ustring.h"
|
||||
#else
|
||||
#include "core/ustring.h"
|
||||
#endif
|
||||
|
||||
#include "editor/editor_plugin.h"
|
||||
|
||||
#include "packer_image_resource_importer.h"
|
||||
|
||||
class EditorPluginPackerImageResource : public EditorPlugin {
|
||||
|
||||
GDCLASS(EditorPluginPackerImageResource, EditorPlugin);
|
||||
|
||||
public:
|
||||
|
@ -73,10 +73,8 @@ Ref<Image> PackerImageResource::get_data() const {
|
||||
|
||||
void PackerImageResource::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_data", "image"), &PackerImageResource::set_data);
|
||||
#if VERSION_MAJOR < 4
|
||||
//for some reason this crashes on 4.0. Not yet sure why
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "Image", PROPERTY_USAGE_DEFAULT), "set_data", "get_data");
|
||||
#endif
|
||||
}
|
||||
|
||||
PackerImageResource::PackerImageResource() {
|
||||
|
@ -22,16 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/io/image.h"
|
||||
#else
|
||||
#include "core/image.h"
|
||||
#endif
|
||||
|
||||
#include "scene/resources/texture.h"
|
||||
|
||||
|
@ -22,12 +22,6 @@ SOFTWARE.
|
||||
|
||||
#include "packer_image_resource_importer.h"
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR >= 4
|
||||
#define REAL FLOAT
|
||||
#endif
|
||||
|
||||
String PackerImageResourceImporter::get_importer_name() const {
|
||||
return "packer_image_resource";
|
||||
}
|
||||
@ -74,11 +68,7 @@ Error PackerImageResourceImporter::import(const String &p_source_file, const Str
|
||||
float scale = p_options["scale"];
|
||||
|
||||
Ref<Image> image;
|
||||
#if VERSION_MAJOR < 4
|
||||
image.instance();
|
||||
#else
|
||||
image.instantiate();
|
||||
#endif
|
||||
Error err = ImageLoader::load_image(p_source_file, image, NULL, hdr_as_srgb, scale);
|
||||
|
||||
if (err != OK) {
|
||||
@ -86,11 +76,7 @@ Error PackerImageResourceImporter::import(const String &p_source_file, const Str
|
||||
}
|
||||
|
||||
Ref<PackerImageResource> res;
|
||||
#if VERSION_MAJOR < 4
|
||||
res.instance();
|
||||
#else
|
||||
res.instantiate();
|
||||
#endif
|
||||
|
||||
res->set_data(image);
|
||||
|
||||
|
@ -22,18 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/string/ustring.h"
|
||||
#include "core/io/image.h"
|
||||
#else
|
||||
#include "core/ustring.h"
|
||||
#include "core/image.h"
|
||||
#endif
|
||||
#include "core/ustring.h"
|
||||
|
||||
#include "core/io/resource_saver.h"
|
||||
#include "editor/import/editor_import_plugin.h"
|
||||
@ -43,7 +33,6 @@ SOFTWARE.
|
||||
#include "packer_image_resource.h"
|
||||
|
||||
class PackerImageResourceImporter : public EditorImportPlugin {
|
||||
|
||||
GDCLASS(PackerImageResourceImporter, EditorImportPlugin);
|
||||
|
||||
public:
|
||||
|
@ -24,30 +24,16 @@ SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/config/engine.h"
|
||||
#include "core/config/project_settings.h"
|
||||
#else
|
||||
#include "core/engine.h"
|
||||
#include "core/project_settings.h"
|
||||
#endif
|
||||
|
||||
#include "core/os/os.h"
|
||||
#include "scene/main/scene_tree.h"
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR >= 4
|
||||
#define CONNECT(sig, obj, target_method_class, method) connect(sig, callable_mp(obj, &target_method_class::method))
|
||||
#define DISCONNECT(sig, obj, target_method_class, method) disconnect(sig, callable_mp(obj, &target_method_class::method))
|
||||
|
||||
#define REAL FLOAT
|
||||
#else
|
||||
#define CONNECT(sig, obj, target_method_class, method) connect(sig, obj, #method)
|
||||
#define DISCONNECT(sig, obj, target_method_class, method) disconnect(sig, obj, #method)
|
||||
#endif
|
||||
|
||||
ThreadPool *ThreadPool::_instance;
|
||||
|
||||
|
@ -25,15 +25,8 @@ SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/object/object.h"
|
||||
#include "core/templates/vector.h"
|
||||
#else
|
||||
#include "core/object.h"
|
||||
#include "core/vector.h"
|
||||
#endif
|
||||
|
||||
#include "core/os/semaphore.h"
|
||||
#include "core/os/thread.h"
|
||||
|
@ -22,13 +22,7 @@ SOFTWARE.
|
||||
|
||||
#include "thread_pool_execute_job.h"
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/variant/variant.h"
|
||||
#else
|
||||
#include "core/variant.h"
|
||||
#endif
|
||||
|
||||
#include "core/os/os.h"
|
||||
|
||||
@ -50,11 +44,7 @@ void ThreadPoolExecuteJob::_execute() {
|
||||
ERR_FAIL_COND(!_object);
|
||||
ERR_FAIL_COND(!_object->has_method(_method));
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
Variant::CallError error;
|
||||
#else
|
||||
Callable::CallError error;
|
||||
#endif
|
||||
|
||||
_object->call(_method, const_cast<const Variant **>(&_argptr), _argcount, error);
|
||||
}
|
||||
@ -86,28 +76,16 @@ void ThreadPoolExecuteJob::setup(const Variant &obj, const StringName &p_method,
|
||||
}
|
||||
}
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
Variant ThreadPoolExecuteJob::_setup_bind(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
|
||||
#else
|
||||
Variant ThreadPoolExecuteJob::_setup_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
|
||||
#endif
|
||||
if (p_argcount < 2) {
|
||||
#if VERSION_MAJOR < 4
|
||||
r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
#else
|
||||
r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
#endif
|
||||
|
||||
r_error.argument = 1;
|
||||
return Variant();
|
||||
}
|
||||
|
||||
if (p_args[0]->get_type() != Variant::OBJECT) {
|
||||
#if VERSION_MAJOR < 4
|
||||
r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||
#else
|
||||
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||
#endif
|
||||
|
||||
r_error.argument = 0;
|
||||
r_error.expected = Variant::OBJECT;
|
||||
@ -115,11 +93,7 @@ Variant ThreadPoolExecuteJob::_setup_bind(const Variant **p_args, int p_argcount
|
||||
}
|
||||
|
||||
if (p_args[1]->get_type() != Variant::STRING) {
|
||||
#if VERSION_MAJOR < 4
|
||||
r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||
#else
|
||||
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||
#endif
|
||||
|
||||
r_error.argument = 1;
|
||||
r_error.expected = Variant::STRING;
|
||||
@ -161,11 +135,7 @@ Variant ThreadPoolExecuteJob::_setup_bind(const Variant **p_args, int p_argcount
|
||||
set_complete(true);
|
||||
}
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
r_error.error = Variant::CallError::CALL_OK;
|
||||
#else
|
||||
r_error.error = Callable::CallError::CALL_OK;
|
||||
#endif
|
||||
|
||||
return Variant();
|
||||
}
|
||||
|
@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "thread_pool_job.h"
|
||||
|
||||
class ThreadPoolExecuteJob : public ThreadPoolJob {
|
||||
@ -39,11 +36,7 @@ public:
|
||||
|
||||
void _execute();
|
||||
void setup(const Variant &obj, const StringName &p_method, VARIANT_ARG_LIST);
|
||||
#if VERSION_MAJOR < 4
|
||||
Variant _setup_bind(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
|
||||
#else
|
||||
Variant _setup_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
|
||||
#endif
|
||||
|
||||
ThreadPoolExecuteJob();
|
||||
~ThreadPoolExecuteJob();
|
||||
|
@ -22,13 +22,7 @@ SOFTWARE.
|
||||
|
||||
#include "thread_pool_job.h"
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/variant/variant.h"
|
||||
#else
|
||||
#include "core/variant.h"
|
||||
#endif
|
||||
|
||||
#include "core/os/os.h"
|
||||
|
||||
@ -94,11 +88,7 @@ void ThreadPoolJob::set_method(const StringName &value) {
|
||||
}
|
||||
|
||||
float ThreadPoolJob::get_current_execution_time() {
|
||||
#if VERSION_MAJOR < 4
|
||||
return (OS::get_singleton()->get_system_time_msecs() - _start_time) / 1000.0;
|
||||
#else
|
||||
return (OS::get_singleton()->get_ticks_msec() - _start_time) / 1000.0;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool ThreadPoolJob::should_do(const bool just_check) {
|
||||
@ -131,17 +121,9 @@ void ThreadPoolJob::execute() {
|
||||
|
||||
_current_run_stage = 0;
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
_start_time = OS::get_singleton()->get_system_time_msecs();
|
||||
#else
|
||||
_start_time = OS::get_singleton()->get_ticks_msec();
|
||||
#endif
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
call("_execute");
|
||||
#else
|
||||
GDVIRTUAL_CALL(_execute);
|
||||
#endif
|
||||
}
|
||||
|
||||
ThreadPoolJob::ThreadPoolJob() {
|
||||
@ -175,11 +157,7 @@ void ThreadPoolJob::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_max_allocated_time"), &ThreadPoolJob::get_max_allocated_time);
|
||||
ClassDB::bind_method(D_METHOD("set_max_allocated_time", "value"), &ThreadPoolJob::set_max_allocated_time);
|
||||
#if VERSION_MAJOR < 4
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "max_allocated_time"), "set_max_allocated_time", "get_max_allocated_time");
|
||||
#else
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "max_allocated_time"), "set_max_allocated_time", "get_max_allocated_time");
|
||||
#endif
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_start_time"), &ThreadPoolJob::get_start_time);
|
||||
ClassDB::bind_method(D_METHOD("set_start_time", "value"), &ThreadPoolJob::set_start_time);
|
||||
@ -200,11 +178,7 @@ void ThreadPoolJob::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("should_do", "just_check"), &ThreadPoolJob::should_do, DEFVAL(false));
|
||||
ClassDB::bind_method(D_METHOD("should_return"), &ThreadPoolJob::should_return);
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
BIND_VMETHOD(MethodInfo("_execute"));
|
||||
#else
|
||||
GDVIRTUAL_BIND(_execute);
|
||||
#endif
|
||||
|
||||
ClassDB::bind_method(D_METHOD("execute"), &ThreadPoolJob::execute);
|
||||
|
||||
|
@ -22,21 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/object/ref_counted.h"
|
||||
#ifndef Reference
|
||||
#define Reference RefCounted
|
||||
#endif
|
||||
#include "core/object/gdvirtual.gen.inc"
|
||||
#include "core/object/script_language.h"
|
||||
#else
|
||||
#include "core/reference.h"
|
||||
#endif
|
||||
|
||||
class ThreadPoolJob : public Reference {
|
||||
GDCLASS(ThreadPoolJob, Reference);
|
||||
@ -78,10 +64,6 @@ public:
|
||||
|
||||
void execute();
|
||||
|
||||
#if VERSION_MAJOR >= 4
|
||||
GDVIRTUAL0(_execute);
|
||||
#endif
|
||||
|
||||
ThreadPoolJob();
|
||||
~ThreadPoolJob();
|
||||
|
||||
|
@ -22,16 +22,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/templates/vector.h"
|
||||
#else
|
||||
#include "core/vector.h"
|
||||
#endif
|
||||
|
||||
#include "voxel_structure.h"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user