Merge pull request #60583 from reduz/placeholder-assets
This commit is contained in:
commit
b239275989
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="PlaceholderCubemap" inherits="PlaceholderTextureLayered" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
</class>
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="PlaceholderCubemapArray" inherits="PlaceholderTextureLayered" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
</class>
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="PlaceholderMaterial" inherits="Material" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
</class>
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="PlaceholderMesh" inherits="Mesh" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<members>
|
||||
<member name="aabb" type="AABB" setter="set_aabb" getter="get_aabb" default="AABB(0, 0, 0, 0, 0, 0)">
|
||||
</member>
|
||||
</members>
|
||||
</class>
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="PlaceholderTexture2D" inherits="Texture2D" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<members>
|
||||
<member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2(1, 1)">
|
||||
</member>
|
||||
</members>
|
||||
</class>
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="PlaceholderTexture2DArray" inherits="PlaceholderTextureLayered" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
</class>
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="PlaceholderTexture3D" inherits="Texture3D" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<members>
|
||||
<member name="size" type="Vector3i" setter="set_size" getter="get_size" default="Vector3i(1, 1, 1)">
|
||||
</member>
|
||||
</members>
|
||||
</class>
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="PlaceholderTextureLayered" inherits="TextureLayered" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<members>
|
||||
<member name="layers" type="int" setter="set_layers" getter="get_layers" default="1">
|
||||
</member>
|
||||
<member name="size" type="Vector2i" setter="set_size" getter="get_size" default="Vector2i(1, 1)">
|
||||
</member>
|
||||
</members>
|
||||
</class>
|
|
@ -752,6 +752,7 @@ void register_scene_types() {
|
|||
|
||||
GDREGISTER_VIRTUAL_CLASS(Mesh);
|
||||
GDREGISTER_CLASS(ArrayMesh);
|
||||
GDREGISTER_CLASS(PlaceholderMesh);
|
||||
GDREGISTER_CLASS(ImmediateMesh);
|
||||
GDREGISTER_CLASS(MultiMesh);
|
||||
GDREGISTER_CLASS(SurfaceTool);
|
||||
|
@ -773,6 +774,7 @@ void register_scene_types() {
|
|||
GDREGISTER_ABSTRACT_CLASS(BaseMaterial3D);
|
||||
GDREGISTER_CLASS(StandardMaterial3D);
|
||||
GDREGISTER_CLASS(ORMMaterial3D);
|
||||
GDREGISTER_CLASS(PlaceholderMaterial);
|
||||
SceneTree::add_idle_callback(BaseMaterial3D::flush_changes);
|
||||
BaseMaterial3D::init_shaders();
|
||||
|
||||
|
@ -837,6 +839,12 @@ void register_scene_types() {
|
|||
GDREGISTER_CLASS(CompressedCubemap);
|
||||
GDREGISTER_CLASS(CompressedCubemapArray);
|
||||
GDREGISTER_CLASS(CompressedTexture2DArray);
|
||||
GDREGISTER_CLASS(PlaceholderTexture2D);
|
||||
GDREGISTER_CLASS(PlaceholderTexture3D);
|
||||
GDREGISTER_ABSTRACT_CLASS(PlaceholderTextureLayered);
|
||||
GDREGISTER_CLASS(PlaceholderTexture2DArray);
|
||||
GDREGISTER_CLASS(PlaceholderCubemap);
|
||||
GDREGISTER_CLASS(PlaceholderCubemapArray);
|
||||
|
||||
GDREGISTER_CLASS(Animation);
|
||||
GDREGISTER_CLASS(AnimationLibrary);
|
||||
|
|
|
@ -3010,4 +3010,7 @@ bool StandardMaterial3D::_set(const StringName &p_name, const Variant &p_value)
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // DISABLE_DEPRECATED
|
||||
|
||||
///////////////////////
|
||||
|
|
|
@ -797,6 +797,13 @@ public:
|
|||
BaseMaterial3D(true) {}
|
||||
};
|
||||
|
||||
class PlaceholderMaterial : public Material {
|
||||
GDCLASS(PlaceholderMaterial, Material)
|
||||
public:
|
||||
virtual RID get_shader_rid() const override { return RID(); }
|
||||
virtual Shader::Mode get_shader_mode() const override { return Shader::MODE_CANVAS_ITEM; }
|
||||
};
|
||||
|
||||
//////////////////////
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2092,3 +2092,17 @@ ArrayMesh::~ArrayMesh() {
|
|||
RenderingServer::get_singleton()->free(mesh);
|
||||
}
|
||||
}
|
||||
///////////////
|
||||
|
||||
void PlaceholderMesh::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_aabb", "aabb"), &PlaceholderMesh::set_aabb);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::AABB, "aabb", PROPERTY_HINT_NONE, ""), "set_aabb", "get_aabb");
|
||||
}
|
||||
|
||||
PlaceholderMesh::PlaceholderMesh() {
|
||||
rid = RS::get_singleton()->mesh_create();
|
||||
}
|
||||
|
||||
PlaceholderMesh::~PlaceholderMesh() {
|
||||
RS::get_singleton()->free(rid);
|
||||
}
|
||||
|
|
|
@ -328,4 +328,38 @@ VARIANT_ENUM_CAST(Mesh::ArrayCustomFormat);
|
|||
VARIANT_ENUM_CAST(Mesh::PrimitiveType);
|
||||
VARIANT_ENUM_CAST(Mesh::BlendShapeMode);
|
||||
|
||||
class PlaceholderMesh : public Mesh {
|
||||
GDCLASS(PlaceholderMesh, Mesh);
|
||||
|
||||
RID rid;
|
||||
AABB aabb;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
virtual int get_surface_count() const override { return 0; }
|
||||
virtual int surface_get_array_len(int p_idx) const override { return 0; }
|
||||
virtual int surface_get_array_index_len(int p_idx) const override { return 0; }
|
||||
virtual Array surface_get_arrays(int p_surface) const override { return Array(); }
|
||||
virtual Array surface_get_blend_shape_arrays(int p_surface) const override { return Array(); }
|
||||
virtual Dictionary surface_get_lods(int p_surface) const override { return Dictionary(); }
|
||||
virtual uint32_t surface_get_format(int p_idx) const override { return 0; }
|
||||
virtual PrimitiveType surface_get_primitive_type(int p_idx) const override { return PRIMITIVE_TRIANGLES; }
|
||||
virtual void surface_set_material(int p_idx, const Ref<Material> &p_material) override {}
|
||||
virtual Ref<Material> surface_get_material(int p_idx) const override { return Ref<Material>(); }
|
||||
virtual int get_blend_shape_count() const override { return 0; }
|
||||
virtual StringName get_blend_shape_name(int p_index) const override { return StringName(); }
|
||||
virtual void set_blend_shape_name(int p_index, const StringName &p_name) override {}
|
||||
virtual RID get_rid() const override { return rid; }
|
||||
virtual AABB get_aabb() const override { return aabb; }
|
||||
void set_aabb(const AABB &p_aabb) { aabb = p_aabb; }
|
||||
|
||||
virtual int get_builtin_bind_pose_count() const override { return 0; }
|
||||
virtual Transform3D get_builtin_bind_pose(int p_index) const override { return Transform3D(); }
|
||||
|
||||
PlaceholderMesh();
|
||||
~PlaceholderMesh();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -3395,3 +3395,148 @@ CameraTexture::~CameraTexture() {
|
|||
RenderingServer::get_singleton()->free(_texture);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////
|
||||
|
||||
void PlaceholderTexture2D::set_size(Size2 p_size) {
|
||||
size = p_size;
|
||||
}
|
||||
|
||||
int PlaceholderTexture2D::get_width() const {
|
||||
return size.width;
|
||||
}
|
||||
|
||||
int PlaceholderTexture2D::get_height() const {
|
||||
return size.height;
|
||||
}
|
||||
|
||||
bool PlaceholderTexture2D::has_alpha() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
Ref<Image> PlaceholderTexture2D::get_image() const {
|
||||
return Ref<Image>();
|
||||
}
|
||||
|
||||
RID PlaceholderTexture2D::get_rid() const {
|
||||
return rid;
|
||||
}
|
||||
|
||||
void PlaceholderTexture2D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_size", "size"), &PlaceholderTexture2D::set_size);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "size"), "set_size", "get_size");
|
||||
}
|
||||
|
||||
PlaceholderTexture2D::PlaceholderTexture2D() {
|
||||
rid = RS::get_singleton()->texture_2d_placeholder_create();
|
||||
}
|
||||
|
||||
PlaceholderTexture2D::~PlaceholderTexture2D() {
|
||||
RS::get_singleton()->free(rid);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////
|
||||
|
||||
void PlaceholderTexture3D::set_size(const Vector3i &p_size) {
|
||||
size = p_size;
|
||||
}
|
||||
|
||||
Vector3i PlaceholderTexture3D::get_size() const {
|
||||
return size;
|
||||
}
|
||||
|
||||
Image::Format PlaceholderTexture3D::get_format() const {
|
||||
return Image::FORMAT_RGB8;
|
||||
}
|
||||
|
||||
int PlaceholderTexture3D::get_width() const {
|
||||
return size.x;
|
||||
}
|
||||
|
||||
int PlaceholderTexture3D::get_height() const {
|
||||
return size.y;
|
||||
}
|
||||
|
||||
int PlaceholderTexture3D::get_depth() const {
|
||||
return size.z;
|
||||
}
|
||||
|
||||
bool PlaceholderTexture3D::has_mipmaps() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector<Ref<Image>> PlaceholderTexture3D::get_data() const {
|
||||
return Vector<Ref<Image>>();
|
||||
}
|
||||
|
||||
void PlaceholderTexture3D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_size", "size"), &PlaceholderTexture3D::set_size);
|
||||
ClassDB::bind_method(D_METHOD("get_size"), &PlaceholderTexture3D::get_size);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3I, "size"), "set_size", "get_size");
|
||||
}
|
||||
|
||||
PlaceholderTexture3D::PlaceholderTexture3D() {
|
||||
rid = RS::get_singleton()->texture_3d_placeholder_create();
|
||||
}
|
||||
PlaceholderTexture3D::~PlaceholderTexture3D() {
|
||||
RS::get_singleton()->free(rid);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
void PlaceholderTextureLayered::set_size(const Size2i &p_size) {
|
||||
size = p_size;
|
||||
}
|
||||
|
||||
Size2i PlaceholderTextureLayered::get_size() const {
|
||||
return size;
|
||||
}
|
||||
|
||||
void PlaceholderTextureLayered::set_layers(int p_layers) {
|
||||
layers = p_layers;
|
||||
}
|
||||
|
||||
Image::Format PlaceholderTextureLayered::get_format() const {
|
||||
return Image::FORMAT_RGB8;
|
||||
}
|
||||
|
||||
TextureLayered::LayeredType PlaceholderTextureLayered::get_layered_type() const {
|
||||
return layered_type;
|
||||
}
|
||||
|
||||
int PlaceholderTextureLayered::get_width() const {
|
||||
return size.x;
|
||||
}
|
||||
|
||||
int PlaceholderTextureLayered::get_height() const {
|
||||
return size.y;
|
||||
}
|
||||
|
||||
int PlaceholderTextureLayered::get_layers() const {
|
||||
return layers;
|
||||
}
|
||||
|
||||
bool PlaceholderTextureLayered::has_mipmaps() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
Ref<Image> PlaceholderTextureLayered::get_layer_data(int p_layer) const {
|
||||
return Ref<Image>();
|
||||
}
|
||||
|
||||
void PlaceholderTextureLayered::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_size", "size"), &PlaceholderTextureLayered::set_size);
|
||||
ClassDB::bind_method(D_METHOD("get_size"), &PlaceholderTextureLayered::get_size);
|
||||
ClassDB::bind_method(D_METHOD("set_layers", "layers"), &PlaceholderTextureLayered::set_layers);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "size"), "set_size", "get_size");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "layers", PROPERTY_HINT_RANGE, "1,4096"), "set_layers", "get_layers");
|
||||
}
|
||||
|
||||
PlaceholderTextureLayered::PlaceholderTextureLayered(LayeredType p_type) {
|
||||
layered_type = p_type;
|
||||
rid = RS::get_singleton()->texture_2d_layered_placeholder_create(RS::TextureLayeredType(layered_type));
|
||||
}
|
||||
PlaceholderTextureLayered::~PlaceholderTextureLayered() {
|
||||
RS::get_singleton()->free(rid);
|
||||
}
|
||||
|
|
|
@ -1011,4 +1011,98 @@ public:
|
|||
~CameraTexture();
|
||||
};
|
||||
|
||||
class PlaceholderTexture2D : public Texture2D {
|
||||
GDCLASS(PlaceholderTexture2D, Texture2D)
|
||||
|
||||
RID rid;
|
||||
Size2 size = Size2(1, 1);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
void set_size(Size2 p_size);
|
||||
|
||||
virtual int get_width() const override;
|
||||
virtual int get_height() const override;
|
||||
virtual RID get_rid() const override;
|
||||
virtual bool has_alpha() const override;
|
||||
|
||||
virtual Ref<Image> get_image() const override;
|
||||
|
||||
PlaceholderTexture2D();
|
||||
~PlaceholderTexture2D();
|
||||
};
|
||||
|
||||
class PlaceholderTexture3D : public Texture3D {
|
||||
GDCLASS(PlaceholderTexture3D, Texture3D)
|
||||
|
||||
RID rid;
|
||||
Vector3i size = Vector3i(1, 1, 1);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
void set_size(const Vector3i &p_size);
|
||||
Vector3i get_size() const;
|
||||
virtual Image::Format get_format() const override;
|
||||
virtual int get_width() const override;
|
||||
virtual int get_height() const override;
|
||||
virtual int get_depth() const override;
|
||||
virtual bool has_mipmaps() const override;
|
||||
virtual Vector<Ref<Image>> get_data() const override;
|
||||
|
||||
PlaceholderTexture3D();
|
||||
~PlaceholderTexture3D();
|
||||
};
|
||||
|
||||
class PlaceholderTextureLayered : public TextureLayered {
|
||||
GDCLASS(PlaceholderTextureLayered, TextureLayered)
|
||||
|
||||
RID rid;
|
||||
Size2i size = Size2i(1, 1);
|
||||
int layers = 1;
|
||||
LayeredType layered_type = LAYERED_TYPE_2D_ARRAY;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
void set_size(const Size2i &p_size);
|
||||
Size2i get_size() const;
|
||||
void set_layers(int p_layers);
|
||||
virtual Image::Format get_format() const override;
|
||||
virtual LayeredType get_layered_type() const override;
|
||||
virtual int get_width() const override;
|
||||
virtual int get_height() const override;
|
||||
virtual int get_layers() const override;
|
||||
virtual bool has_mipmaps() const override;
|
||||
virtual Ref<Image> get_layer_data(int p_layer) const override;
|
||||
|
||||
PlaceholderTextureLayered(LayeredType p_type);
|
||||
~PlaceholderTextureLayered();
|
||||
};
|
||||
|
||||
class PlaceholderTexture2DArray : public PlaceholderTextureLayered {
|
||||
GDCLASS(PlaceholderTexture2DArray, PlaceholderTextureLayered)
|
||||
public:
|
||||
PlaceholderTexture2DArray() :
|
||||
PlaceholderTextureLayered(LAYERED_TYPE_2D_ARRAY) {}
|
||||
};
|
||||
|
||||
class PlaceholderCubemap : public PlaceholderTextureLayered {
|
||||
GDCLASS(PlaceholderCubemap, PlaceholderTextureLayered)
|
||||
public:
|
||||
PlaceholderCubemap() :
|
||||
PlaceholderTextureLayered(LAYERED_TYPE_CUBEMAP) {}
|
||||
};
|
||||
|
||||
class PlaceholderCubemapArray : public PlaceholderTextureLayered {
|
||||
GDCLASS(PlaceholderCubemapArray, PlaceholderTextureLayered)
|
||||
public:
|
||||
PlaceholderCubemapArray() :
|
||||
PlaceholderTextureLayered(LAYERED_TYPE_CUBEMAP_ARRAY) {}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue