74 lines
1.9 KiB
C++
74 lines
1.9 KiB
C++
#ifndef _PACKING_PATCH_H_
|
|
#define _PACKING_PATCH_H_
|
|
|
|
#ifndef _ITF_VEC2D_H_
|
|
#include "core/math/vec2d.h"
|
|
#endif //_ITF_VEC2D_H_
|
|
|
|
#ifndef _ITF_BV_AABB_H_
|
|
#include "core/boundingvolume/AABB.h"
|
|
#endif //_ITF_BV_AABB_H_
|
|
|
|
namespace ITF
|
|
{
|
|
|
|
#define ROTATE_0 0
|
|
#define ROTATE_90 1
|
|
#define ROTATE_180 2
|
|
#define ROTATE_270 3
|
|
#define ROTATE_COUNT 4
|
|
|
|
#define SAMPLE_MASK 0xFF
|
|
#define SAMPLE_TAG (SAMPLE_MASK + 1)
|
|
#define SAMPLE_ROTATE_OOBB 50
|
|
|
|
struct BeginEnd
|
|
{
|
|
u32 m_begin;
|
|
u32 m_end;
|
|
};
|
|
|
|
class PackingPatch
|
|
{
|
|
public:
|
|
|
|
PackingPatch();
|
|
~PackingPatch();
|
|
|
|
ITF_VECTOR<Vec2d> m_points;
|
|
ITF_VECTOR<BeginEnd> m_subPoly;
|
|
AABB m_obb;
|
|
f32 m_area;
|
|
f32 m_angle;
|
|
Vec2d m_baryCenter;
|
|
|
|
// Grid sampling
|
|
u32 m_widthSampling;
|
|
u32 m_heightSampling;
|
|
SafeArray<u32> m_sampling;
|
|
|
|
Vec2d m_posInImage;
|
|
u32 m_rotateMode;
|
|
|
|
//
|
|
f32 m_rotation;
|
|
Vec2d m_translation;
|
|
|
|
ITF_VECTOR<u32> m_srcData;
|
|
|
|
void computeOBB(bbool _ignoreRotate = bfalse);
|
|
void sample(f32 _gridSample);
|
|
Vec2d getBaryCenter();
|
|
|
|
void getCoorSample(f32 _gridSample, const Vec2d &_pos, i32& _x, i32& _y);
|
|
void fillPoint(i32 x, i32 y, u32 idx);
|
|
void bresenham(i32 _x1, i32 _y1, i32 _x2, i32 _y2, u32 idx);
|
|
void andres(i32 _x1, i32 _y1, i32 _x2, i32 _y2, u32 idx);
|
|
void gridFill(f32 _gridSample, Vec2d &_p1, Vec2d &_p2, u32 _idx);
|
|
bbool isInside(f32 _gridSample, u32 fillIdx, u32 idxBegin, u32 idxEnd, u32 _x, u32 _y);
|
|
bbool searchSead(f32 _gridSample, u32 fillIdx, u32 idxBegin, u32 idxEnd, u32 _xbegin, u32 _xend, u32 _ybegin, u32 _yend, u32 & _seed);
|
|
};
|
|
|
|
}
|
|
|
|
#endif // _PACKING_PATCH_H_
|