1 /* 2 Copyright © 2020, Inochi2D Project 3 Distributed under the 2-Clause BSD License, see LICENSE file. 4 5 Authors: Luna Nielsen 6 */ 7 module creator.atlas.part; 8 import creator.atlas.atlas; 9 import inochi2d; 10 11 /** 12 A part in the texture atlas 13 */ 14 struct AtlasPart { 15 16 /** 17 The atlas this part is packed in 18 19 null if the part hasn't been packed yet. 20 */ 21 Atlas* packedIn; 22 23 /** 24 The Inochi2D part this atlas part is attached to 25 */ 26 Part part; 27 28 /** 29 The texture of the part 30 */ 31 Texture texture; 32 33 /** 34 This part's mesh 35 */ 36 MeshData mesh; 37 38 /** 39 UUID of atlas part 40 */ 41 uint uuid() { return part.uuid; } 42 43 /** 44 Returns the size of the part in pixels 45 */ 46 vec2i size() { 47 return texture.size(); 48 } 49 50 /** 51 Applies the UVs to the part in question 52 */ 53 void apply() { 54 part.rebuffer(mesh); 55 } 56 57 /** 58 Draws the part 59 */ 60 void draw() { 61 inDrawTextureAtPart(texture, part); 62 } 63 }