]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
ODE: experimental 'erp' field for per-entity control of Error Restitution (was only...
authorvortex <vortex@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 8 Dec 2011 23:22:00 +0000 (23:22 +0000)
committerRudolf Polzer <divverent@xonotic.org>
Fri, 9 Dec 2011 13:06:21 +0000 (14:06 +0100)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11604 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=f052f75917ec06f67495b941f5faa4a315fa09fa

prvm_offsets.h
world.c

index 639240ea52305c0a2a7d221cb217f7f8285ec060..d194b1fd358b11eff9246d1847ab6cada4f0b309 100644 (file)
@@ -31,6 +31,7 @@ PRVM_DECLARE_clientfieldfloat(lerpfrac4)
 PRVM_DECLARE_clientfieldfloat(mass)
 PRVM_DECLARE_clientfieldvector(massofs)
 PRVM_DECLARE_clientfieldfloat(friction)
+PRVM_DECLARE_clientfieldfloat(erp)
 PRVM_DECLARE_clientfieldfloat(modelindex)
 PRVM_DECLARE_clientfieldfloat(movetype)
 PRVM_DECLARE_clientfieldfloat(nextthink)
@@ -311,6 +312,7 @@ PRVM_DECLARE_field(ltime)
 PRVM_DECLARE_field(mass)
 PRVM_DECLARE_field(massofs)
 PRVM_DECLARE_field(friction)
+PRVM_DECLARE_field(erp)
 PRVM_DECLARE_field(max_health)
 PRVM_DECLARE_field(maxs)
 PRVM_DECLARE_field(message)
@@ -670,6 +672,7 @@ PRVM_DECLARE_serverfieldfloat(ltime)
 PRVM_DECLARE_serverfieldfloat(mass)
 PRVM_DECLARE_serverfieldvector(massofs)
 PRVM_DECLARE_serverfieldfloat(friction)
+PRVM_DECLARE_serverfieldfloat(erp)
 PRVM_DECLARE_serverfieldfloat(max_health)
 PRVM_DECLARE_serverfieldfloat(modelflags)
 PRVM_DECLARE_serverfieldfloat(modelindex)
diff --git a/world.c b/world.c
index 5e14511944930347b4766500b1ef6a07fdb74c9c..fa1ccbc7e33da9b46756bd0de88b3cece73f46a1 100644 (file)
--- a/world.c
+++ b/world.c
@@ -2527,6 +2527,7 @@ static void nearCallback (void *data, dGeomID o1, dGeomID o2)
        float bouncestop1 = 60.0f / 800.0f;
        float bouncefactor2 = 0.0f;
        float bouncestop2 = 60.0f / 800.0f;
+       float erp;
        dVector3 grav;
        prvm_edict_t *ed1, *ed2;
 
@@ -2606,6 +2607,10 @@ static void nearCallback (void *data, dGeomID o1, dGeomID o2)
        dWorldGetGravity((dWorldID)world->physics.ode_world, grav);
        bouncestop1 *= fabs(grav[2]);
 
+       // get erp
+       // select object that moves faster ang get it's erp
+       erp = (VectorLength2(PRVM_gameedictvector(ed1, velocity)) > VectorLength2(PRVM_gameedictvector(ed2, velocity))) ? PRVM_gameedictfloat(ed1, erp) : PRVM_gameedictfloat(ed2, erp);
+
        // generate contact points between the two non-space geoms
        numcontacts = dCollide(o1, o2, MAX_CONTACTS, &(contact[0].geom), sizeof(contact[0]));
        // add these contact points to the simulation
@@ -2613,7 +2618,7 @@ static void nearCallback (void *data, dGeomID o1, dGeomID o2)
        {
                contact[i].surface.mode = (physics_ode_contact_mu.value != -1 ? dContactApprox1 : 0) | (physics_ode_contact_erp.value != -1 ? dContactSoftERP : 0) | (physics_ode_contact_cfm.value != -1 ? dContactSoftCFM : 0) | (bouncefactor1 > 0 ? dContactBounce : 0);
                contact[i].surface.mu = physics_ode_contact_mu.value * ed1->priv.server->ode_friction * ed2->priv.server->ode_friction;
-               contact[i].surface.soft_erp = physics_ode_contact_erp.value;
+               contact[i].surface.soft_erp = physics_ode_contact_erp.value + erp;
                contact[i].surface.soft_cfm = physics_ode_contact_cfm.value;
                contact[i].surface.bounce = bouncefactor1;
                contact[i].surface.bounce_vel = bouncestop1;