/[enigma]/enigma/world.cc
ViewVC logotype

Diff of /enigma/world.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.27 by dheck, Sat Dec 14 23:43:06 2002 UTC revision 1.28 by dheck, Wed Dec 18 22:48:43 2002 UTC
# Line 404  find_contact_with_stone(Actor *a, StoneC Line 404  find_contact_with_stone(Actor *a, StoneC
404     rebounds from any one (or even both) corners, because it changes     rebounds from any one (or even both) corners, because it changes
405     the direction of the marble quite unpredictably.     the direction of the marble quite unpredictably.
406    
407     This function modified the contact information for two adjacent     This function modifies the contact information for two adjacent
408     stones in such a way that the two collisions are treated as a     stones in such a way that the two collisions are treated as a
409     single collision with a flat surface.     single collision with a flat surface.
410   */   */
# Line 414  maybe_join_contacts (StoneContact & a, S Line 414  maybe_join_contacts (StoneContact & a, S
414      double maxd = 4.0/32;   // Max distance between joinable collisions      double maxd = 4.0/32;   // Max distance between joinable collisions
415    
416      if (a.stone && b.stone && (a.is_contact || b.is_contact)  &&      if (a.stone && b.stone && (a.is_contact || b.is_contact)  &&
417            a.is_collision && b.is_collision &&
418          a.response==STONE_REBOUND && b.response==STONE_REBOUND) // &&          a.response==STONE_REBOUND && b.response==STONE_REBOUND) // &&
419  //        length(a.contact_point - b.contact_point) <= maxd)  //        length(a.contact_point - b.contact_point) <= maxd)
420      {      {
# Line 444  find_stone_contacts(Actor *a, StoneConta Line 445  find_stone_contacts(Actor *a, StoneConta
445  {  {
446      ActorInfo &ai = *a->get_actorinfo();      ActorInfo &ai = *a->get_actorinfo();
447      px::Rect r(int(ai.pos[0]-0.5), int(ai.pos[1]-0.5),      px::Rect r(int(ai.pos[0]-0.5), int(ai.pos[1]-0.5),
448             int(ai.pos[0]+0.5), int(ai.pos[1]+0.5));                 int(ai.pos[0]+0.5), int(ai.pos[1]+0.5));
449      r.w -= r.x;      r.w -= r.x;
450      r.h -= r.y;      r.h -= r.y;
451            
452      StoneContact contacts[2][2];      StoneContact contacts[2][2];
453            
454      // Test for collisions with the nearby stones      // Test for collisions with the nearby stones
455      for (int i=0; i<=r.w; i++) {      for (int i=0; i<=r.w; i++)
456          for (int j=0; j<=r.h; j++) {          for (int j=0; j<=r.h; j++)
457              find_contact_with_stone(a, contacts[i][j], r.x+i, r.y+j);              find_contact_with_stone(a, contacts[i][j], r.x+i, r.y+j);
458          }  
     }  
 #if 1  
459      maybe_join_contacts (contacts[0][0], contacts[1][0]);      maybe_join_contacts (contacts[0][0], contacts[1][0]);
460      maybe_join_contacts (contacts[0][0], contacts[0][1]);      maybe_join_contacts (contacts[0][0], contacts[0][1]);
461      maybe_join_contacts (contacts[1][0], contacts[1][1]);      maybe_join_contacts (contacts[1][0], contacts[1][1]);
462      maybe_join_contacts (contacts[0][1], contacts[1][1]);      maybe_join_contacts (contacts[0][1], contacts[1][1]);
463  #endif  
464      for (int i=0; i<=r.w; i++) {      for (int i=0; i<=r.w; i++)
465          for (int j=0; j<=r.h; j++) {          for (int j=0; j<=r.h; j++)
466              if (contacts[i][j].is_contact)              if (contacts[i][j].is_contact)
467                  cl.push_back(contacts[i][j]);                  cl.push_back(contacts[i][j]);
         }  
     }  
468  }  }
469    
470  static V3  static V3

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.28

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26