[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Enigma-cvs] enigma/src world.cc,1.72.2.10,1.72.2.11
From: |
Daniel Heck <address@hidden> |
Subject: |
[Enigma-cvs] enigma/src world.cc,1.72.2.10,1.72.2.11 |
Date: |
Wed, 08 Oct 2003 20:00:21 +0000 |
Update of /cvsroot/enigma/enigma/src
In directory subversions:/tmp/cvs-serv17295/src
Modified Files:
Tag: enigma0_80_rc
world.cc
Log Message:
Fixed actor-actor collision handling (actors don't get stuck if overlapping)
Index: world.cc
===================================================================
RCS file: /cvsroot/enigma/enigma/src/world.cc,v
retrieving revision 1.72.2.10
retrieving revision 1.72.2.11
diff -C2 -d -r1.72.2.10 -r1.72.2.11
*** world.cc 6 Oct 2003 19:27:44 -0000 1.72.2.10
--- world.cc 8 Oct 2003 20:00:18 -0000 1.72.2.11
***************
*** 663,667 ****
ActorInfo &a1 = *actor1->get_actorinfo();
! // list of current contacts is updated in this function
a1.contact_normals.clear();
--- 663,667 ----
ActorInfo &a1 = *actor1->get_actorinfo();
! // List of current contacts is updated in this function
a1.contact_normals.clear();
***************
*** 681,685 ****
*/
V2 p1 = a1.pos;
- double r1 = a1.radius;
double m1 = a1.mass;
--- 681,684 ----
***************
*** 688,701 ****
{
Actor *actor2 = level->actorlist[j];
! ActorInfo &a2 = *actor2->get_actorinfo();
if (actor2 == actor1 || a2.grabbed)
continue;
! V2 p2 = a2.pos;
! double r2 = a2.radius;
!
! bool contactp = length(p1-p2) < r1+r2;
! if (contactp)
{
V2 n = normalize(p1-p2); // normal to contact surface
--- 687,698 ----
{
Actor *actor2 = level->actorlist[j];
! ActorInfo &a2 = *actor2->get_actorinfo();
if (actor2 == actor1 || a2.grabbed)
continue;
! V2 p2 = a2.pos;
! double overlap = a1.radius + a2.radius - length(p1-p2);
! if (overlap > 0)
{
V2 n = normalize(p1-p2); // normal to contact surface
***************
*** 703,710 ****
V2 v2 = n * (a2.vel*n);
- 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);
--- 700,708 ----
V2 v2 = n * (a2.vel*n);
bool collisionp = (a1.vel-a2.vel)*n < 0;
! if (collisionp)
! {
! a1.pos = a1.oldpos; // Reset actor position
!
actor1->on_hit(actor2);
actor2->on_hit(actor1);
***************
*** 713,718 ****
(actor1->is_on_floor() ==
actor2->is_on_floor()));
!
! if (reboundp) {
double m2 = a2.mass;
double M = m1+m2;
--- 711,715 ----
(actor1->is_on_floor() ==
actor2->is_on_floor()));
! if (reboundp) {
double m2 = a2.mass;
double M = m1+m2;
***************
*** 720,725 ****
double restitution = 0.95;
-
-
a1.vel += -v1 + (v2*(2*m2) + v1*(m1-m2)) / M;
a2.vel += -v2 + (v1*(2*m1) + v2*(m2-m1)) / M;
--- 717,720 ----
***************
*** 727,730 ****
--- 722,726 ----
a1.vel *= restitution;
a2.vel *= restitution;
+
sound::PlaySound("ballcollision");
***************
*** 744,750 ****
double rest_time = dtime;
! double dt = 0.0025; //dtime;
! handle_contacts(a, 0.0);
while (rest_time > 0 && !ai.grabbed)
{
--- 740,746 ----
double rest_time = dtime;
! double dt = 0.0025; // Size of one time step -- do not change!
! // handle_contacts(a, 0.0);
while (rest_time > 0 && !ai.grabbed)
{
***************
*** 994,1001 ****
}
! /*
! ** Searches all signals for a signal starting at 'src' and returns the
! ** target object. If multiple signals start from 'src' this function
! ** returns 0.
*/
Object *world::FindSignalDestination(Object *src)
--- 990,996 ----
}
! /* Searches all signals for a signal starting at 'src' and returns the
! target object. If multiple signals start from 'src' this function
! returns 0.
*/
Object *world::FindSignalDestination(Object *src)
***************
*** 1429,1434 ****
}
! void
! world::Init()
{
actors::Init();
--- 1424,1428 ----
}
! void world::Init()
{
actors::Init();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Enigma-cvs] enigma/src world.cc,1.72.2.10,1.72.2.11,
Daniel Heck <address@hidden> <=