gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r9586: collision detection fixes, mi


From: Sandro Santilli
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r9586: collision detection fixes, minor cleanups to remoting
Date: Tue, 12 Aug 2008 20:32:03 +0200
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 9586
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Tue 2008-08-12 20:32:03 +0200
message:
  collision detection fixes, minor cleanups to remoting
modified:
  libcore/asobj/NetConnection.cpp
  libcore/parser/shape_character_def.cpp
  libcore/shape.h
    ------------------------------------------------------------
    revno: 9582.1.8
    committer: Sandro Santilli <address@hidden>
    branch nick: mybranch
    timestamp: Tue 2008-08-12 19:48:51 +0200
    message:
      Have distance function take double instead of int, drop the shortcut
      testing for point-in-boundary as it'd fail if non-scaled strokes are 
      present.
    modified:
      libcore/parser/shape_character_def.cpp
      libcore/shape.h
    ------------------------------------------------------------
    revno: 9582.1.9
    committer: Sandro Santilli <address@hidden>
    branch nick: mybranch
    timestamp: Tue 2008-08-12 20:16:01 +0200
    message:
      comment out useless boundary checking (for now)
    modified:
      libcore/parser/shape_character_def.cpp
    ------------------------------------------------------------
    revno: 9582.1.10
    committer: Sandro Santilli <address@hidden>
    branch nick: mybranch
    timestamp: Tue 2008-08-12 20:28:43 +0200
    message:
      delete connection on error
    modified:
      libcore/asobj/NetConnection.cpp
=== modified file 'libcore/asobj/NetConnection.cpp'
--- a/libcore/asobj/NetConnection.cpp   2008-08-12 15:31:43 +0000
+++ b/libcore/asobj/NetConnection.cpp   2008-08-12 18:28:43 +0000
@@ -577,16 +577,17 @@
                                log_debug("connection is in error condition, 
calling NetConnection.onStatus");
                                reply_start = 0;
                                reply_end = 0;
+                               log_debug("deleting connection");
+                               connection.reset(); // reset connection before 
calling the callback
 
                                // FIXME: should only call NetConnection's 
onStatus
                                //        if the IOChannel is in error 
condition.
                                //        (tipically 404).
                                //        When the response is empty, just 
nothing happens.
                                _nc.callMethod(NSV::PROP_ON_STATUS, as_value());
-                               return;
+
                        }
-                       
-                       if(connection->eof() )
+                       else if(connection->eof() )
                        {
                                if ( reply_end > 8)
                                {

=== modified file 'libcore/parser/shape_character_def.cpp'
--- a/libcore/parser/shape_character_def.cpp    2008-08-10 17:08:19 +0000
+++ b/libcore/parser/shape_character_def.cpp    2008-08-12 18:16:01 +0000
@@ -812,10 +812,16 @@
 
         bool even_odd = true;  // later we will need non-zero for glyphs... 
(TODO)
 
-        if (m_bound.point_test(x, y) == false)
-        {
-            return false;
-        }
+       // FIXME: if the shape contains non-scaled strokes
+       //        we can't rely on boundary itself for a quick
+       //        way out. Bounds supposedly already include
+       //        thickness, so we might keep a flag telling us
+       //        whether *non_scaled* strokes are present
+       //        and if not still use the boundary check.
+        //if (m_bound.point_test(x, y) == false)
+        //{
+               //return false;
+        //}
 
         unsigned npaths = m_paths.size();
         int counter = 0;
@@ -859,15 +865,17 @@
                     // TODO: pass the matrix to withinSquareDistance instead ?
                     double xScale = wm.get_x_scale();
                     double yScale = wm.get_y_scale();
-                    thickness /= std::max(xScale, yScale);
+                       //log_debug("thickness:%d, xScale:%g, yScale:%g", 
thickness, xScale, yScale);
+                    thickness *= std::max(xScale, yScale);
+                       //log_debug("after scaling, thickness:%d", thickness);
                 }
                 else if ( ls.scaleThicknessVertically() != 
ls.scaleThicknessHorizontally() )
                 {
                     LOG_ONCE( log_unimpl("Collision detection for 
unidirectionally scaled strokes") );
                 }
 
-                double  dist = thickness / 2.0;
-                boost::int64_t  sqdist = static_cast<boost::int64_t>(dist * 
dist); 
+                double dist = thickness / 2.0;
+                double sqdist = dist * dist;
                 if (pth.withinSquareDistance(pt, sqdist))
                     return true;
             }

=== modified file 'libcore/shape.h'
--- a/libcore/shape.h   2008-07-09 07:33:34 +0000
+++ b/libcore/shape.h   2008-08-12 17:48:51 +0000
@@ -82,7 +82,7 @@
     }
 
     /// Return squared distance between point pt and segment A-B
-    static boost::int64_t
+    static double
     squareDistancePtSeg(const point& p, const point& A, const point& B)
     {
         boost::int32_t dx = B.x - A.x;
@@ -96,7 +96,7 @@
         boost::int32_t pdx = p.x - A.x;
         boost::int32_t pdy = p.y - A.y;
 
-        float u = ( (float)(pdx) * dx + (float)(pdy) * dy ) / ( (float)(dx)*dx 
+ (float)(dy)*dy );
+        double u = ( (double)(pdx) * dx + (double)(pdy) * dy ) / ( 
(double)(dx)*dx + (double)(dy)*dy );
 
         if (u <= 0)
         {
@@ -108,16 +108,16 @@
             return p.squareDistance(B);
         }
 
-        point px(A, B, u);
+        point px(A, B, u); // FIXME: this interpolation introduce a precision 
loss (point is int-based)
         return p.squareDistance(px);
     }
 
     /// Return distance between point pt and segment A-B
-    static boost::int32_t
+    static double
     distancePtSeg(const point& pt, const point& A, const point& B)
     {
-        boost::int64_t  square = squareDistancePtSeg(pt, A, B);
-        return (boost::int32_t)( std::sqrt(square) );
+        double square = squareDistancePtSeg(pt, A, B);
+        return std::sqrt(square);
     }
 
     /// Find point of the quadratic curve defined by points A,C,B
@@ -412,7 +412,7 @@
     /// NOTE: if the path is empty, false is returned.
     ///
     bool
-    withinSquareDistance(const point& p, boost::int64_t dist) const
+    withinSquareDistance(const point& p, double dist) const
     {
       size_t nedges = m_edges.size();
 
@@ -426,7 +426,7 @@
 
         if ( e.isStraight() )
         {
-          boost::int64_t  d = Edge::squareDistancePtSeg(p, px, np);
+          double d = Edge::squareDistancePtSeg(p, px, np);
 
           if ( d <= dist ) return true;
         }
@@ -453,7 +453,7 @@
 
             // distance from point and segment being an approximation 
             // of the curve 
-            boost::int64_t  d = Edge::squareDistancePtSeg(p, p0, p1);
+            double d = Edge::squareDistancePtSeg(p, p0, p1);
             if ( d <= dist ) return true;
 
             p0.setTo(p1.x, p1.y);


reply via email to

[Prev in Thread] Current Thread [Next in Thread]