Skip to content
Snippets Groups Projects
Commit 1b0089a2 authored by Tazpn's avatar Tazpn
Browse files

niflib: Allow strips as an option on the skin partition.

parent 7640f1bc
No related branches found
No related tags found
No related merge requests found
...@@ -156,7 +156,7 @@ public: ...@@ -156,7 +156,7 @@ public:
protected: protected:
friend class NiTriBasedGeom; friend class NiTriBasedGeom;
NiSkinPartition(Ref<NiTriBasedGeom> shape); NiSkinPartition(Ref<NiTriBasedGeom> shape);
NiSkinPartition(Ref<NiTriBasedGeom> shape, int maxBonesPerPartition, int maxBonesPerVertex, int *faceMap); NiSkinPartition(Ref<NiTriBasedGeom> shape, int maxBonesPerPartition, int maxBonesPerVertex, bool bStrippify, int *faceMap);
void SetNumPartitions( int value ); void SetNumPartitions( int value );
void SetWeightsPerVertex( int partition, unsigned short value ); void SetWeightsPerVertex( int partition, unsigned short value );
......
...@@ -59,7 +59,7 @@ public: ...@@ -59,7 +59,7 @@ public:
* \param[in] max_bones_per_partition The maximum number of bones that can affect a skin partition, i.e. a sub-mesh generated by chopping up the original mesh. Proper value is game dependent. * \param[in] max_bones_per_partition The maximum number of bones that can affect a skin partition, i.e. a sub-mesh generated by chopping up the original mesh. Proper value is game dependent.
* \param[in] max_bones_per_vertex The maximum number of bones that can affect any one vertex. Vertices affected by more bones than this will have the bone witht he smallest affect removed and the remaining bones will be normalized. * \param[in] max_bones_per_vertex The maximum number of bones that can affect any one vertex. Vertices affected by more bones than this will have the bone witht he smallest affect removed and the remaining bones will be normalized.
*/ */
NIFLIB_API void GenHardwareSkinInfo( int max_bones_per_partition = 4, int max_bones_per_vertex = 4, int* face2PartMap = NULL ); NIFLIB_API void GenHardwareSkinInfo( int max_bones_per_partition = 4, int max_bones_per_vertex = 4, bool bStrippify = true, int* face2PartMap = NULL );
/*! /*!
* This clears any hardware acceleration skin data that was previously created. * This clears any hardware acceleration skin data that was previously created.
......
...@@ -644,7 +644,7 @@ void NiSkinPartition::SetTriangles( int partition, const vector<Triangle> & in ) ...@@ -644,7 +644,7 @@ void NiSkinPartition::SetTriangles( int partition, const vector<Triangle> & in )
} }
SkinPartition& part = skinPartitionBlocks[partition]; SkinPartition& part = skinPartitionBlocks[partition];
part.triangles = in; part.triangles = in;
part.hasFaces = (in.size() > 0) ? false : (part.strips.size() != 0); part.hasFaces = (in.size() > 0) ? true : (part.strips.size() != 0);
part.numTriangles = (unsigned int)(in.size()) * 3; part.numTriangles = (unsigned int)(in.size()) * 3;
} }
...@@ -797,7 +797,7 @@ size_t indexOf(I begin, I end, const V& val) { ...@@ -797,7 +797,7 @@ size_t indexOf(I begin, I end, const V& val) {
} }
NiSkinPartition::NiSkinPartition(Ref<NiTriBasedGeom> shape, int maxBonesPerPartition, int maxBonesPerVertex, int* faceMap ) { NiSkinPartition::NiSkinPartition(Ref<NiTriBasedGeom> shape, int maxBonesPerPartition, int maxBonesPerVertex, bool bStrippify, int* faceMap ) {
NiSkinInstanceRef skinInst = shape->GetSkinInstance(); NiSkinInstanceRef skinInst = shape->GetSkinInstance();
if ( skinInst == NULL ) { if ( skinInst == NULL ) {
throw runtime_error( "You must bind a skin before setting generating skin partitions. No NiSkinInstance found." ); throw runtime_error( "You must bind a skin before setting generating skin partitions. No NiSkinInstance found." );
...@@ -1132,11 +1132,18 @@ NiSkinPartition::NiSkinPartition(Ref<NiTriBasedGeom> shape, int maxBonesPerParti ...@@ -1132,11 +1132,18 @@ NiSkinPartition::NiSkinPartition(Ref<NiTriBasedGeom> shape, int maxBonesPerParti
EnableVertexBoneIndices(p, true); EnableVertexBoneIndices(p, true);
// strippify the triangles // strippify the triangles
NiTriStripsDataRef data = new NiTriStripsData(triangles, true); if (bStrippify)
int nstrips = data->GetStripCount(); {
SetStripCount( p, nstrips ); NiTriStripsDataRef data = new NiTriStripsData(triangles, true);
for ( int i=0; i<nstrips; ++i ) { int nstrips = data->GetStripCount();
SetStrip(p, i, data->GetStrip(i)); SetStripCount( p, nstrips );
for ( int i=0; i<nstrips; ++i ) {
SetStrip(p, i, data->GetStrip(i));
}
}
else
{
SetTriangles(p, triangles);
} }
//// Special case for pre-stripped data //// Special case for pre-stripped data
......
...@@ -107,12 +107,12 @@ void NiTriBasedGeom::ClearHardareSkinInfo() { ...@@ -107,12 +107,12 @@ void NiTriBasedGeom::ClearHardareSkinInfo() {
} }
void NiTriBasedGeom::GenHardwareSkinInfo( int max_bones_per_partition /*= 4*/, int max_bones_per_vertex /*= INT_MAX*/, int* face2PartMap /*= NULL*/ ) { void NiTriBasedGeom::GenHardwareSkinInfo( int max_bones_per_partition /*= 4*/, int max_bones_per_vertex /*= INT_MAX*/, bool bStrippify /*= true*/, int* face2PartMap /*= NULL*/ ) {
NiSkinPartitionRef skinPart; NiSkinPartitionRef skinPart;
if ( max_bones_per_partition == 0 ) //old method if ( max_bones_per_partition == 0 ) //old method
skinPart = new NiSkinPartition( this ); skinPart = new NiSkinPartition( this );
else else
skinPart = new NiSkinPartition( this, max_bones_per_partition, max_bones_per_vertex, face2PartMap ); skinPart = new NiSkinPartition( this, max_bones_per_partition, max_bones_per_vertex, bStrippify, face2PartMap );
// Set the partition info in both places and it will be handled when exported. // Set the partition info in both places and it will be handled when exported.
NiSkinInstanceRef skinInst = GetSkinInstance(); NiSkinInstanceRef skinInst = GetSkinInstance();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment