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
|
||||
* freely and without restriction, both in commercial and non commercial
|
||||
@ -36,90 +36,6 @@ public:
|
||||
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):
|
||||
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
|
||||
_root(0),
|
||||
@ -149,59 +65,28 @@ public:
|
||||
_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() {
|
||||
//Perform Updates
|
||||
|
||||
//Update Bones
|
||||
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);
|
||||
}
|
||||
updateBones();
|
||||
updateRigGeometries();
|
||||
|
||||
//We have our T pose, we can compute an AABB for each bone
|
||||
for (BoneList::iterator bone = _bones.begin(); bone != _bones.end(); ++ bone) {
|
||||
osg::BoundingBox bb;
|
||||
//For each geometry
|
||||
for (RigGeometryList::iterator rigGeometry = _rigGeometries.begin(); rigGeometry != _rigGeometries.end(); ++ rigGeometry) {
|
||||
osg::Matrix mtxLocalToSkl = (*rigGeometry)->getWorldMatrices(_root).at(0);
|
||||
for (RigGeometryList::iterator iterator = _rigGeometries.begin(); iterator != _rigGeometries.end(); ++ iterator) {
|
||||
osgAnimation::RigGeometry* rigGeometry = *iterator;
|
||||
if(!rigGeometry) continue;
|
||||
|
||||
osg::Matrix mtxLocalToSkl = rigGeometry->getWorldMatrices(_root).at(0);
|
||||
|
||||
//For each Vertex influence
|
||||
osgAnimation::VertexInfluenceMap * infMap = (*rigGeometry)->getInfluenceMap();
|
||||
osgAnimation::VertexInfluenceMap * infMap = rigGeometry->getInfluenceMap();
|
||||
osgAnimation::VertexInfluenceMap::iterator itMap = infMap->find((*bone)->getName());
|
||||
if(itMap == infMap->end()) continue;
|
||||
|
||||
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
|
||||
for(unsigned int j = 0; j < vxtInf.size(); j++) {
|
||||
@ -230,14 +115,154 @@ public:
|
||||
}
|
||||
|
||||
//Clear geometries
|
||||
for (RigGeometryList::iterator rigGeometry = _rigGeometries.begin(); rigGeometry != _rigGeometries.end(); ++ rigGeometry) {
|
||||
(*rigGeometry)->copyFrom(*(*rigGeometry)->getSourceGeometry());
|
||||
(*rigGeometry)->setRigTransformImplementation(0);
|
||||
for (RigGeometryList::iterator iterator = _rigGeometries.begin(); iterator != _rigGeometries.end(); ++ iterator) {
|
||||
osgAnimation::RigGeometry* rigGeometry = *iterator;
|
||||
if(rigGeometry) {
|
||||
rigGeometry->copyFrom(*rigGeometry->getSourceGeometry());
|
||||
rigGeometry->setRigTransformImplementation(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<osgAnimation::Bone*> _bones;
|
||||
std::vector<osgAnimation::RigGeometry*> _rigGeometries;
|
||||
protected:
|
||||
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;
|
||||
bool _createGeometry;
|
||||
};
|
||||
|
@ -65,7 +65,7 @@ public:
|
||||
geometry(false)
|
||||
{}
|
||||
|
||||
void apply(osg::Geometry& object) {
|
||||
void apply(osg::Geometry& /*object*/) {
|
||||
geometry = true;
|
||||
}
|
||||
|
||||
@ -266,18 +266,16 @@ public:
|
||||
// Replace rig geometries by static geometries if:
|
||||
// * empty or inexistant vertex influence map
|
||||
// * no *strictly* positive influence coefficient
|
||||
|
||||
RigGeometryList::iterator rigGeometry = _rigGeometries.begin();
|
||||
while(rigGeometry != _rigGeometries.end()) {
|
||||
if(rigGeometry->valid()) {
|
||||
if(!hasPositiveWeights((*rigGeometry)->getSourceGeometry())) {
|
||||
for(RigGeometryList::iterator iterator = _rigGeometries.begin() ; iterator != _rigGeometries.end() ; ) {
|
||||
osg::ref_ptr<osgAnimation::RigGeometry> rigGeometry = *iterator;
|
||||
if(rigGeometry.valid() && !hasPositiveWeights(rigGeometry->getSourceGeometry())) {
|
||||
OSG_WARN << "Monitor: animation.invalid_riggeometry" << std::endl;
|
||||
replaceRigGeometryBySource(*(rigGeometry->get()));
|
||||
_rigGeometries.erase(rigGeometry);
|
||||
continue; // skip iterator increment
|
||||
replaceRigGeometryBySource(*rigGeometry.get());
|
||||
_rigGeometries.erase(iterator);
|
||||
}
|
||||
else {
|
||||
++ iterator;
|
||||
}
|
||||
++ rigGeometry;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* -*-c++-*- */
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) Cedric Pinson */
|
||||
|
||||
#ifndef 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)
|
||||
{
|
||||
T* array = dynamic_cast<T*>(src);
|
||||
if (array) {
|
||||
if (array && dst) {
|
||||
T* arrayDst = dynamic_cast<T*>(dst);
|
||||
arrayDst->push_back((*array)[index]);
|
||||
return true;
|
||||
@ -140,15 +141,6 @@ struct GeometryArrayList {
|
||||
if (arrayAppendElement<osg::Vec4Array>(src, index, dst))
|
||||
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))
|
||||
return;
|
||||
|
||||
@ -266,15 +258,6 @@ struct GeometryArrayList {
|
||||
if (arraySetNumElements<osg::Vec4Array>(array, numElements))
|
||||
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))
|
||||
return;
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) Sketchfab */
|
||||
|
||||
#ifndef GEOMETRY_INSPECTOR
|
||||
#define GEOMETRY_INSPECTOR
|
||||
|
||||
@ -17,7 +19,8 @@
|
||||
|
||||
class GeometryInspector : public GeometryUniqueVisitor {
|
||||
public:
|
||||
void process(osg::Geometry& geometry) {}
|
||||
void process(osg::Geometry& /*geometry*/) {}
|
||||
|
||||
void process(osgAnimation::RigGeometry& rigGeometry) {
|
||||
osgAnimation::MorphGeometry* morph = dynamic_cast<osgAnimation::MorphGeometry*>(rigGeometry.getSourceGeometry());
|
||||
if(morph) {
|
||||
|
@ -133,7 +133,8 @@ public:
|
||||
setTriangleCluster(graph, cache.back(), cluster, clusters, cluster_vertices, remaining_triangles);
|
||||
|
||||
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) {
|
||||
candidate = findCandidate(graph.triangleNeighbors(*cached), clusters);
|
||||
if(candidate != std::numeric_limits<unsigned int>::max()) break;
|
||||
|
@ -1,8 +1,8 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) Sketchfab */
|
||||
|
||||
#ifndef LIMIT_MORPH_TARGET_COUNT_VISITOR
|
||||
#define LIMIT_MORPH_TARGET_COUNT_VISITOR
|
||||
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) Sketchfab */
|
||||
|
||||
#include "GeometryUniqueVisitor"
|
||||
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) Sketchfab */
|
||||
|
||||
#ifndef GLES_LINE
|
||||
#define GLES_LINE
|
||||
|
||||
|
@ -49,6 +49,7 @@ public:
|
||||
_disableMergeTriStrip(false),
|
||||
_disablePreTransform(false),
|
||||
_disableAnimation(false),
|
||||
_disableAnimationCleaning(false),
|
||||
_enableAABBonBone(false),
|
||||
_triStripCacheSize(16),
|
||||
_triStripMinSize(2),
|
||||
|
@ -1,3 +1,5 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) Sketchfab */
|
||||
|
||||
#ifndef 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
|
||||
* freely and without restriction, both in commercial and non commercial
|
||||
|
@ -1,3 +1,5 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) Sketchfab */
|
||||
|
||||
#ifndef RIG_ATTRIBUTES_VISITOR
|
||||
#define RIG_ATTRIBUTES_VISITOR
|
||||
|
||||
@ -31,7 +33,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void process(osg::Geometry& geometry) {
|
||||
void process(osg::Geometry& /*geometry*/) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) Sketchfab */
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <set>
|
||||
@ -197,7 +199,16 @@ protected:
|
||||
bool flipped = false;
|
||||
|
||||
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);
|
||||
osg::Vec3f smoothedNormal(0.f, 0.f, 0.f);
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) Sketchfab */
|
||||
|
||||
#ifndef STAT_LOGGER
|
||||
#define STAT_LOGGER
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) Sketchfab */
|
||||
|
||||
#ifndef SUB_GEOMETRY
|
||||
#define SUB_GEOMETRY
|
||||
|
||||
@ -49,13 +51,16 @@ public:
|
||||
if(const osgAnimation::MorphGeometry* morphSource = dynamic_cast<const osgAnimation::MorphGeometry*>(&source)) {
|
||||
osgAnimation::MorphGeometry* morph = dynamic_cast<osgAnimation::MorphGeometry*>(_geometry.get());
|
||||
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;
|
||||
for(targetSource = morphTargetList.begin() ; targetSource != morphTargetList.end() ; ++ targetSource) {
|
||||
if(targetSource->getGeometry()) {
|
||||
osg::Geometry* target = new osg::Geometry;
|
||||
addSourceBuffers(target, *targetSource->getGeometry());
|
||||
morph->addMorphTarget(target, targetSource->getWeight());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// remap primitives indices by decreasing ordering (triangles > lines > wireframe > points)
|
||||
for(unsigned int i = 0 ; i < triangles.size() ; i += 3) {
|
||||
|
@ -1,3 +1,5 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) Sketchfab */
|
||||
|
||||
#ifndef MESH_GRAPH
|
||||
#define MESH_GRAPH
|
||||
|
||||
@ -171,11 +173,13 @@ public:
|
||||
_positions(dynamic_cast<const osg::Vec3Array*>(geometry.getVertexArray())),
|
||||
_comparePosition(comparePosition)
|
||||
{
|
||||
if(_positions) {
|
||||
unsigned int nbVertex = _positions->getNumElements();
|
||||
_unique.resize(nbVertex, std::numeric_limits<unsigned int>::max());
|
||||
_vertexTriangles.resize(nbVertex, IndexVector());
|
||||
build();
|
||||
}
|
||||
}
|
||||
|
||||
VertexIterator begin() const {
|
||||
return _vertices.begin();
|
||||
|
@ -1,3 +1,5 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) Sketchfab */
|
||||
|
||||
#ifndef GLES_UTIL
|
||||
#define GLES_UTIL
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user