tsMesh.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _TSMESH_H_
  23. #define _TSMESH_H_
  24. #ifndef _STREAM_H_
  25. #include "core/stream/stream.h"
  26. #endif
  27. #ifndef _MMATH_H_
  28. #include "math/mMath.h"
  29. #endif
  30. #ifndef _TVECTOR_H_
  31. #include "core/util/tVector.h"
  32. #endif
  33. #ifndef _ABSTRACTPOLYLIST_H_
  34. #include "collision/abstractPolyList.h"
  35. #endif
  36. #ifndef _GFXDEVICE_H_
  37. #include "gfx/gfxDevice.h"
  38. #endif
  39. #ifndef _GFXPRIMITIVEBUFFER_H_
  40. #include "gfx/gfxPrimitiveBuffer.h"
  41. #endif
  42. #ifndef _TSPARSEARRAY_H_
  43. #include "core/tSparseArray.h"
  44. #endif
  45. #include "core/util/safeDelete.h"
  46. namespace Opcode { class Model; class MeshInterface; }
  47. namespace IceMaths { class IndexedTriangle; class Point; }
  48. class Convex;
  49. class SceneRenderState;
  50. class SceneObject;
  51. struct MeshRenderInst;
  52. class TSRenderState;
  53. class RenderPassManager;
  54. class TSMaterialList;
  55. class TSShapeInstance;
  56. struct RayInfo;
  57. class ConvexFeature;
  58. class ShapeBase;
  59. struct TSDrawPrimitive
  60. {
  61. enum
  62. {
  63. Triangles = 0 << 30, ///< bits 30 and 31 index element type
  64. Strip = 1 << 30, ///< bits 30 and 31 index element type
  65. Fan = 2 << 30, ///< bits 30 and 31 index element type
  66. Indexed = BIT(29), ///< use glDrawElements if indexed, glDrawArrays o.w.
  67. NoMaterial = BIT(28), ///< set if no material (i.e., texture missing)
  68. MaterialMask = ~(Strip|Fan|Triangles|Indexed|NoMaterial),
  69. TypeMask = Strip|Fan|Triangles
  70. };
  71. S32 start;
  72. S32 numElements;
  73. S32 matIndex; ///< holds material index & element type (see above enum)
  74. };
  75. typedef GFXVertexBufferDataHandle TSVertexBufferHandle;
  76. class TSMesh;
  77. class TSShapeAlloc;
  78. /// @name Vertex format serialization
  79. /// {
  80. struct TSBasicVertexFormat
  81. {
  82. S16 texCoordOffset;
  83. S16 boneOffset;
  84. S16 colorOffset;
  85. S16 numBones;
  86. S16 vertexSize;
  87. TSBasicVertexFormat();
  88. TSBasicVertexFormat(TSMesh *mesh);
  89. void getFormat(GFXVertexFormat &fmt);
  90. void calculateSize();
  91. void writeAlloc(TSShapeAlloc* alloc);
  92. void readAlloc(TSShapeAlloc* alloc);
  93. void addMeshRequirements(TSMesh *mesh);
  94. };
  95. /// }
  96. ///
  97. class TSMesh
  98. {
  99. friend class TSShape;
  100. public:
  101. /// Helper class for a freeable vector
  102. template<class T>
  103. class FreeableVector : public Vector<T>
  104. {
  105. public:
  106. bool free_memory() { return Vector<T>::resize(0); }
  107. FreeableVector<T>& operator=(const Vector<T>& p) { Vector<T>::operator=(p); return *this; }
  108. FreeableVector<T>& operator=(const FreeableVector<T>& p) { Vector<T>::operator=(p); return *this; }
  109. };
  110. /// @name Aligned Vertex Data
  111. /// {
  112. #pragma pack(1)
  113. struct __TSMeshVertexBase
  114. {
  115. Point3F _vert;
  116. F32 _tangentW;
  117. Point3F _normal;
  118. Point3F _tangent;
  119. Point2F _tvert;
  120. const Point3F &vert() const { return _vert; }
  121. void vert(const Point3F &v) { _vert = v; }
  122. const Point3F &normal() const { return _normal; }
  123. void normal(const Point3F &n) { _normal = n; }
  124. Point4F tangent() const { return Point4F(_tangent.x, _tangent.y, _tangent.z, _tangentW); }
  125. void tangent(const Point4F &t) { _tangent = t.asPoint3F(); _tangentW = t.w; }
  126. const Point2F &tvert() const { return _tvert; }
  127. void tvert(const Point2F &tv) { _tvert = tv; }
  128. };
  129. struct __TSMeshVertex_3xUVColor
  130. {
  131. Point2F _tvert2;
  132. GFXVertexColor _color;
  133. const Point2F &tvert2() const { return _tvert2; }
  134. void tvert2(const Point2F& c) { _tvert2 = c; }
  135. const GFXVertexColor &color() const { return _color; }
  136. void color(const GFXVertexColor &c) { _color = c; }
  137. };
  138. struct __TSMeshIndex_List {
  139. U8 x;
  140. U8 y;
  141. U8 z;
  142. U8 w;
  143. };
  144. struct __TSMeshVertex_BoneData
  145. {
  146. __TSMeshIndex_List _indexes;
  147. Point4F _weights;
  148. const __TSMeshIndex_List &index() const { return _indexes; }
  149. void index(const __TSMeshIndex_List& c) { _indexes = c; }
  150. const Point4F &weight() const { return _weights; }
  151. void weight(const Point4F &w) { _weights = w; }
  152. };
  153. #pragma pack()
  154. struct TSMeshVertexArray
  155. {
  156. protected:
  157. U8 *base;
  158. dsize_t vertSz;
  159. U32 numElements;
  160. U32 colorOffset;
  161. U32 boneOffset;
  162. bool vertexDataReady;
  163. bool ownsData;
  164. public:
  165. TSMeshVertexArray() : base(NULL), vertSz(0), numElements(0), colorOffset(0), boneOffset(0), vertexDataReady(false), ownsData(false) {}
  166. virtual ~TSMeshVertexArray() { set(NULL, 0, 0, 0, 0); }
  167. virtual void set(void *b, dsize_t s, U32 n, S32 inColorOffset, S32 inBoneOffset, bool nowOwnsData = true)
  168. {
  169. if (base && ownsData)
  170. dFree_aligned(base);
  171. base = reinterpret_cast<U8 *>(b);
  172. vertSz = s;
  173. numElements = n;
  174. colorOffset = inColorOffset >= 0 ? inColorOffset : 0;
  175. boneOffset = inBoneOffset >= 0 ? inBoneOffset : 0;
  176. ownsData = nowOwnsData;
  177. }
  178. /// Gets pointer to __TSMeshVertexBase for vertex idx
  179. __TSMeshVertexBase &getBase(int idx) const
  180. {
  181. AssertFatal(idx < numElements, "Out of bounds access!"); return *reinterpret_cast<__TSMeshVertexBase *>(base + (idx * vertSz));
  182. }
  183. /// Gets pointer to __TSMeshVertex_3xUVColor for vertex idx
  184. __TSMeshVertex_3xUVColor &getColor(int idx) const
  185. {
  186. AssertFatal(idx < numElements, "Out of bounds access!"); return *reinterpret_cast<__TSMeshVertex_3xUVColor *>(base + (idx * vertSz) + colorOffset);
  187. }
  188. /// Gets pointer to __TSMeshVertex_BoneData for vertex idx, additionally offsetted by subBoneList
  189. __TSMeshVertex_BoneData &getBone(int idx, int subBoneList) const
  190. {
  191. AssertFatal(idx < numElements, "Out of bounds access!"); return *reinterpret_cast<__TSMeshVertex_BoneData *>(base + (idx * vertSz) + boneOffset + (sizeof(__TSMeshVertex_BoneData) * subBoneList));
  192. }
  193. /// Returns base address of vertex data
  194. __TSMeshVertexBase *address() const
  195. {
  196. return reinterpret_cast<__TSMeshVertexBase *>(base);
  197. }
  198. U32 size() const { return numElements; }
  199. dsize_t mem_size() const { return numElements * vertSz; }
  200. dsize_t vertSize() const { return vertSz; }
  201. bool isReady() const { return vertexDataReady; }
  202. void setReady(bool r) { vertexDataReady = r; }
  203. U8* getPtr() { return base; }
  204. inline U32 getColorOffset() const { return colorOffset; }
  205. inline U32 getBoneOffset() const { return boneOffset; }
  206. };
  207. protected:
  208. U32 mMeshType;
  209. Box3F mBounds;
  210. Point3F mCenter;
  211. F32 mRadius;
  212. F32 mVisibility;
  213. const GFXVertexFormat *mVertexFormat;
  214. TSMesh *mParentMeshObject; ///< Current parent object instance
  215. U32 mPrimBufferOffset;
  216. GFXVertexBufferDataHandle mVB;
  217. GFXPrimitiveBufferHandle mPB;
  218. public:
  219. S32 mParentMesh; ///< index into shapes mesh list
  220. S32 numFrames;
  221. S32 numMatFrames;
  222. S32 vertsPerFrame;
  223. U32 mVertOffset;
  224. U32 mVertSize;
  225. protected:
  226. void _convertToVertexData(TSMeshVertexArray &outArray, const Vector<Point3F> &_verts, const Vector<Point3F> &_norms);
  227. public:
  228. enum
  229. {
  230. /// types...
  231. StandardMeshType = 0,
  232. SkinMeshType = 1,
  233. DecalMeshType = 2,
  234. SortedMeshType = 3,
  235. NullMeshType = 4,
  236. TypeMask = StandardMeshType|SkinMeshType|DecalMeshType|SortedMeshType|NullMeshType,
  237. /// flags (stored with meshType)...
  238. Billboard = BIT(31), HasDetailTexture = BIT(30),
  239. BillboardZAxis = BIT(29), UseEncodedNormals = BIT(28),
  240. HasColor = BIT(27), HasTVert2 = BIT(26),
  241. FlagMask = Billboard|BillboardZAxis|HasDetailTexture|UseEncodedNormals|HasColor|HasTVert2
  242. };
  243. U32 getMeshType() const { return mMeshType & TypeMask; }
  244. U32 getHasColor() const { return mColors.size() > 0 || mMeshType & HasColor; }
  245. U32 getHasTVert2() const { return mTverts2.size() > 0 || mMeshType & HasTVert2; }
  246. void setFlags(U32 flag) { mMeshType |= flag; }
  247. void clearFlags(U32 flag) { mMeshType &= ~flag; }
  248. U32 getFlags( U32 flag = 0xFFFFFFFF ) const { return mMeshType & flag; }
  249. const Point3F* getNormals( S32 firstVert );
  250. TSMeshVertexArray mVertexData;
  251. U32 mNumVerts; ///< Number of verts allocated in main vertex buffer
  252. virtual void convertToVertexData();
  253. virtual void copySourceVertexDataFrom(const TSMesh* srcMesh);
  254. /// @}
  255. /// @name Vertex data
  256. /// @{
  257. FreeableVector<Point3F> mVerts;
  258. FreeableVector<Point3F> mNorms;
  259. FreeableVector<Point2F> mTverts;
  260. FreeableVector<Point4F> mTangents;
  261. // Optional second texture uvs.
  262. FreeableVector<Point2F> mTverts2;
  263. // Optional vertex colors data.
  264. FreeableVector<ColorI> mColors;
  265. /// @}
  266. Vector<TSDrawPrimitive> mPrimitives;
  267. Vector<U8> mEncodedNorms;
  268. Vector<U32> mIndices;
  269. /// billboard data
  270. Point3F mBillboardAxis;
  271. /// @name Convex Hull Data
  272. /// Convex hulls are convex (no angles >= 180º) meshes used for collision
  273. /// @{
  274. Vector<Point3F> mPlaneNormals;
  275. Vector<F32> mPlaneConstants;
  276. Vector<U32> mPlaneMaterials;
  277. S32 mPlanesPerFrame;
  278. U32 mMergeBufferStart;
  279. /// @}
  280. /// @name Render Methods
  281. /// @{
  282. /// This is used by sgShadowProjector to render the
  283. /// mesh directly, skipping the render manager.
  284. virtual void render( TSVertexBufferHandle &vb );
  285. void innerRender( TSVertexBufferHandle &vb, GFXPrimitiveBufferHandle &pb );
  286. virtual void render( TSMaterialList *,
  287. const TSRenderState &data,
  288. bool isSkinDirty,
  289. const Vector<MatrixF> &transforms,
  290. TSVertexBufferHandle &vertexBuffer,
  291. const char *meshName);
  292. void innerRender( TSMaterialList *, const TSRenderState &data, TSVertexBufferHandle &vb, GFXPrimitiveBufferHandle &pb, const char *meshName );
  293. /// @}
  294. /// @name Material Methods
  295. /// @{
  296. void setFade( F32 fade ) { mVisibility = fade; }
  297. void clearFade() { setFade( 1.0f ); }
  298. /// @}
  299. /// @name Collision Methods
  300. /// @{
  301. virtual bool buildPolyList( S32 frame, AbstractPolyList * polyList, U32 & surfaceKey, TSMaterialList* materials );
  302. virtual bool getFeatures( S32 frame, const MatrixF&, const VectorF&, ConvexFeature*, U32 &surfaceKey );
  303. virtual void support( S32 frame, const Point3F &v, F32 *currMaxDP, Point3F *currSupport );
  304. virtual bool castRay( S32 frame, const Point3F & start, const Point3F & end, RayInfo * rayInfo, TSMaterialList* materials );
  305. virtual bool castRayRendered( S32 frame, const Point3F & start, const Point3F & end, RayInfo * rayInfo, TSMaterialList* materials );
  306. virtual bool buildConvexHull(); ///< returns false if not convex (still builds planes)
  307. bool addToHull( U32 idx0, U32 idx1, U32 idx2 );
  308. /// @}
  309. /// @name Bounding Methods
  310. /// calculate and get bounding information
  311. /// @{
  312. void computeBounds();
  313. virtual void computeBounds( const MatrixF &transform, Box3F &bounds, S32 frame = 0, Point3F *center = NULL, F32 *radius = NULL );
  314. void computeBounds( const Point3F *, S32 numVerts, S32 stride, const MatrixF &transform, Box3F &bounds, Point3F *center, F32 *radius );
  315. const Box3F& getBounds() const { return mBounds; }
  316. const Point3F& getCenter() const { return mCenter; }
  317. F32 getRadius() const { return mRadius; }
  318. virtual S32 getNumPolys() const;
  319. static U8 encodeNormal( const Point3F &normal );
  320. static const Point3F& decodeNormal( U8 ncode ) { return smU8ToNormalTable[ncode]; }
  321. /// @}
  322. virtual U32 getMaxBonesPerVert() { return 0; }
  323. /// persist methods...
  324. virtual void assemble( bool skip );
  325. static TSMesh* assembleMesh( U32 meshType, bool skip );
  326. virtual void disassemble();
  327. void createTangents(const Vector<Point3F> &_verts, const Vector<Point3F> &_norms);
  328. void findTangent( U32 index1,
  329. U32 index2,
  330. U32 index3,
  331. Point3F *tan0,
  332. Point3F *tan1,
  333. const Vector<Point3F> &_verts);
  334. /// on load...optionally convert primitives to other form
  335. static bool smUseTriangles;
  336. static bool smUseOneStrip;
  337. static S32 smMinStripSize;
  338. static bool smUseEncodedNormals;
  339. /// Enables mesh instancing on non-skin meshes that
  340. /// have less that this count of verts.
  341. static S32 smMaxInstancingVerts;
  342. /// Default node transform for standard meshes which have blend indices
  343. static MatrixF smDummyNodeTransform;
  344. /// convert primitives on load...
  345. void convertToTris(const TSDrawPrimitive *primitivesIn, const S32 *indicesIn,
  346. S32 numPrimIn, S32 & numPrimOut, S32 & numIndicesOut,
  347. TSDrawPrimitive *primitivesOut, S32 *indicesOut) const;
  348. void convertToSingleStrip(const TSDrawPrimitive *primitivesIn, const S32 *indicesIn,
  349. S32 numPrimIn, S32 &numPrimOut, S32 &numIndicesOut,
  350. TSDrawPrimitive *primitivesOut, S32 *indicesOut) const;
  351. void leaveAsMultipleStrips(const TSDrawPrimitive *primitivesIn, const S32 *indicesIn,
  352. S32 numPrimIn, S32 &numPrimOut, S32 &numIndicesOut,
  353. TSDrawPrimitive *primitivesOut, S32 *indicesOut) const;
  354. /// Moves vertices from the vertex buffer back into the split vert lists, unless verts already exist
  355. virtual void makeEditable();
  356. /// Clears split vertex lists
  357. virtual void clearEditable();
  358. void updateMeshFlags();
  359. /// methods used during assembly to share vertexand other info
  360. /// between meshes (and for skipping detail levels on load)
  361. S32* getSharedData32( S32 parentMesh, S32 size, S32 **source, bool skip );
  362. S8* getSharedData8( S32 parentMesh, S32 size, S8 **source, bool skip );
  363. /// @name Assembly Variables
  364. /// variables used during assembly (for skipping mesh detail levels
  365. /// on load and for sharing verts between meshes)
  366. /// @{
  367. static Vector<Point3F*> smVertsList;
  368. static Vector<Point3F*> smNormsList;
  369. static Vector<U8*> smEncodedNormsList;
  370. static Vector<Point2F*> smTVertsList;
  371. // Optional second texture uvs.
  372. static Vector<Point2F*> smTVerts2List;
  373. // Optional vertex colors.
  374. static Vector<ColorI*> smColorsList;
  375. static Vector<bool> smDataCopied;
  376. static const Point3F smU8ToNormalTable[];
  377. /// @}
  378. TSMesh();
  379. virtual ~TSMesh();
  380. Opcode::Model *mOptTree;
  381. Opcode::MeshInterface* mOpMeshInterface;
  382. IceMaths::IndexedTriangle* mOpTris;
  383. IceMaths::Point* mOpPoints;
  384. void prepOpcodeCollision();
  385. bool buildConvexOpcode( const MatrixF &mat, const Box3F &bounds, Convex *c, Convex *list );
  386. bool buildPolyListOpcode( const S32 od, AbstractPolyList *polyList, const Box3F &nodeBox, TSMaterialList *materials );
  387. bool castRayOpcode( const Point3F &start, const Point3F &end, RayInfo *rayInfo, TSMaterialList *materials );
  388. void dumpPrimitives(U32 startVertex, U32 startIndex, GFXPrimitive *piArray, U16* ibIndices);
  389. virtual U32 getNumVerts();
  390. static const F32 VISIBILITY_EPSILON;
  391. };
  392. class TSSkinMesh : public TSMesh
  393. {
  394. public:
  395. struct BatchData
  396. {
  397. enum Constants
  398. {
  399. maxBonePerVert = 16, // Assumes a maximum of 4 blocks of bone indices for HW skinning
  400. };
  401. /// @name Batch by vertex
  402. /// These are used for batches where each element is a vertex, built by
  403. /// iterating over 0..maxBonePerVert bone transforms
  404. /// @{
  405. struct TransformOp
  406. {
  407. S32 transformIndex;
  408. F32 weight;
  409. TransformOp() : transformIndex( -1 ), weight( -1.0f ) {}
  410. TransformOp( const S32 tIdx, const F32 w ) : transformIndex( tIdx ), weight( w ) {};
  411. };
  412. struct BatchedVertex
  413. {
  414. S32 vertexIndex;
  415. S32 transformCount;
  416. TransformOp transform[maxBonePerVert];
  417. BatchedVertex() : vertexIndex( -1 ), transformCount( -1 ) {}
  418. };
  419. Vector<BatchedVertex> vertexBatchOperations;
  420. /// @}
  421. // # = num bones
  422. Vector<S32> nodeIndex;
  423. Vector<MatrixF> initialTransforms;
  424. // # = numverts
  425. Vector<Point3F> initialVerts;
  426. Vector<Point3F> initialNorms;
  427. bool initialized;
  428. BatchData() : initialized(false) { ; }
  429. };
  430. /// This method will build the batch operations and prepare the BatchData
  431. /// for use.
  432. void createSkinBatchData();
  433. /// Inserts transform indices and weights into vertex data
  434. void setupVertexTransforms();
  435. /// Returns maximum bones used per vertex
  436. virtual U32 getMaxBonesPerVert();
  437. virtual void convertToVertexData();
  438. virtual void copySourceVertexDataFrom(const TSMesh* srcMesh);
  439. void printVerts();
  440. void addWeightsFromVertexBuffer();
  441. void makeEditable();
  442. void clearEditable();
  443. public:
  444. typedef TSMesh Parent;
  445. /// @name Vertex tuples
  446. /// {
  447. FreeableVector<F32> weight; ///< blend weight
  448. FreeableVector<S32> boneIndex; ///< Maps from mesh node to bone in shape
  449. FreeableVector<S32> vertexIndex; ///< index of affected vertex
  450. /// }
  451. /// Maximum number of bones referenced by this skin mesh
  452. S32 maxBones;
  453. /// Structure containing data needed to batch skinning
  454. BatchData batchData;
  455. /// set verts and normals...
  456. void updateSkinBuffer( const Vector<MatrixF> &transforms, U8 *buffer );
  457. /// update bone transforms for this mesh
  458. void updateSkinBones( const Vector<MatrixF> &transforms, Vector<MatrixF>& destTransforms );
  459. // render methods..
  460. void render( TSVertexBufferHandle &instanceVB );
  461. void render( TSMaterialList *,
  462. const TSRenderState &data,
  463. bool isSkinDirty,
  464. const Vector<MatrixF> &transforms,
  465. TSVertexBufferHandle &vertexBuffer,
  466. const char *meshName );
  467. // collision methods...
  468. bool buildPolyList( S32 frame, AbstractPolyList *polyList, U32 &surfaceKey, TSMaterialList *materials );
  469. bool castRay( S32 frame, const Point3F &start, const Point3F &end, RayInfo *rayInfo, TSMaterialList *materials );
  470. bool buildConvexHull(); // does nothing, skins don't use this
  471. void computeBounds( const MatrixF &transform, Box3F &bounds, S32 frame, Point3F *center, F32 *radius );
  472. /// persist methods...
  473. void assemble( bool skip );
  474. void disassemble();
  475. /// Helper method to add a blend tuple for a vertex
  476. inline void addWeightForVert(U32 vi, U32 bi, F32 w)
  477. {
  478. weight.push_back(w);
  479. boneIndex.push_back(bi);
  480. vertexIndex.push_back(vi);
  481. }
  482. /// variables used during assembly (for skipping mesh detail levels
  483. /// on load and for sharing verts between meshes)
  484. static Vector<MatrixF*> smInitTransformList;
  485. static Vector<S32*> smVertexIndexList;
  486. static Vector<S32*> smBoneIndexList;
  487. static Vector<F32*> smWeightList;
  488. static Vector<S32*> smNodeIndexList;
  489. static bool smDebugSkinVerts;
  490. TSSkinMesh();
  491. };
  492. #endif // _TSMESH_H_