Merge branch '4.1' into 4.2-beta

This commit is contained in:
Mario Zechner 2023-02-13 07:42:27 +01:00
commit 2826a3610e
4 changed files with 14 additions and 14 deletions

View File

@ -247,7 +247,7 @@ void SpineAtlasResourceFormatLoader::get_recognized_extensions(List<String> *ext
} }
String SpineAtlasResourceFormatLoader::get_resource_type(const String &path) const { String SpineAtlasResourceFormatLoader::get_resource_type(const String &path) const {
return "SpineAtlasResource"; return path.ends_with("spatlas") || path.ends_with(".atlas") ? "SpineAtlasResource" : "";
} }
bool SpineAtlasResourceFormatLoader::handles_type(const String &type) const { bool SpineAtlasResourceFormatLoader::handles_type(const String &type) const {

View File

@ -174,7 +174,7 @@ void SpineSkeletonFileResourceFormatLoader::get_recognized_extensions(List<Strin
} }
String SpineSkeletonFileResourceFormatLoader::get_resource_type(const String &path) const { String SpineSkeletonFileResourceFormatLoader::get_resource_type(const String &path) const {
return "SpineSkeletonFileResource"; return path.ends_with(".spjson") || path.ends_with(".spskel") || path.ends_with(".spine-json") || path.ends_with(".skel") ? "SpineSkeletonFileResource" : "";
} }
bool SpineSkeletonFileResourceFormatLoader::handles_type(const String &type) const { bool SpineSkeletonFileResourceFormatLoader::handles_type(const String &type) const {

View File

@ -54,14 +54,6 @@ static spine::Vector<unsigned short> quad_indices;
static spine::Vector<float> scratch_vertices; static spine::Vector<float> scratch_vertices;
static Vector<Vector2> scratch_points; static Vector<Vector2> scratch_points;
static void clear_triangles(SpineMesh2D *mesh_instance) {
#if VERSION_MAJOR > 3
RenderingServer::get_singleton()->canvas_item_clear(mesh_instance->get_canvas_item());
#else
VisualServer::get_singleton()->canvas_item_clear(mesh_instance->get_canvas_item());
#endif
}
static void add_triangles(SpineMesh2D *mesh_instance, static void add_triangles(SpineMesh2D *mesh_instance,
const Vector<Point2> &vertices, const Vector<Point2> &vertices,
const Vector<Point2> &uvs, const Vector<Point2> &uvs,
@ -568,7 +560,7 @@ void SpineSprite::update_meshes(Ref<SpineSkeleton> skeleton_ref) {
spine::Attachment *attachment = slot->getAttachment(); spine::Attachment *attachment = slot->getAttachment();
SpineMesh2D *mesh_instance = mesh_instances[i]; SpineMesh2D *mesh_instance = mesh_instances[i];
mesh_instance->renderer_object = nullptr; mesh_instance->renderer_object = nullptr;
mesh_instance->set_light_mask(get_light_mask());
if (!attachment) { if (!attachment) {
skeleton_clipper->clipEnd(*slot); skeleton_clipper->clipEnd(*slot);
continue; continue;
@ -636,7 +628,7 @@ void SpineSprite::update_meshes(Ref<SpineSkeleton> skeleton_ref) {
} }
if (indices->size() > 0) { if (indices->size() > 0) {
// Set the mesh mesh_instance->set_light_mask(get_light_mask());
size_t num_vertices = vertices->size() / 2; size_t num_vertices = vertices->size() / 2;
mesh_instance->vertices.resize((int) num_vertices); mesh_instance->vertices.resize((int) num_vertices);
memcpy(mesh_instance->vertices.ptrw(), vertices->buffer(), num_vertices * 2 * sizeof(float)); memcpy(mesh_instance->vertices.ptrw(), vertices->buffer(), num_vertices * 2 * sizeof(float));

View File

@ -39,6 +39,8 @@ struct SpineRendererObject;
class SpineSprite; class SpineSprite;
class Attachment;
class SpineMesh2D : public Node2D { class SpineMesh2D : public Node2D {
GDCLASS(SpineMesh2D, Node2D); GDCLASS(SpineMesh2D, Node2D);
@ -53,10 +55,16 @@ protected:
Vector<Color> colors; Vector<Color> colors;
Vector<int> indices; Vector<int> indices;
SpineRendererObject *renderer_object; SpineRendererObject *renderer_object;
int slotIndex;
Attachment *attachment;
ArrayMesh *mesh;
public: public:
SpineMesh2D() : renderer_object(nullptr){}; SpineMesh2D() : renderer_object(nullptr), slotIndex(-1), attachment(nullptr), mesh(nullptr) {};
~SpineMesh2D(){}; ~SpineMesh2D(){
if (mesh) memdelete(mesh);
};
ArrayMesh *get_mesh() {return mesh;};
}; };
class SpineSprite : public Node2D, class SpineSprite : public Node2D,