PVR Model POD scaling animation problem

Hi



I was experiencing a crash when one of the .pod file was having scaling animation.



The crash was happening here (in PVRTModelPOD.cpp in GetScalingMatrix() )



if(node.nAnimFlags & ePODHasScaleAni)

{

if(node.pnAnimScaleIdx)

{

PVRTMatrixVec3Lerp(

v,

(PVRTVECTOR3&)node.pfAnimScale[node.pnAnimScaleIdx[m_pImpl->nFrame+0]],

(PVRTVECTOR3&)node.pfAnimScale[node.pnAnimScaleIdx[m_pImpl->nFrame+1]], m_pImpl->fBlend);



}









I fixed the crash using the following fix





if(node.pnAnimScaleIdx)

{

if(m_pImpl->nFrame + 1 >= this->nNumFrame) {

v = (PVRTVECTOR3&)node.pfAnimScale[node.pnAnimScaleIdx[m_pImpl->nFrame+0]];

}

else {

PVRTMatrixVec3Lerp(

v,

(PVRTVECTOR3&)node.pfAnimScale[node.pnAnimScaleIdx[m_pImpl->nFrame+0]],

(PVRTVECTOR3&)node.pfAnimScale[node.pnAnimScaleIdx[m_pImpl->nFrame+1]], m_pImpl->fBlend);

}

}





Please suggest a proper fix. The condition m_pImpl->nFrame + 1 >= this->nNumFrame, was needed to be dealt with :slight_smile:

Hi Madan,



As mentioned in the SetFrame() comment, the tools expect the user to check that the input frame value value is valid for animation. For looping animation, frame 0 and the last frame should be identical, so there is no need to wrap between the last and the first frame animations.



We chose not to add an array bounds test to the function, as its an additional operaiton that would only be required for looping animations.



Regards,

Joe

Hi Joe,



Thanks for the insight into the problem ! Really helps.