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

Diff of /enigma/src/world.cc

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

revision 1.72 by dheck, Fri Sep 12 21:46:25 2003 UTC revision 1.72.2.1 by dheck, Fri Sep 19 17:42:38 2003 UTC
# Line 860  handle_contacts(Actor *actor1, double to Line 860  handle_contacts(Actor *actor1, double to
860      double r1 = a1.radius;      double r1 = a1.radius;
861      double m1 = a1.mass;      double m1 = a1.mass;
862    
     if (!actor1->is_on_floor() || actor1->is_dead())  
         return;  
   
863      unsigned s=level->actorlist.size();      unsigned s=level->actorlist.size();
864      for (unsigned j=0; j<s; ++j)      for (unsigned j=0; j<s; ++j)
865      {      {
# Line 870  handle_contacts(Actor *actor1, double to Line 867  handle_contacts(Actor *actor1, double to
867          if (actor2 == actor1)          if (actor2 == actor1)
868              continue;              continue;
869    
         if (!actor2->is_on_floor() || actor2->is_dead())  
             continue;  
   
870    
871          ActorInfo &a2 = *actor2->get_actorinfo();          ActorInfo &a2 = *actor2->get_actorinfo();
872          V2         p2 = a2.pos;          V2         p2 = a2.pos;
# Line 888  handle_contacts(Actor *actor1, double to Line 882  handle_contacts(Actor *actor1, double to
882              a1.pos = a1.oldpos;         // Reset actor position              a1.pos = a1.oldpos;         // Reset actor position
883    
884              bool collisionp = (v2-v1)*(p2-p1) < 0;              bool collisionp = (v2-v1)*(p2-p1) < 0;
885                bool reboundp = (!actor1->is_dead() && !actor2->is_dead() &&
886                                 (actor1->is_on_floor() == actor2->is_on_floor()));
887    //     if (!actor1->is_on_floor() || actor1->is_dead())
888    //         return;
889    
890    //         if (!actor2->is_on_floor() || actor2->is_dead())
891    //             continue;
892    
893              if (collisionp) {              if (collisionp) {
894                  double m2 = a2.mass;                  double m2 = a2.mass;
895                  double M = m1+m2;                  double M = m1+m2;
# Line 896  handle_contacts(Actor *actor1, double to Line 898  handle_contacts(Actor *actor1, double to
898    
899                  actor1->on_hit(actor2);                  actor1->on_hit(actor2);
900                  actor2->on_hit(actor1);                  actor2->on_hit(actor1);
901                    
902                  a1.vel += -v1 + (v2*(2*m2) + v1*(m1-m2)) / M;                  if (reboundp) {
903                  a2.vel += -v2 + (v1*(2*m1) + v2*(m2-m1)) / M;                      a1.vel += -v1 + (v2*(2*m2) + v1*(m1-m2)) / M;
904                        a2.vel += -v2 + (v1*(2*m1) + v2*(m2-m1)) / M;
905                  a1.vel *= restitution;                      
906                  a2.vel *= restitution;                      a1.vel *= restitution;
907                  sound::PlaySound("ballcollision");                      a2.vel *= restitution;
908                        sound::PlaySound("ballcollision");
909                    }
910              }              }
911          }          }
912      }      }
# Line 950  tick_actor(Actor *a, double dtime) Line 954  tick_actor(Actor *a, double dtime)
954              dt = dt > rest_time? rest_time : dt;              dt = dt > rest_time? rest_time : dt;
955          }          }
956      }      }
     a->think(dtime);  
957  }  }
958    
959    
# Line 1634  world::Tick(double dtime) Line 1637  world::Tick(double dtime)
1637                  ai->forceacc = V2();                  ai->forceacc = V2();
1638                  tick_actor(*i, timestep);                  tick_actor(*i, timestep);
1639              }              }
1640                (*i)->think(timestep);
1641          }          }
1642    
1643          // Handle delayed impulses          // Handle delayed impulses

Legend:
Removed from v.1.72  
changed lines
  Added in v.1.72.2.1

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