Game Development Community

[BUG 1.0.1] CorrectMuzzleVector Always On - RESOLVED

by Steve Acaster · in Torque 3D Professional · 11/03/2009 (12:36 pm) · 10 replies

Regardless of where a weapon is pointed, projectiles always head towards the eyenode's view. Regardless of it's bool, CorrectMuzzleVector appears to always return true.

img17.imageshack.us/img17/8503/muzzlecorrect.jpg
Pic related - weapon held at funny angle, projectiles ignore muzzle vector and head for eyenode vector (crosshair) even though the weapon's cs file has CorrectMuzzleVector = false;.

Accidentally noticed this whilst changing all of my animations.

#1
11/03/2009 (1:26 pm)
It's because in the getMuzzleTransform and getRenderMuzzleTransform there is this piece of code:
...
   // If we are in one of the standard player animations, adjust the
   // muzzle to point in the direction we are looking.
   if (mActionAnimation.action < PlayerData::NumTableActionAnims)
   {
      MatrixF xmat;
      xmat.set(EulerF(mHead.x, 0.0f, 0.0f));
      mat->mul(getTransform(),xmat);
      F32 *sp = nmat;
      F32 *dp = *mat;
      dp[3] = sp[3];
      dp[7] = sp[7];
      dp[11] = sp[11];
   }
   else
   {
      *mat = nmat;
   }
...

so indipendently from the value of correctMuzzleVector, the muzzle transform is always pointing towards the direction the player is looking.
To fix, remove all that block but leave only
*mat = nmat;
#2
11/04/2009 (11:33 am)
I was never really sure what CorrectMuzzleVector was intended to mean or control, so can anyone verify this is for sure what it is suppose to do?

If that is the case, then maybe I should make this change.

if (mActionAnimation.action < PlayerData::NumTableActionAnims && 
    !mDatablock->correctMuzzleVector )  
{  
...
}
else
{
   *mat = nmat;
}
#3
11/04/2009 (11:54 am)
Logged as THREED-796
#4
11/04/2009 (12:15 pm)
@James
I believe this is what it was for, when it was functioning back in the days of TGE - it's certainly what I'd used it for - though only to make sure my weapons mounted perfectly straight in testing.
#5
11/04/2009 (11:48 pm)
Hey Guys, Do you think this is the same issue or not?

The green line is from the muzzle point to rectile and the red is the path of the rocket to rectile.

www.bitSlap.me/FireingPos.jpg

The Fire and Smoke Effects are on the right point but the rockets vector is not from the tip of the gun.

Same thing with either:
correctMuzzleVector = false; or correctMuzzleVector = true;


#6
11/09/2009 (6:58 am)
James,
you don't need to add the "!mDatablock->correctMuzzleVector", if you remove the code as I wrote, the correctMuzzleVector still works ok, because that check is done in another part of the code
Usually, from script, you use getMuzzleVector function, and it is:
void ShapeBase::getMuzzleVector(U32 imageSlot,VectorF* vec)
{
   MatrixF mat;
   getMuzzleTransform(imageSlot,&mat);

   MountedImage& image = mMountedImageList[imageSlot];
   if (image.dataBlock->correctMuzzleVector)
      if (GameConnection * gc = getControllingClient())
         if (gc->isFirstPerson() && !gc->isAIControlled())
            if (getCorrectedAim(mat, vec))
               return;

   mat.getColumn(1,vec);
}

and, as you can see if correctMuzzleVector is true it get back the getCorrectedAim result, so there isn't the need to correct the muzzle vector also in the getMuzzleTransform function.
#7
11/09/2009 (7:02 am)
OmegaDog, I think your issue is exactly this, try to do the changes I wrote.
#8
11/09/2009 (11:51 am)
@Davide
That all seems to work fine for me.

With correctMuzzleVector on the projectiles head for the eyevVector/screen centre and with it set to false, they go straight along the Muzzle vector.

Doesn't appear to intefere with anything else, looks like a good fix.
#9
05/13/2010 (3:10 pm)
Added Davide's change to 1.1 beta 2.
#10
05/13/2010 (3:32 pm)
I thought that this was already fixed?

[edit]
CorrectMuzzleVector seems to work fine - in 1.1b1.

Only odd issue is that if I rotate the weapon as in the pic and export it like that, the rotation only shows up if useEyeOffset is on, but shoots along the rotated vector even if it's off. Not really a big deal though, I can't imagine anyone finding that neither useful nor problematic.

[DOUBLE EDIT]
Actually I had changed player.cpp code as in Davide's first post - but for reasons relating to another matter. I hadn't stuck the second code snippet in though. [triple edit] because it's already defined.