Show
Ignore:
Timestamp:
06/24/11 21:17:25 (3 years ago)
Author:
robert
Message:

Tightened up the float/double usage

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osganimationskinning/osganimationskinning.cpp

    r12292 r12648  
    7474    geometry->setColorBinding (osg::Geometry::BIND_PER_VERTEX);     
    7575   
    76     float step = size / nsplit; 
    77     float s = 0.5/4.0; 
     76    float step = size / static_cast<float>(nsplit); 
     77    float s = 0.5f/4.0f; 
    7878    for (int i = 0; i < nsplit; i++)  
    7979    { 
    80         float x = -1 + i * step; 
     80        float x = -1.0f + static_cast<float>(i) * step; 
    8181        std::cout << x << std::endl; 
    8282        vertices->push_back (osg::Vec3 ( x, s, s)); 
     
    8484        vertices->push_back (osg::Vec3 ( x, -s, -s)); 
    8585        vertices->push_back (osg::Vec3 ( x, s, -s)); 
    86         osg::Vec3 c (0,0,0); 
    87         c[i%3] = 1; 
     86        osg::Vec3 c (0.0f,0.0f,0.0f); 
     87        c[i%3] = 1.0f; 
    8888        colors->push_back (c); 
    8989        colors->push_back (c); 
     
    150150        std::cout << val << std::endl; 
    151151        if (val >= -1 && val <= 0) 
    152             (*vim)[b0->getName()].push_back(osgAnimation::VertexIndexWeight(i,1)); 
     152            (*vim)[b0->getName()].push_back(osgAnimation::VertexIndexWeight(i,1.0f)); 
    153153        else if ( val > 0 && val <= 1) 
    154             (*vim)[b1->getName()].push_back(osgAnimation::VertexIndexWeight(i,1)); 
     154            (*vim)[b1->getName()].push_back(osgAnimation::VertexIndexWeight(i,1.0f)); 
    155155        else if ( val > 1) 
    156             (*vim)[b2->getName()].push_back(osgAnimation::VertexIndexWeight(i,1)); 
     156            (*vim)[b2->getName()].push_back(osgAnimation::VertexIndexWeight(i,1.0f)); 
    157157    } 
    158158 
     
    172172    skelroot->setDefaultUpdateCallback(); 
    173173    osg::ref_ptr<osgAnimation::Bone> root = new osgAnimation::Bone; 
    174     root->setInvBindMatrixInSkeletonSpace(osg::Matrix::inverse(osg::Matrix::translate(-1,0,0))); 
     174    root->setInvBindMatrixInSkeletonSpace(osg::Matrix::inverse(osg::Matrix::translate(-1.0,0.0,0.0))); 
    175175    root->setName("root"); 
    176176    osgAnimation::UpdateBone* pRootUpdate = new osgAnimation::UpdateBone("root"); 
    177     pRootUpdate->getStackedTransforms().push_back(new osgAnimation::StackedTranslateElement("translate",osg::Vec3(-1,0,0))); 
     177    pRootUpdate->getStackedTransforms().push_back(new osgAnimation::StackedTranslateElement("translate",osg::Vec3(-1.0f,0.0f,0.0f))); 
    178178    root->setUpdateCallback(pRootUpdate); 
    179179 
    180180    osg::ref_ptr<osgAnimation::Bone> right0 = new osgAnimation::Bone; 
    181     right0->setInvBindMatrixInSkeletonSpace(osg::Matrix::inverse(osg::Matrix::translate(0,0,0))); 
     181    right0->setInvBindMatrixInSkeletonSpace(osg::Matrix::inverse(osg::Matrix::translate(0.0,0.0,0.0))); 
    182182    right0->setName("right0"); 
    183183    osgAnimation::UpdateBone* pRight0Update = new osgAnimation::UpdateBone("right0"); 
    184     pRight0Update->getStackedTransforms().push_back(new osgAnimation::StackedTranslateElement("translate", osg::Vec3(1,0,0))); 
    185     pRight0Update->getStackedTransforms().push_back(new osgAnimation::StackedRotateAxisElement("rotate", osg::Vec3(0,0,1), 0)); 
     184    pRight0Update->getStackedTransforms().push_back(new osgAnimation::StackedTranslateElement("translate", osg::Vec3(1.0f,0.0f,0.0f))); 
     185    pRight0Update->getStackedTransforms().push_back(new osgAnimation::StackedRotateAxisElement("rotate", osg::Vec3(0.0f,0.0f,1.0f), 0.0)); 
    186186    right0->setUpdateCallback(pRight0Update); 
    187187 
    188188    osg::ref_ptr<osgAnimation::Bone> right1 = new osgAnimation::Bone; 
    189     right1->setInvBindMatrixInSkeletonSpace(osg::Matrix::inverse(osg::Matrix::translate(1,0,0))); 
     189    right1->setInvBindMatrixInSkeletonSpace(osg::Matrix::inverse(osg::Matrix::translate(1.0,0.0,0.0))); 
    190190    right1->setName("right1"); 
    191191    osgAnimation::UpdateBone* pRight1Update = new osgAnimation::UpdateBone("right1"); 
    192     pRight1Update->getStackedTransforms().push_back(new osgAnimation::StackedTranslateElement("translate", osg::Vec3(1,0,0))); 
    193     pRight1Update->getStackedTransforms().push_back(new osgAnimation::StackedRotateAxisElement("rotate", osg::Vec3(0,0,1), 0)); 
     192    pRight1Update->getStackedTransforms().push_back(new osgAnimation::StackedTranslateElement("translate", osg::Vec3(1.0f,0.0f,0.0f))); 
     193    pRight1Update->getStackedTransforms().push_back(new osgAnimation::StackedRotateAxisElement("rotate", osg::Vec3(0.0f,0.0f,1.0f), 0.0)); 
    194194    right1->setUpdateCallback(pRight1Update); 
    195195 
     
    205205    { 
    206206        osgAnimation::FloatKeyframeContainer* keys0 = new osgAnimation::FloatKeyframeContainer; 
    207         keys0->push_back(osgAnimation::FloatKeyframe(0,0)); 
    208         keys0->push_back(osgAnimation::FloatKeyframe(3,osg::PI_2)); 
    209         keys0->push_back(osgAnimation::FloatKeyframe(6,osg::PI_2)); 
     207        keys0->push_back(osgAnimation::FloatKeyframe(0.0,0.0f)); 
     208        keys0->push_back(osgAnimation::FloatKeyframe(3.0,osg::PI_2)); 
     209        keys0->push_back(osgAnimation::FloatKeyframe(6.0,osg::PI_2)); 
    210210        osgAnimation::FloatLinearSampler* sampler = new osgAnimation::FloatLinearSampler; 
    211211        sampler->setKeyframeContainer(keys0); 
     
    218218    { 
    219219        osgAnimation::FloatKeyframeContainer* keys1 = new osgAnimation::FloatKeyframeContainer; 
    220         keys1->push_back(osgAnimation::FloatKeyframe(0,0)); 
    221         keys1->push_back(osgAnimation::FloatKeyframe(3,0)); 
    222         keys1->push_back(osgAnimation::FloatKeyframe(6,osg::PI_2)); 
     220        keys1->push_back(osgAnimation::FloatKeyframe(0.0,0.0f)); 
     221        keys1->push_back(osgAnimation::FloatKeyframe(3.0,0.0f)); 
     222        keys1->push_back(osgAnimation::FloatKeyframe(6.0,osg::PI_2)); 
    223223        osgAnimation::FloatLinearSampler* sampler = new osgAnimation::FloatLinearSampler; 
    224224        sampler->setKeyframeContainer(keys1); 
     
    236236    // we will use local data from the skeleton 
    237237    osg::MatrixTransform* rootTransform = new osg::MatrixTransform; 
    238     rootTransform->setMatrix(osg::Matrix::rotate(osg::PI_2,osg::Vec3(1,0,0))); 
     238    rootTransform->setMatrix(osg::Matrix::rotate(osg::PI_2,osg::Vec3(1.0f,0.0f,0.0f))); 
    239239    right0->addChild(createAxis()); 
    240240    right0->setDataVariance(osg::Object::DYNAMIC); 
     
    249249    scene->addChild(rootTransform); 
    250250   
    251     osgAnimation::RigGeometry* geom = createTesselatedBox(4, 4.0); 
     251    osgAnimation::RigGeometry* geom = createTesselatedBox(4, 4.0f); 
    252252    osg::Geode* geode = new osg::Geode; 
    253253    geode->addDrawable(geom);