Bladeren bron

Update SpriteResource

Daniele Bartolini 12 jaren geleden
bovenliggende
commit
34394ca5b2
1 gewijzigde bestanden met toevoegingen van 6 en 6 verwijderingen
  1. 6 6
      engine/resource/SpriteResource.cpp

+ 6 - 6
engine/resource/SpriteResource.cpp

@@ -112,14 +112,14 @@ void compile(Filesystem& fs, const char* resource_path, File* out_file)
 		const FrameData& fd = m_regions[i];
 		const FrameData& fd = m_regions[i];
 
 
 		// Compute uv coords
 		// Compute uv coords
-		const float u0 = fd.x0;
-		const float v0 = fd.y0;
-		const float u1 = fd.x0 + fd.x1;
-		const float v1 = fd.y0 + fd.y1;
+		const float u0 = fd.x0 / width;
+		const float v0 = fd.y0 / height;
+		const float u1 = (fd.x0 + fd.x1) / width;
+		const float v1 = (fd.y0 + fd.y1) / height;
 
 
 		// Compute positions
 		// Compute positions
-		const float w = (fd.x1 - fd.x0) * (width / CE_PIXELS_PER_METER);
-		const float h = (fd.y1 - fd.y0) * (height / CE_PIXELS_PER_METER);
+		const float w = fd.x1 / CE_PIXELS_PER_METER;
+		const float h = fd.y1 / CE_PIXELS_PER_METER;
 
 
 		const float x0 = fd.scale_x * (-w * 0.5) + fd.offset_x;
 		const float x0 = fd.scale_x * (-w * 0.5) + fd.offset_x;
 		const float y0 = fd.scale_y * (-h * 0.5) + fd.offset_y;
 		const float y0 = fd.scale_y * (-h * 0.5) + fd.offset_y;