Hi Anders,

I've recreated the problem here and applied a fix that is a little
different than your suggestion, my change was done to make things a
bit more readable:


Index: ShapeDrawable.cpp
===================================================================
--- ShapeDrawable.cpp   (revision 13586)
+++ ShapeDrawable.cpp   (working copy)
@@ -826,7 +826,10 @@
             numRows = MIN_NUM_ROWS;
     }

+    // if numRows is odd the top and bottom halves of sphere won't
match, so bump up to the next event numRows
+    if ((numRows%2)!=0) ++numRows;

+
     // capsule cylindrical body
     if (createBody)
         drawCylinderBody(numSegments, capsule.getRadius(),
capsule.getHeight());
@@ -1818,6 +1821,9 @@
             numSegments = MIN_NUM_SEGMENTS;
     }

+    // if numRows is odd the top and bottom halves of sphere won't
match, so bump up to the next event numRows
+    if ((numRows%2)!=0) ++numRows;
+
     // capsule body
     if (createBody)
         createCylinderBody(numSegments, capsule.getRadius(),
capsule.getHeight(), matrix);


Cheers,
Robert.

On 21 June 2013 14:44, Robert Osfield <[email protected]> wrote:
> Hi Anders,
>
> I just had a look at ShapeDrawable.cpp at the suggest line of 828 but
> it really isn't clear whether this is the appropriate place.  This is
> the reason why I always ask for complete files rather than just copy
> and paste in emails as these can be so ambiguous.  Could you send me
> the whole modified file, thanks,
>
> Robert.
>
> On 25 March 2013 11:07, Anders Backman <[email protected]> wrote:
>> A long time ago (May 2012) I reported an issue with the rendering of
>> Capsules (email below). I got sidetracked and did not follow it up to
>> realize a fix. However a fix for this can be found below. Add this to line
>> ~828 after the numRows have been calculated and before drawHalfSphere is
>> called.
>>
>> // Make sure that numRows is even so that the halfSpheres have
>> // equal size and align with the capsule body
>> numRows += 1;
>> numRows &= ~((unsigned int)1);
>>
>>
>> Cheers,
>>
>> Anders
>>
>>
>>
>>
>> On 24 May 2012 09:06, Anders Backman <andersb at cs.umu.se> wrote:
>>> Hi all.
>>>
>>> Found a bug in ShapeDrawable.cpp
>>> This is verified in 3.0.1 and 2.9.11:
>>>
>>> Bug in OpenSceneGraph/src/osg/ShapeDrawable.cpp,  void
>>> DrawShapeVisitor::apply(const Capsule& capsule) :
>>>
>>> If numRows becomes odd, the capsule top and bottom parts created with two
>>> calls to drawHalfSphere will not
>>> align with the cylinder body created with drawCylinderBody.
>>>
>>> Easiest seen if with large radius and few rows.
>>> Example capsule parameters:
>>> height 8.4
>>> radius 5
>>>
>>> Set detail ratio hints to 0.35 so numRows becomes 7. Misalign.
>>> Change hints to 0.4, numRows becomes 8 and capsule part aligns.
>>>
>>> Fix:
>>> If numRows is odd, add one before calling drawHalfSphere.
>>> I don't think the user should be aware of this and have to pick a suitable
>>> detailRatio.
>>
>> --
>> __________________________________________
>> Anders Backman, HPC2N
>> 90187 UmeƄ University, Sweden
>> [email protected] http://www.hpc2n.umu.se
>> Cell: +46-70-392 64 67
>>
>> _______________________________________________
>> osg-submissions mailing list
>> [email protected]
>> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
>>
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to