Permalink
Browse files

Fix "Skin Transform" errors in Transform class.

This partially reverts commit b0e0568
as it fixes transform construction at the class rather than the calls
to it. Hence this fixes other bugs like spells that were not fixed the
first time.
  • Loading branch information...
Alphax committed Jul 31, 2010
1 parent f9a54f4 commit 555afe6eccd0b1798fbe078160d37992194c2cdc
Showing with 30 additions and 11 deletions.
  1. +1 −1 gl/glmesh.cpp
  2. +1 −1 gl/gltools.cpp
  3. +28 −9 niftypes.cpp
View
@@ -602,7 +602,7 @@ void Mesh::transform()
iSkinData = nif->getBlock( nif->getLink( iSkin, "Data" ), "NiSkinData" );
skelRoot = nif->getLink( iSkin, "Skeleton Root" );
- skelTrans = Transform( nif, nif->getIndex( iSkinData, "Skin Transform" ) );
+ skelTrans = Transform( nif, iSkinData );
bones = nif->getLinkArray( iSkin, "Bones" );
View
@@ -40,7 +40,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
BoneWeights::BoneWeights( const NifModel * nif, const QModelIndex & index, int b )
{
- trans = Transform( nif, nif->getIndex( index, "Skin Transform" ) );
+ trans = Transform( nif, index );
center = nif->get<Vector3>( index, "Center" );
radius = nif->get<float>( index, "Radius" );
bone = b;
View
@@ -443,24 +443,43 @@ Transform operator*( const Transform & t1, const Transform & t2 )
bool Transform::canConstruct( const NifModel * nif, const QModelIndex & parent )
{
- return nif && parent.isValid() && nif->getIndex( parent, "Rotation" ).isValid()
- && nif->getIndex( parent, "Translation" ).isValid()
- && nif->getIndex( parent, "Scale" ).isValid();
+ QModelIndex skinTransform = nif->getIndex( parent, "Skin Transform" );
+ return nif && (
+ (
+ parent.isValid() && nif->getIndex( parent, "Rotation" ).isValid()
+ && nif->getIndex( parent, "Translation" ).isValid()
+ && nif->getIndex( parent, "Scale" ).isValid()
+ ) || (
+ skinTransform.isValid() && nif->getIndex( skinTransform, "Rotation" ).isValid()
+ && nif->getIndex( skinTransform, "Translation" ).isValid()
+ && nif->getIndex( skinTransform, "Scale" ).isValid()
+ )
+ );
}
Transform::Transform( const NifModel * nif, const QModelIndex & transform )
{
- rotation = nif->get<Matrix>( transform, "Rotation" );
- translation = nif->get<Vector3>( transform, "Translation" );
- scale = nif->get<float>( transform, "Scale" );
+ QModelIndex skinTransform = nif->getIndex( transform, "Skin Transform" );
+ if( !skinTransform.isValid() )
+ {
+ skinTransform = transform;
+ }
+ rotation = nif->get<Matrix>( skinTransform, "Rotation" );
+ translation = nif->get<Vector3>( skinTransform, "Translation" );
+ scale = nif->get<float>( skinTransform, "Scale" );
}
void Transform::writeBack( NifModel * nif, const QModelIndex & transform ) const
{
- nif->set<Matrix>( transform, "Rotation", rotation );
- nif->set<Vector3>( transform, "Translation", translation );
- nif->set<float>( transform, "Scale", scale );
+ QModelIndex skinTransform = nif->getIndex( transform, "Skin Transform" );
+ if( !skinTransform.isValid() )
+ {
+ skinTransform = transform;
+ }
+ nif->set<Matrix>( skinTransform, "Rotation", rotation );
+ nif->set<Vector3>( skinTransform, "Translation", translation );
+ nif->set<float>( skinTransform, "Scale", scale );
}
QString Transform::toString() const

0 comments on commit 555afe6

Please sign in to comment.