Index: OpenSceneGraph/trunk/src/osgAnimation/RigTransformHardware.cpp
===================================================================
--- OpenSceneGraph/trunk/src/osgAnimation/RigTransformHardware.cpp (revision 10693)
+++ OpenSceneGraph/trunk/src/osgAnimation/RigTransformHardware.cpp (revision 11009)
@@ -15,7 +15,16 @@
 #include <osgAnimation/RigTransformHardware>
 #include <osgAnimation/RigGeometry>
+#include <osgAnimation/BoneMapVisitor>
 #include <sstream>
 
 using namespace osgAnimation;
+
+
+RigTransformHardware::RigTransformHardware()
+{
+    _needInit = true;
+    _bonesPerVertex = 0;
+    _nbVertexes = 0;
+}
 
 osg::Vec4Array* RigTransformHardware::getVertexAttrib(int index)
@@ -68,10 +77,10 @@
 
     int maxBonePerVertex = 0;
-    for (VertexInfluenceSet::VertexIndexToBoneWeightMap::const_iterator it = vertexIndexToBoneWeightMap.begin(); it != vertexIndexToBoneWeightMap.end(); it++)
+    for (VertexInfluenceSet::VertexIndexToBoneWeightMap::const_iterator it = vertexIndexToBoneWeightMap.begin(); it != vertexIndexToBoneWeightMap.end(); ++it)
     {
         int vertexIndex = it->first;
         const VertexInfluenceSet::BoneWeightList& boneWeightList = it->second;
         int bonesForThisVertex = 0;
-        for (VertexInfluenceSet::BoneWeightList::const_iterator it = boneWeightList.begin(); it != boneWeightList.end(); it++)
+        for (VertexInfluenceSet::BoneWeightList::const_iterator it = boneWeightList.begin(); it != boneWeightList.end(); ++it)
         {
             const VertexInfluenceSet::BoneWeight& bw = *it;
@@ -86,5 +95,5 @@
                 if (boneMap.find(bw.getBoneName()) == boneMap.end())
                 {
-                    osg::notify(osg::WARN) << "RigTransformHardware::createPalette can't find bone " << bw.getBoneName() << " skip this influence" << std::endl;
+                    osg::notify(osg::INFO) << "RigTransformHardware::createPalette can't find bone " << bw.getBoneName() << " skip this influence" << std::endl;
                     continue;
                 }
@@ -105,5 +114,5 @@
     osg::notify(osg::INFO) << "RigTransformHardware::createPalette matrix palette has " << boneNameCountMap.size() << " entries" << std::endl;
 
-    for (BoneNameCountMap::iterator it = boneNameCountMap.begin(); it != boneNameCountMap.end(); it++)
+    for (BoneNameCountMap::iterator it = boneNameCountMap.begin(); it != boneNameCountMap.end(); ++it)
     {
         osg::notify(osg::INFO) << "RigTransformHardware::createPalette Bone " << it->first << " is used " << it->second << " times" << std::endl;
@@ -187,18 +196,28 @@
 bool RigTransformHardware::init(RigGeometry& geom)
 {
-    osg::Vec3Array* pos = dynamic_cast<osg::Vec3Array*>(geom.getVertexArray());
-    if (!pos) {
+    osg::Geometry& source = *geom.getSourceGeometry();
+    osg::Vec3Array* positionSrc = dynamic_cast<osg::Vec3Array*>(source.getVertexArray());
+    if (!positionSrc) 
+    {
         osg::notify(osg::WARN) << "RigTransformHardware no vertex array in the geometry " << geom.getName() << std::endl;
         return false;
     }
 
-    if (!geom.getSkeleton()) {
-        osg::notify(osg::WARN) << "RigTransformHardware no skeleting set in geometry " << geom.getName() << std::endl;
-        return false;
-    }
-
-    Bone::BoneMap bm = geom.getSkeleton()->getBoneMap();
-
-    if (!createPalette(pos->size(),bm, geom.getVertexInfluenceSet().getVertexToBoneList()))
+    if (!geom.getSkeleton()) 
+    {
+        osg::notify(osg::WARN) << "RigTransformHardware no skeleton set in geometry " << geom.getName() << std::endl;
+        return false;
+    }
+
+
+    // copy shallow from source geometry to rig
+    geom.copyFrom(source);
+
+
+    BoneMapVisitor mapVisitor;
+    geom.getSkeleton()->accept(mapVisitor);
+    BoneMap bm = mapVisitor.getBoneMap();
+
+    if (!createPalette(positionSrc->size(),bm, geom.getVertexInfluenceSet().getVertexToBoneList()))
         return false;
 
@@ -245,6 +264,9 @@
     return true;
 }
-void RigTransformHardware::update(RigGeometry& geom)
-{
+void RigTransformHardware::operator()(RigGeometry& geom)
+{
+    if (_needInit)
+        if (!init(geom))
+            return;
     computeMatrixPaletteUniform(geom.getMatrixFromSkeletonToGeometry(), geom.getInvMatrixFromSkeletonToGeometry());
 }
