Update to ZDoom r1062:

- Rewrote myvsnprintf to use the StringFormat routines directly so that no
  additional memory needs to be allocated from the heap.
- Polyobject sounds now play from their lines, similar to the way sector
  sounds are handled.
- Why do polyobjects have a 3D start spot? Flattened it to 2D.
- Moved the sector sound origin calculation out of fmodsound.cpp and into
  s_sound.cpp so that the near sound limiting will use the correct sound
  location for deciding on neighbors.
- Removed the S_Sound() variant that allows for pointing the origin at an
  arbitrary point. It has been replaced with a variant that takes a polyobject
  as a source, since that was the only use that couldn't be rewritten with the
  other variants. This also fixes the bug that polyobject sounds were not
  successfully saved and caused a crash when reloading the game. Note that
  this is a significant change to how equality of sound sources is determined,
  so some things may not behave quite the same as before. (Which would be a
  bug, but hopefully everything still sounds the same.)
- Adjusted the noise debug table so that fractional volume levels do not
  run into the adjacent columns.
- Added a NullSoundRenderer so that most of the checks against a NULL GSnd
  can be removed.
- Fixed: Looping sounds must always successfully allocate a channel, even if
  it's only a pre-evicted channel.
- Added A_ClearReFire code pointer for weapons. Preferably A_WeaponReady should
  reset this counter but that can't be done due to unwanted side effects with
  existing weapons.
- Changed the 'scale' variable in CVAR(turbo) to double because the calculations
  depended on the current floating point precision setting and only worked properly
  when set to 'precise' in VC++.

git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@130 b0f79afe-0144-0410-b225-9a4edf0717df
This commit is contained in:
Christoph Oelckers 2008-07-04 16:54:29 +00:00
parent f4dbbf934b
commit bc28486753
56 changed files with 1003 additions and 513 deletions

View file

@ -1671,6 +1671,75 @@ bool PO_Busy (int polyobj)
}
}
//===========================================================================
//
// PO_ClosestPoint
//
// Given a point (x,y), returns the point (ox,oy) on the polyobject's walls
// that is nearest to (x,y). Also returns the seg this point came from.
//
//===========================================================================
void PO_ClosestPoint(const FPolyObj *poly, fixed_t fx, fixed_t fy, fixed_t &ox, fixed_t &oy, seg_t **seg)
{
int i;
double x = fx, y = fy;
double bestdist = HUGE_VAL;
double bestx = 0, besty = 0;
seg_t *bestseg = NULL;
for (i = 0; i < poly->numsegs; ++i)
{
vertex_t *v1 = poly->segs[i]->v1;
vertex_t *v2 = poly->segs[i]->v2;
double a = v2->x - v1->x;
double b = v2->y - v1->y;
double den = a*a + b*b;
double ix, iy, dist;
if (den == 0)
{ // Line is actually a point!
ix = v1->x;
iy = v1->y;
}
else
{
double num = (x - v1->x) * a + (y - v1->y) * b;
double u = num / den;
if (u <= 0)
{
ix = v1->x;
iy = v1->y;
}
else if (u >= 1)
{
ix = v2->x;
iy = v2->y;
}
else
{
ix = v1->x + u * a;
iy = v1->y + u * b;
}
}
a = (ix - x);
b = (iy - y);
dist = a*a + b*b;
if (dist < bestdist)
{
bestdist = dist;
bestx = ix;
besty = iy;
bestseg = poly->segs[i];
}
}
ox = fixed_t(bestx);
oy = fixed_t(besty);
if (seg != NULL)
{
*seg = bestseg;
}
}
FPolyObj::~FPolyObj()
{
@ -1699,4 +1768,4 @@ FPolyObj::~FPolyObj()
delete[] prevPts;
prevPts = NULL;
}
}
}