Skip to content

Commit

Permalink
Fix issues with terrain alignment of structures (FAForever#4724)
Browse files Browse the repository at this point in the history
  • Loading branch information
Garanas authored Feb 23, 2023
1 parent 7f248cb commit 42634f9
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lua/defaultunits.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,14 @@ StructureUnit = ClassUnit(Unit) {
local flatten = physicsBlueprint.FlattenSkirt
if flatten then
self:FlattenSkirt()
end
end

-- check for terrain orientation
if not (
physicsBlueprint.AltitudeToTerrain or
physicsBlueprint.StandUpright
) and (flatten or physicsBlueprint.AlwaysAlignToTerrain)
and self.Layer == 'Land'
then
-- rotate structure to match terrain gradient
local a1, a2 = TerrainUtils.GetTerrainSlopeAngles(
Expand All @@ -90,8 +91,8 @@ StructureUnit = ClassUnit(Unit) {
blueprint.Footprint.SizeZ or physicsBlueprint.SkirtSizeZ
)

-- do not orientate structures that are on essentially flat ground
if MathAbs(a1) > 0.02 or MathAbs(a2) > 0.02 then
-- do not orientate structures that are on flat ground
if a1 != 0 or a2 != 0 then
self:SetOrientation(EulerToQuaternion(-1 * a1, a2, 0), true)

-- technically obsolete, but as this is part of an integration we don't want to break
Expand Down
1 change: 1 addition & 0 deletions units/UAB2101/UAB2101_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ UnitBlueprint {
LifeBarOffset = 0.35,
LifeBarSize = 0.9,
Physics = {
AlwaysAlignToTerrain = true,
BankingSlope = 0,
BuildOnLayerCaps = {
LAYER_Air = false,
Expand Down
1 change: 1 addition & 0 deletions units/UEB2101/UEB2101_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ UnitBlueprint {
LifeBarOffset = 0.35,
LifeBarSize = 0.9,
Physics = {
AlwaysAlignToTerrain = true,
BankingSlope = 0,
BuildOnLayerCaps = {
LAYER_Air = false,
Expand Down
1 change: 1 addition & 0 deletions units/URB2101/URB2101_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ UnitBlueprint {
LifeBarOffset = 0.25,
LifeBarSize = 0.75,
Physics = {
AlwaysAlignToTerrain = true,
BankingSlope = 0,
BuildOnLayerCaps = {
LAYER_Air = false,
Expand Down
1 change: 1 addition & 0 deletions units/XSB2101/XSB2101_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ UnitBlueprint {
LifeBarOffset = 0.4,
LifeBarSize = 0.9,
Physics = {
AlwaysAlignToTerrain = true,
BankingSlope = 0,
BuildOnLayerCaps = {
LAYER_Air = false,
Expand Down

0 comments on commit 42634f9

Please sign in to comment.