[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Fwd: Re: STK bug 2802727 and Ubuntu/Debian]



As upstream bts had some hints of a easy fixable rare crasher bug for
supertuxksart I asked if there would be some hint about which commits to
extract for the current 0.6.1a version. I got the attached patch.

As I'm on my way to spain with bad connectivity I'll first have a chance
to look at it on debconf so if anyone wants to pick that up ;)

Regards

  Christoph

---------------------------- Original Message ----------------------------
Subject: Re: STK bug 2802727 and Ubuntu/Debian
From:    "Joerg Henrichs" <joerg@luding.org>
Date:    Tue, July 14, 2009 2:48 am
To:      "Christoph Egger" <debian@christoph-egger.org>
Cc:      "M Gagnon" <auria.mg@gmail.com>
--------------------------------------------------------------------------

Hi Christoph,

attached a patch for 0.6.1a, which should fix the crash - we ported it
back from our irrlicht version, and hope it works as expected (which it
did for us).

Could you try this version, and see if the problem is fixed? It would be
very good if you could release a build which would give a stack trace in
case of a crash (or when run in the debugger at least), so that we have
some indication on what's wrong. if there should be another problem. As
Iv'e written before: this bug can't really explain why it crashes
frequently in one particular track.

Cheers,
    Joerg

Christoph Egger wrote:
> Hi!
>
> 	I was Pointed to sourceforge's bugpage and specifically 2802727[0]
> by Auria as I dropped in #stk conversation. Comment #3 mentions a
> patch that was applied into irrlicht-svn fixing some anoying bug.
>
> 	As it should be possible to fix that bug for the users of my .deb
> packages quite easily I'm considering to apply it there. Auria was
> thinking you might know off-hand where in svn history that patch got
> applied, can you help me here?
>
> Regards
>
> 	Christoph
>
> [0]
https://sourceforge.net/tracker/?func=detail&atid=981038&aid=2802727&group_id=202302

Index: items/rubber_band.cpp
===================================================================
--- items/rubber_band.cpp	(revision 3741)
+++ items/rubber_band.cpp	(working copy)
@@ -51,7 +51,7 @@
     vertices->add(0, 0, 0); vertices->add(0, 0, 0);
     vertices->add(0, 0, 0); vertices->add(0, 0, 0);
     m_attached_state = RB_TO_PLUNGER;
-    update(0);
+    updatePosition();
 
     sgVec3 norm;
     sgSetVec3(norm, 1/sqrt(2.0f), 0, 1/sqrt(2.0f));
@@ -80,6 +80,42 @@
 }   // removeFromScene
 
 // ----------------------------------------------------------------------------
+/** Updates the position of the rubber band. It especially sets the
+ *  end position of the rubber band, i.e. the side attached to the plunger,
+ *  track, or kart hit.
+ */
+void RubberBand::updatePosition()
+{
+    const Vec3 &k = m_owner.getXYZ();
+
+    // Get the position to which the band is attached
+    // ----------------------------------------------
+    switch(m_attached_state)
+    {
+    case RB_TO_KART:    m_end_position = m_hit_kart->getXYZ(); break;
+    case RB_TO_TRACK:   m_end_position = m_hit_position;       break;
+    case RB_TO_PLUNGER: m_end_position = m_plunger->getXYZ();
+                        checkForHit(k, m_end_position);        break;
+    }   // switch(m_attached_state);
+
+    // Update the rubber band positions
+    // --------------------------------
+    // Todo: make height dependent on length (i.e. rubber band gets
+    // thinner). And call explosion if the band is too long.
+    const float hh=.1f;  // half height of the band
+    const Vec3 &p=m_end_position;  // for shorter typing
+    float *f = vertices->get(0);
+    f[0] = p.getX()-hh; f[1] = p.getY(); f[2] = p.getZ()-hh;
+    f = vertices->get(1);
+    f[0] = p.getX()+hh; f[1] = p.getY(); f[2] = p.getZ()+hh;
+    f = vertices->get(2);
+    f[0] = k.getX()+hh; f[1] = k.getY(); f[2] = k.getZ()+hh;
+    f = vertices->get(3);
+    f[0] = k.getX()-hh; f[1] = k.getY(); f[2] = k.getZ()-hh;
+    dirtyBSphere();
+}   // updatePosition
+
+// ----------------------------------------------------------------------------
 /** Updates the rubber band. It takes the new position of the kart and the
  *  plunger, and sets the quad representing the rubber band appropriately.
  *  It then casts a ray along the rubber band to detect if anything is hit. If
@@ -97,38 +133,12 @@
         return;
     }
 
-    Vec3 p;
+    updatePosition();
     const Vec3 &k = m_owner.getXYZ();
-
-    // Get the position to which the band is attached
-    // ----------------------------------------------
-    switch(m_attached_state)
-    {
-    case RB_TO_KART:    p = m_hit_kart->getXYZ(); break;
-    case RB_TO_TRACK:   p = m_hit_position;       break;
-    case RB_TO_PLUNGER: p = m_plunger->getXYZ();
-                        checkForHit(k, p);        break;
-    }   // switch(m_attached_state);
-
-    // Draw the rubber band
-    // --------------------
-    // Todo: make height dependent on length (i.e. rubber band gets
-    // thinner). And call explosion if the band is too long.
-    const float hh=.1f;  // half height of the band
-  
-    float *f = vertices->get(0);
-    f[0] = p.getX()-hh; f[1] = p.getY(); f[2] = p.getZ()-hh;
-    f = vertices->get(1);
-    f[0] = p.getX()+hh; f[1] = p.getY(); f[2] = p.getZ()+hh;
-    f = vertices->get(2);
-    f[0] = k.getX()+hh; f[1] = k.getY(); f[2] = k.getZ()+hh;
-    f = vertices->get(3);
-    f[0] = k.getX()-hh; f[1] = k.getY(); f[2] = k.getZ()-hh;
-    dirtyBSphere();
-
+    
     // Check for rubber band snapping
     // ------------------------------
-    float l = (p-k).length2();
+    float l = (m_end_position-k).length2();
     float max_len = m_owner.getKartProperties()->getRubberBandMaxLength();
     if(l>max_len*max_len)
     {
@@ -143,7 +153,7 @@
     if(m_attached_state!=RB_TO_PLUNGER)
     {
         float force = m_owner.getKartProperties()->getRubberBandForce();
-        Vec3 diff   = p-k;
+        Vec3 diff   = m_end_position-k;
         
         // detach rubber band if kart gets very close to hit point
         if(m_attached_state==RB_TO_TRACK && diff.length2() < 10*10)
Index: items/rubber_band.hpp
===================================================================
--- items/rubber_band.hpp	(revision 3741)
+++ items/rubber_band.hpp	(working copy)
@@ -50,7 +50,12 @@
     /** State for rubber band. */
     ssgSimpleState *m_state;
 
+    /** Stores the end of the rubber band (i.e. the side attached to the 
+     *  plunger. */
+    Vec3                m_end_position;
+
     void checkForHit(const Vec3 &k, const Vec3 &p);
+    void updatePosition();
 
 public:
          RubberBand(Plunger *plunger, const Kart &kart);

Reply to: