Revision: 8107
          http://playerstage.svn.sourceforge.net/playerstage/?rev=8107&view=rev
Author:   rtv
Date:     2009-07-23 22:17:18 +0000 (Thu, 23 Jul 2009)

Log Message:
-----------
fixed Z collision detection for blocks

Modified Paths:
--------------
    code/stage/trunk/libstage/block.cc

Modified: code/stage/trunk/libstage/block.cc
===================================================================
--- code/stage/trunk/libstage/block.cc  2009-07-23 19:14:37 UTC (rev 8106)
+++ code/stage/trunk/libstage/block.cc  2009-07-23 22:17:18 UTC (rev 8107)
@@ -160,26 +160,30 @@
   
   if( mod->vis.obstacle_return )
     // for every cell we may be rendered into
-       FOR_EACH( cell_it, *candidate_cells )
+        FOR_EACH( cell_it, *candidate_cells )
       {
-               // for every rendered into that cell
-               FOR_EACH( block_it, (*cell_it)->blocks )
-                 {
-                       Model* testmod = (*block_it)->mod;
-                       
-                       //printf( "   testing block %p of model %s\n", 
testblock, testmod->Token() );
-                       
-                       // if the tested model is an obstacle and it's not 
attached to this model
-                       if( (testmod != this->mod) &&
-                               testmod->vis.obstacle_return &&
-                               !mod->IsRelated( testmod ))
-                         {
-                               //puts( "HIT");
-                               return testmod; // bail immediately with the 
bad news
-                         }
-                 }
-      }
-  
+                 // for every block rendered into that cell
+                 FOR_EACH( block_it, (*cell_it)->blocks )
+                        {
+                               Block* testblock = *block_it;
+                               Model* testmod = testblock->mod;
+                               
+                               //printf( "   testing block %p of model %s\n", 
testblock, testmod->Token() );
+                               
+                               // if the tested model is an obstacle and it's 
not attached to this model
+                               if( (testmod != this->mod) &&
+                                        testmod->vis.obstacle_return &&
+                                        (!mod->IsRelated( testmod )) && 
+                                        // also must intersect in the Z range
+                                        testblock->global_z.min <= 
global_z.max && 
+                                        testblock->global_z.max >= 
global_z.min )
+                                 {
+                                        //puts( "HIT");
+                                        return testmod; // bail immediately 
with the bad news
+                                 }
+                        }
+               }
+
   //printf( "model %s block %p collision done. no hits.\n", mod->Token(), this 
);
   return NULL; // no hit
 }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to