reformat with the help of AStyle reformat tool (codeblocks)

This commit is contained in:
Julien Valentin 2017-10-27 21:02:43 +02:00
parent 6530b16fc7
commit 6e79ce348d
8 changed files with 95 additions and 90 deletions

View File

@ -29,7 +29,8 @@ namespace osgAnimation
public:
enum Method {
enum Method
{
NORMALIZED,
RELATIVE
};
@ -88,16 +89,16 @@ namespace osgAnimation
inline MorphTarget& getMorphTarget( unsigned int i ) { return _morphTargets[i]; }
/** Set source of vertices for this morph geometry */
inline void setVertexSource(osg::Vec3Array *v){ _positionSource=v;}
inline void setVertexSource(osg::Vec3Array *v) { _positionSource=v; }
/** Get source of vertices for this morph geometry */
inline osg::Vec3Array * getVertexSource()const{return _positionSource.get();}
inline osg::Vec3Array * getVertexSource() const { return _positionSource.get(); }
/** Set source of normals for this morph geometry */
inline void setNormalSource(osg::Vec3Array *n){ _normalSource=n;}
inline void setNormalSource(osg::Vec3Array *n) { _normalSource=n; }
/** Get source of normals for this morph geometry */
inline osg::Vec3Array * getNormalSource() const {return _normalSource.get();}
inline osg::Vec3Array * getNormalSource() const { return _normalSource.get(); }
/** Add a \c MorphTarget to the \c MorphGeometry.
* If \c MorphTarget is not \c NULL and is not contained in the \c MorphGeometry
@ -108,20 +109,30 @@ namespace osgAnimation
* @param weight The weight to be added to the \c MorphGeometry.
* @return \c true for success; \c false otherwise.
*/
virtual void addMorphTarget( osg::Geometry *morphTarget, float weight = 1.0 ) { _morphTargets.push_back(MorphTarget(morphTarget, weight)); _dirty = true; }
virtual void addMorphTarget( osg::Geometry *morphTarget, float weight = 1.0 )
{
_morphTargets.push_back(MorphTarget(morphTarget, weight));
_dirty = true;
}
virtual void removeMorphTarget( osg::Geometry *morphTarget ) {
for(MorphTargetList::iterator iterator = _morphTargets.begin() ; iterator != _morphTargets.end() ; ++ iterator) {
if(iterator->getGeometry() == morphTarget) {
virtual void removeMorphTarget( osg::Geometry *morphTarget )
{
for(MorphTargetList::iterator iterator = _morphTargets.begin() ; iterator != _morphTargets.end() ; ++ iterator)
{
if(iterator->getGeometry() == morphTarget)
{
_morphTargets.erase(iterator);
break;
}
}
}
virtual void removeMorphTarget( const std::string& name ) {
for(MorphTargetList::iterator iterator = _morphTargets.begin() ; iterator != _morphTargets.end() ; ++ iterator) {
if(iterator->getGeometry() && iterator->getGeometry()->getName() == name) {
virtual void removeMorphTarget( const std::string& name )
{
for(MorphTargetList::iterator iterator = _morphTargets.begin() ; iterator != _morphTargets.end() ; ++ iterator)
{
if(iterator->getGeometry() && iterator->getGeometry()->getName() == name)
{
_morphTargets.erase(iterator);
break;
}
@ -141,10 +152,10 @@ namespace osgAnimation
/** Set the MorphGeometry dirty.*/
inline void dirty(bool b=true) { _dirty = b; }
inline bool isDirty()const { return _dirty; }
inline bool isDirty() const { return _dirty; }
/** for retrocompatibility */
void transformSoftwareMethod(){(*_morphTransformImplementation.get())(*this);}
void transformSoftwareMethod() { (*_morphTransformImplementation.get())(*this); }
protected:
osg::ref_ptr<MorphTransform> _morphTransformImplementation;
@ -175,7 +186,8 @@ namespace osgAnimation
void addTarget(const std::string& name) { _targetNames.push_back(name); }
unsigned int getNumTarget() const { return _targetNames.size(); }
const std::string& getTargetName(unsigned int index) { return _targetNames[index]; }
void removeTarget(const std::string& name) {
void removeTarget(const std::string& name)
{
TargetNames::iterator found = std::find(_targetNames.begin(), _targetNames.end(), name);
if(found != _targetNames.end())
_targetNames.erase(found);
@ -185,9 +197,7 @@ namespace osgAnimation
const std::vector<std::string>& getTargetNames() const { return _targetNames; }
std::vector<std::string>& getTargetNames() { return _targetNames; }
void setTargetNames(const TargetNames& targetNames) {
_targetNames.assign(targetNames.begin(), targetNames.end());
}
void setTargetNames(const TargetNames& targetNames) { _targetNames.assign(targetNames.begin(), targetNames.end()); }
/** Callback method called by the NodeVisitor when visiting a node.*/
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
@ -226,8 +236,6 @@ namespace osgAnimation
(implementation)(*geom);
}
};
}
#endif

View File

@ -43,18 +43,17 @@ namespace osgAnimation
virtual void operator()(MorphGeometry&);
inline void setShader( osg::Shader*s ) { _shader=s; }
inline const osg::Shader * getShader() const{ return _shader.get(); }
inline const osg::Shader * getShader() const { return _shader.get(); }
inline osg::Shader * getShader() { return _shader.get(); }
///texture unit reserved for morphtarget TBO default is 7
void setReservedTextureUnit(unsigned int t) { _reservedTextureUnit=t; }
unsigned int getReservedTextureUnit() const { return _reservedTextureUnit;}
unsigned int getReservedTextureUnit() const { return _reservedTextureUnit; }
protected:
bool init(MorphGeometry&);
osg::ref_ptr<osg::Uniform> _uniformTargetsWeight;
osg::ref_ptr<osg::Shader> _shader;

View File

@ -29,8 +29,8 @@ namespace osgAnimation
class OSGANIMATION_EXPORT MorphTransformSoftware : public MorphTransform
{
public:
MorphTransformSoftware():_needInit(true){}
MorphTransformSoftware(const MorphTransformSoftware& rts,const osg::CopyOp& copyop): MorphTransform(rts, copyop), _needInit(true){}
MorphTransformSoftware():_needInit(true) {}
MorphTransformSoftware(const MorphTransformSoftware& rts,const osg::CopyOp& copyop): MorphTransform(rts, copyop), _needInit(true) {}
META_Object(osgAnimation,MorphTransformSoftware)

View File

@ -23,7 +23,6 @@
namespace osgAnimation
{
// The idea is to compute a bounding box with a factor x of the first step we compute the bounding box
class OSGANIMATION_EXPORT RigComputeBoundingBoxCallback : public osg::Drawable::ComputeBoundingBoxCallback
{
@ -37,8 +36,8 @@ namespace osgAnimation
META_Object(osgAnimation, RigComputeBoundingBoxCallback);
void reset() { _computed = false; }
virtual osg::BoundingBox computeBound(const osg::Drawable& drawable) const;
protected:
mutable bool _computed;
@ -58,16 +57,16 @@ namespace osgAnimation
META_Object(osgAnimation, RigGeometry);
inline void setInfluenceMap(VertexInfluenceMap* vertexInfluenceMap) { _vertexInfluenceMap = vertexInfluenceMap; }
inline const VertexInfluenceMap* getInfluenceMap() const { return _vertexInfluenceMap.get();}
inline VertexInfluenceMap* getInfluenceMap() { return _vertexInfluenceMap.get();}
inline const VertexInfluenceMap* getInfluenceMap() const { return _vertexInfluenceMap.get(); }
inline VertexInfluenceMap* getInfluenceMap() { return _vertexInfluenceMap.get(); }
inline const Skeleton* getSkeleton() const { return _root.get(); }
inline Skeleton* getSkeleton() { return _root.get(); }
// will be used by the update callback to init correctly the rig mesh
inline void setSkeleton(Skeleton* root){ _root = root;}
inline void setSkeleton(Skeleton* root) { _root = root; }
void setNeedToComputeMatrix(bool state) { _needToComputeMatrix = state;}
bool getNeedToComputeMatrix() const { return _needToComputeMatrix;}
void setNeedToComputeMatrix(bool state) { _needToComputeMatrix = state; }
bool getNeedToComputeMatrix() const { return _needToComputeMatrix; }
void computeMatrixFromRootSkeleton();
@ -78,9 +77,10 @@ namespace osgAnimation
void update();
void buildVertexInfluenceSet(){_rigTransformImplementation->prepareData(*this);}
void buildVertexInfluenceSet() { _rigTransformImplementation->prepareData(*this); }
const osg::Matrix& getMatrixFromSkeletonToGeometry() const;
const osg::Matrix& getInvMatrixFromSkeletonToGeometry() const;
inline osg::Geometry* getSourceGeometry() { return _geometry.get(); }
@ -106,7 +106,6 @@ namespace osgAnimation
osg::ref_ptr<osg::Geometry> _geometry;
osg::ref_ptr<RigTransform> _rigTransformImplementation;
osg::ref_ptr<VertexInfluenceMap> _vertexInfluenceMap;
osg::Matrix _matrixFromSkeletonToGeometry;
@ -114,7 +113,6 @@ namespace osgAnimation
osg::observer_ptr<Skeleton> _root;
bool _needToComputeMatrix;
};
@ -129,7 +127,8 @@ namespace osgAnimation
META_Object(osgAnimation, UpdateRigGeometry);
virtual void update(osg::NodeVisitor* nv, osg::Drawable* drw) {
virtual void update(osg::NodeVisitor* nv, osg::Drawable* drw)
{
RigGeometry* geom = dynamic_cast<RigGeometry*>(drw);
if(!geom)
return;
@ -155,7 +154,8 @@ namespace osgAnimation
if(geom->getNeedToComputeMatrix())
geom->computeMatrixFromRootSkeleton();
if(geom->getSourceGeometry()) {
if(geom->getSourceGeometry())
{
osg::Drawable::UpdateCallback * up = dynamic_cast<osg::Drawable::UpdateCallback*>(geom->getSourceGeometry()->getUpdateCallback());
if(up)
up->update(nv, geom->getSourceGeometry());

View File

@ -1,15 +1,15 @@
/* -*-c++-*-
* Copyright (C) 2009 Cedric Pinson <cedric.pinson@plopbyte.net>
*
* 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
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
/* -*-c++-*-
* Copyright (C) 2009 Cedric Pinson <cedric.pinson@plopbyte.net>
*
* 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
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSGANIMATION_RIGTRANSFORM
@ -35,7 +35,7 @@ namespace osgAnimation
/// to call manually when a skeleton is reacheable from the rig
/// in order to prepare technic data before rendering
virtual bool prepareData(RigGeometry&){return true;}
virtual bool prepareData(RigGeometry&) { return true; }
protected:
virtual ~RigTransform() {}

View File

@ -46,20 +46,20 @@ namespace osgAnimation
typedef std::vector<osg::Matrix> MatrixPalette;
///set the first Vertex Attribute Array index of the rig generated by this technic (default:11)
void setFirstVertexAttributeTarget(unsigned int i){ _minAttribIndex=i;}
unsigned int getFirstVertexAttributeTarget()const { return _minAttribIndex;}
void setFirstVertexAttributeTarget(unsigned int i) { _minAttribIndex=i; }
unsigned int getFirstVertexAttributeTarget()const { return _minAttribIndex; }
void setShader(osg::Shader* shader) { _shader = shader; }
const osg::Shader* getShader() const { return _shader.get(); }
osg::Shader* getShader() { return _shader.get(); }
osg::Vec4Array* getVertexAttrib(unsigned int index);
unsigned int getNumVertexAttrib() const {return _boneWeightAttribArrays.size();}
unsigned int getNumVertexAttrib() const { return _boneWeightAttribArrays.size(); }
const unsigned int &getNumBonesPerVertex() const{ return _bonesPerVertex; }
const unsigned int &getNumBonesPerVertex() const { return _bonesPerVertex; }
const unsigned int &getNumVertexes() const { return _nbVertices; }
const BoneNamePaletteIndex& getBoneNameToPalette(){ return _boneNameToPalette; }
const BoneNamePaletteIndex& getBoneNameToPalette() { return _boneNameToPalette; }
const BonePalette& getBonePalette() { return _bonePalette; }
osg::Uniform* getMatrixPaletteUniform() { return _uniformMatrixPalette.get(); }
@ -84,7 +84,7 @@ namespace osgAnimation
bool _needInit;
unsigned int _minAttribIndex;
bool buildPalette(const BoneMap& boneMap ,const RigGeometry& rig);
bool buildPalette(const BoneMap& boneMap,const RigGeometry& rig);
//on first update
virtual bool init(RigGeometry& );

View File

@ -44,20 +44,20 @@ namespace osgAnimation
class BonePtrWeight: LocalBoneIDWeight
{
public:
BonePtrWeight(unsigned int id,float weight, Bone*bone=0 ): LocalBoneIDWeight(id,weight), _boneptr(bone){}
BonePtrWeight(const BonePtrWeight &bw2): LocalBoneIDWeight(bw2.getBoneID(),bw2.getWeight()), _boneptr(bw2._boneptr.get()){}
inline const float & getWeight() const {return second;}
inline void setWeight(float b) {second=b;}
inline const unsigned int & getBoneID() const {return first;}
inline void setBoneID(unsigned int b) {first=b;}
inline bool operator<(const BonePtrWeight &b1) const{
if (second > b1.second)return true;
if (second < b1.second)return false;
BonePtrWeight(unsigned int id,float weight, Bone*bone=0 ): LocalBoneIDWeight(id,weight), _boneptr(bone) {}
BonePtrWeight(const BonePtrWeight &bw2): LocalBoneIDWeight(bw2.getBoneID(),bw2.getWeight()), _boneptr(bw2._boneptr.get()) {}
inline const float & getWeight() const { return second; }
inline void setWeight(float b) { second=b; }
inline const unsigned int & getBoneID() const { return first; }
inline void setBoneID(unsigned int b) { first=b; }
inline bool operator< (const BonePtrWeight &b1) const {
if (second > b1.second) return true;
if (second < b1.second) return false;
return (first > b1.first);
}
///set Bone pointer
inline const Bone * getBonePtr() const {return _boneptr.get();}
inline void setBonePtr(Bone*b){_boneptr=b;}
inline const Bone * getBonePtr() const { return _boneptr.get(); }
inline void setBonePtr(Bone*b) { _boneptr=b; }
protected:
osg::observer_ptr< Bone > _boneptr;
};
@ -110,7 +110,7 @@ namespace osgAnimation
}
resetMatrix();
for(BonePtrWeightList::iterator bwit=_boneweights.begin();bwit!=_boneweights.end();++bwit )
for(BonePtrWeightList::iterator bwit=_boneweights.begin(); bwit!=_boneweights.end(); ++bwit )
{
const Bone* bone = bwit->getBonePtr();
if (!bone)
@ -125,7 +125,7 @@ namespace osgAnimation
}
}
void normalize();
inline const osg::Matrix& getMatrix() const { return _result;}
inline const osg::Matrix& getMatrix() const { return _result; }
protected:
BonePtrWeightList _boneweights;
IndexList _vertexes;

View File

@ -41,15 +41,14 @@ namespace osgAnimation
class OSGANIMATION_EXPORT VertexInfluence : public IndexWeightList
{
public:
const std::string& getName() const { return _name;}
void setName(const std::string& name) { _name = name;}
const std::string& getName() const { return _name; }
void setName(const std::string& name) { _name = name; }
protected:
// the name is the bone to link to
std::string _name;
};
class VertexInfluenceMap : public std::map<std::string, VertexInfluence> , public osg::Object
class VertexInfluenceMap : public std::map<std::string, VertexInfluence>, public osg::Object
{
public:
META_Object(osgAnimation, VertexInfluenceMap);
@ -57,8 +56,8 @@ namespace osgAnimation
VertexInfluenceMap() {}
VertexInfluenceMap(const osgAnimation::VertexInfluenceMap& org, const osg::CopyOp& copyop):
std::map<std::string, VertexInfluence>(org),
osg::Object(org, copyop)
{}
osg::Object(org, copyop) {}
///normalize per vertex weights given numvert of the attached mesh
void normalize(unsigned int numvert);
@ -72,7 +71,7 @@ namespace osgAnimation
class VertexGroup: public std::pair<BoneWeightList, IndexList>
{
public:
inline const BoneWeightList& getBoneWeights()const { return first; }
inline const BoneWeightList& getBoneWeights() const { return first; }
inline void setBoneWeights( BoneWeightList& o ) { first=o; }
inline IndexList& vertIDs() { return second; }
};
@ -83,7 +82,6 @@ namespace osgAnimation
//Experimental removal of unexpressed bone from the skeleton
void removeUnexpressedBones(Skeleton &skel) const;
};
}
#endif