- Timestamp:
- 03/21/12 18:36:20 (15 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgAnimation/VertexInfluence.cpp
r12292 r13041 1 /* -*-c++-*- 1 /* -*-c++-*- 2 2 * Copyright (C) 2008 Cedric Pinson <cedric.pinson@plopbyte.net> 3 3 * 4 * This library is open source and may be redistributed and/or modified under 5 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 4 * This library is open source and may be redistributed and/or modified under 5 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 6 6 * (at your option) any later version. The full license is in LICENSE file 7 7 * included with this distribution, and on the openscenegraph.org website. 8 * 8 * 9 9 * This library is distributed in the hope that it will be useful, 10 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 12 * OpenSceneGraph Public License for more details. 13 13 */ … … 27 27 { 28 28 _vertex2Bones.clear(); 29 for (BoneToVertexList::const_iterator it = _bone2Vertexes.begin(); it != _bone2Vertexes.end(); ++it) 29 for (BoneToVertexList::const_iterator it = _bone2Vertexes.begin(); it != _bone2Vertexes.end(); ++it) 30 30 { 31 31 const VertexInfluence& vi = (*it); 32 32 int size = vi.size(); 33 for (int i = 0; i < size; i++) 33 for (int i = 0; i < size; i++) 34 34 { 35 35 VertexIndexWeight viw = vi[i]; … … 50 50 for (int i = 0; i < size; i++) 51 51 sum += bones[i].getWeight(); 52 if (sum < 1e-4) 52 if (sum < 1e-4) 53 53 { 54 54 OSG_WARN << "VertexInfluenceSet::buildVertex2BoneList warning the vertex " << it->first << " seems to have 0 weight, skip normalize for this vertex" << std::endl; 55 55 } 56 else 56 else 57 57 { 58 58 float mult = 1.0/sum; … … 68 68 struct SortByNameAndWeight : public std::less<VertexInfluenceSet::BoneWeight> 69 69 { 70 bool operator()(const VertexInfluenceSet::BoneWeight& b0, 71 const VertexInfluenceSet::BoneWeight& b1) const 70 bool operator()(const VertexInfluenceSet::BoneWeight& b0, 71 const VertexInfluenceSet::BoneWeight& b1) const 72 72 { 73 73 if (b0.getBoneName() < b1.getBoneName()) … … 83 83 struct SortByBoneWeightList : public std::less<VertexInfluenceSet::BoneWeightList> 84 84 { 85 bool operator()(const VertexInfluenceSet::BoneWeightList& b0, 86 const VertexInfluenceSet::BoneWeightList& b1) const 85 bool operator()(const VertexInfluenceSet::BoneWeightList& b0, 86 const VertexInfluenceSet::BoneWeightList& b1) const 87 87 { 88 88 if (b0.size() < b1.size()) … … 92 92 93 93 int size = b0.size(); 94 for (int i = 0; i < size; i++) 94 for (int i = 0; i < size; i++) 95 95 { 96 96 bool result = SortByNameAndWeight()(b0[i], b1[i]); … … 106 106 void VertexInfluenceSet::clear() 107 107 { 108 _bone2Vertexes.clear(); 108 _bone2Vertexes.clear(); 109 109 _uniqVertexSetToBoneSet.clear(); 110 110 } … … 117 117 UnifyBoneGroup unifyBuffer; 118 118 119 for (VertexIndexToBoneWeightMap::iterator it = _vertex2Bones.begin(); it != _vertex2Bones.end(); ++it) 119 for (VertexIndexToBoneWeightMap::iterator it = _vertex2Bones.begin(); it != _vertex2Bones.end(); ++it) 120 120 { 121 121 BoneWeightList bones = it->second; … … 124 124 // sort the vector to have a consistent key 125 125 std::sort(bones.begin(), bones.end(), SortByNameAndWeight()); 126 126 127 127 // we use the vector<BoneWeight> as key to differentiate group 128 128 UnifyBoneGroup::iterator result = unifyBuffer.find(bones); … … 133 133 134 134 _uniqVertexSetToBoneSet.reserve(unifyBuffer.size()); 135 for (UnifyBoneGroup::iterator it = unifyBuffer.begin(); it != unifyBuffer.end(); ++it) 135 for (UnifyBoneGroup::iterator it = unifyBuffer.begin(); it != unifyBuffer.end(); ++it) 136 136 { 137 137 _uniqVertexSetToBoneSet.push_back(it->second);
