Browse Source

Merge branch '4.1' into 4.2-beta

Mario Zechner 2 years ago
parent
commit
2826a3610e

+ 1 - 1
spine-godot/spine_godot/SpineAtlasResource.cpp

@@ -247,7 +247,7 @@ void SpineAtlasResourceFormatLoader::get_recognized_extensions(List<String> *ext
 }
 
 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 {

+ 1 - 1
spine-godot/spine_godot/SpineSkeletonFileResource.cpp

@@ -174,7 +174,7 @@ void SpineSkeletonFileResourceFormatLoader::get_recognized_extensions(List<Strin
 }
 
 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 {

+ 2 - 10
spine-godot/spine_godot/SpineSprite.cpp

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

+ 10 - 2
spine-godot/spine_godot/SpineSprite.h

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