Remove leftover old "for" loop below "foreach" in some places.

Add SWWMUtility.ToAngles(), temporarily until next Gutamatics update.
Some note stuff.
This commit is contained in:
Mari the Deer 2022-12-12 22:07:03 +01:00
commit 32d1037d66
5 changed files with 37 additions and 9 deletions

View file

@ -1660,7 +1660,6 @@ Class CompanionLamp : Actor
f.A_StartSound("lamp/disappear",CHAN_VOICE);
// carry over the moths
foreach ( m:moff )
for ( int i=0; i<moff.Size(); i++ )
{
if ( !m ) continue;
Vector3 whereto = level.Vec3Offset(m.pos,rel);

View file

@ -256,6 +256,34 @@ Class SWWMUtility
return r*(1,0,0), r*(0,-1,0), r*(0,0,1);
}
// included here until Gutamatics updates to use native quaternions
static clearscope double, double, double ToAngles( Quat q )
{
double angle = 0., pitch = 0., roll = 0.;
double stest = q.z*q.x-q.w*q.y;
double angY = 2.*(q.w*q.z+q.x*q.y);
double angX = 1.-2.*(q.y*q.y+q.z*q.z);
if ( stest < -.4999995 )
{
angle = atan2(angY,angX);
pitch = 90.;
roll = swwm_GM_GlobalMaths.Normalize180(angle+(2.*atan2(q.x,q.w)));
}
else if ( stest > .4999995 )
{
angle = atan2(angY,angX);
pitch = -90.;
roll = swwm_GM_GlobalMaths.Normalize180(angle+(2.*atan2(q.x,q.w)));
}
else
{
angle = atan2(angY,angX);
pitch = -asin(2.*stest);
roll = atan2(2.*(q.w*q.x+q.y*q.z),1.-2.*(q.x*q.x+q.y*q.y));
}
return angle, pitch, roll;
}
// for aiming and shooting
static clearscope Vector3 GetPlayerViewDir( Actor player )
{
@ -1582,7 +1610,6 @@ Class SWWMUtility
{
// see if any services can resolve this first
foreach ( sv:hnd.mergemonstersv )
for ( int i=0; i<hnd.mergemonstersv.Size(); i++ )
{
if ( !sv ) continue;
String res = sv.GetString("MergeMonster",stringArg:a.GetClassName());

View file

@ -1031,7 +1031,6 @@ Class BiosparkBeam : SWWMNonInteractiveActor
l.Activate(target,0,SPAC_Impact);
}
foreach ( hit:t.hitlist )
for ( int i=0; i<t.hitlist.Size(); i++ )
{
if ( !hit.hitactor ) continue;
if ( (hit.hitactor is 'BiosparkHitbox') && hit.hitactor.target )