Pass pre-combined rotations into the rendering code.
This commit is contained in:
@@ -183,8 +183,8 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
foreach (var v in draw)
|
||||
{
|
||||
var bounds = v.Model.Bounds(v.FrameFunc());
|
||||
var worldTransform = v.RotationFunc().Reverse().Aggregate(scaleTransform,
|
||||
(x, y) => OpenRA.Graphics.Util.MatrixMultiply(x, OpenRA.Graphics.Util.MakeFloatMatrix(y.AsMatrix())));
|
||||
var rotation = OpenRA.Graphics.Util.MakeFloatMatrix(v.RotationFunc().AsMatrix());
|
||||
var worldTransform = OpenRA.Graphics.Util.MatrixMultiply(scaleTransform, rotation);
|
||||
|
||||
var pxPos = pxOrigin + wr.ScreenVectorComponents(v.OffsetFunc());
|
||||
var screenTransform = OpenRA.Graphics.Util.MatrixMultiply(cameraTransform, worldTransform);
|
||||
@@ -241,8 +241,8 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
foreach (var v in draw)
|
||||
{
|
||||
var bounds = v.Model.Bounds(v.FrameFunc());
|
||||
var worldTransform = v.RotationFunc().Reverse().Aggregate(scaleTransform,
|
||||
(x, y) => OpenRA.Graphics.Util.MatrixMultiply(x, OpenRA.Graphics.Util.MakeFloatMatrix(y.AsMatrix())));
|
||||
var rotation = OpenRA.Graphics.Util.MakeFloatMatrix(v.RotationFunc().AsMatrix());
|
||||
var worldTransform = OpenRA.Graphics.Util.MatrixMultiply(scaleTransform, rotation);
|
||||
|
||||
var pxPos = pxOrigin + wr.ScreenVectorComponents(v.OffsetFunc());
|
||||
var screenTransform = OpenRA.Graphics.Util.MatrixMultiply(cameraTransform, worldTransform);
|
||||
|
||||
@@ -129,8 +129,8 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
foreach (var v in draw)
|
||||
{
|
||||
var bounds = v.Model.Bounds(v.FrameFunc());
|
||||
var worldTransform = v.RotationFunc().Reverse().Aggregate(scaleTransform,
|
||||
(x, y) => OpenRA.Graphics.Util.MatrixMultiply(x, OpenRA.Graphics.Util.MakeFloatMatrix(y.AsMatrix())));
|
||||
var rotation = OpenRA.Graphics.Util.MakeFloatMatrix(v.RotationFunc().AsMatrix());
|
||||
var worldTransform = OpenRA.Graphics.Util.MatrixMultiply(scaleTransform, rotation);
|
||||
|
||||
var pxPos = pxOrigin + wr.ScreenVectorComponents(v.OffsetFunc());
|
||||
var screenTransform = OpenRA.Graphics.Util.MatrixMultiply(cameraTransform, worldTransform);
|
||||
|
||||
@@ -57,9 +57,8 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
Func<WRot> quantizedTurret = () => body.QuantizeOrientation(turretOrientation(), facings);
|
||||
Func<WRot> quantizedBody = () => body.QuantizeOrientation(orientation(), facings);
|
||||
Func<WVec> barrelOffset = () => body.LocalToWorld((t.Offset + LocalOffset.Rotate(quantizedTurret())).Rotate(quantizedBody()));
|
||||
|
||||
yield return new ModelAnimation(model, barrelOffset, () => new[] { turretOrientation(), orientation() },
|
||||
() => false, () => 0, ShowShadow);
|
||||
Func<WRot> barrelOrientation = () => turretOrientation().Rotate(orientation());
|
||||
yield return new ModelAnimation(model, barrelOffset, barrelOrientation, () => false, () => 0, ShowShadow);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,13 +96,12 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
return body.LocalToWorld((turretLocalOffset + localOffset.Rotate(turretOrientation)).Rotate(qb));
|
||||
}
|
||||
|
||||
IEnumerable<WRot> BarrelRotation()
|
||||
WRot BarrelRotation()
|
||||
{
|
||||
var b = self.Orientation;
|
||||
var qb = body.QuantizeOrientation(self, b);
|
||||
yield return Info.LocalOrientation;
|
||||
yield return turreted.WorldOrientation(self) - b + WRot.FromYaw(b.Yaw - qb.Yaw);
|
||||
yield return qb;
|
||||
var t = turreted.WorldOrientation(self) - b + WRot.FromYaw(b.Yaw - qb.Yaw);
|
||||
return Info.LocalOrientation.Rotate(t).Rotate(qb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
var body = init.Actor.TraitInfo<BodyOrientationInfo>();
|
||||
var model = init.World.ModelCache.GetModelSequence(image, Sequence);
|
||||
yield return new ModelAnimation(model, () => WVec.Zero,
|
||||
() => new[] { body.QuantizeOrientation(orientation(), facings) },
|
||||
() => body.QuantizeOrientation(orientation(), facings),
|
||||
() => false, () => 0, ShowShadow);
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
|
||||
var model = self.World.ModelCache.GetModelSequence(rv.Image, info.Sequence);
|
||||
modelAnimation = new ModelAnimation(model, () => WVec.Zero,
|
||||
() => new[] { body.QuantizeOrientation(self, self.Orientation) },
|
||||
() => body.QuantizeOrientation(self, self.Orientation),
|
||||
() => IsTraitDisabled, () => 0, info.ShowShadow);
|
||||
|
||||
rv.Add(modelAnimation);
|
||||
|
||||
@@ -45,9 +45,10 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
Func<WVec> turretOffset = () => body.LocalToWorld(t.Offset.Rotate(orientation()));
|
||||
|
||||
var turretFacing = Turreted.TurretFacingFromInit(init, t);
|
||||
Func<WRot> turretBodyOrientation = () => WRot.FromYaw(turretFacing() - orientation().Yaw);
|
||||
yield return new ModelAnimation(model, turretOffset,
|
||||
() => new[] { turretBodyOrientation(), body.QuantizeOrientation(orientation(), facings) }, () => false, () => 0, ShowShadow);
|
||||
Func<WRot> turretOrientation = () => WRot.FromYaw(turretFacing() - orientation().Yaw)
|
||||
.Rotate(body.QuantizeOrientation(orientation(), facings));
|
||||
|
||||
yield return new ModelAnimation(model, turretOffset, turretOrientation, () => false, () => 0, ShowShadow);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,12 +72,11 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
() => IsTraitDisabled, () => 0, info.ShowShadow));
|
||||
}
|
||||
|
||||
IEnumerable<WRot> TurretRotation()
|
||||
WRot TurretRotation()
|
||||
{
|
||||
var b = self.Orientation;
|
||||
var qb = body.QuantizeOrientation(self, b);
|
||||
yield return turreted.WorldOrientation(self) - b + WRot.FromYaw(b.Yaw - qb.Yaw);
|
||||
yield return qb;
|
||||
return (turreted.WorldOrientation(self) - b + WRot.FromYaw(b.Yaw - qb.Yaw)).Rotate(qb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user