Hello Michael, On 11/15/2011 01:07 PM, Michael Raab wrote:
3. calling calcVertexNormals(geo, angle) first, then calcVertexNormal(geo), then calcVertexNormals(geo, angle) again and so on also increases the indices size
calcVertexNormals(geo, angle) now looks for an index that does not have a mapping (getIndexMapping(i) == 0) and reuses that instead of always adding a new index. Patch attached. The calcVertexNormals(geo) version could be changed to remove these unused indices, but it otherwise tries to go out of its way to minimize changes to (shared) properties [1], so that did not seem like a good fit.
Cheers, Carsten[1] I don't know why it was written that way and why other functions do not pay attention to shared properties. IMHO the geo functions are complicated enough, they could perhaps warn if they encounter shared properties, but should otherwise assume the caller knows what they are doing.
Index: Source/System/NodeCores/Drawables/Geometry/OSGGeoFunctions.cpp =================================================================== RCS file: /cvsroot/opensg/OpenSG/Source/System/NodeCores/Drawables/Geometry/OSGGeoFunctions.cpp,v retrieving revision 1.76 diff -u -p -r1.76 OSGGeoFunctions.cpp --- Source/System/NodeCores/Drawables/Geometry/OSGGeoFunctions.cpp 16 Nov 2011 15:06:36 -0000 1.76 +++ Source/System/NodeCores/Drawables/Geometry/OSGGeoFunctions.cpp 16 Nov 2011 17:31:13 -0000 @@ -442,18 +442,20 @@ OSG_SYSTEMLIB_DLLMAPPING void OSG::calcV return; } - UInt32 nind = ip->size() / (im.size() ? im.size() : 1); - int imsize = 0; + UInt32 oldIMSize = im.size(); + UInt32 nind = ip->size() / (oldIMSize ? oldIMSize : 1); + if(ni < 0 || im[ni] != Geometry::MapNormal) { // normals need their own index if(ni >= 0) { im[ni] = im[ni] &~Geometry::MapNormal; + ni = -1; } // need to be multi-indexed? - if(im.size() == 0) + if(oldIMSize == 0) { UInt32 map = Geometry::MapPosition; @@ -464,40 +466,55 @@ OSG_SYSTEMLIB_DLLMAPPING void OSG::calcV map |= Geometry::MapColor; im.push_back(map); + oldIMSize = 1; // there was an implicit mapping + } + + for(UInt32 i = 0; i < oldIMSize; ++i) + { + if(im[i] == 0) + { + // unused index? + ni = i; + im[ni] |= Geometry::MapNormal; + break; + } } - ni = im.size(); - im.push_back(Geometry::MapNormal); + if(ni < 0) + { + ni = im.size(); + im.push_back(Geometry::MapNormal); + } // add an entry to the indices for the normals - imsize = im.size(); + UInt32 newIMSize = im.size(); beginEditCP(ip); - ip->resize(nind * imsize); + ip->resize(nind * newIMSize); + // move indices to make room for new normal index for(UInt32 i = nind - 1; i > 0; --i) { - for(Int16 j = imsize - 2; j >= 0; --j) + for(Int16 j = oldIMSize - 1; j >= 0; --j) { - UInt32 val; - ip->getValue(val, i * (imsize - 1) + j); - ip->setValue(val, i * imsize + j); + UInt32 val; + ip->getValue(val, (i * oldIMSize) + j); + ip->setValue(val, (i * newIMSize) + j); } - ip->setValue(i, i * imsize + imsize - 1); + ip->setValue(i, (i * newIMSize) + newIMSize - 1); } - ip->setValue(0, imsize - 1); + ip->setValue(0, newIMSize - 1); endEditCP(ip); } else // set the normal indices { - imsize = im.size(); + UInt32 imsize = im.size(); beginEditCP(ip); for(UInt32 i = 0; i < nind; ++i) { ip->setValue(i, i * imsize + ni); } - endEditCP(ip); }
------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d
_______________________________________________ Opensg-users mailing list Opensg-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensg-users