Some improvements and cleanups for Persistent Debris: Let them bounce, added drag and let them explode on hazardous walls

This commit is contained in:
zicodxx 2011-01-24 21:51:07 +01:00
parent 54097a9a3e
commit 7683527726
3 changed files with 10 additions and 6 deletions

View file

@ -4,6 +4,7 @@ D1X-Rebirth Changelog
--------
main/physics.c: Revamped what previously was the BUMP_HACK by checking if an object is actually intersecting a segment and move it out towards segment center just after the initial object movement composed by fvi and before velocity is made - should make inaccurate wall collisions a bit smoother and prevent objects from goind inside or through walls, too
main/physics.c: Added some new conditions to the bumping code: Only bump objects which can slide (alive robots and players) and added a count making sure this function can never get stuck in an infinite loop
main/collide.c, main/fireball.c: Some improvements and cleanups for Persistent Debris: Let them bounce, added drag and let them explode on hazardous walls
20110123
--------

View file

@ -589,7 +589,7 @@ void collide_weapon_and_wall( object * weapon, fix hitspeed, short hitseg, short
//##}
void collide_debris_and_wall( object * debris, fix hitspeed, short hitseg, short hitwall, vms_vector * hitpt) {
if (!PERSISTENT_DEBRIS)
if (!PERSISTENT_DEBRIS || TmapInfo[Segments[hitseg].sides[hitwall].tmap_num].damage)
explode_object(debris,0);
return;
}

View file

@ -237,7 +237,7 @@ object *object_create_debris(object *parent, int subobj_num)
&parent->orient,Polygon_models[parent->rtype.pobj_info.model_num].submodel_rads[subobj_num],
CT_DEBRIS,MT_PHYSICS,RT_POLYOBJ);
if ((objnum < 0 ) && (Highest_object_index >= MAX_OBJECTS-1) && !PERSISTENT_DEBRIS) {
if ((objnum < 0 ) && (Highest_object_index >= MAX_OBJECTS-1)) {
Int3();
return NULL;
}
@ -268,10 +268,7 @@ object *object_create_debris(object *parent, int subobj_num)
vm_vec_add2(&obj->mtype.phys_info.velocity,&parent->mtype.phys_info.velocity);
// -- used to be: Notice, not random! vm_vec_make(&obj->mtype.phys_info.rotvel,10*0x2000/3,10*0x4000/3,10*0x7000/3);
if (PERSISTENT_DEBRIS)
vm_vec_make(&obj->mtype.phys_info.rotvel, (d_rand() + 0x1000)/5, (d_rand()*2 + 0x4000)/5, (d_rand()*3 + 0x2000)/5);
else
vm_vec_make(&obj->mtype.phys_info.rotvel, d_rand() + 0x1000, d_rand()*2 + 0x4000, d_rand()*3 + 0x2000);
vm_vec_make(&obj->mtype.phys_info.rotvel, d_rand() + 0x1000, d_rand()*2 + 0x4000, d_rand()*3 + 0x2000);
vm_vec_zero(&obj->mtype.phys_info.rotthrust);
obj->lifeleft = 3*DEBRIS_LIFE/4 + fixmul(d_rand(), DEBRIS_LIFE); // Some randomness, so they don't all go away at the same time.
@ -279,6 +276,12 @@ object *object_create_debris(object *parent, int subobj_num)
obj->mtype.phys_info.mass = fixmuldiv(parent->mtype.phys_info.mass,obj->size,parent->size);
obj->mtype.phys_info.drag = 0; //fl2f(0.2); //parent->mtype.phys_info.drag;
if (PERSISTENT_DEBRIS)
{
obj->mtype.phys_info.flags |= PF_BOUNCE;
obj->mtype.phys_info.drag = 128;
}
return obj;
}