mirror of
https://github.com/dhewm/dhewm3-sdk.git
synced 2024-11-24 21:41:23 +00:00
Fix crash by assert in last RoE level (and maybe elsewhere)
The assertion in idBounds::operator-(const idBounds&) was triggered from idWeapon::Event_LaunchProjectiles() (ownerBounds - projBounds) It only happened when using the BFG. So I added a check to make sure calling operator- is legal. I guess this also caused #122
This commit is contained in:
parent
a5a46de8f9
commit
4ad1349113
2 changed files with 15 additions and 2 deletions
|
@ -3446,7 +3446,14 @@ void idWeapon::Event_LaunchProjectiles( int num_projectiles, float spread, float
|
||||||
// make sure the projectile starts inside the bounding box of the owner
|
// make sure the projectile starts inside the bounding box of the owner
|
||||||
if ( i == 0 ) {
|
if ( i == 0 ) {
|
||||||
muzzle_pos = muzzleOrigin + playerViewAxis[ 0 ] * 2.0f;
|
muzzle_pos = muzzleOrigin + playerViewAxis[ 0 ] * 2.0f;
|
||||||
if ( ( ownerBounds - projBounds).RayIntersection( muzzle_pos, playerViewAxis[0], distance ) ) {
|
|
||||||
|
// DG: sometimes the assertion in idBounds::operator-(const idBounds&) triggers
|
||||||
|
// (would get bounding box with negative volume)
|
||||||
|
// => check that before doing ownerBounds - projBounds (equivalent to the check in the assertion)
|
||||||
|
idVec3 obDiff = ownerBounds[1] - ownerBounds[0];
|
||||||
|
idVec3 pbDiff = projBounds[1] - projBounds[0];
|
||||||
|
bool boundsSubLegal = obDiff.x > pbDiff.x && obDiff.y > pbDiff.y && obDiff.z > pbDiff.z;
|
||||||
|
if ( boundsSubLegal && ( ownerBounds - projBounds ).RayIntersection( muzzle_pos, playerViewAxis[0], distance ) ) {
|
||||||
start = muzzle_pos + distance * playerViewAxis[0];
|
start = muzzle_pos + distance * playerViewAxis[0];
|
||||||
} else {
|
} else {
|
||||||
start = ownerBounds.GetCenter();
|
start = ownerBounds.GetCenter();
|
||||||
|
|
|
@ -2941,7 +2941,13 @@ void idWeapon::Event_LaunchProjectiles( int num_projectiles, float spread, float
|
||||||
// make sure the projectile starts inside the bounding box of the owner
|
// make sure the projectile starts inside the bounding box of the owner
|
||||||
if ( i == 0 ) {
|
if ( i == 0 ) {
|
||||||
muzzle_pos = muzzleOrigin + playerViewAxis[ 0 ] * 2.0f;
|
muzzle_pos = muzzleOrigin + playerViewAxis[ 0 ] * 2.0f;
|
||||||
if ( ( ownerBounds - projBounds).RayIntersection( muzzle_pos, playerViewAxis[0], distance ) ) {
|
// DG: sometimes the assertion in idBounds::operator-(const idBounds&) triggers
|
||||||
|
// (would get bounding box with negative volume)
|
||||||
|
// => check that before doing ownerBounds - projBounds (equivalent to the check in the assertion)
|
||||||
|
idVec3 obDiff = ownerBounds[1] - ownerBounds[0];
|
||||||
|
idVec3 pbDiff = projBounds[1] - projBounds[0];
|
||||||
|
bool boundsSubLegal = obDiff.x > pbDiff.x && obDiff.y > pbDiff.y && obDiff.z > pbDiff.z;
|
||||||
|
if ( boundsSubLegal && ( ownerBounds - projBounds ).RayIntersection( muzzle_pos, playerViewAxis[0], distance ) ) {
|
||||||
start = muzzle_pos + distance * playerViewAxis[0];
|
start = muzzle_pos + distance * playerViewAxis[0];
|
||||||
} else {
|
} else {
|
||||||
start = ownerBounds.GetCenter();
|
start = ownerBounds.GetCenter();
|
||||||
|
|
Loading…
Reference in a new issue