84 lines
2.3 KiB
C++
84 lines
2.3 KiB
C++
#ifndef _PACKING_TEXTURE_H_
|
|
#define _PACKING_TEXTURE_H_
|
|
|
|
#ifndef _PACKING_PATCH_H_
|
|
#include "AnimTexPacker/PackingPatch.h"
|
|
#endif //_PACKING_PATCH_H_
|
|
|
|
namespace ITF
|
|
{
|
|
|
|
typedef ITF_VECTOR<PackingPatch> ListPatch;
|
|
#define USE_NEW_GRID_COMPUTATION_SYSTEM
|
|
|
|
struct GridInfo
|
|
{
|
|
GridInfo() : m_x(0), m_y(0), m_val(0) {}
|
|
GridInfo(i32 _x, i32 _y, i32 _val) : m_x(_x), m_y(_y), m_val(_val)
|
|
{
|
|
}
|
|
|
|
i32 m_x;
|
|
i32 m_y;
|
|
i32 m_val;
|
|
};
|
|
|
|
class PackingTexture
|
|
{
|
|
|
|
public:
|
|
|
|
// Constructor
|
|
PackingTexture() {}
|
|
PackingTexture(const ListPatch & _patchs, u32 _width, u32 _height, f32 _sampling);
|
|
~PackingTexture();
|
|
|
|
// Service
|
|
void computeGrid();
|
|
void recomputeRotation(ListPatch & patchs);
|
|
|
|
// Accessors
|
|
// TODO : rajouter les checks de depassement d'index !
|
|
ITF_INLINE const u32 getCountPatchs() {return m_patchs.size();}
|
|
ITF_INLINE const PackingPatch& getPatchsByIndex(u32 _index) {return m_patchs[_index];}
|
|
ITF_INLINE const ListPatch& getPatchsList() {return m_patchs;}
|
|
ITF_INLINE u32 getWidth() {return m_width;}
|
|
ITF_INLINE u32 getHeight() {return m_height;}
|
|
ITF_INLINE f32 getGridSample() {return m_gridSample;}
|
|
ITF_INLINE bbool indexGridIsUsed(u32 _index) {return m_grid[_index] == 0;}
|
|
|
|
static i32 s_gridComputationValue;
|
|
|
|
public:
|
|
|
|
// Service internal
|
|
void reset(const ListPatch & _patchs, u32 _width, u32 _height, f32 _sampling);
|
|
bbool isFree(PackingPatch& _patch, u32 _indexRow, u32 _indexCol, u32 _width, u32 _height, u32& _countNeighbor, u32 _mode);
|
|
void drawGridTexture();
|
|
void pushPatch(u32 _indexRow, u32 _indexCol, u32 _mode, PackingPatch& _patch);
|
|
void growTexture();
|
|
bbool packingPatch();
|
|
#ifndef USE_NEW_GRID_COMPUTATION_SYSTEM
|
|
u32 getCountNeighbor(u32 _indexRow, u32 _indexCol);
|
|
#else
|
|
void propagateGridValues(const ITF_VECTOR<GridInfo> & _gridIndexes);
|
|
#endif
|
|
//private:
|
|
|
|
ListPatch m_patchs;
|
|
ITF_VECTOR<i32> m_grid;
|
|
u32 m_width;
|
|
u32 m_height;
|
|
u32 countGrow;
|
|
f32 m_gridSample;
|
|
u32 m_minNeededGridElemts;
|
|
u32 m_maxNeededGridElemts;
|
|
|
|
#ifdef USE_NEW_GRID_COMPUTATION_SYSTEM
|
|
SafeArray<GridInfo> m_gridInfoTMP;
|
|
#endif
|
|
};
|
|
|
|
}
|
|
|
|
#endif // _PACKING_TEXTURE_H_
|