Skip to content

Commit

Permalink
Fix #5656
Browse files Browse the repository at this point in the history
Not the best solution, I don't want to do the 100% accurate one before
the release
  • Loading branch information
ashdnazg committed Jul 17, 2017
1 parent 78dec6a commit f873597
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
9 changes: 8 additions & 1 deletion rts/Sim/Projectiles/ProjectileHandler.cpp
Expand Up @@ -534,7 +534,14 @@ void CProjectileHandler::CheckShieldCollisions(
if (!repulser->CanIntercept(wdef->interceptedByShieldType, p->GetAllyteamID()))
continue;

if (CCollisionHandler::DetectHit(repulser->owner, &repulser->collisionVolume, repulser->owner->GetTransformMatrix(true), ppos0, ppos1, &cq)) {
// we sometimes get false inside hits due to the movement of the shield
// a very hacky solution is to increase the ray that's intersecting
// by the last movement of the shield.
// it's not 100% accurate so there's a bit of a FIXME here to do a real solution
// (keep track in the projectile which shields it's in)

const float3 effectivePPos0 = ppos0 + (ppos0 - ppos1) * repulser->deltaPos.Length();
if (CCollisionHandler::DetectHit(repulser->owner, &repulser->collisionVolume, repulser->owner->GetTransformMatrix(true), effectivePPos0, ppos1, &cq)) {
if (!cq.InsideHit() || !repulser->weaponDef->exteriorShield || repulser->IsRepulsing(wpro)) {
if (repulser->IncomingProjectile(wpro, cq.GetHitPos()))
return;
Expand Down
10 changes: 7 additions & 3 deletions rts/Sim/Weapons/PlasmaRepulser.cpp
Expand Up @@ -31,7 +31,8 @@ CR_REG_METADATA(CPlasmaRepulser, (

CR_MEMBER(quads),
CR_MEMBER(collisionVolume),
CR_MEMBER(tempNum)
CR_MEMBER(tempNum),
CR_MEMBER(deltaPos)
))


Expand Down Expand Up @@ -108,11 +109,14 @@ void CPlasmaRepulser::Update()
hitFrames--;

UpdateWeaponVectors();
//
collisionVolume.SetOffsets((weaponMuzzlePos - owner->midPos));

collisionVolume.SetOffsets(weaponMuzzlePos - owner->midPos);
if (weaponMuzzlePos != lastPos)
quadField->MovedRepulser(this);

if (lastPos != ZeroVector)
deltaPos = weaponMuzzlePos - lastPos;

lastPos = weaponMuzzlePos;

segmentCollection->UpdateColor();
Expand Down
1 change: 1 addition & 0 deletions rts/Sim/Weapons/PlasmaRepulser.h
Expand Up @@ -44,6 +44,7 @@ class CPlasmaRepulser: public CWeapon
std::vector<int> quads;
CollisionVolume collisionVolume;
int tempNum;
float3 deltaPos;

private:
void FireImpl(const bool scriptCall) override final {}
Expand Down

0 comments on commit f873597

Please sign in to comment.