Fixes gles coverity defects
This commit is contained in:
parent
ab69edb506
commit
6fd972fa42
@ -1,4 +1,4 @@
|
|||||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) Cedric Pinson
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) Sketchfab
|
||||||
*
|
*
|
||||||
* This application is open source and may be redistributed and/or modified
|
* This application is open source and may be redistributed and/or modified
|
||||||
* freely and without restriction, both in commercial and non commercial
|
* freely and without restriction, both in commercial and non commercial
|
||||||
@ -36,90 +36,6 @@ public:
|
|||||||
typedef std::vector<osgAnimation::RigGeometry*> RigGeometryList;
|
typedef std::vector<osgAnimation::RigGeometry*> RigGeometryList;
|
||||||
|
|
||||||
|
|
||||||
osg::Geometry* createBox(const osg::BoundingBox &bb, const osg::Matrix &transform,
|
|
||||||
float ratio=1.0, osg::Vec4 color=osg::Vec4(1.0f, 0.0f, 0.0f, 1.0f)) {
|
|
||||||
osg::Geometry *cube = new osg::Geometry;
|
|
||||||
|
|
||||||
osg::Vec3 center = bb.center();
|
|
||||||
double halfLenghtX = (bb._max.x() - bb._min.x()) * 0.50;
|
|
||||||
double halfLenghtY = (bb._max.y() - bb._min.y()) * 0.50;
|
|
||||||
double halfLenghtZ = (bb._max.z() - bb._min.z()) * 0.50;
|
|
||||||
|
|
||||||
halfLenghtX *= ratio;
|
|
||||||
halfLenghtY *= ratio;
|
|
||||||
halfLenghtZ *= ratio;
|
|
||||||
|
|
||||||
osg::Vec3Array *cubeVertices = new osg::Vec3Array;
|
|
||||||
cubeVertices->push_back(osg::Vec3(center.x() - halfLenghtX, center.y() + halfLenghtY, center.z() + halfLenghtZ) * transform);
|
|
||||||
cubeVertices->push_back(osg::Vec3(center.x() - halfLenghtX, center.y() + halfLenghtY, center.z() - halfLenghtZ) * transform);
|
|
||||||
cubeVertices->push_back(osg::Vec3(center.x() - halfLenghtX, center.y() - halfLenghtY, center.z() - halfLenghtZ) * transform);
|
|
||||||
cubeVertices->push_back(osg::Vec3(center.x() - halfLenghtX, center.y() - halfLenghtY, center.z() + halfLenghtZ) * transform);
|
|
||||||
|
|
||||||
cubeVertices->push_back(osg::Vec3(center.x() + halfLenghtX, center.y() + halfLenghtY, center.z() + halfLenghtZ) * transform);
|
|
||||||
cubeVertices->push_back(osg::Vec3(center.x() + halfLenghtX, center.y() + halfLenghtY, center.z() - halfLenghtZ) * transform);
|
|
||||||
cubeVertices->push_back(osg::Vec3(center.x() + halfLenghtX, center.y() - halfLenghtY, center.z() - halfLenghtZ) * transform);
|
|
||||||
cubeVertices->push_back(osg::Vec3(center.x() + halfLenghtX, center.y() - halfLenghtY, center.z() + halfLenghtZ) * transform);
|
|
||||||
|
|
||||||
cube->setVertexArray(cubeVertices);
|
|
||||||
|
|
||||||
osg::DrawElementsUInt* up = new osg::DrawElementsUInt(osg::PrimitiveSet::QUADS, 0);
|
|
||||||
up->push_back(4);
|
|
||||||
up->push_back(5);
|
|
||||||
up->push_back(1);
|
|
||||||
up->push_back(0);
|
|
||||||
cube->addPrimitiveSet(up);
|
|
||||||
|
|
||||||
osg::DrawElementsUInt* down = new osg::DrawElementsUInt(osg::PrimitiveSet::QUADS, 0);
|
|
||||||
down->push_back(2);
|
|
||||||
down->push_back(6);
|
|
||||||
down->push_back(7);
|
|
||||||
down->push_back(3);
|
|
||||||
cube->addPrimitiveSet(down);
|
|
||||||
|
|
||||||
osg::DrawElementsUInt* left = new osg::DrawElementsUInt(osg::PrimitiveSet::QUADS, 0);
|
|
||||||
left->push_back(2);
|
|
||||||
left->push_back(3);
|
|
||||||
left->push_back(0);
|
|
||||||
left->push_back(1);
|
|
||||||
cube->addPrimitiveSet(left);
|
|
||||||
|
|
||||||
osg::DrawElementsUInt* right = new osg::DrawElementsUInt(osg::PrimitiveSet::QUADS, 0);
|
|
||||||
right->push_back(7);
|
|
||||||
right->push_back(6);
|
|
||||||
right->push_back(5);
|
|
||||||
right->push_back(4);
|
|
||||||
cube->addPrimitiveSet(right);
|
|
||||||
|
|
||||||
osg::DrawElementsUInt* front = new osg::DrawElementsUInt(osg::PrimitiveSet::QUADS, 0);
|
|
||||||
front->push_back(3);
|
|
||||||
front->push_back(7);
|
|
||||||
front->push_back(4);
|
|
||||||
front->push_back(0);
|
|
||||||
cube->addPrimitiveSet(front);
|
|
||||||
|
|
||||||
osg::DrawElementsUInt* back = new osg::DrawElementsUInt(osg::PrimitiveSet::QUADS, 0);
|
|
||||||
back->push_back(6);
|
|
||||||
back->push_back(2);
|
|
||||||
back->push_back(1);
|
|
||||||
back->push_back(5);
|
|
||||||
cube->addPrimitiveSet(back);
|
|
||||||
|
|
||||||
osg::Vec4Array* colors = new osg::Vec4Array;
|
|
||||||
colors->push_back(color);
|
|
||||||
colors->push_back(color);
|
|
||||||
colors->push_back(color);
|
|
||||||
colors->push_back(color);
|
|
||||||
colors->push_back(color);
|
|
||||||
colors->push_back(color);
|
|
||||||
colors->push_back(color);
|
|
||||||
colors->push_back(color);
|
|
||||||
|
|
||||||
cube->setColorArray(colors);
|
|
||||||
cube->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
|
|
||||||
|
|
||||||
return cube;
|
|
||||||
}
|
|
||||||
|
|
||||||
ComputeAABBOnBoneVisitor(bool createGeometry):
|
ComputeAABBOnBoneVisitor(bool createGeometry):
|
||||||
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
|
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
|
||||||
_root(0),
|
_root(0),
|
||||||
@ -149,59 +65,28 @@ public:
|
|||||||
_rigGeometries.push_back(&rig);
|
_rigGeometries.push_back(&rig);
|
||||||
}
|
}
|
||||||
|
|
||||||
void serializeBoundingBox(const osg::BoundingBox &bb, const osg::Matrix &transform, osgAnimation::Bone &b, float ratio = 1.0) {
|
|
||||||
osg::Vec3 center = bb.center();
|
|
||||||
double halfLenghtX = (bb._max.x() - bb._min.x()) * 0.50;
|
|
||||||
double halfLenghtY = (bb._max.y() - bb._min.y()) * 0.50;
|
|
||||||
double halfLenghtZ = (bb._max.z() - bb._min.z()) * 0.50;
|
|
||||||
|
|
||||||
halfLenghtX *= ratio;
|
|
||||||
halfLenghtY *= ratio;
|
|
||||||
halfLenghtZ *= ratio;
|
|
||||||
|
|
||||||
osg::BoundingBox serializedBB;
|
|
||||||
|
|
||||||
serializedBB.expandBy(osg::Vec3(center.x() - halfLenghtX, center.y() + halfLenghtY, center.z() + halfLenghtZ) * transform);
|
|
||||||
serializedBB.expandBy(osg::Vec3(center.x() - halfLenghtX, center.y() + halfLenghtY, center.z() - halfLenghtZ) * transform);
|
|
||||||
serializedBB.expandBy(osg::Vec3(center.x() - halfLenghtX, center.y() - halfLenghtY, center.z() - halfLenghtZ) * transform);
|
|
||||||
serializedBB.expandBy(osg::Vec3(center.x() - halfLenghtX, center.y() - halfLenghtY, center.z() + halfLenghtZ) * transform);
|
|
||||||
serializedBB.expandBy(osg::Vec3(center.x() + halfLenghtX, center.y() + halfLenghtY, center.z() + halfLenghtZ) * transform);
|
|
||||||
serializedBB.expandBy(osg::Vec3(center.x() + halfLenghtX, center.y() + halfLenghtY, center.z() - halfLenghtZ) * transform);
|
|
||||||
serializedBB.expandBy(osg::Vec3(center.x() + halfLenghtX, center.y() - halfLenghtY, center.z() - halfLenghtZ) * transform);
|
|
||||||
serializedBB.expandBy(osg::Vec3(center.x() + halfLenghtX, center.y() - halfLenghtY, center.z() + halfLenghtZ) * transform);
|
|
||||||
|
|
||||||
b.setUserValue("AABBonBone_min", serializedBB._min);
|
|
||||||
b.setUserValue("AABBonBone_max", serializedBB._max);
|
|
||||||
}
|
|
||||||
|
|
||||||
void computeBoundingBoxOnBones() {
|
void computeBoundingBoxOnBones() {
|
||||||
//Perform Updates
|
//Perform Updates
|
||||||
|
updateBones();
|
||||||
//Update Bones
|
updateRigGeometries();
|
||||||
osgUtil::UpdateVisitor up;
|
|
||||||
_root->accept(up);
|
|
||||||
|
|
||||||
//Update rigGeometries
|
|
||||||
for (unsigned int i = 0, size = _rigGeometries.size(); i < size; i++) {
|
|
||||||
osgAnimation::RigGeometry * rig = _rigGeometries.at(i);
|
|
||||||
osg::Drawable::UpdateCallback * up = dynamic_cast<osg::Drawable::UpdateCallback*>(rig->getUpdateCallback());
|
|
||||||
if(up) up->update(0, rig);
|
|
||||||
}
|
|
||||||
|
|
||||||
//We have our T pose, we can compute an AABB for each bone
|
//We have our T pose, we can compute an AABB for each bone
|
||||||
for (BoneList::iterator bone = _bones.begin(); bone != _bones.end(); ++ bone) {
|
for (BoneList::iterator bone = _bones.begin(); bone != _bones.end(); ++ bone) {
|
||||||
osg::BoundingBox bb;
|
osg::BoundingBox bb;
|
||||||
//For each geometry
|
//For each geometry
|
||||||
for (RigGeometryList::iterator rigGeometry = _rigGeometries.begin(); rigGeometry != _rigGeometries.end(); ++ rigGeometry) {
|
for (RigGeometryList::iterator iterator = _rigGeometries.begin(); iterator != _rigGeometries.end(); ++ iterator) {
|
||||||
osg::Matrix mtxLocalToSkl = (*rigGeometry)->getWorldMatrices(_root).at(0);
|
osgAnimation::RigGeometry* rigGeometry = *iterator;
|
||||||
|
if(!rigGeometry) continue;
|
||||||
|
|
||||||
|
osg::Matrix mtxLocalToSkl = rigGeometry->getWorldMatrices(_root).at(0);
|
||||||
|
|
||||||
//For each Vertex influence
|
//For each Vertex influence
|
||||||
osgAnimation::VertexInfluenceMap * infMap = (*rigGeometry)->getInfluenceMap();
|
osgAnimation::VertexInfluenceMap * infMap = rigGeometry->getInfluenceMap();
|
||||||
osgAnimation::VertexInfluenceMap::iterator itMap = infMap->find((*bone)->getName());
|
osgAnimation::VertexInfluenceMap::iterator itMap = infMap->find((*bone)->getName());
|
||||||
if(itMap == infMap->end()) continue;
|
if(itMap == infMap->end()) continue;
|
||||||
|
|
||||||
osgAnimation::VertexInfluence vxtInf = (*itMap).second;
|
osgAnimation::VertexInfluence vxtInf = (*itMap).second;
|
||||||
osg::Vec3Array *vertices = dynamic_cast<osg::Vec3Array*>((*rigGeometry)->getVertexArray());
|
osg::Vec3Array *vertices = dynamic_cast<osg::Vec3Array*>(rigGeometry->getVertexArray());
|
||||||
|
|
||||||
//Expand the boundingBox with each vertex
|
//Expand the boundingBox with each vertex
|
||||||
for(unsigned int j = 0; j < vxtInf.size(); j++) {
|
for(unsigned int j = 0; j < vxtInf.size(); j++) {
|
||||||
@ -230,14 +115,154 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Clear geometries
|
//Clear geometries
|
||||||
for (RigGeometryList::iterator rigGeometry = _rigGeometries.begin(); rigGeometry != _rigGeometries.end(); ++ rigGeometry) {
|
for (RigGeometryList::iterator iterator = _rigGeometries.begin(); iterator != _rigGeometries.end(); ++ iterator) {
|
||||||
(*rigGeometry)->copyFrom(*(*rigGeometry)->getSourceGeometry());
|
osgAnimation::RigGeometry* rigGeometry = *iterator;
|
||||||
(*rigGeometry)->setRigTransformImplementation(0);
|
if(rigGeometry) {
|
||||||
|
rigGeometry->copyFrom(*rigGeometry->getSourceGeometry());
|
||||||
|
rigGeometry->setRigTransformImplementation(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<osgAnimation::Bone*> _bones;
|
protected:
|
||||||
std::vector<osgAnimation::RigGeometry*> _rigGeometries;
|
osg::Geometry* createBox(const osg::BoundingBox &bb, const osg::Matrix &transform,
|
||||||
|
float ratio=1.0, osg::Vec4 color=osg::Vec4(1.0f, 0.0f, 0.0f, 1.0f)) {
|
||||||
|
osg::Geometry *cube = new osg::Geometry;
|
||||||
|
|
||||||
|
osg::Vec3 center = bb.center();
|
||||||
|
double halfLenghtX = (bb._max.x() - bb._min.x()) * 0.50;
|
||||||
|
double halfLenghtY = (bb._max.y() - bb._min.y()) * 0.50;
|
||||||
|
double halfLenghtZ = (bb._max.z() - bb._min.z()) * 0.50;
|
||||||
|
|
||||||
|
halfLenghtX *= ratio;
|
||||||
|
halfLenghtY *= ratio;
|
||||||
|
halfLenghtZ *= ratio;
|
||||||
|
|
||||||
|
osg::Vec3Array *cubeVertices = new osg::Vec3Array;
|
||||||
|
cubeVertices->push_back(osg::Vec3(center.x() - halfLenghtX, center.y() + halfLenghtY, center.z() + halfLenghtZ) * transform);
|
||||||
|
cubeVertices->push_back(osg::Vec3(center.x() - halfLenghtX, center.y() + halfLenghtY, center.z() - halfLenghtZ) * transform);
|
||||||
|
cubeVertices->push_back(osg::Vec3(center.x() - halfLenghtX, center.y() - halfLenghtY, center.z() - halfLenghtZ) * transform);
|
||||||
|
cubeVertices->push_back(osg::Vec3(center.x() - halfLenghtX, center.y() - halfLenghtY, center.z() + halfLenghtZ) * transform);
|
||||||
|
|
||||||
|
cubeVertices->push_back(osg::Vec3(center.x() + halfLenghtX, center.y() + halfLenghtY, center.z() + halfLenghtZ) * transform);
|
||||||
|
cubeVertices->push_back(osg::Vec3(center.x() + halfLenghtX, center.y() + halfLenghtY, center.z() - halfLenghtZ) * transform);
|
||||||
|
cubeVertices->push_back(osg::Vec3(center.x() + halfLenghtX, center.y() - halfLenghtY, center.z() - halfLenghtZ) * transform);
|
||||||
|
cubeVertices->push_back(osg::Vec3(center.x() + halfLenghtX, center.y() - halfLenghtY, center.z() + halfLenghtZ) * transform);
|
||||||
|
|
||||||
|
cube->setVertexArray(cubeVertices);
|
||||||
|
|
||||||
|
{
|
||||||
|
osg::DrawElementsUInt* up = new osg::DrawElementsUInt(osg::PrimitiveSet::QUADS, 0);
|
||||||
|
up->push_back(4);
|
||||||
|
up->push_back(5);
|
||||||
|
up->push_back(1);
|
||||||
|
up->push_back(0);
|
||||||
|
cube->addPrimitiveSet(up);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
osg::DrawElementsUInt* down = new osg::DrawElementsUInt(osg::PrimitiveSet::QUADS, 0);
|
||||||
|
down->push_back(2);
|
||||||
|
down->push_back(6);
|
||||||
|
down->push_back(7);
|
||||||
|
down->push_back(3);
|
||||||
|
cube->addPrimitiveSet(down);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
osg::DrawElementsUInt* left = new osg::DrawElementsUInt(osg::PrimitiveSet::QUADS, 0);
|
||||||
|
left->push_back(2);
|
||||||
|
left->push_back(3);
|
||||||
|
left->push_back(0);
|
||||||
|
left->push_back(1);
|
||||||
|
cube->addPrimitiveSet(left);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
osg::DrawElementsUInt* right = new osg::DrawElementsUInt(osg::PrimitiveSet::QUADS, 0);
|
||||||
|
right->push_back(7);
|
||||||
|
right->push_back(6);
|
||||||
|
right->push_back(5);
|
||||||
|
right->push_back(4);
|
||||||
|
cube->addPrimitiveSet(right);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
osg::DrawElementsUInt* front = new osg::DrawElementsUInt(osg::PrimitiveSet::QUADS, 0);
|
||||||
|
front->push_back(3);
|
||||||
|
front->push_back(7);
|
||||||
|
front->push_back(4);
|
||||||
|
front->push_back(0);
|
||||||
|
cube->addPrimitiveSet(front);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
osg::DrawElementsUInt* back = new osg::DrawElementsUInt(osg::PrimitiveSet::QUADS, 0);
|
||||||
|
back->push_back(6);
|
||||||
|
back->push_back(2);
|
||||||
|
back->push_back(1);
|
||||||
|
back->push_back(5);
|
||||||
|
cube->addPrimitiveSet(back);
|
||||||
|
}
|
||||||
|
|
||||||
|
osg::Vec4Array* colors = new osg::Vec4Array;
|
||||||
|
colors->push_back(color);
|
||||||
|
colors->push_back(color);
|
||||||
|
colors->push_back(color);
|
||||||
|
colors->push_back(color);
|
||||||
|
colors->push_back(color);
|
||||||
|
colors->push_back(color);
|
||||||
|
colors->push_back(color);
|
||||||
|
colors->push_back(color);
|
||||||
|
|
||||||
|
cube->setColorArray(colors);
|
||||||
|
cube->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||||
|
|
||||||
|
return cube;
|
||||||
|
}
|
||||||
|
|
||||||
|
void serializeBoundingBox(const osg::BoundingBox &bb, const osg::Matrix &transform, osgAnimation::Bone &b, float ratio = 1.0) {
|
||||||
|
osg::Vec3 center = bb.center();
|
||||||
|
double halfLenghtX = (bb._max.x() - bb._min.x()) * 0.50;
|
||||||
|
double halfLenghtY = (bb._max.y() - bb._min.y()) * 0.50;
|
||||||
|
double halfLenghtZ = (bb._max.z() - bb._min.z()) * 0.50;
|
||||||
|
|
||||||
|
halfLenghtX *= ratio;
|
||||||
|
halfLenghtY *= ratio;
|
||||||
|
halfLenghtZ *= ratio;
|
||||||
|
|
||||||
|
osg::BoundingBox serializedBB;
|
||||||
|
|
||||||
|
serializedBB.expandBy(osg::Vec3(center.x() - halfLenghtX, center.y() + halfLenghtY, center.z() + halfLenghtZ) * transform);
|
||||||
|
serializedBB.expandBy(osg::Vec3(center.x() - halfLenghtX, center.y() + halfLenghtY, center.z() - halfLenghtZ) * transform);
|
||||||
|
serializedBB.expandBy(osg::Vec3(center.x() - halfLenghtX, center.y() - halfLenghtY, center.z() - halfLenghtZ) * transform);
|
||||||
|
serializedBB.expandBy(osg::Vec3(center.x() - halfLenghtX, center.y() - halfLenghtY, center.z() + halfLenghtZ) * transform);
|
||||||
|
serializedBB.expandBy(osg::Vec3(center.x() + halfLenghtX, center.y() + halfLenghtY, center.z() + halfLenghtZ) * transform);
|
||||||
|
serializedBB.expandBy(osg::Vec3(center.x() + halfLenghtX, center.y() + halfLenghtY, center.z() - halfLenghtZ) * transform);
|
||||||
|
serializedBB.expandBy(osg::Vec3(center.x() + halfLenghtX, center.y() - halfLenghtY, center.z() - halfLenghtZ) * transform);
|
||||||
|
serializedBB.expandBy(osg::Vec3(center.x() + halfLenghtX, center.y() - halfLenghtY, center.z() + halfLenghtZ) * transform);
|
||||||
|
|
||||||
|
b.setUserValue("AABBonBone_min", serializedBB._min);
|
||||||
|
b.setUserValue("AABBonBone_max", serializedBB._max);
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateBones() {
|
||||||
|
osgUtil::UpdateVisitor update;
|
||||||
|
_root->accept(update);
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateRigGeometries() {
|
||||||
|
for (unsigned int i = 0, size = _rigGeometries.size(); i < size; i++) {
|
||||||
|
osgAnimation::RigGeometry * rig = _rigGeometries.at(i);
|
||||||
|
osg::Drawable::UpdateCallback * callback = dynamic_cast<osg::Drawable::UpdateCallback*>(rig->getUpdateCallback());
|
||||||
|
if(callback) {
|
||||||
|
callback->update(0, rig);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BoneList _bones;
|
||||||
|
RigGeometryList _rigGeometries;
|
||||||
osgAnimation::Skeleton *_root;
|
osgAnimation::Skeleton *_root;
|
||||||
bool _createGeometry;
|
bool _createGeometry;
|
||||||
};
|
};
|
||||||
|
@ -65,7 +65,7 @@ public:
|
|||||||
geometry(false)
|
geometry(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void apply(osg::Geometry& object) {
|
void apply(osg::Geometry& /*object*/) {
|
||||||
geometry = true;
|
geometry = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,18 +266,16 @@ public:
|
|||||||
// Replace rig geometries by static geometries if:
|
// Replace rig geometries by static geometries if:
|
||||||
// * empty or inexistant vertex influence map
|
// * empty or inexistant vertex influence map
|
||||||
// * no *strictly* positive influence coefficient
|
// * no *strictly* positive influence coefficient
|
||||||
|
for(RigGeometryList::iterator iterator = _rigGeometries.begin() ; iterator != _rigGeometries.end() ; ) {
|
||||||
RigGeometryList::iterator rigGeometry = _rigGeometries.begin();
|
osg::ref_ptr<osgAnimation::RigGeometry> rigGeometry = *iterator;
|
||||||
while(rigGeometry != _rigGeometries.end()) {
|
if(rigGeometry.valid() && !hasPositiveWeights(rigGeometry->getSourceGeometry())) {
|
||||||
if(rigGeometry->valid()) {
|
OSG_WARN << "Monitor: animation.invalid_riggeometry" << std::endl;
|
||||||
if(!hasPositiveWeights((*rigGeometry)->getSourceGeometry())) {
|
replaceRigGeometryBySource(*rigGeometry.get());
|
||||||
OSG_WARN << "Monitor: animation.invalid_riggeometry" << std::endl;
|
_rigGeometries.erase(iterator);
|
||||||
replaceRigGeometryBySource(*(rigGeometry->get()));
|
}
|
||||||
_rigGeometries.erase(rigGeometry);
|
else {
|
||||||
continue; // skip iterator increment
|
++ iterator;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
++ rigGeometry;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
/* -*-c++-*- */
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) Cedric Pinson */
|
||||||
|
|
||||||
#ifndef GEOMETRY_ARRAY_UTILS_H
|
#ifndef GEOMETRY_ARRAY_UTILS_H
|
||||||
#define GEOMETRY_ARRAY_UTILS_H
|
#define GEOMETRY_ARRAY_UTILS_H
|
||||||
|
|
||||||
@ -98,7 +99,7 @@ struct GeometryArrayList {
|
|||||||
template <class T> bool arrayAppendElement(osg::Array* src, unsigned int index, osg::Array* dst)
|
template <class T> bool arrayAppendElement(osg::Array* src, unsigned int index, osg::Array* dst)
|
||||||
{
|
{
|
||||||
T* array = dynamic_cast<T*>(src);
|
T* array = dynamic_cast<T*>(src);
|
||||||
if (array) {
|
if (array && dst) {
|
||||||
T* arrayDst = dynamic_cast<T*>(dst);
|
T* arrayDst = dynamic_cast<T*>(dst);
|
||||||
arrayDst->push_back((*array)[index]);
|
arrayDst->push_back((*array)[index]);
|
||||||
return true;
|
return true;
|
||||||
@ -140,15 +141,6 @@ struct GeometryArrayList {
|
|||||||
if (arrayAppendElement<osg::Vec4Array>(src, index, dst))
|
if (arrayAppendElement<osg::Vec4Array>(src, index, dst))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (arrayAppendElement<osg::Vec2Array>(src, index, dst))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (arrayAppendElement<osg::Vec3Array>(src, index, dst))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (arrayAppendElement<osg::Vec4Array>(src, index, dst))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (arrayAppendElement<osg::Vec2bArray>(src, index, dst))
|
if (arrayAppendElement<osg::Vec2bArray>(src, index, dst))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -266,15 +258,6 @@ struct GeometryArrayList {
|
|||||||
if (arraySetNumElements<osg::Vec4Array>(array, numElements))
|
if (arraySetNumElements<osg::Vec4Array>(array, numElements))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (arraySetNumElements<osg::Vec2Array>(array, numElements))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (arraySetNumElements<osg::Vec3Array>(array, numElements))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (arraySetNumElements<osg::Vec4Array>(array, numElements))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (arraySetNumElements<osg::Vec2bArray>(array, numElements))
|
if (arraySetNumElements<osg::Vec2bArray>(array, numElements))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) Sketchfab */
|
||||||
|
|
||||||
#ifndef GEOMETRY_INSPECTOR
|
#ifndef GEOMETRY_INSPECTOR
|
||||||
#define GEOMETRY_INSPECTOR
|
#define GEOMETRY_INSPECTOR
|
||||||
|
|
||||||
@ -17,7 +19,8 @@
|
|||||||
|
|
||||||
class GeometryInspector : public GeometryUniqueVisitor {
|
class GeometryInspector : public GeometryUniqueVisitor {
|
||||||
public:
|
public:
|
||||||
void process(osg::Geometry& geometry) {}
|
void process(osg::Geometry& /*geometry*/) {}
|
||||||
|
|
||||||
void process(osgAnimation::RigGeometry& rigGeometry) {
|
void process(osgAnimation::RigGeometry& rigGeometry) {
|
||||||
osgAnimation::MorphGeometry* morph = dynamic_cast<osgAnimation::MorphGeometry*>(rigGeometry.getSourceGeometry());
|
osgAnimation::MorphGeometry* morph = dynamic_cast<osgAnimation::MorphGeometry*>(rigGeometry.getSourceGeometry());
|
||||||
if(morph) {
|
if(morph) {
|
||||||
|
@ -133,7 +133,8 @@ public:
|
|||||||
setTriangleCluster(graph, cache.back(), cluster, clusters, cluster_vertices, remaining_triangles);
|
setTriangleCluster(graph, cache.back(), cluster, clusters, cluster_vertices, remaining_triangles);
|
||||||
|
|
||||||
while(remaining_triangles && cluster_vertices.size() < _maxAllowedIndex) {
|
while(remaining_triangles && cluster_vertices.size() < _maxAllowedIndex) {
|
||||||
unsigned int candidate;
|
unsigned int candidate = std::numeric_limits<unsigned int>::max();
|
||||||
|
|
||||||
for(IndexCache::const_reverse_iterator cached = cache.rbegin() ; cached != cache.rend() ; ++ cached) {
|
for(IndexCache::const_reverse_iterator cached = cache.rbegin() ; cached != cache.rend() ; ++ cached) {
|
||||||
candidate = findCandidate(graph.triangleNeighbors(*cached), clusters);
|
candidate = findCandidate(graph.triangleNeighbors(*cached), clusters);
|
||||||
if(candidate != std::numeric_limits<unsigned int>::max()) break;
|
if(candidate != std::numeric_limits<unsigned int>::max()) break;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) Sketchfab */
|
||||||
|
|
||||||
#ifndef LIMIT_MORPH_TARGET_COUNT_VISITOR
|
#ifndef LIMIT_MORPH_TARGET_COUNT_VISITOR
|
||||||
#define LIMIT_MORPH_TARGET_COUNT_VISITOR
|
#define LIMIT_MORPH_TARGET_COUNT_VISITOR
|
||||||
|
|
||||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) Sketchfab */
|
|
||||||
|
|
||||||
#include "GeometryUniqueVisitor"
|
#include "GeometryUniqueVisitor"
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) Sketchfab */
|
||||||
|
|
||||||
#ifndef GLES_LINE
|
#ifndef GLES_LINE
|
||||||
#define GLES_LINE
|
#define GLES_LINE
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@ public:
|
|||||||
_disableMergeTriStrip(false),
|
_disableMergeTriStrip(false),
|
||||||
_disablePreTransform(false),
|
_disablePreTransform(false),
|
||||||
_disableAnimation(false),
|
_disableAnimation(false),
|
||||||
|
_disableAnimationCleaning(false),
|
||||||
_enableAABBonBone(false),
|
_enableAABBonBone(false),
|
||||||
_triStripCacheSize(16),
|
_triStripCacheSize(16),
|
||||||
_triStripMinSize(2),
|
_triStripMinSize(2),
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) Sketchfab */
|
||||||
|
|
||||||
#ifndef PRIMITIVE_OPERATORS_H
|
#ifndef PRIMITIVE_OPERATORS_H
|
||||||
#define PRIMITIVE_OPERATORS_H
|
#define PRIMITIVE_OPERATORS_H
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) Cedric Pinson
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) Sketchfab
|
||||||
*
|
*
|
||||||
* This application is open source and may be redistributed and/or modified
|
* This application is open source and may be redistributed and/or modified
|
||||||
* freely and without restriction, both in commercial and non commercial
|
* freely and without restriction, both in commercial and non commercial
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) Sketchfab */
|
||||||
|
|
||||||
#ifndef RIG_ATTRIBUTES_VISITOR
|
#ifndef RIG_ATTRIBUTES_VISITOR
|
||||||
#define RIG_ATTRIBUTES_VISITOR
|
#define RIG_ATTRIBUTES_VISITOR
|
||||||
|
|
||||||
@ -31,7 +33,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void process(osg::Geometry& geometry) {
|
void process(osg::Geometry& /*geometry*/) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) Sketchfab */
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <set>
|
#include <set>
|
||||||
@ -197,7 +199,16 @@ protected:
|
|||||||
bool flipped = false;
|
bool flipped = false;
|
||||||
|
|
||||||
osg::Vec3Array* normals = dynamic_cast<osg::Vec3Array*>(_geometry.getNormalArray());
|
osg::Vec3Array* normals = dynamic_cast<osg::Vec3Array*>(_geometry.getNormalArray());
|
||||||
for(unsigned int index = 0 ; index < _geometry.getVertexArray()->getNumElements() ; ++ index) {
|
osg::Vec3Array* positions = dynamic_cast<osg::Vec3Array*>(_geometry.getVertexArray());
|
||||||
|
|
||||||
|
if(!positions || !normals || normals->getNumElements() != positions->getNumElements()) {
|
||||||
|
OSG_WARN << std::endl
|
||||||
|
<< "Warning: [smoothVertexNormals] [[normals]] Geometry '" << _geometry.getName()
|
||||||
|
<< "' has invalid positions/normals";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(unsigned int index = 0 ; index < positions->getNumElements() ; ++ index) {
|
||||||
std::vector<IndexVector> oneRing = _graph->vertexOneRing(_graph->unify(index), _creaseAngle);
|
std::vector<IndexVector> oneRing = _graph->vertexOneRing(_graph->unify(index), _creaseAngle);
|
||||||
osg::Vec3f smoothedNormal(0.f, 0.f, 0.f);
|
osg::Vec3f smoothedNormal(0.f, 0.f, 0.f);
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) Sketchfab */
|
||||||
|
|
||||||
#ifndef STAT_LOGGER
|
#ifndef STAT_LOGGER
|
||||||
#define STAT_LOGGER
|
#define STAT_LOGGER
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) Sketchfab */
|
||||||
|
|
||||||
#ifndef SUB_GEOMETRY
|
#ifndef SUB_GEOMETRY
|
||||||
#define SUB_GEOMETRY
|
#define SUB_GEOMETRY
|
||||||
|
|
||||||
@ -49,11 +51,14 @@ public:
|
|||||||
if(const osgAnimation::MorphGeometry* morphSource = dynamic_cast<const osgAnimation::MorphGeometry*>(&source)) {
|
if(const osgAnimation::MorphGeometry* morphSource = dynamic_cast<const osgAnimation::MorphGeometry*>(&source)) {
|
||||||
osgAnimation::MorphGeometry* morph = dynamic_cast<osgAnimation::MorphGeometry*>(_geometry.get());
|
osgAnimation::MorphGeometry* morph = dynamic_cast<osgAnimation::MorphGeometry*>(_geometry.get());
|
||||||
const osgAnimation::MorphGeometry::MorphTargetList& morphTargetList = morphSource->getMorphTargetList();
|
const osgAnimation::MorphGeometry::MorphTargetList& morphTargetList = morphSource->getMorphTargetList();
|
||||||
for(osgAnimation::MorphGeometry::MorphTargetList::const_iterator targetSource = morphTargetList.begin() ;
|
|
||||||
targetSource != morphTargetList.end() ; ++ targetSource) {
|
osgAnimation::MorphGeometry::MorphTargetList::const_iterator targetSource;
|
||||||
osg::Geometry* target = new osg::Geometry;
|
for(targetSource = morphTargetList.begin() ; targetSource != morphTargetList.end() ; ++ targetSource) {
|
||||||
addSourceBuffers(target, *targetSource->getGeometry());
|
if(targetSource->getGeometry()) {
|
||||||
morph->addMorphTarget(target, targetSource->getWeight());
|
osg::Geometry* target = new osg::Geometry;
|
||||||
|
addSourceBuffers(target, *targetSource->getGeometry());
|
||||||
|
morph->addMorphTarget(target, targetSource->getWeight());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) Sketchfab */
|
||||||
|
|
||||||
#ifndef MESH_GRAPH
|
#ifndef MESH_GRAPH
|
||||||
#define MESH_GRAPH
|
#define MESH_GRAPH
|
||||||
|
|
||||||
@ -171,10 +173,12 @@ public:
|
|||||||
_positions(dynamic_cast<const osg::Vec3Array*>(geometry.getVertexArray())),
|
_positions(dynamic_cast<const osg::Vec3Array*>(geometry.getVertexArray())),
|
||||||
_comparePosition(comparePosition)
|
_comparePosition(comparePosition)
|
||||||
{
|
{
|
||||||
unsigned int nbVertex = _positions->getNumElements();
|
if(_positions) {
|
||||||
_unique.resize(nbVertex, std::numeric_limits<unsigned int>::max());
|
unsigned int nbVertex = _positions->getNumElements();
|
||||||
_vertexTriangles.resize(nbVertex, IndexVector());
|
_unique.resize(nbVertex, std::numeric_limits<unsigned int>::max());
|
||||||
build();
|
_vertexTriangles.resize(nbVertex, IndexVector());
|
||||||
|
build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VertexIterator begin() const {
|
VertexIterator begin() const {
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) Sketchfab */
|
||||||
|
|
||||||
#ifndef GLES_UTIL
|
#ifndef GLES_UTIL
|
||||||
#define GLES_UTIL
|
#define GLES_UTIL
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user