[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Enigma-cvs] enigma/src world.cc, 1.72.2.8, 1.72.2.9 actors.cc, 1.41.2.5
From: |
Daniel Heck <address@hidden> |
Subject: |
[Enigma-cvs] enigma/src world.cc, 1.72.2.8, 1.72.2.9 actors.cc, 1.41.2.5, 1.41.2.6 |
Date: |
Sun, 05 Oct 2003 13:34:52 +0000 |
Update of /cvsroot/enigma/enigma/src
In directory subversions:/tmp/cvs-serv29441/src
Modified Files:
Tag: enigma0_80_rc
world.cc actors.cc
Log Message:
* Improved actor-actor collision handlnig
Index: actors.cc
===================================================================
RCS file: /cvsroot/enigma/enigma/src/actors.cc,v
retrieving revision 1.41.2.5
retrieving revision 1.41.2.6
diff -C2 -d -r1.41.2.5 -r1.41.2.6
*** actors.cc 3 Oct 2003 22:22:59 -0000 1.41.2.5
--- actors.cc 5 Oct 2003 13:34:49 -0000 1.41.2.6
***************
*** 348,352 ****
}
! bool is_dead() { return state == DEAD; }
bool is_flying() { return state == JUMPING; }
bool is_on_floor();
--- 348,352 ----
}
! bool is_dead();
bool is_flying() { return state == JUMPING; }
bool is_on_floor();
***************
*** 395,398 ****
--- 395,404 ----
ai->mass = mass;
}
+
+ bool BasicBall::is_dead()
+ {
+ return state == DEAD || state==RESURRECTED;
+ }
+
bool BasicBall::is_on_floor()
Index: world.cc
===================================================================
RCS file: /cvsroot/enigma/enigma/src/world.cc,v
retrieving revision 1.72.2.8
retrieving revision 1.72.2.9
diff -C2 -d -r1.72.2.8 -r1.72.2.9
*** world.cc 4 Oct 2003 10:44:08 -0000 1.72.2.8
--- world.cc 5 Oct 2003 13:34:49 -0000 1.72.2.9
***************
*** 465,475 ****
// If the actor is currently in contact with other objects, remove
// the force components in the direction of these objects.
! for (unsigned i=0; i<ai.contact_normals.size(); ++i)
! {
! const V2 &normal = ai.contact_normals[i];
! double normal_component = normal * ai.vel;
! if (normal_component < 0)
! ai.vel -= normal_component * normal;
! }
ai.pos += h*ai.vel;
--- 465,475 ----
// If the actor is currently in contact with other objects, remove
// the force components in the direction of these objects.
! // for (unsigned i=0; i<ai.contact_normals.size(); ++i)
! // {
! // const V2 &normal = ai.contact_normals[i];
! // double normal_component = normal * ai.vel;
! // if (normal_component < 0)
! // ai.vel -= normal_component * normal;
! // }
ai.pos += h*ai.vel;
***************
*** 690,698 ****
{
Actor *actor2 = level->actorlist[j];
! if (actor2 == actor1)
! continue;
- ActorInfo &a2 = *actor2->get_actorinfo();
V2 p2 = a2.pos;
double r2 = a2.radius;
--- 690,698 ----
{
Actor *actor2 = level->actorlist[j];
! ActorInfo &a2 = *actor2->get_actorinfo();
+ if (actor2 == actor1 || a2.grabbed)
+ continue;
V2 p2 = a2.pos;
double r2 = a2.radius;
***************
*** 707,724 ****
a1.pos = a1.oldpos; // Reset actor position
! bool collisionp = (v2-v1)*(p2-p1) < 0;
! bool reboundp = (!actor1->is_dead() && !actor2->is_dead() &&
! (actor1->is_on_floor() == actor2->is_on_floor()));
!
if (collisionp) {
- double m2 = a2.mass;
- double M = m1+m2;
-
- double restitution = 0.95;
-
actor1->on_hit(actor2);
actor2->on_hit(actor1);
if (reboundp) {
a1.vel += -v1 + (v2*(2*m2) + v1*(m1-m2)) / M;
a2.vel += -v2 + (v1*(2*m1) + v2*(m2-m1)) / M;
--- 707,727 ----
a1.pos = a1.oldpos; // Reset actor position
! bool collisionp = (a1.vel-a2.vel)*n < 0;
if (collisionp) {
actor1->on_hit(actor2);
actor2->on_hit(actor1);
+
+ bool reboundp = (!actor1->is_dead() && !actor2->is_dead() &&
+ (actor1->is_on_floor() ==
actor2->is_on_floor()));
+
if (reboundp) {
+ double m2 = a2.mass;
+ double M = m1+m2;
+
+ double restitution = 0.95;
+
+
+
a1.vel += -v1 + (v2*(2*m2) + v1*(m1-m2)) / M;
a2.vel += -v2 + (v1*(2*m1) + v2*(m2-m1)) / M;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Enigma-cvs] enigma/src world.cc, 1.72.2.8, 1.72.2.9 actors.cc, 1.41.2.5, 1.41.2.6,
Daniel Heck <address@hidden> <=