remove old path and add few fixes
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
/* -*-c++-*-
|
||||
* Copyright (C) 2009 Cedric Pinson <cedric.pinson@plopbyte.net>
|
||||
* Copyright (C) 2017 Julien Valentin <mp3butcher@hotmail.com>
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
@@ -43,17 +44,6 @@ namespace osgAnimation
|
||||
typedef std::map<std::string, unsigned int> BoneNamePaletteIndex;
|
||||
|
||||
typedef std::vector<osg::Matrix> MatrixPalette;
|
||||
/*struct IndexWeightEntry
|
||||
{
|
||||
IndexWeightEntry(unsigned int index=0, float weight=0.0f): _boneIndex(index), _boneWeight(weight){}
|
||||
IndexWeightEntry(const IndexWeightEntry&o): _boneIndex(o._boneIndex), _boneWeight(o._boneWeight){}
|
||||
bool operator <(const IndexWeightEntry &o)const{return (_boneIndex<o._boneIndex);}
|
||||
const unsigned int &getBoneIndex() const { return _boneIndex; }
|
||||
const float &getWeight() const { return _boneWeight; }
|
||||
unsigned int _boneIndex;
|
||||
float _boneWeight;
|
||||
};*/
|
||||
|
||||
|
||||
osg::Vec4Array* getVertexAttrib(unsigned int index);
|
||||
unsigned int getNumVertexAttrib();
|
||||
@@ -64,8 +54,6 @@ namespace osgAnimation
|
||||
unsigned int getNumBonesPerVertex() const;
|
||||
unsigned int getNumVertexes() const;
|
||||
|
||||
bool createPalette(unsigned int nbVertexes,const BoneMap& boneMap, const VertexInfluenceSet::VertIDToBoneWeightList& vertexIndexToBoneWeightMap);
|
||||
|
||||
virtual void operator()(RigGeometry&);
|
||||
|
||||
virtual bool prepareData(RigGeometry& );
|
||||
@@ -78,8 +66,7 @@ namespace osgAnimation
|
||||
|
||||
protected:
|
||||
|
||||
bool init(RigGeometry&);
|
||||
osg::Uniform* createVertexUniform();
|
||||
osg::Uniform* createVertexUniform();
|
||||
|
||||
unsigned int _bonesPerVertex;
|
||||
unsigned int _nbVertexes;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* -*-c++-*-
|
||||
* Copyright (C) 2009 Cedric Pinson <cedric.pinson@plopbyte.net>
|
||||
* Copyright (C) 2017 Julien Valentin <mp3butcher@hotmail.com>
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
@@ -132,9 +133,9 @@ namespace osgAnimation
|
||||
template <class V> void compute(const osg::Matrix& transform, const osg::Matrix& invTransform, const V* src, V* dst)
|
||||
{
|
||||
// the result of matrix mult should be cached to be used for vertexes transform and normal transform and maybe other computation
|
||||
for(std::vector<VertexGroup>::iterator itvg=_uniqInfluenceSet2VertIDList.begin(); itvg!=_uniqInfluenceSet2VertIDList.end(); ++itvg)
|
||||
for(VertexGroupSet::iterator itvg=_uniqInfluenceSet2VertIDList.begin(); itvg!=_uniqInfluenceSet2VertIDList.end(); ++itvg)
|
||||
{
|
||||
VertexGroup& uniq = *itvg;
|
||||
VertexGroup& uniq = itvg->second;
|
||||
uniq.computeMatrixForVertexSet();
|
||||
osg::Matrix matrix = transform * uniq.getMatrix() * invTransform;
|
||||
|
||||
@@ -150,9 +151,9 @@ namespace osgAnimation
|
||||
|
||||
template <class V> void computeNormal(const osg::Matrix& transform, const osg::Matrix& invTransform, const V* src, V* dst)
|
||||
{
|
||||
for(std::vector<VertexGroup>::iterator itvg=_uniqInfluenceSet2VertIDList.begin(); itvg!=_uniqInfluenceSet2VertIDList.end(); ++itvg)
|
||||
for(VertexGroupSet::iterator itvg=_uniqInfluenceSet2VertIDList.begin(); itvg!=_uniqInfluenceSet2VertIDList.end(); ++itvg)
|
||||
{
|
||||
VertexGroup& uniq = *itvg;
|
||||
VertexGroup& uniq = itvg->second;
|
||||
uniq.computeMatrixForVertexSet();
|
||||
osg::Matrix matrix = transform * uniq.getMatrix() * invTransform;
|
||||
|
||||
@@ -166,15 +167,16 @@ namespace osgAnimation
|
||||
|
||||
protected:
|
||||
|
||||
bool init(RigGeometry&);
|
||||
void initVertexSetFromBones(const BoneMap& map, const VertexInfluenceSet::UniqVertexGroupList& influence);
|
||||
std::vector<VertexGroup> _uniqInfluenceSet2VertIDList;
|
||||
|
||||
bool _needInit;
|
||||
|
||||
std::map<std::string,bool> _invalidInfluence;
|
||||
|
||||
typedef std::vector<BonePtrWeight> BoneWeightList;
|
||||
typedef std::map<BoneWeightList, VertexGroup> VertexGroupSet;
|
||||
|
||||
VertexGroupSet _uniqInfluenceSet2VertIDList;
|
||||
void buildMinimumUpdateSet(const BoneMap&boneMap,const RigGeometry&rig );
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,11 @@ namespace osgAnimation
|
||||
inline void setBoneName(const std::string&s){first=s;}
|
||||
inline const float &getWeight()const{return second;}
|
||||
inline void setWeight(float i){second=i;}
|
||||
///default invweight ordered
|
||||
bool operator <(const BoneWeight&o)const{
|
||||
if(getWeight()>o.getWeight()) return true;
|
||||
if(getWeight()<o.getWeight()) return false;
|
||||
return getBoneName()<o.getBoneName();}
|
||||
};
|
||||
// first is vertex index, and second the weight
|
||||
struct IndexWeight: public std::pair<unsigned int, float>
|
||||
|
||||
Reference in New Issue
Block a user