Thursday, September 20, 2018

Camera Framing Bug and NAN value in Maya 2018.3

NaN
Some operations of floating-point arithmetic are invalid, such as taking the square root of a negative number. The act of reaching an invalid result is called a floating-point exception. An exceptional result is represented by a special code called a NaN, for "Not a Number". All NaNs in IEEE 754-1985 have this format:



    I haven't seen this one in quite a while, but just got bit by it.. hard.  The issue crops up when Maya has a division by zero issue, or something similar that results in an infinitesimally small or NAN number.  It used to happen a lot with uvs .. especially with uvs coming from zBrush, as zBrush, like the honey badger, didn't care.  But it would mess up Maya read on open, and often would end up in an open file, with seemingly nothing in it but the transform nodes. 

   You would think, what do I care. Fubar uvs are not my problem, and I can make new ones anyway.. but Maya, says, wait I don't know what NAN is and basically stops trying, and just errors out the rest of your scene.



 This new issue seems to be hard to track down, but easy to accidentally do, and that's when hit f to frame the camera on a selection. For some reason it will put NAN into all the translate channels of the camera, and also in the center of interest (which is the biggest issue) , and using [ and ] to try and go back to previous views. doesn't work.. huh, 

To fix this you want to do a couple things. 

 First is to reset the TRS of the camera, so select it, and run Modify -> reset transforms.  
 next in the view, go to view -> default View 


 But really, I'm more interested in how it happens, and how to fix it ! 


 the nice thing is.. it looks like this issue is fixed in 2018.4 



but until you get updated.. here is some mel code you can run in your scene to reset you camera.. i added a small part to reset pan/zoom as well 
 I put this on my hotbox so I can quickly access it:

________________________________________________________________

global proc resetCamera()
{
string $panel=`getPanel -wf`; if ($panel == "StereoPanel"){$panel = "StereoPanelEditor";}
string $camera = `modelEditor -q -cam $panel`;

string $chans[] = {"tx","ty","tz","rx","ry","rz"};
for ($chan in $chans)
        {
        catchQuiet(`setAttr ($camera + "." + $chan) 0`);   
        }
string $chans[] = {"sx","sy","sz"};
for ($chan in $chans)
        {
        catchQuiet(`setAttr ($camera + "." + $chan) 1`);   
        }

viewSet -animate 0  -home $camera;


string $camShape[] = `listRelatives -c -s $camera`;
setAttr ($camShape[0] + ".horizontalPan" ) 0 ;
setAttr ($camShape[0] + ".verticalPan"  ) 0 ;

setAttr ($camShape[0] + ".zoom") 1;


}

















No comments:

Post a Comment