From 15740faf9fe9fe4be08965098bbf2947e096aeeb Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 14 Aug 2019 22:50:43 +0800 Subject: +Unity Runtime code --- Runtime/Graphics/SpriteUtility.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Runtime/Graphics/SpriteUtility.h (limited to 'Runtime/Graphics/SpriteUtility.h') diff --git a/Runtime/Graphics/SpriteUtility.h b/Runtime/Graphics/SpriteUtility.h new file mode 100644 index 0000000..aff8491 --- /dev/null +++ b/Runtime/Graphics/SpriteUtility.h @@ -0,0 +1,22 @@ +#pragma once +#include "Configuration/UnityConfigure.h" + +#if ENABLE_SPRITES +#include "Runtime/Graphics/Texture2D.h" +#include "Runtime/Graphics/SpriteFrame.h" + +enum PathSimplifyMode +{ + kPathReduce=0, + kPathEmbed +}; + +void GenerateSpriteOutline(PPtr texture, float pixelsToUnits, const Rectf& rect, const Vector2f& rectOffset, float detail, unsigned char alphaTolerance, bool holeDetection, unsigned int extrude, int simplifyMode, std::vector >* outLine = NULL, std::vector* outVertices = NULL, std::vector* outIndices = NULL, Rectf* meshRect = NULL); + +// Returns the front face of the AABB. +// Sprite is on local Z = 0, however the AABB has volume. Flatten it on Z and return 4 vertices only. +void GetAABBVerticesForSprite (const AABB& aabb, Vector3f* outVertices); + +bool GetSpriteMeshRectPixelBounds (const Texture2D& texture, const Rectf& rectInaccurate, int& rectX, int& rectY, int& rectRight, int& rectBottom); + +#endif //ENABLE_SPRITES -- cgit v1.1-26-g67d0