Hardware Skinning Support

- Supports GL, D3D9 & D3D11
- Extends vertex formats & shadergen to support blend indices and weights
- Adds basic support for using 4x3 matrices for shader constants
- Supports software fallback
This commit is contained in:
James Urquhart 2015-01-10 19:41:25 +00:00
parent 507c239a87
commit 3496c549b5
72 changed files with 2533 additions and 1327 deletions

View file

@ -50,6 +50,25 @@ struct CollisionShapeInfo
PhysicsCollision *colShape;
};
/// Data storage helper for main shape buffer
struct TSShapeVertexArray
{
U8 *base;
U32 size;
bool vertexDataReady;
TSShapeVertexArray() : base(NULL), size(0), vertexDataReady(false) {}
virtual ~TSShapeVertexArray() { set(NULL, 0); }
virtual void set(void *b, U32 s, bool autoFree = true)
{
if (base && autoFree)
dFree_aligned(base);
base = reinterpret_cast<U8 *>(b);
size = s;
}
};
/// TSShape stores generic data for a 3space model.
///
/// TSShape and TSShapeInstance act in conjunction to allow the rendering and
@ -381,19 +400,21 @@ class TSShape
/// The GFX vertex format for all detail meshes in the shape.
/// @see initVertexFeatures()
GFXVertexFormat mVertexFormat;
/// The GFX vertex size in bytes for all detail meshes in the shape.
/// @see initVertexFeatures()
U32 mVertSize;
/// Is true if this shape contains skin meshes.
bool mHasSkinMesh;
bool mSequencesConstructed;
TSBasicVertexFormat mBasicVertexFormat;
U32 mVertexSize;
S8* mShapeData;
U32 mShapeDataSize;
// Processed vertex data
TSShapeVertexArray mShapeVertexData;
TSVertexBufferHandle mShapeVertexBuffer;
GFXPrimitiveBufferHandle mShapeVertexIndices;
bool mSequencesConstructed;
// shape class has few methods --
// just constructor/destructor, io, and lookup methods
@ -402,14 +423,24 @@ class TSShape
~TSShape();
void init();
void initMaterialList(); ///< you can swap in a new material list, but call this if you do
void finalizeEditable();
bool preloadMaterialList(const Torque::Path &path); ///< called to preload and validate the materials in the mat list
void setupBillboardDetails( const String &cachePath );
/// Initializes the main vertex buffer
void initVertexBuffers();
/// Loads shape vertex data into specified buffer
void getVertexBuffer(TSVertexBufferHandle &vb, GFXBufferType bufferType);
/// Called from init() to calcuate the GFX vertex features for
/// all detail meshes in the shape.
void initVertexFeatures();
/// Inits basic buffer pointers on load
void initVertexBufferPointers();
bool getSequencesConstructed() const { return mSequencesConstructed; }
void setSequencesConstructed(const bool c) { mSequencesConstructed = c; }
@ -526,7 +557,7 @@ class TSShape
const GFXVertexFormat* getVertexFormat() const { return &mVertexFormat; }
U32 getVertexSize() const { return mVertSize; }
bool needsBufferUpdate();
/// @}
@ -548,6 +579,12 @@ class TSShape
/// by default we initialize shape when we read...
static bool smInitOnRead;
/// Enables hardware skinning features
static bool smUseHardwareSkinning;
/// Determines maximum number of bones to use in hardware skinning shaders
static U32 smMaxSkinBones;
/// @name Version Info
/// @{